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

Side by Side Diff: chrome/browser/media/router/presentation_service_delegate_impl.cc

Issue 1228863005: [MediaRouter] The minimal change to make everything build on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Typo in a chrome/test/BUILD.gn Created 5 years, 5 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 "chrome/browser/media/router/presentation_service_delegate_impl.h" 5 #include "chrome/browser/media/router/presentation_service_delegate_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/containers/scoped_ptr_hash_map.h" 9 #include "base/containers/scoped_ptr_hash_map.h"
10 #include "base/containers/small_map.h" 10 #include "base/containers/small_map.h"
11 #include "base/guid.h" 11 #include "base/guid.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "chrome/browser/media/router/create_session_request.h" 14 #include "chrome/browser/media/router/create_session_request.h"
15 #include "chrome/browser/media/router/media_route.h" 15 #include "chrome/browser/media/router/media_route.h"
16 #include "chrome/browser/media/router/media_router.h" 16 #include "chrome/browser/media/router/media_router.h"
17 #include "chrome/browser/media/router/media_router_mojo_impl.h" 17 #include "chrome/browser/media/router/media_router_dialog_controller.h"
18 #include "chrome/browser/media/router/media_router_mojo_impl_factory.h" 18 #include "chrome/browser/media/router/media_router_factory.h"
19 #include "chrome/browser/media/router/media_sink.h" 19 #include "chrome/browser/media/router/media_sink.h"
20 #include "chrome/browser/media/router/media_source_helper.h" 20 #include "chrome/browser/media/router/media_source_helper.h"
21 #include "chrome/browser/media/router/presentation_media_sinks_observer.h" 21 #include "chrome/browser/media/router/presentation_media_sinks_observer.h"
22 #include "chrome/browser/media/router/presentation_session_state_observer.h" 22 #include "chrome/browser/media/router/presentation_session_state_observer.h"
23 #include "chrome/browser/sessions/session_tab_helper.h" 23 #include "chrome/browser/sessions/session_tab_helper.h"
24 #include "chrome/browser/ui/webui/media_router/media_router_dialog_controller.h"
25 #include "content/public/browser/presentation_screen_availability_listener.h" 24 #include "content/public/browser/presentation_screen_availability_listener.h"
26 #include "content/public/browser/presentation_session.h" 25 #include "content/public/browser/presentation_session.h"
27 #include "content/public/browser/render_frame_host.h" 26 #include "content/public/browser/render_frame_host.h"
28 #include "content/public/browser/render_process_host.h" 27 #include "content/public/browser/render_process_host.h"
29 28
30 DEFINE_WEB_CONTENTS_USER_DATA_KEY( 29 DEFINE_WEB_CONTENTS_USER_DATA_KEY(
31 media_router::PresentationServiceDelegateImpl); 30 media_router::PresentationServiceDelegateImpl);
32 31
33 using content::RenderFrameHost; 32 using content::RenderFrameHost;
34 33
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 content::WebContents* web_contents) { 435 content::WebContents* web_contents) {
437 DCHECK(web_contents); 436 DCHECK(web_contents);
438 // CreateForWebContents does nothing if the delegate instance already exists. 437 // CreateForWebContents does nothing if the delegate instance already exists.
439 PresentationServiceDelegateImpl::CreateForWebContents(web_contents); 438 PresentationServiceDelegateImpl::CreateForWebContents(web_contents);
440 return PresentationServiceDelegateImpl::FromWebContents(web_contents); 439 return PresentationServiceDelegateImpl::FromWebContents(web_contents);
441 } 440 }
442 441
443 PresentationServiceDelegateImpl::PresentationServiceDelegateImpl( 442 PresentationServiceDelegateImpl::PresentationServiceDelegateImpl(
444 content::WebContents* web_contents) 443 content::WebContents* web_contents)
445 : web_contents_(web_contents), 444 : web_contents_(web_contents),
446 router_(MediaRouterMojoImplFactory::GetApiForBrowserContext( 445 router_(MediaRouterFactory::GetApiForBrowserContext(
447 web_contents_->GetBrowserContext())), 446 web_contents_->GetBrowserContext())),
448 frame_manager_(new PresentationFrameManager(web_contents, router_)), 447 frame_manager_(new PresentationFrameManager(web_contents, router_)),
449 weak_factory_(this) { 448 weak_factory_(this) {
450 DCHECK(web_contents_); 449 DCHECK(web_contents_);
451 DCHECK(router_); 450 DCHECK(router_);
452 } 451 }
453 452
454 PresentationServiceDelegateImpl::~PresentationServiceDelegateImpl() { 453 PresentationServiceDelegateImpl::~PresentationServiceDelegateImpl() {
455 } 454 }
456 455
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 scoped_ptr<CreateSessionRequest> context(new CreateSessionRequest( 598 scoped_ptr<CreateSessionRequest> context(new CreateSessionRequest(
600 presentation_url, presentation_id, 599 presentation_url, presentation_id,
601 GetLastCommittedURLForFrame(render_frame_host_id), 600 GetLastCommittedURLForFrame(render_frame_host_id),
602 base::Bind(&PresentationServiceDelegateImpl::OnStartSessionSucceeded, 601 base::Bind(&PresentationServiceDelegateImpl::OnStartSessionSucceeded,
603 weak_factory_.GetWeakPtr(), render_process_id, render_frame_id, 602 weak_factory_.GetWeakPtr(), render_process_id, render_frame_id,
604 success_cb), 603 success_cb),
605 error_cb)); 604 error_cb));
606 // NOTE: Currently this request is ignored if a dialog is already open, e.g. 605 // NOTE: Currently this request is ignored if a dialog is already open, e.g.
607 // via browser action. In practice, this should rarely happen, but log 606 // via browser action. In practice, this should rarely happen, but log
608 // an error message in case it does. 607 // an error message in case it does.
609 MediaRouterDialogController::CreateForWebContents(web_contents_);
610 MediaRouterDialogController* controller = 608 MediaRouterDialogController* controller =
611 MediaRouterDialogController::FromWebContents(web_contents_); 609 MediaRouterDialogController::GetOrCreateForWebContents(web_contents_);
612 610
613 if (!controller->ShowMediaRouterDialogForPresentation(context.Pass())) { 611 if (!controller->ShowMediaRouterDialogForPresentation(context.Pass())) {
614 LOG(ERROR) << "Media router dialog already exists. Ignoring StartSession."; 612 LOG(ERROR) << "Media router dialog already exists. Ignoring StartSession.";
615 error_cb.Run(content::PresentationError(content::PRESENTATION_ERROR_UNKNOWN, 613 error_cb.Run(content::PresentationError(content::PRESENTATION_ERROR_UNKNOWN,
616 "Unable to create dialog.")); 614 "Unable to create dialog."));
617 return; 615 return;
618 } 616 }
619 } 617 }
620 618
621 void PresentationServiceDelegateImpl::JoinSession( 619 void PresentationServiceDelegateImpl::JoinSession(
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest( 736 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest(
739 int render_process_id, 737 int render_process_id,
740 int render_frame_id, 738 int render_frame_id,
741 const MediaSource::Id& source_id) const { 739 const MediaSource::Id& source_id) const {
742 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); 740 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id);
743 return frame_manager_->HasScreenAvailabilityListenerForTest( 741 return frame_manager_->HasScreenAvailabilityListenerForTest(
744 render_frame_host_id, source_id); 742 render_frame_host_id, source_id);
745 } 743 }
746 744
747 } // namespace media_router 745 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698