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

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

Issue 8227021: Merge 104582 - Add support for an optional "requirements" section in extension/app manifests. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/874/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 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 return true; 1168 return true;
1169 1169
1170 for (DictionaryValue::key_iterator key = manifest->begin_keys(); 1170 for (DictionaryValue::key_iterator key = manifest->begin_keys();
1171 key != manifest->end_keys(); ++key) { 1171 key != manifest->end_keys(); ++key) {
1172 if (!IsBaseCrxKey(*key) && 1172 if (!IsBaseCrxKey(*key) &&
1173 *key != keys::kApp && 1173 *key != keys::kApp &&
1174 *key != keys::kPermissions && 1174 *key != keys::kPermissions &&
1175 *key != keys::kOptionalPermissions && 1175 *key != keys::kOptionalPermissions &&
1176 *key != keys::kOptionsPage && 1176 *key != keys::kOptionsPage &&
1177 *key != keys::kBackground && 1177 *key != keys::kBackground &&
1178 *key != keys::kOfflineEnabled) { 1178 *key != keys::kOfflineEnabled &&
1179 *key != keys::kMinimumChromeVersion &&
1180 *key != keys::kRequirements) {
1179 *error = ExtensionErrorUtils::FormatErrorMessage( 1181 *error = ExtensionErrorUtils::FormatErrorMessage(
1180 errors::kHostedAppsCannotIncludeExtensionFeatures, *key); 1182 errors::kHostedAppsCannotIncludeExtensionFeatures, *key);
1181 return false; 1183 return false;
1182 } 1184 }
1183 } 1185 }
1184 1186
1185 return true; 1187 return true;
1186 } 1188 }
1187 1189
1188 // static 1190 // static
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2292 } 2294 }
2293 2295
2294 // Initialize offline-enabled status. Defaults to false. 2296 // Initialize offline-enabled status. Defaults to false.
2295 if (source.HasKey(keys::kOfflineEnabled)) { 2297 if (source.HasKey(keys::kOfflineEnabled)) {
2296 if (!source.GetBoolean(keys::kOfflineEnabled, &offline_enabled_)) { 2298 if (!source.GetBoolean(keys::kOfflineEnabled, &offline_enabled_)) {
2297 *error = errors::kInvalidOfflineEnabled; 2299 *error = errors::kInvalidOfflineEnabled;
2298 return false; 2300 return false;
2299 } 2301 }
2300 } 2302 }
2301 2303
2304 // Initialize requirements (optional). Not actually persisted (they're only
2305 // used by the store), but still validated.
2306 if (source.HasKey(keys::kRequirements)) {
2307 DictionaryValue* requirements_value = NULL;
2308 if (!source.GetDictionary(keys::kRequirements, &requirements_value)) {
2309 *error = errors::kInvalidRequirements;
2310 return false;
2311 }
2312
2313 for (DictionaryValue::key_iterator it = requirements_value->begin_keys();
2314 it != requirements_value->end_keys(); ++it) {
2315 DictionaryValue* requirement_value;
2316 if (!requirements_value->GetDictionaryWithoutPathExpansion(
2317 *it, &requirement_value)) {
2318 *error = ExtensionErrorUtils::FormatErrorMessage(
2319 errors::kInvalidRequirement, *it);
2320 return false;
2321 }
2322 }
2323 }
2324
2302 if (HasMultipleUISurfaces()) { 2325 if (HasMultipleUISurfaces()) {
2303 *error = errors::kOneUISurfaceOnly; 2326 *error = errors::kOneUISurfaceOnly;
2304 return false; 2327 return false;
2305 } 2328 }
2306 2329
2307 runtime_data_.SetActivePermissions(new ExtensionPermissionSet( 2330 runtime_data_.SetActivePermissions(new ExtensionPermissionSet(
2308 this, api_permissions, host_permissions)); 2331 this, api_permissions, host_permissions));
2309 required_permission_set_ = new ExtensionPermissionSet( 2332 required_permission_set_ = new ExtensionPermissionSet(
2310 this, api_permissions, host_permissions); 2333 this, api_permissions, host_permissions);
2311 optional_permission_set_ = new ExtensionPermissionSet( 2334 optional_permission_set_ = new ExtensionPermissionSet(
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
2897 already_disabled(false), 2920 already_disabled(false),
2898 extension(extension) {} 2921 extension(extension) {}
2899 2922
2900 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 2923 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
2901 const Extension* extension, 2924 const Extension* extension,
2902 const ExtensionPermissionSet* permissions, 2925 const ExtensionPermissionSet* permissions,
2903 Reason reason) 2926 Reason reason)
2904 : reason(reason), 2927 : reason(reason),
2905 extension(extension), 2928 extension(extension),
2906 permissions(permissions) {} 2929 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