Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/shadow/MediaControlElements.cpp |
| diff --git a/third_party/WebKit/Source/core/html/shadow/MediaControlElements.cpp b/third_party/WebKit/Source/core/html/shadow/MediaControlElements.cpp |
| index 5ee318d0787ea6224830fa52b12f8dbf411a8df4..3efd70c7ee5ac5dd7317a84ff4d43bf4b9135209 100644 |
| --- a/third_party/WebKit/Source/core/html/shadow/MediaControlElements.cpp |
| +++ b/third_party/WebKit/Source/core/html/shadow/MediaControlElements.cpp |
| @@ -45,6 +45,8 @@ |
| #include "core/layout/api/LayoutSliderItem.h" |
| #include "platform/Histogram.h" |
| #include "platform/RuntimeEnabledFeatures.h" |
| +#include "public/platform/Platform.h" |
| +#include "public/platform/UserMetricsAction.h" |
| namespace blink { |
| @@ -254,6 +256,11 @@ MediaControlMuteButtonElement* MediaControlMuteButtonElement::create(MediaContro |
| void MediaControlMuteButtonElement::defaultEventHandler(Event* event) |
| { |
| if (event->type() == EventTypeNames::click) { |
| + if (mediaElement().muted()) |
| + Platform::current()->recordAction(UserMetricsAction("Media.Controls.Unmute")); |
| + else |
| + Platform::current()->recordAction(UserMetricsAction("Media.Controls.Mute")); |
| + |
| mediaElement().setMuted(!mediaElement().muted()); |
| event->setDefaultHandled(); |
| } |
| @@ -285,6 +292,11 @@ MediaControlPlayButtonElement* MediaControlPlayButtonElement::create(MediaContro |
| void MediaControlPlayButtonElement::defaultEventHandler(Event* event) |
| { |
| if (event->type() == EventTypeNames::click) { |
| + if (mediaElement().paused()) |
| + Platform::current()->recordAction(UserMetricsAction("Media.Controls.Play")); |
| + else |
| + Platform::current()->recordAction(UserMetricsAction("Media.Controls.Pause")); |
| + |
| // Allow play attempts for plain src= media to force a reload in the error state. This allows potential |
| // recovery for transient network and decoder resource issues. |
| const String& url = mediaElement().currentSrc().getString(); |
| @@ -322,6 +334,7 @@ MediaControlOverlayPlayButtonElement* MediaControlOverlayPlayButtonElement::crea |
| void MediaControlOverlayPlayButtonElement::defaultEventHandler(Event* event) |
| { |
| if (event->type() == EventTypeNames::click && mediaElement().paused()) { |
| + Platform::current()->recordAction(UserMetricsAction("Media.Controls.PlayOverlay")); |
| mediaElement().play(); |
| updateDisplayType(); |
| event->setDefaultHandled(); |
| @@ -366,6 +379,10 @@ void MediaControlToggleClosedCaptionsButtonElement::updateDisplayType() |
| void MediaControlToggleClosedCaptionsButtonElement::defaultEventHandler(Event* event) |
| { |
| if (event->type() == EventTypeNames::click) { |
| + if (mediaElement().closedCaptionsVisible()) |
| + Platform::current()->recordAction(UserMetricsAction("Media.Controls.ClosedCaptionShow")); |
|
philipj_slow
2016/04/14 13:46:15
Isn't this the wrong way around?
mlamouri (slow - plz ping)
2016/04/14 15:46:30
Oh boy... Thanks! :)
|
| + else |
| + Platform::current()->recordAction(UserMetricsAction("Media.Controls.ClosedCaptionHide")); |
| mediaElement().setClosedCaptionsVisible(!mediaElement().closedCaptionsVisible()); |
| setChecked(mediaElement().closedCaptionsVisible()); |
| updateDisplayType(); |
| @@ -400,11 +417,15 @@ void MediaControlTimelineElement::defaultEventHandler(Event* event) |
| if (!inShadowIncludingDocument() || !document().isActive()) |
| return; |
| - if (event->type() == EventTypeNames::mousedown) |
| + if (event->type() == EventTypeNames::mousedown) { |
| + Platform::current()->recordAction(UserMetricsAction("Media.Controls.ScrubbingBegin")); |
|
philipj_slow
2016/04/14 13:46:15
Can anything much be learned from this? How about
mlamouri (slow - plz ping)
2016/04/14 15:46:30
I think the time spent seeking is an interesting m
|
| mediaControls().beginScrubbing(); |
| + } |
| - if (event->type() == EventTypeNames::mouseup) |
| + if (event->type() == EventTypeNames::mouseup) { |
| + Platform::current()->recordAction(UserMetricsAction("Media.Controls.ScrubbingEnd")); |
| mediaControls().endScrubbing(); |
| + } |
| MediaControlInputElement::defaultEventHandler(event); |
| @@ -481,6 +502,12 @@ void MediaControlVolumeSliderElement::defaultEventHandler(Event* event) |
| if (event->type() == EventTypeNames::mouseover || event->type() == EventTypeNames::mouseout || event->type() == EventTypeNames::mousemove) |
| return; |
| + if (event->type() == EventTypeNames::mousedown) |
| + Platform::current()->recordAction(UserMetricsAction("Media.Controls.VolumeChangeBegin")); |
|
philipj_slow
2016/04/14 13:46:15
Same question here.
mlamouri (slow - plz ping)
2016/04/14 15:46:30
Same here, though it's a bit weaker. I mostly did
|
| + |
| + if (event->type() == EventTypeNames::mouseup) |
| + Platform::current()->recordAction(UserMetricsAction("Media.Controls.VolumeChangeEnd")); |
| + |
| double volume = value().toDouble(); |
| mediaElement().setVolume(volume, ASSERT_NO_EXCEPTION); |
| mediaElement().setMuted(false); |
| @@ -533,10 +560,13 @@ MediaControlFullscreenButtonElement* MediaControlFullscreenButtonElement::create |
| void MediaControlFullscreenButtonElement::defaultEventHandler(Event* event) |
| { |
| if (event->type() == EventTypeNames::click) { |
| - if (mediaElement().isFullscreen()) |
| + if (mediaElement().isFullscreen()) { |
| + Platform::current()->recordAction(UserMetricsAction("Media.Controls.ExitFullscreen")); |
| mediaElement().exitFullscreen(); |
| - else |
| + } else { |
| + Platform::current()->recordAction(UserMetricsAction("Media.Controls.EnterFullscreen")); |
| mediaElement().enterFullscreen(); |
| + } |
| event->setDefaultHandled(); |
| } |
| HTMLInputElement::defaultEventHandler(event); |
| @@ -568,6 +598,11 @@ MediaControlCastButtonElement* MediaControlCastButtonElement::create(MediaContro |
| void MediaControlCastButtonElement::defaultEventHandler(Event* event) |
| { |
| if (event->type() == EventTypeNames::click) { |
| + if (m_isOverlayButton) |
| + Platform::current()->recordAction(UserMetricsAction("Media.Controls.CastOverlay")); |
| + else |
| + Platform::current()->recordAction(UserMetricsAction("Media.Controls.Cast")); |
| + |
| if (m_isOverlayButton && !m_clickUseCounted) { |
| m_clickUseCounted = true; |
| recordMetrics(CastOverlayMetrics::Clicked); |