Commit 228321ca authored by John Williams's avatar John Williams Committed by Commit Bot

Set visibility of Cast button for new Chrome windows.

Bug: 883887
Change-Id: I9ce93c85e7fcfb2ad4625fe35abb3b8ee9fa2fd5
Reviewed-on: https://chromium-review.googlesource.com/c/1260103Reviewed-by: default avatarTakumi Fujimoto <takumif@chromium.org>
Commit-Queue: John Williams <jrw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597309}
parent 06487dd5
......@@ -128,6 +128,13 @@ void MediaRouterActionController::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer);
}
bool MediaRouterActionController::ShouldEnableAction() const {
return shown_by_policy_ || has_local_display_route_ || has_issue_ ||
dialog_count_ || context_menu_shown_ ||
keep_visible_for_right_mouse_button_ ||
GetAlwaysShowActionPref(profile_);
}
MediaRouterActionController::MediaRouterActionController(
Profile* profile,
media_router::MediaRouter* router,
......@@ -179,10 +186,3 @@ void MediaRouterActionController::MaybeAddOrRemoveTrustedAreaIcon() {
observer.HideIcon();
}
}
bool MediaRouterActionController::ShouldEnableAction() const {
return shown_by_policy_ || has_local_display_route_ || has_issue_ ||
dialog_count_ || context_menu_shown_ ||
keep_visible_for_right_mouse_button_ ||
GetAlwaysShowActionPref(profile_);
}
......@@ -81,6 +81,10 @@ class MediaRouterActionController : public media_router::IssuesObserver,
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
// Returns |true| if the Media Router action should be present on the toolbar
// or the overflow menu.
bool ShouldEnableAction() const;
private:
friend class MediaRouterActionControllerUnitTest;
FRIEND_TEST_ALL_PREFIXES(MediaRouterActionControllerUnitTest,
......@@ -99,10 +103,6 @@ class MediaRouterActionController : public media_router::IssuesObserver,
void MaybeAddOrRemoveComponentAction();
void MaybeAddOrRemoveTrustedAreaIcon();
// Returns |true| if the Media Router action should be present on the toolbar
// or the overflow menu.
bool ShouldEnableAction() const;
// The profile |this| is associated with. There should be one instance of this
// class per profile.
Profile* const profile_;
......
......@@ -61,7 +61,6 @@ CastToolbarButton::CastToolbarButton(
browser_(browser),
profile_(browser_->profile()),
context_menu_(std::move(context_menu)) {
SetVisible(false);
set_notify_action(Button::NOTIFY_ON_PRESS);
EnableCanvasFlippingForRTLUI(false);
......@@ -69,7 +68,10 @@ CastToolbarButton::CastToolbarButton(
ToolbarButton::Init();
IssuesObserver::Init();
MediaRouterUIService::Get(profile_)->action_controller()->AddObserver(this);
MediaRouterActionController* controller =
MediaRouterUIService::Get(profile_)->action_controller();
controller->AddObserver(this);
SetVisible(controller->ShouldEnableAction());
}
CastToolbarButton::~CastToolbarButton() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment