Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: chrome/browser/permissions/permission_manager.h

Issue 2046293002: Implement DelegationTracker for tracking delegated permissions to RenderFrameHosts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission-delegation-2-blink
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ 5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_
7 7
8 #include <unordered_map> 8 #include <unordered_map>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
11 #include "base/id_map.h" 11 #include "base/id_map.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "components/content_settings/core/browser/content_settings_observer.h" 14 #include "components/content_settings/core/browser/content_settings_observer.h"
15 #include "components/content_settings/core/common/content_settings.h" 15 #include "components/content_settings/core/common/content_settings.h"
16 #include "components/keyed_service/core/keyed_service.h" 16 #include "components/keyed_service/core/keyed_service.h"
17 #include "content/public/browser/permission_manager.h" 17 #include "content/public/browser/permission_manager.h"
18 #include "content/public/browser/permission_type.h"
18 19
19 class PermissionContextBase; 20 class PermissionContextBase;
20 class Profile; 21 class Profile;
21 22
22 namespace content { 23 namespace content {
23 enum class PermissionType;
24 class WebContents; 24 class WebContents;
25 }; // namespace content 25 }; // namespace content
26 26
27 class PermissionManager : public KeyedService, 27 class PermissionManager : public KeyedService,
28 public content::PermissionManager, 28 public content::PermissionManager,
29 public content_settings::Observer { 29 public content_settings::Observer {
30 public: 30 public:
31 static PermissionManager* Get(Profile* profile); 31 static PermissionManager* Get(Profile* profile);
32 32
33 explicit PermissionManager(Profile* profile); 33 explicit PermissionManager(Profile* profile);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // TODO(raymes): Refactor MediaPermission to not call GetPermissionContext. 71 // TODO(raymes): Refactor MediaPermission to not call GetPermissionContext.
72 // See crbug.com/596786. 72 // See crbug.com/596786.
73 friend class MediaPermission; 73 friend class MediaPermission;
74 74
75 class PendingRequest; 75 class PendingRequest;
76 using PendingRequestsMap = IDMap<PendingRequest, IDMapOwnPointer>; 76 using PendingRequestsMap = IDMap<PendingRequest, IDMapOwnPointer>;
77 77
78 struct Subscription; 78 struct Subscription;
79 using SubscriptionsMap = IDMap<Subscription, IDMapOwnPointer>; 79 using SubscriptionsMap = IDMap<Subscription, IDMapOwnPointer>;
80 80
81 struct PermissionTypeHash {
82 std::size_t operator()(const content::PermissionType& type) const;
83 };
84
85 PermissionContextBase* GetPermissionContext(content::PermissionType type); 81 PermissionContextBase* GetPermissionContext(content::PermissionType type);
86 82
87 // Called when a permission was decided for a given PendingRequest. The 83 // Called when a permission was decided for a given PendingRequest. The
88 // PendingRequest is identified by its |request_id| and the permission is 84 // PendingRequest is identified by its |request_id| and the permission is
89 // identified by its |permission_id|. If the PendingRequest contains more than 85 // identified by its |permission_id|. If the PendingRequest contains more than
90 // one permission, it will wait for the remaining permissions to be resolved. 86 // one permission, it will wait for the remaining permissions to be resolved.
91 // When all the permissions have been resolved, the PendingRequest's callback 87 // When all the permissions have been resolved, the PendingRequest's callback
92 // is run. 88 // is run.
93 void OnPermissionsRequestResponseStatus( 89 void OnPermissionsRequestResponseStatus(
94 int request_id, 90 int request_id,
95 int permission_id, 91 int permission_id,
96 blink::mojom::PermissionStatus status); 92 blink::mojom::PermissionStatus status);
97 93
98 // content_settings::Observer implementation. 94 // content_settings::Observer implementation.
99 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, 95 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern,
100 const ContentSettingsPattern& secondary_pattern, 96 const ContentSettingsPattern& secondary_pattern,
101 ContentSettingsType content_type, 97 ContentSettingsType content_type,
102 std::string resource_identifier) override; 98 std::string resource_identifier) override;
103 99
104 Profile* profile_; 100 Profile* profile_;
105 PendingRequestsMap pending_requests_; 101 PendingRequestsMap pending_requests_;
106 SubscriptionsMap subscriptions_; 102 SubscriptionsMap subscriptions_;
107 103
108 std::unordered_map<content::PermissionType, 104 std::unordered_map<content::PermissionType,
109 std::unique_ptr<PermissionContextBase>, 105 std::unique_ptr<PermissionContextBase>,
110 PermissionTypeHash> 106 content::PermissionTypeHash>
111 permission_contexts_; 107 permission_contexts_;
112 108
113 base::WeakPtrFactory<PermissionManager> weak_ptr_factory_; 109 base::WeakPtrFactory<PermissionManager> weak_ptr_factory_;
114 110
115 DISALLOW_COPY_AND_ASSIGN(PermissionManager); 111 DISALLOW_COPY_AND_ASSIGN(PermissionManager);
116 }; 112 };
117 113
118 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ 114 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698