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

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

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

Powered by Google App Engine
This is Rietveld 408576698