| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "mojo/services/window_manager/window_manager_impl.h" | |
| 6 | |
| 7 #include "mojo/services/window_manager/window_manager_app.h" | |
| 8 | |
| 9 namespace mojo { | |
| 10 | |
| 11 WindowManagerImpl::WindowManagerImpl(WindowManagerApp* window_manager, | |
| 12 bool from_vm) | |
| 13 : window_manager_(window_manager), from_vm_(from_vm), binding_(this) { | |
| 14 window_manager_->AddConnection(this); | |
| 15 binding_.set_error_handler(this); | |
| 16 } | |
| 17 | |
| 18 WindowManagerImpl::~WindowManagerImpl() { | |
| 19 window_manager_->RemoveConnection(this); | |
| 20 } | |
| 21 | |
| 22 void WindowManagerImpl::Bind(ScopedMessagePipeHandle window_manager_pipe) { | |
| 23 binding_.Bind(window_manager_pipe.Pass()); | |
| 24 } | |
| 25 | |
| 26 void WindowManagerImpl::NotifyViewFocused(Id new_focused_id, | |
| 27 Id old_focused_id) { | |
| 28 if (from_vm_) | |
| 29 client()->OnFocusChanged(old_focused_id, new_focused_id); | |
| 30 } | |
| 31 | |
| 32 void WindowManagerImpl::NotifyWindowActivated(Id new_active_id, | |
| 33 Id old_active_id) { | |
| 34 if (from_vm_) | |
| 35 client()->OnActiveWindowChanged(old_active_id, new_active_id); | |
| 36 } | |
| 37 | |
| 38 void WindowManagerImpl::Embed( | |
| 39 const String& url, | |
| 40 InterfaceRequest<ServiceProvider> service_provider) { | |
| 41 window_manager_->Embed(url, service_provider.Pass()); | |
| 42 } | |
| 43 | |
| 44 void WindowManagerImpl::SetCapture(Id view, | |
| 45 const Callback<void(bool)>& callback) { | |
| 46 if (!from_vm_) | |
| 47 return; // See comments for |from_vm_| on this. | |
| 48 | |
| 49 bool success = window_manager_->IsReady(); | |
| 50 if (success) | |
| 51 window_manager_->SetCapture(view); | |
| 52 callback.Run(success); | |
| 53 } | |
| 54 | |
| 55 void WindowManagerImpl::FocusWindow(Id view, | |
| 56 const Callback<void(bool)>& callback) { | |
| 57 if (!from_vm_) | |
| 58 return; // See comments for |from_vm_| on this. | |
| 59 | |
| 60 bool success = window_manager_->IsReady(); | |
| 61 if (success) | |
| 62 window_manager_->FocusWindow(view); | |
| 63 callback.Run(success); | |
| 64 } | |
| 65 | |
| 66 void WindowManagerImpl::ActivateWindow(Id view, | |
| 67 const Callback<void(bool)>& callback) { | |
| 68 if (!from_vm_) | |
| 69 return; // See comments for |from_vm_| on this. | |
| 70 | |
| 71 bool success = window_manager_->IsReady(); | |
| 72 if (success) | |
| 73 window_manager_->ActivateWindow(view); | |
| 74 callback.Run(success); | |
| 75 } | |
| 76 | |
| 77 void WindowManagerImpl::OnConnectionError() { | |
| 78 delete this; | |
| 79 } | |
| 80 | |
| 81 } // namespace mojo | |
| OLD | NEW |