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

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

Issue 13997002: Load extensions features file separately when needed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix merge conflicts Created 7 years, 8 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 | Annotate | Revision Log
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/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 *error = errors::kPlatformAppNeedsManifestVersion2; 132 *error = errors::kPlatformAppNeedsManifestVersion2;
133 return false; 133 return false;
134 } 134 }
135 135
136 // Check every feature to see if its in the manifest. Note that this means 136 // Check every feature to see if its in the manifest. Note that this means
137 // we will ignore keys that are not features; we do this for forward 137 // we will ignore keys that are not features; we do this for forward
138 // compatibility. 138 // compatibility.
139 // TODO(aa): Consider having an error here in the case of strict error 139 // TODO(aa): Consider having an error here in the case of strict error
140 // checking to let developers know when they screw up. 140 // checking to let developers know when they screw up.
141 141
142 std::set<std::string> feature_names = 142 FeatureProvider* provider = BaseFeatureProvider::GetByName("manifest");
143 BaseFeatureProvider::GetManifestFeatures()->GetAllFeatureNames(); 143 std::set<std::string> feature_names = provider->GetAllFeatureNames();
144 for (std::set<std::string>::iterator feature_name = feature_names.begin(); 144 for (std::set<std::string>::iterator feature_name = feature_names.begin();
145 feature_name != feature_names.end(); ++feature_name) { 145 feature_name != feature_names.end(); ++feature_name) {
146 // Use Get instead of HasKey because the former uses path expansion. 146 // Use Get instead of HasKey because the former uses path expansion.
147 if (!value_->Get(*feature_name, NULL)) 147 if (!value_->Get(*feature_name, NULL))
148 continue; 148 continue;
149 149
150 Feature* feature = 150 Feature* feature = provider->GetFeature(*feature_name);
151 BaseFeatureProvider::GetManifestFeatures()->GetFeature(*feature_name);
152 Feature::Availability result = feature->IsAvailableToManifest( 151 Feature::Availability result = feature->IsAvailableToManifest(
153 extension_id_, type_, Feature::ConvertLocation(location_), 152 extension_id_, type_, Feature::ConvertLocation(location_),
154 GetManifestVersion()); 153 GetManifestVersion());
155 if (!result.is_available()) 154 if (!result.is_available())
156 warnings->push_back(InstallWarning( 155 warnings->push_back(InstallWarning(
157 InstallWarning::FORMAT_TEXT, result.message())); 156 InstallWarning::FORMAT_TEXT, result.message()));
158 } 157 }
159 158
160 // Also generate warnings for keys that are not features. 159 // Also generate warnings for keys that are not features.
161 for (base::DictionaryValue::Iterator it(*value_); !it.IsAtEnd(); 160 for (base::DictionaryValue::Iterator it(*value_); !it.IsAtEnd();
162 it.Advance()) { 161 it.Advance()) {
163 if (!BaseFeatureProvider::GetManifestFeatures()->GetFeature(it.key())) { 162 if (!provider->GetFeature(it.key())) {
164 warnings->push_back(InstallWarning( 163 warnings->push_back(InstallWarning(
165 InstallWarning::FORMAT_TEXT, 164 InstallWarning::FORMAT_TEXT,
166 base::StringPrintf("Unrecognized manifest key '%s'.", 165 base::StringPrintf("Unrecognized manifest key '%s'.",
167 it.key().c_str()))); 166 it.key().c_str())));
168 } 167 }
169 } 168 }
170 return true; 169 return true;
171 } 170 }
172 171
173 bool Manifest::HasKey(const std::string& key) const { 172 bool Manifest::HasKey(const std::string& key) const {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 key += components[i]; 240 key += components[i];
242 if (!CanAccessKey(key)) 241 if (!CanAccessKey(key))
243 return false; 242 return false;
244 key += '.'; 243 key += '.';
245 } 244 }
246 return true; 245 return true;
247 } 246 }
248 247
249 bool Manifest::CanAccessKey(const std::string& key) const { 248 bool Manifest::CanAccessKey(const std::string& key) const {
250 Feature* feature = 249 Feature* feature =
251 BaseFeatureProvider::GetManifestFeatures()->GetFeature(key); 250 BaseFeatureProvider::GetByName("manifest")->GetFeature(key);
252 if (!feature) 251 if (!feature)
253 return true; 252 return true;
254 253
255 return feature->IsAvailableToManifest( 254 return feature->IsAvailableToManifest(
256 extension_id_, type_, Feature::ConvertLocation(location_), 255 extension_id_, type_, Feature::ConvertLocation(location_),
257 GetManifestVersion()).is_available(); 256 GetManifestVersion()).is_available();
258 } 257 }
259 258
260 } // namespace extensions 259 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/features/feature_provider.h ('k') | chrome/renderer/extensions/dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698