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

Side by Side Diff: extensions/common/permissions/permissions_data.h

Issue 1908953003: Convert //extensions/{common,shell} from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase? Created 4 years, 8 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_ 5 #ifndef EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_
6 #define EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_ 6 #define EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory>
9 #include <string> 10 #include <string>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
16 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
17 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
18 #include "extensions/common/manifest.h" 18 #include "extensions/common/manifest.h"
19 #include "extensions/common/permissions/api_permission.h" 19 #include "extensions/common/permissions/api_permission.h"
20 #include "extensions/common/permissions/permission_message.h" 20 #include "extensions/common/permissions/permission_message.h"
21 #include "extensions/common/permissions/permission_set.h" 21 #include "extensions/common/permissions/permission_set.h"
22 22
23 class GURL; 23 class GURL;
24 24
(...skipping 14 matching lines...) Expand all
39 class PermissionsData { 39 class PermissionsData {
40 public: 40 public:
41 // The possible types of access for a given frame. 41 // The possible types of access for a given frame.
42 enum AccessType { 42 enum AccessType {
43 ACCESS_DENIED, // The extension is not allowed to access the given page. 43 ACCESS_DENIED, // The extension is not allowed to access the given page.
44 ACCESS_ALLOWED, // The extension is allowed to access the given page. 44 ACCESS_ALLOWED, // The extension is allowed to access the given page.
45 ACCESS_WITHHELD // The browser must determine if the extension can access 45 ACCESS_WITHHELD // The browser must determine if the extension can access
46 // the given page. 46 // the given page.
47 }; 47 };
48 48
49 using TabPermissionsMap = std::map<int, scoped_ptr<const PermissionSet>>; 49 using TabPermissionsMap = std::map<int, std::unique_ptr<const PermissionSet>>;
50 50
51 // Delegate class to allow different contexts (e.g. browser vs renderer) to 51 // Delegate class to allow different contexts (e.g. browser vs renderer) to
52 // have control over policy decisions. 52 // have control over policy decisions.
53 class PolicyDelegate { 53 class PolicyDelegate {
54 public: 54 public:
55 virtual ~PolicyDelegate() {} 55 virtual ~PolicyDelegate() {}
56 56
57 // Returns false if script access should be blocked on this page. 57 // Returns false if script access should be blocked on this page.
58 // Otherwise, default policy should decide. 58 // Otherwise, default policy should decide.
59 virtual bool CanExecuteScriptOnPage(const Extension* extension, 59 virtual bool CanExecuteScriptOnPage(const Extension* extension,
(...skipping 21 matching lines...) Expand all
81 static bool IsRestrictedUrl(const GURL& document_url, 81 static bool IsRestrictedUrl(const GURL& document_url,
82 const Extension* extension, 82 const Extension* extension,
83 std::string* error); 83 std::string* error);
84 84
85 // Locks the permissions data to the current thread. We don't do this on 85 // Locks the permissions data to the current thread. We don't do this on
86 // construction, since extensions are initialized across multiple threads. 86 // construction, since extensions are initialized across multiple threads.
87 void BindToCurrentThread() const; 87 void BindToCurrentThread() const;
88 88
89 // Sets the runtime permissions of the given |extension| to |active| and 89 // Sets the runtime permissions of the given |extension| to |active| and
90 // |withheld|. 90 // |withheld|.
91 void SetPermissions(scoped_ptr<const PermissionSet> active, 91 void SetPermissions(std::unique_ptr<const PermissionSet> active,
92 scoped_ptr<const PermissionSet> withheld) const; 92 std::unique_ptr<const PermissionSet> withheld) const;
93 93
94 // Sets the active permissions, leaving withheld the same. 94 // Sets the active permissions, leaving withheld the same.
95 void SetActivePermissions(scoped_ptr<const PermissionSet> active) const; 95 void SetActivePermissions(std::unique_ptr<const PermissionSet> active) const;
96 96
97 // Updates the tab-specific permissions of |tab_id| to include those from 97 // Updates the tab-specific permissions of |tab_id| to include those from
98 // |permissions|. 98 // |permissions|.
99 void UpdateTabSpecificPermissions(int tab_id, 99 void UpdateTabSpecificPermissions(int tab_id,
100 const PermissionSet& permissions) const; 100 const PermissionSet& permissions) const;
101 101
102 // Clears the tab-specific permissions of |tab_id|. 102 // Clears the tab-specific permissions of |tab_id|.
103 void ClearTabSpecificPermissions(int tab_id) const; 103 void ClearTabSpecificPermissions(int tab_id) const;
104 104
105 // Returns true if the |extension| has the given |permission|. Prefer 105 // Returns true if the |extension| has the given |permission|. Prefer
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // The associated extension's manifest type. 239 // The associated extension's manifest type.
240 Manifest::Type manifest_type_; 240 Manifest::Type manifest_type_;
241 241
242 mutable base::Lock runtime_lock_; 242 mutable base::Lock runtime_lock_;
243 243
244 // The permission's which are currently active on the extension during 244 // The permission's which are currently active on the extension during
245 // runtime. 245 // runtime.
246 // Unsafe indicates that we must lock anytime this is directly accessed. 246 // Unsafe indicates that we must lock anytime this is directly accessed.
247 // Unless you need to change |active_permissions_unsafe_|, use the (safe) 247 // Unless you need to change |active_permissions_unsafe_|, use the (safe)
248 // active_permissions() accessor. 248 // active_permissions() accessor.
249 mutable scoped_ptr<const PermissionSet> active_permissions_unsafe_; 249 mutable std::unique_ptr<const PermissionSet> active_permissions_unsafe_;
250 250
251 // The permissions the extension requested, but was not granted due because 251 // The permissions the extension requested, but was not granted due because
252 // they are too powerful. This includes things like all_hosts. 252 // they are too powerful. This includes things like all_hosts.
253 // Unsafe indicates that we must lock anytime this is directly accessed. 253 // Unsafe indicates that we must lock anytime this is directly accessed.
254 // Unless you need to change |withheld_permissions_unsafe_|, use the (safe) 254 // Unless you need to change |withheld_permissions_unsafe_|, use the (safe)
255 // withheld_permissions() accessor. 255 // withheld_permissions() accessor.
256 mutable scoped_ptr<const PermissionSet> withheld_permissions_unsafe_; 256 mutable std::unique_ptr<const PermissionSet> withheld_permissions_unsafe_;
257 257
258 mutable TabPermissionsMap tab_specific_permissions_; 258 mutable TabPermissionsMap tab_specific_permissions_;
259 259
260 mutable scoped_ptr<base::ThreadChecker> thread_checker_; 260 mutable std::unique_ptr<base::ThreadChecker> thread_checker_;
261 261
262 DISALLOW_COPY_AND_ASSIGN(PermissionsData); 262 DISALLOW_COPY_AND_ASSIGN(PermissionsData);
263 }; 263 };
264 264
265 } // namespace extensions 265 } // namespace extensions
266 266
267 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_ 267 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_
OLDNEW
« no previous file with comments | « extensions/common/permissions/permission_set.cc ('k') | extensions/common/permissions/permissions_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698