Chromium Code Reviews| Index: chrome/common/extensions/manifest_handler.h |
| diff --git a/chrome/common/extensions/manifest_handler.h b/chrome/common/extensions/manifest_handler.h |
| index f9797d3bd7db5ef061ad35fa1431eed2da2ce031..8435af8d94bab8f3068ab16a5602e3cafaaac41a 100644 |
| --- a/chrome/common/extensions/manifest_handler.h |
| +++ b/chrome/common/extensions/manifest_handler.h |
| @@ -5,54 +5,44 @@ |
| #ifndef CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLER_H_ |
| #define CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLER_H_ |
| +#include <set> |
| #include <string> |
| -#include <vector> |
| #include "base/string16.h" |
| - |
| -namespace base { |
| -class Value; |
| -} |
| +#include "chrome/common/extensions/extension.h" |
| namespace extensions { |
| -class Extension; |
| +class Manifest; |
| class ManifestHandler { |
| public: |
| ManifestHandler(); |
| virtual ~ManifestHandler(); |
| - // Attempts to parse the manifest value. |
| - // Returns true on success or false on failure; if false, |error| will |
| - // be set to a failure message. |
| - virtual bool Parse(const base::Value* value, |
| - Extension* extension, |
| - string16* error) = 0; |
| - |
| - // Perform any initialization which is necessary when the Handler's key is |
| - // not present in the manifest. |
| + // Attempts to parse the extension's manifest. |
| // Returns true on success or false on failure; if false, |error| will |
| // be set to a failure message. |
| - virtual bool HasNoKey(Extension* extension, string16* error); |
| - |
| - // Associate |handler| with |key| in the manifest. Takes ownership |
| - // of |handler|. TODO(yoz): Decide how to handle dotted subkeys. |
| + virtual bool Parse(Extension* extension, string16* error) = 0; |
| + |
| + // If false (the default), only parse the manifest if a registered |
| + // key is present in the manifest. If true, always attempt to parse |
| + // the manifest for this extension type, even if no registered keys |
| + // are present. |
|
Matt Perry
2013/01/29 00:58:47
Could you add a sentence or two on when this would
Yoyo Zhou
2013/01/29 04:32:42
Done.
|
| + virtual bool AlwaysParseForType(Extension::Type type); |
| + |
| + // Associate |handler| with |key| in the manifest. A handler can register |
| + // for multiple keys. The global registry takes ownership of |handler|; |
| + // if it has an existing handler for |key|, it replaces it with this one. |
| + // |
| // WARNING: Manifest handlers registered only in the browser process |
| - // are not available to renderers. |
| + // are not available to renderers or utility processes. |
| static void Register(const std::string& key, ManifestHandler* handler); |
| - // Get the manifest handler associated with |key|, or NULL |
| - // if there is none. |
| - static ManifestHandler* Get(const std::string& key); |
| - |
| - // If the handler is not handling most of the keys, it may be |
| - // more efficient to have a list of keys to iterate over. |
| - // TODO(yoz): this isn't the long-term solution. |
| - static std::vector<std::string> GetKeys(); |
| + // Get all registered manifest handlers that should parse |manifest|. |
| + static std::set<ManifestHandler*> GetHandlers(const Manifest* manifest); |
| }; |
| - |
| } // namespace extensions |
| #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLER_H_ |