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/focus_client.h" | 11 #include "ui/aura/client/focus_client.h" |
| 12 #include "ui/aura/env_observer.h" | 12 #include "ui/aura/env_observer.h" |
| 13 #include "ui/aura/input_state_lookup.h" | 13 #include "ui/aura/input_state_lookup.h" |
| 14 #include "ui/aura/mus/window_port_mus.h" | 14 #include "ui/aura/mus/window_port_mus.h" |
| 15 #include "ui/aura/mus/window_tree_client.h" | 15 #include "ui/aura/mus/window_tree_client.h" |
| 16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 17 #include "ui/aura/window_observer.h" | 17 #include "ui/aura/window_observer.h" |
| 18 #include "ui/aura/window_port_local.h" | 18 #include "ui/aura/window_port_local.h" |
| 19 #include "ui/events/event_target_iterator.h" | 19 #include "ui/events/event_target_iterator.h" |
| 20 #include "ui/events/platform/platform_event_source.h" | 20 #include "ui/events/platform/platform_event_source.h" |
| 21 #include "ui/gfx/switches.h" | |
| 21 | 22 |
| 22 #if defined(USE_OZONE) | 23 #if defined(USE_OZONE) |
| 23 #include "ui/ozone/public/ozone_platform.h" | 24 #include "ui/ozone/public/ozone_platform.h" |
| 24 #endif | 25 #endif |
| 25 | 26 |
| 26 namespace aura { | 27 namespace aura { |
| 27 | 28 |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| 30 // Env is thread local so that aura may be used on multiple threads. | 31 // Env is thread local so that aura may be used on multiple threads. |
| 31 base::LazyInstance<base::ThreadLocalPointer<Env> >::Leaky lazy_tls_ptr = | 32 base::LazyInstance<base::ThreadLocalPointer<Env> >::Leaky lazy_tls_ptr = |
| 32 LAZY_INSTANCE_INITIALIZER; | 33 LAZY_INSTANCE_INITIALIZER; |
| 33 | 34 |
| 34 // Returns true if running inside of mus. Checks for mojo specific flag. | 35 // Returns true if running inside of mus. Checks for mojo specific flag. |
| 35 bool RunningInsideMus() { | 36 bool RunningInsideMus() { |
| 36 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 37 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 37 "primordial-pipe-token"); | 38 "primordial-pipe-token"); |
| 38 } | 39 } |
| 39 | 40 |
| 41 bool RunningInHeadlessMode() { | |
| 42 return base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kHeadless); | |
| 43 } | |
| 44 | |
| 40 } // namespace | 45 } // namespace |
| 41 | 46 |
| 42 // Observes destruction and changes of the FocusClient for a window. | 47 // Observes destruction and changes of the FocusClient for a window. |
| 43 // ActiveFocusClientWindowObserver is created for the window the FocusClient is | 48 // ActiveFocusClientWindowObserver is created for the window the FocusClient is |
| 44 // associated with. | 49 // associated with. |
| 45 class Env::ActiveFocusClientWindowObserver : public WindowObserver { | 50 class Env::ActiveFocusClientWindowObserver : public WindowObserver { |
| 46 public: | 51 public: |
| 47 explicit ActiveFocusClientWindowObserver(Window* window) : window_(window) { | 52 explicit ActiveFocusClientWindowObserver(Window* window) : window_(window) { |
| 48 window_->AddObserver(this); | 53 window_->AddObserver(this); |
| 49 } | 54 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 | 168 |
| 164 void Env::Init() { | 169 void Env::Init() { |
| 165 if (RunningInsideMus()) | 170 if (RunningInsideMus()) |
| 166 return; | 171 return; |
| 167 #if defined(USE_OZONE) | 172 #if defined(USE_OZONE) |
| 168 // The ozone platform can provide its own event source. So initialize the | 173 // The ozone platform can provide its own event source. So initialize the |
| 169 // platform before creating the default event source. If running inside mus | 174 // platform before creating the default event source. If running inside mus |
| 170 // let the mus process initialize ozone instead. | 175 // let the mus process initialize ozone instead. |
| 171 ui::OzonePlatform::InitializeForUI(); | 176 ui::OzonePlatform::InitializeForUI(); |
| 172 #endif | 177 #endif |
| 178 if (RunningInHeadlessMode()) | |
|
sky
2016/12/06 14:27:31
Would it make more sense for a headless PlatformEv
Sami
2016/12/07 11:51:26
Great idea! Done.
| |
| 179 return; | |
| 173 if (!ui::PlatformEventSource::GetInstance()) | 180 if (!ui::PlatformEventSource::GetInstance()) |
| 174 event_source_ = ui::PlatformEventSource::CreateDefault(); | 181 event_source_ = ui::PlatformEventSource::CreateDefault(); |
| 175 } | 182 } |
| 176 | 183 |
| 177 void Env::NotifyWindowInitialized(Window* window) { | 184 void Env::NotifyWindowInitialized(Window* window) { |
| 178 for (EnvObserver& observer : observers_) | 185 for (EnvObserver& observer : observers_) |
| 179 observer.OnWindowInitialized(window); | 186 observer.OnWindowInitialized(window); |
| 180 } | 187 } |
| 181 | 188 |
| 182 void Env::NotifyHostInitialized(WindowTreeHost* host) { | 189 void Env::NotifyHostInitialized(WindowTreeHost* host) { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 207 std::unique_ptr<ui::EventTargetIterator> Env::GetChildIterator() const { | 214 std::unique_ptr<ui::EventTargetIterator> Env::GetChildIterator() const { |
| 208 return nullptr; | 215 return nullptr; |
| 209 } | 216 } |
| 210 | 217 |
| 211 ui::EventTargeter* Env::GetEventTargeter() { | 218 ui::EventTargeter* Env::GetEventTargeter() { |
| 212 NOTREACHED(); | 219 NOTREACHED(); |
| 213 return NULL; | 220 return NULL; |
| 214 } | 221 } |
| 215 | 222 |
| 216 } // namespace aura | 223 } // namespace aura |
| OLD | NEW |