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 #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/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 = provider->GetFeature(*feature_name); | 150 Feature* feature = provider->GetFeature(*feature_name); |
151 Feature::Availability result = feature->IsAvailableToManifest( | 151 Feature::Availability result = feature->IsAvailableToManifest( |
152 extension_id_, type_, Feature::ConvertLocation(location_), | 152 extension_id_, type_, Feature::ConvertLocation(location_), |
153 GetManifestVersion()); | 153 GetManifestVersion()); |
154 if (!result.is_available()) | 154 if (!result.is_available()) |
155 warnings->push_back(InstallWarning( | 155 warnings->push_back(InstallWarning(result.message(), *feature_name)); |
156 InstallWarning::FORMAT_TEXT, result.message())); | |
157 } | 156 } |
158 | 157 |
159 // Also generate warnings for keys that are not features. | 158 // Also generate warnings for keys that are not features. |
160 for (base::DictionaryValue::Iterator it(*value_); !it.IsAtEnd(); | 159 for (base::DictionaryValue::Iterator it(*value_); !it.IsAtEnd(); |
161 it.Advance()) { | 160 it.Advance()) { |
162 if (!provider->GetFeature(it.key())) { | 161 if (!provider->GetFeature(it.key())) { |
163 warnings->push_back(InstallWarning( | 162 warnings->push_back(InstallWarning( |
164 InstallWarning::FORMAT_TEXT, | |
165 base::StringPrintf("Unrecognized manifest key '%s'.", | 163 base::StringPrintf("Unrecognized manifest key '%s'.", |
166 it.key().c_str()))); | 164 it.key().c_str()), |
| 165 it.key())); |
167 } | 166 } |
168 } | 167 } |
169 return true; | 168 return true; |
170 } | 169 } |
171 | 170 |
172 bool Manifest::HasKey(const std::string& key) const { | 171 bool Manifest::HasKey(const std::string& key) const { |
173 return CanAccessKey(key) && value_->HasKey(key); | 172 return CanAccessKey(key) && value_->HasKey(key); |
174 } | 173 } |
175 | 174 |
176 bool Manifest::HasPath(const std::string& path) const { | 175 bool Manifest::HasPath(const std::string& path) const { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 Feature* feature = FeatureProvider::GetByName("manifest")->GetFeature(key); | 248 Feature* feature = FeatureProvider::GetByName("manifest")->GetFeature(key); |
250 if (!feature) | 249 if (!feature) |
251 return true; | 250 return true; |
252 | 251 |
253 return feature->IsAvailableToManifest( | 252 return feature->IsAvailableToManifest( |
254 extension_id_, type_, Feature::ConvertLocation(location_), | 253 extension_id_, type_, Feature::ConvertLocation(location_), |
255 GetManifestVersion()).is_available(); | 254 GetManifestVersion()).is_available(); |
256 } | 255 } |
257 | 256 |
258 } // namespace extensions | 257 } // namespace extensions |
OLD | NEW |