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

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: Addressed review comments and refactoring Created 6 years, 4 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 f8de09a38b3acc67ed5c6a734383b2263a327ad1..0b530e8a8a709f7241d2531451cab65702528c4e 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -163,6 +163,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,
@@ -845,9 +853,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);
return;
+ }
const Extension* extension = GetInstalledExtension(extension_id);
// |extension| can be NULL if sync disables an extension that is not
@@ -1658,6 +1668,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);
+ }
}
const Extension::State initial_state =
@@ -1837,13 +1853,6 @@ void ExtensionService::PromoteEphemeralApp(
extension->id(), syncer::StringOrdinal());
}
- if (!is_from_sync) {
- // 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.
extension_prefs_->OnEphemeralAppPromoted(extension->id());
@@ -1866,12 +1875,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(
extensions::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, true);
« 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