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

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

Issue 1871343002: Remove PermissionContext factories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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>
9
8 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
9 #include "base/id_map.h" 11 #include "base/id_map.h"
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
12 #include "components/content_settings/core/browser/content_settings_observer.h" 14 #include "components/content_settings/core/browser/content_settings_observer.h"
13 #include "components/content_settings/core/common/content_settings.h" 15 #include "components/content_settings/core/common/content_settings.h"
14 #include "components/keyed_service/core/keyed_service.h" 16 #include "components/keyed_service/core/keyed_service.h"
15 #include "content/public/browser/permission_manager.h" 17 #include "content/public/browser/permission_manager.h"
16 18
19 class PermissionContextBase;
17 class Profile; 20 class Profile;
18 21
19 namespace content { 22 namespace content {
20 enum class PermissionType; 23 enum class PermissionType;
21 class WebContents; 24 class WebContents;
22 }; // namespace content 25 }; // namespace content
23 26
24 class PermissionManager : public KeyedService, 27 class PermissionManager : public KeyedService,
25 public content::PermissionManager, 28 public content::PermissionManager,
26 public content_settings::Observer { 29 public content_settings::Observer {
27 public: 30 public:
31 static PermissionManager* Get(Profile* profile);
32
28 explicit PermissionManager(Profile* profile); 33 explicit PermissionManager(Profile* profile);
29 ~PermissionManager() override; 34 ~PermissionManager() override;
30 35
31 // content::PermissionManager implementation. 36 // content::PermissionManager implementation.
32 int RequestPermission( 37 int RequestPermission(
33 content::PermissionType permission, 38 content::PermissionType permission,
34 content::RenderFrameHost* render_frame_host, 39 content::RenderFrameHost* render_frame_host,
35 const GURL& requesting_origin, 40 const GURL& requesting_origin,
36 const base::Callback<void(blink::mojom::PermissionStatus)>& callback) 41 const base::Callback<void(blink::mojom::PermissionStatus)>& callback)
37 override; 42 override;
(...skipping 17 matching lines...) Expand all
55 const GURL& embedding_origin) override; 60 const GURL& embedding_origin) override;
56 int SubscribePermissionStatusChange( 61 int SubscribePermissionStatusChange(
57 content::PermissionType permission, 62 content::PermissionType permission,
58 const GURL& requesting_origin, 63 const GURL& requesting_origin,
59 const GURL& embedding_origin, 64 const GURL& embedding_origin,
60 const base::Callback<void(blink::mojom::PermissionStatus)>& callback) 65 const base::Callback<void(blink::mojom::PermissionStatus)>& callback)
61 override; 66 override;
62 void UnsubscribePermissionStatusChange(int subscription_id) override; 67 void UnsubscribePermissionStatusChange(int subscription_id) override;
63 68
64 private: 69 private:
70 friend class GeolocationPermissionContextTests;
71 // TODO(raymes): Refactor MediaPermission to not call GetPermissionContext.
72 // See crbug.com/596786.
73 friend class MediaPermission;
74
65 class PendingRequest; 75 class PendingRequest;
66 using PendingRequestsMap = IDMap<PendingRequest, IDMapOwnPointer>; 76 using PendingRequestsMap = IDMap<PendingRequest, IDMapOwnPointer>;
67 77
68 struct Subscription; 78 struct Subscription;
69 using SubscriptionsMap = IDMap<Subscription, IDMapOwnPointer>; 79 using SubscriptionsMap = IDMap<Subscription, IDMapOwnPointer>;
70 80
81 struct PermissionTypeHash {
82 std::size_t operator()(const content::PermissionType& type) const;
83 };
84
85 PermissionContextBase* GetPermissionContext(content::PermissionType type);
86
71 // Called when a permission was decided for a given PendingRequest. The 87 // Called when a permission was decided for a given PendingRequest. The
72 // PendingRequest is identified by its |request_id| and the permission is 88 // PendingRequest is identified by its |request_id| and the permission is
73 // identified by its |permission_id|. If the PendingRequest contains more than 89 // identified by its |permission_id|. If the PendingRequest contains more than
74 // one permission, it will wait for the remaining permissions to be resolved. 90 // one permission, it will wait for the remaining permissions to be resolved.
75 // When all the permissions have been resolved, the PendingRequest's callback 91 // When all the permissions have been resolved, the PendingRequest's callback
76 // is run. 92 // is run.
77 void OnPermissionsRequestResponseStatus( 93 void OnPermissionsRequestResponseStatus(
78 int request_id, 94 int request_id,
79 int permission_id, 95 int permission_id,
80 blink::mojom::PermissionStatus status); 96 blink::mojom::PermissionStatus status);
81 97
82 // Not all WebContents are able to display permission requests. If the PBM 98 // Not all WebContents are able to display permission requests. If the PBM
83 // is required but missing for |web_contents|, don't pass along the request. 99 // is required but missing for |web_contents|, don't pass along the request.
84 bool IsPermissionBubbleManagerMissing(content::WebContents* web_contents); 100 bool IsPermissionBubbleManagerMissing(content::WebContents* web_contents);
85 101
86 // content_settings::Observer implementation. 102 // content_settings::Observer implementation.
87 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, 103 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern,
88 const ContentSettingsPattern& secondary_pattern, 104 const ContentSettingsPattern& secondary_pattern,
89 ContentSettingsType content_type, 105 ContentSettingsType content_type,
90 std::string resource_identifier) override; 106 std::string resource_identifier) override;
91 107
92 Profile* profile_; 108 Profile* profile_;
93 PendingRequestsMap pending_requests_; 109 PendingRequestsMap pending_requests_;
94 SubscriptionsMap subscriptions_; 110 SubscriptionsMap subscriptions_;
95 111
112 std::unordered_map<content::PermissionType,
113 scoped_ptr<PermissionContextBase>,
114 PermissionTypeHash>
115 permission_contexts_;
116
96 base::WeakPtrFactory<PermissionManager> weak_ptr_factory_; 117 base::WeakPtrFactory<PermissionManager> weak_ptr_factory_;
97 118
98 DISALLOW_COPY_AND_ASSIGN(PermissionManager); 119 DISALLOW_COPY_AND_ASSIGN(PermissionManager);
99 }; 120 };
100 121
101 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ 122 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_context_factory_base.cc ('k') | chrome/browser/permissions/permission_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698