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

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

Issue 9508008: Allow apps with background pages to request process-per-app-instance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Prevent script access to background page. Created 8 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
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/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 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 } 1426 }
1427 1427
1428 if (!has_background_page()) { 1428 if (!has_background_page()) {
1429 *error = ASCIIToUTF16(errors::kInvalidBackgroundPersistentNoPage); 1429 *error = ASCIIToUTF16(errors::kInvalidBackgroundPersistentNoPage);
1430 return false; 1430 return false;
1431 } 1431 }
1432 1432
1433 return true; 1433 return true;
1434 } 1434 }
1435 1435
1436 bool Extension::LoadBackgroundAllowJsAccess(
Mihai Parparita -not on Chrome 2012/03/01 02:48:11 I'm assuming you based this on LoadBackgroundPersi
Charlie Reis 2012/03/01 20:12:12 I'm not sure I follow what you want. I can't call
Mihai Parparita -not on Chrome 2012/03/02 01:10:06 Ah, hadn't realized that ManifestFeatureProvider d
1437 const ExtensionAPIPermissionSet& api_permissions,
1438 string16* error) {
1439 Value* allow_js_access = NULL;
1440 if (!manifest_->Get(keys::kBackgroundAllowJsAccess, &allow_js_access))
1441 return true;
1442
1443 if (!allow_js_access->IsType(Value::TYPE_BOOLEAN) ||
1444 !allow_js_access->GetAsBoolean(&allow_background_js_access_)) {
1445 *error = ASCIIToUTF16(errors::kInvalidBackgroundAllowJsAccess);
1446 return false;
1447 }
1448
1449 if (!has_background_page()) {
1450 *error = ASCIIToUTF16(errors::kInvalidBackgroundAllowJsAccessNoPage);
1451 return false;
1452 }
1453
1454 return true;
1455 }
1456
1436 // static 1457 // static
1437 bool Extension::IsTrustedId(const std::string& id) { 1458 bool Extension::IsTrustedId(const std::string& id) {
1438 // See http://b/4946060 for more details. 1459 // See http://b/4946060 for more details.
1439 return id == std::string("nckgahadagoaajjgafhacjanaoiihapd"); 1460 return id == std::string("nckgahadagoaajjgafhacjanaoiihapd");
1440 } 1461 }
1441 1462
1442 Extension::Extension(const FilePath& path, 1463 Extension::Extension(const FilePath& path,
1443 scoped_ptr<extensions::Manifest> manifest) 1464 scoped_ptr<extensions::Manifest> manifest)
1444 : manifest_version_(0), 1465 : manifest_version_(0),
1445 incognito_split_mode_(false), 1466 incognito_split_mode_(false),
1446 offline_enabled_(false), 1467 offline_enabled_(false),
1447 converted_from_user_script_(false), 1468 converted_from_user_script_(false),
1448 background_page_persists_(true), 1469 background_page_persists_(true),
1470 allow_background_js_access_(true),
1449 manifest_(manifest.release()), 1471 manifest_(manifest.release()),
1450 is_storage_isolated_(false), 1472 is_storage_isolated_(false),
1451 launch_container_(extension_misc::LAUNCH_TAB), 1473 launch_container_(extension_misc::LAUNCH_TAB),
1452 launch_width_(0), 1474 launch_width_(0),
1453 launch_height_(0), 1475 launch_height_(0),
1454 wants_file_access_(false), 1476 wants_file_access_(false),
1455 creation_flags_(0) { 1477 creation_flags_(0) {
1456 DCHECK(path.empty() || path.IsAbsolute()); 1478 DCHECK(path.empty() || path.IsAbsolute());
1457 path_ = MaybeNormalizePath(path); 1479 path_ = MaybeNormalizePath(path);
1458 } 1480 }
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 2254
2233 if (!LoadBackgroundScripts(error)) 2255 if (!LoadBackgroundScripts(error))
2234 return false; 2256 return false;
2235 2257
2236 if (!LoadBackgroundPage(api_permissions, error)) 2258 if (!LoadBackgroundPage(api_permissions, error))
2237 return false; 2259 return false;
2238 2260
2239 if (!LoadBackgroundPersistent(api_permissions, error)) 2261 if (!LoadBackgroundPersistent(api_permissions, error))
2240 return false; 2262 return false;
2241 2263
2264 if (!LoadBackgroundAllowJsAccess(api_permissions, error))
2265 return false;
2266
2242 if (manifest_->HasKey(keys::kDefaultLocale)) { 2267 if (manifest_->HasKey(keys::kDefaultLocale)) {
2243 if (!manifest_->GetString(keys::kDefaultLocale, &default_locale_) || 2268 if (!manifest_->GetString(keys::kDefaultLocale, &default_locale_) ||
2244 !l10n_util::IsValidLocaleSyntax(default_locale_)) { 2269 !l10n_util::IsValidLocaleSyntax(default_locale_)) {
2245 *error = ASCIIToUTF16(errors::kInvalidDefaultLocale); 2270 *error = ASCIIToUTF16(errors::kInvalidDefaultLocale);
2246 return false; 2271 return false;
2247 } 2272 }
2248 } 2273 }
2249 2274
2250 // Chrome URL overrides (optional) 2275 // Chrome URL overrides (optional)
2251 if (manifest_->HasKey(keys::kChromeURLOverrides)) { 2276 if (manifest_->HasKey(keys::kChromeURLOverrides)) {
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after
3239 already_disabled(false), 3264 already_disabled(false),
3240 extension(extension) {} 3265 extension(extension) {}
3241 3266
3242 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 3267 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
3243 const Extension* extension, 3268 const Extension* extension,
3244 const ExtensionPermissionSet* permissions, 3269 const ExtensionPermissionSet* permissions,
3245 Reason reason) 3270 Reason reason)
3246 : reason(reason), 3271 : reason(reason),
3247 extension(extension), 3272 extension(extension),
3248 permissions(permissions) {} 3273 permissions(permissions) {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698