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

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

Issue 2555913002: Implement origin specific Permissions Blacklisting. (Closed)
Patch Set: Squashed branches 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"
11 #include "base/containers/scoped_ptr_hash_map.h" 11 #include "base/containers/scoped_ptr_hash_map.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/browser/permissions/permission_request.h" 14 #include "chrome/browser/permissions/permission_request.h"
15 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
dominickn 2016/12/07 04:34:29 Nit: I don't think you need this include in this f
meredithl 2016/12/07 06:37:11 Done.
15 #include "components/content_settings/core/common/content_settings.h" 16 #include "components/content_settings/core/common/content_settings.h"
16 #include "components/content_settings/core/common/content_settings_types.h" 17 #include "components/content_settings/core/common/content_settings_types.h"
17 #include "components/keyed_service/core/keyed_service.h" 18 #include "components/keyed_service/core/keyed_service.h"
19 #include "components/safe_browsing_db/database_manager.h"
18 #include "content/public/browser/permission_type.h" 20 #include "content/public/browser/permission_type.h"
19 21
20 #if defined(OS_ANDROID) 22 #if defined(OS_ANDROID)
21 class PermissionQueueController; 23 class PermissionQueueController;
22 #endif 24 #endif
23 class GURL; 25 class GURL;
24 class PermissionRequestID; 26 class PermissionRequestID;
25 class Profile; 27 class Profile;
26 28
27 namespace content { 29 namespace content {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 75
74 // The renderer is requesting permission to push messages. 76 // The renderer is requesting permission to push messages.
75 // When the answer to a permission request has been determined, |callback| 77 // When the answer to a permission request has been determined, |callback|
76 // should be called with the result. 78 // should be called with the result.
77 virtual void RequestPermission(content::WebContents* web_contents, 79 virtual void RequestPermission(content::WebContents* web_contents,
78 const PermissionRequestID& id, 80 const PermissionRequestID& id,
79 const GURL& requesting_frame, 81 const GURL& requesting_frame,
80 bool user_gesture, 82 bool user_gesture,
81 const BrowserPermissionCallback& callback); 83 const BrowserPermissionCallback& callback);
82 84
85 // The requesting origin and permission have been checked by Safe Browsing
dominickn 2016/12/07 04:34:29 Nit: update the first sentence of this comment to
meredithl 2016/12/07 06:37:11 Done.
86 // The result determines whether to auto-block the permission request without
87 // prompting the user for a decision.
88 void CheckPermissionsBlacklistResult(
89 content::WebContents* web_contents,
90 const PermissionRequestID& id,
91 const GURL& requesting_origin,
92 const GURL& embedding_origin,
93 bool user_gesture,
94 const BrowserPermissionCallback& callback,
95 bool result);
dominickn 2016/12/07 04:34:29 Nit: "result" is a little vague. Perhaps change it
meredithl 2016/12/07 06:37:11 Done.
96
83 // Returns whether the permission has been granted, denied... 97 // Returns whether the permission has been granted, denied...
84 virtual ContentSetting GetPermissionStatus( 98 virtual ContentSetting GetPermissionStatus(
85 const GURL& requesting_origin, 99 const GURL& requesting_origin,
86 const GURL& embedding_origin) const; 100 const GURL& embedding_origin) const;
87 101
88 // Resets the permission to its default value. 102 // Resets the permission to its default value.
89 virtual void ResetPermission(const GURL& requesting_origin, 103 virtual void ResetPermission(const GURL& requesting_origin,
90 const GURL& embedding_origin); 104 const GURL& embedding_origin);
91 105
92 // Withdraw an existing permission request, no op if the permission request 106 // Withdraw an existing permission request, no op if the permission request
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 ContentSetting content_setting); 162 ContentSetting content_setting);
149 163
150 // Whether the permission should be restricted to secure origins. 164 // Whether the permission should be restricted to secure origins.
151 virtual bool IsRestrictedToSecureOrigins() const = 0; 165 virtual bool IsRestrictedToSecureOrigins() const = 0;
152 166
153 content::PermissionType permission_type() const { return permission_type_; } 167 content::PermissionType permission_type() const { return permission_type_; }
154 ContentSettingsType content_settings_type() const { 168 ContentSettingsType content_settings_type() const {
155 return content_settings_type_; 169 return content_settings_type_;
156 } 170 }
157 171
172 // Virtual to allow for mocking in tests.
173 virtual scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager>
174 GetSafeBrowsingDatabaseManager();
175
158 private: 176 private:
159 friend class PermissionContextBaseTests; 177 friend class PermissionContextBaseTests;
160 178
161 // Called when a request is no longer used so it can be cleaned up. 179 // Called when a request is no longer used so it can be cleaned up.
162 void CleanUpRequest(const PermissionRequestID& id); 180 void CleanUpRequest(const PermissionRequestID& id);
163 181
164 Profile* profile_; 182 Profile* profile_;
165 const content::PermissionType permission_type_; 183 const content::PermissionType permission_type_;
166 const ContentSettingsType content_settings_type_; 184 const ContentSettingsType content_settings_type_;
167 #if defined(OS_ANDROID) 185 #if defined(OS_ANDROID)
168 std::unique_ptr<PermissionQueueController> permission_queue_controller_; 186 std::unique_ptr<PermissionQueueController> permission_queue_controller_;
169 #endif 187 #endif
170 base::ScopedPtrHashMap<std::string, std::unique_ptr<PermissionRequest>> 188 base::ScopedPtrHashMap<std::string, std::unique_ptr<PermissionRequest>>
171 pending_requests_; 189 pending_requests_;
172 190
173 // Must be the last member, to ensure that it will be 191 // Must be the last member, to ensure that it will be
174 // destroyed first, which will invalidate weak pointers 192 // destroyed first, which will invalidate weak pointers
175 base::WeakPtrFactory<PermissionContextBase> weak_factory_; 193 base::WeakPtrFactory<PermissionContextBase> weak_factory_;
176 }; 194 };
177 195
178 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ 196 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698