| OLD | NEW |
| 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 "base/bind.h" |
| 8 #include "components/mus/common/util.h" | 8 #include "components/mus/common/util.h" |
| 9 #include "components/mus/public/cpp/lib/in_flight_change.h" | 9 #include "components/mus/public/cpp/lib/in_flight_change.h" |
| 10 #include "components/mus/public/cpp/lib/window_private.h" | 10 #include "components/mus/public/cpp/lib/window_private.h" |
| 11 #include "components/mus/public/cpp/window_manager_delegate.h" | 11 #include "components/mus/public/cpp/window_manager_delegate.h" |
| 12 #include "components/mus/public/cpp/window_observer.h" | 12 #include "components/mus/public/cpp/window_observer.h" |
| 13 #include "components/mus/public/cpp/window_tree_connection.h" | 13 #include "components/mus/public/cpp/window_tree_connection.h" |
| 14 #include "components/mus/public/cpp/window_tree_connection_observer.h" |
| 14 #include "components/mus/public/cpp/window_tree_delegate.h" | 15 #include "components/mus/public/cpp/window_tree_delegate.h" |
| 15 #include "mojo/application/public/cpp/application_impl.h" | 16 #include "mojo/application/public/cpp/application_impl.h" |
| 16 #include "mojo/application/public/cpp/connect.h" | 17 #include "mojo/application/public/cpp/connect.h" |
| 17 #include "mojo/application/public/cpp/service_provider_impl.h" | 18 #include "mojo/application/public/cpp/service_provider_impl.h" |
| 18 #include "mojo/application/public/interfaces/service_provider.mojom.h" | 19 #include "mojo/application/public/interfaces/service_provider.mojom.h" |
| 19 #include "mojo/converters/geometry/geometry_type_converters.h" | 20 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 20 #include "ui/gfx/geometry/insets.h" | 21 #include "ui/gfx/geometry/insets.h" |
| 21 #include "ui/gfx/geometry/size.h" | 22 #include "ui/gfx/geometry/size.h" |
| 22 | 23 |
| 23 namespace mus { | 24 namespace mus { |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 connection_id_ = connection_id; | 347 connection_id_ = connection_id; |
| 347 is_embed_root_ = | 348 is_embed_root_ = |
| 348 (access_policy & mojom::WindowTree::ACCESS_POLICY_EMBED_ROOT) != 0; | 349 (access_policy & mojom::WindowTree::ACCESS_POLICY_EMBED_ROOT) != 0; |
| 349 | 350 |
| 350 DCHECK(!root_); | 351 DCHECK(!root_); |
| 351 root_ = AddWindowToConnection(this, nullptr, root_data); | 352 root_ = AddWindowToConnection(this, nullptr, root_data); |
| 352 | 353 |
| 353 focused_window_ = GetWindowById(focused_window_id); | 354 focused_window_ = GetWindowById(focused_window_id); |
| 354 | 355 |
| 355 delegate_->OnEmbed(root_); | 356 delegate_->OnEmbed(root_); |
| 357 |
| 358 if (focused_window_) { |
| 359 FOR_EACH_OBSERVER(WindowTreeConnectionObserver, observers_, |
| 360 OnWindowTreeFocusChanged(focused_window_, nullptr)); |
| 361 } |
| 356 } | 362 } |
| 357 | 363 |
| 358 //////////////////////////////////////////////////////////////////////////////// | 364 //////////////////////////////////////////////////////////////////////////////// |
| 359 // WindowTreeClientImpl, WindowTreeConnection implementation: | 365 // WindowTreeClientImpl, WindowTreeConnection implementation: |
| 360 | 366 |
| 361 Window* WindowTreeClientImpl::GetRoot() { | 367 Window* WindowTreeClientImpl::GetRoot() { |
| 362 return root_; | 368 return root_; |
| 363 } | 369 } |
| 364 | 370 |
| 365 Window* WindowTreeClientImpl::GetWindowById(Id id) { | 371 Window* WindowTreeClientImpl::GetWindowById(Id id) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 395 return is_embed_root_; | 401 return is_embed_root_; |
| 396 } | 402 } |
| 397 | 403 |
| 398 ConnectionSpecificId WindowTreeClientImpl::GetConnectionId() { | 404 ConnectionSpecificId WindowTreeClientImpl::GetConnectionId() { |
| 399 return connection_id_; | 405 return connection_id_; |
| 400 } | 406 } |
| 401 | 407 |
| 402 //////////////////////////////////////////////////////////////////////////////// | 408 //////////////////////////////////////////////////////////////////////////////// |
| 403 // WindowTreeClientImpl, WindowTreeClient implementation: | 409 // WindowTreeClientImpl, WindowTreeClient implementation: |
| 404 | 410 |
| 411 void WindowTreeClientImpl::AddObserver(WindowTreeConnectionObserver* observer) { |
| 412 observers_.AddObserver(observer); |
| 413 } |
| 414 |
| 415 void WindowTreeClientImpl::RemoveObserver( |
| 416 WindowTreeConnectionObserver* observer) { |
| 417 observers_.RemoveObserver(observer); |
| 418 } |
| 419 |
| 405 void WindowTreeClientImpl::OnEmbed(ConnectionSpecificId connection_id, | 420 void WindowTreeClientImpl::OnEmbed(ConnectionSpecificId connection_id, |
| 406 mojom::WindowDataPtr root_data, | 421 mojom::WindowDataPtr root_data, |
| 407 mojom::WindowTreePtr tree, | 422 mojom::WindowTreePtr tree, |
| 408 Id focused_window_id, | 423 Id focused_window_id, |
| 409 uint32 access_policy) { | 424 uint32 access_policy) { |
| 410 DCHECK(!tree_ptr_); | 425 DCHECK(!tree_ptr_); |
| 411 tree_ptr_ = tree.Pass(); | 426 tree_ptr_ = tree.Pass(); |
| 412 tree_ptr_.set_connection_error_handler([this]() { delete this; }); | 427 tree_ptr_.set_connection_error_handler([this]() { delete this; }); |
| 413 OnEmbedImpl(tree_ptr_.get(), connection_id, root_data.Pass(), | 428 OnEmbedImpl(tree_ptr_.get(), connection_id, root_data.Pass(), |
| 414 focused_window_id, access_policy); | 429 focused_window_id, access_policy); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 // |WindowTreeConnection::GetFocusedWindow()| etc. | 603 // |WindowTreeConnection::GetFocusedWindow()| etc. |
| 589 focused_window_ = focused; | 604 focused_window_ = focused; |
| 590 if (blurred) { | 605 if (blurred) { |
| 591 FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(blurred).observers(), | 606 FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(blurred).observers(), |
| 592 OnWindowFocusChanged(focused, blurred)); | 607 OnWindowFocusChanged(focused, blurred)); |
| 593 } | 608 } |
| 594 if (focused) { | 609 if (focused) { |
| 595 FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(focused).observers(), | 610 FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(focused).observers(), |
| 596 OnWindowFocusChanged(focused, blurred)); | 611 OnWindowFocusChanged(focused, blurred)); |
| 597 } | 612 } |
| 613 FOR_EACH_OBSERVER(WindowTreeConnectionObserver, observers_, |
| 614 OnWindowTreeFocusChanged(focused, blurred)); |
| 598 } | 615 } |
| 599 | 616 |
| 600 void WindowTreeClientImpl::OnChangeCompleted(uint32 change_id, bool success) { | 617 void WindowTreeClientImpl::OnChangeCompleted(uint32 change_id, bool success) { |
| 601 scoped_ptr<InFlightChange> change(std::move(in_flight_map_[change_id])); | 618 scoped_ptr<InFlightChange> change(std::move(in_flight_map_[change_id])); |
| 602 in_flight_map_.erase(change_id); | 619 in_flight_map_.erase(change_id); |
| 603 if (!change) | 620 if (!change) |
| 604 return; | 621 return; |
| 605 | 622 |
| 606 if (!success) | 623 if (!success) |
| 607 change->ChangeFailed(); | 624 change->ChangeFailed(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 } | 675 } |
| 659 | 676 |
| 660 //////////////////////////////////////////////////////////////////////////////// | 677 //////////////////////////////////////////////////////////////////////////////// |
| 661 // WindowTreeClientImpl, private: | 678 // WindowTreeClientImpl, private: |
| 662 | 679 |
| 663 mojo::Callback<void(bool)> WindowTreeClientImpl::ActionCompletedCallback() { | 680 mojo::Callback<void(bool)> WindowTreeClientImpl::ActionCompletedCallback() { |
| 664 return [this](bool success) {}; | 681 return [this](bool success) {}; |
| 665 } | 682 } |
| 666 | 683 |
| 667 } // namespace mus | 684 } // namespace mus |
| OLD | NEW |