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

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

Issue 1049993002: Get mojo_shell building inside chromium checkout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix presubmit Created 5 years, 8 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 "mojo/services/window_manager/window_manager_impl.h"
6
7 #include "mojo/services/window_manager/capture_controller.h"
8 #include "mojo/services/window_manager/focus_controller.h"
9 #include "mojo/services/window_manager/window_manager_app.h"
10 #include "third_party/mojo_services/src/view_manager/public/cpp/view.h"
11
12 using mojo::Callback;
13 using mojo::Id;
14
15 namespace window_manager {
16
17 WindowManagerImpl::WindowManagerImpl(WindowManagerApp* window_manager,
18 bool from_vm)
19 : window_manager_(window_manager), from_vm_(from_vm), binding_(this) {
20 window_manager_->AddConnection(this);
21 binding_.set_error_handler(this);
22 }
23
24 WindowManagerImpl::~WindowManagerImpl() {
25 window_manager_->RemoveConnection(this);
26 }
27
28 void WindowManagerImpl::Bind(
29 mojo::ScopedMessagePipeHandle window_manager_pipe) {
30 binding_.Bind(window_manager_pipe.Pass());
31 }
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 void WindowManagerImpl::OnConnectionError() {
95 delete this;
96 }
97
98 } // namespace window_manager
OLDNEW
« no previous file with comments | « mojo/services/window_manager/window_manager_impl.h ('k') | mojo/services/window_manager/window_manager_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698