Commit 636c518a authored by Mounir Lamouri's avatar Mounir Lamouri Committed by Commit Bot

Picture-in-Picture: playback state change shouldn't show icons.

Updating the views visibility overrides the layer's visibility. This
makes sure the layer is set back to the correct visibility when the
views' one is updated in order to avoid the pause button to show up in
cases such as a playlist.

Bug: 863497
Change-Id: I0d9ce10b1219ea3af492269e228988f51c54b3e2
Reviewed-on: https://chromium-review.googlesource.com/1149507Reviewed-by: default avatarapacible <apacible@chromium.org>
Commit-Queue: Mounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578209}
parent c0260133
...@@ -519,6 +519,15 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -519,6 +519,15 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
EXPECT_TRUE(window_controller()->GetWindowForTesting()->IsVisible()); EXPECT_TRUE(window_controller()->GetWindowForTesting()->IsVisible());
EXPECT_TRUE( EXPECT_TRUE(
window_controller()->GetWindowForTesting()->GetVideoLayer()->visible()); window_controller()->GetWindowForTesting()->GetVideoLayer()->visible());
#if !defined(OS_ANDROID)
OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>(
window_controller()->GetWindowForTesting());
EXPECT_FALSE(overlay_window->play_pause_controls_view_for_testing()
->layer()
->visible());
#endif
} }
// Tests that we can enter Picture-in-Picture when a video is not preloaded, // Tests that we can enter Picture-in-Picture when a video is not preloaded,
......
...@@ -421,6 +421,9 @@ void OverlayWindowViews::UpdateVideoSize(const gfx::Size& natural_size) { ...@@ -421,6 +421,9 @@ void OverlayWindowViews::UpdateVideoSize(const gfx::Size& natural_size) {
} }
void OverlayWindowViews::SetPlaybackState(PlaybackState playback_state) { void OverlayWindowViews::SetPlaybackState(PlaybackState playback_state) {
// TODO(apacible): have machine state for controls visibility.
bool play_pause_layer_visible = GetPlayPauseControlsLayer()->visible();
switch (playback_state) { switch (playback_state) {
case kPlaying: case kPlaying:
play_pause_controls_view_->SetToggled(true); play_pause_controls_view_->SetToggled(true);
...@@ -437,6 +440,8 @@ void OverlayWindowViews::SetPlaybackState(PlaybackState playback_state) { ...@@ -437,6 +440,8 @@ void OverlayWindowViews::SetPlaybackState(PlaybackState playback_state) {
video_view_->SetVisible(false); video_view_->SetVisible(false);
break; break;
} }
GetPlayPauseControlsLayer()->SetVisible(play_pause_layer_visible);
} }
ui::Layer* OverlayWindowViews::GetWindowBackgroundLayer() { ui::Layer* OverlayWindowViews::GetWindowBackgroundLayer() {
...@@ -619,3 +624,7 @@ void OverlayWindowViews::TogglePlayPause() { ...@@ -619,3 +624,7 @@ void OverlayWindowViews::TogglePlayPause() {
void OverlayWindowViews::ClickCustomControl(const std::string& control_id) { void OverlayWindowViews::ClickCustomControl(const std::string& control_id) {
controller_->ClickCustomControl(control_id); controller_->ClickCustomControl(control_id);
} }
views::View* OverlayWindowViews::play_pause_controls_view_for_testing() const {
return play_pause_controls_view_.get();
}
...@@ -60,6 +60,8 @@ class OverlayWindowViews : public content::OverlayWindow, public views::Widget { ...@@ -60,6 +60,8 @@ class OverlayWindowViews : public content::OverlayWindow, public views::Widget {
// Send the message that a custom control on |this| has been clicked. // Send the message that a custom control on |this| has been clicked.
void ClickCustomControl(const std::string& control_id); void ClickCustomControl(const std::string& control_id);
views::View* play_pause_controls_view_for_testing() const;
private: private:
// Gets the internal |ui::Layer| of the controls. // Gets the internal |ui::Layer| of the controls.
ui::Layer* GetControlsBackgroundLayer(); ui::Layer* GetControlsBackgroundLayer();
......
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