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

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

Issue 698883005: Update mojo sdk to rev cfc99316100efdfa7d53d83f9e07f1d4d3765c21 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h" 5 #include "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "mojo/public/cpp/application/application_impl.h" 10 #include "mojo/public/cpp/application/application_impl.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 87 }
88 88
89 View* root_; 89 View* root_;
90 90
91 DISALLOW_COPY_AND_ASSIGN(RootObserver); 91 DISALLOW_COPY_AND_ASSIGN(RootObserver);
92 }; 92 };
93 93
94 ViewManagerClientImpl::ViewManagerClientImpl(ViewManagerDelegate* delegate, 94 ViewManagerClientImpl::ViewManagerClientImpl(ViewManagerDelegate* delegate,
95 Shell* shell) 95 Shell* shell)
96 : connected_(false), connection_id_(0), next_id_(1), delegate_(delegate) { 96 : connected_(false), connection_id_(0), next_id_(1), delegate_(delegate) {
97 InterfacePtr<ServiceProvider> sp;
98 shell->ConnectToApplication("mojo:window_manager", GetProxy(&sp));
99 ConnectToService(sp.get(), &window_manager_);
100 window_manager_.set_client(this);
101 } 97 }
102 98
103 ViewManagerClientImpl::~ViewManagerClientImpl() { 99 ViewManagerClientImpl::~ViewManagerClientImpl() {
104 std::vector<View*> non_owned; 100 std::vector<View*> non_owned;
105 while (!views_.empty()) { 101 while (!views_.empty()) {
106 IdToViewMap::iterator it = views_.begin(); 102 IdToViewMap::iterator it = views_.begin();
107 if (OwnsView(it->second->id())) { 103 if (OwnsView(it->second->id())) {
108 it->second->Destroy(); 104 it->second->Destroy();
109 } else { 105 } else {
110 non_owned.push_back(it->second); 106 non_owned.push_back(it->second);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 159
164 void ViewManagerClientImpl::SetSurfaceId(Id view_id, SurfaceIdPtr surface_id) { 160 void ViewManagerClientImpl::SetSurfaceId(Id view_id, SurfaceIdPtr surface_id) {
165 DCHECK(connected_); 161 DCHECK(connected_);
166 if (surface_id.is_null()) 162 if (surface_id.is_null())
167 return; 163 return;
168 service_->SetViewSurfaceId( 164 service_->SetViewSurfaceId(
169 view_id, surface_id.Pass(), ActionCompletedCallback()); 165 view_id, surface_id.Pass(), ActionCompletedCallback());
170 } 166 }
171 167
172 void ViewManagerClientImpl::SetFocus(Id view_id) { 168 void ViewManagerClientImpl::SetFocus(Id view_id) {
169 // In order for us to get here we had to have exposed a view, which implies we
170 // got a connection.
171 DCHECK(window_manager_.get());
173 window_manager_->FocusWindow(view_id, ActionCompletedCallback()); 172 window_manager_->FocusWindow(view_id, ActionCompletedCallback());
174 } 173 }
175 174
176 void ViewManagerClientImpl::SetVisible(Id view_id, bool visible) { 175 void ViewManagerClientImpl::SetVisible(Id view_id, bool visible) {
177 DCHECK(connected_); 176 DCHECK(connected_);
178 service_->SetViewVisibility(view_id, visible, ActionCompletedCallback()); 177 service_->SetViewVisibility(view_id, visible, ActionCompletedCallback());
179 } 178 }
180 179
181 void ViewManagerClientImpl::SetProperty( 180 void ViewManagerClientImpl::SetProperty(
182 Id view_id, 181 Id view_id,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 service_ = client(); 237 service_ = client();
239 } 238 }
240 239
241 //////////////////////////////////////////////////////////////////////////////// 240 ////////////////////////////////////////////////////////////////////////////////
242 // ViewManagerClientImpl, ViewManagerClient implementation: 241 // ViewManagerClientImpl, ViewManagerClient implementation:
243 242
244 void ViewManagerClientImpl::OnEmbed( 243 void ViewManagerClientImpl::OnEmbed(
245 ConnectionSpecificId connection_id, 244 ConnectionSpecificId connection_id,
246 const String& creator_url, 245 const String& creator_url,
247 ViewDataPtr root_data, 246 ViewDataPtr root_data,
248 InterfaceRequest<ServiceProvider> service_provider) { 247 InterfaceRequest<ServiceProvider> parent_services,
248 ScopedMessagePipeHandle window_manager_pipe) {
249 if (!connected_) { 249 if (!connected_) {
250 connected_ = true; 250 connected_ = true;
251 connection_id_ = connection_id; 251 connection_id_ = connection_id;
252 creator_url_ = String::From(creator_url); 252 creator_url_ = String::From(creator_url);
253 } else { 253 } else {
254 DCHECK_EQ(connection_id_, connection_id); 254 DCHECK_EQ(connection_id_, connection_id);
255 DCHECK_EQ(creator_url_, creator_url); 255 DCHECK_EQ(creator_url_, creator_url);
256 } 256 }
257 257
258 // A new root must not already exist as a root or be contained by an existing 258 // A new root must not already exist as a root or be contained by an existing
259 // hierarchy visible to this view manager. 259 // hierarchy visible to this view manager.
260 View* root = AddViewToViewManager(this, NULL, root_data); 260 View* root = AddViewToViewManager(this, NULL, root_data);
261 roots_.push_back(root); 261 roots_.push_back(root);
262 root->AddObserver(new RootObserver(root)); 262 root->AddObserver(new RootObserver(root));
263 263
264 ServiceProviderImpl* exported_services = nullptr; 264 ServiceProviderImpl* exported_services = nullptr;
265 scoped_ptr<ServiceProvider> remote; 265 scoped_ptr<ServiceProvider> remote;
266 266
267 if (service_provider.is_pending()) { 267 if (parent_services.is_pending()) {
268 // BindToRequest() binds the lifetime of |exported_services| to the pipe. 268 // BindToRequest() binds the lifetime of |exported_services| to the pipe.
269 exported_services = new ServiceProviderImpl; 269 exported_services = new ServiceProviderImpl;
270 BindToRequest(exported_services, &service_provider); 270 BindToRequest(exported_services, &parent_services);
271 remote.reset(exported_services->CreateRemoteServiceProvider()); 271 remote.reset(exported_services->CreateRemoteServiceProvider());
272 } 272 }
273 window_manager_.Bind(window_manager_pipe.Pass());
274 window_manager_.set_client(this);
273 delegate_->OnEmbed(this, root, exported_services, remote.Pass()); 275 delegate_->OnEmbed(this, root, exported_services, remote.Pass());
274 } 276 }
275 277
276 void ViewManagerClientImpl::OnViewBoundsChanged(Id view_id, 278 void ViewManagerClientImpl::OnViewBoundsChanged(Id view_id,
277 RectPtr old_bounds, 279 RectPtr old_bounds,
278 RectPtr new_bounds) { 280 RectPtr new_bounds) {
279 View* view = GetViewById(view_id); 281 View* view = GetViewById(view_id);
280 ViewPrivate(view).LocalSetBounds(*old_bounds, *new_bounds); 282 ViewPrivate(view).LocalSetBounds(*old_bounds, *new_bounds);
281 } 283 }
282 284
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 View* view = GetViewById(view_id); 355 View* view = GetViewById(view_id);
354 if (view) { 356 if (view) {
355 FOR_EACH_OBSERVER(ViewObserver, 357 FOR_EACH_OBSERVER(ViewObserver,
356 *ViewPrivate(view).observers(), 358 *ViewPrivate(view).observers(),
357 OnViewInputEvent(view, event)); 359 OnViewInputEvent(view, event));
358 } 360 }
359 ack_callback.Run(); 361 ack_callback.Run();
360 } 362 }
361 363
362 //////////////////////////////////////////////////////////////////////////////// 364 ////////////////////////////////////////////////////////////////////////////////
363 // ViewManagerClientImpl, WindowManagerClient2 implementation: 365 // ViewManagerClientImpl, WindowManagerClient implementation:
364
365 void ViewManagerClientImpl::OnWindowManagerReady() {}
366 366
367 void ViewManagerClientImpl::OnCaptureChanged(Id old_capture_view_id, 367 void ViewManagerClientImpl::OnCaptureChanged(Id old_capture_view_id,
368 Id new_capture_view_id) {} 368 Id new_capture_view_id) {}
369 369
370 void ViewManagerClientImpl::OnFocusChanged(Id old_focused_view_id, 370 void ViewManagerClientImpl::OnFocusChanged(Id old_focused_view_id,
371 Id new_focused_view_id) { 371 Id new_focused_view_id) {
372 View* focused = GetViewById(new_focused_view_id); 372 View* focused = GetViewById(new_focused_view_id);
373 View* blurred = GetViewById(old_focused_view_id); 373 View* blurred = GetViewById(old_focused_view_id);
374 if (blurred) { 374 if (blurred) {
375 FOR_EACH_OBSERVER(ViewObserver, 375 FOR_EACH_OBSERVER(ViewObserver,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 base::Unretained(this)); 410 base::Unretained(this));
411 } 411 }
412 412
413 base::Callback<void(ErrorCode)> 413 base::Callback<void(ErrorCode)>
414 ViewManagerClientImpl::ActionCompletedCallbackWithErrorCode() { 414 ViewManagerClientImpl::ActionCompletedCallbackWithErrorCode() {
415 return base::Bind(&ViewManagerClientImpl::OnActionCompletedWithErrorCode, 415 return base::Bind(&ViewManagerClientImpl::OnActionCompletedWithErrorCode,
416 base::Unretained(this)); 416 base::Unretained(this));
417 } 417 }
418 418
419 } // namespace mojo 419 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698