diff options
author | m.pistrich <m.pistrich@gmail.com> | 2016-02-25 18:17:31 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-26 02:19:45 +0000 |
commit | 1cdbf437f9f45896ccff18c834c7e8b7bc3e8061 (patch) | |
tree | eeaf20c46090fcc1e8c6df63a9814cbea0080f74 /extensions/common | |
parent | 8f0b97ae15609cee6fe67d2b0b958ef37cffb1e0 (diff) | |
download | chromium_src-1cdbf437f9f45896ccff18c834c7e8b7bc3e8061.zip chromium_src-1cdbf437f9f45896ccff18c834c7e8b7bc3e8061.tar.gz chromium_src-1cdbf437f9f45896ccff18c834c7e8b7bc3e8061.tar.bz2 |
Add warning for packaged apps trying to use a persistent background page
Packaged apps do not support a persistent background page, so the
manifest entry is ignored. To make this more obvious, this CL adds a
warning when validating the manifest.
R=rockot@chromium.org,asargent@chromium.org
BUG=586535
Review URL: https://codereview.chromium.org/1701523002
Cr-Commit-Position: refs/heads/master@{#377775}
Diffstat (limited to 'extensions/common')
-rw-r--r-- | extensions/common/manifest_constants.cc | 5 | ||||
-rw-r--r-- | extensions/common/manifest_constants.h | 2 | ||||
-rw-r--r-- | extensions/common/manifest_handlers/background_info.cc | 26 |
3 files changed, 30 insertions, 3 deletions
diff --git a/extensions/common/manifest_constants.cc b/extensions/common/manifest_constants.cc index 85775ef..51b5570 100644 --- a/extensions/common/manifest_constants.cc +++ b/extensions/common/manifest_constants.cc @@ -257,6 +257,8 @@ const char kAppsNotEnabled[] = const char kBackgroundPermissionNeeded[] = "Hosted apps that use 'background_page' must have the 'background' " "permission."; +const char kBackgroundPersistentInvalidForPlatformApps[] = + "The key 'background.persistent' is not supported for packaged apps."; const char kBackgroundRequiredForPlatformApps[] = "Packaged apps must have a background page or background scripts."; const char kCannotAccessAboutUrl[] = @@ -313,6 +315,9 @@ const char kInvalidBackgroundInHostedApp[] = "absolute HTTPS URL for the background page."; const char kInvalidBackgroundPersistent[] = "Invalid value for 'background.persistent'."; +const char kInvalidBackgroundPersistentInPlatformApp[] = + "Invalid value for 'app.background.persistent'. Packaged apps do not " + "support persistent background pages and must use event pages."; const char kInvalidBackgroundPersistentNoPage[] = "Must specify one of background.page or background.scripts to use" " background.persistent."; diff --git a/extensions/common/manifest_constants.h b/extensions/common/manifest_constants.h index 81f8fc5..da756222 100644 --- a/extensions/common/manifest_constants.h +++ b/extensions/common/manifest_constants.h @@ -250,6 +250,7 @@ extern const char kActiveTabPermissionNotGranted[]; extern const char kAllURLOrActiveTabNeeded[]; extern const char kAppsNotEnabled[]; extern const char kBackgroundPermissionNeeded[]; +extern const char kBackgroundPersistentInvalidForPlatformApps[]; extern const char kBackgroundRequiredForPlatformApps[]; extern const char kCannotAccessAboutUrl[]; extern const char kCannotAccessChromeUrl[]; @@ -277,6 +278,7 @@ extern const char kInvalidBackgroundScript[]; extern const char kInvalidBackgroundScripts[]; extern const char kInvalidBackgroundInHostedApp[]; extern const char kInvalidBackgroundPersistent[]; +extern const char kInvalidBackgroundPersistentInPlatformApp[]; extern const char kInvalidBackgroundPersistentNoPage[]; extern const char kInvalidBrowserAction[]; extern const char kInvalidBrowseURL[]; diff --git a/extensions/common/manifest_handlers/background_info.cc b/extensions/common/manifest_handlers/background_info.cc index 7263aae..c33d22c 100644 --- a/extensions/common/manifest_handlers/background_info.cc +++ b/extensions/common/manifest_handlers/background_info.cc @@ -297,12 +297,32 @@ bool BackgroundManifestHandler::Validate( const base::FilePath path = extension->GetResource(page_path).GetFilePath(); if (path.empty() || !base::PathExists(path)) { *error = - l10n_util::GetStringFUTF8( - IDS_EXTENSION_LOAD_BACKGROUND_PAGE_FAILED, - page_path.LossyDisplayName()); + l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_BACKGROUND_PAGE_FAILED, + page_path.LossyDisplayName()); return false; } } + + if (extension->is_platform_app()) { + const std::string manifest_key = + std::string(keys::kPlatformAppBackground) + ".persistent"; + bool is_persistent = false; + // Validate that packaged apps do not use a persistent background page. + if (extension->manifest()->GetBoolean(manifest_key, &is_persistent) && + is_persistent) { + warnings->push_back( + InstallWarning(errors::kInvalidBackgroundPersistentInPlatformApp)); + } + // Validate that packaged apps do not use the key 'background.persistent'. + // Use the dictionary directly to prevent an access check as + // 'background.persistent' is not available for packaged apps. + if (extension->manifest()->value()->Get(keys::kBackgroundPersistent, + NULL)) { + warnings->push_back( + InstallWarning(errors::kBackgroundPersistentInvalidForPlatformApps)); + } + } + return true; } |