| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 feature_name != feature_names.end(); ++feature_name) { | 150 feature_name != feature_names.end(); ++feature_name) { |
| 151 // Use Get instead of HasKey because the former uses path expansion. | 151 // Use Get instead of HasKey because the former uses path expansion. |
| 152 if (!value_->Get(*feature_name, NULL)) | 152 if (!value_->Get(*feature_name, NULL)) |
| 153 continue; | 153 continue; |
| 154 | 154 |
| 155 Feature* feature = provider->GetFeature(*feature_name); | 155 Feature* feature = provider->GetFeature(*feature_name); |
| 156 Feature::Availability result = feature->IsAvailableToManifest( | 156 Feature::Availability result = feature->IsAvailableToManifest( |
| 157 extension_id_, type_, Feature::ConvertLocation(location_), | 157 extension_id_, type_, Feature::ConvertLocation(location_), |
| 158 GetManifestVersion()); | 158 GetManifestVersion()); |
| 159 if (!result.is_available()) | 159 if (!result.is_available()) |
| 160 warnings->push_back(InstallWarning( | 160 warnings->push_back(InstallWarning(result.message(), *feature_name)); |
| 161 InstallWarning::FORMAT_TEXT, result.message())); | |
| 162 } | 161 } |
| 163 | 162 |
| 164 // Also generate warnings for keys that are not features. | 163 // Also generate warnings for keys that are not features. |
| 165 for (base::DictionaryValue::Iterator it(*value_); !it.IsAtEnd(); | 164 for (base::DictionaryValue::Iterator it(*value_); !it.IsAtEnd(); |
| 166 it.Advance()) { | 165 it.Advance()) { |
| 167 if (!provider->GetFeature(it.key())) { | 166 if (!provider->GetFeature(it.key())) { |
| 168 warnings->push_back(InstallWarning( | 167 warnings->push_back(InstallWarning( |
| 169 InstallWarning::FORMAT_TEXT, | |
| 170 base::StringPrintf("Unrecognized manifest key '%s'.", | 168 base::StringPrintf("Unrecognized manifest key '%s'.", |
| 171 it.key().c_str()))); | 169 it.key().c_str()), |
| 170 it.key())); |
| 172 } | 171 } |
| 173 } | 172 } |
| 174 return true; | 173 return true; |
| 175 } | 174 } |
| 176 | 175 |
| 177 bool Manifest::HasKey(const std::string& key) const { | 176 bool Manifest::HasKey(const std::string& key) const { |
| 178 return CanAccessKey(key) && value_->HasKey(key); | 177 return CanAccessKey(key) && value_->HasKey(key); |
| 179 } | 178 } |
| 180 | 179 |
| 181 bool Manifest::HasPath(const std::string& path) const { | 180 bool Manifest::HasPath(const std::string& path) const { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 Feature* feature = FeatureProvider::GetByName("manifest")->GetFeature(key); | 253 Feature* feature = FeatureProvider::GetByName("manifest")->GetFeature(key); |
| 255 if (!feature) | 254 if (!feature) |
| 256 return true; | 255 return true; |
| 257 | 256 |
| 258 return feature->IsAvailableToManifest( | 257 return feature->IsAvailableToManifest( |
| 259 extension_id_, type_, Feature::ConvertLocation(location_), | 258 extension_id_, type_, Feature::ConvertLocation(location_), |
| 260 GetManifestVersion()).is_available(); | 259 GetManifestVersion()).is_available(); |
| 261 } | 260 } |
| 262 | 261 |
| 263 } // namespace extensions | 262 } // namespace extensions |
| OLD | NEW |