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 AutoplayUmaHelper; | 54 class AutoplayPolicy; |
55 class ContentType; | 55 class ContentType; |
56 class CueTimeline; | 56 class CueTimeline; |
57 class ElementVisibilityObserver; | |
58 class EnumerationHistogram; | 57 class EnumerationHistogram; |
59 class Event; | 58 class Event; |
60 class ExceptionState; | 59 class ExceptionState; |
61 class HTMLMediaElementControlsList; | 60 class HTMLMediaElementControlsList; |
62 class HTMLSourceElement; | 61 class HTMLSourceElement; |
63 class HTMLTrackElement; | 62 class HTMLTrackElement; |
64 class KURL; | 63 class KURL; |
65 class MediaError; | 64 class MediaError; |
66 class MediaStreamDescriptor; | 65 class MediaStreamDescriptor; |
67 class HTMLMediaSource; | 66 class HTMLMediaSource; |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 322 |
324 void VideoWillBeDrawnToCanvas() const; | 323 void VideoWillBeDrawnToCanvas() const; |
325 | 324 |
326 WebRemotePlaybackClient* RemotePlaybackClient() { | 325 WebRemotePlaybackClient* RemotePlaybackClient() { |
327 return remote_playback_client_; | 326 return remote_playback_client_; |
328 } | 327 } |
329 const WebRemotePlaybackClient* RemotePlaybackClient() const { | 328 const WebRemotePlaybackClient* RemotePlaybackClient() const { |
330 return remote_playback_client_; | 329 return remote_playback_client_; |
331 } | 330 } |
332 | 331 |
| 332 const AutoplayPolicy& GetAutoplayPolicy() const { return *autoplay_policy_; } |
| 333 |
333 protected: | 334 protected: |
334 HTMLMediaElement(const QualifiedName&, Document&); | 335 HTMLMediaElement(const QualifiedName&, Document&); |
335 ~HTMLMediaElement() override; | 336 ~HTMLMediaElement() override; |
336 void Dispose(); | 337 void Dispose(); |
337 | 338 |
338 void ParseAttribute(const AttributeModificationParams&) override; | 339 void ParseAttribute(const AttributeModificationParams&) override; |
339 void FinishParsingChildren() final; | 340 void FinishParsingChildren() final; |
340 bool IsURLAttribute(const Attribute&) const override; | 341 bool IsURLAttribute(const Attribute&) const override; |
341 void AttachLayoutTree(const AttachContext& = AttachContext()) override; | 342 void AttachLayoutTree(const AttachContext& = AttachContext()) override; |
342 | 343 |
(...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 | 518 // WebMemediaPlayer objects advertise they have audio and/or video, but don't |
518 // explicitly signal them via addAudioTrack() and addVideoTrack(). | 519 // explicitly signal them via addAudioTrack() and addVideoTrack(). |
519 // FIXME: Remove this once all WebMediaPlayer implementations properly report | 520 // FIXME: Remove this once all WebMediaPlayer implementations properly report |
520 // their track info. | 521 // their track info. |
521 void CreatePlaceholderTracksIfNecessary(); | 522 void CreatePlaceholderTracksIfNecessary(); |
522 | 523 |
523 // Sets the selected/enabled tracks if they aren't set before we initially | 524 // Sets the selected/enabled tracks if they aren't set before we initially |
524 // transition to kHaveMetadata. | 525 // transition to kHaveMetadata. |
525 void SelectInitialTracksIfNecessary(); | 526 void SelectInitialTracksIfNecessary(); |
526 | 527 |
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); | 528 void SetNetworkState(NetworkState); |
555 | 529 |
556 void AudioTracksTimerFired(TimerBase*); | 530 void AudioTracksTimerFired(TimerBase*); |
557 | 531 |
558 void ScheduleResolvePlayPromises(); | 532 void ScheduleResolvePlayPromises(); |
559 void ScheduleRejectPlayPromises(ExceptionCode); | 533 void ScheduleRejectPlayPromises(ExceptionCode); |
560 void ScheduleNotifyPlaying(); | 534 void ScheduleNotifyPlaying(); |
561 void ResolveScheduledPlayPromises(); | 535 void ResolveScheduledPlayPromises(); |
562 void RejectScheduledPlayPromises(); | 536 void RejectScheduledPlayPromises(); |
563 void RejectPlayPromises(ExceptionCode, const String&); | 537 void RejectPlayPromises(ExceptionCode, const String&); |
564 void RejectPlayPromisesInternal(ExceptionCode, const String&); | 538 void RejectPlayPromisesInternal(ExceptionCode, const String&); |
565 | 539 |
566 EnumerationHistogram& ShowControlsHistogram() const; | 540 EnumerationHistogram& ShowControlsHistogram() const; |
567 | 541 |
568 void OnVisibilityChangedForAutoplay(bool is_visible); | |
569 | |
570 void ViewportFillDebouncerTimerFired(TimerBase*); | 542 void ViewportFillDebouncerTimerFired(TimerBase*); |
571 | 543 |
572 TaskRunnerTimer<HTMLMediaElement> load_timer_; | 544 TaskRunnerTimer<HTMLMediaElement> load_timer_; |
573 TaskRunnerTimer<HTMLMediaElement> progress_event_timer_; | 545 TaskRunnerTimer<HTMLMediaElement> progress_event_timer_; |
574 TaskRunnerTimer<HTMLMediaElement> playback_progress_timer_; | 546 TaskRunnerTimer<HTMLMediaElement> playback_progress_timer_; |
575 TaskRunnerTimer<HTMLMediaElement> audio_tracks_timer_; | 547 TaskRunnerTimer<HTMLMediaElement> audio_tracks_timer_; |
576 TaskRunnerTimer<HTMLMediaElement> viewport_fill_debouncer_timer_; | 548 TaskRunnerTimer<HTMLMediaElement> viewport_fill_debouncer_timer_; |
577 TaskRunnerTimer<HTMLMediaElement> check_viewport_intersection_timer_; | 549 TaskRunnerTimer<HTMLMediaElement> check_viewport_intersection_timer_; |
578 | 550 |
579 Member<TimeRanges> played_time_ranges_; | 551 Member<TimeRanges> played_time_ranges_; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 // scripts are running. See setOfficialPlaybackPosition(). | 617 // scripts are running. See setOfficialPlaybackPosition(). |
646 mutable double official_playback_position_; | 618 mutable double official_playback_position_; |
647 mutable bool official_playback_position_needs_update_; | 619 mutable bool official_playback_position_needs_update_; |
648 | 620 |
649 double fragment_end_time_; | 621 double fragment_end_time_; |
650 | 622 |
651 typedef unsigned PendingActionFlags; | 623 typedef unsigned PendingActionFlags; |
652 PendingActionFlags pending_action_flags_; | 624 PendingActionFlags pending_action_flags_; |
653 | 625 |
654 // FIXME: HTMLMediaElement has way too many state bits. | 626 // 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; | 627 bool playing_ : 1; |
658 bool should_delay_load_event_ : 1; | 628 bool should_delay_load_event_ : 1; |
659 bool have_fired_loaded_data_ : 1; | 629 bool have_fired_loaded_data_ : 1; |
660 bool can_autoplay_ : 1; | 630 bool can_autoplay_ : 1; |
661 bool muted_ : 1; | 631 bool muted_ : 1; |
662 bool paused_ : 1; | 632 bool paused_ : 1; |
663 bool seeking_ : 1; | 633 bool seeking_ : 1; |
664 | 634 |
665 // data has not been loaded since sending a "stalled" event | 635 // data has not been loaded since sending a "stalled" event |
666 bool sent_stalled_event_ : 1; | 636 bool sent_stalled_event_ : 1; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 DECLARE_TRACE(); | 708 DECLARE_TRACE(); |
739 | 709 |
740 private: | 710 private: |
741 WebAudioSourceProvider* web_audio_source_provider_; | 711 WebAudioSourceProvider* web_audio_source_provider_; |
742 Member<AudioClientImpl> client_; | 712 Member<AudioClientImpl> client_; |
743 Mutex provide_input_lock; | 713 Mutex provide_input_lock; |
744 }; | 714 }; |
745 | 715 |
746 AudioSourceProviderImpl audio_source_provider_; | 716 AudioSourceProviderImpl audio_source_provider_; |
747 | 717 |
748 friend class AutoplayUmaHelper; // for isAutoplayAllowedPerSettings | 718 friend class AutoplayPolicy; |
749 friend class AutoplayUmaHelperTest; | 719 friend class AutoplayUmaHelperTest; |
750 friend class Internals; | 720 friend class Internals; |
751 friend class TrackDisplayUpdateScope; | 721 friend class TrackDisplayUpdateScope; |
752 friend class MediaControlsImplTest; | 722 friend class MediaControlsImplTest; |
753 friend class HTMLMediaElementTest; | 723 friend class HTMLMediaElementTest; |
754 friend class HTMLMediaElementEventListenersTest; | 724 friend class HTMLMediaElementEventListenersTest; |
755 friend class HTMLVideoElement; | 725 friend class HTMLVideoElement; |
756 friend class MediaControlsOrientationLockDelegateTest; | 726 friend class MediaControlsOrientationLockDelegateTest; |
757 | 727 |
758 Member<AutoplayUmaHelper> autoplay_uma_helper_; | 728 Member<AutoplayPolicy> autoplay_policy_; |
759 | 729 |
760 WebRemotePlaybackClient* remote_playback_client_; | 730 WebRemotePlaybackClient* remote_playback_client_; |
761 | 731 |
762 // class AutoplayVisibilityObserver; | |
763 Member<ElementVisibilityObserver> autoplay_visibility_observer_; | |
764 | |
765 IntRect current_intersect_rect_; | 732 IntRect current_intersect_rect_; |
766 | 733 |
767 Member<MediaControls> media_controls_; | 734 Member<MediaControls> media_controls_; |
768 Member<HTMLMediaElementControlsList> controls_list_; | 735 Member<HTMLMediaElementControlsList> controls_list_; |
769 | 736 |
770 static URLRegistry* media_stream_registry_; | 737 static URLRegistry* media_stream_registry_; |
771 }; | 738 }; |
772 | 739 |
773 inline bool IsHTMLMediaElement(const HTMLElement& element) { | 740 inline bool IsHTMLMediaElement(const HTMLElement& element) { |
774 return isHTMLAudioElement(element) || isHTMLVideoElement(element); | 741 return isHTMLAudioElement(element) || isHTMLVideoElement(element); |
775 } | 742 } |
776 | 743 |
777 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); | 744 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); |
778 | 745 |
779 } // namespace blink | 746 } // namespace blink |
780 | 747 |
781 #endif // HTMLMediaElement_h | 748 #endif // HTMLMediaElement_h |
OLD | NEW |