OLD | NEW |
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_MANIFEST_HANDLER_H_ | 5 #ifndef EXTENSIONS_COMMON_MANIFEST_HANDLER_H_ |
6 #define EXTENSIONS_COMMON_MANIFEST_HANDLER_H_ | 6 #define EXTENSIONS_COMMON_MANIFEST_HANDLER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 11 matching lines...) Expand all Loading... |
22 // An interface for clients that recognize and parse keys in extension | 22 // An interface for clients that recognize and parse keys in extension |
23 // manifests. | 23 // manifests. |
24 class ManifestHandler { | 24 class ManifestHandler { |
25 public: | 25 public: |
26 ManifestHandler(); | 26 ManifestHandler(); |
27 virtual ~ManifestHandler(); | 27 virtual ~ManifestHandler(); |
28 | 28 |
29 // Attempts to parse the extension's manifest. | 29 // Attempts to parse the extension's manifest. |
30 // Returns true on success or false on failure; if false, |error| will | 30 // Returns true on success or false on failure; if false, |error| will |
31 // be set to a failure message. | 31 // be set to a failure message. |
32 virtual bool Parse(Extension* extension, string16* error) = 0; | 32 virtual bool Parse(Extension* extension, base::string16* error) = 0; |
33 | 33 |
34 // Validate that files associated with this manifest key exist. | 34 // Validate that files associated with this manifest key exist. |
35 // Validation takes place after parsing. May also append a series of | 35 // Validation takes place after parsing. May also append a series of |
36 // warning messages to |warnings|. | 36 // warning messages to |warnings|. |
37 // | 37 // |
38 // Otherwise, returns false, and a description of the error is | 38 // Otherwise, returns false, and a description of the error is |
39 // returned in |error|. | 39 // returned in |error|. |
40 // TODO(yoz): Change error to string16. See crbug.com/71980. | 40 // TODO(yoz): Change error to base::string16. See crbug.com/71980. |
41 virtual bool Validate(const Extension* extension, | 41 virtual bool Validate(const Extension* extension, |
42 std::string* error, | 42 std::string* error, |
43 std::vector<InstallWarning>* warnings) const; | 43 std::vector<InstallWarning>* warnings) const; |
44 | 44 |
45 // If false (the default), only parse the manifest if a registered | 45 // If false (the default), only parse the manifest if a registered |
46 // key is present in the manifest. If true, always attempt to parse | 46 // key is present in the manifest. If true, always attempt to parse |
47 // the manifest for this extension type, even if no registered keys | 47 // the manifest for this extension type, even if no registered keys |
48 // are present. This allows specifying a default parsed value for | 48 // are present. This allows specifying a default parsed value for |
49 // extensions that don't declare our key in the manifest. | 49 // extensions that don't declare our key in the manifest. |
50 // TODO(yoz): Use Feature availability instead. | 50 // TODO(yoz): Use Feature availability instead. |
(...skipping 29 matching lines...) Expand all Loading... |
80 const Extension* extension); | 80 const Extension* extension); |
81 | 81 |
82 // Calling FinalizeRegistration indicates that there are no more | 82 // Calling FinalizeRegistration indicates that there are no more |
83 // manifest handlers to be registered. | 83 // manifest handlers to be registered. |
84 static void FinalizeRegistration(); | 84 static void FinalizeRegistration(); |
85 | 85 |
86 static bool IsRegistrationFinalized(); | 86 static bool IsRegistrationFinalized(); |
87 | 87 |
88 // Call Parse on all registered manifest handlers that should parse | 88 // Call Parse on all registered manifest handlers that should parse |
89 // this extension. | 89 // this extension. |
90 static bool ParseExtension(Extension* extension, string16* error); | 90 static bool ParseExtension(Extension* extension, base::string16* error); |
91 | 91 |
92 // Call Validate on all registered manifest handlers for this extension. | 92 // Call Validate on all registered manifest handlers for this extension. |
93 static bool ValidateExtension(const Extension* extension, | 93 static bool ValidateExtension(const Extension* extension, |
94 std::string* error, | 94 std::string* error, |
95 std::vector<InstallWarning>* warnings); | 95 std::vector<InstallWarning>* warnings); |
96 | 96 |
97 // Calls |CreatePermission| on the manifest handler for |key|. Returns |NULL| | 97 // Calls |CreatePermission| on the manifest handler for |key|. Returns |NULL| |
98 // if there is no manifest handler for |key| or if the manifest handler for | 98 // if there is no manifest handler for |key| or if the manifest handler for |
99 // |key| does not support custom permissions. | 99 // |key| does not support custom permissions. |
100 static ManifestPermission* CreatePermission(const std::string& key); | 100 static ManifestPermission* CreatePermission(const std::string& key); |
(...skipping 24 matching lines...) Expand all Loading... |
125 friend class ScopedTestingManifestHandlerRegistry; | 125 friend class ScopedTestingManifestHandlerRegistry; |
126 friend struct base::DefaultLazyInstanceTraits<ManifestHandlerRegistry>; | 126 friend struct base::DefaultLazyInstanceTraits<ManifestHandlerRegistry>; |
127 | 127 |
128 ManifestHandlerRegistry(); | 128 ManifestHandlerRegistry(); |
129 ~ManifestHandlerRegistry(); | 129 ~ManifestHandlerRegistry(); |
130 | 130 |
131 void Finalize(); | 131 void Finalize(); |
132 | 132 |
133 void RegisterManifestHandler(const std::string& key, | 133 void RegisterManifestHandler(const std::string& key, |
134 linked_ptr<ManifestHandler> handler); | 134 linked_ptr<ManifestHandler> handler); |
135 bool ParseExtension(Extension* extension, string16* error); | 135 bool ParseExtension(Extension* extension, base::string16* error); |
136 bool ValidateExtension(const Extension* extension, | 136 bool ValidateExtension(const Extension* extension, |
137 std::string* error, | 137 std::string* error, |
138 std::vector<InstallWarning>* warnings); | 138 std::vector<InstallWarning>* warnings); |
139 | 139 |
140 ManifestPermission* CreatePermission(const std::string& key); | 140 ManifestPermission* CreatePermission(const std::string& key); |
141 | 141 |
142 void AddExtensionInitialRequiredPermissions( | 142 void AddExtensionInitialRequiredPermissions( |
143 const Extension* extension, | 143 const Extension* extension, |
144 ManifestPermissionSet* permission_set); | 144 ManifestPermissionSet* permission_set); |
145 | 145 |
(...skipping 18 matching lines...) Expand all Loading... |
164 // The priority for each manifest handler. Handlers with lower priority | 164 // The priority for each manifest handler. Handlers with lower priority |
165 // values are evaluated first. | 165 // values are evaluated first. |
166 ManifestHandlerPriorityMap priority_map_; | 166 ManifestHandlerPriorityMap priority_map_; |
167 | 167 |
168 bool is_finalized_; | 168 bool is_finalized_; |
169 }; | 169 }; |
170 | 170 |
171 } // namespace extensions | 171 } // namespace extensions |
172 | 172 |
173 #endif // EXTENSIONS_COMMON_MANIFEST_HANDLER_H_ | 173 #endif // EXTENSIONS_COMMON_MANIFEST_HANDLER_H_ |
OLD | NEW |