| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_AURA_ACTIVE_DESKTOP_MONITOR_H_ | 5 #ifndef CHROME_BROWSER_UI_AURA_ACTIVE_DESKTOP_MONITOR_H_ |
| 6 #define CHROME_BROWSER_UI_AURA_ACTIVE_DESKTOP_MONITOR_H_ | 6 #define CHROME_BROWSER_UI_AURA_ACTIVE_DESKTOP_MONITOR_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "chrome/browser/ui/host_desktop.h" | 10 #include "chrome/browser/ui/host_desktop.h" |
| 11 #include "ui/aura/env_observer.h" | 11 #include "ui/aura/env_observer.h" |
| 12 | 12 |
| 13 // Tracks the most-recently activated host desktop type by observing | 13 // Tracks the most-recently activated host desktop type by observing |
| 14 // WindowTreeHost activations. | 14 // RootWindowHost activations. |
| 15 class ActiveDesktopMonitor : public aura::EnvObserver { | 15 class ActiveDesktopMonitor : public aura::EnvObserver { |
| 16 public: | 16 public: |
| 17 // Constructs an ActiveDesktopMonitor which initially uses |initial_desktop| | 17 // Constructs an ActiveDesktopMonitor which initially uses |initial_desktop| |
| 18 // as the |last_activated_desktop_| until a root window is activated. | 18 // as the |last_activated_desktop_| until a root window is activated. |
| 19 explicit ActiveDesktopMonitor(chrome::HostDesktopType initial_desktop); | 19 explicit ActiveDesktopMonitor(chrome::HostDesktopType initial_desktop); |
| 20 virtual ~ActiveDesktopMonitor(); | 20 virtual ~ActiveDesktopMonitor(); |
| 21 | 21 |
| 22 // Returns the host desktop type of the most-recently activated | 22 // Returns the host desktop type of the most-recently activated |
| 23 // WindowTreeHost. This desktop type may no longer exist (e.g., the Ash | 23 // RootWindowHost. This desktop type may no longer exist (e.g., the Ash |
| 24 // desktop may have closed since being active, and no RWHs on the native | 24 // desktop may have closed since being active, and no RWHs on the native |
| 25 // desktop have yet been activated). | 25 // desktop have yet been activated). |
| 26 static chrome::HostDesktopType GetLastActivatedDesktopType(); | 26 static chrome::HostDesktopType GetLastActivatedDesktopType(); |
| 27 | 27 |
| 28 private: | 28 private: |
| 29 // Returns true if |root_window| is hosted by a DesktopWindowTreeHost. | 29 // Returns true if |root_window| is hosted by a DesktopRootWindowHost. |
| 30 static bool IsDesktopWindow(aura::RootWindow* root_window); | 30 static bool IsDesktopWindow(aura::RootWindow* root_window); |
| 31 | 31 |
| 32 // aura::EnvObserver methods. | 32 // aura::EnvObserver methods. |
| 33 virtual void OnWindowInitialized(aura::Window* window) OVERRIDE; | 33 virtual void OnWindowInitialized(aura::Window* window) OVERRIDE; |
| 34 virtual void OnRootWindowActivated(aura::RootWindow* root_window) OVERRIDE; | 34 virtual void OnRootWindowActivated(aura::RootWindow* root_window) OVERRIDE; |
| 35 | 35 |
| 36 static ActiveDesktopMonitor* g_instance_; | 36 static ActiveDesktopMonitor* g_instance_; |
| 37 chrome::HostDesktopType last_activated_desktop_; | 37 chrome::HostDesktopType last_activated_desktop_; |
| 38 | 38 |
| 39 DISALLOW_COPY_AND_ASSIGN(ActiveDesktopMonitor); | 39 DISALLOW_COPY_AND_ASSIGN(ActiveDesktopMonitor); |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 #endif // CHROME_BROWSER_UI_AURA_ACTIVE_DESKTOP_MONITOR_H_ | 42 #endif // CHROME_BROWSER_UI_AURA_ACTIVE_DESKTOP_MONITOR_H_ |
| OLD | NEW |