| 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/data_deleter.h" | 10 #include "chrome/browser/extensions/data_deleter.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 return EphemeralAppServiceFactory::GetForProfile(profile); | 60 return EphemeralAppServiceFactory::GetForProfile(profile); |
| 61 } | 61 } |
| 62 | 62 |
| 63 EphemeralAppService::EphemeralAppService(Profile* profile) | 63 EphemeralAppService::EphemeralAppService(Profile* profile) |
| 64 : profile_(profile), | 64 : profile_(profile), |
| 65 ephemeral_app_count_(-1) { | 65 ephemeral_app_count_(-1) { |
| 66 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 66 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 67 switches::kEnableEphemeralApps)) | 67 switches::kEnableEphemeralApps)) |
| 68 return; | 68 return; |
| 69 | 69 |
| 70 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, | 70 registrar_.Add(this, |
| 71 chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED, |
| 71 content::Source<Profile>(profile_)); | 72 content::Source<Profile>(profile_)); |
| 72 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 73 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
| 73 content::Source<Profile>(profile_)); | 74 content::Source<Profile>(profile_)); |
| 74 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, | 75 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, |
| 75 content::Source<Profile>(profile_)); | 76 content::Source<Profile>(profile_)); |
| 76 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, | 77 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, |
| 77 content::Source<Profile>(profile_)); | 78 content::Source<Profile>(profile_)); |
| 78 } | 79 } |
| 79 | 80 |
| 80 EphemeralAppService::~EphemeralAppService() { | 81 EphemeralAppService::~EphemeralAppService() { |
| 81 } | 82 } |
| 82 | 83 |
| 83 void EphemeralAppService::Observe( | 84 void EphemeralAppService::Observe( |
| 84 int type, | 85 int type, |
| 85 const content::NotificationSource& source, | 86 const content::NotificationSource& source, |
| 86 const content::NotificationDetails& details) { | 87 const content::NotificationDetails& details) { |
| 87 switch (type) { | 88 switch (type) { |
| 88 case chrome::NOTIFICATION_EXTENSIONS_READY: { | 89 case chrome::NOTIFICATION_EXTENSIONS_READY: { |
| 89 Init(); | 90 Init(); |
| 90 break; | 91 break; |
| 91 } | 92 } |
| 92 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { | 93 case chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED: { |
| 93 const Extension* extension = | 94 const Extension* extension = |
| 94 content::Details<const InstalledExtensionInfo>(details)->extension; | 95 content::Details<const InstalledExtensionInfo>(details)->extension; |
| 95 DCHECK(extension); | 96 DCHECK(extension); |
| 96 if (extensions::util::IsEphemeralApp(extension->id(), profile_)) { | 97 if (extensions::util::IsEphemeralApp(extension->id(), profile_)) { |
| 97 ++ephemeral_app_count_; | 98 ++ephemeral_app_count_; |
| 98 if (ephemeral_app_count_ >= kGarbageCollectAppsTriggerCount) | 99 if (ephemeral_app_count_ >= kGarbageCollectAppsTriggerCount) |
| 99 TriggerGarbageCollect( | 100 TriggerGarbageCollect( |
| 100 base::TimeDelta::FromSeconds(kGarbageCollectAppsInstallDelay)); | 101 base::TimeDelta::FromSeconds(kGarbageCollectAppsInstallDelay)); |
| 101 } | 102 } |
| 102 break; | 103 break; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 info->extension_id, | 280 info->extension_id, |
| 280 &error)); | 281 &error)); |
| 281 | 282 |
| 282 if (extension.get()) | 283 if (extension.get()) |
| 283 extensions::DataDeleter::StartDeleting(profile_, extension.get()); | 284 extensions::DataDeleter::StartDeleting(profile_, extension.get()); |
| 284 } | 285 } |
| 285 | 286 |
| 286 prefs->RemoveEvictedEphemeralApp(info->extension_id); | 287 prefs->RemoveEvictedEphemeralApp(info->extension_id); |
| 287 } | 288 } |
| 288 } | 289 } |
| OLD | NEW |