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

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

Issue 707633005: Minor cleanup of ViewManagerServiceImpl (Closed) Base URL: https://github.com/domokit/mojo.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
« no previous file with comments | « mojo/services/view_manager/view_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/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 "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "mojo/converters/geometry/geometry_type_converters.h" 9 #include "mojo/converters/geometry/geometry_type_converters.h"
10 #include "mojo/converters/input_events/input_events_type_converters.h" 10 #include "mojo/converters/input_events/input_events_type_converters.h"
11 #include "mojo/converters/surfaces/surfaces_type_converters.h" 11 #include "mojo/converters/surfaces/surfaces_type_converters.h"
12 #include "mojo/services/view_manager/connection_manager.h" 12 #include "mojo/services/view_manager/connection_manager.h"
13 #include "mojo/services/view_manager/default_access_policy.h" 13 #include "mojo/services/view_manager/default_access_policy.h"
14 #include "mojo/services/view_manager/server_view.h" 14 #include "mojo/services/view_manager/server_view.h"
15 #include "mojo/services/view_manager/window_manager_access_policy.h" 15 #include "mojo/services/view_manager/window_manager_access_policy.h"
16 16
17 namespace mojo { 17 namespace mojo {
18 namespace service { 18 namespace service {
19 19
20 ViewManagerServiceImpl::ViewManagerServiceImpl( 20 ViewManagerServiceImpl::ViewManagerServiceImpl(
21 ConnectionManager* connection_manager, 21 ConnectionManager* connection_manager,
22 ConnectionSpecificId creator_id, 22 ConnectionSpecificId creator_id,
23 const std::string& creator_url, 23 const std::string& creator_url,
24 const std::string& url, 24 const std::string& url,
25 const ViewId& root_id, 25 const ViewId& root_id)
26 InterfaceRequest<ServiceProvider> service_provider)
27 : connection_manager_(connection_manager), 26 : connection_manager_(connection_manager),
28 id_(connection_manager_->GetAndAdvanceNextConnectionId()), 27 id_(connection_manager_->GetAndAdvanceNextConnectionId()),
29 url_(url), 28 url_(url),
30 creator_id_(creator_id), 29 creator_id_(creator_id),
31 creator_url_(creator_url), 30 creator_url_(creator_url) {
32 service_provider_(service_provider.Pass()) {
33 CHECK(GetView(root_id)); 31 CHECK(GetView(root_id));
34 root_.reset(new ViewId(root_id)); 32 root_.reset(new ViewId(root_id));
35 if (root_id == RootViewId()) 33 if (root_id == RootViewId())
36 access_policy_.reset(new WindowManagerAccessPolicy(id_, this)); 34 access_policy_.reset(new WindowManagerAccessPolicy(id_, this));
37 else 35 else
38 access_policy_.reset(new DefaultAccessPolicy(id_, this)); 36 access_policy_.reset(new DefaultAccessPolicy(id_, this));
39 } 37 }
40 38
41 ViewManagerServiceImpl::~ViewManagerServiceImpl() { 39 ViewManagerServiceImpl::~ViewManagerServiceImpl() {
42 DestroyViews(); 40 DestroyViews();
43 } 41 }
44 42
43 void ViewManagerServiceImpl::Init(
44 InterfaceRequest<ServiceProvider> service_provider) {
45 std::vector<const ServerView*> to_send;
46 if (root_.get())
47 GetUnknownViewsFrom(GetView(*root_), &to_send);
48
49 MessagePipe pipe;
50 connection_manager_->wm_internal()->CreateWindowManagerForViewManagerClient(
51 id_, pipe.handle1.Pass());
52 client()->OnEmbed(id_,
53 creator_url_,
54 ViewToViewData(to_send.front()),
55 service_provider.Pass(),
56 pipe.handle0.Pass());
57 }
58
45 const ServerView* ViewManagerServiceImpl::GetView(const ViewId& id) const { 59 const ServerView* ViewManagerServiceImpl::GetView(const ViewId& id) const {
46 if (id_ == id.connection_id) { 60 if (id_ == id.connection_id) {
47 ViewMap::const_iterator i = view_map_.find(id.view_id); 61 ViewMap::const_iterator i = view_map_.find(id.view_id);
48 return i == view_map_.end() ? NULL : i->second; 62 return i == view_map_.end() ? NULL : i->second;
49 } 63 }
50 return connection_manager_->GetView(id); 64 return connection_manager_->GetView(id);
51 } 65 }
52 66
53 bool ViewManagerServiceImpl::IsRoot(const ViewId& id) const { 67 bool ViewManagerServiceImpl::IsRoot(const ViewId& id) const {
54 return root_.get() && *root_ == id; 68 return root_.get() && *root_ == id;
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 RemoveChildrenAsPartOfEmbed(view_id); 557 RemoveChildrenAsPartOfEmbed(view_id);
544 if (existing_owner) { 558 if (existing_owner) {
545 // Never message the originating connection. 559 // Never message the originating connection.
546 connection_manager_->OnConnectionMessagedClient(id_); 560 connection_manager_->OnConnectionMessagedClient(id_);
547 existing_owner->RemoveRoot(); 561 existing_owner->RemoveRoot();
548 } 562 }
549 connection_manager_->EmbedAtView(id_, url, transport_view_id, spir.Pass()); 563 connection_manager_->EmbedAtView(id_, url, transport_view_id, spir.Pass());
550 callback.Run(true); 564 callback.Run(true);
551 } 565 }
552 566
553 void ViewManagerServiceImpl::OnConnectionEstablished() {
554 std::vector<const ServerView*> to_send;
555 if (root_.get())
556 GetUnknownViewsFrom(GetView(*root_), &to_send);
557
558 MessagePipe pipe;
559 connection_manager_->wm_internal()->CreateWindowManagerForViewManagerClient(
560 id_, pipe.handle1.Pass());
561 client()->OnEmbed(id_,
562 creator_url_,
563 ViewToViewData(to_send.front()),
564 service_provider_.Pass(),
565 pipe.handle0.Pass());
566 }
567
568 bool ViewManagerServiceImpl::IsRootForAccessPolicy(const ViewId& id) const { 567 bool ViewManagerServiceImpl::IsRootForAccessPolicy(const ViewId& id) const {
569 return IsRoot(id); 568 return IsRoot(id);
570 } 569 }
571 570
572 bool ViewManagerServiceImpl::IsViewKnownForAccessPolicy( 571 bool ViewManagerServiceImpl::IsViewKnownForAccessPolicy(
573 const ServerView* view) const { 572 const ServerView* view) const {
574 return IsViewKnown(view); 573 return IsViewKnown(view);
575 } 574 }
576 575
577 bool ViewManagerServiceImpl::IsViewRootOfAnotherConnectionForAccessPolicy( 576 bool ViewManagerServiceImpl::IsViewRootOfAnotherConnectionForAccessPolicy(
578 const ServerView* view) const { 577 const ServerView* view) const {
579 ViewManagerServiceImpl* connection = 578 ViewManagerServiceImpl* connection =
580 connection_manager_->GetConnectionWithRoot(view->id()); 579 connection_manager_->GetConnectionWithRoot(view->id());
581 return connection && connection != this; 580 return connection && connection != this;
582 } 581 }
583 582
584 } // namespace service 583 } // namespace service
585 } // namespace mojo 584 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/view_manager_service_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698