Chromium Code Reviews| Index: third_party/WebKit/Source/modules/media_controls/MediaControlsImpl.cpp |
| diff --git a/third_party/WebKit/Source/modules/media_controls/MediaControlsImpl.cpp b/third_party/WebKit/Source/modules/media_controls/MediaControlsImpl.cpp |
| index 6e6a7a17f5e93361191f1112fa052402757f1e63..c1651ad97731b5dabea695d150c3e90b210f7dbd 100644 |
| --- a/third_party/WebKit/Source/modules/media_controls/MediaControlsImpl.cpp |
| +++ b/third_party/WebKit/Source/modules/media_controls/MediaControlsImpl.cpp |
| @@ -52,6 +52,7 @@ |
| #include "modules/media_controls/MediaControlsOrientationLockDelegate.h" |
| #include "modules/media_controls/MediaControlsRotateToFullscreenDelegate.h" |
| #include "modules/media_controls/MediaControlsWindowEventListener.h" |
| +#include "modules/media_controls/MediaDownloadInProductHelpManager.h" |
| #include "modules/media_controls/elements/MediaControlCastButtonElement.h" |
| #include "modules/media_controls/elements/MediaControlCurrentTimeDisplayElement.h" |
| #include "modules/media_controls/elements/MediaControlDownloadButtonElement.h" |
| @@ -297,6 +298,7 @@ MediaControlsImpl::MediaControlsImpl(HTMLMediaElement& media_element) |
| &MediaControlsImpl::ElementSizeChangedTimerFired), |
| keep_showing_until_timer_fires_(false) { |
| resize_observer_->observe(&media_element); |
| + CreateDownloadInProductHelp(); |
|
mlamouri (slow - plz ping)
2017/08/16 13:09:30
Can you move this in ::Create()?
Khushal
2017/08/16 19:01:22
Done.
|
| } |
| MediaControlsImpl* MediaControlsImpl::Create(HTMLMediaElement& media_element, |
| @@ -571,6 +573,8 @@ void MediaControlsImpl::MaybeShow() { |
| // Only make the controls visible if they won't get hidden by OnTimeUpdate. |
| if (MediaElement().paused() || !ShouldHideMediaControls()) |
| MakeOpaque(); |
| + if (download_iph_manager_) |
| + download_iph_manager_->SetControlsState(true); |
|
mlamouri (slow - plz ping)
2017/08/16 13:09:30
Similar to the download button "state", could this
Khushal
2017/08/16 19:01:22
I wasn't sure if I should call it SetControlsVisib
|
| } |
| void MediaControlsImpl::Hide() { |
| @@ -578,6 +582,8 @@ void MediaControlsImpl::Hide() { |
| panel_->SetIsDisplayed(false); |
| if (overlay_play_button_) |
| overlay_play_button_->SetIsWanted(false); |
| + if (download_iph_manager_) |
| + download_iph_manager_->SetControlsState(false); |
| } |
| bool MediaControlsImpl::IsVisible() const { |
| @@ -633,6 +639,10 @@ bool MediaControlsImpl::ShouldHideMediaControls(unsigned behavior_flags) const { |
| if (text_track_list_->IsWanted() || overflow_list_->IsWanted()) |
| return false; |
| + // Don't hide the media controls while the in product help is showing. |
| + if (download_iph_manager_ && download_iph_manager_->IsShowingInProductHelp()) |
| + return false; |
| + |
| return true; |
| } |
| @@ -816,8 +826,7 @@ void MediaControlsImpl::DefaultEventHandler(Event* event) { |
| is_mouse_over_controls_ = true; |
| if (!MediaElement().paused()) { |
| MakeOpaque(); |
| - if (ShouldHideMediaControls()) |
| - StartHideMediaControlsTimer(); |
| + StartHideMediaControlsIfNecessary(); |
| } |
| } |
| return; |
| @@ -962,6 +971,9 @@ void MediaControlsImpl::OnPlay() { |
| UpdatePlayState(); |
| timeline_->SetPosition(MediaElement().currentTime()); |
| UpdateCurrentTimeDisplay(); |
| + |
| + if (download_iph_manager_) |
| + download_iph_manager_->SetPlayState(true); |
|
mlamouri (slow - plz ping)
2017/08/16 13:09:30
This should probably be called "Playback" instead
Khushal
2017/08/16 19:01:22
Done.
|
| } |
| void MediaControlsImpl::OnPlaying() { |
| @@ -977,6 +989,9 @@ void MediaControlsImpl::OnPause() { |
| MakeOpaque(); |
| StopHideMediaControlsTimer(); |
| + |
| + if (download_iph_manager_) |
| + download_iph_manager_->SetPlayState(false); |
| } |
| void MediaControlsImpl::OnTextTracksAddedOrRemoved() { |
| @@ -1220,6 +1235,41 @@ void MediaControlsImpl::HideAllMenus() { |
| text_track_list_->SetVisible(false); |
| } |
| +void MediaControlsImpl::StartHideMediaControlsIfNecessary() { |
| + if (ShouldHideMediaControls()) |
| + StartHideMediaControlsTimer(); |
| +} |
| + |
| +const MediaControlDownloadButtonElement& MediaControlsImpl::DownloadButton() |
| + const { |
| + return *download_button_; |
| +} |
| + |
| +void MediaControlsImpl::DidDismissDownloadInProductHelp() { |
| + StartHideMediaControlsIfNecessary(); |
| +} |
| + |
| +MediaDownloadInProductHelpManager* MediaControlsImpl::DownloadInProductHelp() { |
| + return download_iph_manager_; |
| +} |
| + |
| +void MediaControlsImpl::CreateDownloadInProductHelp() { |
| + // Is showing in-product help enabled? |
| + if (!MediaElement().GetDocument().GetSettings() || |
| + !MediaElement() |
| + .GetDocument() |
| + .GetSettings() |
| + ->GetMediaDownloadInProductHelpEnabled()) { |
| + return; |
| + } |
| + |
| + // Download in-product-help is only shown for videos. |
| + if (!MediaElement().IsHTMLVideoElement()) |
| + return; |
| + |
| + download_iph_manager_ = new MediaDownloadInProductHelpManager(*this); |
| +} |
| + |
| DEFINE_TRACE(MediaControlsImpl) { |
| visitor->Trace(element_mutation_callback_); |
| visitor->Trace(resize_observer_); |
| @@ -1245,6 +1295,7 @@ DEFINE_TRACE(MediaControlsImpl) { |
| visitor->Trace(window_event_listener_); |
| visitor->Trace(orientation_lock_delegate_); |
| visitor->Trace(rotate_to_fullscreen_delegate_); |
| + visitor->Trace(download_iph_manager_); |
| MediaControls::Trace(visitor); |
| HTMLDivElement::Trace(visitor); |
| } |