Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef EXTENSIONS_COMMON_MANIFEST_HANDLERS_PERMISSIONS_PARSER_H_ | |
| 6 #define EXTENSIONS_COMMON_MANIFEST_HANDLERS_PERMISSIONS_PARSER_H_ | |
| 7 | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "base/strings/string16.h" | |
| 10 #include "extensions/common/permissions/api_permission.h" | |
| 11 #include "extensions/common/permissions/permission_set.h" | |
| 12 | |
| 13 namespace extensions { | |
| 14 | |
| 15 class Extension; | |
| 16 class URLPatternSet; | |
| 17 | |
| 18 // The class for parsing the kPermissions and kOptionalPermissions keys in the | |
| 19 // manifest. Because permissions are slightly different than other keys (they | |
| 20 // are used in many different handlers and need to be the first and last key | |
| 21 // touched), this is not an actual ManifestHandler (hence the difference in | |
| 22 // name). | |
|
not at google - send to devlin
2014/06/02 23:20:06
not too keen on the name "PermissionsParser", even
Devlin
2014/06/03 15:28:21
IIRC, we decided on [X]Info for handlers. Since P
not at google - send to devlin
2014/06/03 15:45:16
alright :)
aside: PermissionsInfo is bizarre.
| |
| 23 class PermissionsParser { | |
| 24 public: | |
| 25 PermissionsParser(); | |
| 26 ~PermissionsParser(); | |
| 27 | |
| 28 // Parse the manifest-specified permissions. | |
| 29 bool Parse(Extension* extension, base::string16* error); | |
| 30 | |
| 31 // Finalize the permissions, setting the related manifest data on the | |
| 32 // extension. | |
| 33 void Finalize(Extension* extension); | |
| 34 | |
| 35 // Modify the manifest permissions. These methods should only be used | |
| 36 // during initialization and will DCHECK() for safety. | |
| 37 static void AddAPIPermission(Extension* extension, | |
| 38 APIPermission::ID permission); | |
| 39 static void AddAPIPermission(Extension* extension, | |
| 40 APIPermission* permission); | |
| 41 static bool HasAPIPermission(const Extension* extension, | |
| 42 APIPermission::ID permission); | |
| 43 static void SetScriptableHosts(Extension* extension, | |
| 44 const URLPatternSet& scriptable_hosts); | |
| 45 | |
| 46 // Return the extension's manifest-specified permissions. In no cases should | |
| 47 // these permissions be used to determine if an action is allowed. Instead, | |
| 48 // use PermissionsData. | |
| 49 static scoped_refptr<const PermissionSet> GetRequiredPermissions( | |
| 50 const Extension* extension); | |
| 51 static scoped_refptr<const PermissionSet> GetOptionalPermissions( | |
| 52 const Extension* extension); | |
| 53 | |
| 54 private: | |
| 55 struct InitialPermissions; | |
| 56 | |
| 57 // The initial permissions for the extension, which can still be modified. | |
| 58 scoped_ptr<InitialPermissions> initial_required_permissions_; | |
| 59 scoped_ptr<InitialPermissions> initial_optional_permissions_; | |
| 60 }; | |
| 61 | |
| 62 } // namespace extensions | |
| 63 | |
| 64 #endif // EXTENSIONS_COMMON_MANIFEST_HANDLERS_PERMISSIONS_PARSER_H_ | |
| OLD | NEW |