Chromium Code Reviews| 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/client/focus_client.h" | 12 #include "ui/aura/client/focus_client.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/mus/mus_types.h" | 15 #include "ui/aura/mus/mus_types.h" |
| 16 #include "ui/aura/mus/os_exchange_data_provider_mus.h" | 16 #include "ui/aura/mus/os_exchange_data_provider_mus.h" |
| 17 #include "ui/aura/mus/window_port_mus.h" | 17 #include "ui/aura/mus/window_port_mus.h" |
| 18 #include "ui/aura/mus/window_tree_client.h" | 18 #include "ui/aura/mus/window_tree_client.h" |
| 19 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
| 20 #include "ui/aura/window_observer.h" | 20 #include "ui/aura/window_observer.h" |
| 21 #include "ui/aura/window_port_local.h" | 21 #include "ui/aura/window_port_local.h" |
| 22 #include "ui/events/event_target_iterator.h" | 22 #include "ui/events/event_target_iterator.h" |
| 23 #include "ui/events/platform/platform_event_source.h" | 23 #include "ui/events/platform/platform_event_source.h" |
| 24 | 24 |
| 25 #if defined(USE_OZONE) | 25 #if defined(USE_OZONE) |
| 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 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 // Env is thread local so that aura may be used on multiple threads. | 34 // Env is thread local so that aura may be used on multiple threads. |
| 34 base::LazyInstance<base::ThreadLocalPointer<Env>>::Leaky lazy_tls_ptr = | 35 base::LazyInstance<base::ThreadLocalPointer<Env>>::Leaky lazy_tls_ptr = |
| 35 LAZY_INSTANCE_INITIALIZER; | 36 LAZY_INSTANCE_INITIALIZER; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 | 183 |
| 183 //////////////////////////////////////////////////////////////////////////////// | 184 //////////////////////////////////////////////////////////////////////////////// |
| 184 // Env, private: | 185 // Env, private: |
| 185 | 186 |
| 186 Env::Env(Mode mode) | 187 Env::Env(Mode mode) |
| 187 : mode_(mode), | 188 : mode_(mode), |
| 188 mouse_button_flags_(0), | 189 mouse_button_flags_(0), |
| 189 is_touch_down_(false), | 190 is_touch_down_(false), |
| 190 get_last_mouse_location_from_mus_(mode_ == Mode::MUS), | 191 get_last_mouse_location_from_mus_(mode_ == Mode::MUS), |
| 191 input_state_lookup_(InputStateLookup::Create()), | 192 input_state_lookup_(InputStateLookup::Create()), |
| 193 #if defined(USE_OZONE) | |
| 194 native_pixmap_factory_(ui::CreateClientNativePixmapFactoryOzone()), | |
| 195 #endif | |
| 192 context_factory_(nullptr), | 196 context_factory_(nullptr), |
| 193 context_factory_private_(nullptr) { | 197 context_factory_private_(nullptr) { |
| 194 DCHECK(lazy_tls_ptr.Pointer()->Get() == NULL); | 198 DCHECK(lazy_tls_ptr.Pointer()->Get() == NULL); |
| 195 lazy_tls_ptr.Pointer()->Set(this); | 199 lazy_tls_ptr.Pointer()->Set(this); |
| 196 } | 200 } |
| 197 | 201 |
| 198 void Env::Init() { | 202 void Env::Init() { |
|
sky
2017/04/07 23:23:19
Be aware that some tests reset the mode after the
rjkroege
2017/04/10 16:21:42
I don't understand what you mean. They do this by
| |
| 199 if (RunningInsideMus()) { | 203 if (RunningInsideMus()) { |
| 200 EnableMusOSExchangeDataProvider(); | 204 EnableMusOSExchangeDataProvider(); |
| 205 #if defined(USE_OZONE) | |
| 206 // Required by all Aura-using clients of services/ui | |
| 207 gfx::ClientNativePixmapFactory::SetInstance(native_pixmap_factory_.get()); | |
| 208 #endif | |
| 201 return; | 209 return; |
| 202 } | 210 } |
| 203 | 211 |
| 204 #if defined(USE_OZONE) | 212 #if defined(USE_OZONE) |
| 205 // The ozone platform can provide its own event source. So initialize the | 213 // The ozone platform can provide its own event source. So initialize the |
| 206 // platform before creating the default event source. If running inside mus | 214 // platform before creating the default event source. If running inside mus |
| 207 // let the mus process initialize ozone instead. | 215 // let the mus process initialize ozone instead. |
| 208 ui::OzonePlatform::InitializeForUI(); | 216 ui::OzonePlatform::InitializeForUI(); |
| 217 gfx::ClientNativePixmapFactory::SetInstance(native_pixmap_factory_.get()); | |
|
sky
2017/04/07 23:23:20
SetInstance(null) in the destructor?
rjkroege
2017/04/10 16:21:42
Done.
| |
| 209 #endif | 218 #endif |
| 210 if (!ui::PlatformEventSource::GetInstance()) | 219 if (!ui::PlatformEventSource::GetInstance()) |
| 211 event_source_ = ui::PlatformEventSource::CreateDefault(); | 220 event_source_ = ui::PlatformEventSource::CreateDefault(); |
| 212 } | 221 } |
| 213 | 222 |
| 214 void Env::EnableMusOSExchangeDataProvider() { | 223 void Env::EnableMusOSExchangeDataProvider() { |
| 215 if (!is_os_exchange_data_provider_factory_) { | 224 if (!is_os_exchange_data_provider_factory_) { |
| 216 ui::OSExchangeDataProviderFactory::SetFactory(this); | 225 ui::OSExchangeDataProviderFactory::SetFactory(this); |
| 217 is_os_exchange_data_provider_factory_ = true; | 226 is_os_exchange_data_provider_factory_ = true; |
| 218 } | 227 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 ui::EventTargeter* Env::GetEventTargeter() { | 264 ui::EventTargeter* Env::GetEventTargeter() { |
| 256 NOTREACHED(); | 265 NOTREACHED(); |
| 257 return NULL; | 266 return NULL; |
| 258 } | 267 } |
| 259 | 268 |
| 260 std::unique_ptr<ui::OSExchangeData::Provider> Env::BuildProvider() { | 269 std::unique_ptr<ui::OSExchangeData::Provider> Env::BuildProvider() { |
| 261 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); | 270 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); |
| 262 } | 271 } |
| 263 | 272 |
| 264 } // namespace aura | 273 } // namespace aura |
| OLD | NEW |