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 "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h" | 5 #include "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "mojo/public/cpp/application/application_connection.h" | 9 #include "mojo/public/cpp/application/application_connection.h" |
10 #include "mojo/public/cpp/application/connect.h" | 10 #include "mojo/public/cpp/application/connect.h" |
11 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" | 11 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" |
12 #include "mojo/services/public/cpp/view_manager/lib/node_private.h" | 12 #include "mojo/services/public/cpp/view_manager/lib/node_private.h" |
13 #include "mojo/services/public/cpp/view_manager/lib/view_private.h" | 13 #include "mojo/services/public/cpp/view_manager/lib/view_private.h" |
14 #include "mojo/services/public/cpp/view_manager/node_observer.h" | 14 #include "mojo/services/public/cpp/view_manager/node_observer.h" |
15 #include "mojo/services/public/cpp/view_manager/util.h" | 15 #include "mojo/services/public/cpp/view_manager/util.h" |
16 #include "mojo/services/public/cpp/view_manager/view_event_dispatcher.h" | |
17 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" | 16 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
18 #include "mojo/services/public/cpp/view_manager/view_observer.h" | 17 #include "mojo/services/public/cpp/view_manager/view_observer.h" |
| 18 #include "mojo/services/public/cpp/view_manager/window_manager_delegate.h" |
19 #include "third_party/skia/include/core/SkBitmap.h" | 19 #include "third_party/skia/include/core/SkBitmap.h" |
20 #include "ui/gfx/codec/png_codec.h" | 20 #include "ui/gfx/codec/png_codec.h" |
21 | 21 |
22 namespace mojo { | 22 namespace mojo { |
23 namespace view_manager { | 23 namespace view_manager { |
24 | 24 |
25 Id MakeTransportId(ConnectionSpecificId connection_id, | 25 Id MakeTransportId(ConnectionSpecificId connection_id, |
26 ConnectionSpecificId local_id) { | 26 ConnectionSpecificId local_id) { |
27 return (connection_id << 16) | local_id; | 27 return (connection_id << 16) | local_id; |
28 } | 28 } |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 | 522 |
523 DISALLOW_COPY_AND_ASSIGN(SetVisibleTransaction); | 523 DISALLOW_COPY_AND_ASSIGN(SetVisibleTransaction); |
524 }; | 524 }; |
525 | 525 |
526 ViewManagerClientImpl::ViewManagerClientImpl(ApplicationConnection* connection, | 526 ViewManagerClientImpl::ViewManagerClientImpl(ApplicationConnection* connection, |
527 ViewManagerDelegate* delegate) | 527 ViewManagerDelegate* delegate) |
528 : connected_(false), | 528 : connected_(false), |
529 connection_id_(0), | 529 connection_id_(0), |
530 next_id_(1), | 530 next_id_(1), |
531 delegate_(delegate), | 531 delegate_(delegate), |
532 dispatcher_(NULL) {} | 532 window_manager_delegate_(NULL) {} |
533 | 533 |
534 ViewManagerClientImpl::~ViewManagerClientImpl() { | 534 ViewManagerClientImpl::~ViewManagerClientImpl() { |
535 while (!nodes_.empty()) { | 535 while (!nodes_.empty()) { |
536 IdToNodeMap::iterator it = nodes_.begin(); | 536 IdToNodeMap::iterator it = nodes_.begin(); |
537 if (OwnsNode(it->second->id())) | 537 if (OwnsNode(it->second->id())) |
538 it->second->Destroy(); | 538 it->second->Destroy(); |
539 else | 539 else |
540 nodes_.erase(it); | 540 nodes_.erase(it); |
541 } | 541 } |
542 while (!views_.empty()) { | 542 while (!views_.empty()) { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 | 669 |
670 void ViewManagerClientImpl::RemoveView(Id view_id) { | 670 void ViewManagerClientImpl::RemoveView(Id view_id) { |
671 IdToViewMap::iterator it = views_.find(view_id); | 671 IdToViewMap::iterator it = views_.find(view_id); |
672 if (it != views_.end()) | 672 if (it != views_.end()) |
673 views_.erase(it); | 673 views_.erase(it); |
674 } | 674 } |
675 | 675 |
676 //////////////////////////////////////////////////////////////////////////////// | 676 //////////////////////////////////////////////////////////////////////////////// |
677 // ViewManagerClientImpl, ViewManager implementation: | 677 // ViewManagerClientImpl, ViewManager implementation: |
678 | 678 |
679 void ViewManagerClientImpl::SetEventDispatcher( | 679 void ViewManagerClientImpl::SetWindowManagerDelegate( |
680 ViewEventDispatcher* dispatcher) { | 680 WindowManagerDelegate* window_manager_delegate) { |
681 CHECK(NULL != GetNodeById(1)); | 681 CHECK(NULL != GetNodeById(1)); |
682 dispatcher_ = dispatcher; | 682 window_manager_delegate_ = window_manager_delegate; |
683 } | 683 } |
684 | 684 |
685 void ViewManagerClientImpl::DispatchEvent(View* target, EventPtr event) { | 685 void ViewManagerClientImpl::DispatchEvent(View* target, EventPtr event) { |
686 CHECK(dispatcher_); | 686 CHECK(window_manager_delegate_); |
687 service_->DispatchOnViewInputEvent(target->id(), event.Pass()); | 687 service_->DispatchOnViewInputEvent(target->id(), event.Pass()); |
688 } | 688 } |
689 | 689 |
690 const std::string& ViewManagerClientImpl::GetEmbedderURL() const { | 690 const std::string& ViewManagerClientImpl::GetEmbedderURL() const { |
691 return creator_url_; | 691 return creator_url_; |
692 } | 692 } |
693 | 693 |
694 const std::vector<Node*>& ViewManagerClientImpl::GetRoots() const { | 694 const std::vector<Node*>& ViewManagerClientImpl::GetRoots() const { |
695 return roots_; | 695 return roots_; |
696 } | 696 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 *NodePrivate(blurred).observers(), | 817 *NodePrivate(blurred).observers(), |
818 OnNodeFocusChanged(focused, blurred)); | 818 OnNodeFocusChanged(focused, blurred)); |
819 } | 819 } |
820 if (focused) { | 820 if (focused) { |
821 FOR_EACH_OBSERVER(NodeObserver, | 821 FOR_EACH_OBSERVER(NodeObserver, |
822 *NodePrivate(focused).observers(), | 822 *NodePrivate(focused).observers(), |
823 OnNodeFocusChanged(focused, blurred)); | 823 OnNodeFocusChanged(focused, blurred)); |
824 } | 824 } |
825 } | 825 } |
826 | 826 |
| 827 void ViewManagerClientImpl::EmbedRoot(const String& url) { |
| 828 window_manager_delegate_->EmbedRoot(url); |
| 829 } |
| 830 |
827 void ViewManagerClientImpl::DispatchOnViewInputEvent(Id view_id, | 831 void ViewManagerClientImpl::DispatchOnViewInputEvent(Id view_id, |
828 EventPtr event) { | 832 EventPtr event) { |
829 dispatcher_->DispatchEvent(GetViewById(view_id), event.Pass()); | 833 window_manager_delegate_->DispatchEvent(GetViewById(view_id), event.Pass()); |
830 } | 834 } |
831 | 835 |
832 //////////////////////////////////////////////////////////////////////////////// | 836 //////////////////////////////////////////////////////////////////////////////// |
833 // ViewManagerClientImpl, private: | 837 // ViewManagerClientImpl, private: |
834 | 838 |
835 void ViewManagerClientImpl::Sync() { | 839 void ViewManagerClientImpl::Sync() { |
836 // The service connection may not be set up yet. OnConnectionEstablished() | 840 // The service connection may not be set up yet. OnConnectionEstablished() |
837 // will schedule another sync when it is. | 841 // will schedule another sync when it is. |
838 if (!connected_) | 842 if (!connected_) |
839 return; | 843 return; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 | 882 |
879 // static | 883 // static |
880 void ViewManager::ConfigureIncomingConnection( | 884 void ViewManager::ConfigureIncomingConnection( |
881 ApplicationConnection* connection, | 885 ApplicationConnection* connection, |
882 ViewManagerDelegate* delegate) { | 886 ViewManagerDelegate* delegate) { |
883 connection->AddService<ViewManagerClientImpl>(delegate); | 887 connection->AddService<ViewManagerClientImpl>(delegate); |
884 } | 888 } |
885 | 889 |
886 } // namespace view_manager | 890 } // namespace view_manager |
887 } // namespace mojo | 891 } // namespace mojo |
OLD | NEW |