| OLD | NEW |
| 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/AutoplayUmaHelper.h" | 5 #include "core/html/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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 // Record the source. | 68 // Record the source. |
| 69 if (m_element->isHTMLVideoElement()) { | 69 if (m_element->isHTMLVideoElement()) { |
| 70 videoHistogram.count(static_cast<int>(m_source)); | 70 videoHistogram.count(static_cast<int>(m_source)); |
| 71 if (m_element->muted()) | 71 if (m_element->muted()) |
| 72 mutedVideoHistogram.count(static_cast<int>(m_source)); | 72 mutedVideoHistogram.count(static_cast<int>(m_source)); |
| 73 } else { | 73 } else { |
| 74 audioHistogram.count(static_cast<int>(m_source)); | 74 audioHistogram.count(static_cast<int>(m_source)); |
| 75 } | 75 } |
| 76 | 76 |
| 77 // Record the child frame and top-level frame URLs for autoplay muted videos |
| 78 // by attribute. |
| 79 if (m_element->isHTMLVideoElement() && m_element->muted()) { |
| 80 if (source == AutoplaySource::Attribute) { |
| 81 Platform::current()->recordRapporURL( |
| 82 "Media.Video.Autoplay.Muted.Attribute.Frame", |
| 83 m_element->document().url()); |
| 84 } else { |
| 85 DCHECK(source == AutoplaySource::Method); |
| 86 Platform::current()->recordRapporURL( |
| 87 "Media.Video.Autoplay.Muted.PlayMethod.Frame", |
| 88 m_element->document().url()); |
| 89 } |
| 90 } |
| 91 |
| 77 // Record if it will be blocked by Data Saver or Autoplay setting. | 92 // Record if it will be blocked by Data Saver or Autoplay setting. |
| 78 if (m_element->isHTMLVideoElement() && m_element->muted() && | 93 if (m_element->isHTMLVideoElement() && m_element->muted() && |
| 79 RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) { | 94 RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) { |
| 80 bool dataSaverEnabled = | 95 bool dataSaverEnabled = |
| 81 m_element->document().settings() && | 96 m_element->document().settings() && |
| 82 m_element->document().settings()->getDataSaverEnabled(); | 97 m_element->document().settings()->getDataSaverEnabled(); |
| 83 bool blockedBySetting = !m_element->isAutoplayAllowedPerSettings(); | 98 bool blockedBySetting = !m_element->isAutoplayAllowedPerSettings(); |
| 84 | 99 |
| 85 if (dataSaverEnabled && blockedBySetting) { | 100 if (dataSaverEnabled && blockedBySetting) { |
| 86 blockedMutedVideoHistogram.count( | 101 blockedMutedVideoHistogram.count( |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 376 |
| 362 DEFINE_TRACE(AutoplayUmaHelper) { | 377 DEFINE_TRACE(AutoplayUmaHelper) { |
| 363 EventListener::trace(visitor); | 378 EventListener::trace(visitor); |
| 364 ContextLifecycleObserver::trace(visitor); | 379 ContextLifecycleObserver::trace(visitor); |
| 365 visitor->trace(m_element); | 380 visitor->trace(m_element); |
| 366 visitor->trace(m_mutedVideoPlayMethodVisibilityObserver); | 381 visitor->trace(m_mutedVideoPlayMethodVisibilityObserver); |
| 367 visitor->trace(m_mutedVideoOffscreenDurationVisibilityObserver); | 382 visitor->trace(m_mutedVideoOffscreenDurationVisibilityObserver); |
| 368 } | 383 } |
| 369 | 384 |
| 370 } // namespace blink | 385 } // namespace blink |
| OLD | NEW |