From 23fde852287bcac76f017f39d41a6d99d8c2ca49 Mon Sep 17 00:00:00 2001 From: uazo <29201891+uazo@users.noreply.github.com> Date: Wed, 8 Jun 2022 20:05:40 +0200 Subject: [PATCH] fix category setting activation (#2119) Co-authored-by: Carmelo Messina --- build/patches/Add-webGL-site-setting.patch | 4 ++-- build/patches/Add-webRTC-site-settings.patch | 4 ++-- .../Content-settings-infrastructure.patch | 24 +++++++++---------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/build/patches/Add-webGL-site-setting.patch b/build/patches/Add-webGL-site-setting.patch index 5ac954eb..fd34a6b8 100644 --- a/build/patches/Add-webGL-site-setting.patch +++ b/build/patches/Add-webGL-site-setting.patch @@ -96,7 +96,7 @@ new file mode 100644 + public BromiteWebGLContentSetting() { + super(/*contentSettingsType*/ ContentSettingsType.WEBGL, + /*siteSettingsCategory*/ SiteSettingsCategory.Type.WEBGL, -+ /*initialDefaultValue*/ ContentSettingValues.BLOCK, ++ /*defaultEnabledValue*/ ContentSettingValues.ALLOW, + /*defaultDisabledValue*/ ContentSettingValues.BLOCK, + /*allowException*/ true, + /*preferenceKey*/ "webgl", @@ -108,7 +108,7 @@ new file mode 100644 + return new ContentSettingsResources.ResourceItem( + /*icon*/ R.drawable.web_asset, + /*title*/ R.string.webgl_permission_title, -+ /*defaultEnabledValue*/ getInitialDefaultValue(), ++ /*defaultEnabledValue*/ getDefaultEnabledValue(), + /*defaultDisabledValue*/ getDefaultDisabledValue(), + /*enabledSummary*/ R.string.website_settings_category_webgl_enabled, + /*disabledSummary*/ R.string.website_settings_category_webgl_disabled); diff --git a/build/patches/Add-webRTC-site-settings.patch b/build/patches/Add-webRTC-site-settings.patch index ae5b5af4..f445c113 100644 --- a/build/patches/Add-webRTC-site-settings.patch +++ b/build/patches/Add-webRTC-site-settings.patch @@ -91,7 +91,7 @@ new file mode 100644 + public BromiteWebRTCContentSetting() { + super(/*contentSettingsType*/ ContentSettingsType.WEBRTC, + /*siteSettingsCategory*/ SiteSettingsCategory.Type.WEBRTC, -+ /*initialDefaultValue*/ ContentSettingValues.BLOCK, ++ /*defaultEnabledValue*/ ContentSettingValues.ALLOW, + /*defaultDisabledValue*/ ContentSettingValues.BLOCK, + /*allowException*/ true, + /*preferenceKey*/ "webrtc", @@ -103,7 +103,7 @@ new file mode 100644 + return new ContentSettingsResources.ResourceItem( + /*icon*/ R.drawable.web_asset, + /*title*/ R.string.webrtc_permission_title, -+ /*defaultEnabledValue*/ getInitialDefaultValue(), ++ /*defaultEnabledValue*/ getDefaultEnabledValue(), + /*defaultDisabledValue*/ getDefaultDisabledValue(), + /*enabledSummary*/ R.string.website_settings_category_webrtc_enabled, + /*disabledSummary*/ R.string.website_settings_category_webrtc_disabled); diff --git a/build/patches/Content-settings-infrastructure.patch b/build/patches/Content-settings-infrastructure.patch index 1ada2248..352165e4 100644 --- a/build/patches/Content-settings-infrastructure.patch +++ b/build/patches/Content-settings-infrastructure.patch @@ -9,7 +9,7 @@ See BromiteCustomContentSetting_README.md for more information. --- .../browser_ui/site_settings/android/BUILD.gn | 4 + .../BromiteCustomContentSetting.java | 125 ++++++++ - .../BromiteCustomContentSettingImpl.java | 271 ++++++++++++++++++ + .../BromiteCustomContentSettingImpl.java | 269 ++++++++++++++++++ .../BromiteCustomContentSetting_README.md | 151 ++++++++++ .../ContentSettingsResources.java | 13 +- .../site_settings/SingleCategorySettings.java | 28 +- @@ -30,7 +30,7 @@ See BromiteCustomContentSetting_README.md for more information. .../android/page_info_controller_android.cc | 18 ++ components/page_info/page_info.cc | 23 +- components/page_info/page_info_ui.cc | 18 ++ - 23 files changed, 732 insertions(+), 28 deletions(-) + 23 files changed, 730 insertions(+), 28 deletions(-) create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSetting.java create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSettingImpl.java create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSetting_README.md @@ -89,7 +89,7 @@ new file mode 100644 + + private @ContentSettingsType int mContentSettingsType; + private @SiteSettingsCategory.Type int mSiteSettingsCategory; -+ private @ContentSettingValues Integer mInitialDefaultValue; ++ private @ContentSettingValues Integer mDefaultEnabledValue; + private @ContentSettingValues Integer mDefaultDisabledValue; + private boolean mAllowException; + private String mPreferenceKey; @@ -97,14 +97,14 @@ new file mode 100644 + + public BromiteCustomContentSetting(@ContentSettingsType int contentSettingsType, + @SiteSettingsCategory.Type int siteSettingsCategory, -+ @ContentSettingValues Integer initialDefaultValue, ++ @ContentSettingValues Integer defaultEnabledValue, + @ContentSettingValues Integer defaultDisabledValue, + boolean allowException, + String preferenceKey, + String profilePrefKey) { + mContentSettingsType = contentSettingsType; + mSiteSettingsCategory = siteSettingsCategory; -+ mInitialDefaultValue = initialDefaultValue; ++ mDefaultEnabledValue = defaultEnabledValue; + mDefaultDisabledValue = defaultDisabledValue; + mAllowException = allowException; + mPreferenceKey = preferenceKey; @@ -119,8 +119,8 @@ new file mode 100644 + return mSiteSettingsCategory; + } + -+ protected @ContentSettingValues Integer getInitialDefaultValue() { -+ return mInitialDefaultValue; ++ protected @ContentSettingValues Integer getDefaultEnabledValue() { ++ return mDefaultEnabledValue; + } + + public @ContentSettingValues Integer getDefaultDisabledValue() { @@ -183,7 +183,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c new file mode 100644 --- /dev/null +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSettingImpl.java -@@ -0,0 +1,271 @@ +@@ -0,0 +1,269 @@ +/* + This file is part of Bromite. + @@ -308,10 +308,8 @@ new file mode 100644 + continue; + } + -+ int default_value = WebsitePreferenceBridge.getDefaultContentSetting( -+ browserContextHandle, cs.getContentSetting()); + if (SingleCategorySettings.BINARY_TOGGLE_KEY.equals(preference.getKey())) { -+ int setting = ((boolean) newValue) == true ? default_value : ++ int setting = ((boolean) newValue) == true ? cs.getDefaultEnabledValue() : + cs.getDefaultDisabledValue(); + + WebsitePreferenceBridge.setDefaultContentSetting(browserContextHandle, @@ -477,7 +475,7 @@ new file mode 100644 + public BromiteWebGLContentSetting() { + super(/*contentSettingsType*/ ContentSettingsType.NEW_CONTENT_SETTING, + /*siteSettingsCategory*/ SiteSettingsCategory.Type.NEW_CONTENT_SETTING, -+ /*initialDefaultValue*/ ContentSettingValues.BLOCK, ++ /*defaultEnabledValue*/ ContentSettingValues.ALLOW, + /*defaultDisabledValue*/ ContentSettingValues.BLOCK, + /*allowException*/ true, + /*preferenceKey*/ "new_content_setting", @@ -489,7 +487,7 @@ new file mode 100644 + return new ContentSettingsResources.ResourceItem( + /*icon*/ R.drawable.web_asset, + /*title*/ R.string.new_content_setting_permission_title, -+ /*defaultEnabledValue*/ getInitialDefaultValue(), ++ /*defaultEnabledValue*/ getDefaultEnabledValue(), + /*defaultDisabledValue*/ getDefaultDisabledValue(), + /*enabledSummary*/ R.string.new_content_setting_enabled, + /*disabledSummary*/ R.string.new_content_setting_disabled);