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

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

Issue 2555913002: Implement origin specific Permissions Blacklisting. (Closed)
Patch Set: Nits Created 4 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_CONTEXT_BASE_H_ 5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
(...skipping 10 matching lines...) Expand all
21 class PermissionQueueController; 21 class PermissionQueueController;
22 #endif 22 #endif
23 class GURL; 23 class GURL;
24 class PermissionRequestID; 24 class PermissionRequestID;
25 class Profile; 25 class Profile;
26 26
27 namespace content { 27 namespace content {
28 class WebContents; 28 class WebContents;
29 } 29 }
30 30
31 namespace safe_browsing {
32 class SafeBrowsingDatabaseManager;
33 }
34
31 using BrowserPermissionCallback = base::Callback<void(ContentSetting)>; 35 using BrowserPermissionCallback = base::Callback<void(ContentSetting)>;
32 36
33 // This base class contains common operations for granting permissions. 37 // This base class contains common operations for granting permissions.
34 // It offers the following functionality: 38 // It offers the following functionality:
35 // - Creates a permission request when needed. 39 // - Creates a permission request when needed.
36 // - If accepted/denied the permission is saved in content settings for 40 // - If accepted/denied the permission is saved in content settings for
37 // future uses (for the domain that requested it). 41 // future uses (for the domain that requested it).
38 // - If dismissed the permission is not saved but it's considered denied for 42 // - If dismissed the permission is not saved but it's considered denied for
39 // this one request 43 // this one request
40 // - In any case the BrowserPermissionCallback is executed once a decision 44 // - In any case the BrowserPermissionCallback is executed once a decision
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 77
74 // The renderer is requesting permission to push messages. 78 // The renderer is requesting permission to push messages.
75 // When the answer to a permission request has been determined, |callback| 79 // When the answer to a permission request has been determined, |callback|
76 // should be called with the result. 80 // should be called with the result.
77 virtual void RequestPermission(content::WebContents* web_contents, 81 virtual void RequestPermission(content::WebContents* web_contents,
78 const PermissionRequestID& id, 82 const PermissionRequestID& id,
79 const GURL& requesting_frame, 83 const GURL& requesting_frame,
80 bool user_gesture, 84 bool user_gesture,
81 const BrowserPermissionCallback& callback); 85 const BrowserPermissionCallback& callback);
82 86
83 // Returns whether the permission has been granted, denied... 87 // Called when the requesting origin and permission have been checked by Safe
88 // Browsing. |permission_blocked| determines whether to auto-block the
89 // permission request without prompting the user for a decision.
90 void CheckPermissionsBlacklistResult(
raymes 2016/12/19 00:07:41 nit: should this be private?
meredithl 2016/12/20 07:38:27 Done.
91 content::WebContents* web_contents,
92 const PermissionRequestID& id,
93 const GURL& requesting_origin,
94 const GURL& embedding_origin,
95 bool user_gesture,
96 const BrowserPermissionCallback& callback,
97 bool permission_blocked);
98
99 // Returns whether the permission has been granted, denied etc. This method
100 // does not take into account the Safe Browsing blacklist, as it is executed
101 // synchronously.
raymes 2016/12/19 00:07:41 nit: I think the fact that this doesn't handle the
meredithl 2016/12/20 07:38:27 Done.
raymes 2016/12/20 23:58:56 I don't see this updated :(
meredithl 2016/12/29 06:23:35 Haha, git add -p blues. Fixed!
84 virtual ContentSetting GetPermissionStatus( 102 virtual ContentSetting GetPermissionStatus(
85 const GURL& requesting_origin, 103 const GURL& requesting_origin,
86 const GURL& embedding_origin) const; 104 const GURL& embedding_origin) const;
87 105
88 // Resets the permission to its default value. 106 // Resets the permission to its default value.
89 virtual void ResetPermission(const GURL& requesting_origin, 107 virtual void ResetPermission(const GURL& requesting_origin,
90 const GURL& embedding_origin); 108 const GURL& embedding_origin);
91 109
92 // Withdraw an existing permission request, no op if the permission request 110 // Withdraw an existing permission request, no op if the permission request
93 // was already cancelled by some other means. 111 // was already cancelled by some other means.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 ContentSetting content_setting); 166 ContentSetting content_setting);
149 167
150 // Whether the permission should be restricted to secure origins. 168 // Whether the permission should be restricted to secure origins.
151 virtual bool IsRestrictedToSecureOrigins() const = 0; 169 virtual bool IsRestrictedToSecureOrigins() const = 0;
152 170
153 content::PermissionType permission_type() const { return permission_type_; } 171 content::PermissionType permission_type() const { return permission_type_; }
154 ContentSettingsType content_settings_type() const { 172 ContentSettingsType content_settings_type() const {
155 return content_settings_type_; 173 return content_settings_type_;
156 } 174 }
157 175
176 // Virtual to allow for mocking in tests.
177 virtual scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager>
178 GetSafeBrowsingDatabaseManager();
raymes 2016/12/19 00:07:41 nit: virtuals have several downsides, e.g. the tem
meredithl 2016/12/20 07:38:27 Done.
179
158 private: 180 private:
159 friend class PermissionContextBaseTests; 181 friend class PermissionContextBaseTests;
160 182
161 // Called when a request is no longer used so it can be cleaned up. 183 // Called when a request is no longer used so it can be cleaned up.
162 void CleanUpRequest(const PermissionRequestID& id); 184 void CleanUpRequest(const PermissionRequestID& id);
163 185
164 Profile* profile_; 186 Profile* profile_;
165 const content::PermissionType permission_type_; 187 const content::PermissionType permission_type_;
166 const ContentSettingsType content_settings_type_; 188 const ContentSettingsType content_settings_type_;
167 #if defined(OS_ANDROID) 189 #if defined(OS_ANDROID)
168 std::unique_ptr<PermissionQueueController> permission_queue_controller_; 190 std::unique_ptr<PermissionQueueController> permission_queue_controller_;
169 #endif 191 #endif
170 base::ScopedPtrHashMap<std::string, std::unique_ptr<PermissionRequest>> 192 base::ScopedPtrHashMap<std::string, std::unique_ptr<PermissionRequest>>
171 pending_requests_; 193 pending_requests_;
172 194
173 // Must be the last member, to ensure that it will be 195 // Must be the last member, to ensure that it will be
174 // destroyed first, which will invalidate weak pointers 196 // destroyed first, which will invalidate weak pointers
175 base::WeakPtrFactory<PermissionContextBase> weak_factory_; 197 base::WeakPtrFactory<PermissionContextBase> weak_factory_;
176 }; 198 };
177 199
178 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ 200 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698