| OLD | NEW |
| 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" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 } | 187 } |
| 188 | 188 |
| 189 ExtensionService* service = | 189 ExtensionService* service = |
| 190 ExtensionSystem::Get(profile_)->extension_service(); | 190 ExtensionSystem::Get(profile_)->extension_service(); |
| 191 DCHECK(service); | 191 DCHECK(service); |
| 192 // Execute the replacement policies and remove apps marked for deletion. | 192 // Execute the replacement policies and remove apps marked for deletion. |
| 193 if (!app_launch_times.empty()) { | 193 if (!app_launch_times.empty()) { |
| 194 GetAppsToRemove(app_count, app_launch_times, &remove_app_ids); | 194 GetAppsToRemove(app_count, app_launch_times, &remove_app_ids); |
| 195 for (std::set<std::string>::const_iterator id = remove_app_ids.begin(); | 195 for (std::set<std::string>::const_iterator id = remove_app_ids.begin(); |
| 196 id != remove_app_ids.end(); ++id) { | 196 id != remove_app_ids.end(); ++id) { |
| 197 if (service->UninstallExtension( | 197 if (service->UninstallExtension(*id, false, NULL)) |
| 198 *id, | |
| 199 ExtensionService::UNINSTALL_REASON_ORPHANED_EPHEMERAL_EXTENSION, | |
| 200 NULL)) { | |
| 201 --app_count; | 198 --app_count; |
| 202 } | |
| 203 } | 199 } |
| 204 } | 200 } |
| 205 | 201 |
| 206 ephemeral_app_count_ = app_count; | 202 ephemeral_app_count_ = app_count; |
| 207 } | 203 } |
| 208 | 204 |
| 209 // static | 205 // static |
| 210 void EphemeralAppService::GetAppsToRemove( | 206 void EphemeralAppService::GetAppsToRemove( |
| 211 int app_count, | 207 int app_count, |
| 212 const LaunchTimeAppMap& app_launch_times, | 208 const LaunchTimeAppMap& app_launch_times, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 228 // Remove ephemeral apps that have been inactive for a while or if the cache | 224 // Remove ephemeral apps that have been inactive for a while or if the cache |
| 229 // is larger than the desired size. | 225 // is larger than the desired size. |
| 230 if (it->first < inactive_threshold || app_count > kMaxEphemeralAppsCount) { | 226 if (it->first < inactive_threshold || app_count > kMaxEphemeralAppsCount) { |
| 231 remove_app_ids->insert(it->second); | 227 remove_app_ids->insert(it->second); |
| 232 --app_count; | 228 --app_count; |
| 233 } else { | 229 } else { |
| 234 break; | 230 break; |
| 235 } | 231 } |
| 236 } | 232 } |
| 237 } | 233 } |
| OLD | NEW |