1 // Copyright 2023 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_PERMISSIONS_PERMISSION_REQUEST_DATA_H_
6 #define COMPONENTS_PERMISSIONS_PERMISSION_REQUEST_DATA_H_
8 #include "components/permissions/permission_request_id.h"
9 #include "components/permissions/request_type.h"
10 #include "third_party/abseil-cpp/absl/types/optional.h"
11 #include "third_party/blink/public/mojom/permissions/permission_status.mojom.h"
12 #include "ui/gfx/geometry/rect.h"
16 struct PermissionRequestDescription;
19 namespace permissions {
21 class PermissionContextBase;
23 // Holds information about `permissions::PermissionRequest`
24 struct PermissionRequestData {
25 PermissionRequestData(
26 PermissionContextBase* context,
27 const PermissionRequestID& id,
28 const content::PermissionRequestDescription& request_description,
29 const GURL& canonical_requesting_origin);
31 PermissionRequestData(PermissionContextBase* context,
32 const PermissionRequestID& id,
34 const GURL& requesting_origin,
35 const GURL& embedding_origin = GURL());
37 PermissionRequestData(RequestType request_type,
39 const GURL& requesting_origin,
40 const GURL& embedding_origin = GURL());
42 PermissionRequestData& operator=(const PermissionRequestData&) = delete;
43 PermissionRequestData(const PermissionRequestData&) = delete;
45 PermissionRequestData& operator=(PermissionRequestData&&);
46 PermissionRequestData(PermissionRequestData&&);
48 ~PermissionRequestData();
50 PermissionRequestData& WithRequestingOrigin(const GURL& origin) {
51 requesting_origin = origin;
55 PermissionRequestData& WithEmbeddingOrigin(const GURL& origin) {
56 embedding_origin = origin;
60 // The type of request.
61 absl::optional<RequestType> request_type;
63 // Uniquely identifier of particular permission request.
64 PermissionRequestID id;
66 // Indicates the request is initiated by a user gesture.
69 // Indicates the request is initiated from an embedded permission element.
70 bool embedded_permission_element_initiated;
72 // The origin on whose behalf this permission request is being made.
73 GURL requesting_origin;
75 // The origin of embedding frame (generally is the top level frame).
76 GURL embedding_origin;
78 // Anchor element position (in screen coordinates), gennerally when the
79 // permission request is made from permission element. Used to calculate
80 // position where the secondary prompt UI is expected to be shown.
81 absl::optional<gfx::Rect> anchor_element_position;
84 } // namespace permissions
86 #endif // COMPONENTS_PERMISSIONS_PERMISSION_REQUEST_DATA_H_