Chromium Code Reviews| Index: chrome/browser/ui/webui/media_router/media_router_dialog_controller_impl.cc |
| diff --git a/chrome/browser/ui/webui/media_router/media_router_dialog_controller_impl.cc b/chrome/browser/ui/webui/media_router/media_router_dialog_controller_impl.cc |
| index 631cd6401e55f6980fe3e009396114710b40535c..8bb2e8c9935883f1f44e26f9698d4f2b89af7140 100644 |
| --- a/chrome/browser/ui/webui/media_router/media_router_dialog_controller_impl.cc |
| +++ b/chrome/browser/ui/webui/media_router/media_router_dialog_controller_impl.cc |
| @@ -12,6 +12,7 @@ |
| #include "base/macros.h" |
| #include "base/trace_event/trace_event.h" |
| #include "build/build_config.h" |
| +#include "chrome/browser/media/router/media_router_ui_service.h" |
| #include "chrome/browser/media/router/presentation_service_delegate_impl.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/ui/browser_finder.h" |
| @@ -112,6 +113,12 @@ void MediaRouterDialogDelegate::GetDialogSize(gfx::Size* size) const { |
| controller_->UpdateMaxDialogSize(); |
| } |
| +MediaRouterActionController* GetActionController(WebContents* web_contents) { |
| + Profile* profile = |
| + Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| + return MediaRouterUIService::Get(profile)->action_controller(); |
| +} |
| + |
| } // namespace |
| // static |
| @@ -158,10 +165,11 @@ MediaRouterDialogControllerImpl::MediaRouterDialogControllerImpl( |
| WebContents* web_contents) |
| : MediaRouterDialogController(web_contents), |
| media_router_dialog_pending_(false), |
| - weak_ptr_factory_(this) { |
| -} |
| + action_controller_(GetActionController(web_contents)), |
| + weak_ptr_factory_(this) {} |
|
mark a. foltz
2016/10/17 18:57:40
Can you DCHECK(action_controller_) here?
takumif
2016/10/27 23:06:38
Done.
|
| MediaRouterDialogControllerImpl::~MediaRouterDialogControllerImpl() { |
| + Reset(); |
| } |
| WebContents* MediaRouterDialogControllerImpl::GetMediaRouterDialog() const { |
| @@ -264,15 +272,21 @@ void MediaRouterDialogControllerImpl::CreateMediaRouterDialog() { |
| dialog_observer_.reset(new DialogWebContentsObserver( |
| media_router_dialog, this)); |
| + // The |action_controller_| must be notified after |action_| to avoid a UI |
| + // bug in which the drop shadow is drawn in an incorrect position. |
| if (action_) |
| action_->OnDialogShown(); |
| + action_controller_->OnDialogShown(); |
| } |
| void MediaRouterDialogControllerImpl::Reset() { |
| + if (IsShowingMediaRouterDialog()) { |
| + if (action_) |
| + action_->OnDialogHidden(); |
| + action_controller_->OnDialogHidden(); |
| + } |
| MediaRouterDialogController::Reset(); |
| dialog_observer_.reset(); |
| - if (action_) |
| - action_->OnDialogHidden(); |
| } |
| void MediaRouterDialogControllerImpl::OnDialogNavigated( |