blob: de585e5a8e1b85818c33be8e5229b5fbf2fc7c30 [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/supports_user_data.h"
#include "content/common/content_export.h"
#include "content/public/browser/permission_type.h"
#include "third_party/blink/public/platform/modules/permissions/permission_status.mojom.h"
class GURL;
namespace content {
class RenderFrameHost;
// This class allows the content layer to manipulate permissions. It's behavior
// is defined by the embedder via PermissionControllerDelegate implementation.
class CONTENT_EXPORT PermissionController
: public base::SupportsUserData::Data {
// Constant retured when registering and subscribing if
// cancelling/unsubscribing at a later stage would have no effect.
static const int kNoPendingOperation = -1;
~PermissionController() override{};
// Returns the permission status of a given requesting_origin/embedding_origin
// tuple. This is not taking a RenderFrameHost because the call might happen
// outside of a frame context. Prefer GetPermissionStatusForFrame (below)
// whenever possible.
virtual blink::mojom::PermissionStatus GetPermissionStatus(
PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) = 0;
// Returns the permission status for a given frame. Use this over
// GetPermissionStatus whenever possible.
// TODO(raymes): Currently we still pass the |requesting_origin| as a separate
// parameter because we can't yet guarantee that it matches the last committed
// origin of the RenderFrameHost. See
virtual blink::mojom::PermissionStatus GetPermissionStatusForFrame(
PermissionType permission,
RenderFrameHost* render_frame_host,
const GURL& requesting_origin) = 0;
} // namespace content