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

Unified Diff: chrome/common/extensions/background_info.cc

Issue 16398010: Move some extension manifest consistency checks to BackgroundManifestHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/background_info.cc
diff --git a/chrome/common/extensions/background_info.cc b/chrome/common/extensions/background_info.cc
index 77dd5af0f73a68f29a59828e803771828c0d4e71..7a52537a573b65cde09a879d68721abddf221305 100644
--- a/chrome/common/extensions/background_info.cc
+++ b/chrome/common/extensions/background_info.cc
@@ -79,14 +79,12 @@ bool BackgroundInfo::AllowJSAccess(const Extension* extension) {
// static
bool BackgroundInfo::HasPersistentBackgroundPage(const Extension* extension) {
- const BackgroundInfo& info = GetBackgroundInfo(extension);
- return info.has_background_page() && info.is_persistent_;
+ return GetBackgroundInfo(extension).has_persistent_background_page();
}
// static
bool BackgroundInfo::HasLazyBackgroundPage(const Extension* extension) {
- const BackgroundInfo& info = GetBackgroundInfo(extension);
- return info.has_background_page() && !info.is_persistent_;
+ return GetBackgroundInfo(extension).has_lazy_background_page();
}
bool BackgroundInfo::Parse(const Extension* extension, string16* error) {
@@ -240,6 +238,20 @@ bool BackgroundManifestHandler::Parse(Extension* extension, string16* error) {
scoped_ptr<BackgroundInfo> info(new BackgroundInfo);
if (!info->Parse(extension, error))
return false;
+
+ // Platform apps must have background pages.
+ if (extension->is_platform_app() && !info->has_background_page()) {
+ *error = ASCIIToUTF16(errors::kBackgroundRequiredForPlatformApps);
+ return false;
+ }
+ // Lazy background pages are incompatible with the webRequest API.
+ if (info->has_lazy_background_page() &&
+ PermissionsData::GetInitialAPIPermissions(extension)->count(
+ APIPermission::kWebRequest)) {
+ *error = ASCIIToUTF16(errors::kWebRequestConflictsWithLazyBackground);
+ return false;
+ }
+
extension->SetManifestData(kBackground, info.release());
return true;
}
@@ -281,6 +293,10 @@ bool BackgroundManifestHandler::Validate(
return true;
}
+bool BackgroundManifestHandler::AlwaysParseForType(Manifest::Type type) const {
+ return type == Manifest::TYPE_PLATFORM_APP;
+}
+
const std::vector<std::string> BackgroundManifestHandler::Keys() const {
static const char* keys[] = {
keys::kBackgroundAllowJsAccess,

Powered by Google App Engine
This is Rietveld 408576698