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

Side by Side Diff: ash/wm/aura/wm_globals_aura.cc

Issue 1918883002: Makes Panel related classes use ash/wm/common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@phantom_window_controller
Patch Set: feedback Created 4 years, 8 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 | « ash/wm/aura/wm_globals_aura.h ('k') | ash/wm/aura/wm_window_aura.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 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"
14 #include "ash/wm/common/wm_overview_mode_observer.h"
13 #include "ash/wm/mru_window_tracker.h" 15 #include "ash/wm/mru_window_tracker.h"
14 #include "ash/wm/window_util.h" 16 #include "ash/wm/window_util.h"
15 #include "ui/aura/client/focus_client.h" 17 #include "ui/aura/client/focus_client.h"
16 #include "ui/wm/public/activation_client.h" 18 #include "ui/wm/public/activation_client.h"
17 19
18 namespace ash { 20 namespace ash {
19 namespace wm { 21 namespace wm {
20 namespace { 22 namespace {
21 23
22 WmGlobalsAura* instance_ = nullptr; 24 WmGlobalsAura* instance_ = nullptr;
23 25
24 } // namespace 26 } // namespace
25 27
26 // static 28 // static
27 WmGlobals* WmGlobals::Get() { 29 WmGlobals* WmGlobals::Get() {
28 return instance_; 30 return instance_;
29 } 31 }
30 32
31 WmGlobalsAura::WmGlobalsAura() { 33 WmGlobalsAura::WmGlobalsAura() {
32 DCHECK(!instance_); 34 DCHECK(!instance_);
33 instance_ = this; 35 instance_ = this;
36 Shell::GetInstance()->AddShellObserver(this);
34 } 37 }
35 38
36 WmGlobalsAura::~WmGlobalsAura() { 39 WmGlobalsAura::~WmGlobalsAura() {
37 instance_ = nullptr; 40 instance_ = nullptr;
38 if (added_activation_observer_) { 41 if (added_activation_observer_) {
39 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow()) 42 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())
40 ->RemoveObserver(this); 43 ->RemoveObserver(this);
41 } 44 }
45 if (added_display_observer_)
46 Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this);
47
48 Shell::GetInstance()->RemoveShellObserver(this);
42 } 49 }
43 50
44 // static 51 // static
45 WmGlobalsAura* WmGlobalsAura::Get() { 52 WmGlobalsAura* WmGlobalsAura::Get() {
46 if (!instance_) 53 if (!instance_)
47 new WmGlobalsAura; 54 new WmGlobalsAura;
48 return instance_; 55 return instance_;
49 } 56 }
50 57
51 WmWindow* WmGlobalsAura::GetFocusedWindow() { 58 WmWindow* WmGlobalsAura::GetFocusedWindow() {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow()) 115 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())
109 ->AddObserver(this); 116 ->AddObserver(this);
110 } 117 }
111 activation_observers_.AddObserver(observer); 118 activation_observers_.AddObserver(observer);
112 } 119 }
113 120
114 void WmGlobalsAura::RemoveActivationObserver(WmActivationObserver* observer) { 121 void WmGlobalsAura::RemoveActivationObserver(WmActivationObserver* observer) {
115 activation_observers_.RemoveObserver(observer); 122 activation_observers_.RemoveObserver(observer);
116 } 123 }
117 124
125 void WmGlobalsAura::AddDisplayObserver(WmDisplayObserver* observer) {
126 if (!added_display_observer_) {
127 added_display_observer_ = true;
128 Shell::GetInstance()->window_tree_host_manager()->AddObserver(this);
129 }
130 display_observers_.AddObserver(observer);
131 }
132
133 void WmGlobalsAura::RemoveDisplayObserver(WmDisplayObserver* observer) {
134 display_observers_.RemoveObserver(observer);
135 }
136
137 void WmGlobalsAura::AddOverviewModeObserver(WmOverviewModeObserver* observer) {
138 overview_mode_observers_.AddObserver(observer);
139 }
140
141 void WmGlobalsAura::RemoveOverviewModeObserver(
142 WmOverviewModeObserver* observer) {
143 overview_mode_observers_.RemoveObserver(observer);
144 }
145
118 void WmGlobalsAura::OnWindowActivated( 146 void WmGlobalsAura::OnWindowActivated(
119 aura::client::ActivationChangeObserver::ActivationReason reason, 147 aura::client::ActivationChangeObserver::ActivationReason reason,
120 aura::Window* gained_active, 148 aura::Window* gained_active,
121 aura::Window* lost_active) { 149 aura::Window* lost_active) {
122 FOR_EACH_OBSERVER(WmActivationObserver, activation_observers_, 150 FOR_EACH_OBSERVER(WmActivationObserver, activation_observers_,
123 OnWindowActivated(WmWindowAura::Get(gained_active), 151 OnWindowActivated(WmWindowAura::Get(gained_active),
124 WmWindowAura::Get(lost_active))); 152 WmWindowAura::Get(lost_active)));
125 } 153 }
126 154
155 void WmGlobalsAura::OnDisplayConfigurationChanged() {
156 FOR_EACH_OBSERVER(WmDisplayObserver, display_observers_,
157 OnDisplayConfigurationChanged());
158 }
159
160 void WmGlobalsAura::OnOverviewModeEnded() {
161 FOR_EACH_OBSERVER(WmOverviewModeObserver, overview_mode_observers_,
162 OnOverviewModeEnded());
163 }
164
127 } // namespace wm 165 } // namespace wm
128 } // namespace ash 166 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/aura/wm_globals_aura.h ('k') | ash/wm/aura/wm_window_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698