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

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

Issue 2555913002: Implement origin specific Permissions Blacklisting. (Closed)
Patch Set: Comments Created 3 years, 11 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
« no previous file with comments | « no previous file | chrome/browser/permissions/permission_context_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <unordered_map> 9 #include <unordered_map>
10 10
(...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 // Returns whether the permission has been granted, denied etc.
88 // TODO(meredithl): Ensure that the result accurately reflects whether the
89 // origin is blacklisted for this permission.
84 ContentSetting GetPermissionStatus(const GURL& requesting_origin, 90 ContentSetting GetPermissionStatus(const GURL& requesting_origin,
85 const GURL& embedding_origin) const; 91 const GURL& embedding_origin) const;
86 92
87 // Resets the permission to its default value. 93 // Resets the permission to its default value.
88 virtual void ResetPermission(const GURL& requesting_origin, 94 virtual void ResetPermission(const GURL& requesting_origin,
89 const GURL& embedding_origin); 95 const GURL& embedding_origin);
90 96
91 // Withdraw an existing permission request, no op if the permission request 97 // Withdraw an existing permission request, no op if the permission request
92 // was already cancelled by some other means. 98 // was already cancelled by some other means.
93 virtual void CancelPermissionRequest(content::WebContents* web_contents, 99 virtual void CancelPermissionRequest(content::WebContents* web_contents,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 ContentSettingsType content_settings_type() const { 163 ContentSettingsType content_settings_type() const {
158 return content_settings_type_; 164 return content_settings_type_;
159 } 165 }
160 166
161 private: 167 private:
162 friend class PermissionContextBaseTests; 168 friend class PermissionContextBaseTests;
163 169
164 // Called when a request is no longer used so it can be cleaned up. 170 // Called when a request is no longer used so it can be cleaned up.
165 void CleanUpRequest(const PermissionRequestID& id); 171 void CleanUpRequest(const PermissionRequestID& id);
166 172
173 // Called when the requesting origin and permission have been checked by Safe
174 // Browsing. |permission_blocked| determines whether to auto-block the
175 // permission request without prompting the user for a decision.
176 void ContinueRequestPermission(content::WebContents* web_contents,
177 const PermissionRequestID& id,
178 const GURL& requesting_origin,
179 const GURL& embedding_origin,
180 bool user_gesture,
181 const BrowserPermissionCallback& callback,
182 bool permission_blocked);
183
184 void SetSafeBrowsingDatabaseManagerAndTimeoutForTest(
185 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager,
186 int timeout);
187
167 Profile* profile_; 188 Profile* profile_;
168 const content::PermissionType permission_type_; 189 const content::PermissionType permission_type_;
169 const ContentSettingsType content_settings_type_; 190 const ContentSettingsType content_settings_type_;
191 int safe_browsing_timeout_;
192 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager_;
170 #if defined(OS_ANDROID) 193 #if defined(OS_ANDROID)
171 std::unique_ptr<PermissionQueueController> permission_queue_controller_; 194 std::unique_ptr<PermissionQueueController> permission_queue_controller_;
172 #endif 195 #endif
173 std::unordered_map<std::string, std::unique_ptr<PermissionRequest>> 196 std::unordered_map<std::string, std::unique_ptr<PermissionRequest>>
174 pending_requests_; 197 pending_requests_;
175 198
176 // Must be the last member, to ensure that it will be 199 // Must be the last member, to ensure that it will be
177 // destroyed first, which will invalidate weak pointers 200 // destroyed first, which will invalidate weak pointers
178 base::WeakPtrFactory<PermissionContextBase> weak_factory_; 201 base::WeakPtrFactory<PermissionContextBase> weak_factory_;
179 }; 202 };
180 203
181 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ 204 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/permissions/permission_context_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698