Commit dafc5c79 authored by Mounir Lamouri's avatar Mounir Lamouri Committed by Commit Bot

Media Controls: show IPH on the overflow button with modern controls.

The download button only shows up in the overflow menu so the logic is
now to show the UI anchor to the overflow menu button to suggest the
user to use it to find the download action.

Bug: 781725
Change-Id: Ifce219924ac55c7858ffb1ba8a099cbc96a24e6d
Reviewed-on: https://chromium-review.googlesource.com/998913Reviewed-by: default avatarBecca Hughes <beccahughes@chromium.org>
Commit-Queue: Mounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548659}
parent 08d2ef4b
...@@ -1848,6 +1848,11 @@ const MediaControlDownloadButtonElement& MediaControlsImpl::DownloadButton() ...@@ -1848,6 +1848,11 @@ const MediaControlDownloadButtonElement& MediaControlsImpl::DownloadButton()
return *download_button_; return *download_button_;
} }
const MediaControlOverflowMenuButtonElement& MediaControlsImpl::OverflowButton()
const {
return *overflow_menu_;
}
void MediaControlsImpl::DidDismissDownloadInProductHelp() { void MediaControlsImpl::DidDismissDownloadInProductHelp() {
StartHideMediaControlsIfNecessary(); StartHideMediaControlsIfNecessary();
} }
......
...@@ -140,6 +140,7 @@ class MODULES_EXPORT MediaControlsImpl final : public HTMLDivElement, ...@@ -140,6 +140,7 @@ class MODULES_EXPORT MediaControlsImpl final : public HTMLDivElement,
// Methods used for Download In-product help. // Methods used for Download In-product help.
const MediaControlDownloadButtonElement& DownloadButton() const; const MediaControlDownloadButtonElement& DownloadButton() const;
const MediaControlOverflowMenuButtonElement& OverflowButton() const;
void DidDismissDownloadInProductHelp(); void DidDismissDownloadInProductHelp();
MediaDownloadInProductHelpManager* DownloadInProductHelp(); MediaDownloadInProductHelpManager* DownloadInProductHelp();
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "core/frame/LocalFrameClient.h" #include "core/frame/LocalFrameClient.h"
#include "modules/media_controls/MediaControlsImpl.h" #include "modules/media_controls/MediaControlsImpl.h"
#include "modules/media_controls/elements/MediaControlDownloadButtonElement.h" #include "modules/media_controls/elements/MediaControlDownloadButtonElement.h"
#include "modules/media_controls/elements/MediaControlOverflowMenuButtonElement.h"
#include "services/service_manager/public/cpp/interface_provider.h" #include "services/service_manager/public/cpp/interface_provider.h"
namespace blink { namespace blink {
...@@ -66,7 +67,9 @@ void MediaDownloadInProductHelpManager:: ...@@ -66,7 +67,9 @@ void MediaDownloadInProductHelpManager::
// If the button is not in the viewport, don't show the in-product-help. // If the button is not in the viewport, don't show the in-product-help.
IntRect button_rect = IntRect button_rect =
controls_->DownloadButton().VisibleBoundsInVisualViewport(); controls_->IsModern()
? controls_->OverflowButton().VisibleBoundsInVisualViewport()
: controls_->DownloadButton().VisibleBoundsInVisualViewport();
if (button_rect.IsEmpty()) if (button_rect.IsEmpty())
return; return;
......
...@@ -26,7 +26,7 @@ MediaControlDownloadButtonElement::MediaControlDownloadButtonElement( ...@@ -26,7 +26,7 @@ MediaControlDownloadButtonElement::MediaControlDownloadButtonElement(
SetIsWanted(false); SetIsWanted(false);
} }
bool MediaControlDownloadButtonElement::ShouldDisplayDownloadButton() { bool MediaControlDownloadButtonElement::ShouldDisplayDownloadButton() const {
if (!MediaElement().SupportsSave()) if (!MediaElement().SupportsSave())
return false; return false;
...@@ -62,7 +62,8 @@ const char* MediaControlDownloadButtonElement::GetNameForHistograms() const { ...@@ -62,7 +62,8 @@ const char* MediaControlDownloadButtonElement::GetNameForHistograms() const {
void MediaControlDownloadButtonElement::UpdateShownState() { void MediaControlDownloadButtonElement::UpdateShownState() {
MediaControlInputElement::UpdateShownState(); MediaControlInputElement::UpdateShownState();
if (GetMediaControls().DownloadInProductHelp()) { if (!MediaControlsImpl::IsModern() &&
GetMediaControls().DownloadInProductHelp()) {
GetMediaControls().DownloadInProductHelp()->SetDownloadButtonVisibility( GetMediaControls().DownloadInProductHelp()->SetDownloadButtonVisibility(
IsWanted() && DoesFit()); IsWanted() && DoesFit());
} }
......
...@@ -20,7 +20,7 @@ class MODULES_EXPORT MediaControlDownloadButtonElement final ...@@ -20,7 +20,7 @@ class MODULES_EXPORT MediaControlDownloadButtonElement final
// Returns true if the download button should be shown. We should // Returns true if the download button should be shown. We should
// show the button for only non-MSE, non-EME, and non-MediaStream content. // show the button for only non-MSE, non-EME, and non-MediaStream content.
bool ShouldDisplayDownloadButton(); bool ShouldDisplayDownloadButton() const;
// MediaControlInputElement overrides. // MediaControlInputElement overrides.
// TODO(mlamouri): add WillRespondToMouseClickEvents // TODO(mlamouri): add WillRespondToMouseClickEvents
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include "core/dom/events/Event.h" #include "core/dom/events/Event.h"
#include "core/input_type_names.h" #include "core/input_type_names.h"
#include "modules/media_controls/MediaControlsImpl.h" #include "modules/media_controls/MediaControlsImpl.h"
#include "modules/media_controls/MediaDownloadInProductHelpManager.h"
#include "modules/media_controls/elements/MediaControlDownloadButtonElement.h"
#include "public/platform/Platform.h" #include "public/platform/Platform.h"
namespace blink { namespace blink {
...@@ -28,6 +30,17 @@ const char* MediaControlOverflowMenuButtonElement::GetNameForHistograms() ...@@ -28,6 +30,17 @@ const char* MediaControlOverflowMenuButtonElement::GetNameForHistograms()
return "OverflowButton"; return "OverflowButton";
} }
void MediaControlOverflowMenuButtonElement::UpdateShownState() {
MediaControlInputElement::UpdateShownState();
if (MediaControlsImpl::IsModern() &&
GetMediaControls().DownloadInProductHelp()) {
GetMediaControls().DownloadInProductHelp()->SetDownloadButtonVisibility(
IsWanted() && DoesFit() &&
GetMediaControls().DownloadButton().ShouldDisplayDownloadButton());
}
}
void MediaControlOverflowMenuButtonElement::DefaultEventHandler(Event* event) { void MediaControlOverflowMenuButtonElement::DefaultEventHandler(Event* event) {
if (event->type() == EventTypeNames::click) { if (event->type() == EventTypeNames::click) {
if (GetMediaControls().OverflowMenuVisible()) { if (GetMediaControls().OverflowMenuVisible()) {
......
...@@ -24,6 +24,7 @@ class MediaControlOverflowMenuButtonElement final ...@@ -24,6 +24,7 @@ class MediaControlOverflowMenuButtonElement final
protected: protected:
const char* GetNameForHistograms() const override; const char* GetNameForHistograms() const override;
void UpdateShownState() final;
private: private:
void DefaultEventHandler(Event*) override; void DefaultEventHandler(Event*) override;
......
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