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