Chromium Code Reviews| Index: content/renderer/presentation/presentation_dispatcher.cc |
| diff --git a/content/renderer/presentation/presentation_dispatcher.cc b/content/renderer/presentation/presentation_dispatcher.cc |
| index 293b030a88d9bfd911a4f29983d88b82e5d1d423..9f8f0bb887028e454aabd0ca5063fa2e9eb9f6e4 100644 |
| --- a/content/renderer/presentation/presentation_dispatcher.cc |
| +++ b/content/renderer/presentation/presentation_dispatcher.cc |
| @@ -16,7 +16,7 @@ |
| #include "content/renderer/presentation/presentation_connection_client.h" |
| #include "services/shell/public/cpp/interface_provider.h" |
| #include "third_party/WebKit/public/platform/WebString.h" |
| -#include "third_party/WebKit/public/platform/WebURL.h" |
| +#include "third_party/WebKit/public/platform/WebVector.h" |
| #include "third_party/WebKit/public/platform/modules/presentation/WebPresentationAvailabilityObserver.h" |
| #include "third_party/WebKit/public/platform/modules/presentation/WebPresentationController.h" |
| #include "third_party/WebKit/public/platform/modules/presentation/WebPresentationError.h" |
| @@ -100,37 +100,50 @@ void PresentationDispatcher::setController( |
| } |
| void PresentationDispatcher::startSession( |
| - const blink::WebString& presentationUrl, |
| + const blink::WebVector<blink::WebString>& presentationUrls, |
| blink::WebPresentationConnectionClientCallbacks* callback) { |
| DCHECK(callback); |
| ConnectToPresentationServiceIfNeeded(); |
| + std::vector<url::mojom::UrlPtr> urls(presentationUrls.size()); |
| + std::transform(presentationUrls.begin(), presentationUrls.end(), urls.begin(), |
| + [](const blink::WebString& url) { |
| + url::mojom::UrlPtr mojo_url = url::mojom::Url::New(); |
| + mojo_url->url = url.utf8(); |
| + return mojo_url; |
| + }); |
| + |
| // The dispatcher owns the service so |this| will be valid when |
| // OnSessionCreated() is called. |callback| needs to be alive and also needs |
| // to be destroyed so we transfer its ownership to the mojo callback. |
| presentation_service_->StartSession( |
| - presentationUrl.utf8(), |
| + std::move(urls), |
| base::Bind(&PresentationDispatcher::OnSessionCreated, |
| - base::Unretained(this), |
| - base::Owned(callback))); |
| + base::Unretained(this), base::Owned(callback))); |
| } |
| void PresentationDispatcher::joinSession( |
| - const blink::WebString& presentationUrl, |
| + const blink::WebVector<blink::WebString>& presentationUrls, |
| const blink::WebString& presentationId, |
| blink::WebPresentationConnectionClientCallbacks* callback) { |
| DCHECK(callback); |
| ConnectToPresentationServiceIfNeeded(); |
| + std::vector<url::mojom::UrlPtr> urls(presentationUrls.size()); |
| + std::transform(presentationUrls.begin(), presentationUrls.end(), urls.begin(), |
| + [](const blink::WebString& url) { |
| + url::mojom::UrlPtr mojo_url = url::mojom::Url::New(); |
| + mojo_url->url = url.utf8(); |
| + return mojo_url; |
| + }); |
| + |
| // The dispatcher owns the service so |this| will be valid when |
| // OnSessionCreated() is called. |callback| needs to be alive and also needs |
| // to be destroyed so we transfer its ownership to the mojo callback. |
| presentation_service_->JoinSession( |
| - presentationUrl.utf8(), |
| - presentationId.utf8(), |
| + std::move(urls), presentationId.utf8(), |
| base::Bind(&PresentationDispatcher::OnSessionCreated, |
| - base::Unretained(this), |
| - base::Owned(callback))); |
| + base::Unretained(this), base::Owned(callback))); |
| } |
| void PresentationDispatcher::sendString( |
| @@ -227,8 +240,10 @@ void PresentationDispatcher::closeSession( |
| const blink::WebString& presentationId) { |
| ConnectToPresentationServiceIfNeeded(); |
| - presentation_service_->CloseConnection(presentationUrl.utf8(), |
| - presentationId.utf8()); |
| + url::mojom::UrlPtr url = url::mojom::Url::New(); |
| + url->url = presentationUrl.utf8(); |
| + |
| + presentation_service_->CloseConnection(std::move(url), presentationId.utf8()); |
| } |
| void PresentationDispatcher::terminateSession( |
| @@ -236,8 +251,10 @@ void PresentationDispatcher::terminateSession( |
| const blink::WebString& presentationId) { |
| ConnectToPresentationServiceIfNeeded(); |
| - presentation_service_->Terminate(presentationUrl.utf8(), |
| - presentationId.utf8()); |
| + url::mojom::UrlPtr url = url::mojom::Url::New(); |
| + url->url = presentationUrl.utf8(); |
| + |
| + presentation_service_->Terminate(std::move(url), presentationId.utf8()); |
| } |
| void PresentationDispatcher::getAvailability( |
| @@ -290,10 +307,18 @@ void PresentationDispatcher::stopListening( |
| UpdateListeningState(status_it->second.get()); |
| } |
| -void PresentationDispatcher::setDefaultPresentationUrl( |
| - const blink::WebString& url) { |
| +void PresentationDispatcher::setDefaultPresentationUrls( |
| + const blink::WebVector<blink::WebString>& presentationUrls) { |
| ConnectToPresentationServiceIfNeeded(); |
| - presentation_service_->SetDefaultPresentationURL(url.utf8()); |
| + |
| + std::vector<url::mojom::UrlPtr> urls(presentationUrls.size()); |
| + std::transform(presentationUrls.begin(), presentationUrls.end(), urls.begin(), |
| + [](const blink::WebString& url) { |
| + url::mojom::UrlPtr mojo_url = url::mojom::Url::New(); |
| + mojo_url->url = url.utf8(); |
| + return mojo_url; |
| + }); |
| + presentation_service_->SetDefaultPresentationUrls(std::move(urls)); |
| } |
| void PresentationDispatcher::DidCommitProvisionalLoad( |
| @@ -313,9 +338,9 @@ void PresentationDispatcher::OnDestruct() { |
| delete this; |
| } |
| -void PresentationDispatcher::OnScreenAvailabilityUpdated(const std::string& url, |
| +void PresentationDispatcher::OnScreenAvailabilityUpdated(url::mojom::UrlPtr url, |
| bool available) { |
| - auto status_it = availability_status_.find(url); |
| + auto status_it = availability_status_.find(url->url); |
| if (status_it == availability_status_.end()) |
| return; |
| AvailabilityStatus* status = status_it->second.get(); |
| @@ -337,8 +362,8 @@ void PresentationDispatcher::OnScreenAvailabilityUpdated(const std::string& url, |
| } |
| void PresentationDispatcher::OnScreenAvailabilityNotSupported( |
| - const std::string& url) { |
| - auto status_it = availability_status_.find(url); |
| + url::mojom::UrlPtr url) { |
| + auto status_it = availability_status_.find(url->url); |
| if (status_it == availability_status_.end()) |
| return; |
| AvailabilityStatus* status = status_it->second.get(); |
| @@ -426,7 +451,8 @@ void PresentationDispatcher::OnSessionMessagesReceived( |
| // Note: Passing batches of messages to the Blink layer would be more |
| // efficient. |
| std::unique_ptr<PresentationConnectionClient> session_client( |
| - new PresentationConnectionClient(session_info->url, session_info->id)); |
| + new PresentationConnectionClient(session_info->url->url, |
| + session_info->id)); |
| switch (messages[i]->type) { |
| case blink::mojom::PresentationMessageType::TEXT: { |
| // TODO(mfoltz): Do we need to DCHECK(messages[i]->message)? |
| @@ -468,12 +494,14 @@ void PresentationDispatcher::UpdateListeningState(AvailabilityStatus* status) { |
| return; |
| ConnectToPresentationServiceIfNeeded(); |
| + url::mojom::UrlPtr url = url::mojom::Url::New(); |
| + url->url = status->url; |
| if (should_listen) { |
| status->listening_state = ListeningState::WAITING; |
| - presentation_service_->ListenForScreenAvailability(status->url); |
| + presentation_service_->ListenForScreenAvailability(std::move(url)); |
| } else { |
| status->listening_state = ListeningState::INACTIVE; |
| - presentation_service_->StopListeningForScreenAvailability(status->url); |
| + presentation_service_->StopListeningForScreenAvailability(std::move(url)); |
| } |
| } |
| @@ -492,7 +520,9 @@ PresentationDispatcher::CreateSendTextMessageRequest( |
| const blink::WebString& message) { |
| blink::mojom::PresentationSessionInfoPtr session_info = |
| blink::mojom::PresentationSessionInfo::New(); |
| - session_info->url = presentationUrl.utf8(); |
| + url::mojom::UrlPtr url = url::mojom::Url::New(); |
| + url->url = presentationUrl.utf8(); |
| + session_info->url = std::move(url); |
| session_info->id = presentationId.utf8(); |
| blink::mojom::SessionMessagePtr session_message = |
| @@ -513,7 +543,9 @@ PresentationDispatcher::CreateSendBinaryMessageRequest( |
| size_t length) { |
| blink::mojom::PresentationSessionInfoPtr session_info = |
| blink::mojom::PresentationSessionInfo::New(); |
| - session_info->url = presentationUrl.utf8(); |
| + url::mojom::UrlPtr url = url::mojom::Url::New(); |
|
dcheng
2016/08/24 22:14:19
What's the status on typemapping? We shouldn't hav
mark a. foltz
2016/08/24 22:37:11
Sorry I don't understand the question. The revise
dcheng
2016/08/24 23:12:17
At this point, it's quite unusual to use the raw m
mark a. foltz
2016/08/29 23:54:54
Now passing GURL into all the Mojo interfaces.
|
| + url->url = presentationUrl.utf8(); |
| + session_info->url = std::move(url); |
| session_info->id = presentationId.utf8(); |
| blink::mojom::SessionMessagePtr session_message = |