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

Side by Side Diff: extensions/common/manifest_handlers/permissions_parser.h

Issue 309533007: Refactor PermissionsData pt1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
(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).
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, APIPermission* permission);
40 static bool HasAPIPermission(const Extension* extension,
41 APIPermission::ID permission);
42 static void SetScriptableHosts(Extension* extension,
43 const URLPatternSet& scriptable_hosts);
44
45 // Return the extension's manifest-specified permissions. In no cases should
46 // these permissions be used to determine if an action is allowed. Instead,
47 // use PermissionsData.
48 static scoped_refptr<const PermissionSet> GetRequiredPermissions(
49 const Extension* extension);
50 static scoped_refptr<const PermissionSet> GetOptionalPermissions(
51 const Extension* extension);
52
53 private:
54 struct InitialPermissions;
55
56 // The initial permissions for the extension, which can still be modified.
57 scoped_ptr<InitialPermissions> initial_required_permissions_;
58 scoped_ptr<InitialPermissions> initial_optional_permissions_;
59 };
60
61 } // namespace extensions
62
63 #endif // EXTENSIONS_COMMON_MANIFEST_HANDLERS_PERMISSIONS_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698