| 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 <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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 int loc2_rank = GetLocationRank(loc2); | 102 int loc2_rank = GetLocationRank(loc2); |
| 103 | 103 |
| 104 // If two different locations have the same rank, then we can not | 104 // If two different locations have the same rank, then we can not |
| 105 // deterministicly choose a location. | 105 // deterministicly choose a location. |
| 106 CHECK(loc1_rank != loc2_rank); | 106 CHECK(loc1_rank != loc2_rank); |
| 107 | 107 |
| 108 // Highest rank has highest priority. | 108 // Highest rank has highest priority. |
| 109 return (loc1_rank > loc2_rank ? loc1 : loc2 ); | 109 return (loc1_rank > loc2_rank ? loc1 : loc2 ); |
| 110 } | 110 } |
| 111 | 111 |
| 112 Manifest::Manifest(Location location, scoped_ptr<base::DictionaryValue> value) | 112 Manifest::Manifest(Location location, |
| 113 std::unique_ptr<base::DictionaryValue> value) |
| 113 : location_(location), value_(std::move(value)), type_(TYPE_UNKNOWN) { | 114 : location_(location), value_(std::move(value)), type_(TYPE_UNKNOWN) { |
| 114 if (value_->HasKey(keys::kTheme)) { | 115 if (value_->HasKey(keys::kTheme)) { |
| 115 type_ = TYPE_THEME; | 116 type_ = TYPE_THEME; |
| 116 } else if (value_->HasKey(keys::kExport)) { | 117 } else if (value_->HasKey(keys::kExport)) { |
| 117 type_ = TYPE_SHARED_MODULE; | 118 type_ = TYPE_SHARED_MODULE; |
| 118 } else if (value_->HasKey(keys::kApp)) { | 119 } else if (value_->HasKey(keys::kApp)) { |
| 119 if (value_->Get(keys::kWebURLs, NULL) || | 120 if (value_->Get(keys::kWebURLs, NULL) || |
| 120 value_->Get(keys::kLaunchWebURL, NULL)) { | 121 value_->Get(keys::kLaunchWebURL, NULL)) { |
| 121 type_ = TYPE_HOSTED_APP; | 122 type_ = TYPE_HOSTED_APP; |
| 122 } else if (value_->Get(keys::kPlatformAppBackground, NULL)) { | 123 } else if (value_->Get(keys::kPlatformAppBackground, NULL)) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 return CanAccessPath(path) && value_->GetDictionary(path, out_value); | 210 return CanAccessPath(path) && value_->GetDictionary(path, out_value); |
| 210 } | 211 } |
| 211 | 212 |
| 212 bool Manifest::GetList( | 213 bool Manifest::GetList( |
| 213 const std::string& path, const base::ListValue** out_value) const { | 214 const std::string& path, const base::ListValue** out_value) const { |
| 214 return CanAccessPath(path) && value_->GetList(path, out_value); | 215 return CanAccessPath(path) && value_->GetList(path, out_value); |
| 215 } | 216 } |
| 216 | 217 |
| 217 Manifest* Manifest::DeepCopy() const { | 218 Manifest* Manifest::DeepCopy() const { |
| 218 Manifest* manifest = new Manifest( | 219 Manifest* manifest = new Manifest( |
| 219 location_, scoped_ptr<base::DictionaryValue>(value_->DeepCopy())); | 220 location_, std::unique_ptr<base::DictionaryValue>(value_->DeepCopy())); |
| 220 manifest->set_extension_id(extension_id_); | 221 manifest->set_extension_id(extension_id_); |
| 221 return manifest; | 222 return manifest; |
| 222 } | 223 } |
| 223 | 224 |
| 224 bool Manifest::Equals(const Manifest* other) const { | 225 bool Manifest::Equals(const Manifest* other) const { |
| 225 return other && value_->Equals(other->value()); | 226 return other && value_->Equals(other->value()); |
| 226 } | 227 } |
| 227 | 228 |
| 228 int Manifest::GetManifestVersion() const { | 229 int Manifest::GetManifestVersion() const { |
| 229 // Platform apps were launched after manifest version 2 was the preferred | 230 // Platform apps were launched after manifest version 2 was the preferred |
| (...skipping 19 matching lines...) Expand all Loading... |
| 249 Feature* feature = FeatureProvider::GetManifestFeatures()->GetFeature(key); | 250 Feature* feature = FeatureProvider::GetManifestFeatures()->GetFeature(key); |
| 250 if (!feature) | 251 if (!feature) |
| 251 return true; | 252 return true; |
| 252 | 253 |
| 253 return feature->IsAvailableToManifest( | 254 return feature->IsAvailableToManifest( |
| 254 extension_id_, type_, location_, GetManifestVersion()) | 255 extension_id_, type_, location_, GetManifestVersion()) |
| 255 .is_available(); | 256 .is_available(); |
| 256 } | 257 } |
| 257 | 258 |
| 258 } // namespace extensions | 259 } // namespace extensions |
| OLD | NEW |