| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "modules/media_controls/elements/MediaControlOverlayPlayButtonElement.h
" |
| 6 |
| 7 #include "core/InputTypeNames.h" |
| 8 #include "core/events/Event.h" |
| 9 #include "core/html/HTMLMediaElement.h" |
| 10 #include "modules/media_controls/MediaControlsImpl.h" |
| 11 #include "modules/media_controls/elements/MediaControlElementsHelper.h" |
| 12 #include "public/platform/Platform.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 MediaControlOverlayPlayButtonElement::MediaControlOverlayPlayButtonElement( |
| 17 MediaControlsImpl& media_controls) |
| 18 : MediaControlInputElement(media_controls, kMediaOverlayPlayButton) { |
| 19 EnsureUserAgentShadowRoot(); |
| 20 setType(InputTypeNames::button); |
| 21 SetShadowPseudoId(AtomicString("-webkit-media-controls-overlay-play-button")); |
| 22 } |
| 23 |
| 24 void MediaControlOverlayPlayButtonElement::UpdateDisplayType() { |
| 25 SetIsWanted(MediaElement().ShouldShowControls() && MediaElement().paused()); |
| 26 } |
| 27 |
| 28 void MediaControlOverlayPlayButtonElement::DefaultEventHandler(Event* event) { |
| 29 if (event->type() == EventTypeNames::click && MediaElement().paused()) { |
| 30 Platform::Current()->RecordAction( |
| 31 UserMetricsAction("Media.Controls.PlayOverlay")); |
| 32 MediaElement().Play(); |
| 33 UpdateDisplayType(); |
| 34 event->SetDefaultHandled(); |
| 35 } |
| 36 // TODO(mlamouri): should call MediaControlInputElement::DefaultEventHandler. |
| 37 } |
| 38 |
| 39 bool MediaControlOverlayPlayButtonElement::KeepEventInNode(Event* event) { |
| 40 return MediaControlElementsHelper::IsUserInteractionEvent(event); |
| 41 } |
| 42 |
| 43 } // namespace blink |
| OLD | NEW |