Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_MANIFEST_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_MANIFEST_H_ | 6 #define CHROME_COMMON_EXTENSIONS_MANIFEST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 virtual ~Manifest(); | 26 virtual ~Manifest(); |
| 27 | 27 |
| 28 const std::string& extension_id() const { return extension_id_; } | 28 const std::string& extension_id() const { return extension_id_; } |
| 29 void set_extension_id(const std::string& id) { extension_id_ = id; } | 29 void set_extension_id(const std::string& id) { extension_id_ = id; } |
| 30 | 30 |
| 31 Extension::Location location() const { return location_; } | 31 Extension::Location location() const { return location_; } |
| 32 void set_location(Extension::Location location) { location_ = location; } | 32 void set_location(Extension::Location location) { location_ = location; } |
| 33 | 33 |
| 34 // Returns true if all keys in the manifest can be specified by | 34 // Returns true if all keys in the manifest can be specified by |
| 35 // the extension type. | 35 // the extension type. |
| 36 bool ValidateManifest(string16* error) const; | 36 bool ValidateManifest(string16* error); |
| 37 | 37 |
| 38 // The version of this extension's manifest. We increase the manifest | 38 // The version of this extension's manifest. We increase the manifest |
| 39 // version when making breaking changes to the extension system. If the | 39 // version when making breaking changes to the extension system. If the |
| 40 // manifest contains no explicit manifest version, this returns the current | 40 // manifest contains no explicit manifest version, this returns the current |
| 41 // system default. | 41 // system default. |
| 42 int GetManifestVersion() const; | 42 int GetManifestVersion() const; |
| 43 | 43 |
| 44 // Returns the manifest type. | 44 // Returns the manifest type. |
| 45 Extension::Type GetType() const; | 45 Extension::Type GetType() const; |
| 46 | 46 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 72 // the caller. | 72 // the caller. |
| 73 Manifest* DeepCopy() const; | 73 Manifest* DeepCopy() const; |
| 74 | 74 |
| 75 // Returns true if this equals the |other| manifest. | 75 // Returns true if this equals the |other| manifest. |
| 76 bool Equals(const Manifest* other) const; | 76 bool Equals(const Manifest* other) const; |
| 77 | 77 |
| 78 // Gets the underlying DictionaryValue representing the manifest. | 78 // Gets the underlying DictionaryValue representing the manifest. |
| 79 // Note: only know this when you KNOW you don't need the validation. | 79 // Note: only know this when you KNOW you don't need the validation. |
| 80 base::DictionaryValue* value() const { return value_.get(); } | 80 base::DictionaryValue* value() const { return value_.get(); } |
| 81 | 81 |
| 82 // Gets the list of unrecognized keys in the manifest, if any. | |
| 83 // Unrecognized keys are filled in when ValidateManifest is called. | |
| 84 bool HasUnrecognizedKeys( | |
| 85 const std::vector<const std::string*>** unrecognized_keys) const; | |
|
not at google - send to devlin
2012/04/09 13:01:54
The unrecognised keys are unlikely to be a lot of
| |
| 86 | |
| 82 private: | 87 private: |
| 83 // Returns true if the extension can specify the given |path|. | 88 // Returns true if the extension can specify the given |path|. |
| 84 bool CanAccessPath(const std::string& path) const; | 89 bool CanAccessPath(const std::string& path) const; |
| 85 bool CanAccessKey(const std::string& key) const; | 90 bool CanAccessKey(const std::string& key) const; |
| 86 | 91 |
| 87 // A persistent, globally unique ID. An extension's ID is used in things | 92 // A persistent, globally unique ID. An extension's ID is used in things |
| 88 // like directory structures and URLs, and is expected to not change across | 93 // like directory structures and URLs, and is expected to not change across |
| 89 // versions. It is generated as a SHA-256 hash of the extension's public | 94 // versions. It is generated as a SHA-256 hash of the extension's public |
| 90 // key, or as a hash of the path in the case of unpacked extensions. | 95 // key, or as a hash of the path in the case of unpacked extensions. |
| 91 std::string extension_id_; | 96 std::string extension_id_; |
| 92 | 97 |
| 93 // The location the extension was loaded from. | 98 // The location the extension was loaded from. |
| 94 Extension::Location location_; | 99 Extension::Location location_; |
| 95 | 100 |
| 96 // The underlying dictionary representation of the manifest. | 101 // The underlying dictionary representation of the manifest. |
| 97 scoped_ptr<base::DictionaryValue> value_; | 102 scoped_ptr<base::DictionaryValue> value_; |
| 98 | 103 |
| 104 // Unrecognized keys (e.g. "permisions": ["tabs"]) | |
| 105 std::vector<const std::string*> unrecognized_keys_; | |
|
not at google - send to devlin
2012/04/09 13:01:54
Make this a scoped_ptr<std::vector<std::string> >
| |
| 106 | |
| 99 DISALLOW_COPY_AND_ASSIGN(Manifest); | 107 DISALLOW_COPY_AND_ASSIGN(Manifest); |
| 100 }; | 108 }; |
| 101 | 109 |
| 102 } // namespace extensions | 110 } // namespace extensions |
| 103 | 111 |
| 104 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_H_ | 112 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_H_ |
| OLD | NEW |