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

Side by Side Diff: apps/app_lifetime_monitor.cc

Issue 166573005: Rename apps::ShellWindow to apps::AppWindow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, nits (rename) Created 6 years, 10 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
« no previous file with comments | « apps/app_lifetime_monitor.h ('k') | apps/app_lifetime_monitor_factory.cc » ('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 "apps/shell_window.h" 7 #include "apps/app_window.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/extensions/extension_host.h" 9 #include "chrome/browser/extensions/extension_host.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "content/public/browser/notification_details.h" 11 #include "content/public/browser/notification_details.h"
12 #include "content/public/browser/notification_service.h" 12 #include "content/public/browser/notification_service.h"
13 #include "extensions/common/extension.h" 13 #include "extensions/common/extension.h"
14 14
15 namespace apps { 15 namespace apps {
16 16
17 using extensions::Extension; 17 using extensions::Extension;
18 using extensions::ExtensionHost; 18 using extensions::ExtensionHost;
19 19
20 AppLifetimeMonitor::AppLifetimeMonitor(Profile* profile) 20 AppLifetimeMonitor::AppLifetimeMonitor(Profile* profile)
21 : profile_(profile) { 21 : profile_(profile) {
22 registrar_.Add( 22 registrar_.Add(
23 this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, 23 this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING,
24 content::NotificationService::AllSources()); 24 content::NotificationService::AllSources());
25 registrar_.Add( 25 registrar_.Add(
26 this, chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, 26 this, chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
27 content::NotificationService::AllSources()); 27 content::NotificationService::AllSources());
28 registrar_.Add( 28 registrar_.Add(
29 this, chrome::NOTIFICATION_APP_TERMINATING, 29 this, chrome::NOTIFICATION_APP_TERMINATING,
30 content::NotificationService::AllSources()); 30 content::NotificationService::AllSources());
31 31
32 ShellWindowRegistry* shell_window_registry = 32 AppWindowRegistry* app_window_registry =
33 ShellWindowRegistry::Factory::GetForBrowserContext( 33 AppWindowRegistry::Factory::GetForBrowserContext(profile_,
34 profile_, false /* create */); 34 false /* create */);
35 DCHECK(shell_window_registry); 35 DCHECK(app_window_registry);
36 shell_window_registry->AddObserver(this); 36 app_window_registry->AddObserver(this);
37 } 37 }
38 38
39 AppLifetimeMonitor::~AppLifetimeMonitor() {} 39 AppLifetimeMonitor::~AppLifetimeMonitor() {}
40 40
41 void AppLifetimeMonitor::AddObserver(Observer* observer) { 41 void AppLifetimeMonitor::AddObserver(Observer* observer) {
42 observers_.AddObserver(observer); 42 observers_.AddObserver(observer);
43 } 43 }
44 44
45 void AppLifetimeMonitor::RemoveObserver(Observer* observer) { 45 void AppLifetimeMonitor::RemoveObserver(Observer* observer) {
46 observers_.RemoveObserver(observer); 46 observers_.RemoveObserver(observer);
(...skipping 23 matching lines...) Expand all
70 break; 70 break;
71 } 71 }
72 72
73 case chrome::NOTIFICATION_APP_TERMINATING: { 73 case chrome::NOTIFICATION_APP_TERMINATING: {
74 NotifyChromeTerminating(); 74 NotifyChromeTerminating();
75 break; 75 break;
76 } 76 }
77 } 77 }
78 } 78 }
79 79
80 void AppLifetimeMonitor::OnShellWindowAdded(ShellWindow* shell_window) { 80 void AppLifetimeMonitor::OnAppWindowAdded(AppWindow* app_window) {
81 if (shell_window->window_type() != ShellWindow::WINDOW_TYPE_DEFAULT) 81 if (app_window->window_type() != AppWindow::WINDOW_TYPE_DEFAULT)
82 return; 82 return;
83 83
84 ShellWindowRegistry::ShellWindowList windows = 84 AppWindowRegistry::AppWindowList windows =
85 ShellWindowRegistry::Get(shell_window->browser_context()) 85 AppWindowRegistry::Get(app_window->browser_context())
86 ->GetShellWindowsForApp(shell_window->extension_id()); 86 ->GetAppWindowsForApp(app_window->extension_id());
87 if (windows.size() == 1) 87 if (windows.size() == 1)
88 NotifyAppActivated(shell_window->extension_id()); 88 NotifyAppActivated(app_window->extension_id());
89 } 89 }
90 90
91 void AppLifetimeMonitor::OnShellWindowIconChanged(ShellWindow* shell_window) {} 91 void AppLifetimeMonitor::OnAppWindowIconChanged(AppWindow* app_window) {}
92 92
93 void AppLifetimeMonitor::OnShellWindowRemoved(ShellWindow* shell_window) { 93 void AppLifetimeMonitor::OnAppWindowRemoved(AppWindow* app_window) {
94 ShellWindowRegistry::ShellWindowList windows = 94 AppWindowRegistry::AppWindowList windows =
95 ShellWindowRegistry::Get(shell_window->browser_context()) 95 AppWindowRegistry::Get(app_window->browser_context())
96 ->GetShellWindowsForApp(shell_window->extension_id()); 96 ->GetAppWindowsForApp(app_window->extension_id());
97 if (windows.empty()) 97 if (windows.empty())
98 NotifyAppDeactivated(shell_window->extension_id()); 98 NotifyAppDeactivated(app_window->extension_id());
99 } 99 }
100 100
101 void AppLifetimeMonitor::Shutdown() { 101 void AppLifetimeMonitor::Shutdown() {
102 ShellWindowRegistry* shell_window_registry = 102 AppWindowRegistry* app_window_registry =
103 ShellWindowRegistry::Factory::GetForBrowserContext( 103 AppWindowRegistry::Factory::GetForBrowserContext(profile_,
104 profile_, false /* create */); 104 false /* create */);
105 if (shell_window_registry) 105 if (app_window_registry)
106 shell_window_registry->RemoveObserver(this); 106 app_window_registry->RemoveObserver(this);
107 } 107 }
108 108
109 void AppLifetimeMonitor::NotifyAppStart(const std::string& app_id) { 109 void AppLifetimeMonitor::NotifyAppStart(const std::string& app_id) {
110 FOR_EACH_OBSERVER(Observer, observers_, OnAppStart(profile_, app_id)); 110 FOR_EACH_OBSERVER(Observer, observers_, OnAppStart(profile_, app_id));
111 } 111 }
112 112
113 void AppLifetimeMonitor::NotifyAppActivated(const std::string& app_id) { 113 void AppLifetimeMonitor::NotifyAppActivated(const std::string& app_id) {
114 FOR_EACH_OBSERVER(Observer, observers_, OnAppActivated(profile_, app_id)); 114 FOR_EACH_OBSERVER(Observer, observers_, OnAppActivated(profile_, app_id));
115 } 115 }
116 116
117 void AppLifetimeMonitor::NotifyAppDeactivated(const std::string& app_id) { 117 void AppLifetimeMonitor::NotifyAppDeactivated(const std::string& app_id) {
118 FOR_EACH_OBSERVER(Observer, observers_, OnAppDeactivated(profile_, app_id)); 118 FOR_EACH_OBSERVER(Observer, observers_, OnAppDeactivated(profile_, app_id));
119 } 119 }
120 120
121 void AppLifetimeMonitor::NotifyAppStop(const std::string& app_id) { 121 void AppLifetimeMonitor::NotifyAppStop(const std::string& app_id) {
122 FOR_EACH_OBSERVER(Observer, observers_, OnAppStop(profile_, app_id)); 122 FOR_EACH_OBSERVER(Observer, observers_, OnAppStop(profile_, app_id));
123 } 123 }
124 124
125 void AppLifetimeMonitor::NotifyChromeTerminating() { 125 void AppLifetimeMonitor::NotifyChromeTerminating() {
126 FOR_EACH_OBSERVER(Observer, observers_, OnChromeTerminating()); 126 FOR_EACH_OBSERVER(Observer, observers_, OnChromeTerminating());
127 } 127 }
128 128
129 } // namespace apps 129 } // namespace apps
OLDNEW
« no previous file with comments | « apps/app_lifetime_monitor.h ('k') | apps/app_lifetime_monitor_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698