Skip to content

Commit

Permalink
Revert "[Harmony Cast Dialog] Close dialog after starting a page-init…
Browse files Browse the repository at this point in the history
…iated route"

This reverts commit a8e9bac.

Reason for revert: We have a crash in issue 876900 which we're not sure how it
happens. Based on when the crash started happening, this CL may be relevant.
We're reverting this CL to see if the crashes stop.

Original change's description:
> [Harmony Cast Dialog] Close dialog after starting a page-initiated route
>
> The dialog needs to be closed when a PresentationRequest is fulfilled,
> so that the user cannot attempt to cast again using the same request.
>
> Bug: 868186
>
> Change-Id: I9d00cc5119257bba046e67c750210104123f0bdb
> Reviewed-on: https://chromium-review.googlesource.com/1151890
> Reviewed-by: Derek Cheng <imcheng@chromium.org>
> Commit-Queue: Takumi Fujimoto <takumif@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#579129}

TBR=imcheng@chromium.org,takumif@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 868186,876900
Change-Id: I419a343cf8ea85cc92e219b0c5422fa9d095b805
Reviewed-on: https://chromium-review.googlesource.com/1218162
Reviewed-by: Derek Cheng <imcheng@chromium.org>
Reviewed-by: Takumi Fujimoto <takumif@chromium.org>
Commit-Queue: Takumi Fujimoto <takumif@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590391}
  • Loading branch information
takumif authored and Commit Bot committed Sep 11, 2018
1 parent 90f7d3f commit 91dfc81
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 17 deletions.
11 changes: 5 additions & 6 deletions chrome/browser/ui/media_router/media_router_ui_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,7 @@ void MediaRouterUIBase::OnRouteResponseReceived(
}

void MediaRouterUIBase::HandleCreateSessionRequestRouteResponse(
const RouteRequestResult&) {
Close();
}
const RouteRequestResult&) {}

void MediaRouterUIBase::InitCommon(content::WebContents* initiator) {
DCHECK(initiator);
Expand Down Expand Up @@ -551,15 +549,16 @@ base::Optional<RouteParameters> MediaRouterUIBase::GetRouteParameters(
weak_factory_.GetWeakPtr(), cast_mode));

// There are 3 cases. In cases (1) and (3) the MediaRouterUIBase will need to
// be notified via OnRouteResponseReceived(). In case (2) the dialog will be
// closed via HandleCreateSessionRequestRouteResponse().
// be notified. In case (2) the dialog will be closed.
// (1) Non-presentation route request (e.g., mirroring). No additional
// notification necessary.
// (2) Presentation route request for a PresentationRequest.start() call.
// The StartPresentationContext will need to be answered with the route
// response.
// (3) Browser-initiated presentation route request. If successful,
// PresentationServiceDelegateImpl will have to be notified.
// PresentationServiceDelegateImpl will have to be notified. Note that we
// treat subsequent route requests from a Presentation API-initiated
// dialogs as browser-initiated.
if (!for_presentation_source || !start_presentation_context_) {
params.route_result_callbacks.push_back(base::BindOnce(
&MediaRouterUIBase::OnRouteResponseReceived, weak_factory_.GetWeakPtr(),
Expand Down
3 changes: 0 additions & 3 deletions chrome/browser/ui/media_router/media_router_ui_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ class MediaRouterUIBase
// Opens a file picker for when the user selected local file casting.
void OpenFileDialog();

// Closes the Media Router dialog.
virtual void Close() = 0;

const std::vector<MediaRoute>& routes() const { return routes_; }
content::WebContents* initiator() const { return initiator_; }

Expand Down
5 changes: 0 additions & 5 deletions chrome/browser/ui/views/media_router/media_router_views_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "chrome/browser/media/router/media_router_metrics.h"
#include "chrome/browser/ui/media_router/media_sink_with_cast_modes.h"
#include "chrome/browser/ui/media_router/ui_media_sink.h"
#include "chrome/browser/ui/views/media_router/cast_dialog_view.h"
#include "chrome/common/media_router/route_request_result.h"
#include "chrome/grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
Expand Down Expand Up @@ -77,10 +76,6 @@ std::vector<MediaSinkWithCastModes> MediaRouterViewsUI::GetEnabledSinks()
return sinks;
}

void MediaRouterViewsUI::Close() {
CastDialogView::HideDialog();
}

void MediaRouterViewsUI::InitCommon(content::WebContents* initiator) {
MediaRouterUIBase::InitCommon(initiator);
// We don't start observing issues in MediaRouterUIBase::InitCommon() because
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class MediaRouterViewsUI : public MediaRouterUIBase,

// MediaRouterUIBase:
std::vector<MediaSinkWithCastModes> GetEnabledSinks() const override;
void Close() override;

private:
FRIEND_TEST_ALL_PREFIXES(MediaRouterViewsUITest, NotifyObserver);
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/ui/webui/media_router/media_router_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,11 @@ void MediaRouterUI::OnRouteResponseReceived(
SendIssueForRouteTimeout(cast_mode, presentation_request_source_name);
}

void MediaRouterUI::HandleCreateSessionRequestRouteResponse(
const RouteRequestResult&) {
Close();
}

void MediaRouterUI::OnSearchSinkResponseReceived(
MediaCastMode cast_mode,
const MediaSink::Id& found_sink_id) {
Expand Down
7 changes: 5 additions & 2 deletions chrome/browser/ui/webui/media_router/media_router_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class MediaRouterUI : public MediaRouterUIBase, public ConstrainedWebDialogUI {
explicit MediaRouterUI(content::WebUI* web_ui);
~MediaRouterUI() override;

// MediaRouterUIBase:
void Close() override;
// Closes the media router UI.
void Close();

// Notifies this instance that the UI has been initialized.
virtual void OnUIInitialized();
Expand Down Expand Up @@ -160,6 +160,9 @@ class MediaRouterUI : public MediaRouterUIBase, public ConstrainedWebDialogUI {
const base::string16& presentation_request_source_name,
const RouteRequestResult& result) override;

void HandleCreateSessionRequestRouteResponse(
const RouteRequestResult&) override;

// Callback passed to MediaRouter to receive the sink ID of the sink found by
// SearchSinksAndCreateRoute().
void OnSearchSinkResponseReceived(MediaCastMode cast_mode,
Expand Down

0 comments on commit 91dfc81

Please sign in to comment.