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

Unified Diff: chrome/browser/extensions/extension_service.cc

Issue 10689097: Enforce the 'requirements' field in manifests. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Conforming to the doc Created 8 years, 5 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/browser/extensions/extension_service.cc
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index ba17841c743a37b9bcc5953b625b3b2402eb2918..487bdd67450b0339897e020d7f019b9426be66c7 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -2092,7 +2092,8 @@ void ExtensionService::UpdateActiveExtensionsInCrashReporter() {
void ExtensionService::OnExtensionInstalled(
const Extension* extension,
bool from_webstore,
- const StringOrdinal& page_ordinal) {
+ const StringOrdinal& page_ordinal,
+ const std::vector<std::string>& requirement_errors) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Ensure extension is deleted unless we transfer ownership.
@@ -2139,6 +2140,15 @@ void ExtensionService::OnExtensionInstalled(
}
}
+ // Unsupported requirements overrides the management policy.
+ if (!requirement_errors.empty()) {
+ initial_enable = false;
+ // If the extension was disabled because of unsupported requirements but
+ // now supports all requirements after an update, enable it.
+ } else if (extension_prefs_->HasUnsupportedRequirements(id)) {
+ initial_enable = true;
+ }
+
// Do not record the install histograms for upgrades.
if (!GetExtensionByIdInternal(extension->id(), true, true, false)) {
UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType",
@@ -2159,6 +2169,12 @@ void ExtensionService::OnExtensionInstalled(
from_webstore,
page_ordinal);
+ if (!requirement_errors.empty()) {
+ extension_prefs_->SetDisableReason(
+ id, Extension::DISABLE_UNSUPPORTED_REQUIREMENT);
+ extension_prefs_->SetUnsupportedRequirements(id, requirement_errors);
+ }
+
// Unpacked extensions default to allowing file access, but if that has been
// overridden, don't reset the value.
if (Extension::ShouldAlwaysAllowFileAccess(extension->location()) &&

Powered by Google App Engine
This is Rietveld 408576698