Index: chrome/common/extensions/extension.cc |
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc |
index be1017fe9b1b270f60b974d29dc98951d7747164..56f0733c7c88fd3071d0066145ea2bd2e02f708d 100644 |
--- a/chrome/common/extensions/extension.cc |
+++ b/chrome/common/extensions/extension.cc |
@@ -1433,6 +1433,27 @@ bool Extension::LoadBackgroundPersistent( |
return true; |
} |
+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
|
+ const ExtensionAPIPermissionSet& api_permissions, |
+ string16* error) { |
+ Value* allow_js_access = NULL; |
+ if (!manifest_->Get(keys::kBackgroundAllowJsAccess, &allow_js_access)) |
+ return true; |
+ |
+ if (!allow_js_access->IsType(Value::TYPE_BOOLEAN) || |
+ !allow_js_access->GetAsBoolean(&allow_background_js_access_)) { |
+ *error = ASCIIToUTF16(errors::kInvalidBackgroundAllowJsAccess); |
+ return false; |
+ } |
+ |
+ if (!has_background_page()) { |
+ *error = ASCIIToUTF16(errors::kInvalidBackgroundAllowJsAccessNoPage); |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
// static |
bool Extension::IsTrustedId(const std::string& id) { |
// See http://b/4946060 for more details. |
@@ -1446,6 +1467,7 @@ Extension::Extension(const FilePath& path, |
offline_enabled_(false), |
converted_from_user_script_(false), |
background_page_persists_(true), |
+ allow_background_js_access_(true), |
manifest_(manifest.release()), |
is_storage_isolated_(false), |
launch_container_(extension_misc::LAUNCH_TAB), |
@@ -2239,6 +2261,9 @@ bool Extension::InitFromValue(int flags, string16* error) { |
if (!LoadBackgroundPersistent(api_permissions, error)) |
return false; |
+ if (!LoadBackgroundAllowJsAccess(api_permissions, error)) |
+ return false; |
+ |
if (manifest_->HasKey(keys::kDefaultLocale)) { |
if (!manifest_->GetString(keys::kDefaultLocale, &default_locale_) || |
!l10n_util::IsValidLocaleSyntax(default_locale_)) { |