| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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(Id view_id, const String& name) { |
| 422 View* view = GetViewById(view_id); |
| 423 delegate_->OnPerformAction(view, name); |
| 424 } |
| 425 |
| 421 //////////////////////////////////////////////////////////////////////////////// | 426 //////////////////////////////////////////////////////////////////////////////// |
| 422 // ViewManagerClientImpl, WindowManagerObserver implementation: | 427 // ViewManagerClientImpl, WindowManagerObserver implementation: |
| 423 | 428 |
| 424 void ViewManagerClientImpl::OnCaptureChanged(Id capture_view_id) { | 429 void ViewManagerClientImpl::OnCaptureChanged(Id capture_view_id) { |
| 425 View* gained_capture = GetViewById(capture_view_id); | 430 View* gained_capture = GetViewById(capture_view_id); |
| 426 View* lost_capture = capture_view_; | 431 View* lost_capture = capture_view_; |
| 427 if (lost_capture) { | 432 if (lost_capture) { |
| 428 FOR_EACH_OBSERVER(ViewObserver, | 433 FOR_EACH_OBSERVER(ViewObserver, |
| 429 *ViewPrivate(lost_capture).observers(), | 434 *ViewPrivate(lost_capture).observers(), |
| 430 OnViewFocusChanged(gained_capture, lost_capture)); | 435 OnViewFocusChanged(gained_capture, lost_capture)); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 void ViewManagerClientImpl::OnActionCompleted(bool success) { | 492 void ViewManagerClientImpl::OnActionCompleted(bool success) { |
| 488 if (!change_acked_callback_.is_null()) | 493 if (!change_acked_callback_.is_null()) |
| 489 change_acked_callback_.Run(); | 494 change_acked_callback_.Run(); |
| 490 } | 495 } |
| 491 | 496 |
| 492 Callback<void(bool)> ViewManagerClientImpl::ActionCompletedCallback() { | 497 Callback<void(bool)> ViewManagerClientImpl::ActionCompletedCallback() { |
| 493 return [this](bool success) { OnActionCompleted(success); }; | 498 return [this](bool success) { OnActionCompleted(success); }; |
| 494 } | 499 } |
| 495 | 500 |
| 496 } // namespace mojo | 501 } // namespace mojo |
| OLD | NEW |