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

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

Issue 1772683002: FeatureProvider returns std::map instead of vector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 #include "extensions/common/manifest.h" 5 #include "extensions/common/manifest.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 *error = ""; 139 *error = "";
140 140
141 // Check every feature to see if its in the manifest. Note that this means 141 // Check every feature to see if its in the manifest. Note that this means
142 // we will ignore keys that are not features; we do this for forward 142 // we will ignore keys that are not features; we do this for forward
143 // compatibility. 143 // compatibility.
144 // TODO(aa): Consider having an error here in the case of strict error 144 // TODO(aa): Consider having an error here in the case of strict error
145 // checking to let developers know when they screw up. 145 // checking to let developers know when they screw up.
146 146
147 const FeatureProvider* manifest_feature_provider = 147 const FeatureProvider* manifest_feature_provider =
148 FeatureProvider::GetManifestFeatures(); 148 FeatureProvider::GetManifestFeatures();
149 const std::vector<std::string>& feature_names = 149 for (const auto& map_entry : manifest_feature_provider->GetAllFeatures()) {
150 manifest_feature_provider->GetAllFeatureNames();
151 for (std::vector<std::string>::const_iterator feature_name =
152 feature_names.begin();
153 feature_name != feature_names.end(); ++feature_name) {
154 // Use Get instead of HasKey because the former uses path expansion. 150 // Use Get instead of HasKey because the former uses path expansion.
155 if (!value_->Get(*feature_name, NULL)) 151 if (!value_->Get(map_entry.first, nullptr))
156 continue; 152 continue;
157 153
158 Feature* feature = manifest_feature_provider->GetFeature(*feature_name); 154 Feature::Availability result = map_entry.second->IsAvailableToManifest(
159 Feature::Availability result = feature->IsAvailableToManifest(
160 extension_id_, type_, location_, GetManifestVersion()); 155 extension_id_, type_, location_, GetManifestVersion());
161 if (!result.is_available()) 156 if (!result.is_available())
162 warnings->push_back(InstallWarning(result.message(), *feature_name)); 157 warnings->push_back(InstallWarning(result.message(), map_entry.first));
163 } 158 }
164 159
165 // Also generate warnings for keys that are not features. 160 // Also generate warnings for keys that are not features.
166 for (base::DictionaryValue::Iterator it(*value_); !it.IsAtEnd(); 161 for (base::DictionaryValue::Iterator it(*value_); !it.IsAtEnd();
167 it.Advance()) { 162 it.Advance()) {
168 if (!manifest_feature_provider->GetFeature(it.key())) { 163 if (!manifest_feature_provider->GetFeature(it.key())) {
169 warnings->push_back(InstallWarning( 164 warnings->push_back(InstallWarning(
170 ErrorUtils::FormatErrorMessage( 165 ErrorUtils::FormatErrorMessage(
171 manifest_errors::kUnrecognizedManifestKey, it.key()), 166 manifest_errors::kUnrecognizedManifestKey, it.key()),
172 it.key())); 167 it.key()));
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 Feature* feature = FeatureProvider::GetManifestFeatures()->GetFeature(key); 249 Feature* feature = FeatureProvider::GetManifestFeatures()->GetFeature(key);
255 if (!feature) 250 if (!feature)
256 return true; 251 return true;
257 252
258 return feature->IsAvailableToManifest( 253 return feature->IsAvailableToManifest(
259 extension_id_, type_, location_, GetManifestVersion()) 254 extension_id_, type_, location_, GetManifestVersion())
260 .is_available(); 255 .is_available();
261 } 256 }
262 257
263 } // namespace extensions 258 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/features/feature_provider.h ('k') | extensions/renderer/api_definitions_natives.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698