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); | |
245 std::string key; | 243 std::string key; |
246 for (size_t i = 0; i < components.size(); ++i) { | 244 for (const base::StringPiece& component : base::SplitStringPiece( |
247 key += components[i]; | 245 path, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { |
| 246 component.AppendToString(&key); |
248 if (!CanAccessKey(key)) | 247 if (!CanAccessKey(key)) |
249 return false; | 248 return false; |
250 key += '.'; | 249 key += '.'; |
251 } | 250 } |
252 return true; | 251 return true; |
253 } | 252 } |
254 | 253 |
255 bool Manifest::CanAccessKey(const std::string& key) const { | 254 bool Manifest::CanAccessKey(const std::string& key) const { |
256 Feature* feature = FeatureProvider::GetManifestFeatures()->GetFeature(key); | 255 Feature* feature = FeatureProvider::GetManifestFeatures()->GetFeature(key); |
257 if (!feature) | 256 if (!feature) |
258 return true; | 257 return true; |
259 | 258 |
260 return feature->IsAvailableToManifest( | 259 return feature->IsAvailableToManifest( |
261 extension_id_, type_, location_, GetManifestVersion()) | 260 extension_id_, type_, location_, GetManifestVersion()) |
262 .is_available(); | 261 .is_available(); |
263 } | 262 } |
264 | 263 |
265 } // namespace extensions | 264 } // namespace extensions |
OLD | NEW |