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

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

Issue 2108973002: [Media Router] Return NotFoundError on dialog exit if appropriate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments, add no-sinks integration test, update test data json format Created 4 years, 6 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 c5572be8d05e283ea506b6bbc59239c35aca9810..4a8afb4de0bc550fb9a6c34573ac042bea77bc11 100644
--- a/chrome/browser/ui/webui/media_router/media_router_ui.cc
+++ b/chrome/browser/ui/webui/media_router/media_router_ui.cc
@@ -205,9 +205,19 @@ MediaRouterUI::~MediaRouterUI() {
// If |create_session_request_| still exists, then it means presentation route
// request was never attempted.
if (create_session_request_) {
- create_session_request_->InvokeErrorCallback(content::PresentationError(
- content::PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED,
- "Dialog closed."));
+ bool presentation_sinks_available = std::any_of(
+ sinks_.begin(), sinks_.end(), [](const MediaSinkWithCastModes& sink) {
+ return ContainsValue(sink.cast_modes, MediaCastMode::DEFAULT);
+ });
+ if (presentation_sinks_available) {
+ create_session_request_->InvokeErrorCallback(content::PresentationError(
+ content::PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED,
+ "Dialog closed."));
+ } else {
+ create_session_request_->InvokeErrorCallback(content::PresentationError(
+ content::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS,
+ "No screens found."));
+ }
}
}
@@ -286,12 +296,20 @@ void MediaRouterUI::InitCommon(content::WebContents* initiator) {
UpdateCastModes();
}
-void MediaRouterUI::InitForTest(MediaRouter* router,
- content::WebContents* initiator,
- MediaRouterWebUIMessageHandler* handler) {
+void MediaRouterUI::InitForTest(
+ MediaRouter* router,
+ content::WebContents* initiator,
+ MediaRouterWebUIMessageHandler* handler,
+ std::unique_ptr<CreatePresentationConnectionRequest>
+ create_session_request) {
router_ = router;
handler_ = handler;
+ create_session_request_ = std::move(create_session_request);
InitCommon(initiator);
+ if (create_session_request_) {
+ OnDefaultPresentationChanged(
+ create_session_request_->presentation_request());
+ }
}
void MediaRouterUI::OnDefaultPresentationChanged(

Powered by Google App Engine
This is Rietveld 408576698