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 #include "ui/aura/env.h" | 5 #include "ui/aura/env.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
11 #include "ui/aura/client/aura_constants.h" | 11 #include "ui/aura/client/aura_constants.h" |
12 #include "ui/aura/env_input_state_controller.h" | 12 #include "ui/aura/env_input_state_controller.h" |
13 #include "ui/aura/env_observer.h" | 13 #include "ui/aura/env_observer.h" |
14 #include "ui/aura/input_state_lookup.h" | 14 #include "ui/aura/input_state_lookup.h" |
15 #include "ui/aura/local/window_port_local.h" | 15 #include "ui/aura/local/window_port_local.h" |
16 #include "ui/aura/mus/mus_types.h" | 16 #include "ui/aura/mus/mus_types.h" |
17 #include "ui/aura/mus/os_exchange_data_provider_mus.h" | 17 #include "ui/aura/mus/os_exchange_data_provider_mus.h" |
18 #include "ui/aura/mus/window_port_mus.h" | 18 #include "ui/aura/mus/window_port_mus.h" |
19 #include "ui/aura/mus/window_tree_client.h" | 19 #include "ui/aura/mus/window_tree_client.h" |
20 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
| 21 #include "ui/aura/window_port_for_shutdown.h" |
21 #include "ui/events/event_target_iterator.h" | 22 #include "ui/events/event_target_iterator.h" |
22 #include "ui/events/platform/platform_event_source.h" | 23 #include "ui/events/platform/platform_event_source.h" |
23 | 24 |
24 #if defined(USE_OZONE) | 25 #if defined(USE_OZONE) |
25 #include "ui/ozone/public/client_native_pixmap_factory_ozone.h" | 26 #include "ui/ozone/public/client_native_pixmap_factory_ozone.h" |
26 #include "ui/ozone/public/ozone_platform.h" | 27 #include "ui/ozone/public/ozone_platform.h" |
27 #endif | 28 #endif |
28 | 29 |
29 namespace aura { | 30 namespace aura { |
30 | 31 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 77 |
77 // static | 78 // static |
78 Env* Env::GetInstanceDontCreate() { | 79 Env* Env::GetInstanceDontCreate() { |
79 return lazy_tls_ptr.Pointer()->Get(); | 80 return lazy_tls_ptr.Pointer()->Get(); |
80 } | 81 } |
81 | 82 |
82 std::unique_ptr<WindowPort> Env::CreateWindowPort(Window* window) { | 83 std::unique_ptr<WindowPort> Env::CreateWindowPort(Window* window) { |
83 if (mode_ == Mode::LOCAL) | 84 if (mode_ == Mode::LOCAL) |
84 return base::MakeUnique<WindowPortLocal>(window); | 85 return base::MakeUnique<WindowPortLocal>(window); |
85 | 86 |
| 87 if (in_mus_shutdown_) |
| 88 return base::MakeUnique<WindowPortForShutdown>(); |
| 89 |
86 DCHECK(window_tree_client_); | 90 DCHECK(window_tree_client_); |
87 WindowMusType window_mus_type; | 91 WindowMusType window_mus_type; |
88 switch (window->GetProperty(aura::client::kEmbedType)) { | 92 switch (window->GetProperty(aura::client::kEmbedType)) { |
89 case aura::client::WindowEmbedType::NONE: | 93 case aura::client::WindowEmbedType::NONE: |
90 window_mus_type = WindowMusType::LOCAL; | 94 window_mus_type = WindowMusType::LOCAL; |
91 break; | 95 break; |
92 case aura::client::WindowEmbedType::TOP_LEVEL_IN_WM: | 96 case aura::client::WindowEmbedType::TOP_LEVEL_IN_WM: |
93 window_mus_type = WindowMusType::TOP_LEVEL_IN_WM; | 97 window_mus_type = WindowMusType::TOP_LEVEL_IN_WM; |
94 break; | 98 break; |
95 case aura::client::WindowEmbedType::EMBED_IN_OWNER: | 99 case aura::client::WindowEmbedType::EMBED_IN_OWNER: |
(...skipping 19 matching lines...) Expand all Loading... |
115 mouse_button_flags_ != 0; | 119 mouse_button_flags_ != 0; |
116 } | 120 } |
117 | 121 |
118 const gfx::Point& Env::last_mouse_location() const { | 122 const gfx::Point& Env::last_mouse_location() const { |
119 if (mode_ == Mode::LOCAL || always_use_last_mouse_location_ || | 123 if (mode_ == Mode::LOCAL || always_use_last_mouse_location_ || |
120 !get_last_mouse_location_from_mus_) { | 124 !get_last_mouse_location_from_mus_) { |
121 return last_mouse_location_; | 125 return last_mouse_location_; |
122 } | 126 } |
123 | 127 |
124 // Some tests may not install a WindowTreeClient, and we allow multiple | 128 // Some tests may not install a WindowTreeClient, and we allow multiple |
125 // WindowTreeClients for the case of multiple connections. | 129 // WindowTreeClients for the case of multiple connections, and this may be |
| 130 // called during shutdown, when there is no WindowTreeClient. |
126 if (window_tree_client_) | 131 if (window_tree_client_) |
127 last_mouse_location_ = window_tree_client_->GetCursorScreenPoint(); | 132 last_mouse_location_ = window_tree_client_->GetCursorScreenPoint(); |
128 return last_mouse_location_; | 133 return last_mouse_location_; |
129 } | 134 } |
130 | 135 |
131 void Env::SetWindowTreeClient(WindowTreeClient* window_tree_client) { | 136 void Env::SetWindowTreeClient(WindowTreeClient* window_tree_client) { |
132 // The WindowTreeClient should only be set once. Test code may need to change | 137 // The WindowTreeClient should only be set once. Test code may need to change |
133 // the value after the fact, to do that use EnvTestHelper. | 138 // the value after the fact, to do that use EnvTestHelper. |
134 DCHECK(!window_tree_client_); | 139 DCHECK(!window_tree_client_); |
135 window_tree_client_ = window_tree_client; | 140 window_tree_client_ = window_tree_client; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 void Env::NotifyHostInitialized(WindowTreeHost* host) { | 195 void Env::NotifyHostInitialized(WindowTreeHost* host) { |
191 for (EnvObserver& observer : observers_) | 196 for (EnvObserver& observer : observers_) |
192 observer.OnHostInitialized(host); | 197 observer.OnHostInitialized(host); |
193 } | 198 } |
194 | 199 |
195 void Env::NotifyHostActivated(WindowTreeHost* host) { | 200 void Env::NotifyHostActivated(WindowTreeHost* host) { |
196 for (EnvObserver& observer : observers_) | 201 for (EnvObserver& observer : observers_) |
197 observer.OnHostActivated(host); | 202 observer.OnHostActivated(host); |
198 } | 203 } |
199 | 204 |
| 205 void Env::WindowTreeClientDestroyed(aura::WindowTreeClient* client) { |
| 206 DCHECK_EQ(Mode::MUS, mode_); |
| 207 |
| 208 if (client != window_tree_client_) |
| 209 return; |
| 210 |
| 211 in_mus_shutdown_ = true; |
| 212 window_tree_client_ = nullptr; |
| 213 } |
| 214 |
200 //////////////////////////////////////////////////////////////////////////////// | 215 //////////////////////////////////////////////////////////////////////////////// |
201 // Env, ui::EventTarget implementation: | 216 // Env, ui::EventTarget implementation: |
202 | 217 |
203 bool Env::CanAcceptEvent(const ui::Event& event) { | 218 bool Env::CanAcceptEvent(const ui::Event& event) { |
204 return true; | 219 return true; |
205 } | 220 } |
206 | 221 |
207 ui::EventTarget* Env::GetParentTarget() { | 222 ui::EventTarget* Env::GetParentTarget() { |
208 return NULL; | 223 return NULL; |
209 } | 224 } |
210 | 225 |
211 std::unique_ptr<ui::EventTargetIterator> Env::GetChildIterator() const { | 226 std::unique_ptr<ui::EventTargetIterator> Env::GetChildIterator() const { |
212 return nullptr; | 227 return nullptr; |
213 } | 228 } |
214 | 229 |
215 ui::EventTargeter* Env::GetEventTargeter() { | 230 ui::EventTargeter* Env::GetEventTargeter() { |
216 NOTREACHED(); | 231 NOTREACHED(); |
217 return NULL; | 232 return NULL; |
218 } | 233 } |
219 | 234 |
220 std::unique_ptr<ui::OSExchangeData::Provider> Env::BuildProvider() { | 235 std::unique_ptr<ui::OSExchangeData::Provider> Env::BuildProvider() { |
221 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); | 236 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); |
222 } | 237 } |
223 | 238 |
224 } // namespace aura | 239 } // namespace aura |
OLD | NEW |