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

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

Issue 2675483002: Replace PermissionType in chrome/ with ContentSettingsType (Closed)
Patch Set: ready Created 3 years, 10 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"
(...skipping 15 matching lines...) Expand all
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);
34 ~PermissionManager() override; 34 ~PermissionManager() override;
35 35
36 int RequestPermission(
37 ContentSettingsType permission,
38 content::RenderFrameHost* render_frame_host,
39 const GURL& requesting_origin,
40 bool user_gesture,
41 const base::Callback<void(blink::mojom::PermissionStatus)>& callback);
42 blink::mojom::PermissionStatus GetPermissionStatus(
raymes 2017/02/07 04:46:15 Naming is tricky here (for both these functions).
Timothy Loh 2017/02/08 04:01:06 Once we change it to return ContentSetting, I thin
raymes 2017/02/09 00:39:56 I think we should keep it as GetPermissionStatus (
43 ContentSettingsType permission,
44 const GURL& requesting_origin,
45 const GURL& embedding_origin);
46
36 // content::PermissionManager implementation. 47 // content::PermissionManager implementation.
37 int RequestPermission( 48 int RequestPermission(
38 content::PermissionType permission, 49 content::PermissionType permission,
39 content::RenderFrameHost* render_frame_host, 50 content::RenderFrameHost* render_frame_host,
40 const GURL& requesting_origin, 51 const GURL& requesting_origin,
41 bool user_gesture, 52 bool user_gesture,
42 const base::Callback<void(blink::mojom::PermissionStatus)>& callback) 53 const base::Callback<void(blink::mojom::PermissionStatus)>& callback)
43 override; 54 override;
44 int RequestPermissions( 55 int RequestPermissions(
45 const std::vector<content::PermissionType>& permissions, 56 const std::vector<content::PermissionType>& permissions,
(...skipping 18 matching lines...) Expand all
64 content::PermissionType permission, 75 content::PermissionType permission,
65 const GURL& requesting_origin, 76 const GURL& requesting_origin,
66 const GURL& embedding_origin, 77 const GURL& embedding_origin,
67 const base::Callback<void(blink::mojom::PermissionStatus)>& callback) 78 const base::Callback<void(blink::mojom::PermissionStatus)>& callback)
68 override; 79 override;
69 void UnsubscribePermissionStatusChange(int subscription_id) override; 80 void UnsubscribePermissionStatusChange(int subscription_id) override;
70 81
71 // TODO(raymes): Rather than exposing this, expose a denial reason from 82 // TODO(raymes): Rather than exposing this, expose a denial reason from
72 // GetPermissionStatus so that callers can determine whether a permission is 83 // GetPermissionStatus so that callers can determine whether a permission is
73 // denied due to the kill switch. 84 // denied due to the kill switch.
74 bool IsPermissionKillSwitchOn(content::PermissionType permission); 85 bool IsPermissionKillSwitchOn(ContentSettingsType);
75 86
76 private: 87 private:
77 friend class GeolocationPermissionContextTests; 88 friend class GeolocationPermissionContextTests;
78 89
79 class PendingRequest; 90 class PendingRequest;
80 using PendingRequestsMap = IDMap<std::unique_ptr<PendingRequest>>; 91 using PendingRequestsMap = IDMap<std::unique_ptr<PendingRequest>>;
81 92
82 struct Subscription; 93 struct Subscription;
83 using SubscriptionsMap = IDMap<std::unique_ptr<Subscription>>; 94 using SubscriptionsMap = IDMap<std::unique_ptr<Subscription>>;
84 95
85 PermissionContextBase* GetPermissionContext(content::PermissionType type); 96 PermissionContextBase* GetPermissionContext(ContentSettingsType type);
86 97
87 // Called when a permission was decided for a given PendingRequest. The 98 // Called when a permission was decided for a given PendingRequest. The
88 // PendingRequest is identified by its |request_id| and the permission is 99 // PendingRequest is identified by its |request_id| and the permission is
89 // identified by its |permission_id|. If the PendingRequest contains more than 100 // identified by its |permission_id|. If the PendingRequest contains more than
90 // one permission, it will wait for the remaining permissions to be resolved. 101 // one permission, it will wait for the remaining permissions to be resolved.
91 // When all the permissions have been resolved, the PendingRequest's callback 102 // When all the permissions have been resolved, the PendingRequest's callback
92 // is run. 103 // is run.
93 void OnPermissionsRequestResponseStatus( 104 void OnPermissionsRequestResponseStatus(
94 int request_id, 105 int request_id,
95 int permission_id, 106 int permission_id,
96 blink::mojom::PermissionStatus status); 107 blink::mojom::PermissionStatus status);
97 108
98 // content_settings::Observer implementation. 109 // content_settings::Observer implementation.
99 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, 110 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern,
100 const ContentSettingsPattern& secondary_pattern, 111 const ContentSettingsPattern& secondary_pattern,
101 ContentSettingsType content_type, 112 ContentSettingsType content_type,
102 std::string resource_identifier) override; 113 std::string resource_identifier) override;
103 114
104 ContentSetting GetPermissionStatusInternal(content::PermissionType permission,
105 const GURL& requesting_origin,
106 const GURL& embedding_origin);
107
108 Profile* profile_; 115 Profile* profile_;
109 PendingRequestsMap pending_requests_; 116 PendingRequestsMap pending_requests_;
110 SubscriptionsMap subscriptions_; 117 SubscriptionsMap subscriptions_;
111 118
112 std::unordered_map<content::PermissionType, 119 std::unordered_map<ContentSettingsType,
113 std::unique_ptr<PermissionContextBase>, 120 std::unique_ptr<PermissionContextBase>,
114 PermissionTypeHash> 121 ContentSettingsTypeHash>
115 permission_contexts_; 122 permission_contexts_;
116 123
117 base::WeakPtrFactory<PermissionManager> weak_ptr_factory_; 124 base::WeakPtrFactory<PermissionManager> weak_ptr_factory_;
118 125
119 DISALLOW_COPY_AND_ASSIGN(PermissionManager); 126 DISALLOW_COPY_AND_ASSIGN(PermissionManager);
120 }; 127 };
121 128
122 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ 129 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698