| 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 CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLER_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLER_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLER_H_ | 6 #define CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // Returns true on success or false on failure; if false, |error| will | 24 // Returns true on success or false on failure; if false, |error| will |
| 25 // be set to a failure message. | 25 // be set to a failure message. |
| 26 virtual bool Parse(Extension* extension, string16* error) = 0; | 26 virtual bool Parse(Extension* extension, string16* error) = 0; |
| 27 | 27 |
| 28 // If false (the default), only parse the manifest if a registered | 28 // If false (the default), only parse the manifest if a registered |
| 29 // key is present in the manifest. If true, always attempt to parse | 29 // key is present in the manifest. If true, always attempt to parse |
| 30 // the manifest for this extension type, even if no registered keys | 30 // the manifest for this extension type, even if no registered keys |
| 31 // are present. This allows specifying a default parsed value for | 31 // are present. This allows specifying a default parsed value for |
| 32 // extensions that don't declare our key in the manifest. | 32 // extensions that don't declare our key in the manifest. |
| 33 // TODO(yoz): Use Feature availability instead. | 33 // TODO(yoz): Use Feature availability instead. |
| 34 virtual bool AlwaysParseForType(Manifest::Type type); | 34 virtual bool AlwaysParseForType(Manifest::Type type) const; |
| 35 | 35 |
| 36 // The list of keys that, if present, should be parsed before calling our | 36 // The list of keys that, if present, should be parsed before calling our |
| 37 // Parse (typically, because our Parse needs to read those keys). | 37 // Parse (typically, because our Parse needs to read those keys). |
| 38 // Defaults to empty. | 38 // Defaults to empty. |
| 39 virtual const std::vector<std::string>& PrerequisiteKeys(); | 39 virtual const std::vector<std::string>& PrerequisiteKeys() const; |
| 40 | 40 |
| 41 // Associate |handler| with |key| in the manifest. A handler can register | 41 // Associate |handler| with |key| in the manifest. A handler can register |
| 42 // for multiple keys. The global registry takes ownership of |handler|; | 42 // for multiple keys. The global registry takes ownership of |handler|; |
| 43 // if it has an existing handler for |key|, it replaces it with this one. | 43 // if it has an existing handler for |key|, it replaces it with this one. |
| 44 // | 44 // |
| 45 // WARNING: Manifest handlers registered only in the browser process | 45 // WARNING: Manifest handlers registered only in the browser process |
| 46 // are not available to renderers or utility processes. | 46 // are not available to renderers or utility processes. |
| 47 static void Register(const std::string& key, | 47 static void Register(const std::string& key, |
| 48 linked_ptr<ManifestHandler> handler); | 48 linked_ptr<ManifestHandler> handler); |
| 49 | 49 |
| 50 // Call Parse on all registered manifest handlers that should parse | 50 // Call Parse on all registered manifest handlers that should parse |
| 51 // this extension. | 51 // this extension. |
| 52 static bool ParseExtension(Extension* extension, string16* error); | 52 static bool ParseExtension(Extension* extension, string16* error); |
| 53 | 53 |
| 54 // Reset the manifest handler registry to an empty state. Useful for | 54 // Reset the manifest handler registry to an empty state. Useful for |
| 55 // unit tests. | 55 // unit tests. |
| 56 static void ClearRegistryForTesting(); | 56 static void ClearRegistryForTesting(); |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 } // namespace extensions | 59 } // namespace extensions |
| 60 | 60 |
| 61 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLER_H_ | 61 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLER_H_ |
| OLD | NEW |