| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/wm/aura/wm_globals_aura.h" | 5 #include "ash/wm/aura/wm_globals_aura.h" |
| 6 | 6 |
| 7 #include "ash/display/window_tree_host_manager.h" | 7 #include "ash/display/window_tree_host_manager.h" |
| 8 #include "ash/session/session_state_delegate.h" | 8 #include "ash/session/session_state_delegate.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_delegate.h" | 10 #include "ash/shell_delegate.h" |
| 11 #include "ash/wm/aura/wm_window_aura.h" | 11 #include "ash/wm/aura/wm_window_aura.h" |
| 12 #include "ash/wm/common/wm_activation_observer.h" | 12 #include "ash/wm/common/wm_activation_observer.h" |
| 13 #include "ash/wm/common/wm_display_observer.h" | 13 #include "ash/wm/common/wm_display_observer.h" |
| 14 #include "ash/wm/common/wm_overview_mode_observer.h" | 14 #include "ash/wm/common/wm_overview_mode_observer.h" |
| 15 #include "ash/wm/drag_window_resizer.h" | 15 #include "ash/wm/drag_window_resizer.h" |
| 16 #include "ash/wm/mru_window_tracker.h" | 16 #include "ash/wm/mru_window_tracker.h" |
| 17 #include "ash/wm/overview/window_selector_controller.h" | 17 #include "ash/wm/overview/window_selector_controller.h" |
| 18 #include "ash/wm/window_util.h" | 18 #include "ash/wm/window_util.h" |
| 19 #include "base/memory/ptr_util.h" | 19 #include "base/memory/ptr_util.h" |
| 20 #include "ui/aura/client/focus_client.h" | 20 #include "ui/aura/client/focus_client.h" |
| 21 #include "ui/wm/public/activation_client.h" | 21 #include "ui/wm/public/activation_client.h" |
| 22 | 22 |
| 23 namespace ash { | 23 namespace ash { |
| 24 namespace wm { | 24 namespace wm { |
| 25 namespace { | |
| 26 | |
| 27 WmGlobalsAura* instance_ = nullptr; | |
| 28 | |
| 29 } // namespace | |
| 30 | |
| 31 // static | |
| 32 WmGlobals* WmGlobals::Get() { | |
| 33 return instance_; | |
| 34 } | |
| 35 | 25 |
| 36 WmGlobalsAura::WmGlobalsAura() { | 26 WmGlobalsAura::WmGlobalsAura() { |
| 37 DCHECK(!instance_); | 27 WmGlobals::Set(this); |
| 38 instance_ = this; | |
| 39 Shell::GetInstance()->AddShellObserver(this); | 28 Shell::GetInstance()->AddShellObserver(this); |
| 40 } | 29 } |
| 41 | 30 |
| 42 WmGlobalsAura::~WmGlobalsAura() { | 31 WmGlobalsAura::~WmGlobalsAura() { |
| 43 instance_ = nullptr; | 32 WmGlobals::Set(nullptr); |
| 44 if (added_activation_observer_) { | 33 if (added_activation_observer_) { |
| 45 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow()) | 34 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow()) |
| 46 ->RemoveObserver(this); | 35 ->RemoveObserver(this); |
| 47 } | 36 } |
| 48 if (added_display_observer_) | 37 if (added_display_observer_) |
| 49 Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); | 38 Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); |
| 50 | 39 |
| 51 Shell::GetInstance()->RemoveShellObserver(this); | 40 Shell::GetInstance()->RemoveShellObserver(this); |
| 52 } | 41 } |
| 53 | 42 |
| 54 // static | |
| 55 WmGlobalsAura* WmGlobalsAura::Get() { | |
| 56 if (!instance_) | |
| 57 new WmGlobalsAura; | |
| 58 return instance_; | |
| 59 } | |
| 60 | |
| 61 WmWindow* WmGlobalsAura::GetFocusedWindow() { | 43 WmWindow* WmGlobalsAura::GetFocusedWindow() { |
| 62 return WmWindowAura::Get( | 44 return WmWindowAura::Get( |
| 63 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow()) | 45 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow()) |
| 64 ->GetFocusedWindow()); | 46 ->GetFocusedWindow()); |
| 65 } | 47 } |
| 66 | 48 |
| 67 WmWindow* WmGlobalsAura::GetActiveWindow() { | 49 WmWindow* WmGlobalsAura::GetActiveWindow() { |
| 68 return WmWindowAura::Get(wm::GetActiveWindow()); | 50 return WmWindowAura::Get(wm::GetActiveWindow()); |
| 69 } | 51 } |
| 70 | 52 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 OnDisplayConfigurationChanged()); | 167 OnDisplayConfigurationChanged()); |
| 186 } | 168 } |
| 187 | 169 |
| 188 void WmGlobalsAura::OnOverviewModeEnded() { | 170 void WmGlobalsAura::OnOverviewModeEnded() { |
| 189 FOR_EACH_OBSERVER(WmOverviewModeObserver, overview_mode_observers_, | 171 FOR_EACH_OBSERVER(WmOverviewModeObserver, overview_mode_observers_, |
| 190 OnOverviewModeEnded()); | 172 OnOverviewModeEnded()); |
| 191 } | 173 } |
| 192 | 174 |
| 193 } // namespace wm | 175 } // namespace wm |
| 194 } // namespace ash | 176 } // namespace ash |
| OLD | NEW |