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

Side by Side Diff: apps/app_lifetime_monitor.cc

Issue 2623273011: Move Chrome terminating notification out of //apps (Closed)
Patch Set: remove DEPS rule Created 3 years, 11 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
« no previous file with comments | « apps/app_lifetime_monitor.h ('k') | apps/app_restore_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "apps/app_lifetime_monitor.h" 5 #include "apps/app_lifetime_monitor.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
9 #include "content/public/browser/notification_details.h" 8 #include "content/public/browser/notification_details.h"
10 #include "content/public/browser/notification_service.h" 9 #include "content/public/browser/notification_service.h"
11 #include "extensions/browser/app_window/app_window.h" 10 #include "extensions/browser/app_window/app_window.h"
12 #include "extensions/browser/extension_host.h" 11 #include "extensions/browser/extension_host.h"
13 #include "extensions/browser/notification_types.h" 12 #include "extensions/browser/notification_types.h"
14 #include "extensions/common/extension.h" 13 #include "extensions/common/extension.h"
15 14
16 namespace apps { 15 namespace apps {
17 16
18 using extensions::AppWindow; 17 using extensions::AppWindow;
19 using extensions::AppWindowRegistry; 18 using extensions::AppWindowRegistry;
20 using extensions::Extension; 19 using extensions::Extension;
21 using extensions::ExtensionHost; 20 using extensions::ExtensionHost;
22 21
23 AppLifetimeMonitor::AppLifetimeMonitor(Profile* profile) 22 AppLifetimeMonitor::AppLifetimeMonitor(Profile* profile)
24 : profile_(profile) { 23 : profile_(profile) {
25 registrar_.Add(this, 24 registrar_.Add(this,
26 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD, 25 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD,
27 content::NotificationService::AllSources()); 26 content::NotificationService::AllSources());
28 registrar_.Add(this, 27 registrar_.Add(this,
29 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, 28 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED,
30 content::NotificationService::AllSources()); 29 content::NotificationService::AllSources());
31 registrar_.Add(
32 this, chrome::NOTIFICATION_APP_TERMINATING,
33 content::NotificationService::AllSources());
34 30
35 AppWindowRegistry* app_window_registry = 31 AppWindowRegistry* app_window_registry =
36 AppWindowRegistry::Factory::GetForBrowserContext(profile_, 32 AppWindowRegistry::Factory::GetForBrowserContext(profile_,
37 false /* create */); 33 false /* create */);
38 DCHECK(app_window_registry); 34 DCHECK(app_window_registry);
39 app_window_registry->AddObserver(this); 35 app_window_registry->AddObserver(this);
40 } 36 }
41 37
42 AppLifetimeMonitor::~AppLifetimeMonitor() {} 38 AppLifetimeMonitor::~AppLifetimeMonitor() {}
43 39
(...skipping 21 matching lines...) Expand all
65 61
66 case extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED: { 62 case extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED: {
67 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); 63 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr();
68 const Extension* extension = host->extension(); 64 const Extension* extension = host->extension();
69 if (!extension || !extension->is_platform_app()) 65 if (!extension || !extension->is_platform_app())
70 return; 66 return;
71 67
72 NotifyAppStop(extension->id()); 68 NotifyAppStop(extension->id());
73 break; 69 break;
74 } 70 }
75
76 case chrome::NOTIFICATION_APP_TERMINATING: {
77 NotifyChromeTerminating();
78 break;
79 }
80 } 71 }
81 } 72 }
82 73
83 void AppLifetimeMonitor::OnAppWindowRemoved(AppWindow* app_window) { 74 void AppLifetimeMonitor::OnAppWindowRemoved(AppWindow* app_window) {
84 if (!HasOtherVisibleAppWindows(app_window)) 75 if (!HasOtherVisibleAppWindows(app_window))
85 NotifyAppDeactivated(app_window->extension_id()); 76 NotifyAppDeactivated(app_window->extension_id());
86 } 77 }
87 78
88 void AppLifetimeMonitor::OnAppWindowHidden(AppWindow* app_window) { 79 void AppLifetimeMonitor::OnAppWindowHidden(AppWindow* app_window) {
89 if (!HasOtherVisibleAppWindows(app_window)) 80 if (!HasOtherVisibleAppWindows(app_window))
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 void AppLifetimeMonitor::NotifyAppDeactivated(const std::string& app_id) { 128 void AppLifetimeMonitor::NotifyAppDeactivated(const std::string& app_id) {
138 for (auto& observer : observers_) 129 for (auto& observer : observers_)
139 observer.OnAppDeactivated(profile_, app_id); 130 observer.OnAppDeactivated(profile_, app_id);
140 } 131 }
141 132
142 void AppLifetimeMonitor::NotifyAppStop(const std::string& app_id) { 133 void AppLifetimeMonitor::NotifyAppStop(const std::string& app_id) {
143 for (auto& observer : observers_) 134 for (auto& observer : observers_)
144 observer.OnAppStop(profile_, app_id); 135 observer.OnAppStop(profile_, app_id);
145 } 136 }
146 137
147 void AppLifetimeMonitor::NotifyChromeTerminating() {
148 for (auto& observer : observers_)
149 observer.OnChromeTerminating();
150 }
151
152 } // namespace apps 138 } // namespace apps
OLDNEW
« no previous file with comments | « apps/app_lifetime_monitor.h ('k') | apps/app_restore_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698