| OLD | NEW |
| 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 "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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 233 |
| 234 int Manifest::GetManifestVersion() const { | 234 int Manifest::GetManifestVersion() const { |
| 235 // Platform apps were launched after manifest version 2 was the preferred | 235 // Platform apps were launched after manifest version 2 was the preferred |
| 236 // version, so they default to that. | 236 // version, so they default to that. |
| 237 int manifest_version = type_ == TYPE_PLATFORM_APP ? 2 : 1; | 237 int manifest_version = type_ == TYPE_PLATFORM_APP ? 2 : 1; |
| 238 value_->GetInteger(keys::kManifestVersion, &manifest_version); | 238 value_->GetInteger(keys::kManifestVersion, &manifest_version); |
| 239 return manifest_version; | 239 return manifest_version; |
| 240 } | 240 } |
| 241 | 241 |
| 242 bool Manifest::CanAccessPath(const std::string& path) const { | 242 bool Manifest::CanAccessPath(const std::string& path) const { |
| 243 std::vector<std::string> components; |
| 244 base::SplitString(path, '.', &components); |
| 243 std::string key; | 245 std::string key; |
| 244 for (const base::StringPiece& component : base::SplitStringPiece( | 246 for (size_t i = 0; i < components.size(); ++i) { |
| 245 path, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { | 247 key += components[i]; |
| 246 component.AppendToString(&key); | |
| 247 if (!CanAccessKey(key)) | 248 if (!CanAccessKey(key)) |
| 248 return false; | 249 return false; |
| 249 key += '.'; | 250 key += '.'; |
| 250 } | 251 } |
| 251 return true; | 252 return true; |
| 252 } | 253 } |
| 253 | 254 |
| 254 bool Manifest::CanAccessKey(const std::string& key) const { | 255 bool Manifest::CanAccessKey(const std::string& key) const { |
| 255 Feature* feature = FeatureProvider::GetManifestFeatures()->GetFeature(key); | 256 Feature* feature = FeatureProvider::GetManifestFeatures()->GetFeature(key); |
| 256 if (!feature) | 257 if (!feature) |
| 257 return true; | 258 return true; |
| 258 | 259 |
| 259 return feature->IsAvailableToManifest( | 260 return feature->IsAvailableToManifest( |
| 260 extension_id_, type_, location_, GetManifestVersion()) | 261 extension_id_, type_, location_, GetManifestVersion()) |
| 261 .is_available(); | 262 .is_available(); |
| 262 } | 263 } |
| 263 | 264 |
| 264 } // namespace extensions | 265 } // namespace extensions |
| OLD | NEW |