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

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

Issue 2446893005: Adds a porting layer so aura can be made to work with mus (Closed)
Patch Set: better Created 4 years, 1 month 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
« no previous file with comments | « ui/aura/env.h ('k') | ui/aura/window.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/threading/thread_local.h" 10 #include "base/threading/thread_local.h"
10 #include "ui/aura/env_observer.h" 11 #include "ui/aura/env_observer.h"
11 #include "ui/aura/input_state_lookup.h" 12 #include "ui/aura/input_state_lookup.h"
13 #include "ui/aura/window_port_local.h"
12 #include "ui/events/event_target_iterator.h" 14 #include "ui/events/event_target_iterator.h"
13 #include "ui/events/platform/platform_event_source.h" 15 #include "ui/events/platform/platform_event_source.h"
14 16
15 #if defined(USE_OZONE) 17 #if defined(USE_OZONE)
16 #include "ui/ozone/public/ozone_platform.h" 18 #include "ui/ozone/public/ozone_platform.h"
17 #endif 19 #endif
18 20
19 namespace aura { 21 namespace aura {
20 22
21 namespace { 23 namespace {
(...skipping 14 matching lines...) Expand all
36 // Env, public: 38 // Env, public:
37 39
38 Env::~Env() { 40 Env::~Env() {
39 for (EnvObserver& observer : observers_) 41 for (EnvObserver& observer : observers_)
40 observer.OnWillDestroyEnv(); 42 observer.OnWillDestroyEnv();
41 DCHECK_EQ(this, lazy_tls_ptr.Pointer()->Get()); 43 DCHECK_EQ(this, lazy_tls_ptr.Pointer()->Get());
42 lazy_tls_ptr.Pointer()->Set(NULL); 44 lazy_tls_ptr.Pointer()->Set(NULL);
43 } 45 }
44 46
45 // static 47 // static
46 std::unique_ptr<Env> Env::CreateInstance() { 48 std::unique_ptr<Env> Env::CreateInstance(
49 const WindowPortFactory& window_port_factory) {
47 DCHECK(!lazy_tls_ptr.Pointer()->Get()); 50 DCHECK(!lazy_tls_ptr.Pointer()->Get());
48 std::unique_ptr<Env> env(new Env()); 51 std::unique_ptr<Env> env(new Env(window_port_factory));
49 env->Init(); 52 env->Init();
50 return env; 53 return env;
51 } 54 }
52 55
53 // static 56 // static
54 Env* Env::GetInstance() { 57 Env* Env::GetInstance() {
55 Env* env = lazy_tls_ptr.Pointer()->Get(); 58 Env* env = lazy_tls_ptr.Pointer()->Get();
56 DCHECK(env) << "Env::CreateInstance must be called before getting the " 59 DCHECK(env) << "Env::CreateInstance must be called before getting the "
57 "instance of Env."; 60 "instance of Env.";
58 return env; 61 return env;
59 } 62 }
60 63
61 // static 64 // static
62 Env* Env::GetInstanceDontCreate() { 65 Env* Env::GetInstanceDontCreate() {
63 return lazy_tls_ptr.Pointer()->Get(); 66 return lazy_tls_ptr.Pointer()->Get();
64 } 67 }
65 68
69 std::unique_ptr<WindowPort> Env::CreateWindowPort(Window* window) {
70 if (window_port_factory_.is_null())
71 return base::MakeUnique<WindowPortLocal>(window);
72 return window_port_factory_.Run(window);
73 }
74
66 void Env::AddObserver(EnvObserver* observer) { 75 void Env::AddObserver(EnvObserver* observer) {
67 observers_.AddObserver(observer); 76 observers_.AddObserver(observer);
68 } 77 }
69 78
70 void Env::RemoveObserver(EnvObserver* observer) { 79 void Env::RemoveObserver(EnvObserver* observer) {
71 observers_.RemoveObserver(observer); 80 observers_.RemoveObserver(observer);
72 } 81 }
73 82
74 bool Env::IsMouseButtonDown() const { 83 bool Env::IsMouseButtonDown() const {
75 return input_state_lookup_.get() ? input_state_lookup_->IsMouseButtonDown() : 84 return input_state_lookup_.get() ? input_state_lookup_->IsMouseButtonDown() :
76 mouse_button_flags_ != 0; 85 mouse_button_flags_ != 0;
77 } 86 }
78 87
79 //////////////////////////////////////////////////////////////////////////////// 88 ////////////////////////////////////////////////////////////////////////////////
80 // Env, private: 89 // Env, private:
81 90
82 Env::Env() 91 Env::Env(const WindowPortFactory& window_port_factory)
83 : mouse_button_flags_(0), 92 : window_port_factory_(window_port_factory),
93 mouse_button_flags_(0),
84 is_touch_down_(false), 94 is_touch_down_(false),
85 input_state_lookup_(InputStateLookup::Create()), 95 input_state_lookup_(InputStateLookup::Create()),
86 context_factory_(NULL) { 96 context_factory_(NULL) {
87 DCHECK(lazy_tls_ptr.Pointer()->Get() == NULL); 97 DCHECK(lazy_tls_ptr.Pointer()->Get() == NULL);
88 lazy_tls_ptr.Pointer()->Set(this); 98 lazy_tls_ptr.Pointer()->Set(this);
89 } 99 }
90 100
91 void Env::Init() { 101 void Env::Init() {
92 if (RunningInsideMus()) 102 if (RunningInsideMus())
93 return; 103 return;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 std::unique_ptr<ui::EventTargetIterator> Env::GetChildIterator() const { 140 std::unique_ptr<ui::EventTargetIterator> Env::GetChildIterator() const {
131 return nullptr; 141 return nullptr;
132 } 142 }
133 143
134 ui::EventTargeter* Env::GetEventTargeter() { 144 ui::EventTargeter* Env::GetEventTargeter() {
135 NOTREACHED(); 145 NOTREACHED();
136 return NULL; 146 return NULL;
137 } 147 }
138 148
139 } // namespace aura 149 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/env.h ('k') | ui/aura/window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698