Revert-the-removal-of-an-option-to-block-autoplay.patch

This commit is contained in:
none 2021-03-06 22:47:40 +01:00
parent 21c9facc4c
commit d50b8992b2

View file

@ -13,12 +13,12 @@ Subject: Revert the removal of an option to block autoplay
.../res/xml/site_settings_preferences.xml | 4 +++
.../ContentSettingsResources.java | 4 +++
.../site_settings/SingleCategorySettings.java | 4 +++
.../site_settings/SingleWebsiteSettings.java | 22 ++++++++++++++++
.../site_settings/SingleWebsiteSettings.java | 22 +++++++++++++++++
.../site_settings/SiteSettingsCategory.java | 9 +++++--
.../browser_ui/site_settings/Website.java | 8 ++++++
.../WebsitePermissionsFetcher.java | 1 +
.../WebsitePreferenceBridge.java | 4 +++
.../android/website_preference_bridge.cc | 24 +++++++++++++++++-
.../android/website_preference_bridge.cc | 23 ++++++++++++++++++
.../strings/android/site_settings.grdp | 9 +++++++
.../core/browser/content_settings_registry.cc | 2 +-
.../core/browser/content_settings_utils.cc | 2 ++
@ -27,7 +27,7 @@ Subject: Revert the removal of an option to block autoplay
.../core/common/content_settings.mojom | 1 +
.../common/content_settings_mojom_traits.cc | 1 +
.../common/content_settings_mojom_traits.h | 5 ++++
.../renderer/content_settings_agent_impl.cc | 11 ++++++++
.../renderer/content_settings_agent_impl.cc | 11 +++++++++
.../renderer/content_settings_agent_impl.h | 1 +
.../android/page_info_controller_android.cc | 1 +
components/page_info/page_info.cc | 6 +++++
@ -36,7 +36,7 @@ Subject: Revert the removal of an option to block autoplay
.../platform/web_content_settings_client.h | 3 +++
.../core/html/media/autoplay_policy.cc | 12 ++++++++-
.../core/html/media/autoplay_policy.h | 4 +++
33 files changed, 146 insertions(+), 5 deletions(-)
33 files changed, 146 insertions(+), 4 deletions(-)
create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-hdpi/settings_autoplay.png
create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-mdpi/settings_autoplay.png
create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xhdpi/settings_autoplay.png
@ -46,7 +46,7 @@ Subject: Revert the removal of an option to block autoplay
diff --git a/components/browser_ui/site_settings/android/BUILD.gn b/components/browser_ui/site_settings/android/BUILD.gn
--- a/components/browser_ui/site_settings/android/BUILD.gn
+++ b/components/browser_ui/site_settings/android/BUILD.gn
@@ -190,6 +190,11 @@ android_resources("java_resources") {
@@ -188,6 +188,11 @@ android_resources("java_resources") {
"java/res/drawable-xxxhdpi/settings_storage.png",
"java/res/drawable-xxxhdpi/settings_usb.png",
"java/res/drawable-xxxhdpi/web_asset.png",
@ -169,15 +169,15 @@ HcmV?d00001
diff --git a/components/browser_ui/site_settings/android/java/res/xml/single_website_preferences.xml b/components/browser_ui/site_settings/android/java/res/xml/single_website_preferences.xml
--- a/components/browser_ui/site_settings/android/java/res/xml/single_website_preferences.xml
+++ b/components/browser_ui/site_settings/android/java/res/xml/single_website_preferences.xml
@@ -71,6 +71,8 @@
android:key="automatic_downloads_permission_list" />
<ListPreference
android:key="protected_media_identifier_permission_list" />
+ <ListPreference
@@ -36,6 +36,8 @@
<ListPreference
android:key="timezone_override_permission_list" />
<PreferenceCategory
+ android:key="autoplay_permission_list" />
<ListPreference
android:key="sound_permission_list" />
<ListPreference
+ <ListPreference
android:key="site_usage"
android:title="@string/website_settings_usage_category" />
<org.chromium.components.browser_ui.site_settings.ClearWebsiteStorage
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
--- 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
@ -195,7 +195,7 @@ diff --git a/components/browser_ui/site_settings/android/java/res/xml/site_setti
diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java
--- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java
+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java
@@ -104,6 +104,10 @@ public class ContentSettingsResources {
@@ -111,6 +111,10 @@ public class ContentSettingsResources {
new ResourceItem(R.drawable.infobar_downloading,
R.string.automatic_downloads_permission_title, ContentSettingValues.ASK,
ContentSettingValues.BLOCK, R.string.website_settings_category_ask, 0));
@ -209,7 +209,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c
diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java
--- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java
+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java
@@ -533,6 +533,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
@@ -537,6 +537,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
int resource = 0;
if (mCategory.showSites(SiteSettingsCategory.Type.AUTOMATIC_DOWNLOADS)) {
resource = R.string.website_settings_add_site_description_automatic_downloads;
@ -218,7 +218,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c
} else if (mCategory.showSites(SiteSettingsCategory.Type.BACKGROUND_SYNC)) {
resource = R.string.website_settings_add_site_description_background_sync;
} else if (mCategory.showSites(SiteSettingsCategory.Type.JAVASCRIPT)) {
@@ -650,6 +652,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
@@ -653,6 +655,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
boolean exception = false;
if (mCategory.showSites(SiteSettingsCategory.Type.SOUND)) {
exception = true;
@ -230,7 +230,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c
diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java
--- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java
+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java
@@ -101,6 +101,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
@@ -127,6 +127,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
return "bluetooth_scanning_permission_list";
case ContentSettingsType.COOKIES:
return "cookies_permission_list";
@ -239,16 +239,16 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c
case ContentSettingsType.IDLE_DETECTION:
return "idle_detection_permission_list";
case ContentSettingsType.JAVASCRIPT:
@@ -435,6 +437,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
setUpSoundPreference(preference);
} else if (type == ContentSettingsType.JAVASCRIPT) {
setUpJavascriptPreference(preference);
+ } else if (type == ContentSettingsType.AUTOPLAY) {
+ setUpAutoplayPreference(preference);
} else if (type == ContentSettingsType.COOKIES) {
setUpCookiePreference(preference);
} else if (type == ContentSettingsType.GEOLOCATION) {
@@ -921,6 +925,24 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
@@ -480,6 +482,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
setUpNotificationsPreference(preference, isPermissionEmbargoed(type));
} else if (type == ContentSettingsType.COOKIES) {
setUpCookiePreference(preference);
+ } else if (type == ContentSettingsType.AUTOPLAY) {
+ setUpAutoplayPreference(preference);
} else {
setupContentSettingsPreference(preference,
mSite.getContentSetting(
@@ -972,6 +976,24 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
}
}
@ -256,12 +256,12 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c
+ @ContentSettingValues
+ @Nullable
+ Integer currentValue = mSite.getContentSetting(
+ getSiteSettingsClient().getBrowserContextHandle(), ContentSettingsType.AUTOPLAY);
+ getSiteSettingsDelegate().getBrowserContextHandle(), ContentSettingsType.AUTOPLAY);
+ // In order to always show the autoplay permission, set it up with the default value if it
+ // doesn't have a current value.
+ if (currentValue == null) {
+ currentValue = WebsitePreferenceBridge.isCategoryEnabled(
+ getSiteSettingsClient().getBrowserContextHandle(),
+ getSiteSettingsDelegate().getBrowserContextHandle(),
+ ContentSettingsType.AUTOPLAY)
+ ? ContentSettingValues.ALLOW
+ : ContentSettingValues.BLOCK;
@ -272,11 +272,11 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c
+
private void setUpSoundPreference(Preference preference) {
BrowserContextHandle browserContextHandle =
getSiteSettingsClient().getBrowserContextHandle();
getSiteSettingsDelegate().getBrowserContextHandle();
diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsCategory.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsCategory.java
--- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsCategory.java
+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsCategory.java
@@ -43,7 +43,7 @@ public class SiteSettingsCategory {
@@ -42,7 +42,7 @@ public class SiteSettingsCategory {
Type.CLIPBOARD, Type.COOKIES, Type.IDLE_DETECTION, Type.DEVICE_LOCATION,
Type.JAVASCRIPT, Type.MICROPHONE, Type.NFC, Type.NOTIFICATIONS, Type.POPUPS,
Type.PROTECTED_MEDIA, Type.SENSORS, Type.SOUND, Type.USB, Type.VIRTUAL_REALITY,
@ -285,7 +285,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c
@Retention(RetentionPolicy.SOURCE)
public @interface Type {
// All updates here must also be reflected in {@link #preferenceKey(int)
@@ -72,10 +72,11 @@ public class SiteSettingsCategory {
@@ -71,10 +71,11 @@ public class SiteSettingsCategory {
int VIRTUAL_REALITY = 21;
int USE_STORAGE = 22;
int TIMEZONE_OVERRIDE = 23;
@ -298,7 +298,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c
}
private final BrowserContextHandle mBrowserContextHandle;
@@ -181,6 +182,8 @@ public class SiteSettingsCategory {
@@ -180,6 +181,8 @@ public class SiteSettingsCategory {
return ContentSettingsType.NFC;
case Type.NOTIFICATIONS:
return ContentSettingsType.NOTIFICATIONS;
@ -307,7 +307,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c
case Type.POPUPS:
return ContentSettingsType.POPUPS;
case Type.PROTECTED_MEDIA:
@@ -254,6 +257,8 @@ public class SiteSettingsCategory {
@@ -253,6 +256,8 @@ public class SiteSettingsCategory {
return "nfc";
case Type.NOTIFICATIONS:
return "notifications";
@ -319,9 +319,9 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c
diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/Website.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/Website.java
--- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/Website.java
+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/Website.java
@@ -216,6 +216,14 @@ public final class Website implements Serializable {
} else {
RecordUserAction.record("JavascriptContentSetting.DisableBy.SiteSettings");
@@ -219,6 +219,14 @@ public final class Website implements Serializable {
getAddress().getOrigin(), value, "");
setContentSettingException(type, exception);
}
+ } else if (type == ContentSettingsType.AUTOPLAY) {
+ // It is possible to set the permission without having an existing exception,
@ -406,11 +406,6 @@ diff --git a/components/browser_ui/site_settings/android/website_preference_brid
static jboolean JNI_WebsitePreferenceBridge_IsContentSettingManagedByCustodian(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle,
@@ -934,4 +957,3 @@ static base::android::ScopedJavaLocalRef<jstring> JNI_WebsitePreferenceBridge_Ge
GetHostContentSettingsMap(jbrowser_context_handle)->GetTimezoneOverrideValue(timezone);
return ConvertUTF8ToJavaString(env, timezone);
}
-
diff --git a/components/browser_ui/strings/android/site_settings.grdp b/components/browser_ui/strings/android/site_settings.grdp
--- a/components/browser_ui/strings/android/site_settings.grdp
+++ b/components/browser_ui/strings/android/site_settings.grdp
@ -433,7 +428,7 @@ diff --git a/components/browser_ui/strings/android/site_settings.grdp b/componen
diff --git a/components/content_settings/core/browser/content_settings_registry.cc b/components/content_settings/core/browser/content_settings_registry.cc
--- a/components/content_settings/core/browser/content_settings_registry.cc
+++ b/components/content_settings/core/browser/content_settings_registry.cc
@@ -323,7 +323,7 @@ void ContentSettingsRegistry::Init() {
@@ -311,7 +311,7 @@ void ContentSettingsRegistry::Init() {
ContentSettingsInfo::PERSISTENT,
ContentSettingsInfo::EXCEPTIONS_ON_SECURE_ORIGINS_ONLY);
@ -457,7 +452,7 @@ diff --git a/components/content_settings/core/browser/content_settings_utils.cc
diff --git a/components/content_settings/core/common/content_settings.cc b/components/content_settings/core/common/content_settings.cc
--- a/components/content_settings/core/common/content_settings.cc
+++ b/components/content_settings/core/common/content_settings.cc
@@ -178,6 +178,7 @@ bool RendererContentSettingRules::IsRendererContentSetting(
@@ -179,6 +179,7 @@ bool RendererContentSettingRules::IsRendererContentSetting(
ContentSettingsType content_type) {
return content_type == ContentSettingsType::IMAGES ||
content_type == ContentSettingsType::JAVASCRIPT ||
@ -516,7 +511,7 @@ diff --git a/components/content_settings/core/common/content_settings_mojom_trai
diff --git a/components/content_settings/renderer/content_settings_agent_impl.cc b/components/content_settings/renderer/content_settings_agent_impl.cc
--- a/components/content_settings/renderer/content_settings_agent_impl.cc
+++ b/components/content_settings/renderer/content_settings_agent_impl.cc
@@ -430,6 +430,17 @@ bool ContentSettingsAgentImpl::AllowRunningInsecureContent(
@@ -422,6 +422,17 @@ bool ContentSettingsAgentImpl::AllowRunningInsecureContent(
return false;
}
@ -537,7 +532,7 @@ diff --git a/components/content_settings/renderer/content_settings_agent_impl.cc
diff --git a/components/content_settings/renderer/content_settings_agent_impl.h b/components/content_settings/renderer/content_settings_agent_impl.h
--- a/components/content_settings/renderer/content_settings_agent_impl.h
+++ b/components/content_settings/renderer/content_settings_agent_impl.h
@@ -96,6 +96,7 @@ class ContentSettingsAgentImpl
@@ -95,6 +95,7 @@ class ContentSettingsAgentImpl
void DidNotAllowScript() override;
bool AllowRunningInsecureContent(bool allowed_per_settings,
const blink::WebURL& url) override;
@ -565,7 +560,7 @@ diff --git a/components/page_info/page_info.cc b/components/page_info/page_info.
ContentSettingsType::SOUND,
+ ContentSettingsType::AUTOPLAY,
ContentSettingsType::AUTOMATIC_DOWNLOADS,
#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
#if defined(OS_ANDROID) || BUILDFLAG(IS_CHROMEOS_ASH)
ContentSettingsType::PROTECTED_MEDIA_IDENTIFIER,
@@ -141,6 +142,11 @@ bool ShouldShowPermission(const PageInfo::PermissionInfo& info,
return is_subresource_filter_activated;
@ -582,7 +577,7 @@ diff --git a/components/page_info/page_info.cc b/components/page_info/page_info.
diff --git a/components/page_info/page_info_ui.cc b/components/page_info/page_info_ui.cc
--- a/components/page_info/page_info_ui.cc
+++ b/components/page_info/page_info_ui.cc
@@ -163,6 +163,7 @@ base::span<const PermissionsUIInfo> GetContentSettingsUIInfo() {
@@ -160,6 +160,7 @@ base::span<const PermissionsUIInfo> GetContentSettingsUIInfo() {
IDS_PAGE_INFO_TYPE_PROTECTED_MEDIA_IDENTIFIER},
#endif
{ContentSettingsType::ADS, IDS_PAGE_INFO_TYPE_ADS},
@ -593,7 +588,7 @@ diff --git a/components/page_info/page_info_ui.cc b/components/page_info/page_in
diff --git a/components/page_info_strings.grdp b/components/page_info_strings.grdp
--- a/components/page_info_strings.grdp
+++ b/components/page_info_strings.grdp
@@ -281,6 +281,9 @@
@@ -278,6 +278,9 @@
<message name="IDS_PAGE_INFO_TYPE_SOUND" desc="The label used for the sound permission controls in the Page Info popup.">
Sound
</message>
@ -636,7 +631,7 @@ diff --git a/third_party/blink/renderer/core/html/media/autoplay_policy.cc b/thi
}
String AutoplayPolicy::GetPlayErrorMessage() const {
@@ -382,6 +383,15 @@ void AutoplayPolicy::MaybeSetAutoplayInitiated() {
@@ -384,6 +385,15 @@ void AutoplayPolicy::MaybeSetAutoplayInitiated() {
}
}