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

Side by Side Diff: chrome/browser/apps/ephemeral_app_service.cc

Issue 398083002: Add "UninstallReason" parameter to ExtensionRegistryObserver::OnExtensionUninstalled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/apps/ephemeral_app_service.h" 5 #include "chrome/browser/apps/ephemeral_app_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/apps/ephemeral_app_service_factory.h" 8 #include "chrome/browser/apps/ephemeral_app_service_factory.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_util.h" 11 #include "chrome/browser/extensions/extension_util.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
14 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/notification_source.h" 15 #include "content/public/browser/notification_source.h"
16 #include "content/public/browser/notification_types.h" 16 #include "content/public/browser/notification_types.h"
17 #include "extensions/browser/extension_prefs.h" 17 #include "extensions/browser/extension_prefs.h"
18 #include "extensions/browser/extension_registry.h" 18 #include "extensions/browser/extension_registry.h"
19 #include "extensions/browser/extension_system.h" 19 #include "extensions/browser/extension_system.h"
20 #include "extensions/browser/extension_util.h" 20 #include "extensions/browser/extension_util.h"
21 #include "extensions/common/extension.h" 21 #include "extensions/common/extension.h"
22 #include "extensions/common/extension_set.h" 22 #include "extensions/common/extension_set.h"
23 23
24 using extensions::Extension; 24 using extensions::Extension;
25 using extensions::ExtensionPrefs; 25 using extensions::ExtensionPrefs;
26 using extensions::ExtensionSet; 26 using extensions::ExtensionSet;
27 using extensions::ExtensionSystem; 27 using extensions::ExtensionSystem;
28 using extensions::UninstalledExtensionInfo;
28 29
29 namespace { 30 namespace {
30 31
31 // The number of seconds after startup before performing garbage collection 32 // The number of seconds after startup before performing garbage collection
32 // of ephemeral apps. 33 // of ephemeral apps.
33 const int kGarbageCollectAppsStartupDelay = 60; 34 const int kGarbageCollectAppsStartupDelay = 60;
34 35
35 // The number of seconds after an ephemeral app has been installed before 36 // The number of seconds after an ephemeral app has been installed before
36 // performing garbage collection. 37 // performing garbage collection.
37 const int kGarbageCollectAppsInstallDelay = 15; 38 const int kGarbageCollectAppsInstallDelay = 15;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 ExtensionService* service = 190 ExtensionService* service =
190 ExtensionSystem::Get(profile_)->extension_service(); 191 ExtensionSystem::Get(profile_)->extension_service();
191 DCHECK(service); 192 DCHECK(service);
192 // Execute the replacement policies and remove apps marked for deletion. 193 // Execute the replacement policies and remove apps marked for deletion.
193 if (!app_launch_times.empty()) { 194 if (!app_launch_times.empty()) {
194 GetAppsToRemove(app_count, app_launch_times, &remove_app_ids); 195 GetAppsToRemove(app_count, app_launch_times, &remove_app_ids);
195 for (std::set<std::string>::const_iterator id = remove_app_ids.begin(); 196 for (std::set<std::string>::const_iterator id = remove_app_ids.begin();
196 id != remove_app_ids.end(); ++id) { 197 id != remove_app_ids.end(); ++id) {
197 if (service->UninstallExtension( 198 if (service->UninstallExtension(
198 *id, 199 *id,
199 ExtensionService::UNINSTALL_REASON_ORPHANED_EPHEMERAL_EXTENSION, 200 UninstalledExtensionInfo::REASON_ORPHANED_EPHEMERAL_EXTENSION,
200 NULL)) { 201 NULL)) {
201 --app_count; 202 --app_count;
202 } 203 }
203 } 204 }
204 } 205 }
205 206
206 ephemeral_app_count_ = app_count; 207 ephemeral_app_count_ = app_count;
207 } 208 }
208 209
209 // static 210 // static
(...skipping 18 matching lines...) Expand all
228 // Remove ephemeral apps that have been inactive for a while or if the cache 229 // Remove ephemeral apps that have been inactive for a while or if the cache
229 // is larger than the desired size. 230 // is larger than the desired size.
230 if (it->first < inactive_threshold || app_count > kMaxEphemeralAppsCount) { 231 if (it->first < inactive_threshold || app_count > kMaxEphemeralAppsCount) {
231 remove_app_ids->insert(it->second); 232 remove_app_ids->insert(it->second);
232 --app_count; 233 --app_count;
233 } else { 234 } else {
234 break; 235 break;
235 } 236 }
236 } 237 }
237 } 238 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698