Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_API_PERMISSION_H_ | 5 #ifndef EXTENSIONS_COMMON_PERMISSIONS_API_PERMISSION_H_ |
| 6 #define EXTENSIONS_COMMON_PERMISSIONS_API_PERMISSION_H_ | 6 #define EXTENSIONS_COMMON_PERMISSIONS_API_PERMISSION_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/pickle.h" | 14 #include "base/pickle.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "extensions/common/permissions/permission_message.h" | 16 #include "extensions/common/permissions/permission_message.h" |
| 17 | 17 |
| 18 namespace IPC { | 18 namespace IPC { |
| 19 class Message; | 19 class Message; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace extensions { | 22 namespace extensions { |
| 23 | 23 |
| 24 class PermissionIDSet; | |
| 24 class APIPermissionInfo; | 25 class APIPermissionInfo; |
| 25 class ChromeAPIPermissions; | 26 class ChromeAPIPermissions; |
| 26 | 27 |
| 27 // APIPermission is for handling some complex permissions. Please refer to | 28 // APIPermission is for handling some complex permissions. Please refer to |
| 28 // extensions::SocketPermission as an example. | 29 // extensions::SocketPermission as an example. |
| 29 // There is one instance per permission per loaded extension. | 30 // There is one instance per permission per loaded extension. |
| 30 class APIPermission { | 31 class APIPermission { |
| 31 public: | 32 public: |
| 32 // The IDs of all permissions available to apps. Add as many permissions here | 33 // The IDs of all permissions available to apps. Add as many permissions here |
| 33 // as needed to generate meaningful permission messages. Add the rules for the | 34 // as needed to generate meaningful permission messages. Add the rules for the |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 // permission message rule combinations. | 209 // permission message rule combinations. |
| 209 // TODO(sashab): Move these in-line with the other permission IDs. | 210 // TODO(sashab): Move these in-line with the other permission IDs. |
| 210 kBluetooth, | 211 kBluetooth, |
| 211 kBluetoothDevices, | 212 kBluetoothDevices, |
| 212 kFavicon, | 213 kFavicon, |
| 213 kFullAccess, | 214 kFullAccess, |
| 214 kHostReadOnly, | 215 kHostReadOnly, |
| 215 kHostReadWrite, | 216 kHostReadWrite, |
| 216 kHostsAll, | 217 kHostsAll, |
| 217 kHostsAllReadOnly, | 218 kHostsAllReadOnly, |
| 219 kMediaGalleriesAllGalleriesCopyTo, | |
| 220 kMediaGalleriesAllGalleriesDelete, | |
| 221 kMediaGalleriesAllGalleriesRead, | |
| 222 kNetworkState, | |
| 218 kOverrideBookmarksUI, | 223 kOverrideBookmarksUI, |
| 224 kShouldWarnAllHosts, | |
| 219 kSocketAnyHost, | 225 kSocketAnyHost, |
| 220 kSocketDomainHostsSingular, | 226 kSocketDomainHosts, |
| 221 kSocketDomainHostsPlural, | 227 kSocketSpecificHosts, |
| 222 kSocketSpecificHostsSingular, | 228 kUsbDeviceList, |
| 223 kSocketSpecificHostsPlural, | 229 kUsbDeviceUnknownProduct, |
| 224 kNetworkState, | 230 kUsbDeviceUnknownVendor, |
| 225 | 231 |
| 226 kEnumBoundary | 232 kEnumBoundary |
| 227 }; | 233 }; |
| 228 | 234 |
| 229 struct CheckParam { | 235 struct CheckParam { |
| 230 }; | 236 }; |
| 231 | 237 |
| 232 explicit APIPermission(const APIPermissionInfo* info); | 238 explicit APIPermission(const APIPermissionInfo* info); |
| 233 | 239 |
| 234 virtual ~APIPermission(); | 240 virtual ~APIPermission(); |
| 235 | 241 |
| 236 // Returns the id of this permission. | 242 // Returns the id of this permission. |
| 237 ID id() const; | 243 ID id() const; |
| 238 | 244 |
| 239 // Returns the name of this permission. | 245 // Returns the name of this permission. |
| 240 const char* name() const; | 246 const char* name() const; |
| 241 | 247 |
| 242 // Returns the APIPermission of this permission. | 248 // Returns the APIPermission of this permission. |
| 243 const APIPermissionInfo* info() const { | 249 const APIPermissionInfo* info() const { |
| 244 return info_; | 250 return info_; |
| 245 } | 251 } |
| 246 | 252 |
| 253 // The set of permissions this API permission has. These permissions are used | |
| 254 // by PermissionMessageProvider to generate meaningful permission messages | |
| 255 // for the app. | |
| 256 virtual PermissionIDSet GetPermissions() const = 0; | |
|
sashab
2014/12/10 08:57:49
This is the main change in this patch.
| |
| 257 | |
| 247 // Returns true if this permission has any PermissionMessages. | 258 // Returns true if this permission has any PermissionMessages. |
| 259 // TODO(sashab): Deprecate this in favor of GetPermissions() above. | |
| 248 virtual bool HasMessages() const = 0; | 260 virtual bool HasMessages() const = 0; |
| 249 | 261 |
| 250 // Returns the localized permission messages of this permission. | 262 // Returns the localized permission messages of this permission. |
| 263 // TODO(sashab): Deprecate this in favor of GetPermissions() above. | |
| 251 virtual PermissionMessages GetMessages() const = 0; | 264 virtual PermissionMessages GetMessages() const = 0; |
| 252 | 265 |
| 253 // Returns true if the given permission is allowed. | 266 // Returns true if the given permission is allowed. |
| 254 virtual bool Check(const CheckParam* param) const = 0; | 267 virtual bool Check(const CheckParam* param) const = 0; |
| 255 | 268 |
| 256 // Returns true if |rhs| is a subset of this. | 269 // Returns true if |rhs| is a subset of this. |
| 257 virtual bool Contains(const APIPermission* rhs) const = 0; | 270 virtual bool Contains(const APIPermission* rhs) const = 0; |
| 258 | 271 |
| 259 // Returns true if |rhs| is equal to this. | 272 // Returns true if |rhs| is equal to this. |
| 260 virtual bool Equal(const APIPermission* rhs) const = 0; | 273 virtual bool Equal(const APIPermission* rhs) const = 0; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 409 const char* const name_; | 422 const char* const name_; |
| 410 const int flags_; | 423 const int flags_; |
| 411 const int l10n_message_id_; | 424 const int l10n_message_id_; |
| 412 const PermissionMessage::ID message_id_; | 425 const PermissionMessage::ID message_id_; |
| 413 const APIPermissionConstructor api_permission_constructor_; | 426 const APIPermissionConstructor api_permission_constructor_; |
| 414 }; | 427 }; |
| 415 | 428 |
| 416 } // namespace extensions | 429 } // namespace extensions |
| 417 | 430 |
| 418 #endif // EXTENSIONS_COMMON_PERMISSIONS_API_PERMISSION_H_ | 431 #endif // EXTENSIONS_COMMON_PERMISSIONS_API_PERMISSION_H_ |
| OLD | NEW |