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

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

Issue 2795783004: Move core MediaControls implementation to modules/media_controls/. (Closed)
Patch Set: rebase Created 3 years, 8 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) 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "core/frame/LocalFrameClient.h" 49 #include "core/frame/LocalFrameClient.h"
50 #include "core/frame/Settings.h" 50 #include "core/frame/Settings.h"
51 #include "core/frame/UseCounter.h" 51 #include "core/frame/UseCounter.h"
52 #include "core/frame/csp/ContentSecurityPolicy.h" 52 #include "core/frame/csp/ContentSecurityPolicy.h"
53 #include "core/html/HTMLSourceElement.h" 53 #include "core/html/HTMLSourceElement.h"
54 #include "core/html/HTMLTrackElement.h" 54 #include "core/html/HTMLTrackElement.h"
55 #include "core/html/TimeRanges.h" 55 #include "core/html/TimeRanges.h"
56 #include "core/html/media/AutoplayUmaHelper.h" 56 #include "core/html/media/AutoplayUmaHelper.h"
57 #include "core/html/media/HTMLMediaElementControlsList.h" 57 #include "core/html/media/HTMLMediaElementControlsList.h"
58 #include "core/html/media/HTMLMediaSource.h" 58 #include "core/html/media/HTMLMediaSource.h"
59 #include "core/html/media/MediaControls.h"
59 #include "core/html/media/MediaError.h" 60 #include "core/html/media/MediaError.h"
60 #include "core/html/media/MediaFragmentURIParser.h" 61 #include "core/html/media/MediaFragmentURIParser.h"
61 #include "core/html/shadow/MediaControls.h"
62 #include "core/html/track/AudioTrack.h" 62 #include "core/html/track/AudioTrack.h"
63 #include "core/html/track/AudioTrackList.h" 63 #include "core/html/track/AudioTrackList.h"
64 #include "core/html/track/AutomaticTrackSelection.h" 64 #include "core/html/track/AutomaticTrackSelection.h"
65 #include "core/html/track/CueTimeline.h" 65 #include "core/html/track/CueTimeline.h"
66 #include "core/html/track/InbandTextTrack.h" 66 #include "core/html/track/InbandTextTrack.h"
67 #include "core/html/track/TextTrackContainer.h" 67 #include "core/html/track/TextTrackContainer.h"
68 #include "core/html/track/TextTrackList.h" 68 #include "core/html/track/TextTrackList.h"
69 #include "core/html/track/VideoTrack.h" 69 #include "core/html/track/VideoTrack.h"
70 #include "core/html/track/VideoTrackList.h" 70 #include "core/html/track/VideoTrackList.h"
71 #include "core/inspector/ConsoleMessage.h" 71 #include "core/inspector/ConsoleMessage.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 320 }
321 321
322 if (document.settings()->getCrossOriginMediaPlaybackRequiresUserGesture() && 322 if (document.settings()->getCrossOriginMediaPlaybackRequiresUserGesture() &&
323 isDocumentCrossOrigin(document)) { 323 isDocumentCrossOrigin(document)) {
324 return true; 324 return true;
325 } 325 }
326 326
327 return document.settings()->getMediaPlaybackRequiresUserGesture(); 327 return document.settings()->getMediaPlaybackRequiresUserGesture();
328 } 328 }
329 329
330 std::unique_ptr<MediaControls::Factory>& mediaControlsFactory() {
331 DEFINE_STATIC_LOCAL(std::unique_ptr<MediaControls::Factory>,
332 s_mediaControlsFactory, ());
333 return s_mediaControlsFactory;
334 }
335
330 } // anonymous namespace 336 } // anonymous namespace
331 337
332 MIMETypeRegistry::SupportsType HTMLMediaElement::supportsType( 338 MIMETypeRegistry::SupportsType HTMLMediaElement::supportsType(
333 const ContentType& contentType) { 339 const ContentType& contentType) {
334 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs")); 340 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs"));
335 341
336 String type = contentType.type().lower(); 342 String type = contentType.type().lower();
337 // The codecs string is not lower-cased because MP4 values are case sensitive 343 // The codecs string is not lower-cased because MP4 values are case sensitive
338 // per http://tools.ietf.org/html/rfc4281#page-7. 344 // per http://tools.ietf.org/html/rfc4281#page-7.
339 String typeCodecs = contentType.parameter(codecs); 345 String typeCodecs = contentType.parameter(codecs);
(...skipping 30 matching lines...) Expand all
370 return false; 376 return false;
371 377
372 return url.getString().contains("m3u8"); 378 return url.getString().contains("m3u8");
373 } 379 }
374 380
375 bool HTMLMediaElement::mediaTracksEnabledInternally() { 381 bool HTMLMediaElement::mediaTracksEnabledInternally() {
376 return RuntimeEnabledFeatures::audioVideoTracksEnabled() || 382 return RuntimeEnabledFeatures::audioVideoTracksEnabled() ||
377 RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled(); 383 RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled();
378 } 384 }
379 385
386 // static
380 void HTMLMediaElement::onMediaControlsEnabledChange(Document* document) { 387 void HTMLMediaElement::onMediaControlsEnabledChange(Document* document) {
381 auto it = documentToElementSetMap().find(document); 388 auto it = documentToElementSetMap().find(document);
382 if (it == documentToElementSetMap().end()) 389 if (it == documentToElementSetMap().end())
383 return; 390 return;
384 DCHECK(it->value); 391 DCHECK(it->value);
385 WeakMediaElementSet& elements = *it->value; 392 WeakMediaElementSet& elements = *it->value;
386 for (const auto& element : elements) { 393 for (const auto& element : elements) {
387 element->updateControlsVisibility(); 394 element->updateControlsVisibility();
388 if (element->mediaControls()) 395 if (element->mediaControls())
389 element->mediaControls()->onMediaControlsEnabledChange(); 396 element->mediaControls()->onMediaControlsEnabledChange();
390 } 397 }
391 } 398 }
392 399
400 // static
401 void HTMLMediaElement::registerMediaControlsFactory(
402 std::unique_ptr<MediaControls::Factory> factory) {
403 DCHECK(!mediaControlsFactory());
404 mediaControlsFactory() = std::move(factory);
405 }
406
393 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, 407 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName,
394 Document& document) 408 Document& document)
395 : HTMLElement(tagName, document), 409 : HTMLElement(tagName, document),
396 SuspendableObject(&document), 410 SuspendableObject(&document),
397 m_loadTimer(TaskRunnerHelper::get(TaskType::Unthrottled, &document), 411 m_loadTimer(TaskRunnerHelper::get(TaskType::Unthrottled, &document),
398 this, 412 this,
399 &HTMLMediaElement::loadTimerFired), 413 &HTMLMediaElement::loadTimerFired),
400 m_progressEventTimer( 414 m_progressEventTimer(
401 TaskRunnerHelper::get(TaskType::Unthrottled, &document), 415 TaskRunnerHelper::get(TaskType::Unthrottled, &document),
402 this, 416 this,
(...skipping 3289 matching lines...) Expand 10 before | Expand all | Expand 10 after
3692 document().incrementLoadEventDelayCount(); 3706 document().incrementLoadEventDelayCount();
3693 else 3707 else
3694 document().decrementLoadEventDelayCount(); 3708 document().decrementLoadEventDelayCount();
3695 } 3709 }
3696 3710
3697 MediaControls* HTMLMediaElement::mediaControls() const { 3711 MediaControls* HTMLMediaElement::mediaControls() const {
3698 return m_mediaControls; 3712 return m_mediaControls;
3699 } 3713 }
3700 3714
3701 void HTMLMediaElement::ensureMediaControls() { 3715 void HTMLMediaElement::ensureMediaControls() {
3702 if (mediaControls()) 3716 if (mediaControls() || !mediaControlsFactory())
3703 return; 3717 return;
3704 3718
3705 ShadowRoot& shadowRoot = ensureUserAgentShadowRoot(); 3719 ShadowRoot& shadowRoot = ensureUserAgentShadowRoot();
3706 m_mediaControls = MediaControls::create(*this, shadowRoot); 3720 m_mediaControls = mediaControlsFactory()->create(*this, shadowRoot);
3707 3721
3708 // The media controls should be inserted after the text track container, 3722 // The media controls should be inserted after the text track container,
3709 // so that they are rendered in front of captions and subtitles. This check 3723 // so that they are rendered in front of captions and subtitles. This check
3710 // is verifying the contract. 3724 // is verifying the contract.
3711 assertShadowRootChildren(shadowRoot); 3725 assertShadowRootChildren(shadowRoot);
3712 } 3726 }
3713 3727
3714 void HTMLMediaElement::updateControlsVisibility() { 3728 void HTMLMediaElement::updateControlsVisibility() {
3715 if (!isConnected()) { 3729 if (!isConnected()) {
3716 if (mediaControls()) 3730 if (mediaControls())
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
4192 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); 4206 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE);
4193 } 4207 }
4194 4208
4195 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { 4209 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) {
4196 m_mostlyFillingViewport = true; 4210 m_mostlyFillingViewport = true;
4197 if (m_webMediaPlayer) 4211 if (m_webMediaPlayer)
4198 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); 4212 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport);
4199 } 4213 }
4200 4214
4201 } // namespace blink 4215 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698