Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/renderer/presentation/presentation_dispatcher.h" | 5 #include "content/renderer/presentation/presentation_dispatcher.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "content/public/common/presentation_constants.h" | 14 #include "content/public/common/presentation_constants.h" |
| 15 #include "content/public/renderer/render_frame.h" | 15 #include "content/public/renderer/render_frame.h" |
| 16 #include "content/renderer/presentation/presentation_connection_client.h" | 16 #include "content/renderer/presentation/presentation_connection_client.h" |
| 17 #include "services/shell/public/cpp/interface_provider.h" | 17 #include "services/shell/public/cpp/interface_provider.h" |
| 18 #include "third_party/WebKit/public/platform/WebString.h" | 18 #include "third_party/WebKit/public/platform/WebString.h" |
| 19 #include "third_party/WebKit/public/platform/WebURL.h" | 19 #include "third_party/WebKit/public/platform/WebVector.h" |
| 20 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nAvailabilityObserver.h" | 20 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nAvailabilityObserver.h" |
| 21 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nController.h" | 21 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nController.h" |
| 22 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nError.h" | 22 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nError.h" |
| 23 #include "third_party/WebKit/public/platform/modules/presentation/presentation.m ojom.h" | 23 #include "third_party/WebKit/public/platform/modules/presentation/presentation.m ojom.h" |
| 24 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 24 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 25 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 blink::WebPresentationError::ErrorType GetWebPresentationErrorTypeFromMojo( | 29 blink::WebPresentationError::ErrorType GetWebPresentationErrorTypeFromMojo( |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 blink::WebPresentationController* controller) { | 93 blink::WebPresentationController* controller) { |
| 94 // There shouldn't be any swapping from one non-null controller to another. | 94 // There shouldn't be any swapping from one non-null controller to another. |
| 95 DCHECK(controller != controller_ && (!controller || !controller_)); | 95 DCHECK(controller != controller_ && (!controller || !controller_)); |
| 96 controller_ = controller; | 96 controller_ = controller; |
| 97 // The controller is set to null when the frame is about to be detached. | 97 // The controller is set to null when the frame is about to be detached. |
| 98 // Nothing is listening for screen availability anymore but the Mojo service | 98 // Nothing is listening for screen availability anymore but the Mojo service |
| 99 // will know about the frame being detached anyway. | 99 // will know about the frame being detached anyway. |
| 100 } | 100 } |
| 101 | 101 |
| 102 void PresentationDispatcher::startSession( | 102 void PresentationDispatcher::startSession( |
| 103 const blink::WebString& presentationUrl, | 103 const blink::WebVector<blink::WebString>& presentationUrls, |
| 104 blink::WebPresentationConnectionClientCallbacks* callback) { | 104 blink::WebPresentationConnectionClientCallbacks* callback) { |
| 105 DCHECK(callback); | 105 DCHECK(callback); |
| 106 ConnectToPresentationServiceIfNeeded(); | 106 ConnectToPresentationServiceIfNeeded(); |
| 107 | 107 |
| 108 std::vector<url::mojom::UrlPtr> urls(presentationUrls.size()); | |
| 109 std::transform(presentationUrls.begin(), presentationUrls.end(), urls.begin(), | |
| 110 [](const blink::WebString& url) { | |
| 111 url::mojom::UrlPtr mojo_url = url::mojom::Url::New(); | |
| 112 mojo_url->url = url.utf8(); | |
| 113 return mojo_url; | |
| 114 }); | |
| 115 | |
| 108 // The dispatcher owns the service so |this| will be valid when | 116 // The dispatcher owns the service so |this| will be valid when |
| 109 // OnSessionCreated() is called. |callback| needs to be alive and also needs | 117 // OnSessionCreated() is called. |callback| needs to be alive and also needs |
| 110 // to be destroyed so we transfer its ownership to the mojo callback. | 118 // to be destroyed so we transfer its ownership to the mojo callback. |
| 111 presentation_service_->StartSession( | 119 presentation_service_->StartSession( |
| 112 presentationUrl.utf8(), | 120 std::move(urls), |
| 113 base::Bind(&PresentationDispatcher::OnSessionCreated, | 121 base::Bind(&PresentationDispatcher::OnSessionCreated, |
| 114 base::Unretained(this), | 122 base::Unretained(this), base::Owned(callback))); |
| 115 base::Owned(callback))); | |
| 116 } | 123 } |
| 117 | 124 |
| 118 void PresentationDispatcher::joinSession( | 125 void PresentationDispatcher::joinSession( |
| 119 const blink::WebString& presentationUrl, | 126 const blink::WebVector<blink::WebString>& presentationUrls, |
| 120 const blink::WebString& presentationId, | 127 const blink::WebString& presentationId, |
| 121 blink::WebPresentationConnectionClientCallbacks* callback) { | 128 blink::WebPresentationConnectionClientCallbacks* callback) { |
| 122 DCHECK(callback); | 129 DCHECK(callback); |
| 123 ConnectToPresentationServiceIfNeeded(); | 130 ConnectToPresentationServiceIfNeeded(); |
| 124 | 131 |
| 132 std::vector<url::mojom::UrlPtr> urls(presentationUrls.size()); | |
| 133 std::transform(presentationUrls.begin(), presentationUrls.end(), urls.begin(), | |
| 134 [](const blink::WebString& url) { | |
| 135 url::mojom::UrlPtr mojo_url = url::mojom::Url::New(); | |
| 136 mojo_url->url = url.utf8(); | |
| 137 return mojo_url; | |
| 138 }); | |
| 139 | |
| 125 // The dispatcher owns the service so |this| will be valid when | 140 // The dispatcher owns the service so |this| will be valid when |
| 126 // OnSessionCreated() is called. |callback| needs to be alive and also needs | 141 // OnSessionCreated() is called. |callback| needs to be alive and also needs |
| 127 // to be destroyed so we transfer its ownership to the mojo callback. | 142 // to be destroyed so we transfer its ownership to the mojo callback. |
| 128 presentation_service_->JoinSession( | 143 presentation_service_->JoinSession( |
| 129 presentationUrl.utf8(), | 144 std::move(urls), presentationId.utf8(), |
| 130 presentationId.utf8(), | |
| 131 base::Bind(&PresentationDispatcher::OnSessionCreated, | 145 base::Bind(&PresentationDispatcher::OnSessionCreated, |
| 132 base::Unretained(this), | 146 base::Unretained(this), base::Owned(callback))); |
| 133 base::Owned(callback))); | |
| 134 } | 147 } |
| 135 | 148 |
| 136 void PresentationDispatcher::sendString( | 149 void PresentationDispatcher::sendString( |
| 137 const blink::WebString& presentationUrl, | 150 const blink::WebString& presentationUrl, |
| 138 const blink::WebString& presentationId, | 151 const blink::WebString& presentationId, |
| 139 const blink::WebString& message) { | 152 const blink::WebString& message) { |
| 140 if (message.utf8().size() > kMaxPresentationSessionMessageSize) { | 153 if (message.utf8().size() > kMaxPresentationSessionMessageSize) { |
| 141 // TODO(crbug.com/459008): Limit the size of individual messages to 64k | 154 // TODO(crbug.com/459008): Limit the size of individual messages to 64k |
| 142 // for now. Consider throwing DOMException or splitting bigger messages | 155 // for now. Consider throwing DOMException or splitting bigger messages |
| 143 // into smaller chunks later. | 156 // into smaller chunks later. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 if (!message_request_queue_.empty()) { | 233 if (!message_request_queue_.empty()) { |
| 221 DoSendMessage(message_request_queue_.front().get()); | 234 DoSendMessage(message_request_queue_.front().get()); |
| 222 } | 235 } |
| 223 } | 236 } |
| 224 | 237 |
| 225 void PresentationDispatcher::closeSession( | 238 void PresentationDispatcher::closeSession( |
| 226 const blink::WebString& presentationUrl, | 239 const blink::WebString& presentationUrl, |
| 227 const blink::WebString& presentationId) { | 240 const blink::WebString& presentationId) { |
| 228 ConnectToPresentationServiceIfNeeded(); | 241 ConnectToPresentationServiceIfNeeded(); |
| 229 | 242 |
| 230 presentation_service_->CloseConnection(presentationUrl.utf8(), | 243 url::mojom::UrlPtr url = url::mojom::Url::New(); |
| 231 presentationId.utf8()); | 244 url->url = presentationUrl.utf8(); |
| 245 | |
| 246 presentation_service_->CloseConnection(std::move(url), presentationId.utf8()); | |
| 232 } | 247 } |
| 233 | 248 |
| 234 void PresentationDispatcher::terminateSession( | 249 void PresentationDispatcher::terminateSession( |
| 235 const blink::WebString& presentationUrl, | 250 const blink::WebString& presentationUrl, |
| 236 const blink::WebString& presentationId) { | 251 const blink::WebString& presentationId) { |
| 237 ConnectToPresentationServiceIfNeeded(); | 252 ConnectToPresentationServiceIfNeeded(); |
| 238 | 253 |
| 239 presentation_service_->Terminate(presentationUrl.utf8(), | 254 url::mojom::UrlPtr url = url::mojom::Url::New(); |
| 240 presentationId.utf8()); | 255 url->url = presentationUrl.utf8(); |
| 256 | |
| 257 presentation_service_->Terminate(std::move(url), presentationId.utf8()); | |
| 241 } | 258 } |
| 242 | 259 |
| 243 void PresentationDispatcher::getAvailability( | 260 void PresentationDispatcher::getAvailability( |
| 244 const blink::WebString& availabilityUrl, | 261 const blink::WebString& availabilityUrl, |
| 245 blink::WebPresentationAvailabilityCallbacks* callbacks) { | 262 blink::WebPresentationAvailabilityCallbacks* callbacks) { |
| 246 const std::string& availability_url = availabilityUrl.utf8(); | 263 const std::string& availability_url = availabilityUrl.utf8(); |
| 247 AvailabilityStatus* status = nullptr; | 264 AvailabilityStatus* status = nullptr; |
| 248 auto status_it = availability_status_.find(availability_url); | 265 auto status_it = availability_status_.find(availability_url); |
| 249 if (status_it == availability_status_.end()) { | 266 if (status_it == availability_status_.end()) { |
| 250 status = new AvailabilityStatus(availability_url); | 267 status = new AvailabilityStatus(availability_url); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 auto status_it = availability_status_.find(availability_url); | 300 auto status_it = availability_status_.find(availability_url); |
| 284 if (status_it == availability_status_.end()) { | 301 if (status_it == availability_status_.end()) { |
| 285 DLOG(WARNING) << "Stop listening for availability for unknown URL " | 302 DLOG(WARNING) << "Stop listening for availability for unknown URL " |
| 286 << availability_url; | 303 << availability_url; |
| 287 return; | 304 return; |
| 288 } | 305 } |
| 289 status_it->second->availability_observers.erase(observer); | 306 status_it->second->availability_observers.erase(observer); |
| 290 UpdateListeningState(status_it->second.get()); | 307 UpdateListeningState(status_it->second.get()); |
| 291 } | 308 } |
| 292 | 309 |
| 293 void PresentationDispatcher::setDefaultPresentationUrl( | 310 void PresentationDispatcher::setDefaultPresentationUrls( |
| 294 const blink::WebString& url) { | 311 const blink::WebVector<blink::WebString>& presentationUrls) { |
| 295 ConnectToPresentationServiceIfNeeded(); | 312 ConnectToPresentationServiceIfNeeded(); |
| 296 presentation_service_->SetDefaultPresentationURL(url.utf8()); | 313 |
| 314 std::vector<url::mojom::UrlPtr> urls(presentationUrls.size()); | |
| 315 std::transform(presentationUrls.begin(), presentationUrls.end(), urls.begin(), | |
| 316 [](const blink::WebString& url) { | |
| 317 url::mojom::UrlPtr mojo_url = url::mojom::Url::New(); | |
| 318 mojo_url->url = url.utf8(); | |
| 319 return mojo_url; | |
| 320 }); | |
| 321 presentation_service_->SetDefaultPresentationUrls(std::move(urls)); | |
| 297 } | 322 } |
| 298 | 323 |
| 299 void PresentationDispatcher::DidCommitProvisionalLoad( | 324 void PresentationDispatcher::DidCommitProvisionalLoad( |
| 300 bool is_new_navigation, | 325 bool is_new_navigation, |
| 301 bool is_same_page_navigation) { | 326 bool is_same_page_navigation) { |
| 302 blink::WebFrame* frame = render_frame()->GetWebFrame(); | 327 blink::WebFrame* frame = render_frame()->GetWebFrame(); |
| 303 // If not top-level navigation. | 328 // If not top-level navigation. |
| 304 if (frame->parent() || is_same_page_navigation) | 329 if (frame->parent() || is_same_page_navigation) |
| 305 return; | 330 return; |
| 306 | 331 |
| 307 // Remove all pending send message requests. | 332 // Remove all pending send message requests. |
| 308 MessageRequestQueue empty; | 333 MessageRequestQueue empty; |
| 309 std::swap(message_request_queue_, empty); | 334 std::swap(message_request_queue_, empty); |
| 310 } | 335 } |
| 311 | 336 |
| 312 void PresentationDispatcher::OnDestruct() { | 337 void PresentationDispatcher::OnDestruct() { |
| 313 delete this; | 338 delete this; |
| 314 } | 339 } |
| 315 | 340 |
| 316 void PresentationDispatcher::OnScreenAvailabilityUpdated(const std::string& url, | 341 void PresentationDispatcher::OnScreenAvailabilityUpdated(url::mojom::UrlPtr url, |
| 317 bool available) { | 342 bool available) { |
| 318 auto status_it = availability_status_.find(url); | 343 auto status_it = availability_status_.find(url->url); |
| 319 if (status_it == availability_status_.end()) | 344 if (status_it == availability_status_.end()) |
| 320 return; | 345 return; |
| 321 AvailabilityStatus* status = status_it->second.get(); | 346 AvailabilityStatus* status = status_it->second.get(); |
| 322 DCHECK(status); | 347 DCHECK(status); |
| 323 | 348 |
| 324 if (status->listening_state == ListeningState::WAITING) | 349 if (status->listening_state == ListeningState::WAITING) |
| 325 status->listening_state = ListeningState::ACTIVE; | 350 status->listening_state = ListeningState::ACTIVE; |
| 326 | 351 |
| 327 for (auto* observer : status->availability_observers) | 352 for (auto* observer : status->availability_observers) |
| 328 observer->availabilityChanged(available); | 353 observer->availabilityChanged(available); |
| 329 | 354 |
| 330 for (AvailabilityCallbacksMap::iterator iter(&status->availability_callbacks); | 355 for (AvailabilityCallbacksMap::iterator iter(&status->availability_callbacks); |
| 331 !iter.IsAtEnd(); iter.Advance()) { | 356 !iter.IsAtEnd(); iter.Advance()) { |
| 332 iter.GetCurrentValue()->onSuccess(available); | 357 iter.GetCurrentValue()->onSuccess(available); |
| 333 } | 358 } |
| 334 status->last_known_availability = available; | 359 status->last_known_availability = available; |
| 335 status->availability_callbacks.Clear(); | 360 status->availability_callbacks.Clear(); |
| 336 UpdateListeningState(status); | 361 UpdateListeningState(status); |
| 337 } | 362 } |
| 338 | 363 |
| 339 void PresentationDispatcher::OnScreenAvailabilityNotSupported( | 364 void PresentationDispatcher::OnScreenAvailabilityNotSupported( |
| 340 const std::string& url) { | 365 url::mojom::UrlPtr url) { |
| 341 auto status_it = availability_status_.find(url); | 366 auto status_it = availability_status_.find(url->url); |
| 342 if (status_it == availability_status_.end()) | 367 if (status_it == availability_status_.end()) |
| 343 return; | 368 return; |
| 344 AvailabilityStatus* status = status_it->second.get(); | 369 AvailabilityStatus* status = status_it->second.get(); |
| 345 DCHECK(status); | 370 DCHECK(status); |
| 346 DCHECK(status->listening_state == ListeningState::WAITING); | 371 DCHECK(status->listening_state == ListeningState::WAITING); |
| 347 | 372 |
| 348 const blink::WebString& not_supported_error = blink::WebString::fromUTF8( | 373 const blink::WebString& not_supported_error = blink::WebString::fromUTF8( |
| 349 "getAvailability() isn't supported at the moment. It can be due to " | 374 "getAvailability() isn't supported at the moment. It can be due to " |
| 350 "a permanent or temporary system limitation. It is recommended to " | 375 "a permanent or temporary system limitation. It is recommended to " |
| 351 "try to blindly start a session in that case."); | 376 "try to blindly start a session in that case."); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 void PresentationDispatcher::OnSessionMessagesReceived( | 444 void PresentationDispatcher::OnSessionMessagesReceived( |
| 420 blink::mojom::PresentationSessionInfoPtr session_info, | 445 blink::mojom::PresentationSessionInfoPtr session_info, |
| 421 std::vector<blink::mojom::SessionMessagePtr> messages) { | 446 std::vector<blink::mojom::SessionMessagePtr> messages) { |
| 422 if (!controller_) | 447 if (!controller_) |
| 423 return; | 448 return; |
| 424 | 449 |
| 425 for (size_t i = 0; i < messages.size(); ++i) { | 450 for (size_t i = 0; i < messages.size(); ++i) { |
| 426 // Note: Passing batches of messages to the Blink layer would be more | 451 // Note: Passing batches of messages to the Blink layer would be more |
| 427 // efficient. | 452 // efficient. |
| 428 std::unique_ptr<PresentationConnectionClient> session_client( | 453 std::unique_ptr<PresentationConnectionClient> session_client( |
| 429 new PresentationConnectionClient(session_info->url, session_info->id)); | 454 new PresentationConnectionClient(session_info->url->url, |
| 455 session_info->id)); | |
| 430 switch (messages[i]->type) { | 456 switch (messages[i]->type) { |
| 431 case blink::mojom::PresentationMessageType::TEXT: { | 457 case blink::mojom::PresentationMessageType::TEXT: { |
| 432 // TODO(mfoltz): Do we need to DCHECK(messages[i]->message)? | 458 // TODO(mfoltz): Do we need to DCHECK(messages[i]->message)? |
| 433 controller_->didReceiveSessionTextMessage( | 459 controller_->didReceiveSessionTextMessage( |
| 434 session_client.release(), | 460 session_client.release(), |
| 435 blink::WebString::fromUTF8(messages[i]->message.value())); | 461 blink::WebString::fromUTF8(messages[i]->message.value())); |
| 436 break; | 462 break; |
| 437 } | 463 } |
| 438 case blink::mojom::PresentationMessageType::ARRAY_BUFFER: | 464 case blink::mojom::PresentationMessageType::ARRAY_BUFFER: |
| 439 case blink::mojom::PresentationMessageType::BLOB: { | 465 case blink::mojom::PresentationMessageType::BLOB: { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 461 | 487 |
| 462 void PresentationDispatcher::UpdateListeningState(AvailabilityStatus* status) { | 488 void PresentationDispatcher::UpdateListeningState(AvailabilityStatus* status) { |
| 463 bool should_listen = !status->availability_callbacks.IsEmpty() || | 489 bool should_listen = !status->availability_callbacks.IsEmpty() || |
| 464 !status->availability_observers.empty(); | 490 !status->availability_observers.empty(); |
| 465 bool is_listening = status->listening_state != ListeningState::INACTIVE; | 491 bool is_listening = status->listening_state != ListeningState::INACTIVE; |
| 466 | 492 |
| 467 if (should_listen == is_listening) | 493 if (should_listen == is_listening) |
| 468 return; | 494 return; |
| 469 | 495 |
| 470 ConnectToPresentationServiceIfNeeded(); | 496 ConnectToPresentationServiceIfNeeded(); |
| 497 url::mojom::UrlPtr url = url::mojom::Url::New(); | |
| 498 url->url = status->url; | |
| 471 if (should_listen) { | 499 if (should_listen) { |
| 472 status->listening_state = ListeningState::WAITING; | 500 status->listening_state = ListeningState::WAITING; |
| 473 presentation_service_->ListenForScreenAvailability(status->url); | 501 presentation_service_->ListenForScreenAvailability(std::move(url)); |
| 474 } else { | 502 } else { |
| 475 status->listening_state = ListeningState::INACTIVE; | 503 status->listening_state = ListeningState::INACTIVE; |
| 476 presentation_service_->StopListeningForScreenAvailability(status->url); | 504 presentation_service_->StopListeningForScreenAvailability(std::move(url)); |
| 477 } | 505 } |
| 478 } | 506 } |
| 479 | 507 |
| 480 PresentationDispatcher::SendMessageRequest::SendMessageRequest( | 508 PresentationDispatcher::SendMessageRequest::SendMessageRequest( |
| 481 blink::mojom::PresentationSessionInfoPtr session_info, | 509 blink::mojom::PresentationSessionInfoPtr session_info, |
| 482 blink::mojom::SessionMessagePtr message) | 510 blink::mojom::SessionMessagePtr message) |
| 483 : session_info(std::move(session_info)), message(std::move(message)) {} | 511 : session_info(std::move(session_info)), message(std::move(message)) {} |
| 484 | 512 |
| 485 PresentationDispatcher::SendMessageRequest::~SendMessageRequest() {} | 513 PresentationDispatcher::SendMessageRequest::~SendMessageRequest() {} |
| 486 | 514 |
| 487 // static | 515 // static |
| 488 PresentationDispatcher::SendMessageRequest* | 516 PresentationDispatcher::SendMessageRequest* |
| 489 PresentationDispatcher::CreateSendTextMessageRequest( | 517 PresentationDispatcher::CreateSendTextMessageRequest( |
| 490 const blink::WebString& presentationUrl, | 518 const blink::WebString& presentationUrl, |
| 491 const blink::WebString& presentationId, | 519 const blink::WebString& presentationId, |
| 492 const blink::WebString& message) { | 520 const blink::WebString& message) { |
| 493 blink::mojom::PresentationSessionInfoPtr session_info = | 521 blink::mojom::PresentationSessionInfoPtr session_info = |
| 494 blink::mojom::PresentationSessionInfo::New(); | 522 blink::mojom::PresentationSessionInfo::New(); |
| 495 session_info->url = presentationUrl.utf8(); | 523 url::mojom::UrlPtr url = url::mojom::Url::New(); |
| 524 url->url = presentationUrl.utf8(); | |
| 525 session_info->url = std::move(url); | |
| 496 session_info->id = presentationId.utf8(); | 526 session_info->id = presentationId.utf8(); |
| 497 | 527 |
| 498 blink::mojom::SessionMessagePtr session_message = | 528 blink::mojom::SessionMessagePtr session_message = |
| 499 blink::mojom::SessionMessage::New(); | 529 blink::mojom::SessionMessage::New(); |
| 500 session_message->type = blink::mojom::PresentationMessageType::TEXT; | 530 session_message->type = blink::mojom::PresentationMessageType::TEXT; |
| 501 session_message->message = message.utf8(); | 531 session_message->message = message.utf8(); |
| 502 return new SendMessageRequest(std::move(session_info), | 532 return new SendMessageRequest(std::move(session_info), |
| 503 std::move(session_message)); | 533 std::move(session_message)); |
| 504 } | 534 } |
| 505 | 535 |
| 506 // static | 536 // static |
| 507 PresentationDispatcher::SendMessageRequest* | 537 PresentationDispatcher::SendMessageRequest* |
| 508 PresentationDispatcher::CreateSendBinaryMessageRequest( | 538 PresentationDispatcher::CreateSendBinaryMessageRequest( |
| 509 const blink::WebString& presentationUrl, | 539 const blink::WebString& presentationUrl, |
| 510 const blink::WebString& presentationId, | 540 const blink::WebString& presentationId, |
| 511 blink::mojom::PresentationMessageType type, | 541 blink::mojom::PresentationMessageType type, |
| 512 const uint8_t* data, | 542 const uint8_t* data, |
| 513 size_t length) { | 543 size_t length) { |
| 514 blink::mojom::PresentationSessionInfoPtr session_info = | 544 blink::mojom::PresentationSessionInfoPtr session_info = |
| 515 blink::mojom::PresentationSessionInfo::New(); | 545 blink::mojom::PresentationSessionInfo::New(); |
| 516 session_info->url = presentationUrl.utf8(); | 546 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.
| |
| 547 url->url = presentationUrl.utf8(); | |
| 548 session_info->url = std::move(url); | |
| 517 session_info->id = presentationId.utf8(); | 549 session_info->id = presentationId.utf8(); |
| 518 | 550 |
| 519 blink::mojom::SessionMessagePtr session_message = | 551 blink::mojom::SessionMessagePtr session_message = |
| 520 blink::mojom::SessionMessage::New(); | 552 blink::mojom::SessionMessage::New(); |
| 521 session_message->type = type; | 553 session_message->type = type; |
| 522 session_message->data = std::vector<uint8_t>(data, data + length); | 554 session_message->data = std::vector<uint8_t>(data, data + length); |
| 523 return new SendMessageRequest(std::move(session_info), | 555 return new SendMessageRequest(std::move(session_info), |
| 524 std::move(session_message)); | 556 std::move(session_message)); |
| 525 } | 557 } |
| 526 | 558 |
| 527 PresentationDispatcher::AvailabilityStatus::AvailabilityStatus( | 559 PresentationDispatcher::AvailabilityStatus::AvailabilityStatus( |
| 528 const std::string& availability_url) | 560 const std::string& availability_url) |
| 529 : url(availability_url), | 561 : url(availability_url), |
| 530 last_known_availability(false), | 562 last_known_availability(false), |
| 531 listening_state(ListeningState::INACTIVE) {} | 563 listening_state(ListeningState::INACTIVE) {} |
| 532 | 564 |
| 533 PresentationDispatcher::AvailabilityStatus::~AvailabilityStatus() { | 565 PresentationDispatcher::AvailabilityStatus::~AvailabilityStatus() { |
| 534 } | 566 } |
| 535 | 567 |
| 536 } // namespace content | 568 } // namespace content |
| OLD | NEW |