Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: services/window_manager/window_manager_impl.cc

Issue 1531403003: Delete the ViewManager and WindowManager services. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-3
Patch Set: rebase Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "services/window_manager/window_manager_impl.h"
6
7 #include "base/bind.h"
8 #include "mojo/services/view_manager/cpp/view.h"
9 #include "services/window_manager/capture_controller.h"
10 #include "services/window_manager/focus_controller.h"
11 #include "services/window_manager/window_manager_root.h"
12
13 using mojo::Callback;
14 using mojo::Id;
15
16 namespace window_manager {
17
18 WindowManagerImpl::WindowManagerImpl(
19 WindowManagerRoot* window_manager,
20 mojo::ScopedMessagePipeHandle window_manager_pipe,
21 bool from_vm)
22 : window_manager_(window_manager),
23 from_vm_(from_vm),
24 binding_(this, window_manager_pipe.Pass()) {
25 binding_.set_connection_error_handler(
26 // WindowManagerRoot::RemoveConnectedService will destroy this object.
27 base::Bind(&WindowManagerRoot::RemoveConnectedService,
28 base::Unretained(window_manager_), base::Unretained(this)));
29 }
30
31 WindowManagerImpl::~WindowManagerImpl(){};
32
33 void WindowManagerImpl::NotifyViewFocused(Id focused_id) {
34 if (from_vm_ && observer_)
35 observer_->OnFocusChanged(focused_id);
36 }
37
38 void WindowManagerImpl::NotifyWindowActivated(Id active_id) {
39 if (from_vm_ && observer_)
40 observer_->OnActiveWindowChanged(active_id);
41 }
42
43 void WindowManagerImpl::NotifyCaptureChanged(Id capture_id) {
44 if (from_vm_ && observer_)
45 observer_->OnCaptureChanged(capture_id);
46 }
47
48 void WindowManagerImpl::Embed(
49 const mojo::String& url,
50 mojo::InterfaceRequest<mojo::ServiceProvider> services,
51 mojo::ServiceProviderPtr exposed_services) {
52 window_manager_->Embed(url, services.Pass(), exposed_services.Pass());
53 }
54
55 void WindowManagerImpl::SetCapture(Id view,
56 const Callback<void(bool)>& callback) {
57 callback.Run(from_vm_ && window_manager_->IsReady() &&
58 window_manager_->SetCapture(view));
59 }
60
61 void WindowManagerImpl::FocusWindow(Id view,
62 const Callback<void(bool)>& callback) {
63 callback.Run(from_vm_ && window_manager_->IsReady() &&
64 window_manager_->FocusWindow(view));
65 }
66
67 void WindowManagerImpl::ActivateWindow(Id view,
68 const Callback<void(bool)>& callback) {
69 callback.Run(from_vm_ && window_manager_->IsReady() &&
70 window_manager_->ActivateWindow(view));
71 }
72
73 void WindowManagerImpl::GetFocusedAndActiveViews(
74 mojo::WindowManagerObserverPtr observer,
75 const mojo::WindowManager::GetFocusedAndActiveViewsCallback& callback) {
76 observer_ = observer.Pass();
77 if (!window_manager_->focus_controller()) {
78 // TODO(sky): add typedef for 0.
79 callback.Run(0, 0, 0);
80 return;
81 }
82 mojo::View* capture_view =
83 window_manager_->capture_controller()->GetCapture();
84 mojo::View* active_view =
85 window_manager_->focus_controller()->GetActiveView();
86 mojo::View* focused_view =
87 window_manager_->focus_controller()->GetFocusedView();
88 // TODO(sky): sanitize ids for client.
89 callback.Run(capture_view ? capture_view->id() : 0,
90 focused_view ? focused_view->id() : 0,
91 active_view ? active_view->id() : 0);
92 }
93
94 } // namespace window_manager
OLDNEW
« no previous file with comments | « services/window_manager/window_manager_impl.h ('k') | services/window_manager/window_manager_root.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698