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 #include "core/html/media/AutoplayPolicy.h" | 5 #include "core/html/media/AutoplayPolicy.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/dom/ElementVisibilityObserver.h" | 8 #include "core/dom/ElementVisibilityObserver.h" |
9 #include "core/frame/ContentSettingsClient.h" | 9 #include "core/frame/ContentSettingsClient.h" |
10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 return false; | 243 return false; |
244 | 244 |
245 // We want to allow muted video to autoplay if: | 245 // We want to allow muted video to autoplay if: |
246 // - the flag is enabled; | 246 // - the flag is enabled; |
247 // - Data Saver is not enabled; | 247 // - Data Saver is not enabled; |
248 // - Preload was not disabled (low end devices); | 248 // - Preload was not disabled (low end devices); |
249 // - Autoplay is enabled in settings; | 249 // - Autoplay is enabled in settings; |
250 if (element_->IsHTMLVideoElement() && element_->muted() && | 250 if (element_->IsHTMLVideoElement() && element_->muted() && |
251 RuntimeEnabledFeatures::autoplayMutedVideosEnabled() && | 251 RuntimeEnabledFeatures::autoplayMutedVideosEnabled() && |
252 !(element_->GetDocument().GetSettings() && | 252 !(element_->GetDocument().GetSettings() && |
253 element_->GetDocument().GetSettings()->GetDataSaverEnabled()) && | 253 element_->GetDocument().GetSettings()->GetDataSaverFlag() == |
| 254 WebDataSaverFlag::kEnabled) && |
254 !(element_->GetDocument().GetSettings() && | 255 !(element_->GetDocument().GetSettings() && |
255 element_->GetDocument() | 256 element_->GetDocument() |
256 .GetSettings() | 257 .GetSettings() |
257 ->GetForcePreloadNoneForMediaElements()) && | 258 ->GetForcePreloadNoneForMediaElements()) && |
258 IsAutoplayAllowedPerSettings()) { | 259 IsAutoplayAllowedPerSettings()) { |
259 return false; | 260 return false; |
260 } | 261 } |
261 | 262 |
262 return true; | 263 return true; |
263 } | 264 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 return element_->can_autoplay_ && element_->paused_ && element_->Autoplay(); | 302 return element_->can_autoplay_ && element_->paused_ && element_->Autoplay(); |
302 } | 303 } |
303 | 304 |
304 DEFINE_TRACE(AutoplayPolicy) { | 305 DEFINE_TRACE(AutoplayPolicy) { |
305 visitor->Trace(element_); | 306 visitor->Trace(element_); |
306 visitor->Trace(autoplay_visibility_observer_); | 307 visitor->Trace(autoplay_visibility_observer_); |
307 visitor->Trace(autoplay_uma_helper_); | 308 visitor->Trace(autoplay_uma_helper_); |
308 } | 309 } |
309 | 310 |
310 } // namespace blink | 311 } // namespace blink |
OLD | NEW |