Index: chrome/browser/apps/ephemeral_app_service.cc |
diff --git a/chrome/browser/apps/ephemeral_app_service.cc b/chrome/browser/apps/ephemeral_app_service.cc |
index da4a5d19ab9b5b79956e6ffd82be4a38ea52e4de..da8d4a592200c5e8b9ba2d3fed745f5ed1490c41 100644 |
--- a/chrome/browser/apps/ephemeral_app_service.cc |
+++ b/chrome/browser/apps/ephemeral_app_service.cc |
@@ -71,6 +71,40 @@ EphemeralAppService::EphemeralAppService(Profile* profile) |
EphemeralAppService::~EphemeralAppService() { |
} |
+void EphemeralAppService::ClearCachedApps() { |
+ // Cancel any pending garbage collects. |
+ garbage_collect_apps_timer_.Stop(); |
+ |
+ scoped_ptr<ExtensionSet> extensions = |
+ extensions::ExtensionRegistry::Get(profile_) |
+ ->GenerateInstalledExtensionsSet(); |
+ ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_); |
+ DCHECK(prefs); |
+ |
+ ExtensionService* service = |
+ ExtensionSystem::Get(profile_)->extension_service(); |
+ DCHECK(service); |
+ |
+ for (ExtensionSet::const_iterator it = extensions->begin(); |
+ it != extensions->end(); |
+ ++it) { |
+ std::string extension_id = (*it)->id(); |
+ if (!prefs->IsEphemeralApp(extension_id) || |
+ !service->GetInstalledExtension(extension_id)) { |
tapted
2014/07/11 01:16:36
I think GetInstalledExtension(..) should return tr
tmdiep
2014/07/11 02:28:31
There is a CHECK in ExtensionService::UninstallExt
|
+ continue; |
+ } |
+ |
+ // Do not remove apps that are running. |
+ if (!extensions::util::IsExtensionIdle(extension_id, profile_)) |
+ continue; |
+ |
+ service->UninstallExtension( |
+ extension_id, |
+ ExtensionService::UNINSTALL_REASON_ORPHANED_EPHEMERAL_EXTENSION, |
+ NULL); |
+ } |
+} |
+ |
void EphemeralAppService::Observe( |
int type, |
const content::NotificationSource& source, |
@@ -189,11 +223,14 @@ void EphemeralAppService::GarbageCollectApps() { |
ExtensionService* service = |
ExtensionSystem::Get(profile_)->extension_service(); |
DCHECK(service); |
- // Execute the replacement policies and remove apps marked for deletion. |
+ // Execute the eviction policies and remove apps marked for deletion. |
if (!app_launch_times.empty()) { |
GetAppsToRemove(app_count, app_launch_times, &remove_app_ids); |
for (std::set<std::string>::const_iterator id = remove_app_ids.begin(); |
id != remove_app_ids.end(); ++id) { |
+ if (!service->GetInstalledExtension(*id)) |
tapted
2014/07/11 01:16:36
I don't think I've wrapped my head around this bit
tmdiep
2014/07/11 02:28:31
Same reason as above - in case of cascading uninst
|
+ continue; |
+ |
if (service->UninstallExtension( |
*id, |
ExtensionService::UNINSTALL_REASON_ORPHANED_EPHEMERAL_EXTENSION, |