diff --git a/chromium_src/third_party/blink/public/platform/web_content_settings_client.h b/chromium_src/third_party/blink/public/platform/web_content_settings_client.h index b88480cd65c2..c5df224a3598 100644 --- a/chromium_src/third_party/blink/public/platform/web_content_settings_client.h +++ b/chromium_src/third_party/blink/public/platform/web_content_settings_client.h @@ -8,8 +8,8 @@ #include "brave/third_party/blink/renderer/brave_farbling_constants.h" -#define AllowStorageAccessSync \ - AllowAutoplay(bool default_value) { return default_value; } \ +#define AllowStorageAccessSync \ + AllowAutoplay(bool play_requested) { return true; } \ virtual bool AllowFingerprinting(bool enabled_per_settings) { \ return enabled_per_settings; \ } \ @@ -18,7 +18,6 @@ } \ virtual bool AllowStorageAccessSync - #include "../../../../../../third_party/blink/public/platform/web_content_settings_client.h" #undef AllowStorageAccessSync diff --git a/chromium_src/third_party/blink/renderer/core/html/media/autoplay_policy.cc b/chromium_src/third_party/blink/renderer/core/html/media/autoplay_policy.cc index e1b7f54c3107..8f8ebf1d013a 100644 --- a/chromium_src/third_party/blink/renderer/core/html/media/autoplay_policy.cc +++ b/chromium_src/third_party/blink/renderer/core/html/media/autoplay_policy.cc @@ -10,12 +10,11 @@ namespace blink { namespace { -bool IsAutoplayAllowedForFrame(LocalFrame* frame) { +bool IsAutoplayAllowedForFrame(LocalFrame* frame, bool play_requested) { if (!frame) return false; if (auto* settings_client = frame->GetContentSettingsClient()) { - bool allow_autoplay = - settings_client->AllowAutoplay(true /* default_value */); + bool allow_autoplay = settings_client->AllowAutoplay(play_requested); // Clear it in order to block media when refresh or navigate if (!allow_autoplay) { frame->ClearUserActivation(); @@ -26,11 +25,11 @@ bool IsAutoplayAllowedForFrame(LocalFrame* frame) { } bool IsAutoplayAllowedForDocument(const Document& document) { - return IsAutoplayAllowedForFrame(document.GetFrame()); + return IsAutoplayAllowedForFrame(document.GetFrame(), false); } bool IsAutoplayAllowedForElement(Member element) { - return IsAutoplayAllowedForFrame(element->GetDocument().GetFrame()); + return IsAutoplayAllowedForFrame(element->GetDocument().GetFrame(), true); } } // namespace diff --git a/components/content_settings/renderer/brave_content_settings_agent_impl.cc b/components/content_settings/renderer/brave_content_settings_agent_impl.cc index aabfa57d3d0d..cb1362c70d33 100644 --- a/components/content_settings/renderer/brave_content_settings_agent_impl.cc +++ b/components/content_settings/renderer/brave_content_settings_agent_impl.cc @@ -212,7 +212,7 @@ BraveFarblingLevel BraveContentSettingsAgentImpl::GetBraveFarblingLevel() { } } -bool BraveContentSettingsAgentImpl::AllowAutoplay(bool default_value) { +bool BraveContentSettingsAgentImpl::AllowAutoplay(bool play_requested) { blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); auto origin = frame->GetSecurityOrigin(); // default allow local files @@ -228,7 +228,8 @@ bool BraveContentSettingsAgentImpl::AllowAutoplay(bool default_value) { frame, url::Origin(origin).GetURL()); if (setting == CONTENT_SETTING_BLOCK) { VLOG(1) << "AllowAutoplay=false because rule=CONTENT_SETTING_BLOCK"; - DidBlockContentType(ContentSettingsType::AUTOPLAY); + if (play_requested) + DidBlockContentType(ContentSettingsType::AUTOPLAY); return false; } else if (setting == CONTENT_SETTING_ALLOW) { VLOG(1) << "AllowAutoplay=true because rule=CONTENT_SETTING_ALLOW"; @@ -236,12 +237,13 @@ bool BraveContentSettingsAgentImpl::AllowAutoplay(bool default_value) { } } - bool allow = ContentSettingsAgentImpl::AllowAutoplay(default_value); + bool allow = ContentSettingsAgentImpl::AllowAutoplay(play_requested); if (allow) { VLOG(1) << "AllowAutoplay=true because " "ContentSettingsAgentImpl::AllowAutoplay says so"; } else { - DidBlockContentType(ContentSettingsType::AUTOPLAY); + if (play_requested) + DidBlockContentType(ContentSettingsType::AUTOPLAY); VLOG(1) << "AllowAutoplay=false because " "ContentSettingsAgentImpl::AllowAutoplay says so"; } diff --git a/components/content_settings/renderer/brave_content_settings_agent_impl.h b/components/content_settings/renderer/brave_content_settings_agent_impl.h index b2212f4c1758..e474543d377a 100644 --- a/components/content_settings/renderer/brave_content_settings_agent_impl.h +++ b/components/content_settings/renderer/brave_content_settings_agent_impl.h @@ -38,7 +38,7 @@ class BraveContentSettingsAgentImpl : public ContentSettingsAgentImpl { void BraveSpecificDidBlockJavaScript(const base::string16& details); - bool AllowAutoplay(bool default_value) override; + bool AllowAutoplay(bool play_requested) override; bool AllowFingerprinting(bool enabled_per_settings) override; void DidBlockFingerprinting(const base::string16& details);