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

Side by Side Diff: mojo/services/view_manager/view_manager_service_impl.cc

Issue 636363002: Splits window manager like methods into ViewManagerServiceDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge 2 trunk Created 6 years, 2 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 "mojo/services/view_manager/view_manager_service_impl.h" 5 #include "mojo/services/view_manager/view_manager_service_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "mojo/converters/geometry/geometry_type_converters.h" 8 #include "mojo/converters/geometry/geometry_type_converters.h"
9 #include "mojo/converters/input_events/input_events_type_converters.h" 9 #include "mojo/converters/input_events/input_events_type_converters.h"
10 #include "mojo/converters/surfaces/surfaces_type_converters.h" 10 #include "mojo/converters/surfaces/surfaces_type_converters.h"
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 474
475 void ViewManagerServiceImpl::Embed( 475 void ViewManagerServiceImpl::Embed(
476 const String& url, 476 const String& url,
477 Id transport_view_id, 477 Id transport_view_id,
478 ServiceProviderPtr service_provider, 478 ServiceProviderPtr service_provider,
479 const Callback<void(bool)>& callback) { 479 const Callback<void(bool)>& callback) {
480 InterfaceRequest<ServiceProvider> spir; 480 InterfaceRequest<ServiceProvider> spir;
481 spir.Bind(service_provider.PassMessagePipe()); 481 spir.Bind(service_provider.PassMessagePipe());
482 482
483 if (ViewIdFromTransportId(transport_view_id) == InvalidViewId()) { 483 if (ViewIdFromTransportId(transport_view_id) == InvalidViewId()) {
484 connection_manager_->EmbedRoot(url, spir.Pass()); 484 connection_manager_->Embed(url, spir.Pass());
485 callback.Run(true); 485 callback.Run(true);
486 return; 486 return;
487 } 487 }
488 const ServerView* view = GetView(ViewIdFromTransportId(transport_view_id)); 488 const ServerView* view = GetView(ViewIdFromTransportId(transport_view_id));
489 if (!view || !access_policy_->CanEmbed(view)) { 489 if (!view || !access_policy_->CanEmbed(view)) {
490 callback.Run(false); 490 callback.Run(false);
491 return; 491 return;
492 } 492 }
493 493
494 // Only allow a node to be the root for one connection. 494 // Only allow a node to be the root for one connection.
495 const ViewId view_id(ViewIdFromTransportId(transport_view_id)); 495 const ViewId view_id(ViewIdFromTransportId(transport_view_id));
496 ViewManagerServiceImpl* existing_owner = 496 ViewManagerServiceImpl* existing_owner =
497 connection_manager_->GetConnectionWithRoot(view_id); 497 connection_manager_->GetConnectionWithRoot(view_id);
498 498
499 ConnectionManager::ScopedChange change(this, connection_manager_, true); 499 ConnectionManager::ScopedChange change(this, connection_manager_, true);
500 RemoveChildrenAsPartOfEmbed(view_id); 500 RemoveChildrenAsPartOfEmbed(view_id);
501 if (existing_owner) { 501 if (existing_owner) {
502 // Never message the originating connection. 502 // Never message the originating connection.
503 connection_manager_->OnConnectionMessagedClient(id_); 503 connection_manager_->OnConnectionMessagedClient(id_);
504 existing_owner->RemoveRoot(view_id); 504 existing_owner->RemoveRoot(view_id);
505 } 505 }
506 connection_manager_->Embed(id_, url, transport_view_id, spir.Pass()); 506 connection_manager_->EmbedAtView(id_, url, transport_view_id, spir.Pass());
507 callback.Run(true); 507 callback.Run(true);
508 } 508 }
509 509
510 void ViewManagerServiceImpl::DispatchOnViewInputEvent(Id transport_view_id,
511 EventPtr event) {
512 // We only allow the WM to dispatch events. At some point this function will
513 // move to a separate interface and the check can go away.
514 if (id_ != kWindowManagerConnection)
515 return;
516
517 const ViewId view_id(ViewIdFromTransportId(transport_view_id));
518
519 // If another app is embedded at this view, we forward the input event to the
520 // embedded app, rather than the app that created the view.
521 ViewManagerServiceImpl* connection =
522 connection_manager_->GetConnectionWithRoot(view_id);
523 if (!connection)
524 connection = connection_manager_->GetConnection(view_id.connection_id);
525 if (connection) {
526 connection->client()->OnViewInputEvent(
527 transport_view_id,
528 event.Pass(),
529 base::Bind(&base::DoNothing));
530 }
531 }
532
533 void ViewManagerServiceImpl::OnConnectionEstablished() { 510 void ViewManagerServiceImpl::OnConnectionEstablished() {
534 connection_manager_->AddConnection(this); 511 connection_manager_->AddConnection(this);
535 512
536 std::vector<const ServerView*> to_send; 513 std::vector<const ServerView*> to_send;
537 for (ViewIdSet::const_iterator i = roots_.begin(); i != roots_.end(); ++i) 514 for (ViewIdSet::const_iterator i = roots_.begin(); i != roots_.end(); ++i)
538 GetUnknownViewsFrom(GetView(ViewIdFromTransportId(*i)), &to_send); 515 GetUnknownViewsFrom(GetView(ViewIdFromTransportId(*i)), &to_send);
539 516
540 client()->OnEmbed(id_, 517 client()->OnEmbed(id_,
541 creator_url_, 518 creator_url_,
542 ViewToViewData(to_send.front()), 519 ViewToViewData(to_send.front()),
(...skipping 12 matching lines...) Expand all
555 532
556 bool ViewManagerServiceImpl::IsViewRootOfAnotherConnectionForAccessPolicy( 533 bool ViewManagerServiceImpl::IsViewRootOfAnotherConnectionForAccessPolicy(
557 const ServerView* view) const { 534 const ServerView* view) const {
558 ViewManagerServiceImpl* connection = 535 ViewManagerServiceImpl* connection =
559 connection_manager_->GetConnectionWithRoot(view->id()); 536 connection_manager_->GetConnectionWithRoot(view->id());
560 return connection && connection != this; 537 return connection && connection != this;
561 } 538 }
562 539
563 } // namespace service 540 } // namespace service
564 } // namespace mojo 541 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/view_manager_service_impl.h ('k') | mojo/services/view_manager/view_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698