diff --git a/patches/0088-implement-UI-for-autoplay-site-setting.patch b/patches/0088-implement-UI-for-autoplay-site-setting.patch new file mode 100644 index 000000000..040209163 --- /dev/null +++ b/patches/0088-implement-UI-for-autoplay-site-setting.patch @@ -0,0 +1,523 @@ +From a552882603a549d9b3511244eb976fc3ca3be515 Mon Sep 17 00:00:00 2001 +From: octocorvus +Date: Sun, 9 Oct 2022 10:06:52 +0000 +Subject: [PATCH] implement UI for autoplay site setting + +This setting is experimental and is hidden behind the flag +#enable-autoplay-permssion. It can be enabled in chrome://flags. +--- + .../ChromeSiteSettingsDelegate.java | 2 ++ + chrome/browser/about_flags.cc | 4 +++ + chrome/browser/flag-metadata.json | 7 +++++ + chrome/browser/flag_descriptions.cc | 4 +++ + chrome/browser/flag_descriptions.h | 3 +++ + .../flags/android/chrome_feature_list.cc | 1 + + .../browser/flags/ChromeFeatureList.java | 1 + + .../res/xml/site_settings_preferences.xml | 4 +++ + .../ContentSettingsResources.java | 6 +++++ + .../site_settings/SingleCategorySettings.java | 7 +++++ + .../site_settings/SingleWebsiteSettings.java | 26 +++++++++++++++++++ + .../site_settings/SiteSettingsCategory.java | 9 +++++-- + .../SiteSettingsFeatureList.java | 1 + + .../site_settings/SiteSettingsUtil.java | 1 + + .../browser_ui/site_settings/Website.java | 6 +++++ + .../WebsitePermissionsFetcher.java | 1 + + .../android/site_settings_feature_list.cc | 2 ++ + .../android/website_preference_bridge.cc | 1 + + .../strings/android/site_settings.grdp | 15 +++++++++++ + .../android/page_info_controller_android.cc | 7 +++++ + components/page_info/page_info.cc | 6 +++++ + components/page_info/page_info_ui.cc | 2 ++ + components/site_settings_strings.grdp | 6 +++++ + third_party/blink/common/features.cc | 3 +++ + third_party/blink/public/common/features.h | 2 ++ + 25 files changed, 125 insertions(+), 2 deletions(-) + +diff --git a/chrome/android/java/src/org/chromium/chrome/browser/site_settings/ChromeSiteSettingsDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/site_settings/ChromeSiteSettingsDelegate.java +index 4b7293423203f..bbdd227661faf 100644 +--- a/chrome/android/java/src/org/chromium/chrome/browser/site_settings/ChromeSiteSettingsDelegate.java ++++ b/chrome/android/java/src/org/chromium/chrome/browser/site_settings/ChromeSiteSettingsDelegate.java +@@ -111,6 +111,8 @@ public class ChromeSiteSettingsDelegate implements SiteSettingsDelegate { + case SiteSettingsCategory.Type.AUTO_DARK_WEB_CONTENT: + return ChromeFeatureList.isEnabled( + ChromeFeatureList.DARKEN_WEBSITES_CHECKBOX_IN_THEMES_SETTING); ++ case SiteSettingsCategory.Type.AUTOPLAY: ++ return ChromeFeatureList.isEnabled(ChromeFeatureList.ENABLE_AUTOPLAY_PERMISSION); + case SiteSettingsCategory.Type.BLUETOOTH: + return ContentFeatureList.isEnabled( + ContentFeatureList.WEB_BLUETOOTH_NEW_PERMISSIONS_BACKEND); +diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc +index 91b87e334bb27..f958b200e792c 100644 +--- a/chrome/browser/about_flags.cc ++++ b/chrome/browser/about_flags.cc +@@ -6135,6 +6135,10 @@ const FeatureEntry kFeatureEntries[] = { + flag_descriptions::kDisableProcessReuseDescription, kOsDesktop, + FEATURE_VALUE_TYPE(features::kDisableProcessReuse)}, + ++ {"enable-autoplay-permission", flag_descriptions::kEnableAutoplayPermission, ++ flag_descriptions::kEnableAutoplayPermissionDescription, kOsAndroid, ++ FEATURE_VALUE_TYPE(blink::features::kEnableAutoplayPermission)}, ++ + #if !BUILDFLAG(IS_ANDROID) + {"enable-accessibility-live-caption", + flag_descriptions::kEnableAccessibilityLiveCaptionName, +diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json +index 1f1f2f8f003a5..a829ac570d9e5 100644 +--- a/chrome/browser/flag-metadata.json ++++ b/chrome/browser/flag-metadata.json +@@ -1375,6 +1375,13 @@ + "yangsharon@google.com", "alexmos@google.com", "creis@google.com" ], + "expiry_milestone": 110 + }, ++ { ++ "name": "enable-autoplay-permission", ++ "owners": [ ++ "loryeam@gmail.com" ++ ], ++ "expiry_milestone": -1 ++ }, + { + "name": "disable-quick-answers-v2-translation", + "owners": [ "croissant-eng" ], +diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc +index 2998fc1683b13..858da1bb054f9 100644 +--- a/chrome/browser/flag_descriptions.cc ++++ b/chrome/browser/flag_descriptions.cc +@@ -830,6 +830,10 @@ const char kDisableProcessReuseDescription[] = + "unrelated tabs. This is an experimental mode that will result in more " + "processes being created."; + ++const char kEnableAutoplayPermission[] = "Enable autoplay permission"; ++const char kEnableAutoplayPermissionDescription[] = ++ "Enable autoplay permission."; ++ + const char kDisallowDocWrittenScriptsUiName[] = + "Block scripts loaded via document.write"; + const char kDisallowDocWrittenScriptsUiDescription[] = +diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h +index d095089242878..923675ce90f49 100644 +--- a/chrome/browser/flag_descriptions.h ++++ b/chrome/browser/flag_descriptions.h +@@ -415,6 +415,9 @@ extern const char kDarkLightTestDescription[]; + extern const char kDisableProcessReuse[]; + extern const char kDisableProcessReuseDescription[]; + ++extern const char kEnableAutoplayPermission[]; ++extern const char kEnableAutoplayPermissionDescription[]; ++ + extern const char kDiscountConsentV2Name[]; + extern const char kDiscountConsentV2Description[]; + +diff --git a/chrome/browser/flags/android/chrome_feature_list.cc b/chrome/browser/flags/android/chrome_feature_list.cc +index 05a1a44188b79..e66070c71d0c2 100644 +--- a/chrome/browser/flags/android/chrome_feature_list.cc ++++ b/chrome/browser/flags/android/chrome_feature_list.cc +@@ -98,6 +98,7 @@ const base::Feature* const kFeaturesExposedToJava[] = { + &autofill::features::kAutofillEnableSupportForMoreStructureInNames, + &autofill::features::kAutofillEnableUpdateVirtualCardEnrollment, + &autofill::features::kAutofillEnableVirtualCardMetadata, ++ &blink::features::kEnableAutoplayPermission, + &blink::features::kPrerender2, + &blink::features::kForceWebContentsDarkMode, + &commerce::kCommerceMerchantViewer, +diff --git a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java +index bf78e9a27a551..e0f39c7210f7b 100644 +--- a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java ++++ b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java +@@ -344,6 +344,7 @@ public abstract class ChromeFeatureList { + public static final String EARLY_LIBRARY_LOAD = "EarlyLibraryLoad"; + public static final String ELIDE_PRIORITIZATION_OF_PRE_NATIVE_BOOTSTRAP_TASKS = + "ElidePrioritizationOfPreNativeBootstrapTasks"; ++ public static final String ENABLE_AUTOPLAY_PERMISSION = "EnableAutoplayPermission"; + public static final String ENABLE_AUTOMATIC_SNOOZE = "EnableAutomaticSnooze"; + public static final String ENABLE_FAMILY_INFO_FEEDBACK = "EnableFamilyInfoFeedback"; + public static final String ELASTIC_OVERSCROLL = "ElasticOverscroll"; +diff --git a/components/browser_ui/site_settings/android/java/res/xml/site_settings_preferences.xml b/components/browser_ui/site_settings/android/java/res/xml/site_settings_preferences.xml +index 41dff78d390df..6974ebccd9fe2 100644 +--- a/components/browser_ui/site_settings/android/java/res/xml/site_settings_preferences.xml ++++ b/components/browser_ui/site_settings/android/java/res/xml/site_settings_preferences.xml +@@ -69,6 +69,10 @@ + ++ ++ + + + + Sound + ++ ++ Autoplay ++ + + Virtual reality + +@@ -563,6 +566,18 @@ + Mute sound for a specific site. + + ++ ++ ++ ++ Allow sites to automatically play muted videos ++ ++ ++ Allow autoplay for a specific site. ++ ++ ++ Block autoplay for a specific site. ++ ++ + + + +diff --git a/components/page_info/android/page_info_controller_android.cc b/components/page_info/android/page_info_controller_android.cc +index c306b42b0152d..79c0f714b3a7a 100644 +--- a/components/page_info/android/page_info_controller_android.cc ++++ b/components/page_info/android/page_info_controller_android.cc +@@ -25,6 +25,7 @@ + #include "content/public/browser/web_contents.h" + #include "content/public/common/content_features.h" + #include "content/public/common/content_switches.h" ++#include "third_party/blink/public/common/features.h" + #include "url/origin.h" + + using base::android::ConvertUTF16ToJavaString; +@@ -147,6 +148,10 @@ void PageInfoControllerAndroid::SetPermissionInfo( + permissions_to_display.push_back( + ContentSettingsType::PROTECTED_MEDIA_IDENTIFIER); + permissions_to_display.push_back(ContentSettingsType::SOUND); ++ if (base::FeatureList::IsEnabled( ++ blink::features::kEnableAutoplayPermission)) { ++ permissions_to_display.push_back(ContentSettingsType::AUTOPLAY); ++ } + if (base::FeatureList::IsEnabled(features::kWebNfc)) + permissions_to_display.push_back(ContentSettingsType::NFC); + base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); +@@ -231,6 +236,8 @@ absl::optional PageInfoControllerAndroid::GetSettingToDisplay( + // audio since last navigation. + if (web_contents_->WasEverAudible()) + return permission.default_setting; ++ } else if (permission.type == ContentSettingsType::AUTOPLAY) { ++ return permission.default_setting; + } + + // TODO(crbug.com/1077766): Also return permissions that are non +diff --git a/components/page_info/page_info.cc b/components/page_info/page_info.cc +index 192c247739346..f0c6e10654e28 100644 +--- a/components/page_info/page_info.cc ++++ b/components/page_info/page_info.cc +@@ -99,6 +99,7 @@ ContentSettingsType kPermissionType[] = { + ContentSettingsType::ADS, + ContentSettingsType::BACKGROUND_SYNC, + ContentSettingsType::SOUND, ++ ContentSettingsType::AUTOPLAY, + ContentSettingsType::AUTOMATIC_DOWNLOADS, + #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_WIN) + ContentSettingsType::PROTECTED_MEDIA_IDENTIFIER, +@@ -149,6 +150,11 @@ bool ShouldShowPermission(const PageInfo::PermissionInfo& info, + return true; + } + ++ // Always show autoplay settings UI when it has a site-specific override. ++ if (info.type == ContentSettingsType::AUTOPLAY) { ++ return true; ++ } ++ + // Always show JIT settings UI when when it has a site-specific override. + if (info.type == ContentSettingsType::JAVASCRIPT_JIT) { + return true; +diff --git a/components/page_info/page_info_ui.cc b/components/page_info/page_info_ui.cc +index 23390fd4ae50f..18ca7cac9ac93 100644 +--- a/components/page_info/page_info_ui.cc ++++ b/components/page_info/page_info_ui.cc +@@ -165,6 +165,8 @@ base::span GetContentSettingsUIInfo() { + IDS_SITE_SETTINGS_TYPE_ADS_MID_SENTENCE}, + {ContentSettingsType::SOUND, IDS_SITE_SETTINGS_TYPE_SOUND, + IDS_SITE_SETTINGS_TYPE_SOUND_MID_SENTENCE}, ++ {ContentSettingsType::AUTOPLAY, IDS_SITE_SETTINGS_TYPE_AUTOPLAY, ++ IDS_SITE_SETTINGS_TYPE_AUTOPLAY_MID_SENTENCE}, + {ContentSettingsType::CLIPBOARD_READ_WRITE, + IDS_SITE_SETTINGS_TYPE_CLIPBOARD, + IDS_SITE_SETTINGS_TYPE_CLIPBOARD_MID_SENTENCE}, +diff --git a/components/site_settings_strings.grdp b/components/site_settings_strings.grdp +index d73b6fa7e483b..ce012b4525a6a 100644 +--- a/components/site_settings_strings.grdp ++++ b/components/site_settings_strings.grdp +@@ -145,6 +145,12 @@ + + sound + ++ ++ Autoplay ++ ++ ++ autoplay ++ + + USB devices + +diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/features.cc +index e69f9c7bab3fe..6377b0eb7d995 100644 +--- a/third_party/blink/common/features.cc ++++ b/third_party/blink/common/features.cc +@@ -1623,5 +1623,8 @@ const base::Feature kWebRtcThreadsUseResourceEfficientType{ + const base::Feature kThrottleIntersectionObserverUMA{ + "ThrottleIntersectionObserverUMA", base::FEATURE_DISABLED_BY_DEFAULT}; + ++const base::Feature kEnableAutoplayPermission{ ++ "EnableAutoplayPermission", base::FEATURE_DISABLED_BY_DEFAULT}; ++ + } // namespace features + } // namespace blink +diff --git a/third_party/blink/public/common/features.h b/third_party/blink/public/common/features.h +index 73ff7dbf3936b..fd83558053db3 100644 +--- a/third_party/blink/public/common/features.h ++++ b/third_party/blink/public/common/features.h +@@ -869,6 +869,8 @@ BLINK_COMMON_EXPORT extern const base::Feature + // collected on 10% of animation frames. + BLINK_COMMON_EXPORT extern const base::Feature kThrottleIntersectionObserverUMA; + ++BLINK_COMMON_EXPORT extern const base::Feature kEnableAutoplayPermission; ++ + } // namespace features + } // namespace blink + diff --git a/patches/0089-add-AllowAutoplay-for-WebContentSettingsClient.patch b/patches/0089-add-AllowAutoplay-for-WebContentSettingsClient.patch new file mode 100644 index 000000000..245e7ca76 --- /dev/null +++ b/patches/0089-add-AllowAutoplay-for-WebContentSettingsClient.patch @@ -0,0 +1,182 @@ +From 18ddf8ee4f7807c031f16b9cbaf2846d63c2496a Mon Sep 17 00:00:00 2001 +From: octocorvus +Date: Wed, 12 Oct 2022 09:04:43 +0000 +Subject: [PATCH] add AllowAutoplay for WebContentSettingsClient + +This allows accessing the Autoplay site setting in blink. +--- + .../core/browser/content_settings_utils.cc | 2 ++ + .../core/common/content_settings.cc | 4 +++- + .../core/common/content_settings.h | 1 + + .../core/common/content_settings.mojom | 1 + + .../common/content_settings_mojom_traits.cc | 3 ++- + .../common/content_settings_mojom_traits.h | 5 ++++ + .../renderer/content_settings_agent_impl.cc | 23 +++++++++++++++++++ + .../renderer/content_settings_agent_impl.h | 3 +++ + .../platform/web_content_settings_client.h | 4 ++++ + 9 files changed, 44 insertions(+), 2 deletions(-) + +diff --git a/components/content_settings/core/browser/content_settings_utils.cc b/components/content_settings/core/browser/content_settings_utils.cc +index 011f3b4fea36b..2e2aa17d0c713 100644 +--- a/components/content_settings/core/browser/content_settings_utils.cc ++++ b/components/content_settings/core/browser/content_settings_utils.cc +@@ -150,6 +150,8 @@ void GetRendererContentSettingRules(const HostContentSettingsMap* map, + &(rules->script_rules)); + map->GetSettingsForOneType(ContentSettingsType::POPUPS, + &(rules->popup_redirect_rules)); ++ map->GetSettingsForOneType(ContentSettingsType::AUTOPLAY, ++ &(rules->autoplay_rules)); + } + + bool IsMorePermissive(ContentSetting a, ContentSetting b) { +diff --git a/components/content_settings/core/common/content_settings.cc b/components/content_settings/core/common/content_settings.cc +index faed596e2f408..f18f302afa8e5 100644 +--- a/components/content_settings/core/common/content_settings.cc ++++ b/components/content_settings/core/common/content_settings.cc +@@ -201,7 +201,8 @@ bool RendererContentSettingRules::IsRendererContentSetting( + content_type == ContentSettingsType::JAVASCRIPT || + content_type == ContentSettingsType::POPUPS || + content_type == ContentSettingsType::MIXEDSCRIPT || +- content_type == ContentSettingsType::AUTO_DARK_WEB_CONTENT; ++ content_type == ContentSettingsType::AUTO_DARK_WEB_CONTENT || ++ content_type == ContentSettingsType::AUTOPLAY; + } + + void RendererContentSettingRules::FilterRulesByOutermostMainFrameURL( +@@ -211,6 +212,7 @@ void RendererContentSettingRules::FilterRulesByOutermostMainFrameURL( + FilterRulesForType(popup_redirect_rules, outermost_main_frame_url); + FilterRulesForType(mixed_content_rules, outermost_main_frame_url); + FilterRulesForType(auto_dark_content_rules, outermost_main_frame_url); ++ FilterRulesForType(autoplay_rules, outermost_main_frame_url); + } + + RendererContentSettingRules::RendererContentSettingRules() = default; +diff --git a/components/content_settings/core/common/content_settings.h b/components/content_settings/core/common/content_settings.h +index 604f902a259d7..8a55ac75d6e9e 100644 +--- a/components/content_settings/core/common/content_settings.h ++++ b/components/content_settings/core/common/content_settings.h +@@ -92,6 +92,7 @@ struct RendererContentSettingRules { + ContentSettingsForOneType popup_redirect_rules; + ContentSettingsForOneType mixed_content_rules; + ContentSettingsForOneType auto_dark_content_rules; ++ ContentSettingsForOneType autoplay_rules; + }; + + namespace content_settings { +diff --git a/components/content_settings/core/common/content_settings.mojom b/components/content_settings/core/common/content_settings.mojom +index f2f3eba2167a2..56cbd97c0a0f6 100644 +--- a/components/content_settings/core/common/content_settings.mojom ++++ b/components/content_settings/core/common/content_settings.mojom +@@ -78,4 +78,5 @@ struct RendererContentSettingRules { + array popup_redirect_rules; + array mixed_content_rules; + array auto_dark_content_rules; ++ array autoplay_rules; + }; +diff --git a/components/content_settings/core/common/content_settings_mojom_traits.cc b/components/content_settings/core/common/content_settings_mojom_traits.cc +index 4ae7a3b123dc2..02512e5bc4cb4 100644 +--- a/components/content_settings/core/common/content_settings_mojom_traits.cc ++++ b/components/content_settings/core/common/content_settings_mojom_traits.cc +@@ -101,7 +101,8 @@ bool StructTraitsscript_rules) && + data.ReadPopupRedirectRules(&out->popup_redirect_rules) && + data.ReadMixedContentRules(&out->mixed_content_rules) && +- data.ReadAutoDarkContentRules(&out->auto_dark_content_rules); ++ data.ReadAutoDarkContentRules(&out->auto_dark_content_rules) && ++ data.ReadAutoplayRules(&out->autoplay_rules); + } + + } // namespace mojo +diff --git a/components/content_settings/core/common/content_settings_mojom_traits.h b/components/content_settings/core/common/content_settings_mojom_traits.h +index 7127ca7d852b6..f9cf51960ac4b 100644 +--- a/components/content_settings/core/common/content_settings_mojom_traits.h ++++ b/components/content_settings/core/common/content_settings_mojom_traits.h +@@ -150,6 +150,11 @@ struct StructTraits< + return r.auto_dark_content_rules; + } + ++ static const std::vector& autoplay_rules( ++ const RendererContentSettingRules& r) { ++ return r.autoplay_rules; ++ } ++ + static bool Read( + content_settings::mojom::RendererContentSettingRulesDataView data, + RendererContentSettingRules* out); +diff --git a/components/content_settings/renderer/content_settings_agent_impl.cc b/components/content_settings/renderer/content_settings_agent_impl.cc +index 701d6a5155f57..f6fd0227d0cf4 100644 +--- a/components/content_settings/renderer/content_settings_agent_impl.cc ++++ b/components/content_settings/renderer/content_settings_agent_impl.cc +@@ -362,6 +362,28 @@ bool ContentSettingsAgentImpl::AllowAutoDarkWebContent( + return allow; + } + ++bool ContentSettingsAgentImpl::AllowAutoplay(bool enabled_per_settings) { ++ if (!enabled_per_settings) ++ return false; ++ ++ blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); ++ const auto it = cached_autoplay_permissions_.find(frame); ++ if (it != cached_autoplay_permissions_.end()) ++ return it->second; ++ ++ bool allow = true; ++ if (content_setting_rules_) { ++ ContentSetting setting = GetContentSettingFromRules( ++ content_setting_rules_->autoplay_rules, ++ url::Origin(frame->GetDocument().GetSecurityOrigin()).GetURL()); ++ allow = setting != CONTENT_SETTING_BLOCK; ++ } ++ allow = allow || IsAllowlistedForContentSettings(); ++ ++ cached_autoplay_permissions_[frame] = allow; ++ return allow; ++} ++ + bool ContentSettingsAgentImpl::AllowReadFromClipboard(bool default_value) { + return delegate_->AllowReadFromClipboard().value_or(default_value); + } +@@ -430,6 +452,7 @@ void ContentSettingsAgentImpl::ClearBlockedContentSettings() { + content_blocked_.clear(); + cached_storage_permissions_.clear(); + cached_script_permissions_.clear(); ++ cached_autoplay_permissions_.clear(); + } + + bool ContentSettingsAgentImpl::IsAllowlistedForContentSettings() const { +diff --git a/components/content_settings/renderer/content_settings_agent_impl.h b/components/content_settings/renderer/content_settings_agent_impl.h +index d53c20d431942..da3ef0b8aa047 100644 +--- a/components/content_settings/renderer/content_settings_agent_impl.h ++++ b/components/content_settings/renderer/content_settings_agent_impl.h +@@ -85,6 +85,7 @@ class ContentSettingsAgentImpl + bool AllowScriptFromSource(bool enabled_per_settings, + const blink::WebURL& script_url) override; + bool AllowAutoDarkWebContent(bool enabled_per_settings) override; ++ bool AllowAutoplay(bool enabled_per_settings) override; + bool AllowReadFromClipboard(bool default_value) override; + bool AllowWriteToClipboard(bool default_value) override; + bool AllowMutationEvents(bool default_value) override; +@@ -159,6 +160,8 @@ class ContentSettingsAgentImpl + // Caches the result of AllowScript. + base::flat_map cached_script_permissions_; + ++ base::flat_map cached_autoplay_permissions_; ++ + bool mixed_content_autoupgrades_disabled_ = false; + + // If true, IsAllowlistedForContentSettings will always return true. +diff --git a/third_party/blink/public/platform/web_content_settings_client.h b/third_party/blink/public/platform/web_content_settings_client.h +index 87d4a0ee3887d..a810e5bdf55eb 100644 +--- a/third_party/blink/public/platform/web_content_settings_client.h ++++ b/third_party/blink/public/platform/web_content_settings_client.h +@@ -73,6 +73,10 @@ class WebContentSettingsClient { + return enabled_per_settings; + } + ++ virtual bool AllowAutoplay(bool enabled_per_settings) { ++ return enabled_per_settings; ++ } ++ + // Controls whether access to read the clipboard is allowed for this frame. + virtual bool AllowReadFromClipboard(bool default_value) { + return default_value; diff --git a/patches/0090-implement-autoplay-policy-to-block-media-autoplay.patch b/patches/0090-implement-autoplay-policy-to-block-media-autoplay.patch new file mode 100644 index 000000000..5ca7f924b --- /dev/null +++ b/patches/0090-implement-autoplay-policy-to-block-media-autoplay.patch @@ -0,0 +1,67 @@ +From 853f72400466e9eb15a785f2b50461470fa969ff Mon Sep 17 00:00:00 2001 +From: octocorvus +Date: Thu, 13 Oct 2022 13:20:05 +0000 +Subject: [PATCH] implement autoplay policy to block media autoplay... + +... when not allowed by content settings. + +Current autoplay policy (if autoplay is blocked for site as per content +settings): +- Muted autoplay is always blocked. +- Autoplay with sound is allowed if and only if the user has interacted + with domain (click, tap, etc.). If we block this, then the user won't + be able to start a video by tapping on the play button, since those + will be blocked too. +--- + .../renderer/core/html/media/autoplay_policy.cc | 17 +++++++++++++++++ + .../renderer/core/html/media/autoplay_policy.h | 2 ++ + 2 files changed, 19 insertions(+) + +diff --git a/third_party/blink/renderer/core/html/media/autoplay_policy.cc b/third_party/blink/renderer/core/html/media/autoplay_policy.cc +index 871d82556706b..a2baf0489dddd 100644 +--- a/third_party/blink/renderer/core/html/media/autoplay_policy.cc ++++ b/third_party/blink/renderer/core/html/media/autoplay_policy.cc +@@ -310,6 +310,9 @@ void AutoplayPolicy::TryUnlockingUserGesture() { + } + + bool AutoplayPolicy::IsGestureNeededForPlayback() const { ++ if (!IsAutoplayAllowedByContentSettings()) ++ return true; ++ + if (!IsLockedPendingUserGesture()) + return false; + +@@ -337,6 +340,20 @@ void AutoplayPolicy::EnsureAutoplayInitiatedSet() { + autoplay_initiated_ = false; + } + ++bool AutoplayPolicy::IsAutoplayAllowedByContentSettings() const { ++ if (!base::FeatureList::IsEnabled(features::kEnableAutoplayPermission)) ++ return true; ++ ++ LocalFrame* frame = element_->GetDocument().GetFrame(); ++ if (!frame) ++ return false; ++ ++ if (auto* settings_client = frame->GetContentSettingsClient()) ++ return settings_client->AllowAutoplay(true); ++ ++ return true; ++} ++ + void AutoplayPolicy::OnIntersectionChangedForAutoplay( + const HeapVector>& entries) { + bool is_visible = (entries.back()->intersectionRatio() > 0); +diff --git a/third_party/blink/renderer/core/html/media/autoplay_policy.h b/third_party/blink/renderer/core/html/media/autoplay_policy.h +index ca5c996363ad8..ae4c094cd1559 100644 +--- a/third_party/blink/renderer/core/html/media/autoplay_policy.h ++++ b/third_party/blink/renderer/core/html/media/autoplay_policy.h +@@ -113,6 +113,8 @@ class CORE_EXPORT AutoplayPolicy final + // avoid false positives. + void EnsureAutoplayInitiatedSet(); + ++ bool IsAutoplayAllowedByContentSettings() const; ++ + virtual void Trace(Visitor*) const; + + private: