Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: third_party/WebKit/Source/core/html/shadow/MediaControls.cpp

Issue 2657723002: [Blink, Media] Added controlsList to HTMLMediaElement (Closed)
Patch Set: Addressed nits Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2011, 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 * 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 14 matching lines...) Expand all
25 */ 25 */
26 26
27 #include "core/html/shadow/MediaControls.h" 27 #include "core/html/shadow/MediaControls.h"
28 28
29 #include "bindings/core/v8/ExceptionState.h" 29 #include "bindings/core/v8/ExceptionState.h"
30 #include "core/dom/ClientRect.h" 30 #include "core/dom/ClientRect.h"
31 #include "core/dom/Fullscreen.h" 31 #include "core/dom/Fullscreen.h"
32 #include "core/dom/TaskRunnerHelper.h" 32 #include "core/dom/TaskRunnerHelper.h"
33 #include "core/events/MouseEvent.h" 33 #include "core/events/MouseEvent.h"
34 #include "core/frame/Settings.h" 34 #include "core/frame/Settings.h"
35 #include "core/frame/UseCounter.h"
35 #include "core/html/HTMLMediaElement.h" 36 #include "core/html/HTMLMediaElement.h"
36 #include "core/html/HTMLVideoElement.h" 37 #include "core/html/HTMLVideoElement.h"
37 #include "core/html/shadow/MediaControlsMediaEventListener.h" 38 #include "core/html/shadow/MediaControlsMediaEventListener.h"
38 #include "core/html/shadow/MediaControlsOrientationLockDelegate.h" 39 #include "core/html/shadow/MediaControlsOrientationLockDelegate.h"
39 #include "core/html/shadow/MediaControlsWindowEventListener.h" 40 #include "core/html/shadow/MediaControlsWindowEventListener.h"
40 #include "core/html/track/TextTrackContainer.h" 41 #include "core/html/track/TextTrackContainer.h"
41 #include "core/html/track/TextTrackList.h" 42 #include "core/html/track/TextTrackList.h"
42 #include "core/layout/LayoutObject.h" 43 #include "core/layout/LayoutObject.h"
43 #include "core/layout/LayoutTheme.h" 44 #include "core/layout/LayoutTheme.h"
44 #include "platform/EventDispatchForbiddenScope.h" 45 #include "platform/EventDispatchForbiddenScope.h"
(...skipping 15 matching lines...) Expand all
60 61
61 if (!mediaElement.isHTMLVideoElement()) 62 if (!mediaElement.isHTMLVideoElement())
62 return false; 63 return false;
63 64
64 if (!mediaElement.hasVideo()) 65 if (!mediaElement.hasVideo())
65 return false; 66 return false;
66 67
67 if (!Fullscreen::fullscreenEnabled(mediaElement.document())) 68 if (!Fullscreen::fullscreenEnabled(mediaElement.document()))
68 return false; 69 return false;
69 70
71 if (mediaElement.controlsList()->tokens().contains("nofullscreen")) {
DaleCurtis 2017/03/09 18:45:48 Do you really want callers to have to know about t
whywhat 2017/03/09 19:56:45 Good suggestion! Done.
72 UseCounter::count(mediaElement.document(),
73 UseCounter::HTMLMediaElementControlsListNoFullscreen);
74 return false;
75 }
76
70 return true; 77 return true;
71 } 78 }
72 79
73 static bool shouldShowCastButton(HTMLMediaElement& mediaElement) { 80 static bool shouldShowCastButton(HTMLMediaElement& mediaElement) {
74 if (mediaElement.fastHasAttribute(HTMLNames::disableremoteplaybackAttr)) 81 if (mediaElement.fastHasAttribute(HTMLNames::disableremoteplaybackAttr))
75 return false; 82 return false;
76 83
77 // Explicitly do not show cast button when the mediaControlsEnabled setting is 84 // Explicitly do not show cast button when the mediaControlsEnabled setting is
78 // false to make sure the overlay does not appear. 85 // false to make sure the overlay does not appear.
79 Document& document = mediaElement.document(); 86 Document& document = mediaElement.document();
80 if (document.settings() && !document.settings()->getMediaControlsEnabled()) 87 if (document.settings() && !document.settings()->getMediaControlsEnabled())
81 return false; 88 return false;
82 89
90 // The page disabled the button via the attribute.
91 if (mediaElement.controlsList()->tokens().contains("noremoteplayback")) {
92 UseCounter::count(mediaElement.document(),
93 UseCounter::HTMLMediaElementControlsListNoRemotePlayback);
94 return false;
95 }
96
83 return mediaElement.hasRemoteRoutes(); 97 return mediaElement.hasRemoteRoutes();
84 } 98 }
85 99
86 static bool preferHiddenVolumeControls(const Document& document) { 100 static bool preferHiddenVolumeControls(const Document& document) {
87 return !document.settings() || 101 return !document.settings() ||
88 document.settings()->getPreferHiddenVolumeControls(); 102 document.settings()->getPreferHiddenVolumeControls();
89 } 103 }
90 104
91 class MediaControls::BatchedControlUpdate { 105 class MediaControls::BatchedControlUpdate {
92 WTF_MAKE_NONCOPYABLE(BatchedControlUpdate); 106 WTF_MAKE_NONCOPYABLE(BatchedControlUpdate);
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 updatePlayState(); 404 updatePlayState();
391 405
392 updateCurrentTimeDisplay(); 406 updateCurrentTimeDisplay();
393 407
394 m_timeline->setDuration(duration); 408 m_timeline->setDuration(duration);
395 m_timeline->setPosition(mediaElement().currentTime()); 409 m_timeline->setPosition(mediaElement().currentTime());
396 410
397 onVolumeChange(); 411 onVolumeChange();
398 onTextTracksAddedOrRemoved(); 412 onTextTracksAddedOrRemoved();
399 413
414 onControlsListUpdated();
415 }
416
417 void MediaControls::onControlsListUpdated() {
418 BatchedControlUpdate batch(this);
419
400 m_fullscreenButton->setIsWanted(shouldShowFullscreenButton(mediaElement())); 420 m_fullscreenButton->setIsWanted(shouldShowFullscreenButton(mediaElement()));
401 421
402 refreshCastButtonVisibilityWithoutUpdate(); 422 refreshCastButtonVisibilityWithoutUpdate();
403 423
404 m_downloadButton->setIsWanted( 424 m_downloadButton->setIsWanted(
405 m_downloadButton->shouldDisplayDownloadButton()); 425 m_downloadButton->shouldDisplayDownloadButton());
406 } 426 }
407 427
408 LayoutObject* MediaControls::layoutObjectForTextTrackLayout() { 428 LayoutObject* MediaControls::layoutObjectForTextTrackLayout() {
409 return m_panel->layoutObject(); 429 return m_panel->layoutObject();
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 visitor->trace(m_overflowList); 1029 visitor->trace(m_overflowList);
1010 visitor->trace(m_castButton); 1030 visitor->trace(m_castButton);
1011 visitor->trace(m_overlayCastButton); 1031 visitor->trace(m_overlayCastButton);
1012 visitor->trace(m_mediaEventListener); 1032 visitor->trace(m_mediaEventListener);
1013 visitor->trace(m_windowEventListener); 1033 visitor->trace(m_windowEventListener);
1014 visitor->trace(m_orientationLockDelegate); 1034 visitor->trace(m_orientationLockDelegate);
1015 HTMLDivElement::trace(visitor); 1035 HTMLDivElement::trace(visitor);
1016 } 1036 }
1017 1037
1018 } // namespace blink 1038 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/shadow/MediaControls.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698