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

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: Fixed unit test Created 8 years, 7 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 "base/stringprintf.h"
11 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
12 #include "chrome/common/extensions/extension_manifest_constants.h" 13 #include "chrome/common/extensions/extension_manifest_constants.h"
13 #include "chrome/common/extensions/extension_error_utils.h" 14 #include "chrome/common/extensions/extension_error_utils.h"
14 #include "chrome/common/extensions/simple_feature_provider.h" 15 #include "chrome/common/extensions/simple_feature_provider.h"
15 16
16 namespace errors = extension_manifest_errors; 17 namespace errors = extension_manifest_errors;
17 namespace keys = extension_manifest_keys; 18 namespace keys = extension_manifest_keys;
18 19
19 namespace extensions { 20 namespace extensions {
20 21
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 continue; 71 continue;
71 72
72 Feature* feature = 73 Feature* feature =
73 SimpleFeatureProvider::GetManifestFeatures()->GetFeature(*feature_name); 74 SimpleFeatureProvider::GetManifestFeatures()->GetFeature(*feature_name);
74 Feature::Availability result = feature->IsAvailableToManifest( 75 Feature::Availability result = feature->IsAvailableToManifest(
75 extension_id_, type_, Feature::ConvertLocation(location_), 76 extension_id_, type_, Feature::ConvertLocation(location_),
76 GetManifestVersion()); 77 GetManifestVersion());
77 if (result != Feature::IS_AVAILABLE) 78 if (result != Feature::IS_AVAILABLE)
78 warnings->push_back(feature->GetErrorMessage(result)); 79 warnings->push_back(feature->GetErrorMessage(result));
79 } 80 }
81
82 // Also generate warnings for keys that are not features.
83 for (DictionaryValue::key_iterator key = value_->begin_keys();
84 key != value_->end_keys(); ++key) {
85 if (!SimpleFeatureProvider::GetManifestFeatures()->GetFeature(*key)) {
86 warnings->push_back(base::StringPrintf("Unrecognized manifest key '%s'.",
87 (*key).c_str()));
88 }
89 }
80 } 90 }
81 91
82 bool Manifest::HasKey(const std::string& key) const { 92 bool Manifest::HasKey(const std::string& key) const {
83 return CanAccessKey(key) && value_->HasKey(key); 93 return CanAccessKey(key) && value_->HasKey(key);
84 } 94 }
85 95
86 bool Manifest::Get( 96 bool Manifest::Get(
87 const std::string& path, Value** out_value) const { 97 const std::string& path, Value** out_value) const {
88 return CanAccessPath(path) && value_->Get(path, out_value); 98 return CanAccessPath(path) && value_->Get(path, out_value);
89 } 99 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 SimpleFeatureProvider::GetManifestFeatures()->GetFeature(key); 163 SimpleFeatureProvider::GetManifestFeatures()->GetFeature(key);
154 if (!feature) 164 if (!feature)
155 return true; 165 return true;
156 166
157 return Feature::IS_AVAILABLE == feature->IsAvailableToManifest( 167 return Feature::IS_AVAILABLE == feature->IsAvailableToManifest(
158 extension_id_, type_, Feature::ConvertLocation(location_), 168 extension_id_, type_, Feature::ConvertLocation(location_),
159 GetManifestVersion()); 169 GetManifestVersion());
160 } 170 }
161 171
162 } // namespace extensions 172 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_database_migration_unittest.cc ('k') | chrome/common/extensions/manifest_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698