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

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

Issue 405523002: Add ability APIs for opening a window with a url embedded, focusing and activating a window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « mojo/services/window_manager/window_manager_service_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/services/window_manager/window_manager_service_impl.h" 5 #include "mojo/services/window_manager/window_manager_service_impl.h"
6 6
7 #include "mojo/services/window_manager/window_manager_app.h" 7 #include "mojo/services/window_manager/window_manager_app.h"
8 8
9 namespace mojo { 9 namespace mojo {
10 10
11 //////////////////////////////////////////////////////////////////////////////// 11 ////////////////////////////////////////////////////////////////////////////////
12 // WindowManagerServiceImpl, public: 12 // WindowManagerServiceImpl, public:
13 13
14 WindowManagerServiceImpl::WindowManagerServiceImpl( 14 WindowManagerServiceImpl::WindowManagerServiceImpl(
15 ApplicationConnection* connection, 15 ApplicationConnection* connection,
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 WindowManagerServiceImpl::~WindowManagerServiceImpl() {
22 window_manager_->RemoveConnection(this); 22 window_manager_->RemoveConnection(this);
23 } 23 }
24 24
25 void WindowManagerServiceImpl::NotifyReady() { 25 void WindowManagerServiceImpl::NotifyReady() {
26 client()->OnWindowManagerReady(); 26 client()->OnWindowManagerReady();
27 } 27 }
28 28
29 void WindowManagerServiceImpl::NotifyNodeFocused(
30 view_manager::Id new_focused_id,
31 view_manager::Id old_focused_id) {
32 client()->OnFocusChanged(old_focused_id, new_focused_id);
33 }
34
35 void WindowManagerServiceImpl::NotifyWindowActivated(
36 view_manager::Id new_active_id,
37 view_manager::Id old_active_id) {
38 client()->OnActiveWindowChanged(old_active_id, new_active_id);
39 }
40
29 //////////////////////////////////////////////////////////////////////////////// 41 ////////////////////////////////////////////////////////////////////////////////
30 // WindowManagerServiceImpl, WindowManager implementation: 42 // WindowManagerServiceImpl, WindowManager implementation:
31 43
32 void WindowManagerServiceImpl::OpenWindow( 44 void WindowManagerServiceImpl::OpenWindow(
33 const Callback<void(view_manager::Id)>& callback) { 45 const Callback<void(view_manager::Id)>& callback) {
34 view_manager::Id id = window_manager_->OpenWindow(); 46 bool success = window_manager_->IsReady();
35 callback.Run(id); 47 if (success) {
48 view_manager::Id id = window_manager_->OpenWindow();
49 callback.Run(id);
50 } else {
51 // TODO(beng): perhaps should take an error code for this.
52 callback.Run(0);
53 }
54 }
55
56 void WindowManagerServiceImpl::OpenWindowWithURL(
57 const String& url,
58 const Callback<void(view_manager::Id)>& callback) {
59 bool success = window_manager_->IsReady();
60 if (success) {
61 view_manager::Id id = window_manager_->OpenWindowWithURL(url);
62 callback.Run(id);
63 } else {
64 // TODO(beng): perhaps should take an error code for this.
65 callback.Run(0);
66 }
36 } 67 }
37 68
38 void WindowManagerServiceImpl::SetCapture( 69 void WindowManagerServiceImpl::SetCapture(
39 view_manager::Id node, 70 view_manager::Id node,
40 const Callback<void(bool)>& callback) { 71 const Callback<void(bool)>& callback) {
41 window_manager_->SetCapture(node); 72 bool success = window_manager_->IsReady();
42 callback.Run(true); 73 if (success)
74 window_manager_->SetCapture(node);
75 callback.Run(success);
76 }
77
78 void WindowManagerServiceImpl::FocusWindow(
79 view_manager::Id node,
80 const Callback<void(bool)>& callback) {
81 bool success = window_manager_->IsReady();
82 if (success)
83 window_manager_->FocusWindow(node);
84 callback.Run(success);
85 }
86
87 void WindowManagerServiceImpl::ActivateWindow(
88 view_manager::Id node,
89 const Callback<void(bool)>& callback) {
90 bool success = window_manager_->IsReady();
91 if (success)
92 window_manager_->ActivateWindow(node);
93 callback.Run(success);
43 } 94 }
44 95
45 //////////////////////////////////////////////////////////////////////////////// 96 ////////////////////////////////////////////////////////////////////////////////
46 // WindowManagerServiceImpl, InterfaceImpl overrides: 97 // WindowManagerServiceImpl, InterfaceImpl overrides:
47 98
48 void WindowManagerServiceImpl::OnConnectionEstablished() { 99 void WindowManagerServiceImpl::OnConnectionEstablished() {
49 // If the connection was established prior to the window manager being 100 // If the connection was established prior to the window manager being
50 // embedded by the view manager, |window_manager_|'s ViewManagerDelegate 101 // embedded by the view manager, |window_manager_|'s ViewManagerDelegate
51 // impl will call NotifyReady() when it is. 102 // impl will call NotifyReady() when it is.
52 if (window_manager_->IsReady()) 103 if (window_manager_->IsReady())
53 NotifyReady(); 104 NotifyReady();
54 } 105 }
55 106
56 } // namespace mojo 107 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/window_manager/window_manager_service_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698