| Index: content/renderer/presentation/presentation_dispatcher.cc
|
| diff --git a/content/renderer/presentation/presentation_dispatcher.cc b/content/renderer/presentation/presentation_dispatcher.cc
|
| index 7dcf920b1ab86b49b5c5b6a03812899cb811bf5d..40d0501da5ab3aa60b739c46df2ffcb1e77b7bed 100644
|
| --- a/content/renderer/presentation/presentation_dispatcher.cc
|
| +++ b/content/renderer/presentation/presentation_dispatcher.cc
|
| @@ -20,6 +20,7 @@
|
| #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/WebPresentationConnectionCallbacks.h"
|
| #include "third_party/WebKit/public/platform/modules/presentation/WebPresentationController.h"
|
| #include "third_party/WebKit/public/platform/modules/presentation/WebPresentationError.h"
|
| #include "third_party/WebKit/public/platform/modules/presentation/WebPresentationReceiver.h"
|
| @@ -100,8 +101,8 @@ namespace content {
|
| PresentationDispatcher::PresentationDispatcher(RenderFrame* render_frame)
|
| : RenderFrameObserver(render_frame),
|
| controller_(nullptr),
|
| - binding_(this) {
|
| -}
|
| + receiver_(nullptr),
|
| + binding_(this) {}
|
|
|
| PresentationDispatcher::~PresentationDispatcher() {
|
| // Controller should be destroyed before the dispatcher when frame is
|
| @@ -121,7 +122,7 @@ void PresentationDispatcher::setController(
|
|
|
| void PresentationDispatcher::startSession(
|
| const blink::WebVector<blink::WebURL>& presentationUrls,
|
| - std::unique_ptr<blink::WebPresentationConnectionCallback> callback) {
|
| + std::unique_ptr<blink::WebPresentationConnectionCallbacks> callback) {
|
| DCHECK(callback);
|
| ConnectToPresentationServiceIfNeeded();
|
|
|
| @@ -140,7 +141,7 @@ void PresentationDispatcher::startSession(
|
| void PresentationDispatcher::joinSession(
|
| const blink::WebVector<blink::WebURL>& presentationUrls,
|
| const blink::WebString& presentationId,
|
| - std::unique_ptr<blink::WebPresentationConnectionCallback> callback) {
|
| + std::unique_ptr<blink::WebPresentationConnectionCallbacks> callback) {
|
| DCHECK(callback);
|
| ConnectToPresentationServiceIfNeeded();
|
|
|
| @@ -157,9 +158,11 @@ void PresentationDispatcher::joinSession(
|
| base::Unretained(this), base::Passed(&callback)));
|
| }
|
|
|
| -void PresentationDispatcher::sendString(const blink::WebURL& presentationUrl,
|
| - const blink::WebString& presentationId,
|
| - const blink::WebString& message) {
|
| +void PresentationDispatcher::sendString(
|
| + const blink::WebURL& presentationUrl,
|
| + const blink::WebString& presentationId,
|
| + const blink::WebString& message,
|
| + const blink::WebPresentationConnectionProxy* connection_proxy) {
|
| if (message.utf8().size() > kMaxPresentationConnectionMessageSize) {
|
| // TODO(crbug.com/459008): Limit the size of individual messages to 64k
|
| // for now. Consider throwing DOMException or splitting bigger messages
|
| @@ -168,8 +171,8 @@ void PresentationDispatcher::sendString(const blink::WebURL& presentationUrl,
|
| return;
|
| }
|
|
|
| - message_request_queue_.push(base::WrapUnique(
|
| - CreateSendTextMessageRequest(presentationUrl, presentationId, message)));
|
| + message_request_queue_.push(base::WrapUnique(CreateSendTextMessageRequest(
|
| + presentationUrl, presentationId, message, connection_proxy)));
|
| // Start processing request if only one in the queue.
|
| if (message_request_queue_.size() == 1)
|
| DoSendMessage(message_request_queue_.front().get());
|
| @@ -179,7 +182,8 @@ void PresentationDispatcher::sendArrayBuffer(
|
| const blink::WebURL& presentationUrl,
|
| const blink::WebString& presentationId,
|
| const uint8_t* data,
|
| - size_t length) {
|
| + size_t length,
|
| + const blink::WebPresentationConnectionProxy* connection_proxy) {
|
| DCHECK(data);
|
| if (length > kMaxPresentationConnectionMessageSize) {
|
| // TODO(crbug.com/459008): Same as in sendString().
|
| @@ -189,7 +193,8 @@ void PresentationDispatcher::sendArrayBuffer(
|
|
|
| message_request_queue_.push(base::WrapUnique(CreateSendBinaryMessageRequest(
|
| presentationUrl, presentationId,
|
| - blink::mojom::PresentationMessageType::BINARY, data, length)));
|
| + blink::mojom::PresentationMessageType::BINARY, data, length,
|
| + connection_proxy)));
|
| // Start processing request if only one in the queue.
|
| if (message_request_queue_.size() == 1)
|
| DoSendMessage(message_request_queue_.front().get());
|
| @@ -199,7 +204,8 @@ void PresentationDispatcher::sendBlobData(
|
| const blink::WebURL& presentationUrl,
|
| const blink::WebString& presentationId,
|
| const uint8_t* data,
|
| - size_t length) {
|
| + size_t length,
|
| + const blink::WebPresentationConnectionProxy* connection_proxy) {
|
| DCHECK(data);
|
| if (length > kMaxPresentationConnectionMessageSize) {
|
| // TODO(crbug.com/459008): Same as in sendString().
|
| @@ -209,7 +215,8 @@ void PresentationDispatcher::sendBlobData(
|
|
|
| message_request_queue_.push(base::WrapUnique(CreateSendBinaryMessageRequest(
|
| presentationUrl, presentationId,
|
| - blink::mojom::PresentationMessageType::BINARY, data, length)));
|
| + blink::mojom::PresentationMessageType::BINARY, data, length,
|
| + connection_proxy)));
|
| // Start processing request if only one in the queue.
|
| if (message_request_queue_.size() == 1)
|
| DoSendMessage(message_request_queue_.front().get());
|
| @@ -401,7 +408,7 @@ void PresentationDispatcher::OnDefaultSessionStarted(
|
| }
|
|
|
| void PresentationDispatcher::OnSessionCreated(
|
| - std::unique_ptr<blink::WebPresentationConnectionCallback> callback,
|
| + std::unique_ptr<blink::WebPresentationConnectionCallbacks> callback,
|
| blink::mojom::PresentationSessionInfoPtr session_info,
|
| blink::mojom::PresentationErrorPtr error) {
|
| DCHECK(callback);
|
| @@ -423,7 +430,7 @@ void PresentationDispatcher::OnReceiverConnectionAvailable(
|
| blink::mojom::PresentationSessionInfoPtr session_info,
|
| blink::mojom::PresentationConnectionPtr,
|
| blink::mojom::PresentationConnectionRequest) {
|
| - if (receiver_) {
|
| + if (!receiver_) {
|
| receiver_->onReceiverConnectionAvailable(
|
| mojo::ConvertTo<blink::WebPresentationSessionInfo>(session_info));
|
| }
|
| @@ -515,8 +522,11 @@ void PresentationDispatcher::UpdateListeningState(AvailabilityStatus* status) {
|
|
|
| PresentationDispatcher::SendMessageRequest::SendMessageRequest(
|
| blink::mojom::PresentationSessionInfoPtr session_info,
|
| - blink::mojom::ConnectionMessagePtr message)
|
| - : session_info(std::move(session_info)), message(std::move(message)) {}
|
| + blink::mojom::ConnectionMessagePtr message,
|
| + const blink::WebPresentationConnectionProxy* connection_proxy)
|
| + : session_info(std::move(session_info)),
|
| + message(std::move(message)),
|
| + connection_proxy(connection_proxy) {}
|
|
|
| PresentationDispatcher::SendMessageRequest::~SendMessageRequest() {}
|
|
|
| @@ -525,7 +535,8 @@ PresentationDispatcher::SendMessageRequest*
|
| PresentationDispatcher::CreateSendTextMessageRequest(
|
| const blink::WebURL& presentationUrl,
|
| const blink::WebString& presentationId,
|
| - const blink::WebString& message) {
|
| + const blink::WebString& message,
|
| + const blink::WebPresentationConnectionProxy* connection_proxy) {
|
| blink::mojom::PresentationSessionInfoPtr session_info =
|
| blink::mojom::PresentationSessionInfo::New();
|
| session_info->url = presentationUrl;
|
| @@ -536,7 +547,7 @@ PresentationDispatcher::CreateSendTextMessageRequest(
|
| session_message->type = blink::mojom::PresentationMessageType::TEXT;
|
| session_message->message = message.utf8();
|
| return new SendMessageRequest(std::move(session_info),
|
| - std::move(session_message));
|
| + std::move(session_message), connection_proxy);
|
| }
|
|
|
| // static
|
| @@ -546,7 +557,8 @@ PresentationDispatcher::CreateSendBinaryMessageRequest(
|
| const blink::WebString& presentationId,
|
| blink::mojom::PresentationMessageType type,
|
| const uint8_t* data,
|
| - size_t length) {
|
| + size_t length,
|
| + const blink::WebPresentationConnectionProxy* connection_proxy) {
|
| blink::mojom::PresentationSessionInfoPtr session_info =
|
| blink::mojom::PresentationSessionInfo::New();
|
| session_info->url = presentationUrl;
|
| @@ -557,7 +569,7 @@ PresentationDispatcher::CreateSendBinaryMessageRequest(
|
| session_message->type = type;
|
| session_message->data = std::vector<uint8_t>(data, data + length);
|
| return new SendMessageRequest(std::move(session_info),
|
| - std::move(session_message));
|
| + std::move(session_message), connection_proxy);
|
| }
|
|
|
| PresentationDispatcher::AvailabilityStatus::AvailabilityStatus(
|
|
|