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

Unified Diff: chrome/browser/ui/webui/media_router/media_router_ui.cc

Issue 2862393002: [Media Router] Force DEFAULT cast mode when starting presentations from content. (Closed)
Patch Set: Update unittests Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/media_router/media_router_ui.cc
diff --git a/chrome/browser/ui/webui/media_router/media_router_ui.cc b/chrome/browser/ui/webui/media_router/media_router_ui.cc
index 0b58cfb34ac9f1cdabee3b2a0c9ba2bf5b43800f..3d003cb6074bea7eea2cd5172ff6af90290bf3e5 100644
--- a/chrome/browser/ui/webui/media_router/media_router_ui.cc
+++ b/chrome/browser/ui/webui/media_router/media_router_ui.cc
@@ -270,8 +270,12 @@ void MediaRouterUI::InitWithPresentationSessionRequest(
create_session_request_ = std::move(create_session_request);
presentation_service_delegate_ = delegate->GetWeakPtr();
+
+ const PresentationRequest& presentation_request =
takumif 2017/05/16 21:51:28 Nit: Was there a reason why you stored this in a v
mark a. foltz 2017/05/16 22:02:11 Reverted
+ create_session_request_->presentation_request();
+
InitCommon(initiator);
- OnDefaultPresentationChanged(create_session_request_->presentation_request());
+ OnDefaultPresentationChanged(presentation_request);
}
void MediaRouterUI::InitCommon(content::WebContents* initiator) {
@@ -281,6 +285,11 @@ void MediaRouterUI::InitCommon(content::WebContents* initiator) {
TRACE_EVENT_NESTABLE_ASYNC_INSTANT1("media_router", "UI", initiator,
"MediaRouterUI::InitCommon", this);
+ // Presentation requests from content must show the origin requesting
+ // presentation: crbug.com/704964
+ if (create_session_request_)
+ forced_cast_mode_ = MediaCastMode::DEFAULT;
+
router_->OnUserGesture();
// Create |collator_| before |query_result_manager_| so that |collator_| is
@@ -357,6 +366,12 @@ void MediaRouterUI::OnDefaultPresentationChanged(
void MediaRouterUI::OnDefaultPresentationRemoved() {
presentation_request_.reset();
query_result_manager_->RemoveSourcesForCastMode(MediaCastMode::DEFAULT);
+
+ // This should not be set if the dialog was initiated with a default
+ // presentation request from the top level frame. However, clear it just to
+ // be safe.
+ forced_cast_mode_ = base::nullopt;
+
// Register for MediaRoute updates without a media source.
routes_observer_.reset(new UIMediaRoutesObserver(
router_, MediaSource::Id(),
@@ -368,7 +383,8 @@ void MediaRouterUI::UpdateCastModes() {
// Gets updated cast modes from |query_result_manager_| and forwards it to UI.
cast_modes_ = query_result_manager_->GetSupportedCastModes();
if (ui_initialized_) {
- handler_->UpdateCastModes(cast_modes_, GetPresentationRequestSourceName());
+ handler_->UpdateCastModes(cast_modes_, GetPresentationRequestSourceName(),
+ forced_cast_mode());
}
}

Powered by Google App Engine
This is Rietveld 408576698