| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #ifndef MediaControlElements_h | 30 #ifndef MediaControlElements_h |
| 31 #define MediaControlElements_h | 31 #define MediaControlElements_h |
| 32 | 32 |
| 33 #include "core/html/shadow/MediaControlElementTypes.h" | 33 #include "core/html/shadow/MediaControlElementTypes.h" |
| 34 #include "core/html/shadow/MediaControlTimelineMetrics.h" | 34 #include "core/html/shadow/MediaControlTimelineMetrics.h" |
| 35 #include "public/platform/WebLocalizedString.h" | |
| 36 | 35 |
| 37 namespace blink { | 36 namespace blink { |
| 38 | 37 |
| 39 // Represents a button that allows users to download media if the file is | |
| 40 // downloadable. | |
| 41 class CORE_EXPORT MediaControlDownloadButtonElement final | |
| 42 : public MediaControlInputElement { | |
| 43 public: | |
| 44 static MediaControlDownloadButtonElement* Create(MediaControls&); | |
| 45 | |
| 46 WebLocalizedString::Name GetOverflowStringName() override; | |
| 47 | |
| 48 bool HasOverflowButton() override { return true; } | |
| 49 | |
| 50 // Returns true if the download button should be shown. We should | |
| 51 // show the button for only non-MSE, non-EME, and non-MediaStream content. | |
| 52 bool ShouldDisplayDownloadButton(); | |
| 53 | |
| 54 void SetIsWanted(bool) override; | |
| 55 | |
| 56 DECLARE_VIRTUAL_TRACE(); | |
| 57 | |
| 58 private: | |
| 59 explicit MediaControlDownloadButtonElement(MediaControls&); | |
| 60 | |
| 61 void DefaultEventHandler(Event*) override; | |
| 62 | |
| 63 // Points to an anchor element that contains the URL of the media file. | |
| 64 Member<HTMLAnchorElement> anchor_; | |
| 65 | |
| 66 // This is used for UMA histogram (Media.Controls.Download). New values should | |
| 67 // be appended only and must be added before |Count|. | |
| 68 enum class DownloadActionMetrics { | |
| 69 kShown = 0, | |
| 70 kClicked, | |
| 71 kCount // Keep last. | |
| 72 }; | |
| 73 void RecordMetrics(DownloadActionMetrics); | |
| 74 | |
| 75 // UMA related boolean. They are used to prevent counting something twice | |
| 76 // for the same media element. | |
| 77 bool click_use_counted_ = false; | |
| 78 bool show_use_counted_ = false; | |
| 79 }; | |
| 80 | |
| 81 class CORE_EXPORT MediaControlTimelineElement final | 38 class CORE_EXPORT MediaControlTimelineElement final |
| 82 : public MediaControlInputElement { | 39 : public MediaControlInputElement { |
| 83 public: | 40 public: |
| 84 static MediaControlTimelineElement* Create(MediaControls&); | 41 static MediaControlTimelineElement* Create(MediaControls&); |
| 85 | 42 |
| 86 bool WillRespondToMouseClickEvents() override; | 43 bool WillRespondToMouseClickEvents() override; |
| 87 | 44 |
| 88 // FIXME: An "earliest possible position" will be needed once that concept | 45 // FIXME: An "earliest possible position" will be needed once that concept |
| 89 // is supported by HTMLMediaElement, see https://crbug.com/137275 | 46 // is supported by HTMLMediaElement, see https://crbug.com/137275 |
| 90 void SetPosition(double); | 47 void SetPosition(double); |
| 91 void SetDuration(double); | 48 void SetDuration(double); |
| 92 | 49 |
| 93 void OnPlaying(); | 50 void OnPlaying(); |
| 94 | 51 |
| 95 private: | 52 private: |
| 96 explicit MediaControlTimelineElement(MediaControls&); | 53 explicit MediaControlTimelineElement(MediaControls&); |
| 97 | 54 |
| 98 void DefaultEventHandler(Event*) override; | 55 void DefaultEventHandler(Event*) override; |
| 99 bool KeepEventInNode(Event*) override; | 56 bool KeepEventInNode(Event*) override; |
| 100 | 57 |
| 101 // Width in CSS pixels * pageZoomFactor (ignores CSS transforms for | 58 // Width in CSS pixels * pageZoomFactor (ignores CSS transforms for |
| 102 // simplicity; deliberately ignores pinch zoom's pageScaleFactor). | 59 // simplicity; deliberately ignores pinch zoom's pageScaleFactor). |
| 103 int TimelineWidth(); | 60 int TimelineWidth(); |
| 104 | 61 |
| 105 MediaControlTimelineMetrics metrics_; | 62 MediaControlTimelineMetrics metrics_; |
| 106 }; | 63 }; |
| 107 | 64 |
| 108 // ---------------------------- | 65 // ---------------------------- |
| 109 | 66 |
| 110 class CORE_EXPORT MediaControlCastButtonElement final | |
| 111 : public MediaControlInputElement { | |
| 112 public: | |
| 113 static MediaControlCastButtonElement* Create(MediaControls&, | |
| 114 bool is_overlay_button); | |
| 115 | |
| 116 bool WillRespondToMouseClickEvents() override { return true; } | |
| 117 | |
| 118 void SetIsPlayingRemotely(bool); | |
| 119 | |
| 120 WebLocalizedString::Name GetOverflowStringName() override; | |
| 121 | |
| 122 bool HasOverflowButton() override { return true; } | |
| 123 | |
| 124 // This will show a cast button if it is not covered by another element. | |
| 125 // This MUST be called for cast button elements that are overlay elements. | |
| 126 void TryShowOverlay(); | |
| 127 | |
| 128 private: | |
| 129 explicit MediaControlCastButtonElement(MediaControls&, | |
| 130 bool is_overlay_button); | |
| 131 | |
| 132 void DefaultEventHandler(Event*) override; | |
| 133 bool KeepEventInNode(Event*) override; | |
| 134 | |
| 135 bool is_overlay_button_; | |
| 136 | |
| 137 // This is used for UMA histogram (Cast.Sender.Overlay). New values should | |
| 138 // be appended only and must be added before |Count|. | |
| 139 enum class CastOverlayMetrics { | |
| 140 kCreated = 0, | |
| 141 kShown, | |
| 142 kClicked, | |
| 143 kCount // Keep last. | |
| 144 }; | |
| 145 void RecordMetrics(CastOverlayMetrics); | |
| 146 | |
| 147 // UMA related boolean. They are used to prevent counting something twice | |
| 148 // for the same media element. | |
| 149 bool click_use_counted_ = false; | |
| 150 bool show_use_counted_ = false; | |
| 151 }; | |
| 152 | |
| 153 // ---------------------------- | |
| 154 | |
| 155 class CORE_EXPORT MediaControlVolumeSliderElement final | 67 class CORE_EXPORT MediaControlVolumeSliderElement final |
| 156 : public MediaControlInputElement { | 68 : public MediaControlInputElement { |
| 157 public: | 69 public: |
| 158 static MediaControlVolumeSliderElement* Create(MediaControls&); | 70 static MediaControlVolumeSliderElement* Create(MediaControls&); |
| 159 | 71 |
| 160 bool WillRespondToMouseMoveEvents() override; | 72 bool WillRespondToMouseMoveEvents() override; |
| 161 bool WillRespondToMouseClickEvents() override; | 73 bool WillRespondToMouseClickEvents() override; |
| 162 void SetVolume(double); | 74 void SetVolume(double); |
| 163 | 75 |
| 164 private: | 76 private: |
| 165 explicit MediaControlVolumeSliderElement(MediaControls&); | 77 explicit MediaControlVolumeSliderElement(MediaControls&); |
| 166 | 78 |
| 167 void DefaultEventHandler(Event*) override; | 79 void DefaultEventHandler(Event*) override; |
| 168 bool KeepEventInNode(Event*) override; | 80 bool KeepEventInNode(Event*) override; |
| 169 }; | 81 }; |
| 170 | 82 |
| 171 } // namespace blink | 83 } // namespace blink |
| 172 | 84 |
| 173 #endif // MediaControlElements_h | 85 #endif // MediaControlElements_h |
| OLD | NEW |