| OLD | NEW |
| 1 | |
| 2 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 // 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 |
| 4 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 5 | 4 |
| 6 #include "mojo/services/window_manager/window_manager_service_impl.h" | 5 #include "mojo/services/window_manager/window_manager_service_impl.h" |
| 7 | 6 |
| 7 #include "mojo/aura/window_tree_host_mojo.h" |
| 8 #include "mojo/converters/input_events/input_events_type_converters.h" |
| 8 #include "mojo/services/window_manager/window_manager_app.h" | 9 #include "mojo/services/window_manager/window_manager_app.h" |
| 10 #include "mojo/services/window_manager/window_manager_delegate.h" |
| 9 | 11 |
| 10 namespace mojo { | 12 namespace mojo { |
| 11 | 13 |
| 12 //////////////////////////////////////////////////////////////////////////////// | 14 WindowManagerServiceImpl::WindowManagerServiceImpl(WindowManagerApp* app) |
| 13 // WindowManagerServiceImpl, public: | 15 : app_(app) { |
| 14 | |
| 15 WindowManagerServiceImpl::WindowManagerServiceImpl( | |
| 16 WindowManagerApp* window_manager) | |
| 17 : window_manager_(window_manager) { | |
| 18 window_manager_->AddConnection(this); | |
| 19 } | 16 } |
| 20 | 17 |
| 21 WindowManagerServiceImpl::~WindowManagerServiceImpl() { | 18 WindowManagerServiceImpl::~WindowManagerServiceImpl() { |
| 22 window_manager_->RemoveConnection(this); | |
| 23 } | 19 } |
| 24 | 20 |
| 25 void WindowManagerServiceImpl::NotifyReady() { | 21 void WindowManagerServiceImpl::Embed( |
| 26 client()->OnWindowManagerReady(); | 22 const String& url, |
| 23 InterfaceRequest<ServiceProvider> service_provider) { |
| 24 app_->window_manager_delegate()->Embed(url, service_provider.Pass()); |
| 27 } | 25 } |
| 28 | 26 |
| 29 void WindowManagerServiceImpl::NotifyViewFocused(Id new_focused_id, | 27 void WindowManagerServiceImpl::OnViewInputEvent(mojo::EventPtr event) { |
| 30 Id old_focused_id) { | 28 scoped_ptr<ui::Event> ui_event = event.To<scoped_ptr<ui::Event>>(); |
| 31 client()->OnFocusChanged(old_focused_id, new_focused_id); | 29 if (ui_event) |
| 30 app_->host()->SendEventToProcessor(ui_event.get()); |
| 32 } | 31 } |
| 33 | 32 |
| 34 void WindowManagerServiceImpl::NotifyWindowActivated(Id new_active_id, | |
| 35 Id old_active_id) { | |
| 36 client()->OnActiveWindowChanged(old_active_id, new_active_id); | |
| 37 } | |
| 38 | |
| 39 //////////////////////////////////////////////////////////////////////////////// | |
| 40 // WindowManagerServiceImpl, WindowManager implementation: | |
| 41 | |
| 42 void WindowManagerServiceImpl::SetCapture( | |
| 43 Id view, | |
| 44 const Callback<void(bool)>& callback) { | |
| 45 bool success = window_manager_->IsReady(); | |
| 46 if (success) | |
| 47 window_manager_->SetCapture(view); | |
| 48 callback.Run(success); | |
| 49 } | |
| 50 | |
| 51 void WindowManagerServiceImpl::FocusWindow( | |
| 52 Id view, | |
| 53 const Callback<void(bool)>& callback) { | |
| 54 bool success = window_manager_->IsReady(); | |
| 55 if (success) | |
| 56 window_manager_->FocusWindow(view); | |
| 57 callback.Run(success); | |
| 58 } | |
| 59 | |
| 60 void WindowManagerServiceImpl::ActivateWindow( | |
| 61 Id view, | |
| 62 const Callback<void(bool)>& callback) { | |
| 63 bool success = window_manager_->IsReady(); | |
| 64 if (success) | |
| 65 window_manager_->ActivateWindow(view); | |
| 66 callback.Run(success); | |
| 67 } | |
| 68 | |
| 69 //////////////////////////////////////////////////////////////////////////////// | |
| 70 // WindowManagerServiceImpl, InterfaceImpl overrides: | |
| 71 | |
| 72 void WindowManagerServiceImpl::OnConnectionEstablished() { | 33 void WindowManagerServiceImpl::OnConnectionEstablished() { |
| 73 // If the connection was established prior to the window manager being | 34 app_->set_window_manager_client(client()); |
| 74 // embedded by the view manager, |window_manager_|'s ViewManagerDelegate | |
| 75 // impl will call NotifyReady() when it is. | |
| 76 if (window_manager_->IsReady()) | |
| 77 NotifyReady(); | |
| 78 } | 35 } |
| 79 | 36 |
| 80 } // namespace mojo | 37 } // namespace mojo |
| OLD | NEW |