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/ui/ash/launcher/browser_status_monitor.h" | 5 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" |
6 | 6 |
7 #include "ash/display/window_tree_host_manager.h" | 7 #include "ash/display/window_tree_host_manager.h" |
8 #include "ash/shelf/shelf_util.h" | 8 #include "ash/shelf/shelf_util.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
22 #include "chrome/browser/web_applications/web_app.h" | 22 #include "chrome/browser/web_applications/web_app.h" |
23 #include "components/strings/grit/components_strings.h" | 23 #include "components/strings/grit/components_strings.h" |
24 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
25 #include "content/public/browser/web_contents_observer.h" | 25 #include "content/public/browser/web_contents_observer.h" |
26 #include "grit/ash_resources.h" | 26 #include "grit/ash_resources.h" |
27 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
28 #include "ui/aura/window.h" | 28 #include "ui/aura/window.h" |
29 #include "ui/aura/window_event_dispatcher.h" | 29 #include "ui/aura/window_event_dispatcher.h" |
30 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
31 #include "ui/gfx/screen.h" | 31 #include "ui/display/screen.h" |
32 #include "ui/wm/public/activation_client.h" | 32 #include "ui/wm/public/activation_client.h" |
33 | 33 |
34 // This class monitors the WebContent of the all tab and notifies a navigation | 34 // This class monitors the WebContent of the all tab and notifies a navigation |
35 // to the BrowserStatusMonitor. | 35 // to the BrowserStatusMonitor. |
36 class BrowserStatusMonitor::LocalWebContentsObserver | 36 class BrowserStatusMonitor::LocalWebContentsObserver |
37 : public content::WebContentsObserver { | 37 : public content::WebContentsObserver { |
38 public: | 38 public: |
39 LocalWebContentsObserver(content::WebContents* contents, | 39 LocalWebContentsObserver(content::WebContents* contents, |
40 BrowserStatusMonitor* monitor) | 40 BrowserStatusMonitor* monitor) |
41 : content::WebContentsObserver(contents), | 41 : content::WebContentsObserver(contents), |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); | 121 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); |
122 aura::Window::Windows::const_iterator iter = root_windows.begin(); | 122 aura::Window::Windows::const_iterator iter = root_windows.begin(); |
123 for (; iter != root_windows.end(); ++iter) { | 123 for (; iter != root_windows.end(); ++iter) { |
124 // |observed_activation_clients_| can have the same activation client | 124 // |observed_activation_clients_| can have the same activation client |
125 // multiple times - which would be handled by the used | 125 // multiple times - which would be handled by the used |
126 // |ScopedObserverWithDuplicatedSources|. | 126 // |ScopedObserverWithDuplicatedSources|. |
127 observed_activation_clients_.Add( | 127 observed_activation_clients_.Add( |
128 aura::client::GetActivationClient(*iter)); | 128 aura::client::GetActivationClient(*iter)); |
129 observed_root_windows_.Add(static_cast<aura::Window*>(*iter)); | 129 observed_root_windows_.Add(static_cast<aura::Window*>(*iter)); |
130 } | 130 } |
131 gfx::Screen::GetScreen()->AddObserver(this); | 131 display::Screen::GetScreen()->AddObserver(this); |
132 } | 132 } |
133 | 133 |
134 browser_tab_strip_tracker_.Init( | 134 browser_tab_strip_tracker_.Init( |
135 BrowserTabStripTracker::InitWith::ALL_BROWERS); | 135 BrowserTabStripTracker::InitWith::ALL_BROWERS); |
136 } | 136 } |
137 | 137 |
138 BrowserStatusMonitor::~BrowserStatusMonitor() { | 138 BrowserStatusMonitor::~BrowserStatusMonitor() { |
139 // This check needs for win7_aura. Without this, all tests in | 139 // This check needs for win7_aura. Without this, all tests in |
140 // ChromeLauncherController will fail in win7_aura. | 140 // ChromeLauncherController will fail in win7_aura. |
141 if (ash::Shell::HasInstance()) | 141 if (ash::Shell::HasInstance()) |
142 gfx::Screen::GetScreen()->RemoveObserver(this); | 142 display::Screen::GetScreen()->RemoveObserver(this); |
143 | 143 |
144 chrome::SettingsWindowManager::GetInstance()->RemoveObserver( | 144 chrome::SettingsWindowManager::GetInstance()->RemoveObserver( |
145 settings_window_observer_.get()); | 145 settings_window_observer_.get()); |
146 | 146 |
147 browser_tab_strip_tracker_.StopObservingAndSendOnBrowserRemoved(); | 147 browser_tab_strip_tracker_.StopObservingAndSendOnBrowserRemoved(); |
148 | 148 |
149 STLDeleteContainerPairSecondPointers(webcontents_to_observer_map_.begin(), | 149 STLDeleteContainerPairSecondPointers(webcontents_to_observer_map_.begin(), |
150 webcontents_to_observer_map_.end()); | 150 webcontents_to_observer_map_.end()); |
151 } | 151 } |
152 | 152 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 } | 223 } |
224 } | 224 } |
225 | 225 |
226 void BrowserStatusMonitor::OnBrowserRemoved(Browser* browser) { | 226 void BrowserStatusMonitor::OnBrowserRemoved(Browser* browser) { |
227 if (browser->is_type_popup() && browser->is_app()) | 227 if (browser->is_type_popup() && browser->is_app()) |
228 RemoveV1AppFromShelf(browser); | 228 RemoveV1AppFromShelf(browser); |
229 | 229 |
230 UpdateBrowserItemState(); | 230 UpdateBrowserItemState(); |
231 } | 231 } |
232 | 232 |
233 void BrowserStatusMonitor::OnDisplayAdded(const gfx::Display& new_display) { | 233 void BrowserStatusMonitor::OnDisplayAdded(const display::Display& new_display) { |
234 // Add a new RootWindow and its ActivationClient to observed list. | 234 // Add a new RootWindow and its ActivationClient to observed list. |
235 aura::Window* root_window = ash::Shell::GetInstance() | 235 aura::Window* root_window = ash::Shell::GetInstance() |
236 ->window_tree_host_manager() | 236 ->window_tree_host_manager() |
237 ->GetRootWindowForDisplayId(new_display.id()); | 237 ->GetRootWindowForDisplayId(new_display.id()); |
238 // When the primary root window's display get removed, the existing root | 238 // When the primary root window's display get removed, the existing root |
239 // window is taken over by the new display and the observer is already set. | 239 // window is taken over by the new display and the observer is already set. |
240 if (!observed_root_windows_.IsObserving(root_window)) { | 240 if (!observed_root_windows_.IsObserving(root_window)) { |
241 observed_root_windows_.Add(static_cast<aura::Window*>(root_window)); | 241 observed_root_windows_.Add(static_cast<aura::Window*>(root_window)); |
242 observed_activation_clients_.Add( | 242 observed_activation_clients_.Add( |
243 aura::client::GetActivationClient(root_window)); | 243 aura::client::GetActivationClient(root_window)); |
244 } | 244 } |
245 } | 245 } |
246 | 246 |
247 void BrowserStatusMonitor::OnDisplayRemoved(const gfx::Display& old_display) { | 247 void BrowserStatusMonitor::OnDisplayRemoved( |
| 248 const display::Display& old_display) { |
248 // When this is called, RootWindow of |old_display| is already removed. | 249 // When this is called, RootWindow of |old_display| is already removed. |
249 // Instead, we can remove RootWindow and its ActivationClient in the | 250 // Instead, we can remove RootWindow and its ActivationClient in the |
250 // OnWindowRemoved(). | 251 // OnWindowRemoved(). |
251 // Do nothing here. | 252 // Do nothing here. |
252 } | 253 } |
253 | 254 |
254 void BrowserStatusMonitor::OnDisplayMetricsChanged(const gfx::Display&, | 255 void BrowserStatusMonitor::OnDisplayMetricsChanged(const display::Display&, |
255 uint32_t) { | 256 uint32_t) { |
256 // Do nothing here. | 257 // Do nothing here. |
257 } | 258 } |
258 | 259 |
259 void BrowserStatusMonitor::ActiveTabChanged(content::WebContents* old_contents, | 260 void BrowserStatusMonitor::ActiveTabChanged(content::WebContents* old_contents, |
260 content::WebContents* new_contents, | 261 content::WebContents* new_contents, |
261 int index, | 262 int index, |
262 int reason) { | 263 int reason) { |
263 Browser* browser = NULL; | 264 Browser* browser = NULL; |
264 // Use |new_contents|. |old_contents| could be NULL. | 265 // Use |new_contents|. |old_contents| could be NULL. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 content::WebContents* contents) { | 379 content::WebContents* contents) { |
379 return launcher_controller_->GetShelfIDForWebContents(contents); | 380 return launcher_controller_->GetShelfIDForWebContents(contents); |
380 } | 381 } |
381 | 382 |
382 void BrowserStatusMonitor::SetShelfIDForBrowserWindowContents( | 383 void BrowserStatusMonitor::SetShelfIDForBrowserWindowContents( |
383 Browser* browser, | 384 Browser* browser, |
384 content::WebContents* web_contents) { | 385 content::WebContents* web_contents) { |
385 launcher_controller_->GetBrowserShortcutLauncherItemController()-> | 386 launcher_controller_->GetBrowserShortcutLauncherItemController()-> |
386 SetShelfIDForBrowserWindowContents(browser, web_contents); | 387 SetShelfIDForBrowserWindowContents(browser, web_contents); |
387 } | 388 } |
OLD | NEW |