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()
return *download_button_;
}
const MediaControlOverflowMenuButtonElement& MediaControlsImpl::OverflowButton()
const {
return *overflow_menu_;
}
void MediaControlsImpl::DidDismissDownloadInProductHelp() {
StartHideMediaControlsIfNecessary();
}
......
......@@ -140,6 +140,7 @@ class MODULES_EXPORT MediaControlsImpl final : public HTMLDivElement,
// Methods used for Download In-product help.
const MediaControlDownloadButtonElement& DownloadButton() const;
const MediaControlOverflowMenuButtonElement& OverflowButton() const;
void DidDismissDownloadInProductHelp();
MediaDownloadInProductHelpManager* DownloadInProductHelp();
......
......@@ -7,6 +7,7 @@
#include "core/frame/LocalFrameClient.h"
#include "modules/media_controls/MediaControlsImpl.h"
#include "modules/media_controls/elements/MediaControlDownloadButtonElement.h"
#include "modules/media_controls/elements/MediaControlOverflowMenuButtonElement.h"
#include "services/service_manager/public/cpp/interface_provider.h"
namespace blink {
......@@ -66,7 +67,9 @@ void MediaDownloadInProductHelpManager::
// If the button is not in the viewport, don't show the in-product-help.
IntRect button_rect =
controls_->DownloadButton().VisibleBoundsInVisualViewport();
controls_->IsModern()
? controls_->OverflowButton().VisibleBoundsInVisualViewport()
: controls_->DownloadButton().VisibleBoundsInVisualViewport();
if (button_rect.IsEmpty())
return;
......
......@@ -26,7 +26,7 @@ MediaControlDownloadButtonElement::MediaControlDownloadButtonElement(
SetIsWanted(false);
}
bool MediaControlDownloadButtonElement::ShouldDisplayDownloadButton() {
bool MediaControlDownloadButtonElement::ShouldDisplayDownloadButton() const {
if (!MediaElement().SupportsSave())
return false;
......@@ -62,7 +62,8 @@ const char* MediaControlDownloadButtonElement::GetNameForHistograms() const {
void MediaControlDownloadButtonElement::UpdateShownState() {
MediaControlInputElement::UpdateShownState();
if (GetMediaControls().DownloadInProductHelp()) {
if (!MediaControlsImpl::IsModern() &&
GetMediaControls().DownloadInProductHelp()) {
GetMediaControls().DownloadInProductHelp()->SetDownloadButtonVisibility(
IsWanted() && DoesFit());
}
......
......@@ -20,7 +20,7 @@ class MODULES_EXPORT MediaControlDownloadButtonElement final
// Returns true if the download button should be shown. We should
// show the button for only non-MSE, non-EME, and non-MediaStream content.
bool ShouldDisplayDownloadButton();
bool ShouldDisplayDownloadButton() const;
// MediaControlInputElement overrides.
// TODO(mlamouri): add WillRespondToMouseClickEvents
......
......@@ -7,6 +7,8 @@
#include "core/dom/events/Event.h"
#include "core/input_type_names.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"
namespace blink {
......@@ -28,6 +30,17 @@ const char* MediaControlOverflowMenuButtonElement::GetNameForHistograms()
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) {
if (event->type() == EventTypeNames::click) {
if (GetMediaControls().OverflowMenuVisible()) {
......
......@@ -24,6 +24,7 @@ class MediaControlOverflowMenuButtonElement final
protected:
const char* GetNameForHistograms() const override;
void UpdateShownState() final;
private:
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