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
4 // found in the LICENSE file.
6 #include "mojo/services/window_manager/window_manager_service_impl.h"
8 #include "mojo/services/window_manager/window_manager_app.h"
12 ////////////////////////////////////////////////////////////////////////////////
13 // WindowManagerServiceImpl, public:
15 WindowManagerServiceImpl::WindowManagerServiceImpl(
16 WindowManagerApp* window_manager)
17 : window_manager_(window_manager) {
18 window_manager_->AddConnection(this);
21 WindowManagerServiceImpl::~WindowManagerServiceImpl() {
22 window_manager_->RemoveConnection(this);
25 void WindowManagerServiceImpl::NotifyReady() {
26 client()->OnWindowManagerReady();
29 void WindowManagerServiceImpl::NotifyViewFocused(Id new_focused_id,
31 client()->OnFocusChanged(old_focused_id, new_focused_id);
34 void WindowManagerServiceImpl::NotifyWindowActivated(Id new_active_id,
36 client()->OnActiveWindowChanged(old_active_id, new_active_id);
39 ////////////////////////////////////////////////////////////////////////////////
40 // WindowManagerServiceImpl, WindowManager implementation:
42 void WindowManagerServiceImpl::SetCapture(
44 const Callback<void(bool)>& callback) {
45 bool success = window_manager_->IsReady();
47 window_manager_->SetCapture(view);
48 callback.Run(success);
51 void WindowManagerServiceImpl::FocusWindow(
53 const Callback<void(bool)>& callback) {
54 bool success = window_manager_->IsReady();
56 window_manager_->FocusWindow(view);
57 callback.Run(success);
60 void WindowManagerServiceImpl::ActivateWindow(
62 const Callback<void(bool)>& callback) {
63 bool success = window_manager_->IsReady();
65 window_manager_->ActivateWindow(view);
66 callback.Run(success);
69 ////////////////////////////////////////////////////////////////////////////////
70 // WindowManagerServiceImpl, InterfaceImpl overrides:
72 void WindowManagerServiceImpl::OnConnectionEstablished() {
73 // If the connection was established prior to the window manager being
74 // embedded by the view manager, |window_manager_|'s ViewManagerDelegate
75 // impl will call NotifyReady() when it is.
76 if (window_manager_->IsReady())