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

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

Issue 8200015: Add support for an optional "requirements" section in extension/app manifests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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 | « no previous file | chrome/common/extensions/extension_constants.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extension.h" 5 #include "chrome/common/extensions/extension.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 1239
1240 for (DictionaryValue::key_iterator key = manifest->begin_keys(); 1240 for (DictionaryValue::key_iterator key = manifest->begin_keys();
1241 key != manifest->end_keys(); ++key) { 1241 key != manifest->end_keys(); ++key) {
1242 if (!IsBaseCrxKey(*key) && 1242 if (!IsBaseCrxKey(*key) &&
1243 *key != keys::kApp && 1243 *key != keys::kApp &&
1244 *key != keys::kPermissions && 1244 *key != keys::kPermissions &&
1245 *key != keys::kOptionalPermissions && 1245 *key != keys::kOptionalPermissions &&
1246 *key != keys::kOptionsPage && 1246 *key != keys::kOptionsPage &&
1247 *key != keys::kBackground && 1247 *key != keys::kBackground &&
1248 *key != keys::kOfflineEnabled && 1248 *key != keys::kOfflineEnabled &&
1249 *key != keys::kMinimumChromeVersion) { 1249 *key != keys::kMinimumChromeVersion &&
1250 *key != keys::kRequirements) {
1250 *error = ExtensionErrorUtils::FormatErrorMessage( 1251 *error = ExtensionErrorUtils::FormatErrorMessage(
1251 errors::kHostedAppsCannotIncludeExtensionFeatures, *key); 1252 errors::kHostedAppsCannotIncludeExtensionFeatures, *key);
1252 return false; 1253 return false;
1253 } 1254 }
1254 } 1255 }
1255 1256
1256 return true; 1257 return true;
1257 } 1258 }
1258 1259
1259 // static 1260 // static
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
2368 } 2369 }
2369 2370
2370 // Initialize offline-enabled status. Defaults to false. 2371 // Initialize offline-enabled status. Defaults to false.
2371 if (source.HasKey(keys::kOfflineEnabled)) { 2372 if (source.HasKey(keys::kOfflineEnabled)) {
2372 if (!source.GetBoolean(keys::kOfflineEnabled, &offline_enabled_)) { 2373 if (!source.GetBoolean(keys::kOfflineEnabled, &offline_enabled_)) {
2373 *error = errors::kInvalidOfflineEnabled; 2374 *error = errors::kInvalidOfflineEnabled;
2374 return false; 2375 return false;
2375 } 2376 }
2376 } 2377 }
2377 2378
2379 // Initialize requirements (optional). Not actually persisted (they're only
2380 // used by the store), but still validated.
2381 if (source.HasKey(keys::kRequirements)) {
2382 DictionaryValue* requirements_value = NULL;
2383 if (!source.GetDictionary(keys::kRequirements, &requirements_value)) {
2384 *error = errors::kInvalidRequirements;
2385 return false;
2386 }
2387
2388 for (DictionaryValue::key_iterator it = requirements_value->begin_keys();
2389 it != requirements_value->end_keys(); ++it) {
2390 DictionaryValue* requirement_value;
2391 if (!requirements_value->GetDictionaryWithoutPathExpansion(
Yoyo Zhou 2011/10/07 21:05:33 Any particular reason to use the WithoutPathExpans
Mihai Parparita -not on Chrome 2011/10/07 21:15:32 The iterator docs say that should be used (http://
Yoyo Zhou 2011/10/07 21:19:11 Ok, I didn't realize we would have such keys (from
2392 *it, &requirement_value)) {
2393 *error = ExtensionErrorUtils::FormatErrorMessage(
2394 errors::kInvalidRequirement, *it);
2395 return false;
2396 }
2397 }
2398 }
2399
2378 if (HasMultipleUISurfaces()) { 2400 if (HasMultipleUISurfaces()) {
2379 *error = errors::kOneUISurfaceOnly; 2401 *error = errors::kOneUISurfaceOnly;
2380 return false; 2402 return false;
2381 } 2403 }
2382 2404
2383 runtime_data_.SetActivePermissions(new ExtensionPermissionSet( 2405 runtime_data_.SetActivePermissions(new ExtensionPermissionSet(
2384 this, api_permissions, host_permissions)); 2406 this, api_permissions, host_permissions));
2385 required_permission_set_ = new ExtensionPermissionSet( 2407 required_permission_set_ = new ExtensionPermissionSet(
2386 this, api_permissions, host_permissions); 2408 this, api_permissions, host_permissions);
2387 optional_permission_set_ = new ExtensionPermissionSet( 2409 optional_permission_set_ = new ExtensionPermissionSet(
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
2973 already_disabled(false), 2995 already_disabled(false),
2974 extension(extension) {} 2996 extension(extension) {}
2975 2997
2976 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 2998 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
2977 const Extension* extension, 2999 const Extension* extension,
2978 const ExtensionPermissionSet* permissions, 3000 const ExtensionPermissionSet* permissions,
2979 Reason reason) 3001 Reason reason)
2980 : reason(reason), 3002 : reason(reason),
2981 extension(extension), 3003 extension(extension),
2982 permissions(permissions) {} 3004 permissions(permissions) {}
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/extension_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698