| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef AutoplayPolicy_h | 5 #ifndef AutoplayPolicy_h |
| 6 #define AutoplayPolicy_h | 6 #define AutoplayPolicy_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/Nullable.h" | 8 #include "bindings/core/v8/Nullable.h" |
| 9 #include "core/CoreExport.h" | 9 #include "core/CoreExport.h" |
| 10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
| 11 #include "platform/heap/Handle.h" | 11 #include "platform/heap/Handle.h" |
| 12 #include "public/platform/WebMediaPlayerClient.h" |
| 12 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 | 15 |
| 15 class AutoplayUmaHelper; | 16 class AutoplayUmaHelper; |
| 16 class Document; | 17 class Document; |
| 17 class ElementVisibilityObserver; | 18 class ElementVisibilityObserver; |
| 18 class HTMLMediaElement; | 19 class HTMLMediaElement; |
| 19 | 20 |
| 20 // AutoplayPolicy is the class for handles autoplay logics. | 21 // AutoplayPolicy is the class for handles autoplay logics. |
| 21 class AutoplayPolicy final : public GarbageCollected<AutoplayPolicy> { | 22 class AutoplayPolicy final : public GarbageCollected<AutoplayPolicy> { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 60 |
| 60 // Unlock user gesture if a user gesture can be utilized. | 61 // Unlock user gesture if a user gesture can be utilized. |
| 61 void TryUnlockingUserGesture(); | 62 void TryUnlockingUserGesture(); |
| 62 | 63 |
| 63 // Return true if and only if a user gesture is requried for playback. Even | 64 // Return true if and only if a user gesture is requried for playback. Even |
| 64 // if isLockedPendingUserGesture() return true, this might return false if | 65 // if isLockedPendingUserGesture() return true, this might return false if |
| 65 // the requirement is currently overridden. This does not check if a user | 66 // the requirement is currently overridden. This does not check if a user |
| 66 // gesture is currently being processed. | 67 // gesture is currently being processed. |
| 67 bool IsGestureNeededForPlayback() const; | 68 bool IsGestureNeededForPlayback() const; |
| 68 | 69 |
| 70 // Called when source is initialized and loading starts. |
| 71 void OnLoadStarted(WebMediaPlayer::LoadType); |
| 72 |
| 69 DECLARE_VIRTUAL_TRACE(); | 73 DECLARE_VIRTUAL_TRACE(); |
| 70 | 74 |
| 71 private: | 75 private: |
| 72 friend class AutoplayUmaHelper; | 76 friend class AutoplayUmaHelper; |
| 73 friend class AutoplayUmaHelperTest; | 77 friend class AutoplayUmaHelperTest; |
| 74 | 78 |
| 75 // Start autoplaying the video element whenever its visible. | 79 // Start autoplaying the video element whenever its visible. |
| 76 void StartAutoplayMutedWhenVisible(); | 80 void StartAutoplayMutedWhenVisible(); |
| 77 | 81 |
| 78 // Returns whether the media element is eligible to autoplay muted. | 82 // Returns whether the media element is eligible to autoplay muted. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 Member<ElementVisibilityObserver> autoplay_visibility_observer_; | 118 Member<ElementVisibilityObserver> autoplay_visibility_observer_; |
| 115 | 119 |
| 116 Member<AutoplayUmaHelper> autoplay_uma_helper_; | 120 Member<AutoplayUmaHelper> autoplay_uma_helper_; |
| 117 | 121 |
| 118 DISALLOW_COPY_AND_ASSIGN(AutoplayPolicy); | 122 DISALLOW_COPY_AND_ASSIGN(AutoplayPolicy); |
| 119 }; | 123 }; |
| 120 | 124 |
| 121 } // namespace blink | 125 } // namespace blink |
| 122 | 126 |
| 123 #endif // AutoplayPolicy_h | 127 #endif // AutoplayPolicy_h |
| OLD | NEW |