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

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

Issue 344543006: Disable ephemeral apps after they stop running (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Prevent demotion of installed app due to race condition Created 6 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/browser/extensions/extension_service.cc
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 869a8dd99b53acad8468184a7f086e9fbae5cf6d..a5c44446221488a227208e5413b3489909891b78 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -195,6 +195,14 @@ void ExtensionService::AddProviderForTesting(
linked_ptr<extensions::ExternalProviderInterface>(test_provider));
}
+void ExtensionService::BlacklistExtensionForTest(
+ const std::string& extension_id) {
+ ExtensionIdSet blocked;
+ ExtensionIdSet unchanged;
+ blocked.insert(extension_id);
+ UpdateBlockedExtensions(blocked, unchanged);
+}
+
bool ExtensionService::OnExternalExtensionUpdateUrlFound(
const std::string& id,
const std::string& install_parameter,
@@ -880,9 +888,11 @@ void ExtensionService::DisableExtension(
Extension::DisableReason disable_reason) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- // The extension may have been disabled already.
- if (!IsExtensionEnabled(extension_id))
+ // The extension may have been disabled already. Just add a disable reason.
+ if (!IsExtensionEnabled(extension_id)) {
+ extension_prefs_->AddDisableReason(extension_id, disable_reason);
tmdiep 2014/07/02 07:13:39 yoz: Are multiple disable reasons meant to be supp
Yoyo Zhou 2014/07/10 23:30:12 Yes, they are meant to be supported. This is most
return;
+ }
const Extension* extension = GetInstalledExtension(extension_id);
// |extension| can be NULL if sync disables an extension that is not
@@ -1746,6 +1756,12 @@ void ExtensionService::OnExtensionInstalled(
extension->GetType(), 100);
UMA_HISTOGRAM_ENUMERATION("Extensions.UpdateSource",
extension->location(), Manifest::NUM_LOCATIONS);
+
+ // A fully installed app cannot be demoted to an ephemeral app.
+ if ((install_flags & extensions::kInstallFlagIsEphemeral) &&
+ !extension_prefs_->IsEphemeralApp(id)) {
+ install_flags &= ~static_cast<int>(extensions::kInstallFlagIsEphemeral);
+ }
}
// Certain extension locations are specific enough that we can
@@ -1946,11 +1962,6 @@ void ExtensionService::PromoteEphemeralApp(
extension_prefs_->app_sorting()->EnsureValidOrdinals(
extension->id(), syncer::StringOrdinal());
}
-
- // Cached ephemeral apps may be updated and disabled due to permissions
- // increase. The app can be enabled as the install was user-acknowledged.
- if (extension_prefs_->DidExtensionEscalatePermissions(extension->id()))
- GrantPermissionsAndEnableExtension(extension);
}
// Remove the ephemeral flags from the preferences.
@@ -1975,12 +1986,30 @@ void ExtensionService::PromoteEphemeralApp(
extension->name() /* old name */);
if (registry_->enabled_extensions().Contains(extension->id())) {
+ // If the app is already enabled and loaded, fire the load events to allow
+ // observers to handle the promotion of the ephemeral app.
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
content::Source<Profile>(profile_),
content::Details<const Extension>(extension));
registry_->TriggerOnLoaded(extension);
+ } else {
+ // Cached ephemeral apps may be updated and disabled due to permissions
+ // increase. The app can be enabled (as long as no other disable reasons
+ // exist) as the install was user-acknowledged.
+ int disable_mask = Extension::DISABLE_NONE;
+ if (!is_from_sync)
+ disable_mask |= Extension::DISABLE_PERMISSIONS_INCREASE;
+
+ int other_disable_reasons =
+ extension_prefs_->GetDisableReasons(extension->id()) & ~disable_mask;
+ if (!other_disable_reasons) {
+ if (extension_prefs_->DidExtensionEscalatePermissions(extension->id()))
+ GrantPermissionsAndEnableExtension(extension);
+ else
+ EnableExtension(extension->id());
+ }
}
registry_->TriggerOnInstalled(extension);
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/notifications/message_center_settings_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698