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

Side by Side Diff: ui/aura/env.cc

Issue 2807833002: [views-mus] Prevent creating a native OzonePlatform in mus tests. (Closed)
Patch Set: sky comments Created 3 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
OLDNEW
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"
(...skipping 14 matching lines...) Expand all
25 #endif 25 #endif
26 26
27 namespace aura { 27 namespace aura {
28 28
29 namespace { 29 namespace {
30 30
31 // 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.
32 base::LazyInstance<base::ThreadLocalPointer<Env>>::Leaky lazy_tls_ptr = 32 base::LazyInstance<base::ThreadLocalPointer<Env>>::Leaky lazy_tls_ptr =
33 LAZY_INSTANCE_INITIALIZER; 33 LAZY_INSTANCE_INITIALIZER;
34 34
35 // Returns true if running inside of mus. Checks for mojo specific flag.
36 bool RunningInsideMus() {
37 return base::CommandLine::ForCurrentProcess()->HasSwitch(
38 "primordial-pipe-token");
39 }
40
41 } // namespace 35 } // namespace
42 36
43 //////////////////////////////////////////////////////////////////////////////// 37 ////////////////////////////////////////////////////////////////////////////////
44 // Env, public: 38 // Env, public:
45 39
46 Env::~Env() { 40 Env::~Env() {
47 if (is_os_exchange_data_provider_factory_) 41 if (is_os_exchange_data_provider_factory_)
48 ui::OSExchangeDataProviderFactory::SetFactory(nullptr); 42 ui::OSExchangeDataProviderFactory::SetFactory(nullptr);
49 43
50 for (EnvObserver& observer : observers_) 44 for (EnvObserver& observer : observers_)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 is_touch_down_(false), 138 is_touch_down_(false),
145 get_last_mouse_location_from_mus_(mode_ == Mode::MUS), 139 get_last_mouse_location_from_mus_(mode_ == Mode::MUS),
146 input_state_lookup_(InputStateLookup::Create()), 140 input_state_lookup_(InputStateLookup::Create()),
147 context_factory_(nullptr), 141 context_factory_(nullptr),
148 context_factory_private_(nullptr) { 142 context_factory_private_(nullptr) {
149 DCHECK(lazy_tls_ptr.Pointer()->Get() == NULL); 143 DCHECK(lazy_tls_ptr.Pointer()->Get() == NULL);
150 lazy_tls_ptr.Pointer()->Set(this); 144 lazy_tls_ptr.Pointer()->Set(this);
151 } 145 }
152 146
153 void Env::Init() { 147 void Env::Init() {
154 if (RunningInsideMus()) { 148 if (mode_ == Mode::MUS) {
155 EnableMusOSExchangeDataProvider(); 149 EnableMusOSExchangeDataProvider();
156 return; 150 return;
157 } 151 }
158 152
159 #if defined(USE_OZONE) 153 #if defined(USE_OZONE)
160 // The ozone platform can provide its own event source. So initialize the 154 // The ozone platform can provide its own event source. So initialize the
161 // platform before creating the default event source. If running inside mus 155 // platform before creating the default event source. If running inside mus
162 // let the mus process initialize ozone instead. 156 // let the mus process initialize ozone instead.
163 ui::OzonePlatform::InitializeForUI(); 157 ui::OzonePlatform::InitializeForUI();
164 #endif 158 #endif
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 ui::EventTargeter* Env::GetEventTargeter() { 200 ui::EventTargeter* Env::GetEventTargeter() {
207 NOTREACHED(); 201 NOTREACHED();
208 return NULL; 202 return NULL;
209 } 203 }
210 204
211 std::unique_ptr<ui::OSExchangeData::Provider> Env::BuildProvider() { 205 std::unique_ptr<ui::OSExchangeData::Provider> Env::BuildProvider() {
212 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); 206 return base::MakeUnique<aura::OSExchangeDataProviderMus>();
213 } 207 }
214 208
215 } // namespace aura 209 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698