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

Side by Side Diff: mojo/services/view_manager/public/cpp/lib/view_manager_client_impl.cc

Issue 954273002: Routes WindowManager functionality through the view manager (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: comments Created 5 years, 10 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
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 "view_manager/public/cpp/lib/view_manager_client_impl.h" 5 #include "view_manager/public/cpp/lib/view_manager_client_impl.h"
6 6
7 #include "mojo/public/cpp/application/application_impl.h" 7 #include "mojo/public/cpp/application/application_impl.h"
8 #include "mojo/public/cpp/application/connect.h" 8 #include "mojo/public/cpp/application/connect.h"
9 #include "mojo/public/cpp/application/service_provider_impl.h" 9 #include "mojo/public/cpp/application/service_provider_impl.h"
10 #include "mojo/public/interfaces/application/service_provider.mojom.h" 10 #include "mojo/public/interfaces/application/service_provider.mojom.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 DCHECK(service_); 165 DCHECK(service_);
166 if (surface_id.is_null()) 166 if (surface_id.is_null())
167 return; 167 return;
168 service_->SetViewSurfaceId( 168 service_->SetViewSurfaceId(
169 view_id, surface_id.Pass(), ActionCompletedCallback()); 169 view_id, surface_id.Pass(), ActionCompletedCallback());
170 } 170 }
171 171
172 void ViewManagerClientImpl::SetFocus(Id view_id) { 172 void ViewManagerClientImpl::SetFocus(Id view_id) {
173 // In order for us to get here we had to have exposed a view, which implies we 173 // In order for us to get here we had to have exposed a view, which implies we
174 // got a connection. 174 // got a connection.
175 DCHECK(window_manager_.get()); 175 DCHECK(service_);
176 window_manager_->FocusWindow(view_id, ActionCompletedCallback()); 176 service_->PerformAction(view_id, "focus", ActionCompletedCallback());
177 } 177 }
178 178
179 void ViewManagerClientImpl::SetVisible(Id view_id, bool visible) { 179 void ViewManagerClientImpl::SetVisible(Id view_id, bool visible) {
180 DCHECK(service_); 180 DCHECK(service_);
181 service_->SetViewVisibility(view_id, visible, ActionCompletedCallback()); 181 service_->SetViewVisibility(view_id, visible, ActionCompletedCallback());
182 } 182 }
183 183
184 void ViewManagerClientImpl::SetProperty( 184 void ViewManagerClientImpl::SetProperty(
185 Id view_id, 185 Id view_id,
186 const std::string& name, 186 const std::string& name,
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 const Callback<void()>& ack_callback) { 411 const Callback<void()>& ack_callback) {
412 View* view = GetViewById(view_id); 412 View* view = GetViewById(view_id);
413 if (view) { 413 if (view) {
414 FOR_EACH_OBSERVER(ViewObserver, 414 FOR_EACH_OBSERVER(ViewObserver,
415 *ViewPrivate(view).observers(), 415 *ViewPrivate(view).observers(),
416 OnViewInputEvent(view, event)); 416 OnViewInputEvent(view, event));
417 } 417 }
418 ack_callback.Run(); 418 ack_callback.Run();
419 } 419 }
420 420
421 void ViewManagerClientImpl::OnPerformAction(
422 Id view_id,
423 const String& name,
424 const Callback<void(bool)>& callback) {
425 View* view = GetViewById(view_id);
426 callback.Run(delegate_->OnPerformAction(view, name));
427 }
428
421 //////////////////////////////////////////////////////////////////////////////// 429 ////////////////////////////////////////////////////////////////////////////////
422 // ViewManagerClientImpl, WindowManagerObserver implementation: 430 // ViewManagerClientImpl, WindowManagerObserver implementation:
423 431
424 void ViewManagerClientImpl::OnCaptureChanged(Id capture_view_id) { 432 void ViewManagerClientImpl::OnCaptureChanged(Id capture_view_id) {
425 View* gained_capture = GetViewById(capture_view_id); 433 View* gained_capture = GetViewById(capture_view_id);
426 View* lost_capture = capture_view_; 434 View* lost_capture = capture_view_;
427 if (lost_capture) { 435 if (lost_capture) {
428 FOR_EACH_OBSERVER(ViewObserver, 436 FOR_EACH_OBSERVER(ViewObserver,
429 *ViewPrivate(lost_capture).observers(), 437 *ViewPrivate(lost_capture).observers(),
430 OnViewFocusChanged(gained_capture, lost_capture)); 438 OnViewFocusChanged(gained_capture, lost_capture));
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 void ViewManagerClientImpl::OnActionCompleted(bool success) { 495 void ViewManagerClientImpl::OnActionCompleted(bool success) {
488 if (!change_acked_callback_.is_null()) 496 if (!change_acked_callback_.is_null())
489 change_acked_callback_.Run(); 497 change_acked_callback_.Run();
490 } 498 }
491 499
492 Callback<void(bool)> ViewManagerClientImpl::ActionCompletedCallback() { 500 Callback<void(bool)> ViewManagerClientImpl::ActionCompletedCallback() {
493 return [this](bool success) { OnActionCompleted(success); }; 501 return [this](bool success) { OnActionCompleted(success); };
494 } 502 }
495 503
496 } // namespace mojo 504 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698