Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: chrome/common/extensions/manifest.cc

Issue 12253022: Manifest handler for all keys background-related. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/extensions/manifest.h ('k') | chrome/common/extensions/manifest_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/string_split.h" 10 #include "base/string_split.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 int loc2_rank = GetLocationRank(loc2); 93 int loc2_rank = GetLocationRank(loc2);
94 94
95 // If two different locations have the same rank, then we can not 95 // If two different locations have the same rank, then we can not
96 // deterministicly choose a location. 96 // deterministicly choose a location.
97 CHECK(loc1_rank != loc2_rank); 97 CHECK(loc1_rank != loc2_rank);
98 98
99 // Highest rank has highest priority. 99 // Highest rank has highest priority.
100 return (loc1_rank > loc2_rank ? loc1 : loc2 ); 100 return (loc1_rank > loc2_rank ? loc1 : loc2 );
101 } 101 }
102 102
103 Manifest::Manifest(Location location, scoped_ptr<DictionaryValue> value) 103 Manifest::Manifest(Location location, scoped_ptr<base::DictionaryValue> value)
104 : location_(location), 104 : location_(location),
105 value_(value.Pass()), 105 value_(value.Pass()),
106 type_(TYPE_UNKNOWN) { 106 type_(TYPE_UNKNOWN) {
107 if (value_->HasKey(keys::kTheme)) { 107 if (value_->HasKey(keys::kTheme)) {
108 type_ = TYPE_THEME; 108 type_ = TYPE_THEME;
109 } else if (value_->HasKey(keys::kApp)) { 109 } else if (value_->HasKey(keys::kApp)) {
110 if (value_->Get(keys::kWebURLs, NULL) || 110 if (value_->Get(keys::kWebURLs, NULL) ||
111 value_->Get(keys::kLaunchWebURL, NULL)) { 111 value_->Get(keys::kLaunchWebURL, NULL)) {
112 type_ = TYPE_HOSTED_APP; 112 type_ = TYPE_HOSTED_APP;
113 } else if (value_->Get(keys::kPlatformAppBackground, NULL)) { 113 } else if (value_->Get(keys::kPlatformAppBackground, NULL)) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 BaseFeatureProvider::GetManifestFeatures()->GetFeature(*feature_name); 151 BaseFeatureProvider::GetManifestFeatures()->GetFeature(*feature_name);
152 Feature::Availability result = feature->IsAvailableToManifest( 152 Feature::Availability result = feature->IsAvailableToManifest(
153 extension_id_, type_, Feature::ConvertLocation(location_), 153 extension_id_, type_, Feature::ConvertLocation(location_),
154 GetManifestVersion()); 154 GetManifestVersion());
155 if (!result.is_available()) 155 if (!result.is_available())
156 warnings->push_back(InstallWarning( 156 warnings->push_back(InstallWarning(
157 InstallWarning::FORMAT_TEXT, result.message())); 157 InstallWarning::FORMAT_TEXT, result.message()));
158 } 158 }
159 159
160 // Also generate warnings for keys that are not features. 160 // Also generate warnings for keys that are not features.
161 for (DictionaryValue::key_iterator key = value_->begin_keys(); 161 for (base::DictionaryValue::key_iterator key = value_->begin_keys();
162 key != value_->end_keys(); ++key) { 162 key != value_->end_keys(); ++key) {
163 if (!BaseFeatureProvider::GetManifestFeatures()->GetFeature(*key)) { 163 if (!BaseFeatureProvider::GetManifestFeatures()->GetFeature(*key)) {
164 warnings->push_back(InstallWarning( 164 warnings->push_back(InstallWarning(
165 InstallWarning::FORMAT_TEXT, 165 InstallWarning::FORMAT_TEXT,
166 base::StringPrintf("Unrecognized manifest key '%s'.", 166 base::StringPrintf("Unrecognized manifest key '%s'.",
167 (*key).c_str()))); 167 (*key).c_str())));
168 } 168 }
169 } 169 }
170 } 170 }
171 171
172 bool Manifest::HasKey(const std::string& key) const { 172 bool Manifest::HasKey(const std::string& key) const {
173 return CanAccessKey(key) && value_->HasKey(key); 173 return CanAccessKey(key) && value_->HasKey(key);
174 } 174 }
175 175
176 bool Manifest::HasPath(const std::string& path) const { 176 bool Manifest::HasPath(const std::string& path) const {
177 Value* ignored = NULL; 177 base::Value* ignored = NULL;
178 return CanAccessPath(path) && value_->Get(path, &ignored); 178 return CanAccessPath(path) && value_->Get(path, &ignored);
179 } 179 }
180 180
181 bool Manifest::Get( 181 bool Manifest::Get(
182 const std::string& path, Value** out_value) const { 182 const std::string& path, const base::Value** out_value) const {
183 return CanAccessPath(path) && value_->Get(path, out_value); 183 return CanAccessPath(path) && value_->Get(path, out_value);
184 } 184 }
185 185
186 bool Manifest::GetBoolean( 186 bool Manifest::GetBoolean(
187 const std::string& path, bool* out_value) const { 187 const std::string& path, bool* out_value) const {
188 return CanAccessPath(path) && value_->GetBoolean(path, out_value); 188 return CanAccessPath(path) && value_->GetBoolean(path, out_value);
189 } 189 }
190 190
191 bool Manifest::GetInteger( 191 bool Manifest::GetInteger(
192 const std::string& path, int* out_value) const { 192 const std::string& path, int* out_value) const {
193 return CanAccessPath(path) && value_->GetInteger(path, out_value); 193 return CanAccessPath(path) && value_->GetInteger(path, out_value);
194 } 194 }
195 195
196 bool Manifest::GetString( 196 bool Manifest::GetString(
197 const std::string& path, std::string* out_value) const { 197 const std::string& path, std::string* out_value) const {
198 return CanAccessPath(path) && value_->GetString(path, out_value); 198 return CanAccessPath(path) && value_->GetString(path, out_value);
199 } 199 }
200 200
201 bool Manifest::GetString( 201 bool Manifest::GetString(
202 const std::string& path, string16* out_value) const { 202 const std::string& path, string16* out_value) const {
203 return CanAccessPath(path) && value_->GetString(path, out_value); 203 return CanAccessPath(path) && value_->GetString(path, out_value);
204 } 204 }
205 205
206 bool Manifest::GetDictionary( 206 bool Manifest::GetDictionary(
207 const std::string& path, const DictionaryValue** out_value) const { 207 const std::string& path, const base::DictionaryValue** out_value) const {
208 return GetDictionary(path, const_cast<DictionaryValue**>(out_value));
209 }
210
211 bool Manifest::GetDictionary(
212 const std::string& path, DictionaryValue** out_value) const {
213 return CanAccessPath(path) && value_->GetDictionary(path, out_value); 208 return CanAccessPath(path) && value_->GetDictionary(path, out_value);
214 } 209 }
215 210
216 bool Manifest::GetList( 211 bool Manifest::GetList(
217 const std::string& path, const ListValue** out_value) const { 212 const std::string& path, const base::ListValue** out_value) const {
218 return GetList(path, const_cast<ListValue**>(out_value));
219 }
220
221 bool Manifest::GetList(
222 const std::string& path, ListValue** out_value) const {
223 return CanAccessPath(path) && value_->GetList(path, out_value); 213 return CanAccessPath(path) && value_->GetList(path, out_value);
224 } 214 }
225 215
226 Manifest* Manifest::DeepCopy() const { 216 Manifest* Manifest::DeepCopy() const {
227 Manifest* manifest = new Manifest( 217 Manifest* manifest = new Manifest(
228 location_, scoped_ptr<DictionaryValue>(value_->DeepCopy())); 218 location_, scoped_ptr<base::DictionaryValue>(value_->DeepCopy()));
229 manifest->set_extension_id(extension_id_); 219 manifest->set_extension_id(extension_id_);
230 return manifest; 220 return manifest;
231 } 221 }
232 222
233 bool Manifest::Equals(const Manifest* other) const { 223 bool Manifest::Equals(const Manifest* other) const {
234 return other && value_->Equals(other->value()); 224 return other && value_->Equals(other->value());
235 } 225 }
236 226
237 int Manifest::GetManifestVersion() const { 227 int Manifest::GetManifestVersion() const {
238 // Platform apps were launched after manifest version 2 was the preferred 228 // Platform apps were launched after manifest version 2 was the preferred
(...skipping 21 matching lines...) Expand all
260 BaseFeatureProvider::GetManifestFeatures()->GetFeature(key); 250 BaseFeatureProvider::GetManifestFeatures()->GetFeature(key);
261 if (!feature) 251 if (!feature)
262 return true; 252 return true;
263 253
264 return feature->IsAvailableToManifest( 254 return feature->IsAvailableToManifest(
265 extension_id_, type_, Feature::ConvertLocation(location_), 255 extension_id_, type_, Feature::ConvertLocation(location_),
266 GetManifestVersion()).is_available(); 256 GetManifestVersion()).is_available();
267 } 257 }
268 258
269 } // namespace extensions 259 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/manifest.h ('k') | chrome/common/extensions/manifest_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698