| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights |
| 3 * reserved. | 3 * 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 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 using WeakMediaElementSet = HeapHashSet<WeakMember<HTMLMediaElement>>; | 123 using WeakMediaElementSet = HeapHashSet<WeakMember<HTMLMediaElement>>; |
| 124 using DocumentElementSetMap = | 124 using DocumentElementSetMap = |
| 125 HeapHashMap<WeakMember<Document>, Member<WeakMediaElementSet>>; | 125 HeapHashMap<WeakMember<Document>, Member<WeakMediaElementSet>>; |
| 126 | 126 |
| 127 namespace { | 127 namespace { |
| 128 | 128 |
| 129 constexpr float kMostlyFillViewportThreshold = 0.85f; | 129 constexpr float kMostlyFillViewportThreshold = 0.85f; |
| 130 constexpr double kMostlyFillViewportBecomeStableSeconds = 5; | 130 constexpr double kMostlyFillViewportBecomeStableSeconds = 5; |
| 131 constexpr double kCheckViewportIntersectionIntervalSeconds = 1; | 131 constexpr double kCheckViewportIntersectionIntervalSeconds = 1; |
| 132 | 132 |
| 133 // This enum is used to record histograms. Do not reorder. |
| 133 enum MediaControlsShow { | 134 enum MediaControlsShow { |
| 134 MediaControlsShowAttribute = 0, | 135 MediaControlsShowAttribute = 0, |
| 135 MediaControlsShowFullscreen, | 136 MediaControlsShowFullscreen, |
| 136 MediaControlsShowNoScript, | 137 MediaControlsShowNoScript, |
| 137 MediaControlsShowNotShown, | 138 MediaControlsShowNotShown, |
| 138 MediaControlsShowDisabledSettings, | 139 MediaControlsShowDisabledSettings, |
| 139 MediaControlsShowMax | 140 MediaControlsShowMax |
| 140 }; | 141 }; |
| 141 | 142 |
| 143 // This enum is used to record histograms. Do not reorder. |
| 144 enum VideoPersistenceControlsType { |
| 145 VideoPersistenceControlsTypeNative = 0, |
| 146 VideoPersistenceControlsTypeCustom, |
| 147 VideoPersistenceControlsTypeCount |
| 148 }; |
| 149 |
| 142 String urlForLoggingMedia(const KURL& url) { | 150 String urlForLoggingMedia(const KURL& url) { |
| 143 static const unsigned maximumURLLengthForLogging = 128; | 151 static const unsigned maximumURLLengthForLogging = 128; |
| 144 | 152 |
| 145 if (url.getString().length() < maximumURLLengthForLogging) | 153 if (url.getString().length() < maximumURLLengthForLogging) |
| 146 return url.getString(); | 154 return url.getString(); |
| 147 return url.getString().substring(0, maximumURLLengthForLogging) + "..."; | 155 return url.getString().substring(0, maximumURLLengthForLogging) + "..."; |
| 148 } | 156 } |
| 149 | 157 |
| 150 const char* boolString(bool val) { | 158 const char* boolString(bool val) { |
| 151 return val ? "true" : "false"; | 159 return val ? "true" : "false"; |
| (...skipping 3083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3235 if (remotePlaybackClient()) | 3243 if (remotePlaybackClient()) |
| 3236 remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Connected); | 3244 remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Connected); |
| 3237 } | 3245 } |
| 3238 | 3246 |
| 3239 // TODO(zqzhang): move logic for hiding controls here. | 3247 // TODO(zqzhang): move logic for hiding controls here. |
| 3240 void HTMLMediaElement::onBecamePersistentVideo(bool value) { | 3248 void HTMLMediaElement::onBecamePersistentVideo(bool value) { |
| 3241 if (!isHTMLVideoElement()) | 3249 if (!isHTMLVideoElement()) |
| 3242 return; | 3250 return; |
| 3243 | 3251 |
| 3244 if (value) { | 3252 if (value) { |
| 3253 // Record the type of video. If it is already fullscreen, it is a video with |
| 3254 // native controls, otherwise it is assumed to be with custom controls. |
| 3255 // This is only recorded when entering this mode. |
| 3256 DEFINE_STATIC_LOCAL(EnumerationHistogram, histogram, |
| 3257 ("Media.VideoPersistence.ControlsType", |
| 3258 VideoPersistenceControlsTypeCount)); |
| 3259 if (isFullscreen()) |
| 3260 histogram.count(VideoPersistenceControlsTypeNative); |
| 3261 else |
| 3262 histogram.count(VideoPersistenceControlsTypeCustom); |
| 3263 |
| 3245 if (isFullscreen()) | 3264 if (isFullscreen()) |
| 3246 return; | 3265 return; |
| 3247 | 3266 |
| 3248 UserGestureIndicator gestureIndicator( | 3267 UserGestureIndicator gestureIndicator( |
| 3249 DocumentUserGestureToken::create(&document())); | 3268 DocumentUserGestureToken::create(&document())); |
| 3250 Fullscreen::requestFullscreen(*this); | 3269 Fullscreen::requestFullscreen(*this); |
| 3251 m_isPersistentVideo = true; | 3270 m_isPersistentVideo = true; |
| 3252 } else { | 3271 } else { |
| 3253 if (!m_isPersistentVideo) | 3272 if (!m_isPersistentVideo) |
| 3254 return; | 3273 return; |
| (...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4222 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); | 4241 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); |
| 4223 } | 4242 } |
| 4224 | 4243 |
| 4225 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { | 4244 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { |
| 4226 m_mostlyFillingViewport = true; | 4245 m_mostlyFillingViewport = true; |
| 4227 if (m_webMediaPlayer) | 4246 if (m_webMediaPlayer) |
| 4228 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); | 4247 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); |
| 4229 } | 4248 } |
| 4230 | 4249 |
| 4231 } // namespace blink | 4250 } // namespace blink |
| OLD | NEW |