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

Side by Side Diff: content/renderer/presentation/presentation_dispatcher.cc

Issue 2340433003: [Presentation API] 1-UA: notify receiver page when receiver connection becomes available (blink sid… (Closed)
Patch Set: rebase with master Created 4 years, 2 months 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
OLDNEW
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 <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "content/public/common/presentation_constants.h" 13 #include "content/public/common/presentation_constants.h"
14 #include "content/public/renderer/render_frame.h" 14 #include "content/public/renderer/render_frame.h"
15 #include "content/renderer/presentation/presentation_connection_client.h" 15 #include "content/renderer/presentation/presentation_connection_client.h"
16 #include "services/shell/public/cpp/interface_provider.h" 16 #include "services/shell/public/cpp/interface_provider.h"
17 #include "third_party/WebKit/public/platform/WebString.h" 17 #include "third_party/WebKit/public/platform/WebString.h"
18 #include "third_party/WebKit/public/platform/WebURL.h" 18 #include "third_party/WebKit/public/platform/WebURL.h"
19 #include "third_party/WebKit/public/platform/WebVector.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/WebPresentatio nReceiver.h"
23 #include "third_party/WebKit/public/platform/modules/presentation/presentation.m ojom.h" 24 #include "third_party/WebKit/public/platform/modules/presentation/presentation.m ojom.h"
24 #include "third_party/WebKit/public/web/WebLocalFrame.h" 25 #include "third_party/WebKit/public/web/WebLocalFrame.h"
25 #include "url/gurl.h" 26 #include "url/gurl.h"
26 27
27 namespace { 28 namespace {
28 29
29 blink::WebPresentationError::ErrorType GetWebPresentationErrorTypeFromMojo( 30 blink::WebPresentationError::ErrorType GetWebPresentationErrorTypeFromMojo(
30 blink::mojom::PresentationErrorType mojoErrorType) { 31 blink::mojom::PresentationErrorType mojoErrorType) {
31 switch (mojoErrorType) { 32 switch (mojoErrorType) {
32 case blink::mojom::PresentationErrorType::NO_AVAILABLE_SCREENS: 33 case blink::mojom::PresentationErrorType::NO_AVAILABLE_SCREENS:
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 const blink::WebVector<blink::WebURL>& presentationUrls) { 292 const blink::WebVector<blink::WebURL>& presentationUrls) {
292 ConnectToPresentationServiceIfNeeded(); 293 ConnectToPresentationServiceIfNeeded();
293 294
294 std::vector<GURL> urls; 295 std::vector<GURL> urls;
295 for (const auto& url : presentationUrls) 296 for (const auto& url : presentationUrls)
296 urls.push_back(url); 297 urls.push_back(url);
297 298
298 presentation_service_->SetDefaultPresentationUrls(urls); 299 presentation_service_->SetDefaultPresentationUrls(urls);
299 } 300 }
300 301
302 void PresentationDispatcher::setReceiver(
303 blink::WebPresentationReceiver* receiver) {
304 ConnectToPresentationServiceIfNeeded();
305 receiver_ = receiver;
306 }
307
301 void PresentationDispatcher::DidCommitProvisionalLoad( 308 void PresentationDispatcher::DidCommitProvisionalLoad(
302 bool is_new_navigation, 309 bool is_new_navigation,
303 bool is_same_page_navigation) { 310 bool is_same_page_navigation) {
304 blink::WebFrame* frame = render_frame()->GetWebFrame(); 311 blink::WebFrame* frame = render_frame()->GetWebFrame();
305 // If not top-level navigation. 312 // If not top-level navigation.
306 if (frame->parent() || is_same_page_navigation) 313 if (frame->parent() || is_same_page_navigation)
307 return; 314 return;
308 315
309 // Remove all pending send message requests. 316 // Remove all pending send message requests.
310 MessageRequestQueue empty; 317 MessageRequestQueue empty;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 blink::WebString::fromUTF8(error->message))); 391 blink::WebString::fromUTF8(error->message)));
385 return; 392 return;
386 } 393 }
387 394
388 DCHECK(!session_info.is_null()); 395 DCHECK(!session_info.is_null());
389 presentation_service_->ListenForSessionMessages(session_info.Clone()); 396 presentation_service_->ListenForSessionMessages(session_info.Clone());
390 callback->onSuccess( 397 callback->onSuccess(
391 base::MakeUnique<PresentationConnectionClient>(std::move(session_info))); 398 base::MakeUnique<PresentationConnectionClient>(std::move(session_info)));
392 } 399 }
393 400
401 void PresentationDispatcher::OnReceiverConnectionAvailable(
402 blink::mojom::PresentationSessionInfoPtr session_info) {
403 if (receiver_) {
404 receiver_->onReceiverConnectionAvailable(
405 new PresentationConnectionClient(std::move(session_info)));
406 }
407 }
408
394 void PresentationDispatcher::OnConnectionStateChanged( 409 void PresentationDispatcher::OnConnectionStateChanged(
395 blink::mojom::PresentationSessionInfoPtr connection, 410 blink::mojom::PresentationSessionInfoPtr connection,
396 blink::mojom::PresentationConnectionState state) { 411 blink::mojom::PresentationConnectionState state) {
397 if (!controller_) 412 if (!controller_)
398 return; 413 return;
399 414
400 DCHECK(!connection.is_null()); 415 DCHECK(!connection.is_null());
401 controller_->didChangeSessionState( 416 controller_->didChangeSessionState(
402 new PresentationConnectionClient(std::move(connection)), 417 new PresentationConnectionClient(std::move(connection)),
403 GetWebPresentationConnectionStateFromMojo(state)); 418 GetWebPresentationConnectionStateFromMojo(state));
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 PresentationDispatcher::AvailabilityStatus::AvailabilityStatus( 543 PresentationDispatcher::AvailabilityStatus::AvailabilityStatus(
529 const GURL& availability_url) 544 const GURL& availability_url)
530 : url(availability_url), 545 : url(availability_url),
531 last_known_availability(false), 546 last_known_availability(false),
532 listening_state(ListeningState::INACTIVE) {} 547 listening_state(ListeningState::INACTIVE) {}
533 548
534 PresentationDispatcher::AvailabilityStatus::~AvailabilityStatus() { 549 PresentationDispatcher::AvailabilityStatus::~AvailabilityStatus() {
535 } 550 }
536 551
537 } // namespace content 552 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698