| 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 |
| 11 #include "base/string16.h" | 11 #include "base/string16.h" |
| 12 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
| 13 #include "chrome/common/extensions/manifest.h" |
| 13 | 14 |
| 14 namespace extensions { | 15 namespace extensions { |
| 15 | 16 |
| 16 class Manifest; | |
| 17 | |
| 18 class ManifestHandler { | 17 class ManifestHandler { |
| 19 public: | 18 public: |
| 20 ManifestHandler(); | 19 ManifestHandler(); |
| 21 virtual ~ManifestHandler(); | 20 virtual ~ManifestHandler(); |
| 22 | 21 |
| 23 // Attempts to parse the extension's manifest. | 22 // Attempts to parse the extension's manifest. |
| 24 // Returns true on success or false on failure; if false, |error| will | 23 // Returns true on success or false on failure; if false, |error| will |
| 25 // be set to a failure message. | 24 // be set to a failure message. |
| 26 virtual bool Parse(Extension* extension, string16* error) = 0; | 25 virtual bool Parse(Extension* extension, string16* error) = 0; |
| 27 | 26 |
| 28 // If false (the default), only parse the manifest if a registered | 27 // If false (the default), only parse the manifest if a registered |
| 29 // key is present in the manifest. If true, always attempt to parse | 28 // key is present in the manifest. If true, always attempt to parse |
| 30 // the manifest for this extension type, even if no registered keys | 29 // the manifest for this extension type, even if no registered keys |
| 31 // are present. This allows specifying a default parsed value for | 30 // are present. This allows specifying a default parsed value for |
| 32 // extensions that don't declare our key in the manifest. | 31 // extensions that don't declare our key in the manifest. |
| 33 // TODO(yoz): Use Feature availability instead. | 32 // TODO(yoz): Use Feature availability instead. |
| 34 virtual bool AlwaysParseForType(Extension::Type type); | 33 virtual bool AlwaysParseForType(Manifest::Type type); |
| 35 | 34 |
| 36 // Associate |handler| with |key| in the manifest. A handler can register | 35 // Associate |handler| with |key| in the manifest. A handler can register |
| 37 // for multiple keys. The global registry takes ownership of |handler|; | 36 // for multiple keys. The global registry takes ownership of |handler|; |
| 38 // if it has an existing handler for |key|, it replaces it with this one. | 37 // if it has an existing handler for |key|, it replaces it with this one. |
| 39 // | 38 // |
| 40 // WARNING: Manifest handlers registered only in the browser process | 39 // WARNING: Manifest handlers registered only in the browser process |
| 41 // are not available to renderers or utility processes. | 40 // are not available to renderers or utility processes. |
| 42 static void Register(const std::string& key, ManifestHandler* handler); | 41 static void Register(const std::string& key, ManifestHandler* handler); |
| 43 | 42 |
| 44 // Call Parse on all registered manifest handlers that should parse | 43 // Call Parse on all registered manifest handlers that should parse |
| 45 // this extension. | 44 // this extension. |
| 46 static bool ParseExtension(Extension* extension, string16* error); | 45 static bool ParseExtension(Extension* extension, string16* error); |
| 47 }; | 46 }; |
| 48 | 47 |
| 49 } // namespace extensions | 48 } // namespace extensions |
| 50 | 49 |
| 51 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLER_H_ | 50 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLER_H_ |
| OLD | NEW |