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

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

Issue 2881073003: Support DataSaver for SharedWorker (Closed)
Patch Set: fix #include "public/web/WebDataSaverFlag.h" Created 3 years, 7 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/AutoplayUmaHelper.h" 5 #include "core/html/media/AutoplayUmaHelper.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/events/Event.h" 9 #include "core/events/Event.h"
10 #include "core/frame/Settings.h" 10 #include "core/frame/Settings.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 "Media.Video.Autoplay.Muted.PlayMethod.Frame", 104 "Media.Video.Autoplay.Muted.PlayMethod.Frame",
105 element_->GetDocument().Url()); 105 element_->GetDocument().Url());
106 } 106 }
107 } 107 }
108 108
109 // Record if it will be blocked by Data Saver or Autoplay setting. 109 // Record if it will be blocked by Data Saver or Autoplay setting.
110 if (element_->IsHTMLVideoElement() && element_->muted() && 110 if (element_->IsHTMLVideoElement() && element_->muted() &&
111 RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) { 111 RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) {
112 bool data_saver_enabled = 112 bool data_saver_enabled =
113 element_->GetDocument().GetSettings() && 113 element_->GetDocument().GetSettings() &&
114 element_->GetDocument().GetSettings()->GetDataSaverEnabled(); 114 element_->GetDocument().GetSettings()->GetDataSaverFlag() ==
115 WebDataSaverFlag::kEnabled;
115 bool blocked_by_setting = 116 bool blocked_by_setting =
116 !element_->GetAutoplayPolicy().IsAutoplayAllowedPerSettings(); 117 !element_->GetAutoplayPolicy().IsAutoplayAllowedPerSettings();
117 118
118 if (data_saver_enabled && blocked_by_setting) { 119 if (data_saver_enabled && blocked_by_setting) {
119 blocked_muted_video_histogram.Count( 120 blocked_muted_video_histogram.Count(
120 kAutoplayBlockedReasonDataSaverAndSetting); 121 kAutoplayBlockedReasonDataSaverAndSetting);
121 } else if (data_saver_enabled) { 122 } else if (data_saver_enabled) {
122 blocked_muted_video_histogram.Count(kAutoplayBlockedReasonDataSaver); 123 blocked_muted_video_histogram.Count(kAutoplayBlockedReasonDataSaver);
123 } else if (blocked_by_setting) { 124 } else if (blocked_by_setting) {
124 blocked_muted_video_histogram.Count(kAutoplayBlockedReasonSetting); 125 blocked_muted_video_histogram.Count(kAutoplayBlockedReasonSetting);
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 400
400 DEFINE_TRACE(AutoplayUmaHelper) { 401 DEFINE_TRACE(AutoplayUmaHelper) {
401 EventListener::Trace(visitor); 402 EventListener::Trace(visitor);
402 ContextLifecycleObserver::Trace(visitor); 403 ContextLifecycleObserver::Trace(visitor);
403 visitor->Trace(element_); 404 visitor->Trace(element_);
404 visitor->Trace(muted_video_play_method_visibility_observer_); 405 visitor->Trace(muted_video_play_method_visibility_observer_);
405 visitor->Trace(muted_video_offscreen_duration_visibility_observer_); 406 visitor->Trace(muted_video_offscreen_duration_visibility_observer_);
406 } 407 }
407 408
408 } // namespace blink 409 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698