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/window_port_mus.h" | 17 #include "ui/aura/mus/window_port_mus.h" |
17 #include "ui/aura/mus/window_tree_client.h" | 18 #include "ui/aura/mus/window_tree_client.h" |
18 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
19 #include "ui/aura/window_observer.h" | 20 #include "ui/aura/window_observer.h" |
20 #include "ui/aura/window_port_local.h" | 21 #include "ui/aura/window_port_local.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/ozone_platform.h" | 26 #include "ui/ozone/public/ozone_platform.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 private: | 69 private: |
69 Window* window_; | 70 Window* window_; |
70 | 71 |
71 DISALLOW_COPY_AND_ASSIGN(ActiveFocusClientWindowObserver); | 72 DISALLOW_COPY_AND_ASSIGN(ActiveFocusClientWindowObserver); |
72 }; | 73 }; |
73 | 74 |
74 //////////////////////////////////////////////////////////////////////////////// | 75 //////////////////////////////////////////////////////////////////////////////// |
75 // Env, public: | 76 // Env, public: |
76 | 77 |
77 Env::~Env() { | 78 Env::~Env() { |
| 79 if (RunningInsideMus()) |
| 80 ui::OSExchangeDataProviderFactory::SetFactory(nullptr); |
| 81 |
78 for (EnvObserver& observer : observers_) | 82 for (EnvObserver& observer : observers_) |
79 observer.OnWillDestroyEnv(); | 83 observer.OnWillDestroyEnv(); |
80 DCHECK_EQ(this, lazy_tls_ptr.Pointer()->Get()); | 84 DCHECK_EQ(this, lazy_tls_ptr.Pointer()->Get()); |
81 lazy_tls_ptr.Pointer()->Set(NULL); | 85 lazy_tls_ptr.Pointer()->Set(NULL); |
82 } | 86 } |
83 | 87 |
84 // static | 88 // static |
85 std::unique_ptr<Env> Env::CreateInstance(Mode mode) { | 89 std::unique_ptr<Env> Env::CreateInstance(Mode mode) { |
86 DCHECK(!lazy_tls_ptr.Pointer()->Get()); | 90 DCHECK(!lazy_tls_ptr.Pointer()->Get()); |
87 std::unique_ptr<Env> env(new Env(mode)); | 91 std::unique_ptr<Env> env(new Env(mode)); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 is_touch_down_(false), | 189 is_touch_down_(false), |
186 get_last_mouse_location_from_mus_(mode_ == Mode::MUS), | 190 get_last_mouse_location_from_mus_(mode_ == Mode::MUS), |
187 input_state_lookup_(InputStateLookup::Create()), | 191 input_state_lookup_(InputStateLookup::Create()), |
188 context_factory_(nullptr), | 192 context_factory_(nullptr), |
189 context_factory_private_(nullptr) { | 193 context_factory_private_(nullptr) { |
190 DCHECK(lazy_tls_ptr.Pointer()->Get() == NULL); | 194 DCHECK(lazy_tls_ptr.Pointer()->Get() == NULL); |
191 lazy_tls_ptr.Pointer()->Set(this); | 195 lazy_tls_ptr.Pointer()->Set(this); |
192 } | 196 } |
193 | 197 |
194 void Env::Init() { | 198 void Env::Init() { |
195 if (RunningInsideMus()) | 199 if (RunningInsideMus()) { |
| 200 ui::OSExchangeDataProviderFactory::SetFactory(this); |
196 return; | 201 return; |
| 202 } |
| 203 |
197 #if defined(USE_OZONE) | 204 #if defined(USE_OZONE) |
198 // The ozone platform can provide its own event source. So initialize the | 205 // The ozone platform can provide its own event source. So initialize the |
199 // platform before creating the default event source. If running inside mus | 206 // platform before creating the default event source. If running inside mus |
200 // let the mus process initialize ozone instead. | 207 // let the mus process initialize ozone instead. |
201 ui::OzonePlatform::InitializeForUI(); | 208 ui::OzonePlatform::InitializeForUI(); |
202 #endif | 209 #endif |
203 if (!ui::PlatformEventSource::GetInstance()) | 210 if (!ui::PlatformEventSource::GetInstance()) |
204 event_source_ = ui::PlatformEventSource::CreateDefault(); | 211 event_source_ = ui::PlatformEventSource::CreateDefault(); |
205 } | 212 } |
206 | 213 |
(...skipping 29 matching lines...) Expand all Loading... |
236 | 243 |
237 std::unique_ptr<ui::EventTargetIterator> Env::GetChildIterator() const { | 244 std::unique_ptr<ui::EventTargetIterator> Env::GetChildIterator() const { |
238 return nullptr; | 245 return nullptr; |
239 } | 246 } |
240 | 247 |
241 ui::EventTargeter* Env::GetEventTargeter() { | 248 ui::EventTargeter* Env::GetEventTargeter() { |
242 NOTREACHED(); | 249 NOTREACHED(); |
243 return NULL; | 250 return NULL; |
244 } | 251 } |
245 | 252 |
| 253 std::unique_ptr<ui::OSExchangeData::Provider> Env::BuildProvider() { |
| 254 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); |
| 255 } |
| 256 |
246 } // namespace aura | 257 } // namespace aura |
OLD | NEW |