Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: chrome/common/extensions/manifest.cc

Issue 9705083: Unknown options in extension manifest file are silently ignored (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Removed an accedentally-included file Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "chrome/common/extensions/manifest.h" 5 #include "chrome/common/extensions/manifest.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
11 #include "chrome/common/extensions/extension_constants.h" 11 #include "chrome/common/extensions/extension_constants.h"
12 #include "chrome/common/extensions/extension_error_utils.h" 12 #include "chrome/common/extensions/extension_error_utils.h"
13 #include "chrome/common/extensions/manifest_feature_provider.h" 13 #include "chrome/common/extensions/manifest_feature_provider.h"
14 14
15 namespace errors = extension_manifest_errors; 15 namespace errors = extension_manifest_errors;
16 namespace keys = extension_manifest_keys; 16 namespace keys = extension_manifest_keys;
17 17
18 namespace extensions { 18 namespace extensions {
19 19
20 Manifest::Manifest(Extension::Location location, 20 Manifest::Manifest(Extension::Location location,
21 scoped_ptr<DictionaryValue> value) 21 scoped_ptr<DictionaryValue> value)
22 : location_(location), value_(value.Pass()) { 22 : location_(location), value_(value.Pass()) {
23 } 23 }
24 24
25 Manifest::~Manifest() { 25 Manifest::~Manifest() {
26 } 26 }
27 27
28 bool Manifest::ValidateManifest(string16* error) const { 28 bool Manifest::ValidateManifest(string16* error) {
29 for (DictionaryValue::key_iterator key = value_->begin_keys(); 29 for (DictionaryValue::key_iterator key = value_->begin_keys();
30 key != value_->end_keys(); ++key) { 30 key != value_->end_keys(); ++key) {
31 scoped_ptr<Feature> feature = 31 scoped_ptr<Feature> feature =
32 ManifestFeatureProvider::GetDefaultInstance()->GetFeature(*key); 32 ManifestFeatureProvider::GetDefaultInstance()->GetFeature(*key);
33 if (!feature.get()) { 33 if (!feature.get()) {
34 // When validating the extension manifests, we ignore keys that are not 34 // When validating the extension manifests, we ignore keys that are not
35 // recognized for forward compatibility. 35 // recognized for forward compatibility.
36 // TODO(aa): Consider having an error here in the case of strict error 36 // TODO(aa): Consider having an error here in the case of strict error
37 // checking to let developers know when they screw up. 37 // checking to let developers know when they screw up.
38 unrecognized_keys_.push_back(&(*key));
38 continue; 39 continue;
39 } 40 }
40 41
41 Feature::Availability result = feature->IsAvailable( 42 Feature::Availability result = feature->IsAvailable(
42 extension_id_, GetType(), Feature::ConvertLocation(location_), 43 extension_id_, GetType(), Feature::ConvertLocation(location_),
43 GetManifestVersion()); 44 GetManifestVersion());
44 if (result != Feature::IS_AVAILABLE) { 45 if (result != Feature::IS_AVAILABLE) {
45 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( 46 *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
46 errors::kFeatureNotAllowed, 47 errors::kFeatureNotAllowed,
47 *key, 48 *key,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 bool Manifest::GetDictionary( 86 bool Manifest::GetDictionary(
86 const std::string& path, DictionaryValue** out_value) const { 87 const std::string& path, DictionaryValue** out_value) const {
87 return CanAccessPath(path) && value_->GetDictionary(path, out_value); 88 return CanAccessPath(path) && value_->GetDictionary(path, out_value);
88 } 89 }
89 90
90 bool Manifest::GetList( 91 bool Manifest::GetList(
91 const std::string& path, ListValue** out_value) const { 92 const std::string& path, ListValue** out_value) const {
92 return CanAccessPath(path) && value_->GetList(path, out_value); 93 return CanAccessPath(path) && value_->GetList(path, out_value);
93 } 94 }
94 95
96 bool Manifest::HasUnrecognizedKeys(
97 const std::vector<const std::string*>** unrecognized_keys) const {
98 if (!unrecognized_keys_.empty()) {
99 *unrecognized_keys = &unrecognized_keys_;
100 return true;
101 }
102
103 return false;
104 }
105
95 Manifest* Manifest::DeepCopy() const { 106 Manifest* Manifest::DeepCopy() const {
96 Manifest* manifest = new Manifest( 107 Manifest* manifest = new Manifest(
97 location_, scoped_ptr<DictionaryValue>(value_->DeepCopy())); 108 location_, scoped_ptr<DictionaryValue>(value_->DeepCopy()));
98 manifest->set_extension_id(extension_id_); 109 manifest->set_extension_id(extension_id_);
99 return manifest; 110 return manifest;
100 } 111 }
101 112
102 bool Manifest::Equals(const Manifest* other) const { 113 bool Manifest::Equals(const Manifest* other) const {
103 return other && value_->Equals(other->value()); 114 return other && value_->Equals(other->value());
104 } 115 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 ManifestFeatureProvider::GetDefaultInstance()->GetFeature(key); 165 ManifestFeatureProvider::GetDefaultInstance()->GetFeature(key);
155 if (!feature.get()) 166 if (!feature.get())
156 return false; 167 return false;
157 168
158 return Feature::IS_AVAILABLE == feature->IsAvailable( 169 return Feature::IS_AVAILABLE == feature->IsAvailable(
159 extension_id_, GetType(), Feature::ConvertLocation(location_), 170 extension_id_, GetType(), Feature::ConvertLocation(location_),
160 GetManifestVersion()); 171 GetManifestVersion());
161 } 172 }
162 173
163 } // namespace extensions 174 } // namespace extensions
OLDNEW
« chrome/common/extensions/manifest.h ('K') | « chrome/common/extensions/manifest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698