| 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/view_manager/connection_manager.h" | 5 #include "components/view_manager/connection_manager.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "components/view_manager/client_connection.h" | 9 #include "components/view_manager/client_connection.h" |
| 10 #include "components/view_manager/connection_manager_delegate.h" | 10 #include "components/view_manager/connection_manager_delegate.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 connection_id_(connection->id()), | 104 connection_id_(connection->id()), |
| 105 is_delete_view_(is_delete_view) { | 105 is_delete_view_(is_delete_view) { |
| 106 connection_manager_->PrepareForChange(this); | 106 connection_manager_->PrepareForChange(this); |
| 107 } | 107 } |
| 108 | 108 |
| 109 ConnectionManager::ScopedChange::~ScopedChange() { | 109 ConnectionManager::ScopedChange::~ScopedChange() { |
| 110 connection_manager_->FinishChange(); | 110 connection_manager_->FinishChange(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 ConnectionManager::ConnectionManager(ConnectionManagerDelegate* delegate, | 113 ConnectionManager::ConnectionManager(ConnectionManagerDelegate* delegate, |
| 114 scoped_ptr<DisplayManager> display_manager, | 114 scoped_ptr<DisplayManager> display_manager) |
| 115 mojo::WindowManagerInternal* wm_internal) | |
| 116 : delegate_(delegate), | 115 : delegate_(delegate), |
| 117 window_manager_client_connection_(nullptr), | 116 window_manager_client_connection_(nullptr), |
| 118 next_connection_id_(1), | 117 next_connection_id_(1), |
| 119 display_manager_(display_manager.Pass()), | 118 display_manager_(display_manager.Pass()), |
| 120 root_(CreateServerView(RootViewId())), | 119 root_(CreateServerView(RootViewId())), |
| 121 wm_internal_(wm_internal), | |
| 122 current_change_(nullptr), | 120 current_change_(nullptr), |
| 123 in_destructor_(false), | 121 in_destructor_(false), |
| 124 animation_runner_(base::TimeTicks::Now()), | 122 animation_runner_(base::TimeTicks::Now()), |
| 125 event_dispatcher_(this), | 123 event_dispatcher_(this), |
| 126 event_dispatcher_binding_(&event_dispatcher_), | 124 event_dispatcher_binding_(&event_dispatcher_), |
| 127 focus_controller_(new FocusController(this, root_.get())) { | 125 focus_controller_(new FocusController(this, root_.get())) { |
| 128 root_->SetBounds(gfx::Rect(800, 600)); | 126 root_->SetBounds(gfx::Rect(800, 600)); |
| 129 root_->SetVisible(true); | 127 root_->SetVisible(true); |
| 130 | 128 |
| 131 mojo::NativeViewportEventDispatcherPtr event_dispatcher_ptr; | 129 mojo::NativeViewportEventDispatcherPtr event_dispatcher_ptr; |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 void ConnectionManager::OnViewSharedPropertyChanged( | 516 void ConnectionManager::OnViewSharedPropertyChanged( |
| 519 ServerView* view, | 517 ServerView* view, |
| 520 const std::string& name, | 518 const std::string& name, |
| 521 const std::vector<uint8_t>* new_data) { | 519 const std::vector<uint8_t>* new_data) { |
| 522 for (auto& pair : connection_map_) { | 520 for (auto& pair : connection_map_) { |
| 523 pair.second->service()->ProcessViewPropertyChanged( | 521 pair.second->service()->ProcessViewPropertyChanged( |
| 524 view, name, new_data, IsChangeSource(pair.first)); | 522 view, name, new_data, IsChangeSource(pair.first)); |
| 525 } | 523 } |
| 526 } | 524 } |
| 527 | 525 |
| 526 void ConnectionManager::SetViewManagerRootClient( |
| 527 mojo::ViewManagerRootClientPtr client) { |
| 528 view_manager_root_client_ = client.Pass(); |
| 529 } |
| 530 |
| 528 void ConnectionManager::SetViewportSize(mojo::SizePtr size) { | 531 void ConnectionManager::SetViewportSize(mojo::SizePtr size) { |
| 529 display_manager_->SetViewportSize(size.To<gfx::Size>()); | 532 display_manager_->SetViewportSize(size.To<gfx::Size>()); |
| 530 } | 533 } |
| 531 | 534 |
| 532 void ConnectionManager::DispatchInputEventToViewDEPRECATED( | |
| 533 mojo::Id transport_view_id, | |
| 534 mojo::EventPtr event) { | |
| 535 const ViewId view_id(ViewIdFromTransportId(transport_view_id)); | |
| 536 | |
| 537 ViewManagerServiceImpl* connection = GetConnectionWithRoot(view_id); | |
| 538 if (!connection) | |
| 539 connection = GetConnection(view_id.connection_id); | |
| 540 if (connection) { | |
| 541 connection->client()->OnViewInputEvent( | |
| 542 transport_view_id, event.Pass(), base::Bind(&base::DoNothing)); | |
| 543 } | |
| 544 } | |
| 545 | |
| 546 void ConnectionManager::CloneAndAnimate(mojo::Id transport_view_id) { | 535 void ConnectionManager::CloneAndAnimate(mojo::Id transport_view_id) { |
| 547 CloneAndAnimate(ViewIdFromTransportId(transport_view_id)); | 536 CloneAndAnimate(ViewIdFromTransportId(transport_view_id)); |
| 548 } | 537 } |
| 549 | 538 |
| 550 void ConnectionManager::AddAccelerator(mojo::KeyboardCode keyboard_code, | 539 void ConnectionManager::AddAccelerator(mojo::KeyboardCode keyboard_code, |
| 551 mojo::EventFlags flags) { | 540 mojo::EventFlags flags) { |
| 552 event_dispatcher_.AddAccelerator(keyboard_code, flags); | 541 event_dispatcher_.AddAccelerator(keyboard_code, flags); |
| 553 } | 542 } |
| 554 | 543 |
| 555 void ConnectionManager::RemoveAccelerator(mojo::KeyboardCode keyboard_code, | 544 void ConnectionManager::RemoveAccelerator(mojo::KeyboardCode keyboard_code, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 if (wm_connection != owning_connection_old && | 598 if (wm_connection != owning_connection_old && |
| 610 wm_connection != embedded_connection_old && | 599 wm_connection != embedded_connection_old && |
| 611 wm_connection != owning_connection_new && | 600 wm_connection != owning_connection_new && |
| 612 wm_connection != embedded_connection_new) { | 601 wm_connection != embedded_connection_new) { |
| 613 wm_connection->ProcessFocusChanged(old_focused_view, new_focused_view); | 602 wm_connection->ProcessFocusChanged(old_focused_view, new_focused_view); |
| 614 } | 603 } |
| 615 } | 604 } |
| 616 } | 605 } |
| 617 | 606 |
| 618 } // namespace view_manager | 607 } // namespace view_manager |
| OLD | NEW |