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

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

Issue 2439673004: Add threadsafe version of PermissionManager::GetPermissionStatus (Closed)
Patch Set: remove override Created 4 years, 2 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 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 "content/public/browser/permission_type.h" 18 #include "content/public/browser/permission_type.h"
19 19
20 #if defined(OS_ANDROID) 20 #if defined(OS_ANDROID)
21 class PermissionQueueController; 21 class PermissionQueueController;
22 #endif 22 #endif
23 class GURL; 23 class GURL;
24 class HostContentSettingsMap;
24 class PermissionRequestID; 25 class PermissionRequestID;
25 class Profile; 26 class Profile;
26 27
27 namespace content { 28 namespace content {
28 class WebContents; 29 class WebContents;
29 } 30 }
30 31
31 using BrowserPermissionCallback = base::Callback<void(ContentSetting)>; 32 using BrowserPermissionCallback = base::Callback<void(ContentSetting)>;
32 33
33 // This base class contains common operations for granting permissions. 34 // This base class contains common operations for granting permissions.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
83 // Returns whether the permission has been granted, denied... 84 // Returns whether the permission has been granted, denied...
84 virtual ContentSetting GetPermissionStatus( 85 virtual ContentSetting GetPermissionStatus(
85 const GURL& requesting_origin, 86 const GURL& requesting_origin,
86 const GURL& embedding_origin) const; 87 const GURL& embedding_origin) const;
87 88
89 // Thread safe version of GetPermissionStatus for consumers that already have
90 // an associated HostContentSettingsMap.
91 virtual ContentSetting GetPermissionStatus(
92 HostContentSettingsMap* host,
93 const GURL& requesting_origin,
94 const GURL& embedding_origin) const;
95
88 // Resets the permission to its default value. 96 // Resets the permission to its default value.
89 virtual void ResetPermission(const GURL& requesting_origin, 97 virtual void ResetPermission(const GURL& requesting_origin,
90 const GURL& embedding_origin); 98 const GURL& embedding_origin);
91 99
92 // Withdraw an existing permission request, no op if the permission request 100 // Withdraw an existing permission reqUest, no op if the permission request
mlamouri (slow - plz ping) 2016/10/22 11:36:38 typo: s/reqUest/request/
93 // was already cancelled by some other means. 101 // was already cancelled by some other means.
94 virtual void CancelPermissionRequest(content::WebContents* web_contents, 102 virtual void CancelPermissionRequest(content::WebContents* web_contents,
95 const PermissionRequestID& id); 103 const PermissionRequestID& id);
96 104
97 // Whether the kill switch has been enabled for this permission. 105 // Whether the kill switch has been enabled for this permission.
98 // public for permissions that do not use RequestPermission, like 106 // public for permissions that do not use RequestPermission, like
99 // camera and microphone, and for testing. 107 // camera and microphone, and for testing.
100 bool IsPermissionKillSwitchOn() const; 108 bool IsPermissionKillSwitchOn() const;
101 109
102 protected: 110 protected:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 Profile* profile() const; 149 Profile* profile() const;
142 150
143 // Store the decided permission as a content setting. 151 // Store the decided permission as a content setting.
144 // virtual since the permission might be stored with different restrictions 152 // virtual since the permission might be stored with different restrictions
145 // (for example for desktop notifications). 153 // (for example for desktop notifications).
146 virtual void UpdateContentSetting(const GURL& requesting_origin, 154 virtual void UpdateContentSetting(const GURL& requesting_origin,
147 const GURL& embedding_origin, 155 const GURL& embedding_origin,
148 ContentSetting content_setting); 156 ContentSetting content_setting);
149 157
150 // Whether the permission should be restricted to secure origins. 158 // Whether the permission should be restricted to secure origins.
159 // Note: Maybe be called from multiple threads.
151 virtual bool IsRestrictedToSecureOrigins() const = 0; 160 virtual bool IsRestrictedToSecureOrigins() const = 0;
152 161
153 content::PermissionType permission_type() const { return permission_type_; } 162 content::PermissionType permission_type() const { return permission_type_; }
154 ContentSettingsType content_settings_type() const { 163 ContentSettingsType content_settings_type() const {
155 return content_settings_type_; 164 return content_settings_type_;
156 } 165 }
157 166
158 private: 167 private:
159 friend class PermissionContextBaseTests; 168 friend class PermissionContextBaseTests;
160 169
161 // 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.
162 void CleanUpRequest(const PermissionRequestID& id); 171 void CleanUpRequest(const PermissionRequestID& id);
163 172
164 Profile* profile_; 173 Profile* profile_;
165 const content::PermissionType permission_type_; 174 const content::PermissionType permission_type_;
166 const ContentSettingsType content_settings_type_; 175 const ContentSettingsType content_settings_type_;
167 #if defined(OS_ANDROID) 176 #if defined(OS_ANDROID)
168 std::unique_ptr<PermissionQueueController> permission_queue_controller_; 177 std::unique_ptr<PermissionQueueController> permission_queue_controller_;
169 #endif 178 #endif
170 base::ScopedPtrHashMap<std::string, std::unique_ptr<PermissionRequest>> 179 base::ScopedPtrHashMap<std::string, std::unique_ptr<PermissionRequest>>
171 pending_requests_; 180 pending_requests_;
172 181
173 // Must be the last member, to ensure that it will be 182 // Must be the last member, to ensure that it will be
174 // destroyed first, which will invalidate weak pointers 183 // destroyed first, which will invalidate weak pointers
175 base::WeakPtrFactory<PermissionContextBase> weak_factory_; 184 base::WeakPtrFactory<PermissionContextBase> weak_factory_;
176 }; 185 };
177 186
178 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ 187 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698