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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 #include "platform/audio/AudioSourceProvider.h" | 44 #include "platform/audio/AudioSourceProvider.h" |
45 #include "platform/network/mime/MIMETypeRegistry.h" | 45 #include "platform/network/mime/MIMETypeRegistry.h" |
46 #include "public/platform/WebAudioSourceProviderClient.h" | 46 #include "public/platform/WebAudioSourceProviderClient.h" |
47 #include "public/platform/WebMediaPlayerClient.h" | 47 #include "public/platform/WebMediaPlayerClient.h" |
48 | 48 |
49 namespace blink { | 49 namespace blink { |
50 | 50 |
51 class AudioSourceProviderClient; | 51 class AudioSourceProviderClient; |
52 class AudioTrack; | 52 class AudioTrack; |
53 class AudioTrackList; | 53 class AudioTrackList; |
54 class AutoplayPolicy; | |
54 class AutoplayUmaHelper; | 55 class AutoplayUmaHelper; |
55 class ContentType; | 56 class ContentType; |
56 class CueTimeline; | 57 class CueTimeline; |
57 class ElementVisibilityObserver; | |
58 class EnumerationHistogram; | 58 class EnumerationHistogram; |
59 class Event; | 59 class Event; |
60 class ExceptionState; | 60 class ExceptionState; |
61 class HTMLMediaElementControlsList; | 61 class HTMLMediaElementControlsList; |
62 class HTMLSourceElement; | 62 class HTMLSourceElement; |
63 class HTMLTrackElement; | 63 class HTMLTrackElement; |
64 class KURL; | 64 class KURL; |
65 class MediaError; | 65 class MediaError; |
66 class MediaStreamDescriptor; | 66 class MediaStreamDescriptor; |
67 class HTMLMediaSource; | 67 class HTMLMediaSource; |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 | 323 |
324 void VideoWillBeDrawnToCanvas() const; | 324 void VideoWillBeDrawnToCanvas() const; |
325 | 325 |
326 WebRemotePlaybackClient* RemotePlaybackClient() { | 326 WebRemotePlaybackClient* RemotePlaybackClient() { |
327 return remote_playback_client_; | 327 return remote_playback_client_; |
328 } | 328 } |
329 const WebRemotePlaybackClient* RemotePlaybackClient() const { | 329 const WebRemotePlaybackClient* RemotePlaybackClient() const { |
330 return remote_playback_client_; | 330 return remote_playback_client_; |
331 } | 331 } |
332 | 332 |
333 const AutoplayPolicy& autoplay_policy() const { return *autoplay_policy_; } | |
334 AutoplayUmaHelper& autoplay_uma_helper() { return *autoplay_uma_helper_; } | |
mlamouri (slow - plz ping)
2017/04/18 13:28:28
For some reasons, Blink coding style doesn't allow
Zhiqiang Zhang (Slow)
2017/04/18 16:56:44
Done.
| |
335 | |
333 protected: | 336 protected: |
334 HTMLMediaElement(const QualifiedName&, Document&); | 337 HTMLMediaElement(const QualifiedName&, Document&); |
335 ~HTMLMediaElement() override; | 338 ~HTMLMediaElement() override; |
336 void Dispose(); | 339 void Dispose(); |
337 | 340 |
338 void ParseAttribute(const AttributeModificationParams&) override; | 341 void ParseAttribute(const AttributeModificationParams&) override; |
339 void FinishParsingChildren() final; | 342 void FinishParsingChildren() final; |
340 bool IsURLAttribute(const Attribute&) const override; | 343 bool IsURLAttribute(const Attribute&) const override; |
341 void AttachLayoutTree(const AttachContext& = AttachContext()) override; | 344 void AttachLayoutTree(const AttachContext& = AttachContext()) override; |
342 | 345 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
517 // WebMemediaPlayer objects advertise they have audio and/or video, but don't | 520 // WebMemediaPlayer objects advertise they have audio and/or video, but don't |
518 // explicitly signal them via addAudioTrack() and addVideoTrack(). | 521 // explicitly signal them via addAudioTrack() and addVideoTrack(). |
519 // FIXME: Remove this once all WebMediaPlayer implementations properly report | 522 // FIXME: Remove this once all WebMediaPlayer implementations properly report |
520 // their track info. | 523 // their track info. |
521 void CreatePlaceholderTracksIfNecessary(); | 524 void CreatePlaceholderTracksIfNecessary(); |
522 | 525 |
523 // Sets the selected/enabled tracks if they aren't set before we initially | 526 // Sets the selected/enabled tracks if they aren't set before we initially |
524 // transition to kHaveMetadata. | 527 // transition to kHaveMetadata. |
525 void SelectInitialTracksIfNecessary(); | 528 void SelectInitialTracksIfNecessary(); |
526 | 529 |
527 // Return true if and only if a user gesture is required to unlock this | |
528 // media element for unrestricted autoplay / script control. Don't confuse | |
529 // this with isGestureNeededForPlayback(). The latter is usually what one | |
530 // should use, if checking to see if an action is allowed. | |
531 bool IsLockedPendingUserGesture() const; | |
532 | |
533 bool IsLockedPendingUserGestureIfCrossOriginExperimentEnabled() const; | |
534 | |
535 // If the user gesture is required, then this will remove it. Note that | |
536 // one should not generally call this method directly; use the one on | |
537 // m_helper and give it a reason. | |
538 void UnlockUserGesture(); | |
539 | |
540 // Return true if and only if a user gesture is requried for playback. Even | |
541 // if isLockedPendingUserGesture() return true, this might return false if | |
542 // the requirement is currently overridden. This does not check if a user | |
543 // gesture is currently being processed. | |
544 bool IsGestureNeededForPlayback() const; | |
545 | |
546 bool IsGestureNeededForPlaybackIfCrossOriginExperimentEnabled() const; | |
547 | |
548 bool IsGestureNeededForPlaybackIfPendingUserGestureIsLocked() const; | |
549 | |
550 // Return true if and only if the settings allow autoplay of media on this | |
551 // frame. | |
552 bool IsAutoplayAllowedPerSettings() const; | |
553 | |
554 void SetNetworkState(NetworkState); | 530 void SetNetworkState(NetworkState); |
555 | 531 |
556 void AudioTracksTimerFired(TimerBase*); | 532 void AudioTracksTimerFired(TimerBase*); |
557 | 533 |
558 void ScheduleResolvePlayPromises(); | 534 void ScheduleResolvePlayPromises(); |
559 void ScheduleRejectPlayPromises(ExceptionCode); | 535 void ScheduleRejectPlayPromises(ExceptionCode); |
560 void ScheduleNotifyPlaying(); | 536 void ScheduleNotifyPlaying(); |
561 void ResolveScheduledPlayPromises(); | 537 void ResolveScheduledPlayPromises(); |
562 void RejectScheduledPlayPromises(); | 538 void RejectScheduledPlayPromises(); |
563 void RejectPlayPromises(ExceptionCode, const String&); | 539 void RejectPlayPromises(ExceptionCode, const String&); |
564 void RejectPlayPromisesInternal(ExceptionCode, const String&); | 540 void RejectPlayPromisesInternal(ExceptionCode, const String&); |
565 | 541 |
566 EnumerationHistogram& ShowControlsHistogram() const; | 542 EnumerationHistogram& ShowControlsHistogram() const; |
567 | 543 |
568 void OnVisibilityChangedForAutoplay(bool is_visible); | |
569 | |
570 void ViewportFillDebouncerTimerFired(TimerBase*); | 544 void ViewportFillDebouncerTimerFired(TimerBase*); |
571 | 545 |
572 TaskRunnerTimer<HTMLMediaElement> load_timer_; | 546 TaskRunnerTimer<HTMLMediaElement> load_timer_; |
573 TaskRunnerTimer<HTMLMediaElement> progress_event_timer_; | 547 TaskRunnerTimer<HTMLMediaElement> progress_event_timer_; |
574 TaskRunnerTimer<HTMLMediaElement> playback_progress_timer_; | 548 TaskRunnerTimer<HTMLMediaElement> playback_progress_timer_; |
575 TaskRunnerTimer<HTMLMediaElement> audio_tracks_timer_; | 549 TaskRunnerTimer<HTMLMediaElement> audio_tracks_timer_; |
576 TaskRunnerTimer<HTMLMediaElement> viewport_fill_debouncer_timer_; | 550 TaskRunnerTimer<HTMLMediaElement> viewport_fill_debouncer_timer_; |
577 TaskRunnerTimer<HTMLMediaElement> check_viewport_intersection_timer_; | 551 TaskRunnerTimer<HTMLMediaElement> check_viewport_intersection_timer_; |
578 | 552 |
579 Member<TimeRanges> played_time_ranges_; | 553 Member<TimeRanges> played_time_ranges_; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
645 // scripts are running. See setOfficialPlaybackPosition(). | 619 // scripts are running. See setOfficialPlaybackPosition(). |
646 mutable double official_playback_position_; | 620 mutable double official_playback_position_; |
647 mutable bool official_playback_position_needs_update_; | 621 mutable bool official_playback_position_needs_update_; |
648 | 622 |
649 double fragment_end_time_; | 623 double fragment_end_time_; |
650 | 624 |
651 typedef unsigned PendingActionFlags; | 625 typedef unsigned PendingActionFlags; |
652 PendingActionFlags pending_action_flags_; | 626 PendingActionFlags pending_action_flags_; |
653 | 627 |
654 // FIXME: HTMLMediaElement has way too many state bits. | 628 // FIXME: HTMLMediaElement has way too many state bits. |
655 bool locked_pending_user_gesture_ : 1; | |
656 bool locked_pending_user_gesture_if_cross_origin_experiment_enabled_ : 1; | |
657 bool playing_ : 1; | 629 bool playing_ : 1; |
658 bool should_delay_load_event_ : 1; | 630 bool should_delay_load_event_ : 1; |
659 bool have_fired_loaded_data_ : 1; | 631 bool have_fired_loaded_data_ : 1; |
660 bool can_autoplay_ : 1; | 632 bool can_autoplay_ : 1; |
661 bool muted_ : 1; | 633 bool muted_ : 1; |
662 bool paused_ : 1; | 634 bool paused_ : 1; |
663 bool seeking_ : 1; | 635 bool seeking_ : 1; |
664 | 636 |
665 // data has not been loaded since sending a "stalled" event | 637 // data has not been loaded since sending a "stalled" event |
666 bool sent_stalled_event_ : 1; | 638 bool sent_stalled_event_ : 1; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
738 DECLARE_TRACE(); | 710 DECLARE_TRACE(); |
739 | 711 |
740 private: | 712 private: |
741 WebAudioSourceProvider* web_audio_source_provider_; | 713 WebAudioSourceProvider* web_audio_source_provider_; |
742 Member<AudioClientImpl> client_; | 714 Member<AudioClientImpl> client_; |
743 Mutex provide_input_lock; | 715 Mutex provide_input_lock; |
744 }; | 716 }; |
745 | 717 |
746 AudioSourceProviderImpl audio_source_provider_; | 718 AudioSourceProviderImpl audio_source_provider_; |
747 | 719 |
748 friend class AutoplayUmaHelper; // for isAutoplayAllowedPerSettings | 720 friend class AutoplayPolicy; |
749 friend class AutoplayUmaHelperTest; | 721 friend class AutoplayUmaHelperTest; |
750 friend class Internals; | 722 friend class Internals; |
751 friend class TrackDisplayUpdateScope; | 723 friend class TrackDisplayUpdateScope; |
752 friend class MediaControlsImplTest; | 724 friend class MediaControlsImplTest; |
753 friend class HTMLMediaElementTest; | 725 friend class HTMLMediaElementTest; |
754 friend class HTMLMediaElementEventListenersTest; | 726 friend class HTMLMediaElementEventListenersTest; |
755 friend class HTMLVideoElement; | 727 friend class HTMLVideoElement; |
756 friend class MediaControlsOrientationLockDelegateTest; | 728 friend class MediaControlsOrientationLockDelegateTest; |
757 | 729 |
730 Member<AutoplayPolicy> autoplay_policy_; | |
758 Member<AutoplayUmaHelper> autoplay_uma_helper_; | 731 Member<AutoplayUmaHelper> autoplay_uma_helper_; |
mlamouri (slow - plz ping)
2017/04/18 13:28:28
How hard would it be to move `autoplay_uma_helper_
Zhiqiang Zhang (Slow)
2017/04/18 16:56:44
Makes sense. Done :)
| |
759 | 732 |
760 WebRemotePlaybackClient* remote_playback_client_; | 733 WebRemotePlaybackClient* remote_playback_client_; |
761 | 734 |
762 // class AutoplayVisibilityObserver; | |
763 Member<ElementVisibilityObserver> autoplay_visibility_observer_; | |
764 | |
765 IntRect current_intersect_rect_; | 735 IntRect current_intersect_rect_; |
766 | 736 |
767 Member<MediaControls> media_controls_; | 737 Member<MediaControls> media_controls_; |
768 Member<HTMLMediaElementControlsList> controls_list_; | 738 Member<HTMLMediaElementControlsList> controls_list_; |
769 | 739 |
770 static URLRegistry* media_stream_registry_; | 740 static URLRegistry* media_stream_registry_; |
771 }; | 741 }; |
772 | 742 |
773 inline bool IsHTMLMediaElement(const HTMLElement& element) { | 743 inline bool IsHTMLMediaElement(const HTMLElement& element) { |
774 return isHTMLAudioElement(element) || isHTMLVideoElement(element); | 744 return isHTMLAudioElement(element) || isHTMLVideoElement(element); |
775 } | 745 } |
776 | 746 |
777 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); | 747 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); |
778 | 748 |
779 } // namespace blink | 749 } // namespace blink |
780 | 750 |
781 #endif // HTMLMediaElement_h | 751 #endif // HTMLMediaElement_h |
OLD | NEW |