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

Side by Side Diff: ui/views/mus/mus_client.cc

Issue 2578893003: Converts chrome to aura-mus (Closed)
Patch Set: merge again Created 4 years 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
« chrome/app/chrome_main.cc ('K') | « ui/views/mus/mus_client.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/views/mus/mus_client.h" 5 #include "ui/views/mus/mus_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "services/service_manager/public/cpp/connection.h" 9 #include "services/service_manager/public/cpp/connection.h"
10 #include "services/service_manager/public/cpp/connector.h" 10 #include "services/service_manager/public/cpp/connector.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 WINDOW_TYPES_MATCH(BUBBLE); 48 WINDOW_TYPES_MATCH(BUBBLE);
49 WINDOW_TYPES_MATCH(DRAG); 49 WINDOW_TYPES_MATCH(DRAG);
50 // ui::mojom::WindowType::UNKNOWN does not correspond to a value in 50 // ui::mojom::WindowType::UNKNOWN does not correspond to a value in
51 // Widget::InitParams::Type. 51 // Widget::InitParams::Type.
52 52
53 namespace views { 53 namespace views {
54 54
55 // static 55 // static
56 MusClient* MusClient::instance_ = nullptr; 56 MusClient* MusClient::instance_ = nullptr;
57 57
58 MusClient::MusClient(service_manager::Connector* connector,
59 const service_manager::Identity& identity,
60 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
61 bool create_wm_state)
62 : identity_(identity) {
63 DCHECK(!instance_);
64 instance_ = this;
65 // TODO(msw): Avoid this... use some default value? Allow clients to extend?
66 property_converter_ = base::MakeUnique<aura::PropertyConverter>();
67
68 if (create_wm_state)
69 wm_state_ = base::MakeUnique<wm::WMState>();
70
71 gpu_ = ui::Gpu::Create(connector, std::move(io_task_runner));
72 compositor_context_factory_ =
73 base::MakeUnique<aura::MusContextFactory>(gpu_.get());
74 aura::Env::GetInstance()->set_context_factory(
75 compositor_context_factory_.get());
76 window_tree_client_ =
77 base::MakeUnique<aura::WindowTreeClient>(connector, this);
78 aura::Env::GetInstance()->SetWindowTreeClient(window_tree_client_.get());
79 window_tree_client_->ConnectViaWindowTreeFactory();
80
81 pointer_watcher_event_router_ =
82 base::MakeUnique<PointerWatcherEventRouter2>(window_tree_client_.get());
83
84 screen_ = base::MakeUnique<ScreenMus>(this);
85 screen_->Init(connector);
86
87 std::unique_ptr<ClipboardMus> clipboard = base::MakeUnique<ClipboardMus>();
88 clipboard->Init(connector);
89 ui::Clipboard::SetClipboardForCurrentThread(std::move(clipboard));
90
91 ui::OSExchangeDataProviderFactory::SetFactory(this);
92
93 ViewsDelegate::GetInstance()->set_native_widget_factory(
94 base::Bind(&MusClient::CreateNativeWidget, base::Unretained(this)));
95 }
96
58 MusClient::~MusClient() { 97 MusClient::~MusClient() {
59 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while 98 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while
60 // we are still valid. 99 // we are still valid.
61 window_tree_client_.reset(); 100 window_tree_client_.reset();
62 ui::OSExchangeDataProviderFactory::SetFactory(nullptr); 101 ui::OSExchangeDataProviderFactory::SetFactory(nullptr);
63 ui::Clipboard::DestroyClipboardForCurrentThread(); 102 ui::Clipboard::DestroyClipboardForCurrentThread();
64 gpu_.reset(); 103 gpu_.reset();
65 104
66 if (ViewsDelegate::GetInstance()) { 105 if (ViewsDelegate::GetInstance()) {
67 ViewsDelegate::GetInstance()->set_native_widget_factory( 106 ViewsDelegate::GetInstance()->set_native_widget_factory(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 200 }
162 201
163 void MusClient::AddObserver(MusClientObserver* observer) { 202 void MusClient::AddObserver(MusClientObserver* observer) {
164 observer_list_.AddObserver(observer); 203 observer_list_.AddObserver(observer);
165 } 204 }
166 205
167 void MusClient::RemoveObserver(MusClientObserver* observer) { 206 void MusClient::RemoveObserver(MusClientObserver* observer) {
168 observer_list_.RemoveObserver(observer); 207 observer_list_.RemoveObserver(observer);
169 } 208 }
170 209
171 MusClient::MusClient(service_manager::Connector* connector,
172 const service_manager::Identity& identity,
173 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner)
174 : identity_(identity) {
175 DCHECK(!instance_);
176 instance_ = this;
177 // TODO(msw): Avoid this... use some default value? Allow clients to extend?
178 property_converter_ = base::MakeUnique<aura::PropertyConverter>();
179
180 wm_state_ = base::MakeUnique<wm::WMState>();
181
182 gpu_ = ui::Gpu::Create(connector, std::move(io_task_runner));
183 compositor_context_factory_ =
184 base::MakeUnique<aura::MusContextFactory>(gpu_.get());
185 aura::Env::GetInstance()->set_context_factory(
186 compositor_context_factory_.get());
187 window_tree_client_ =
188 base::MakeUnique<aura::WindowTreeClient>(connector, this);
189 aura::Env::GetInstance()->SetWindowTreeClient(window_tree_client_.get());
190 window_tree_client_->ConnectViaWindowTreeFactory();
191
192 pointer_watcher_event_router_ =
193 base::MakeUnique<PointerWatcherEventRouter2>(window_tree_client_.get());
194
195 screen_ = base::MakeUnique<ScreenMus>(this);
196 screen_->Init(connector);
197
198 std::unique_ptr<ClipboardMus> clipboard = base::MakeUnique<ClipboardMus>();
199 clipboard->Init(connector);
200 ui::Clipboard::SetClipboardForCurrentThread(std::move(clipboard));
201
202 ui::OSExchangeDataProviderFactory::SetFactory(this);
203
204 ViewsDelegate::GetInstance()->set_native_widget_factory(
205 base::Bind(&MusClient::CreateNativeWidget, base::Unretained(this)));
206 }
207
208 void MusClient::OnEmbed( 210 void MusClient::OnEmbed(
209 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { 211 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) {
210 NOTREACHED(); 212 NOTREACHED();
211 } 213 }
212 214
213 void MusClient::OnLostConnection(aura::WindowTreeClient* client) {} 215 void MusClient::OnLostConnection(aura::WindowTreeClient* client) {}
214 216
215 void MusClient::OnEmbedRootDestroyed( 217 void MusClient::OnEmbedRootDestroyed(
216 aura::WindowTreeHostMus* window_tree_host) { 218 aura::WindowTreeHostMus* window_tree_host) {
217 static_cast<DesktopWindowTreeHostMus*>(window_tree_host) 219 static_cast<DesktopWindowTreeHostMus*>(window_tree_host)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 return root->GetTopWindowContainingPoint(relative_point); 254 return root->GetTopWindowContainingPoint(relative_point);
253 } 255 }
254 return nullptr; 256 return nullptr;
255 } 257 }
256 258
257 std::unique_ptr<OSExchangeData::Provider> MusClient::BuildProvider() { 259 std::unique_ptr<OSExchangeData::Provider> MusClient::BuildProvider() {
258 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); 260 return base::MakeUnique<aura::OSExchangeDataProviderMus>();
259 } 261 }
260 262
261 } // namespace views 263 } // namespace views
OLDNEW
« chrome/app/chrome_main.cc ('K') | « ui/views/mus/mus_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698