Upload upstream chromium 120.0.6099.5
[platform/framework/web/chromium-efl.git] / components / permissions / permission_request_data.h
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.
4
5 #ifndef COMPONENTS_PERMISSIONS_PERMISSION_REQUEST_DATA_H_
6 #define COMPONENTS_PERMISSIONS_PERMISSION_REQUEST_DATA_H_
7
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"
13 #include "url/gurl.h"
14
15 namespace content {
16 struct PermissionRequestDescription;
17 }
18
19 namespace permissions {
20
21 class PermissionContextBase;
22
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);
30
31   PermissionRequestData(PermissionContextBase* context,
32                         const PermissionRequestID& id,
33                         bool user_gesture,
34                         const GURL& requesting_origin,
35                         const GURL& embedding_origin = GURL());
36
37   PermissionRequestData(RequestType request_type,
38                         bool user_gesture,
39                         const GURL& requesting_origin,
40                         const GURL& embedding_origin = GURL());
41
42   PermissionRequestData& operator=(const PermissionRequestData&) = delete;
43   PermissionRequestData(const PermissionRequestData&) = delete;
44
45   PermissionRequestData& operator=(PermissionRequestData&&);
46   PermissionRequestData(PermissionRequestData&&);
47
48   ~PermissionRequestData();
49
50   PermissionRequestData& WithRequestingOrigin(const GURL& origin) {
51     requesting_origin = origin;
52     return *this;
53   }
54
55   PermissionRequestData& WithEmbeddingOrigin(const GURL& origin) {
56     embedding_origin = origin;
57     return *this;
58   }
59
60   // The type of request.
61   absl::optional<RequestType> request_type;
62
63   //  Uniquely identifier of particular permission request.
64   PermissionRequestID id;
65
66   // Indicates the request is initiated by a user gesture.
67   bool user_gesture;
68
69   // Indicates the request is initiated from an embedded permission element.
70   bool embedded_permission_element_initiated;
71
72   // The origin on whose behalf this permission request is being made.
73   GURL requesting_origin;
74
75   // The origin of embedding frame (generally is the top level frame).
76   GURL embedding_origin;
77
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;
82 };
83
84 }  // namespace permissions
85
86 #endif  // COMPONENTS_PERMISSIONS_PERMISSION_REQUEST_DATA_H_