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

Side by Side Diff: components/mus/public/cpp/lib/window_tree_client_impl.cc

Issue 1423133003: Routes calls to WM through WS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no braces Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/mus/public/cpp/lib/window_tree_client_impl.h" 5 #include "components/mus/public/cpp/lib/window_tree_client_impl.h"
6 6
7 #include "base/bind.h"
7 #include "components/mus/public/cpp/lib/window_private.h" 8 #include "components/mus/public/cpp/lib/window_private.h"
8 #include "components/mus/public/cpp/util.h" 9 #include "components/mus/public/cpp/util.h"
9 #include "components/mus/public/cpp/window_observer.h" 10 #include "components/mus/public/cpp/window_observer.h"
10 #include "components/mus/public/cpp/window_tree_connection.h" 11 #include "components/mus/public/cpp/window_tree_connection.h"
11 #include "components/mus/public/cpp/window_tree_delegate.h" 12 #include "components/mus/public/cpp/window_tree_delegate.h"
12 #include "mojo/application/public/cpp/application_impl.h" 13 #include "mojo/application/public/cpp/application_impl.h"
13 #include "mojo/application/public/cpp/connect.h" 14 #include "mojo/application/public/cpp/connect.h"
14 #include "mojo/application/public/cpp/service_provider_impl.h" 15 #include "mojo/application/public/cpp/service_provider_impl.h"
15 #include "mojo/application/public/interfaces/service_provider.mojom.h" 16 #include "mojo/application/public/interfaces/service_provider.mojom.h"
17 #include "mojo/converters/geometry/geometry_type_converters.h"
18 #include "ui/gfx/geometry/rect.h"
19 #include "ui/gfx/geometry/size.h"
16 20
17 namespace mus { 21 namespace mus {
22 namespace {
23
24 void WindowManagerCallback(mus::mojom::WindowManagerErrorCode error_code) {}
25
26 } // namespace
18 27
19 Id MakeTransportId(ConnectionSpecificId connection_id, 28 Id MakeTransportId(ConnectionSpecificId connection_id,
20 ConnectionSpecificId local_id) { 29 ConnectionSpecificId local_id) {
21 return (connection_id << 16) | local_id; 30 return (connection_id << 16) | local_id;
22 } 31 }
23 32
24 // Helper called to construct a local window object from transport data. 33 // Helper called to construct a local window object from transport data.
25 Window* AddWindowToConnection(WindowTreeClientImpl* client, 34 Window* AddWindowToConnection(WindowTreeClientImpl* client,
26 Window* parent, 35 Window* parent,
27 const mojom::WindowDataPtr& window_data) { 36 const mojom::WindowDataPtr& window_data) {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 240
232 void WindowTreeClientImpl::OnRootDestroyed(Window* root) { 241 void WindowTreeClientImpl::OnRootDestroyed(Window* root) {
233 DCHECK_EQ(root, root_); 242 DCHECK_EQ(root, root_);
234 root_ = nullptr; 243 root_ = nullptr;
235 244
236 // When the root is gone we can't do anything useful. 245 // When the root is gone we can't do anything useful.
237 if (!in_destructor_) 246 if (!in_destructor_)
238 delete this; 247 delete this;
239 } 248 }
240 249
250 void WindowTreeClientImpl::SetPreferredSize(Id window_id,
251 const gfx::Size& size) {
252 tree_->SetPreferredSize(window_id, mojo::Size::From(size),
253 base::Bind(&WindowManagerCallback));
254 }
255
256 void WindowTreeClientImpl::RequestBoundsChange(Id window_id,
257 const gfx::Rect& bounds) {
258 tree_->SetBounds(window_id, mojo::Rect::From(bounds),
259 base::Bind(&WindowManagerCallback));
260 }
261
262 void WindowTreeClientImpl::SetShowState(Id window_id,
263 mojom::ShowState show_state) {
264 tree_->SetShowState(window_id, show_state,
265 base::Bind(&WindowManagerCallback));
266 }
267
241 //////////////////////////////////////////////////////////////////////////////// 268 ////////////////////////////////////////////////////////////////////////////////
242 // WindowTreeClientImpl, WindowTreeConnection implementation: 269 // WindowTreeClientImpl, WindowTreeConnection implementation:
243 270
244 Id WindowTreeClientImpl::CreateWindowOnServer() { 271 Id WindowTreeClientImpl::CreateWindowOnServer() {
245 DCHECK(tree_); 272 DCHECK(tree_);
246 const Id window_id = MakeTransportId(connection_id_, next_id_++); 273 const Id window_id = MakeTransportId(connection_id_, next_id_++);
247 tree_->NewWindow(window_id, [this](mojom::ErrorCode code) { 274 tree_->NewWindow(window_id, [this](mojom::ErrorCode code) {
248 OnActionCompleted(code == mojom::ERROR_CODE_NONE); 275 OnActionCompleted(code == mojom::ERROR_CODE_NONE);
249 }); 276 });
250 return window_id; 277 return window_id;
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 void WindowTreeClientImpl::OnActionCompleted(bool success) { 486 void WindowTreeClientImpl::OnActionCompleted(bool success) {
460 if (!change_acked_callback_.is_null()) 487 if (!change_acked_callback_.is_null())
461 change_acked_callback_.Run(); 488 change_acked_callback_.Run();
462 } 489 }
463 490
464 mojo::Callback<void(bool)> WindowTreeClientImpl::ActionCompletedCallback() { 491 mojo::Callback<void(bool)> WindowTreeClientImpl::ActionCompletedCallback() {
465 return [this](bool success) { OnActionCompleted(success); }; 492 return [this](bool success) { OnActionCompleted(success); };
466 } 493 }
467 494
468 } // namespace mus 495 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/public/cpp/lib/window_tree_client_impl.h ('k') | components/mus/public/cpp/lib/window_tree_host_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698