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 "components/view_manager/view_manager_service_impl.h" | 5 #include "components/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 "components/view_manager/connection_manager.h" | 9 #include "components/view_manager/connection_manager.h" |
10 #include "components/view_manager/default_access_policy.h" | 10 #include "components/view_manager/default_access_policy.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 ServerView* view = GetView(view_id); | 135 ServerView* view = GetView(view_id); |
136 if (!view || view->visible() == visible || | 136 if (!view || view->visible() == visible || |
137 !access_policy_->CanChangeViewVisibility(view)) { | 137 !access_policy_->CanChangeViewVisibility(view)) { |
138 return false; | 138 return false; |
139 } | 139 } |
140 ConnectionManager::ScopedChange change(this, connection_manager_, false); | 140 ConnectionManager::ScopedChange change(this, connection_manager_, false); |
141 view->SetVisible(visible); | 141 view->SetVisible(visible); |
142 return true; | 142 return true; |
143 } | 143 } |
144 | 144 |
145 bool ViewManagerServiceImpl::EmbedUrl( | 145 bool ViewManagerServiceImpl::EmbedRequest( |
146 const std::string& url, | 146 mojo::URLRequestPtr request, |
147 const ViewId& view_id, | 147 const ViewId& view_id, |
148 InterfaceRequest<ServiceProvider> services, | 148 InterfaceRequest<ServiceProvider> services, |
149 ServiceProviderPtr exposed_services) { | 149 ServiceProviderPtr exposed_services) { |
150 if (!PrepareForEmbed(view_id)) | 150 if (!PrepareForEmbed(view_id)) |
151 return false; | 151 return false; |
152 connection_manager_->EmbedAtView(id_, url, view_id, services.Pass(), | 152 connection_manager_->EmbedAtView(id_, request.Pass(), view_id, |
153 exposed_services.Pass()); | 153 services.Pass(), exposed_services.Pass()); |
154 return true; | 154 return true; |
155 } | 155 } |
156 | 156 |
157 bool ViewManagerServiceImpl::Embed(const ViewId& view_id, | 157 bool ViewManagerServiceImpl::Embed(const ViewId& view_id, |
158 mojo::ViewManagerClientPtr client) { | 158 mojo::ViewManagerClientPtr client) { |
159 if (!client.get() || !PrepareForEmbed(view_id)) | 159 if (!client.get() || !PrepareForEmbed(view_id)) |
160 return false; | 160 return false; |
161 connection_manager_->EmbedAtView(id_, view_id, client.Pass()); | 161 connection_manager_->EmbedAtView(id_, view_id, client.Pass()); |
162 return true; | 162 return true; |
163 } | 163 } |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 if (value.is_null()) { | 615 if (value.is_null()) { |
616 view->SetProperty(name, nullptr); | 616 view->SetProperty(name, nullptr); |
617 } else { | 617 } else { |
618 std::vector<uint8_t> data = value.To<std::vector<uint8_t>>(); | 618 std::vector<uint8_t> data = value.To<std::vector<uint8_t>>(); |
619 view->SetProperty(name, &data); | 619 view->SetProperty(name, &data); |
620 } | 620 } |
621 } | 621 } |
622 callback.Run(success); | 622 callback.Run(success); |
623 } | 623 } |
624 | 624 |
625 void ViewManagerServiceImpl::EmbedUrl( | 625 void ViewManagerServiceImpl::EmbedRequest( |
626 const String& url, | 626 mojo::URLRequestPtr request, |
627 Id transport_view_id, | 627 Id transport_view_id, |
628 InterfaceRequest<ServiceProvider> services, | 628 InterfaceRequest<ServiceProvider> services, |
629 ServiceProviderPtr exposed_services, | 629 ServiceProviderPtr exposed_services, |
630 const Callback<void(bool)>& callback) { | 630 const Callback<void(bool)>& callback) { |
631 callback.Run(EmbedUrl(url.To<std::string>(), | 631 callback.Run(EmbedRequest(request.Pass(), |
632 ViewIdFromTransportId(transport_view_id), | 632 ViewIdFromTransportId(transport_view_id), |
633 services.Pass(), exposed_services.Pass())); | 633 services.Pass(), exposed_services.Pass())); |
634 } | 634 } |
635 | 635 |
636 void ViewManagerServiceImpl::Embed(mojo::Id transport_view_id, | 636 void ViewManagerServiceImpl::Embed(mojo::Id transport_view_id, |
637 mojo::ViewManagerClientPtr client, | 637 mojo::ViewManagerClientPtr client, |
638 const mojo::Callback<void(bool)>& callback) { | 638 const mojo::Callback<void(bool)>& callback) { |
639 callback.Run(Embed(ViewIdFromTransportId(transport_view_id), client.Pass())); | 639 callback.Run(Embed(ViewIdFromTransportId(transport_view_id), client.Pass())); |
640 } | 640 } |
641 | 641 |
642 void ViewManagerServiceImpl::SetFocus(uint32_t view_id, | 642 void ViewManagerServiceImpl::SetFocus(uint32_t view_id, |
643 const SetFocusCallback& callback) { | 643 const SetFocusCallback& callback) { |
(...skipping 17 matching lines...) Expand all Loading... |
661 } | 661 } |
662 | 662 |
663 bool ViewManagerServiceImpl::IsViewRootOfAnotherConnectionForAccessPolicy( | 663 bool ViewManagerServiceImpl::IsViewRootOfAnotherConnectionForAccessPolicy( |
664 const ServerView* view) const { | 664 const ServerView* view) const { |
665 ViewManagerServiceImpl* connection = | 665 ViewManagerServiceImpl* connection = |
666 connection_manager_->GetConnectionWithRoot(view->id()); | 666 connection_manager_->GetConnectionWithRoot(view->id()); |
667 return connection && connection != this; | 667 return connection && connection != this; |
668 } | 668 } |
669 | 669 |
670 } // namespace view_manager | 670 } // namespace view_manager |
OLD | NEW |