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

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

Issue 425303002: Move extension notifications to extensions/browser/notification_types.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (extension-notifications) rebase 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 unified diff | Download patch | Annotate | Revision Log
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/browser/notification_types.h"
21 #include "extensions/browser/uninstall_reason.h" 22 #include "extensions/browser/uninstall_reason.h"
22 #include "extensions/common/extension.h" 23 #include "extensions/common/extension.h"
23 #include "extensions/common/extension_set.h" 24 #include "extensions/common/extension_set.h"
24 25
25 using extensions::Extension; 26 using extensions::Extension;
26 using extensions::ExtensionPrefs; 27 using extensions::ExtensionPrefs;
27 using extensions::ExtensionRegistry; 28 using extensions::ExtensionRegistry;
28 using extensions::ExtensionSet; 29 using extensions::ExtensionSet;
29 using extensions::ExtensionSystem; 30 using extensions::ExtensionSystem;
30 31
(...skipping 25 matching lines...) Expand all
56 57
57 EphemeralAppService::EphemeralAppService(Profile* profile) 58 EphemeralAppService::EphemeralAppService(Profile* profile)
58 : profile_(profile), 59 : profile_(profile),
59 extension_registry_observer_(this), 60 extension_registry_observer_(this),
60 ephemeral_app_count_(-1) { 61 ephemeral_app_count_(-1) {
61 if (!CommandLine::ForCurrentProcess()->HasSwitch( 62 if (!CommandLine::ForCurrentProcess()->HasSwitch(
62 switches::kEnableEphemeralApps)) 63 switches::kEnableEphemeralApps))
63 return; 64 return;
64 65
65 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); 66 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_));
66 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, 67 registrar_.Add(this,
68 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED,
67 content::Source<Profile>(profile_)); 69 content::Source<Profile>(profile_));
68 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, 70 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
69 content::Source<Profile>(profile_)); 71 content::Source<Profile>(profile_));
70 } 72 }
71 73
72 EphemeralAppService::~EphemeralAppService() { 74 EphemeralAppService::~EphemeralAppService() {
73 } 75 }
74 76
75 void EphemeralAppService::ClearCachedApps() { 77 void EphemeralAppService::ClearCachedApps() {
76 // Cancel any pending garbage collects. 78 // Cancel any pending garbage collects.
(...skipping 29 matching lines...) Expand all
106 base::Bind(&base::DoNothing), 108 base::Bind(&base::DoNothing),
107 NULL); 109 NULL);
108 } 110 }
109 } 111 }
110 112
111 void EphemeralAppService::Observe( 113 void EphemeralAppService::Observe(
112 int type, 114 int type,
113 const content::NotificationSource& source, 115 const content::NotificationSource& source,
114 const content::NotificationDetails& details) { 116 const content::NotificationDetails& details) {
115 switch (type) { 117 switch (type) {
116 case chrome::NOTIFICATION_EXTENSIONS_READY: { 118 case extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED: {
117 Init(); 119 Init();
118 break; 120 break;
119 } 121 }
120 case chrome::NOTIFICATION_PROFILE_DESTROYED: { 122 case chrome::NOTIFICATION_PROFILE_DESTROYED: {
121 // Ideally we need to know when the extension system is shutting down. 123 // Ideally we need to know when the extension system is shutting down.
122 garbage_collect_apps_timer_.Stop(); 124 garbage_collect_apps_timer_.Stop();
123 break; 125 break;
124 } 126 }
125 default: 127 default:
126 NOTREACHED(); 128 NOTREACHED();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 // Remove ephemeral apps that have been inactive for a while or if the cache 271 // Remove ephemeral apps that have been inactive for a while or if the cache
270 // is larger than the desired size. 272 // is larger than the desired size.
271 if (it->first < inactive_threshold || app_count > kMaxEphemeralAppsCount) { 273 if (it->first < inactive_threshold || app_count > kMaxEphemeralAppsCount) {
272 remove_app_ids->insert(it->second); 274 remove_app_ids->insert(it->second);
273 --app_count; 275 --app_count;
274 } else { 276 } else {
275 break; 277 break;
276 } 278 }
277 } 279 }
278 } 280 }
OLDNEW
« no previous file with comments | « chrome/browser/apps/ephemeral_app_browsertest.cc ('k') | chrome/browser/apps/ephemeral_app_service_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698