From 829aacfc9626cee12c0169a7135ba2616f10d41d Mon Sep 17 00:00:00 2001 From: Carmelo Messina Date: Wed, 14 Jun 2023 09:02:52 +0200 Subject: [PATCH 1/3] stage 1 - android version --- .../00Viewport-Protection-Site-Setting.patch | 298 +----- .../patches/00Viewport-Protection-flag.patch | 10 +- .../00WIN-ADDTO-Add-webGL-site-setting.patch | 19 +- ...00WIN-ADDTO-Add-webRTC-site-settings.patch | 4 +- ...DDTO-Content-settings-infrastructure.patch | 21 - ...0WIN-ADDTO-JIT-site-settings--fixup-.patch | 22 + .../00WIN-ADDTO-JIT-site-settings.patch | 8 +- ...Revert-the-removal-to-block-autoplay.patch | 6 +- .../00WIN-ADDTO-Timezone-customization.patch | 10 +- build/patches/00bromite-build-utils.patch | 453 +++++++++ build/patches/Add-webGL-site-setting.patch | 315 +------ build/patches/Add-webRTC-site-settings.patch | 335 ++----- .../Content-settings-infrastructure.patch | 858 +++++++++++++++--- build/patches/JIT-site-settings.patch | 439 +++------ ...moval-of-an-option-to-block-autoplay.patch | 542 +++-------- ...tings-for-cookies-javascript-and-ads.patch | 16 +- build/patches/Site-setting-for-images.patch | 469 +++------- build/patches/Timezone-customization.patch | 256 ++---- 18 files changed, 1884 insertions(+), 2197 deletions(-) delete mode 100644 build/patches/00WIN-ADDTO-Content-settings-infrastructure.patch create mode 100644 build/patches/00WIN-ADDTO-JIT-site-settings--fixup-.patch create mode 100644 build/patches/00bromite-build-utils.patch diff --git a/build/patches/00Viewport-Protection-Site-Setting.patch b/build/patches/00Viewport-Protection-Site-Setting.patch index 7744a5f3..88f9d653 100644 --- a/build/patches/00Viewport-Protection-Site-Setting.patch +++ b/build/patches/00Viewport-Protection-Site-Setting.patch @@ -17,35 +17,23 @@ Subject: Viewport Protection Site Setting .../views/page_info/page_info_view_factory.cc | 3 + .../settings_localized_strings_provider.cc | 7 ++ .../ui/webui/settings/site_settings_helper.cc | 1 + - .../browser_ui/site_settings/android/BUILD.gn | 3 + - .../BromiteCustomContentSettingImpl.java | 1 + - .../BromiteViewportContentSetting.java | 86 +++++++++++++++++++ - .../site_settings/SiteSettingsCategory.java | 5 +- - .../strings/android/browser_ui_strings.grd | 1 + - .../browser_ui/strings/android/viewport.grdp | 18 ++++ - components/components_strings.grd | 1 + - .../core/browser/content_settings_registry.cc | 15 +++- - .../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 ++ - .../core/common/content_settings_types.h | 2 + - .../renderer/content_settings_agent_impl.cc | 9 ++ - .../renderer/content_settings_agent_impl.h | 1 + + .../impl/BromiteViewportContentSetting.java | 88 +++++++++++++++++++ + .../bromite_content_settings/viewport.grdp | 18 ++++ + .../bromite_content_settings/viewport.inc | 13 +++ + .../bromite_content_settings/VIEWPORT.inc | 1 + third_party/blink/common/features.cc | 2 +- - .../platform/web_content_settings_client.h | 2 + - .../renderer/core/frame/local_dom_window.cc | 1 + - third_party/blink/renderer/core/page/page.cc | 2 + - 35 files changed, 234 insertions(+), 6 deletions(-) - create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteViewportContentSetting.java - create mode 100644 components/browser_ui/strings/android/viewport.grdp + .../renderer/core/frame/local_dom_window.cc | 2 + + third_party/blink/renderer/core/page/page.cc | 3 + + 21 files changed, 201 insertions(+), 1 deletion(-) + create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteViewportContentSetting.java + create mode 100644 components/browser_ui/strings/android/bromite_content_settings/viewport.grdp + create mode 100644 components/content_settings/core/browser/bromite_content_settings/viewport.inc + create mode 100644 components/content_settings/core/common/bromite_content_settings/VIEWPORT.inc diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp --- a/chrome/app/settings_strings.grdp +++ b/chrome/app/settings_strings.grdp -@@ -4424,6 +4424,25 @@ +@@ -4434,6 +4434,25 @@ Not allowed to use WebRTC @@ -235,7 +223,7 @@ diff --git a/chrome/browser/ui/views/page_info/page_info_view_factory.cc b/chrom diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc --- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc -@@ -2555,6 +2555,13 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, +@@ -2556,6 +2556,13 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, {"siteSettingsWebRTCAllowedExceptions",IDS_SETTINGS_SITE_SETTINGS_WEBRTC_ALLOWED_EXCEPTIONS}, {"siteSettingsWebRTCBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_WEBRTC_BLOCKED_EXCEPTIONS}, {"siteSettingsWebRTCMidSentence", IDS_SITE_SETTINGS_WEBRTC_TITLE}, @@ -260,35 +248,11 @@ diff --git a/chrome/browser/ui/webui/settings/site_settings_helper.cc b/chrome/b // Add new content settings here if a corresponding Javascript string // representation for it is not required, for example if the content setting -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 -@@ -112,6 +112,9 @@ android_library("java") { - sources += [ - "java/src/org/chromium/components/browser_ui/site_settings/BromiteWebRTCContentSetting.java", - ] -+ sources += [ -+ "java/src/org/chromium/components/browser_ui/site_settings/BromiteViewportContentSetting.java", -+ ] - annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ] - resources_package = "org.chromium.components.browser_ui.site_settings" - deps = [ -diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSettingImpl.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSettingImpl.java ---- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSettingImpl.java -+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSettingImpl.java -@@ -45,6 +45,7 @@ public abstract class BromiteCustomContentSettingImpl { - mItemList = new ArrayList(); - mItemList.add(new BromiteWebGLContentSetting()); - mItemList.add(new BromiteWebRTCContentSetting()); -+ mItemList.add(new BromiteViewportContentSetting()); - } - - public static SiteSettingsCategory createFromType( -diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteViewportContentSetting.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteViewportContentSetting.java +diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteViewportContentSetting.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteViewportContentSetting.java new file mode 100644 --- /dev/null -+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteViewportContentSetting.java -@@ -0,0 +1,86 @@ ++++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteViewportContentSetting.java +@@ -0,0 +1,88 @@ +/* + This file is part of Bromite. + @@ -306,8 +270,11 @@ new file mode 100644 + along with Bromite. If not, see . +*/ + -+package org.chromium.components.browser_ui.site_settings; ++package org.chromium.components.browser_ui.site_settings.impl; + ++import org.chromium.components.browser_ui.site_settings.R; ++ ++import org.chromium.components.browser_ui.site_settings.BromiteCustomContentSetting; +import org.chromium.components.browser_ui.site_settings.ContentSettingsResources; +import org.chromium.components.browser_ui.site_settings.SiteSettingsCategory; +import org.chromium.components.content_settings.ContentSettingValues; @@ -323,7 +290,6 @@ new file mode 100644 +public class BromiteViewportContentSetting extends BromiteCustomContentSetting { + public BromiteViewportContentSetting() { + super(/*contentSettingsType*/ ContentSettingsType.VIEWPORT, -+ /*siteSettingsCategory*/ SiteSettingsCategory.Type.VIEWPORT, + /*defaultEnabledValue*/ ContentSettingValues.ALLOW, + /*defaultDisabledValue*/ ContentSettingValues.BLOCK, + /*allowException*/ true, @@ -375,46 +341,10 @@ new file mode 100644 + return value != ContentSettingValues.BLOCK; + } +} -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 -@@ -48,7 +48,7 @@ public class SiteSettingsCategory { - Type.USE_STORAGE, Type.AUTO_DARK_WEB_CONTENT, Type.REQUEST_DESKTOP_SITE, - Type.FEDERATED_IDENTITY_API, Type.THIRD_PARTY_COOKIES, Type.SITE_DATA, Type.ANTI_ABUSE, - Type.TIMEZONE_OVERRIDE, Type.AUTOPLAY, Type.JAVASCRIPT_JIT, Type.IMAGES, -- Type.NUM_ENTRIES, Type.WEBGL, Type.WEBRTC}) -+ Type.NUM_ENTRIES, Type.WEBGL, Type.WEBRTC, Type.VIEWPORT}) - @Retention(RetentionPolicy.SOURCE) - public @interface Type { - // All updates here must also be reflected in {@link #preferenceKey(int) -@@ -88,10 +88,11 @@ public class SiteSettingsCategory { - int IMAGES = 32; - int WEBGL = 33; - int WEBRTC = 34; -+ int VIEWPORT = 35; - /** - * Number of handled categories used for calculating array sizes. - */ -- int NUM_ENTRIES = 35; -+ int NUM_ENTRIES = 36; - } - - private final BrowserContextHandle mBrowserContextHandle; -diff --git a/components/browser_ui/strings/android/browser_ui_strings.grd b/components/browser_ui/strings/android/browser_ui_strings.grd ---- a/components/browser_ui/strings/android/browser_ui_strings.grd -+++ b/components/browser_ui/strings/android/browser_ui_strings.grd -@@ -176,6 +176,7 @@ - - - -+ - - - Got it -diff --git a/components/browser_ui/strings/android/viewport.grdp b/components/browser_ui/strings/android/viewport.grdp +diff --git a/components/browser_ui/strings/android/bromite_content_settings/viewport.grdp b/components/browser_ui/strings/android/bromite_content_settings/viewport.grdp new file mode 100644 --- /dev/null -+++ b/components/browser_ui/strings/android/viewport.grdp ++++ b/components/browser_ui/strings/android/bromite_content_settings/viewport.grdp @@ -0,0 +1,18 @@ + + @@ -434,32 +364,11 @@ new file mode 100644 + Disabled + + -diff --git a/components/components_strings.grd b/components/components_strings.grd ---- a/components/components_strings.grd -+++ b/components/components_strings.grd -@@ -339,6 +339,7 @@ - - - -+ - - - -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 -@@ -627,12 +627,25 @@ void ContentSettingsRegistry::Init() { - /*valid_settings=*/{CONTENT_SETTING_ALLOW, - CONTENT_SETTING_BLOCK}, - WebsiteSettingsInfo::TOP_ORIGIN_ONLY_SCOPE, -- WebsiteSettingsRegistry::PLATFORM_ANDROID, -+ WebsiteSettingsRegistry::ALL_PLATFORMS, - ContentSettingsInfo::INHERIT_IN_INCOGNITO, - ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS, - /*show_into_info_page*/ true, - /*permission_type_ui*/ IDS_SITE_SETTINGS_TYPE_WEBRTC, - /*permission_type_ui_mid_sentence*/ IDS_SITE_SETTINGS_TYPE_WEBRTC_MID_SENTENCE); -+ +diff --git a/components/content_settings/core/browser/bromite_content_settings/viewport.inc b/components/content_settings/core/browser/bromite_content_settings/viewport.inc +new file mode 100644 +--- /dev/null ++++ b/components/content_settings/core/browser/bromite_content_settings/viewport.inc +@@ -0,0 +1,13 @@ + Register(ContentSettingsType::VIEWPORT, "viewport", CONTENT_SETTING_ALLOW, + WebsiteSettingsInfo::SYNCABLE, + /*allowlisted_schemes=*/{}, @@ -470,134 +379,15 @@ diff --git a/components/content_settings/core/browser/content_settings_registry. + ContentSettingsInfo::INHERIT_IN_INCOGNITO, + ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS, + /*show_into_info_page*/ true, ++ /*is_renderer_content_setting*/ true, + /*permission_type_ui*/ IDS_SITE_SETTINGS_TYPE_VIEWPORT, + /*permission_type_ui_mid_sentence*/ IDS_SITE_SETTINGS_TYPE_VIEWPORT_MID_SENTENCE); - } - - void ContentSettingsRegistry::Register( -diff --git a/components/content_settings/core/browser/content_settings_utils.cc b/components/content_settings/core/browser/content_settings_utils.cc ---- a/components/content_settings/core/browser/content_settings_utils.cc -+++ b/components/content_settings/core/browser/content_settings_utils.cc -@@ -162,6 +162,8 @@ void GetRendererContentSettingRules(const HostContentSettingsMap* map, - &(rules->webgl_rules)); - map->GetSettingsForOneType(ContentSettingsType::WEBRTC, - &(rules->webrtc_rules)); -+ map->GetSettingsForOneType(ContentSettingsType::VIEWPORT, -+ &(rules->viewport_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 ---- a/components/content_settings/core/common/content_settings.cc -+++ b/components/content_settings/core/common/content_settings.cc -@@ -221,7 +221,8 @@ bool RendererContentSettingRules::IsRendererContentSetting( - content_type == ContentSettingsType::AUTO_DARK_WEB_CONTENT || - content_type == ContentSettingsType::TIMEZONE_OVERRIDE || - content_type == ContentSettingsType::WEBGL || -- content_type == ContentSettingsType::WEBRTC; -+ content_type == ContentSettingsType::WEBRTC || -+ content_type == ContentSettingsType::VIEWPORT; - } - - void RendererContentSettingRules::FilterRulesByOutermostMainFrameURL( -@@ -235,6 +236,7 @@ void RendererContentSettingRules::FilterRulesByOutermostMainFrameURL( - FilterRulesForType(autoplay_rules, outermost_main_frame_url); - FilterRulesForType(webgl_rules, outermost_main_frame_url); - FilterRulesForType(webrtc_rules, outermost_main_frame_url); -+ FilterRulesForType(viewport_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 ---- a/components/content_settings/core/common/content_settings.h -+++ b/components/content_settings/core/common/content_settings.h -@@ -98,6 +98,7 @@ struct RendererContentSettingRules { - std::string timezone_override_value; - ContentSettingsForOneType webgl_rules; - ContentSettingsForOneType webrtc_rules; -+ ContentSettingsForOneType viewport_rules; - }; - - namespace content_settings { -diff --git a/components/content_settings/core/common/content_settings.mojom b/components/content_settings/core/common/content_settings.mojom ---- a/components/content_settings/core/common/content_settings.mojom -+++ b/components/content_settings/core/common/content_settings.mojom -@@ -83,4 +83,5 @@ struct RendererContentSettingRules { - string timezone_override_value; - array webgl_rules; - array webrtc_rules; -+ array viewport_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 ---- a/components/content_settings/core/common/content_settings_mojom_traits.cc -+++ b/components/content_settings/core/common/content_settings_mojom_traits.cc -@@ -107,7 +107,8 @@ bool StructTraitstimezone_override_rules) && - data.ReadTimezoneOverrideValue(&out->timezone_override_value) && - data.ReadWebglRules(&out->webgl_rules) && -- data.ReadWebrtcRules(&out->webrtc_rules); -+ data.ReadWebrtcRules(&out->webrtc_rules) && -+ data.ReadViewportRules(&out->viewport_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 ---- a/components/content_settings/core/common/content_settings_mojom_traits.h -+++ b/components/content_settings/core/common/content_settings_mojom_traits.h -@@ -175,6 +175,11 @@ struct StructTraits< - return r.webrtc_rules; - } - -+ static const std::vector& viewport_rules( -+ const RendererContentSettingRules& r) { -+ return r.viewport_rules; -+ } -+ - static bool Read( - content_settings::mojom::RendererContentSettingRulesDataView data, - RendererContentSettingRules* out); -diff --git a/components/content_settings/core/common/content_settings_types.h b/components/content_settings/core/common/content_settings_types.h ---- a/components/content_settings/core/common/content_settings_types.h -+++ b/components/content_settings/core/common/content_settings_types.h -@@ -281,6 +281,8 @@ enum class ContentSettingsType : int32_t { - - WEBRTC, - +diff --git a/components/content_settings/core/common/bromite_content_settings/VIEWPORT.inc b/components/content_settings/core/common/bromite_content_settings/VIEWPORT.inc +new file mode 100644 +--- /dev/null ++++ b/components/content_settings/core/common/bromite_content_settings/VIEWPORT.inc +@@ -0,0 +1 @@ + VIEWPORT, -+ - // Setting to indicate whether browser should allow signing into a website via - // the browser FedCM API. - FEDERATED_IDENTITY_API, -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 -@@ -459,6 +459,15 @@ bool ContentSettingsAgentImpl::AllowWebRTC(bool enabled_per_settings) { - url::Origin(frame->GetDocument().GetSecurityOrigin()).GetURL()); - } - -+bool ContentSettingsAgentImpl::AllowViewportChange(bool enabled_per_settings) { -+ if (!content_setting_rules_) -+ return false; -+ blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); -+ return CONTENT_SETTING_ALLOW == GetContentSettingFromRules( -+ content_setting_rules_->viewport_rules, -+ url::Origin(frame->GetDocument().GetSecurityOrigin()).GetURL()); -+} -+ - bool ContentSettingsAgentImpl::IsAllowlistedForContentSettings() const { - if (should_allowlist_) - return true; -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 -@@ -101,6 +101,7 @@ class ContentSettingsAgentImpl - bool ShouldAutoupgradeMixedContent() override; - bool AllowWebgl(bool enabled_per_settings) override; - bool AllowWebRTC(bool enabled_per_settings) override; -+ bool AllowViewportChange(bool enabled_per_settings) override; - - bool allow_running_insecure_content() const { - return allow_running_insecure_content_; diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/features.cc --- a/third_party/blink/common/features.cc +++ b/third_party/blink/common/features.cc @@ -610,38 +400,28 @@ diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/fea BASE_FEATURE(kPrivacySandboxAdsAPIs, "PrivacySandboxAdsAPIs", // disabled by default -diff --git a/third_party/blink/public/platform/web_content_settings_client.h b/third_party/blink/public/platform/web_content_settings_client.h ---- a/third_party/blink/public/platform/web_content_settings_client.h -+++ b/third_party/blink/public/platform/web_content_settings_client.h -@@ -103,6 +103,8 @@ class WebContentSettingsClient { - - virtual bool AllowWebRTC(bool default_value) { return default_value; } - -+ virtual bool AllowViewportChange(bool default_value) { return default_value; } -+ - // Reports that passive mixed content was found at the provided URL. - virtual void PassiveInsecureContentFound(const WebURL&) {} - diff --git a/third_party/blink/renderer/core/frame/local_dom_window.cc b/third_party/blink/renderer/core/frame/local_dom_window.cc --- a/third_party/blink/renderer/core/frame/local_dom_window.cc +++ b/third_party/blink/renderer/core/frame/local_dom_window.cc -@@ -2322,6 +2322,7 @@ DOMWindow* LocalDOMWindow::open(v8::Isolate* isolate, +@@ -2322,6 +2322,8 @@ DOMWindow* LocalDOMWindow::open(v8::Isolate* isolate, // var w = window.open() // var not_emulated_screen_info = w.screen bool protection_enabled = base::FeatureList::IsEnabled(features::kViewportProtection); -+ protection_enabled |= GetFrame()->GetContentSettingsClient()->AllowViewportChange(false); ++ protection_enabled |= GetFrame()->GetContentSettingsClient()->AllowContentSetting( ++ ContentSettingsType::VIEWPORT, false); result.frame->GetPage()->CalculateEmulatedScreenSetting( To(result.frame), /*force*/ protection_enabled); diff --git a/third_party/blink/renderer/core/page/page.cc b/third_party/blink/renderer/core/page/page.cc --- a/third_party/blink/renderer/core/page/page.cc +++ b/third_party/blink/renderer/core/page/page.cc -@@ -884,6 +884,8 @@ void Page::UpdateAcceleratedCompositingSettings() { +@@ -884,6 +884,9 @@ void Page::UpdateAcceleratedCompositingSettings() { void Page::CalculateEmulatedScreenSetting(LocalFrame* frame, bool force) { bool isEnabled = base::FeatureList::IsEnabled(features::kViewportProtection); + blink::WebContentSettingsClient* settings = frame->GetContentSettingsClient(); -+ isEnabled |= (settings && settings->AllowViewportChange(false)); ++ isEnabled |= (settings && settings->AllowContentSetting( ++ ContentSettingsType::VIEWPORT, /*default_value*/ false)); if (isEnabled || force) { // this is the maximum (and minimum) value which in percentage // corresponds to +- 0.03% diff --git a/build/patches/00Viewport-Protection-flag.patch b/build/patches/00Viewport-Protection-flag.patch index 7e736eda..b9a83bea 100644 --- a/build/patches/00Viewport-Protection-flag.patch +++ b/build/patches/00Viewport-Protection-flag.patch @@ -34,7 +34,7 @@ The feature is controlled by a feature flag (default enabled) diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc -@@ -7794,6 +7794,11 @@ const FeatureEntry kFeatureEntries[] = { +@@ -7803,6 +7803,11 @@ const FeatureEntry kFeatureEntries[] = { FEATURE_VALUE_TYPE(paint_preview::kPaintPreviewDemo)}, #endif // BUILDFLAG(ENABLE_PAINT_PREVIEW) && BUILDFLAG(IS_ANDROID) @@ -49,7 +49,7 @@ diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc --- a/chrome/browser/flag_descriptions.cc +++ b/chrome/browser/flag_descriptions.cc -@@ -7106,6 +7106,12 @@ const char kPaintPreviewDemoDescription[] = +@@ -7119,6 +7119,12 @@ const char kPaintPreviewDemoDescription[] = "previews."; #endif // ENABLE_PAINT_PREVIEW && BUILDFLAG(IS_ANDROID) @@ -65,7 +65,7 @@ diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descripti diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h --- a/chrome/browser/flag_descriptions.h +++ b/chrome/browser/flag_descriptions.h -@@ -4124,6 +4124,9 @@ extern const char kPaintPreviewDemoName[]; +@@ -4133,6 +4133,9 @@ extern const char kPaintPreviewDemoName[]; extern const char kPaintPreviewDemoDescription[]; #endif // ENABLE_PAINT_PREVIEW && BUILDFLAG(IS_ANDROID) @@ -92,7 +92,7 @@ diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/fea diff --git a/third_party/blink/public/common/features.h b/third_party/blink/public/common/features.h --- a/third_party/blink/public/common/features.h +++ b/third_party/blink/public/common/features.h -@@ -919,6 +919,9 @@ BLINK_COMMON_EXPORT extern const base::FeatureParam< +@@ -924,6 +924,9 @@ BLINK_COMMON_EXPORT extern const base::FeatureParam< // base url inheritance behavior from https://crbug.com/1356658. BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kNewBaseUrlInheritanceBehavior); @@ -650,7 +650,7 @@ diff --git a/third_party/blink/renderer/core/page/page.h b/third_party/blink/ren diff --git a/third_party/blink/renderer/platform/runtime_enabled_features.json5 b/third_party/blink/renderer/platform/runtime_enabled_features.json5 --- a/third_party/blink/renderer/platform/runtime_enabled_features.json5 +++ b/third_party/blink/renderer/platform/runtime_enabled_features.json5 -@@ -1823,8 +1823,8 @@ +@@ -1819,8 +1819,8 @@ // as a speculative site compatibility measure, because web authors may // assume that screen dimensions match window.innerWidth/innerHeight while // a page is fullscreen, but that is not always true. crbug.com/1367416 diff --git a/build/patches/00WIN-ADDTO-Add-webGL-site-setting.patch b/build/patches/00WIN-ADDTO-Add-webGL-site-setting.patch index e2b0ce57..4d3f8616 100644 --- a/build/patches/00WIN-ADDTO-Add-webGL-site-setting.patch +++ b/build/patches/00WIN-ADDTO-Add-webGL-site-setting.patch @@ -17,13 +17,12 @@ Subject: WIN ADDTO Add webGL site setting .../views/page_info/page_info_view_factory.cc | 3 +++ .../settings_localized_strings_provider.cc | 7 ++++++ .../ui/webui/settings/site_settings_helper.cc | 1 + - .../core/browser/content_settings_registry.cc | 2 +- - 15 files changed, 76 insertions(+), 1 deletion(-) + 14 files changed, 75 insertions(+) diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp --- a/chrome/app/settings_strings.grdp +++ b/chrome/app/settings_strings.grdp -@@ -4386,6 +4386,25 @@ +@@ -4396,6 +4396,25 @@ Random Timezone override @@ -213,7 +212,7 @@ diff --git a/chrome/browser/ui/views/page_info/page_info_view_factory.cc b/chrom diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc --- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc -@@ -2541,6 +2541,13 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, +@@ -2542,6 +2542,13 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, {"siteSettingsTimezoneOverrideAllowedExceptions",IDS_SETTINGS_SITE_SETTINGS_TIMEZONE_OVERRIDE_ALLOWED_EXCEPTIONS}, {"siteSettingsTimezoneOverrideBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_TIMEZONE_OVERRIDE_BLOCKED_EXCEPTIONS}, {"siteSettingsTimezoneOverrideMidSentence", IDS_SITE_SETTINGS_TIMEZONE_OVERRIDE_TITLE}, @@ -238,17 +237,5 @@ diff --git a/chrome/browser/ui/webui/settings/site_settings_helper.cc b/chrome/b // Add new content settings here if a corresponding Javascript string // representation for it is not required, for example if the content setting -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 -@@ -614,7 +614,7 @@ void ContentSettingsRegistry::Init() { - /*valid_settings=*/{CONTENT_SETTING_ALLOW, - CONTENT_SETTING_BLOCK}, - WebsiteSettingsInfo::TOP_ORIGIN_ONLY_SCOPE, -- WebsiteSettingsRegistry::PLATFORM_ANDROID, -+ WebsiteSettingsRegistry::ALL_PLATFORMS, - ContentSettingsInfo::INHERIT_IN_INCOGNITO, - ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS, - /*show_into_info_page*/ true, -- 2.25.1 diff --git a/build/patches/00WIN-ADDTO-Add-webRTC-site-settings.patch b/build/patches/00WIN-ADDTO-Add-webRTC-site-settings.patch index e8beb1c1..d167e3de 100644 --- a/build/patches/00WIN-ADDTO-Add-webRTC-site-settings.patch +++ b/build/patches/00WIN-ADDTO-Add-webRTC-site-settings.patch @@ -22,7 +22,7 @@ Subject: WIN ADDTO Add webRTC site settings diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp --- a/chrome/app/settings_strings.grdp +++ b/chrome/app/settings_strings.grdp -@@ -4405,6 +4405,25 @@ +@@ -4415,6 +4415,25 @@ Not allowed to use webgl @@ -212,7 +212,7 @@ diff --git a/chrome/browser/ui/views/page_info/page_info_view_factory.cc b/chrom diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc --- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc -@@ -2548,6 +2548,13 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, +@@ -2549,6 +2549,13 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, {"siteSettingsWebglAllowedExceptions",IDS_SETTINGS_SITE_SETTINGS_WEBGL_ALLOWED_EXCEPTIONS}, {"siteSettingsWebglBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_WEBGL_BLOCKED_EXCEPTIONS}, {"siteSettingsWebglMidSentence", IDS_SITE_SETTINGS_WEBGL_TITLE}, diff --git a/build/patches/00WIN-ADDTO-Content-settings-infrastructure.patch b/build/patches/00WIN-ADDTO-Content-settings-infrastructure.patch deleted file mode 100644 index afb9f16e..00000000 --- a/build/patches/00WIN-ADDTO-Content-settings-infrastructure.patch +++ /dev/null @@ -1,21 +0,0 @@ -From: Your Name -Date: Thu, 13 Oct 2022 10:26:13 +0000 -Subject: WIN ADDTO Content settings infrastructure - ---- - components/content_settings/core/common/content_settings.cc | 1 + - 1 file changed, 1 insertion(+) - -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 -@@ -143,6 +143,7 @@ ContentSetting IntToContentSetting(int content_setting) { - int ContentSettingTypeToHistogramValue(ContentSettingsType content_setting, - size_t* num_values) { - *num_values = std::size(kHistogramValue); -+ if ((true)) return 0; - - // Verify the array is sorted by enum type and contains all values. - DCHECK(std::is_sorted(std::begin(kHistogramValue), std::end(kHistogramValue), --- -2.25.1 diff --git a/build/patches/00WIN-ADDTO-JIT-site-settings--fixup-.patch b/build/patches/00WIN-ADDTO-JIT-site-settings--fixup-.patch new file mode 100644 index 00000000..7e431122 --- /dev/null +++ b/build/patches/00WIN-ADDTO-JIT-site-settings--fixup-.patch @@ -0,0 +1,22 @@ +From: Your Name +Date: Tue, 13 Jun 2023 15:52:08 +0000 +Subject: WIN ADDTO JIT site settings (fixup) + +--- + .../ui/webui/settings/settings_localized_strings_provider.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +--- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc ++++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +@@ -2534,7 +2534,7 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, + {"siteSettingsJavascriptJITBlocked", IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_JIT_BLOCKED}, + {"siteSettingsJavascriptJITAllowedExceptions",IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_JIT_ALLOWED_EXCEPTIONS}, + {"siteSettingsJavascriptJITBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_JIT_BLOCKED_EXCEPTIONS}, +- {"siteSettingsJavascriptJITMidSentence", IDS_SITE_SETTINGS_TYPE_JAVASCRIPT_JIT}, ++ {"siteSettingsJavascriptJITMidSentence", IDS_JAVASCRIPT_JIT_PERMISSION_TITLE}, + {"siteSettingsTimezoneOverride", IDS_SITE_SETTINGS_TIMEZONE_OVERRIDE_TITLE}, + {"siteSettingsTimezoneOverrideDescription", IDS_SETTINGS_SITE_SETTINGS_TIMEZONE_OVERRIDE_DESCRIPTION}, + {"siteSettingsTimezoneOverrideAllowed", IDS_SETTINGS_SITE_SETTINGS_TIMEZONE_OVERRIDE_ALLOWED}, +-- +2.25.1 diff --git a/build/patches/00WIN-ADDTO-JIT-site-settings.patch b/build/patches/00WIN-ADDTO-JIT-site-settings.patch index 6f2975d6..0e037611 100644 --- a/build/patches/00WIN-ADDTO-JIT-site-settings.patch +++ b/build/patches/00WIN-ADDTO-JIT-site-settings.patch @@ -23,7 +23,7 @@ Subject: WIN ADDTO JIT site settings diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp --- a/chrome/app/settings_strings.grdp +++ b/chrome/app/settings_strings.grdp -@@ -4348,6 +4348,25 @@ +@@ -4358,6 +4358,25 @@ Not allowed to autoplay @@ -213,10 +213,10 @@ diff --git a/chrome/browser/ui/views/page_info/page_info_view_factory.cc b/chrom diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc --- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc -@@ -2527,6 +2527,13 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, +@@ -2528,6 +2528,13 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, {"siteSettingsAutoplayAllowedExceptions",IDS_SETTINGS_SITE_SETTINGS_AUTOPLAY_ALLOWED_EXCEPTIONS}, {"siteSettingsAutoplayBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_AUTOPLAY_BLOCKED_EXCEPTIONS}, - {"siteSettingsAutoplayMidSentence", IDS_SITE_SETTINGS_TYPE_AUTOPLAY}, + {"siteSettingsAutoplayMidSentence", IDS_AUTOPLAY_PERMISSION_TITLE}, + {"siteSettingsJavascriptJIT", IDS_SITE_SETTINGS_JAVASCRIPT_JIT_TITLE}, + {"siteSettingsJavascriptJITDescription", IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_JIT_DESCRIPTION}, + {"siteSettingsJavascriptJITAllowed", IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_JIT_ALLOWED}, @@ -257,7 +257,7 @@ diff --git a/chrome/browser/ui/webui/settings/site_settings_helper.cc b/chrome/b 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 -@@ -511,7 +511,8 @@ void ContentSettingsRegistry::Init() { +@@ -518,7 +518,8 @@ void ContentSettingsRegistry::Init() { ContentSettingsInfo::EXCEPTIONS_ON_SECURE_ORIGINS_ONLY); Register(ContentSettingsType::JAVASCRIPT_JIT, "javascript-jit", diff --git a/build/patches/00WIN-ADDTO-Revert-the-removal-to-block-autoplay.patch b/build/patches/00WIN-ADDTO-Revert-the-removal-to-block-autoplay.patch index 5a191272..03a3ef64 100644 --- a/build/patches/00WIN-ADDTO-Revert-the-removal-to-block-autoplay.patch +++ b/build/patches/00WIN-ADDTO-Revert-the-removal-to-block-autoplay.patch @@ -22,7 +22,7 @@ Subject: WIN ADDTO Revert the removal to block autoplay diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp --- a/chrome/app/settings_strings.grdp +++ b/chrome/app/settings_strings.grdp -@@ -4329,6 +4329,25 @@ +@@ -4339,6 +4339,25 @@ Control how your browsing history is used to personalize Search and more @@ -212,7 +212,7 @@ diff --git a/chrome/browser/ui/views/page_info/page_info_view_factory.cc b/chrom diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc --- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc -@@ -2520,6 +2520,13 @@ void AddSearchEnginesStrings(content::WebUIDataSource* html_source) { +@@ -2521,6 +2521,13 @@ void AddSearchEnginesStrings(content::WebUIDataSource* html_source) { void AddSiteSettingsStrings(content::WebUIDataSource* html_source, Profile* profile) { static constexpr webui::LocalizedString kLocalizedStrings[] = { @@ -222,7 +222,7 @@ diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provide + {"siteSettingsAutoplayBlocked", IDS_SETTINGS_SITE_SETTINGS_AUTOPLAY_BLOCKED}, + {"siteSettingsAutoplayAllowedExceptions",IDS_SETTINGS_SITE_SETTINGS_AUTOPLAY_ALLOWED_EXCEPTIONS}, + {"siteSettingsAutoplayBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_AUTOPLAY_BLOCKED_EXCEPTIONS}, -+ {"siteSettingsAutoplayMidSentence", IDS_SITE_SETTINGS_TYPE_AUTOPLAY}, ++ {"siteSettingsAutoplayMidSentence", IDS_AUTOPLAY_PERMISSION_TITLE}, {"addSite", IDS_SETTINGS_ADD_SITE}, {"addSiteTitle", IDS_SETTINGS_ADD_SITE_TITLE}, #if BUILDFLAG(IS_CHROMEOS_ASH) diff --git a/build/patches/00WIN-ADDTO-Timezone-customization.patch b/build/patches/00WIN-ADDTO-Timezone-customization.patch index 6a1342a9..255771ca 100644 --- a/build/patches/00WIN-ADDTO-Timezone-customization.patch +++ b/build/patches/00WIN-ADDTO-Timezone-customization.patch @@ -23,7 +23,7 @@ Subject: WIN ADDTO Timezone customization diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp --- a/chrome/app/settings_strings.grdp +++ b/chrome/app/settings_strings.grdp -@@ -4367,6 +4367,25 @@ +@@ -4377,6 +4377,25 @@ Not allowed to Javascript JIT @@ -213,7 +213,7 @@ diff --git a/chrome/browser/ui/views/page_info/page_info_view_factory.cc b/chrom diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc --- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc -@@ -2534,6 +2534,13 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, +@@ -2535,6 +2535,13 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, {"siteSettingsJavascriptJITAllowedExceptions",IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_JIT_ALLOWED_EXCEPTIONS}, {"siteSettingsJavascriptJITBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_JIT_BLOCKED_EXCEPTIONS}, {"siteSettingsJavascriptJITMidSentence", IDS_SITE_SETTINGS_TYPE_JAVASCRIPT_JIT}, @@ -241,14 +241,14 @@ diff --git a/chrome/browser/ui/webui/settings/site_settings_helper.cc b/chrome/b 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 -@@ -566,7 +566,7 @@ void ContentSettingsRegistry::Init() { +@@ -577,7 +577,7 @@ void ContentSettingsRegistry::Init() { CONTENT_SETTING_ASK, // custom timezone, default UTC CONTENT_SETTING_BLOCK}, // random WebsiteSettingsInfo::TOP_ORIGIN_ONLY_SCOPE, - WebsiteSettingsRegistry::PLATFORM_ANDROID, + WebsiteSettingsRegistry::ALL_PLATFORMS, ContentSettingsInfo::INHERIT_IN_INCOGNITO, - ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); - + ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS, + /*show_into_info_page*/ false, -- 2.25.1 diff --git a/build/patches/00bromite-build-utils.patch b/build/patches/00bromite-build-utils.patch new file mode 100644 index 00000000..dffe6826 --- /dev/null +++ b/build/patches/00bromite-build-utils.patch @@ -0,0 +1,453 @@ +From: Your Name +Date: Fri, 9 Jun 2023 15:11:46 +0000 +Subject: bromite build utils + +--- + build/android/gyp/java_cpp_enum.py | 36 ++++++-- + build/android/gyp/util/build_utils.py | 25 +++++- + build/bromite/bromite_utils.gni | 68 +++++++++++++++ + build/bromite/gyp/cpp_bromite_include.py | 35 ++++++++ + build/bromite/gyp/cpp_bromite_include.pydeps | 9 ++ + build/bromite/gyp/java_bromite_impl.py | 92 ++++++++++++++++++++ + build/bromite/gyp/java_bromite_impl.pydeps | 9 ++ + build/config/BUILDCONFIG.gn | 1 + + build/config/android/rules.gni | 4 + + tools/grit/grit/grd_reader.py | 27 ++++-- + 10 files changed, 294 insertions(+), 12 deletions(-) + create mode 100644 build/bromite/bromite_utils.gni + create mode 100644 build/bromite/gyp/cpp_bromite_include.py + create mode 100644 build/bromite/gyp/cpp_bromite_include.pydeps + create mode 100644 build/bromite/gyp/java_bromite_impl.py + create mode 100644 build/bromite/gyp/java_bromite_impl.pydeps + +diff --git a/build/android/gyp/java_cpp_enum.py b/build/android/gyp/java_cpp_enum.py +--- a/build/android/gyp/java_cpp_enum.py ++++ b/build/android/gyp/java_cpp_enum.py +@@ -173,6 +173,7 @@ class DirectiveSet: + + + class HeaderParser: ++ include_re = re.compile(r'#include "(.*)"') + single_line_comment_re = re.compile(r'\s*//\s*([^\n]*)') + multi_line_comment_start_re = re.compile(r'\s*/\*') + enum_line_re = re.compile(r'^\s*(\w+)(\s*\=\s*([^,\n]+))?,?') +@@ -194,7 +195,7 @@ class HeaderParser: + enum_single_line_re = re.compile( + r'^\s*(?:\[cpp.*\])?\s*enum.*{(?P.*)}.*$') + +- def __init__(self, lines, path=''): ++ def __init__(self, lines, options, path=''): + self._lines = lines + self._path = path + self._enum_definitions = [] +@@ -204,6 +205,7 @@ class HeaderParser: + self._generator_directives = DirectiveSet() + self._multi_line_generator_directive = None + self._current_enum_entry = '' ++ self._options = options + + def _ApplyGeneratorDirectives(self): + self._generator_directives.UpdateDefinition(self._current_definition) +@@ -227,6 +229,24 @@ class HeaderParser: + raise Exception('Multi-line comments in enums are not supported in ' + + self._path) + ++ # handles the management of #include files ++ include_line = HeaderParser.include_re.match(line) ++ if include_line: ++ include_file = include_line.groups()[0]; ++ if not include_file.endswith(".inc"): ++ raise Exception('Include file \"' + include_file + '\" must ends with .inc') ++ ++ file_to_include = os.path.join(self._options.gen_dir, include_file) ++ if not os.path.exists(file_to_include): ++ file_to_include = os.path.join(self._options.root_dir, include_file) ++ lines = [] ++ with open(file_to_include) as include_file_handle: ++ lines = include_file_handle.readlines() ++ ++ for new_line in lines: ++ self._ParseEnumLine(new_line) ++ return ++ + enum_comment = HeaderParser.single_line_comment_re.match(line) + if enum_comment: + comment = enum_comment.groups()[0] +@@ -327,9 +347,9 @@ class HeaderParser: + self._ParseSingleLineEnum(single_line_enum.group('enum_entries')) + + +-def DoGenerate(source_paths): ++def DoGenerate(source_paths, options): + for source_path in source_paths: +- enum_definitions = DoParseHeaderFile(source_path) ++ enum_definitions = DoParseHeaderFile(source_path, options) + if not enum_definitions: + raise Exception('No enums found in %s\n' + 'Did you forget prefixing enums with ' +@@ -342,9 +362,9 @@ def DoGenerate(source_paths): + yield output_path, output + + +-def DoParseHeaderFile(path): ++def DoParseHeaderFile(path, options): + with open(path) as f: +- return HeaderParser(f.readlines(), path).ParseDefinitions() ++ return HeaderParser(f.readlines(), options, path).ParseDefinitions() + + + def GenerateOutput(source_path, enum_definition): +@@ -423,6 +443,10 @@ def DoMain(argv): + parser.add_option('--srcjar', + help='When specified, a .srcjar at the given path is ' + 'created instead of individual .java files.') ++ parser.add_option('--gen_dir', ++ help='Indicates the path to the generated file') ++ parser.add_option('--root_dir', ++ help='Indicates the path to the build root') + + options, args = parser.parse_args(argv) + +@@ -432,7 +456,7 @@ def DoMain(argv): + + with action_helpers.atomic_output(options.srcjar) as f: + with zipfile.ZipFile(f, 'w', zipfile.ZIP_STORED) as srcjar: +- for output_path, data in DoGenerate(input_paths): ++ for output_path, data in DoGenerate(input_paths, options): + zip_helpers.add_to_zip_hermetic(srcjar, output_path, data=data) + + +diff --git a/build/android/gyp/util/build_utils.py b/build/android/gyp/util/build_utils.py +--- a/build/android/gyp/util/build_utils.py ++++ b/build/android/gyp/util/build_utils.py +@@ -485,4 +485,27 @@ def ReadSourcesList(sources_list_file_name): + Note that this function should not be used to parse response files. + """ + with open(sources_list_file_name) as f: +- return [file_name.strip() for file_name in f] ++ files = [file_name.strip() for file_name in f] ++ # allows inclusion of all files in the indicated folder ++ # in the sources of java-related gn targets. ++ # "include_all_directory.java" is a special name and must exist in the ++ # folder since gn checks for its existence, but it will not be ++ # included in the list. ++ # example: ++ # ++ # sources += [ ++ # "java/src/org/chromium/components/browser_ui/site_settings/impl/include_all_directory.java", ++ # ] ++ # ++ # will include in source all files found in ++ # "java/src/org/chromium/components/browser_ui/site_settings/impl" ++ include_dirs = [f for f in files if f.endswith('include_all_directory.java')] ++ for include_file in include_dirs: ++ directory = os.path.dirname(include_file) ++ for root, dirs, directory_files in os.walk(directory): ++ for directory_file in directory_files: ++ files.append(os.path.join(directory, directory_file)) ++ files = [f for f in files if not f.endswith('include_all_directory.java') ++ and not f.endswith('.java.tmpl')] ++ ++ return files +diff --git a/build/bromite/bromite_utils.gni b/build/bromite/bromite_utils.gni +new file mode 100644 +--- /dev/null ++++ b/build/bromite/bromite_utils.gni +@@ -0,0 +1,68 @@ ++import("//build/config/python.gni") ++ ++# generates the file specified in ouput_file containing ++# the inclusion of all .inc files found in the folder ++# specified ++# ++# Parameters ++# directories (required) ++# A list of folders from which to extract the .inc files ++# ++# output_file (required) ++# The name of the include file to be generated ++# ++# Example ++# ++# cpp_bromite_include("bromite_content_settings") { ++# directories = [ "bromite_content_settings/placeholder.txt" ] ++# output_file = "bromite_content_settings.inc" ++# } ++# ++template("cpp_bromite_include") { ++ action_with_pydeps(target_name) { ++ forward_variables_from(invoker, ++ TESTONLY_AND_VISIBILITY + [ ++ "deps", ++ ]) ++ script = "//build/bromite/gyp/cpp_bromite_include.py" ++ ++ _rebased_directories = rebase_path(invoker.directories, root_build_dir) ++ _output = "$target_gen_dir/" + invoker.output_file ++ _output_rebased = rebase_path(_output) ++ ++ args = [ ++ "--output=$_output_rebased", ++ ] ++ args += _rebased_directories ++ ++ outputs = [ _output ] ++ } ++} ++ ++# allows the generation of the java file needed for ++# the inclusion of the defined site settings ++# in separate files ++# used by content settings patch ++template("java_bromite_impl") { ++ action_with_pydeps(target_name) { ++ forward_variables_from(invoker, ++ TESTONLY_AND_VISIBILITY + [ ++ "deps", ++ "inputs", ++ ]) ++ script = "//build/bromite/gyp/java_bromite_impl.py" ++ ++ _srcjar_path = "${target_gen_dir}/${target_name}.srcjar" ++ _rebased_srcjar_path = rebase_path(_srcjar_path, root_build_dir) ++ _rebased_directories = rebase_path(invoker.directories, root_build_dir) ++ _rebased_template = rebase_path(invoker.template, root_build_dir) ++ ++ args = [ ++ "--srcjar=$_rebased_srcjar_path", ++ "--template=$_rebased_template", ++ ] ++ args += _rebased_directories ++ ++ outputs = [ _srcjar_path ] ++ } ++} +diff --git a/build/bromite/gyp/cpp_bromite_include.py b/build/bromite/gyp/cpp_bromite_include.py +new file mode 100644 +--- /dev/null ++++ b/build/bromite/gyp/cpp_bromite_include.py +@@ -0,0 +1,35 @@ ++#!/usr/bin/env python3 ++ ++import argparse ++import os ++import re ++import sys ++ ++def _Main(argv): ++ parser = argparse.ArgumentParser() ++ ++ parser.add_argument('--output', ++ required=True, ++ help='The path at which to generate the .inc file') ++ ++ parser.add_argument( ++ 'inputs', nargs='+', help='Input folder(s)', metavar='INPUTFILE') ++ args = parser.parse_args(argv) ++ ++ for include_file in args.inputs: ++ directory = os.path.dirname(include_file) ++ files = [] ++ for root, dirs, directory_files in os.walk(directory): ++ for directory_file in directory_files: ++ files.append(os.path.join(directory, directory_file)) ++ ++ files = [f for f in files if f.endswith('.inc')] ++ ++ with open(args.output, 'w') as f: ++ for file in files: ++ f.write("#include \"" + file + "\"\n") ++ f.write("\n") ++ ++ ++if __name__ == '__main__': ++ _Main(sys.argv[1:]) +diff --git a/build/bromite/gyp/cpp_bromite_include.pydeps b/build/bromite/gyp/cpp_bromite_include.pydeps +new file mode 100644 +--- /dev/null ++++ b/build/bromite/gyp/cpp_bromite_include.pydeps +@@ -0,0 +1,9 @@ ++# Generated by running: ++# build/print_python_deps.py --root build/bromite/gyp --output build/bromite/gyp/cpp_bromite_include.pydeps build/bromite/gyp/cpp_bromite_include.py ++../../action_helpers.py ++../../android/gyp/util/__init__.py ++../../android/gyp/util/build_utils.py ++../../android/gyp/util/java_cpp_utils.py ++../../gn_helpers.py ++../../zip_helpers.py ++cpp_bromite_include.py +diff --git a/build/bromite/gyp/java_bromite_impl.py b/build/bromite/gyp/java_bromite_impl.py +new file mode 100644 +--- /dev/null ++++ b/build/bromite/gyp/java_bromite_impl.py +@@ -0,0 +1,92 @@ ++#!/usr/bin/env python3 ++ ++import argparse ++import os ++import re ++import sys ++import zipfile ++ ++sys.path.append('build/android/gyp') ++sys.path.append('../../build/android/gyp') ++ ++from util import build_utils ++from util import java_cpp_utils ++import action_helpers # build_utils adds //build to sys.path. ++import zip_helpers ++ ++def _GenerateOutput(template, source_paths, template_path, strings): ++ description_template = """ ++// This following string constants were inserted by ++// {SCRIPT_NAME} ++// Directory ++// {SOURCE_PATHS} ++// Template ++// {TEMPLATE_PATH} ++ ++""" ++ values = { ++ 'SCRIPT_NAME': java_cpp_utils.GetScriptName(), ++ 'SOURCE_PATHS': ',\n// '.join(source_paths), ++ 'TEMPLATE_PATH': template_path, ++ } ++ description = description_template.format(**values) ++ ++ import_clause = '\n'.join( ++ ['import org.chromium.components.browser_ui.site_settings.impl.' + f + ';' for f in strings]) ++ add_clause = '\n\t'.join(['\tadd(new ' + f + '());' for f in strings]) ++ ++ values = { ++ 'DESCRIPTION': description, ++ 'ADD_CLAUSE': add_clause, ++ 'IMPORT_CLAUSE': import_clause, ++ } ++ return template.format(**values) ++ ++ ++def _Generate(source_paths, template_path): ++ with open(template_path) as f: ++ lines = f.readlines() ++ ++ template = ''.join(lines) ++ package, class_name = java_cpp_utils.ParseTemplateFile(lines) ++ output_path = java_cpp_utils.GetJavaFilePath(package, class_name) ++ strings = [] ++ ++ for directory in source_paths: ++ for root, dirs, directory_files in os.walk(directory): ++ for directory_file in directory_files: ++ strings.append(directory_file) ++ ++ strings = [f.replace('.java', '') for f in strings ++ if not f.endswith('include_all_directory.java') and ++ not f.endswith('.java.tmpl') ] ++ ++ output = _GenerateOutput(template, source_paths, template_path, strings) ++ ++ return output, output_path ++ ++ ++def _Main(argv): ++ parser = argparse.ArgumentParser() ++ ++ parser.add_argument('--srcjar', ++ required=True, ++ help='The path at which to generate the .srcjar file') ++ ++ parser.add_argument('--template', ++ required=True, ++ help='The template file with which to generate the Java ' ++ 'class.') ++ ++ parser.add_argument( ++ 'inputs', nargs='+', help='Input folder(s)', metavar='INPUTFILE') ++ args = parser.parse_args(argv) ++ ++ with action_helpers.atomic_output(args.srcjar) as f: ++ with zipfile.ZipFile(f, 'w', zipfile.ZIP_STORED) as srcjar: ++ data, path = _Generate(args.inputs, args.template) ++ zip_helpers.add_to_zip_hermetic(srcjar, path, data=data) ++ ++ ++if __name__ == '__main__': ++ _Main(sys.argv[1:]) +diff --git a/build/bromite/gyp/java_bromite_impl.pydeps b/build/bromite/gyp/java_bromite_impl.pydeps +new file mode 100644 +--- /dev/null ++++ b/build/bromite/gyp/java_bromite_impl.pydeps +@@ -0,0 +1,9 @@ ++# Generated by running: ++# build/print_python_deps.py --root build/bromite/gyp --output build/bromite/gyp/java_bromite_impl.pydeps build/bromite/gyp/java_bromite_impl.py ++../../action_helpers.py ++../../android/gyp/util/__init__.py ++../../android/gyp/util/build_utils.py ++../../android/gyp/util/java_cpp_utils.py ++../../gn_helpers.py ++../../zip_helpers.py ++java_bromite_impl.py +diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn +--- a/build/config/BUILDCONFIG.gn ++++ b/build/config/BUILDCONFIG.gn +@@ -640,6 +640,7 @@ set_defaults("component") { + configs = default_component_configs + } + ++import("//build/bromite/bromite_utils.gni") + # ============================================================================= + # ACTION OVERRIDE + # ============================================================================= +diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni +--- a/build/config/android/rules.gni ++++ b/build/config/android/rules.gni +@@ -586,6 +586,10 @@ if (enable_java_templates && is_android) { + _rebased_sources = rebase_path(invoker.sources, root_build_dir) + + args = [ "--srcjar=$_rebased_srcjar_path" ] + _rebased_sources ++ _root_gen_dir = rebase_path(root_gen_dir) ++ _root_dir = rebase_path(root_build_dir) ++ args += [ "--gen_dir=$_root_gen_dir", ++ "--root_dir=$_root_dir" ] + outputs = [ _srcjar_path ] + } + } +diff --git a/tools/grit/grit/grd_reader.py b/tools/grit/grit/grd_reader.py +--- a/tools/grit/grit/grd_reader.py ++++ b/tools/grit/grit/grd_reader.py +@@ -93,11 +93,28 @@ class GrdContentHandler(xml.sax.handler.ContentHandler): + raise exception.FileNotFound(partname) + # Exceptions propagate to the handler in grd_reader.Parse(). + oldsource = self.source +- try: +- self.source = partname +- xml.sax.parse(partname, GrdPartContentHandler(self)) +- finally: +- self.source = oldsource ++ # modifies the behavior of ++ # ++ # allowing the inclusion of all grdp files found in the folder ++ # specified. ++ # the file value must end with "/placeholder.txt" ++ if partname.endswith("/placeholder.txt"): ++ partname = os.path.dirname(partname) ++ for root, dirs, files in os.walk(partname): ++ for file in files: ++ filepath = os.path.join(partname, file) ++ if filepath.endswith(".grdp"): ++ try: ++ self.source = partname ++ xml.sax.parse(filepath, GrdPartContentHandler(self)) ++ finally: ++ self.source = oldsource ++ else: ++ try: ++ self.source = partname ++ xml.sax.parse(partname, GrdPartContentHandler(self)) ++ finally: ++ self.source = oldsource + + if self.debug: + print("End parsing of element %s" % name) +-- +2.25.1 diff --git a/build/patches/Add-webGL-site-setting.patch b/build/patches/Add-webGL-site-setting.patch index d9530074..ee09d561 100644 --- a/build/patches/Add-webGL-site-setting.patch +++ b/build/patches/Add-webGL-site-setting.patch @@ -9,61 +9,25 @@ Requires patch: Content-settings-infrastructure.patch Original License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html --- - .../browser_ui/site_settings/android/BUILD.gn | 3 + - .../BromiteCustomContentSettingImpl.java | 1 + - .../BromiteWebGLContentSetting.java | 85 +++++++++++++++++++ - .../site_settings/SiteSettingsCategory.java | 5 +- - .../strings/android/browser_ui_strings.grd | 1 + - .../browser_ui/strings/android/webgl.grdp | 18 ++++ - components/components_strings.grd | 1 + - .../core/browser/content_settings_registry.cc | 13 +++ - .../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 ++ - .../core/common/content_settings_types.h | 2 + - .../renderer/content_settings_agent_impl.cc | 9 ++ - .../renderer/content_settings_agent_impl.h | 1 + - .../platform/web_content_settings_client.h | 2 + - .../execution_context/execution_context.cc | 23 +++++ - .../execution_context/execution_context.h | 5 ++ + .../impl/BromiteWebGLContentSetting.java | 87 +++++++++++++++++++ + .../bromite_content_settings/webgl.grdp | 18 ++++ + .../bromite_content_settings/webgl.inc | 13 +++ + .../common/bromite_content_settings/WEBGL.inc | 1 + + .../execution_context/execution_context.cc | 7 ++ + .../execution_context/execution_context.h | 2 + .../webgl/webgl_rendering_context_base.cc | 32 +++---- .../webgl/webgl_rendering_context_base.h | 2 + - 22 files changed, 196 insertions(+), 23 deletions(-) - create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteWebGLContentSetting.java - create mode 100644 components/browser_ui/strings/android/webgl.grdp + 8 files changed, 143 insertions(+), 19 deletions(-) + create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteWebGLContentSetting.java + create mode 100644 components/browser_ui/strings/android/bromite_content_settings/webgl.grdp + create mode 100644 components/content_settings/core/browser/bromite_content_settings/webgl.inc + create mode 100644 components/content_settings/core/common/bromite_content_settings/WEBGL.inc -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 -@@ -106,6 +106,9 @@ android_library("java") { - "java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSettingImpl.java", - "java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSetting.java", - ] -+ sources += [ -+ "java/src/org/chromium/components/browser_ui/site_settings/BromiteWebGLContentSetting.java", -+ ] - annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ] - resources_package = "org.chromium.components.browser_ui.site_settings" - deps = [ -diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSettingImpl.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSettingImpl.java ---- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSettingImpl.java -+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSettingImpl.java -@@ -43,6 +43,7 @@ public abstract class BromiteCustomContentSettingImpl { - - static { - mItemList = new ArrayList(); -+ mItemList.add(new BromiteWebGLContentSetting()); - } - - public static SiteSettingsCategory createFromType( -diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteWebGLContentSetting.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteWebGLContentSetting.java +diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteWebGLContentSetting.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteWebGLContentSetting.java new file mode 100644 --- /dev/null -+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteWebGLContentSetting.java -@@ -0,0 +1,85 @@ ++++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteWebGLContentSetting.java +@@ -0,0 +1,87 @@ +/* + This file is part of Bromite. + @@ -81,8 +45,11 @@ new file mode 100644 + along with Bromite. If not, see . +*/ + -+package org.chromium.components.browser_ui.site_settings; ++package org.chromium.components.browser_ui.site_settings.impl; + ++import org.chromium.components.browser_ui.site_settings.R; ++ ++import org.chromium.components.browser_ui.site_settings.BromiteCustomContentSetting; +import org.chromium.components.browser_ui.site_settings.ContentSettingsResources; +import org.chromium.components.browser_ui.site_settings.SiteSettingsCategory; +import org.chromium.components.content_settings.ContentSettingValues; @@ -98,7 +65,6 @@ new file mode 100644 +public class BromiteWebGLContentSetting extends BromiteCustomContentSetting { + public BromiteWebGLContentSetting() { + super(/*contentSettingsType*/ ContentSettingsType.WEBGL, -+ /*siteSettingsCategory*/ SiteSettingsCategory.Type.WEBGL, + /*defaultEnabledValue*/ ContentSettingValues.ALLOW, + /*defaultDisabledValue*/ ContentSettingValues.BLOCK, + /*allowException*/ true, @@ -149,46 +115,10 @@ new file mode 100644 + return value != ContentSettingValues.BLOCK; + } +} -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 -@@ -48,7 +48,7 @@ public class SiteSettingsCategory { - Type.USE_STORAGE, Type.AUTO_DARK_WEB_CONTENT, Type.REQUEST_DESKTOP_SITE, - Type.FEDERATED_IDENTITY_API, Type.THIRD_PARTY_COOKIES, Type.SITE_DATA, Type.ANTI_ABUSE, - Type.TIMEZONE_OVERRIDE, Type.AUTOPLAY, Type.JAVASCRIPT_JIT, Type.IMAGES, -- Type.NUM_ENTRIES}) -+ Type.NUM_ENTRIES, Type.WEBGL}) - @Retention(RetentionPolicy.SOURCE) - public @interface Type { - // All updates here must also be reflected in {@link #preferenceKey(int) -@@ -86,10 +86,11 @@ public class SiteSettingsCategory { - int AUTOPLAY = 30; - int JAVASCRIPT_JIT = 31; - int IMAGES = 32; -+ int WEBGL = 33; - /** - * Number of handled categories used for calculating array sizes. - */ -- int NUM_ENTRIES = 33; -+ int NUM_ENTRIES = 34; - } - - private final BrowserContextHandle mBrowserContextHandle; -diff --git a/components/browser_ui/strings/android/browser_ui_strings.grd b/components/browser_ui/strings/android/browser_ui_strings.grd ---- a/components/browser_ui/strings/android/browser_ui_strings.grd -+++ b/components/browser_ui/strings/android/browser_ui_strings.grd -@@ -174,6 +174,7 @@ - - - -+ - - - Got it -diff --git a/components/browser_ui/strings/android/webgl.grdp b/components/browser_ui/strings/android/webgl.grdp +diff --git a/components/browser_ui/strings/android/bromite_content_settings/webgl.grdp b/components/browser_ui/strings/android/bromite_content_settings/webgl.grdp new file mode 100644 --- /dev/null -+++ b/components/browser_ui/strings/android/webgl.grdp ++++ b/components/browser_ui/strings/android/bromite_content_settings/webgl.grdp @@ -0,0 +1,18 @@ + + @@ -208,202 +138,41 @@ new file mode 100644 + Disabled + + -diff --git a/components/components_strings.grd b/components/components_strings.grd ---- a/components/components_strings.grd -+++ b/components/components_strings.grd -@@ -336,6 +336,7 @@ - - - -+ - - - -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 -@@ -606,6 +606,19 @@ void ContentSettingsRegistry::Init() { - WebsiteSettingsRegistry::ALL_PLATFORMS, - ContentSettingsInfo::INHERIT_IN_INCOGNITO, - ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); -+ +diff --git a/components/content_settings/core/browser/bromite_content_settings/webgl.inc b/components/content_settings/core/browser/bromite_content_settings/webgl.inc +new file mode 100644 +--- /dev/null ++++ b/components/content_settings/core/browser/bromite_content_settings/webgl.inc +@@ -0,0 +1,13 @@ + Register(ContentSettingsType::WEBGL, "webgl", CONTENT_SETTING_BLOCK, + WebsiteSettingsInfo::SYNCABLE, + /*allowlisted_schemes=*/{}, + /*valid_settings=*/{CONTENT_SETTING_ALLOW, + CONTENT_SETTING_BLOCK}, + WebsiteSettingsInfo::TOP_ORIGIN_ONLY_SCOPE, -+ WebsiteSettingsRegistry::PLATFORM_ANDROID, ++ WebsiteSettingsRegistry::ALL_PLATFORMS, + ContentSettingsInfo::INHERIT_IN_INCOGNITO, + ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS, + /*show_into_info_page*/ true, ++ /*is_renderer_content_setting*/ true, + /*permission_type_ui*/ IDS_SITE_SETTINGS_TYPE_WEBGL, + /*permission_type_ui_mid_sentence*/ IDS_SITE_SETTINGS_TYPE_WEBGL_MID_SENTENCE); - } - - void ContentSettingsRegistry::Register( -diff --git a/components/content_settings/core/browser/content_settings_utils.cc b/components/content_settings/core/browser/content_settings_utils.cc ---- a/components/content_settings/core/browser/content_settings_utils.cc -+++ b/components/content_settings/core/browser/content_settings_utils.cc -@@ -158,6 +158,8 @@ void GetRendererContentSettingRules(const HostContentSettingsMap* map, - std::string timezone; - map->GetTimezoneOverrideValue(timezone); - rules->timezone_override_value = timezone; -+ map->GetSettingsForOneType(ContentSettingsType::WEBGL, -+ &(rules->webgl_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 ---- a/components/content_settings/core/common/content_settings.cc -+++ b/components/content_settings/core/common/content_settings.cc -@@ -218,7 +218,8 @@ bool RendererContentSettingRules::IsRendererContentSetting( - content_type == ContentSettingsType::AUTOPLAY || - content_type == ContentSettingsType::MIXEDSCRIPT || - content_type == ContentSettingsType::AUTO_DARK_WEB_CONTENT || -- content_type == ContentSettingsType::TIMEZONE_OVERRIDE; -+ content_type == ContentSettingsType::TIMEZONE_OVERRIDE || -+ content_type == ContentSettingsType::WEBGL; - } - - void RendererContentSettingRules::FilterRulesByOutermostMainFrameURL( -@@ -230,6 +231,7 @@ void RendererContentSettingRules::FilterRulesByOutermostMainFrameURL( - FilterRulesForType(auto_dark_content_rules, outermost_main_frame_url); - FilterRulesForType(timezone_override_rules, outermost_main_frame_url); - FilterRulesForType(autoplay_rules, outermost_main_frame_url); -+ FilterRulesForType(webgl_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 ---- a/components/content_settings/core/common/content_settings.h -+++ b/components/content_settings/core/common/content_settings.h -@@ -96,6 +96,7 @@ struct RendererContentSettingRules { - ContentSettingsForOneType auto_dark_content_rules; - ContentSettingsForOneType timezone_override_rules; - std::string timezone_override_value; -+ ContentSettingsForOneType webgl_rules; - }; - - namespace content_settings { -diff --git a/components/content_settings/core/common/content_settings.mojom b/components/content_settings/core/common/content_settings.mojom ---- a/components/content_settings/core/common/content_settings.mojom -+++ b/components/content_settings/core/common/content_settings.mojom -@@ -81,4 +81,5 @@ struct RendererContentSettingRules { - array auto_dark_content_rules; - array timezone_override_rules; - string timezone_override_value; -+ array webgl_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 ---- a/components/content_settings/core/common/content_settings_mojom_traits.cc -+++ b/components/content_settings/core/common/content_settings_mojom_traits.cc -@@ -105,7 +105,8 @@ bool StructTraitsmixed_content_rules) && - data.ReadAutoDarkContentRules(&out->auto_dark_content_rules) && - data.ReadTimezoneOverrideRules(&out->timezone_override_rules) && -- data.ReadTimezoneOverrideValue(&out->timezone_override_value); -+ data.ReadTimezoneOverrideValue(&out->timezone_override_value) && -+ data.ReadWebglRules(&out->webgl_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 ---- a/components/content_settings/core/common/content_settings_mojom_traits.h -+++ b/components/content_settings/core/common/content_settings_mojom_traits.h -@@ -165,6 +165,11 @@ struct StructTraits< - return r.timezone_override_value; - } - -+ static const std::vector& webgl_rules( -+ const RendererContentSettingRules& r) { -+ return r.webgl_rules; -+ } -+ - static bool Read( - content_settings::mojom::RendererContentSettingRulesDataView data, - RendererContentSettingRules* out); -diff --git a/components/content_settings/core/common/content_settings_types.h b/components/content_settings/core/common/content_settings_types.h ---- a/components/content_settings/core/common/content_settings_types.h -+++ b/components/content_settings/core/common/content_settings_types.h -@@ -277,6 +277,8 @@ enum class ContentSettingsType : int32_t { - // site instead of the mobile one. - REQUEST_DESKTOP_SITE, - +diff --git a/components/content_settings/core/common/bromite_content_settings/WEBGL.inc b/components/content_settings/core/common/bromite_content_settings/WEBGL.inc +new file mode 100644 +--- /dev/null ++++ b/components/content_settings/core/common/bromite_content_settings/WEBGL.inc +@@ -0,0 +1 @@ + WEBGL, -+ - // Setting to indicate whether browser should allow signing into a website via - // the browser FedCM API. - FEDERATED_IDENTITY_API, -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 -@@ -441,6 +441,15 @@ void ContentSettingsAgentImpl::ClearBlockedContentSettings() { - cached_script_permissions_.clear(); - } - -+bool ContentSettingsAgentImpl::AllowWebgl(bool enabled_per_settings) { -+ if (!content_setting_rules_) -+ return false; -+ blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); -+ return CONTENT_SETTING_ALLOW == GetContentSettingFromRules( -+ content_setting_rules_->webgl_rules, -+ url::Origin(frame->GetDocument().GetSecurityOrigin()).GetURL()); -+} -+ - bool ContentSettingsAgentImpl::IsAllowlistedForContentSettings() const { - if (should_allowlist_) - return true; -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 -@@ -99,6 +99,7 @@ class ContentSettingsAgentImpl - bool AllowAutoplay(bool default_value) override; - bool AllowPopupsAndRedirects(bool default_value) override; - bool ShouldAutoupgradeMixedContent() override; -+ bool AllowWebgl(bool enabled_per_settings) override; - - bool allow_running_insecure_content() const { - return allow_running_insecure_content_; -diff --git a/third_party/blink/public/platform/web_content_settings_client.h b/third_party/blink/public/platform/web_content_settings_client.h ---- a/third_party/blink/public/platform/web_content_settings_client.h -+++ b/third_party/blink/public/platform/web_content_settings_client.h -@@ -99,6 +99,8 @@ class WebContentSettingsClient { - return default_value; - } - -+ virtual bool AllowWebgl(bool default_value) { return default_value; } -+ - // Reports that passive mixed content was found at the provided URL. - virtual void PassiveInsecureContentFound(const WebURL&) {} - diff --git a/third_party/blink/renderer/core/execution_context/execution_context.cc b/third_party/blink/renderer/core/execution_context/execution_context.cc --- a/third_party/blink/renderer/core/execution_context/execution_context.cc +++ b/third_party/blink/renderer/core/execution_context/execution_context.cc -@@ -68,6 +68,29 @@ +@@ -84,6 +84,13 @@ blink::WebContentSettingsClient* GetContentSettingsClientFor( + return settings; + } - namespace blink { - -+blink::WebContentSettingsClient* GetContentSettingsClientFor( -+ ExecutionContext* context) { -+ blink::WebContentSettingsClient* settings = nullptr; -+ if (!context) -+ return settings; -+ if (auto* window = blink::DynamicTo(context)) { -+ auto* frame = window->GetFrame(); -+ if (frame) -+ settings = frame->GetContentSettingsClient(); -+ } else if (context->IsWorkerGlobalScope()) { -+ settings = -+ blink::To(context)->ContentSettingsClient(); -+ } -+ return settings; -+} -+ +bool AllowWebgl(ExecutionContext* context) { + blink::WebContentSettingsClient* settings = GetContentSettingsClientFor(context); + if (settings) -+ return settings->AllowWebgl(false); ++ return settings->AllowContentSetting(ContentSettingsType::WEBGL, false); + return false; +} + @@ -413,21 +182,11 @@ diff --git a/third_party/blink/renderer/core/execution_context/execution_context diff --git a/third_party/blink/renderer/core/execution_context/execution_context.h b/third_party/blink/renderer/core/execution_context/execution_context.h --- a/third_party/blink/renderer/core/execution_context/execution_context.h +++ b/third_party/blink/renderer/core/execution_context/execution_context.h -@@ -103,6 +103,7 @@ class SecurityOrigin; - class ScriptState; - class ScriptWrappable; - class TrustedTypePolicyFactory; -+class WebContentSettingsClient; - - enum ReasonForCallingCanExecuteScripts { - kAboutToExecuteScript, -@@ -111,6 +112,10 @@ enum ReasonForCallingCanExecuteScripts { +@@ -117,6 +117,8 @@ enum ReasonForCallingCanExecuteScripts { enum ReferrerPolicySource { kPolicySourceHttpHeader, kPolicySourceMetaTag }; +CORE_EXPORT bool AllowWebgl(ExecutionContext* context); -+CORE_EXPORT WebContentSettingsClient* GetContentSettingsClientFor( -+ ExecutionContext* context); + // An environment in which script can execute. This class exposes the common // properties of script execution environments on the web (i.e, common between diff --git a/build/patches/Add-webRTC-site-settings.patch b/build/patches/Add-webRTC-site-settings.patch index 63d8a2d2..94d95b69 100644 --- a/build/patches/Add-webRTC-site-settings.patch +++ b/build/patches/Add-webRTC-site-settings.patch @@ -7,58 +7,24 @@ Requires patch: Content-settings-infrastructure.patch Original License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html --- - .../browser_ui/site_settings/android/BUILD.gn | 3 + - .../BromiteCustomContentSettingImpl.java | 1 + - .../BromiteWebRTCContentSetting.java | 86 +++++++++++++++++++ - .../site_settings/SiteSettingsCategory.java | 5 +- - .../strings/android/browser_ui_strings.grd | 1 + - .../browser_ui/strings/android/webrtc.grdp | 18 ++++ - components/components_strings.grd | 1 + - .../core/browser/content_settings_registry.cc | 13 +++ - .../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 ++ - .../core/common/content_settings_types.h | 2 + - .../renderer/content_settings_agent_impl.cc | 9 ++ - .../renderer/content_settings_agent_impl.h | 1 + - .../platform/web_content_settings_client.h | 2 + + .../impl/BromiteWebRTCContentSetting.java | 88 +++++++++++++++++++ + .../bromite_content_settings/webrtc.grdp | 18 ++++ + .../bromite_content_settings/webrtc.inc | 13 +++ + .../bromite_content_settings/WEBRTC.inc | 1 + .../peer_connection_dependency_factory.cc | 6 ++ - 19 files changed, 160 insertions(+), 4 deletions(-) - create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteWebRTCContentSetting.java - create mode 100644 components/browser_ui/strings/android/webrtc.grdp + .../peerconnection/rtc_rtp_receiver.cc | 10 +++ + .../modules/peerconnection/rtc_rtp_sender.cc | 10 +++ + 7 files changed, 146 insertions(+) + create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteWebRTCContentSetting.java + create mode 100644 components/browser_ui/strings/android/bromite_content_settings/webrtc.grdp + create mode 100644 components/content_settings/core/browser/bromite_content_settings/webrtc.inc + create mode 100644 components/content_settings/core/common/bromite_content_settings/WEBRTC.inc -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 -@@ -109,6 +109,9 @@ android_library("java") { - sources += [ - "java/src/org/chromium/components/browser_ui/site_settings/BromiteWebGLContentSetting.java", - ] -+ sources += [ -+ "java/src/org/chromium/components/browser_ui/site_settings/BromiteWebRTCContentSetting.java", -+ ] - annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ] - resources_package = "org.chromium.components.browser_ui.site_settings" - deps = [ -diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSettingImpl.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSettingImpl.java ---- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSettingImpl.java -+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSettingImpl.java -@@ -44,6 +44,7 @@ public abstract class BromiteCustomContentSettingImpl { - static { - mItemList = new ArrayList(); - mItemList.add(new BromiteWebGLContentSetting()); -+ mItemList.add(new BromiteWebRTCContentSetting()); - } - - public static SiteSettingsCategory createFromType( -diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteWebRTCContentSetting.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteWebRTCContentSetting.java +diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteWebRTCContentSetting.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteWebRTCContentSetting.java new file mode 100644 --- /dev/null -+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteWebRTCContentSetting.java -@@ -0,0 +1,86 @@ ++++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteWebRTCContentSetting.java +@@ -0,0 +1,88 @@ +/* + This file is part of Bromite. + @@ -76,8 +42,11 @@ new file mode 100644 + along with Bromite. If not, see . +*/ + -+package org.chromium.components.browser_ui.site_settings; ++package org.chromium.components.browser_ui.site_settings.impl; + ++import org.chromium.components.browser_ui.site_settings.R; ++ ++import org.chromium.components.browser_ui.site_settings.BromiteCustomContentSetting; +import org.chromium.components.browser_ui.site_settings.ContentSettingsResources; +import org.chromium.components.browser_ui.site_settings.SiteSettingsCategory; +import org.chromium.components.content_settings.ContentSettingValues; @@ -93,7 +62,6 @@ new file mode 100644 +public class BromiteWebRTCContentSetting extends BromiteCustomContentSetting { + public BromiteWebRTCContentSetting() { + super(/*contentSettingsType*/ ContentSettingsType.WEBRTC, -+ /*siteSettingsCategory*/ SiteSettingsCategory.Type.WEBRTC, + /*defaultEnabledValue*/ ContentSettingValues.ALLOW, + /*defaultDisabledValue*/ ContentSettingValues.BLOCK, + /*allowException*/ true, @@ -145,46 +113,10 @@ new file mode 100644 + return value != ContentSettingValues.BLOCK; + } +} -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 -@@ -48,7 +48,7 @@ public class SiteSettingsCategory { - Type.USE_STORAGE, Type.AUTO_DARK_WEB_CONTENT, Type.REQUEST_DESKTOP_SITE, - Type.FEDERATED_IDENTITY_API, Type.THIRD_PARTY_COOKIES, Type.SITE_DATA, Type.ANTI_ABUSE, - Type.TIMEZONE_OVERRIDE, Type.AUTOPLAY, Type.JAVASCRIPT_JIT, Type.IMAGES, -- Type.NUM_ENTRIES, Type.WEBGL}) -+ Type.NUM_ENTRIES, Type.WEBGL, Type.WEBRTC}) - @Retention(RetentionPolicy.SOURCE) - public @interface Type { - // All updates here must also be reflected in {@link #preferenceKey(int) -@@ -87,10 +87,11 @@ public class SiteSettingsCategory { - int JAVASCRIPT_JIT = 31; - int IMAGES = 32; - int WEBGL = 33; -+ int WEBRTC = 34; - /** - * Number of handled categories used for calculating array sizes. - */ -- int NUM_ENTRIES = 34; -+ int NUM_ENTRIES = 35; - } - - private final BrowserContextHandle mBrowserContextHandle; -diff --git a/components/browser_ui/strings/android/browser_ui_strings.grd b/components/browser_ui/strings/android/browser_ui_strings.grd ---- a/components/browser_ui/strings/android/browser_ui_strings.grd -+++ b/components/browser_ui/strings/android/browser_ui_strings.grd -@@ -175,6 +175,7 @@ - - - -+ - - - Got it -diff --git a/components/browser_ui/strings/android/webrtc.grdp b/components/browser_ui/strings/android/webrtc.grdp +diff --git a/components/browser_ui/strings/android/bromite_content_settings/webrtc.grdp b/components/browser_ui/strings/android/bromite_content_settings/webrtc.grdp new file mode 100644 --- /dev/null -+++ b/components/browser_ui/strings/android/webrtc.grdp ++++ b/components/browser_ui/strings/android/bromite_content_settings/webrtc.grdp @@ -0,0 +1,18 @@ + + @@ -204,175 +136,30 @@ new file mode 100644 + Disabled + + -diff --git a/components/components_strings.grd b/components/components_strings.grd ---- a/components/components_strings.grd -+++ b/components/components_strings.grd -@@ -337,6 +337,7 @@ - - - -+ - - - -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 -@@ -619,6 +619,19 @@ void ContentSettingsRegistry::Init() { - /*show_into_info_page*/ true, - /*permission_type_ui*/ IDS_SITE_SETTINGS_TYPE_WEBGL, - /*permission_type_ui_mid_sentence*/ IDS_SITE_SETTINGS_TYPE_WEBGL_MID_SENTENCE); -+ +diff --git a/components/content_settings/core/browser/bromite_content_settings/webrtc.inc b/components/content_settings/core/browser/bromite_content_settings/webrtc.inc +new file mode 100644 +--- /dev/null ++++ b/components/content_settings/core/browser/bromite_content_settings/webrtc.inc +@@ -0,0 +1,13 @@ + Register(ContentSettingsType::WEBRTC, "webrtc", CONTENT_SETTING_BLOCK, + WebsiteSettingsInfo::SYNCABLE, + /*allowlisted_schemes=*/{}, + /*valid_settings=*/{CONTENT_SETTING_ALLOW, + CONTENT_SETTING_BLOCK}, + WebsiteSettingsInfo::TOP_ORIGIN_ONLY_SCOPE, -+ WebsiteSettingsRegistry::PLATFORM_ANDROID, ++ WebsiteSettingsRegistry::ALL_PLATFORMS, + ContentSettingsInfo::INHERIT_IN_INCOGNITO, + ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS, + /*show_into_info_page*/ true, ++ /*is_renderer_content_setting*/ true, + /*permission_type_ui*/ IDS_SITE_SETTINGS_TYPE_WEBRTC, + /*permission_type_ui_mid_sentence*/ IDS_SITE_SETTINGS_TYPE_WEBRTC_MID_SENTENCE); - } - - void ContentSettingsRegistry::Register( -diff --git a/components/content_settings/core/browser/content_settings_utils.cc b/components/content_settings/core/browser/content_settings_utils.cc ---- a/components/content_settings/core/browser/content_settings_utils.cc -+++ b/components/content_settings/core/browser/content_settings_utils.cc -@@ -160,6 +160,8 @@ void GetRendererContentSettingRules(const HostContentSettingsMap* map, - rules->timezone_override_value = timezone; - map->GetSettingsForOneType(ContentSettingsType::WEBGL, - &(rules->webgl_rules)); -+ map->GetSettingsForOneType(ContentSettingsType::WEBRTC, -+ &(rules->webrtc_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 ---- a/components/content_settings/core/common/content_settings.cc -+++ b/components/content_settings/core/common/content_settings.cc -@@ -219,7 +219,8 @@ bool RendererContentSettingRules::IsRendererContentSetting( - content_type == ContentSettingsType::MIXEDSCRIPT || - content_type == ContentSettingsType::AUTO_DARK_WEB_CONTENT || - content_type == ContentSettingsType::TIMEZONE_OVERRIDE || -- content_type == ContentSettingsType::WEBGL; -+ content_type == ContentSettingsType::WEBGL || -+ content_type == ContentSettingsType::WEBRTC; - } - - void RendererContentSettingRules::FilterRulesByOutermostMainFrameURL( -@@ -232,6 +233,7 @@ void RendererContentSettingRules::FilterRulesByOutermostMainFrameURL( - FilterRulesForType(timezone_override_rules, outermost_main_frame_url); - FilterRulesForType(autoplay_rules, outermost_main_frame_url); - FilterRulesForType(webgl_rules, outermost_main_frame_url); -+ FilterRulesForType(webrtc_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 ---- a/components/content_settings/core/common/content_settings.h -+++ b/components/content_settings/core/common/content_settings.h -@@ -97,6 +97,7 @@ struct RendererContentSettingRules { - ContentSettingsForOneType timezone_override_rules; - std::string timezone_override_value; - ContentSettingsForOneType webgl_rules; -+ ContentSettingsForOneType webrtc_rules; - }; - - namespace content_settings { -diff --git a/components/content_settings/core/common/content_settings.mojom b/components/content_settings/core/common/content_settings.mojom ---- a/components/content_settings/core/common/content_settings.mojom -+++ b/components/content_settings/core/common/content_settings.mojom -@@ -82,4 +82,5 @@ struct RendererContentSettingRules { - array timezone_override_rules; - string timezone_override_value; - array webgl_rules; -+ array webrtc_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 ---- a/components/content_settings/core/common/content_settings_mojom_traits.cc -+++ b/components/content_settings/core/common/content_settings_mojom_traits.cc -@@ -106,7 +106,8 @@ bool StructTraitsauto_dark_content_rules) && - data.ReadTimezoneOverrideRules(&out->timezone_override_rules) && - data.ReadTimezoneOverrideValue(&out->timezone_override_value) && -- data.ReadWebglRules(&out->webgl_rules); -+ data.ReadWebglRules(&out->webgl_rules) && -+ data.ReadWebrtcRules(&out->webrtc_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 ---- a/components/content_settings/core/common/content_settings_mojom_traits.h -+++ b/components/content_settings/core/common/content_settings_mojom_traits.h -@@ -170,6 +170,11 @@ struct StructTraits< - return r.webgl_rules; - } - -+ static const std::vector& webrtc_rules( -+ const RendererContentSettingRules& r) { -+ return r.webrtc_rules; -+ } -+ - static bool Read( - content_settings::mojom::RendererContentSettingRulesDataView data, - RendererContentSettingRules* out); -diff --git a/components/content_settings/core/common/content_settings_types.h b/components/content_settings/core/common/content_settings_types.h ---- a/components/content_settings/core/common/content_settings_types.h -+++ b/components/content_settings/core/common/content_settings_types.h -@@ -279,6 +279,8 @@ enum class ContentSettingsType : int32_t { - - WEBGL, - +diff --git a/components/content_settings/core/common/bromite_content_settings/WEBRTC.inc b/components/content_settings/core/common/bromite_content_settings/WEBRTC.inc +new file mode 100644 +--- /dev/null ++++ b/components/content_settings/core/common/bromite_content_settings/WEBRTC.inc +@@ -0,0 +1 @@ + WEBRTC, -+ - // Setting to indicate whether browser should allow signing into a website via - // the browser FedCM API. - FEDERATED_IDENTITY_API, -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 -@@ -450,6 +450,15 @@ bool ContentSettingsAgentImpl::AllowWebgl(bool enabled_per_settings) { - url::Origin(frame->GetDocument().GetSecurityOrigin()).GetURL()); - } - -+bool ContentSettingsAgentImpl::AllowWebRTC(bool enabled_per_settings) { -+ if (!content_setting_rules_) -+ return false; -+ blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); -+ return CONTENT_SETTING_ALLOW == GetContentSettingFromRules( -+ content_setting_rules_->webrtc_rules, -+ url::Origin(frame->GetDocument().GetSecurityOrigin()).GetURL()); -+} -+ - bool ContentSettingsAgentImpl::IsAllowlistedForContentSettings() const { - if (should_allowlist_) - return true; -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 -@@ -100,6 +100,7 @@ class ContentSettingsAgentImpl - bool AllowPopupsAndRedirects(bool default_value) override; - bool ShouldAutoupgradeMixedContent() override; - bool AllowWebgl(bool enabled_per_settings) override; -+ bool AllowWebRTC(bool enabled_per_settings) override; - - bool allow_running_insecure_content() const { - return allow_running_insecure_content_; -diff --git a/third_party/blink/public/platform/web_content_settings_client.h b/third_party/blink/public/platform/web_content_settings_client.h ---- a/third_party/blink/public/platform/web_content_settings_client.h -+++ b/third_party/blink/public/platform/web_content_settings_client.h -@@ -101,6 +101,8 @@ class WebContentSettingsClient { - - virtual bool AllowWebgl(bool default_value) { return default_value; } - -+ virtual bool AllowWebRTC(bool default_value) { return default_value; } -+ - // Reports that passive mixed content was found at the provided URL. - virtual void PassiveInsecureContentFound(const WebURL&) {} - diff --git a/third_party/blink/renderer/modules/peerconnection/peer_connection_dependency_factory.cc b/third_party/blink/renderer/modules/peerconnection/peer_connection_dependency_factory.cc --- a/third_party/blink/renderer/modules/peerconnection/peer_connection_dependency_factory.cc +++ b/third_party/blink/renderer/modules/peerconnection/peer_connection_dependency_factory.cc @@ -384,17 +171,71 @@ diff --git a/third_party/blink/renderer/modules/peerconnection/peer_connection_d #include "third_party/blink/public/platform/web_url.h" #include "third_party/blink/public/web/modules/mediastream/media_stream_video_source.h" #include "third_party/blink/public/web/web_document.h" -@@ -750,6 +751,11 @@ PeerConnectionDependencyFactory::CreatePortAllocator( +@@ -752,6 +753,11 @@ PeerConnectionDependencyFactory::CreatePortAllocator( // origin. WebRTCIPHandlingPolicy policy = GetWebRTCIPHandlingPolicy(webrtc_ip_handling_policy); + blink::WebContentSettingsClient* settings = web_frame->GetContentSettingsClient(); -+ if (settings && settings->AllowWebRTC(false)) { ++ if (settings && settings->AllowContentSetting(ContentSettingsType::WEBRTC, false)) { + policy = kDefault; + } + switch (policy) { // TODO(guoweis): specify the flag of disabling local candidate // collection when webrtc is updated. +diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_rtp_receiver.cc b/third_party/blink/renderer/modules/peerconnection/rtc_rtp_receiver.cc +--- a/third_party/blink/renderer/modules/peerconnection/rtc_rtp_receiver.cc ++++ b/third_party/blink/renderer/modules/peerconnection/rtc_rtp_receiver.cc +@@ -11,6 +11,8 @@ + #include "third_party/blink/public/common/privacy_budget/identifiability_study_settings.h" + #include "third_party/blink/public/common/privacy_budget/identifiable_surface.h" + #include "third_party/blink/public/common/privacy_budget/identifiable_token_builder.h" ++#include "third_party/blink/public/platform/web_content_settings_client.h" ++#include "third_party/blink/public/web/web_local_frame.h" + #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" + #include "third_party/blink/renderer/bindings/modules/v8/v8_rtc_insertable_streams.h" + #include "third_party/blink/renderer/bindings/modules/v8/v8_rtc_rtcp_parameters.h" +@@ -256,6 +258,14 @@ RTCRtpCapabilities* RTCRtpReceiver::getCapabilities(ScriptState* state, + if (kind != "audio" && kind != "video") + return nullptr; + ++ LocalDOMWindow* window = To(ExecutionContext::From(state)); ++ auto* web_frame = ++ static_cast(WebFrame::FromCoreFrame(window->GetFrame())); ++ blink::WebContentSettingsClient* settings = web_frame->GetContentSettingsClient(); ++ if (settings && !settings->AllowContentSetting(ContentSettingsType::WEBRTC, false)) { ++ return nullptr; ++ } ++ + RTCRtpCapabilities* capabilities = RTCRtpCapabilities::Create(); + capabilities->setCodecs(HeapVector>()); + capabilities->setHeaderExtensions( +diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_rtp_sender.cc b/third_party/blink/renderer/modules/peerconnection/rtc_rtp_sender.cc +--- a/third_party/blink/renderer/modules/peerconnection/rtc_rtp_sender.cc ++++ b/third_party/blink/renderer/modules/peerconnection/rtc_rtp_sender.cc +@@ -16,6 +16,8 @@ + #include "third_party/blink/public/common/privacy_budget/identifiability_study_settings.h" + #include "third_party/blink/public/common/privacy_budget/identifiable_surface.h" + #include "third_party/blink/public/common/privacy_budget/identifiable_token_builder.h" ++#include "third_party/blink/public/platform/web_content_settings_client.h" ++#include "third_party/blink/public/web/web_local_frame.h" + #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" + #include "third_party/blink/renderer/bindings/modules/v8/v8_rtc_insertable_streams.h" + #include "third_party/blink/renderer/bindings/modules/v8/v8_rtc_rtcp_parameters.h" +@@ -941,6 +943,14 @@ RTCRtpCapabilities* RTCRtpSender::getCapabilities(ScriptState* state, + if (kind != "audio" && kind != "video") + return nullptr; + ++ LocalDOMWindow* window = To(ExecutionContext::From(state)); ++ auto* web_frame = ++ static_cast(WebFrame::FromCoreFrame(window->GetFrame())); ++ blink::WebContentSettingsClient* settings = web_frame->GetContentSettingsClient(); ++ if (settings && !settings->AllowContentSetting(ContentSettingsType::WEBRTC, false)) { ++ return nullptr; ++ } ++ + RTCRtpCapabilities* capabilities = RTCRtpCapabilities::Create(); + capabilities->setCodecs(HeapVector>()); + capabilities->setHeaderExtensions( -- 2.25.1 diff --git a/build/patches/Content-settings-infrastructure.patch b/build/patches/Content-settings-infrastructure.patch index c4146564..81b7e100 100644 --- a/build/patches/Content-settings-infrastructure.patch +++ b/build/patches/Content-settings-infrastructure.patch @@ -10,53 +10,90 @@ See BromiteCustomContentSetting_README.md for more information. Original License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html --- - .../browser_ui/site_settings/android/BUILD.gn | 4 + - .../BromiteCustomContentSetting.java | 125 ++++++++ - .../BromiteCustomContentSettingImpl.java | 271 ++++++++++++++++++ + .../browser_ui/site_settings/android/BUILD.gn | 15 + + .../BromiteCustomContentSetting.java | 127 ++++++++ + .../BromiteCustomContentSettingImpl.java | 275 ++++++++++++++++++ .../BromiteCustomContentSetting_README.md | 151 ++++++++++ - .../ContentSettingsResources.java | 13 +- + .../ContentSettingsResources.java | 14 +- .../site_settings/SingleCategorySettings.java | 27 +- - .../site_settings/SingleWebsiteSettings.java | 24 +- - .../site_settings/SiteSettings.java | 3 +- - .../site_settings/SiteSettingsCategory.java | 10 +- + .../site_settings/SingleWebsiteSettings.java | 22 +- + .../site_settings/SiteSettings.java | 7 +- + .../site_settings/SiteSettingsCategory.java | 18 +- .../TriStateSiteSettingsPreference.java | 13 +- - .../browser_ui/site_settings/Website.java | 4 + + .../browser_ui/site_settings/Website.java | 6 + .../WebsitePermissionsFetcher.java | 2 +- .../WebsitePreferenceBridge.java | 3 +- - .../core/browser/content_settings_registry.cc | 11 +- - .../core/browser/content_settings_registry.h | 5 +- - .../core/browser/website_settings_info.cc | 10 +- - .../core/browser/website_settings_info.h | 12 +- - .../core/browser/website_settings_registry.cc | 8 +- - .../core/browser/website_settings_registry.h | 5 +- + .../impl/include_all_directory.java | 1 + + ...miteCustomContentSettingImplBase.java.tmpl | 48 +++ + .../bromite_content_settings/placeholder.txt | 1 + + .../strings/android/browser_ui_strings.grd | 1 + + components/components_strings.grd | 1 + + .../content_settings/core/browser/BUILD.gn | 7 + + .../bromite_content_settings/placeholder.txt | 1 + + .../core/browser/content_settings_registry.cc | 15 +- + .../core/browser/content_settings_registry.h | 6 +- + .../core/browser/content_settings_utils.cc | 12 + + .../core/browser/website_settings_info.cc | 12 +- + .../core/browser/website_settings_info.h | 15 +- + .../core/browser/website_settings_registry.cc | 10 +- + .../core/browser/website_settings_registry.h | 6 +- + .../content_settings/core/common/BUILD.gn | 6 + + .../bromite_content_settings/placeholder.txt | 1 + + .../core/common/content_settings.cc | 19 ++ + .../core/common/content_settings.h | 10 + + .../core/common/content_settings.mojom | 6 + + .../common/content_settings_mojom_traits.cc | 12 +- + .../common/content_settings_mojom_traits.h | 24 ++ + .../core/common/content_settings_types.h | 2 + + .../renderer/content_settings_agent_impl.cc | 33 +++ + .../renderer/content_settings_agent_impl.h | 5 + .../PermissionParamsListBuilder.java | 1 + .../android/page_info_controller_android.cc | 18 ++ - components/page_info/page_info.cc | 23 +- + components/page_info/page_info.cc | 22 +- components/page_info/page_info_ui.cc | 18 ++ - 23 files changed, 731 insertions(+), 30 deletions(-) + .../platform/web_content_settings_client.h | 5 + + .../execution_context/execution_context.cc | 16 + + .../execution_context/execution_context.h | 5 + + 44 files changed, 986 insertions(+), 33 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 + create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/include_all_directory.java + create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/java_template/BromiteCustomContentSettingImplBase.java.tmpl + create mode 100644 components/browser_ui/strings/android/bromite_content_settings/placeholder.txt + create mode 100644 components/content_settings/core/browser/bromite_content_settings/placeholder.txt + create mode 100644 components/content_settings/core/common/bromite_content_settings/placeholder.txt 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 -@@ -102,6 +102,10 @@ android_library("java") { - "java/src/org/chromium/components/browser_ui/site_settings/WebsiteRowPreference.java", - "java/src/org/chromium/components/browser_ui/site_settings/TimezoneOverrideSiteSettingsPreference.java" +@@ -139,6 +139,21 @@ android_library("java") { ] + srcjar_deps = + [ "//components/content_settings/android:java_pref_names_srcjar" ] + sources += [ + "java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSettingImpl.java", + "java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSetting.java", ++ "java/src/org/chromium/components/browser_ui/site_settings/impl/include_all_directory.java", + ] - annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ] - resources_package = "org.chromium.components.browser_ui.site_settings" - deps = [ ++ deps += [ ++ ":java_bromite_content_settings" ++ ] ++ srcjar_deps += [ ":java_bromite_content_settings" ] ++} ++ ++java_bromite_impl("java_bromite_content_settings") { ++ inputs = [ "java/src/org/chromium/components/browser_ui/site_settings/impl/include_all_directory.java" ] ++ directories = [ "java/src/org/chromium/components/browser_ui/site_settings/impl" ] ++ template = "java/src/org/chromium/components/browser_ui/site_settings/impl/java_template/BromiteCustomContentSettingImplBase.java.tmpl" + } + + android_library("javatests") { diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSetting.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSetting.java new file mode 100644 --- /dev/null +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSetting.java -@@ -0,0 +1,125 @@ +@@ -0,0 +1,127 @@ +/* + This file is part of Bromite. + @@ -99,14 +136,12 @@ new file mode 100644 + private String mProfilePrefKey; + + public BromiteCustomContentSetting(@ContentSettingsType int contentSettingsType, -+ @SiteSettingsCategory.Type int siteSettingsCategory, + @ContentSettingValues Integer defaultEnabledValue, + @ContentSettingValues Integer defaultDisabledValue, + boolean allowException, + String preferenceKey, + String profilePrefKey) { + mContentSettingsType = contentSettingsType; -+ mSiteSettingsCategory = siteSettingsCategory; + mDefaultEnabledValue = defaultEnabledValue; + mDefaultDisabledValue = defaultDisabledValue; + mAllowException = allowException; @@ -118,6 +153,10 @@ new file mode 100644 + return mContentSettingsType; + } + ++ public void setSiteSettingsCategory(int value) { ++ mSiteSettingsCategory = value; ++ } ++ + public @SiteSettingsCategory.Type int getSiteSettingsCategory() { + return mSiteSettingsCategory; + } @@ -186,7 +225,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,275 @@ +/* + This file is part of Bromite. + @@ -226,19 +265,23 @@ new file mode 100644 +import java.util.Arrays; +import java.util.List; + -+public abstract class BromiteCustomContentSettingImpl { -+ -+ static private final ArrayList mItemList; -+ -+ static { -+ mItemList = new ArrayList(); -+ } ++public abstract class BromiteCustomContentSettingImpl ++ extends BromiteCustomContentSettingImplBase { + + public static SiteSettingsCategory createFromType( + BrowserContextHandle browserContextHandle, @SiteSettingsCategory.Type int type) { ++ for (BromiteCustomContentSetting cs : mItemList) { ++ if (type == cs.getSiteSettingsCategory()) { ++ return new SiteSettingsCategory(browserContextHandle, type, ""); ++ } ++ } + return null; + } + ++ public static int NUM_ENTRIES() { ++ return BromiteCustomContentSettingImplBase.NUM_ENTRIES(); ++ } ++ + public static BromiteCustomContentSetting getContentSetting(@ContentSettingsType int type) { + for (BromiteCustomContentSetting cs : mItemList) { + if (type == cs.getContentSetting()) { @@ -626,37 +669,38 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c private final int mIcon; private final int mTitle; private final @ContentSettingValues @Nullable Integer mDefaultEnabledValue; -@@ -323,6 +323,8 @@ public class ContentSettingsResources { - R.string.website_settings_category_timezone_override_custom, - R.string.website_settings_category_timezone_override_random); +@@ -46,7 +46,7 @@ public class ContentSettingsResources { + private final int mEnabledSummary; + private final int mDisabledSummary; + +- ResourceItem(int icon, int title, ++ public ResourceItem(int icon, int title, + @ContentSettingValues @Nullable Integer defaultEnabledValue, + @ContentSettingValues @Nullable Integer defaultDisabledValue, int enabledSummary, + int disabledSummary) { +@@ -303,6 +303,8 @@ public class ContentSettingsResources { + ContentSettingValues.BLOCK, R.string.website_settings_category_vr_ask, + R.string.website_settings_category_vr_blocked); } + ResourceItem ri = BromiteCustomContentSettingImpl.getResourceItem(contentType); + if (ri != null) return ri; assert false; // NOTREACHED return null; } -@@ -488,7 +490,9 @@ public class ContentSettingsResources { +@@ -468,6 +470,12 @@ public class ContentSettingsResources { } } -- public static int getCategorySummary(int contentType, @Nullable @ContentSettingValues int value) { -+ public static int getCategorySummary(int contentType, @Nullable @ContentSettingValues int value) { // ++ public static int getCategorySummary(int contentType, @Nullable @ContentSettingValues int value) { + int result = BromiteCustomContentSettingImpl.getCategorySummary(contentType, value); + if (result != 0) return result; - if (contentType == ContentSettingsType.TIMEZONE_OVERRIDE) { - switch (value) { - case ContentSettingValues.ALLOW: -@@ -501,8 +505,7 @@ public class ContentSettingsResources { - return 0; - } - } -- else -- return getCategorySummary(value); + return getCategorySummary(value); - } - ++ } ++ /** -@@ -643,6 +646,8 @@ public class ContentSettingsResources { + * Returns the string resource id for a content type to show with a permission category. + * @param enabled Whether the content type is enabled. +@@ -603,6 +611,8 @@ public class ContentSettingsResources { * Blocked states, in that order. */ public static int[] getTriStateSettingDescriptionIDs(int contentType) { @@ -668,7 +712,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 -@@ -311,6 +311,10 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -305,6 +305,10 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment @ContentSettingValues Integer contentSetting = website.site().getContentSetting( browserContextHandle, mCategory.getContentSettingsType()); @@ -677,9 +721,9 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c + return BromiteCustomContentSettingImpl.isOnBlockList(contentSetting, website, contentSetting); + } if (contentSetting != null) { - if (mCategory.getContentSettingsType() == SiteSettingsCategory.Type.TIMEZONE_OVERRIDE) { - return ContentSettingValues.ALLOW != contentSetting; -@@ -473,6 +477,7 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment + return ContentSettingValues.BLOCK == contentSetting; + } +@@ -463,6 +467,7 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment ? new HashSet<>(getArguments().getStringArrayList(EXTRA_SELECTED_DOMAINS)) : null; @@ -687,7 +731,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c configureGlobalToggles(); if (mCategory.getType() == SiteSettingsCategory.Type.REQUEST_DESKTOP_SITE) { RecordUserAction.record("DesktopSiteContentSetting.SettingsPage.Entered"); -@@ -585,6 +590,11 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -571,6 +576,11 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment BrowserContextHandle browserContextHandle = getSiteSettingsDelegate().getBrowserContextHandle(); PrefService prefService = UserPrefs.get(browserContextHandle); @@ -699,8 +743,8 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c if (BINARY_TOGGLE_KEY.equals(preference.getKey())) { assert !mCategory.isManaged(); boolean toggleValue = (boolean) newValue; -@@ -831,6 +841,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment - : R.string.website_settings_category_timezone_override_allowed; +@@ -787,6 +797,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment + : R.string.website_settings_allowed_group_heading_request_desktop_site; break; } + if (resource == 0) @@ -708,7 +752,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c assert resource > 0; return getString(resource); } -@@ -964,6 +976,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -908,6 +920,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment default: break; } @@ -717,7 +761,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c if (allowSpecifyingExceptions) { getPreferenceScreen().addPreference(new AddExceptionPreference(getStyledContext(), ADD_EXCEPTION_KEY, getAddExceptionDialogMessage(), mCategory, this)); -@@ -1137,6 +1151,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -1081,6 +1095,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment case GlobalToggleLayout.TRI_STATE_TOGGLE: TriStateSiteSettingsPreference triStateToggle = getPreferenceScreen().findPreference(TRI_STATE_TOGGLE_KEY); @@ -726,15 +770,15 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c return (triStateToggle.getCheckedSetting() == ContentSettingValues.BLOCK); case GlobalToggleLayout.FOUR_STATE_COOKIE_TOGGLE: FourStateCookieSettingsPreference fourStateCookieToggle = -@@ -1248,6 +1264,7 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -1182,6 +1198,7 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment screen.removePreference(antiAbuseThingsToConsiderHeader); screen.removePreference(antiAbuseThingsToConsiderSectionOne); } + BromiteCustomContentSettingImpl.configureGlobalToggles(mCategory, screen); - if (mCategory.getType() == SiteSettingsCategory.Type.TIMEZONE_OVERRIDE) { - screen.removePreference(triStateToggle); -@@ -1407,7 +1424,7 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment + if (permissionBlockedByOs) { + maybeShowOsWarning(screen); +@@ -1335,7 +1352,7 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment getSiteSettingsDelegate().getBrowserContextHandle(), contentType); int[] descriptionIds = ContentSettingsResources.getTriStateSettingDescriptionIDs(contentType); @@ -742,8 +786,8 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c + triStateToggle.initialize(contentType, setting, descriptionIds); } - private void configureTimeOverrideStateToggle( -@@ -1520,6 +1537,14 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment + private void configureBinaryToggle(ChromeSwitchPreference binaryToggle, int contentType) { +@@ -1439,6 +1456,14 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment @ContentSettingValues Integer value = site.getContentSetting(browserContextHandle, contentSettingsType); @@ -761,7 +805,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 -@@ -44,6 +44,7 @@ import org.chromium.content_public.browser.ContentFeatureList; +@@ -45,6 +45,7 @@ import org.chromium.content_public.browser.ContentFeatureList; import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -769,7 +813,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c /** * Shows the permissions and other settings for a particular website. -@@ -174,7 +175,7 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment +@@ -167,7 +168,7 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment case ContentSettingsType.CLIPBOARD_READ_WRITE: return "clipboard_permission_list"; default: @@ -778,7 +822,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c } } -@@ -510,7 +511,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment +@@ -503,7 +504,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment private void setupContentSettingsPreferences() { mMaxPermissionOrder = findPreference(PREF_PERMISSIONS_HEADER).getOrder(); @@ -788,14 +832,12 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c Preference preference = new ChromeSwitchPreference(getStyledContext()); preference.setKey(getPreferenceKey(type)); -@@ -956,16 +958,22 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment +@@ -948,14 +950,22 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment private void setupContentSettingsPreference(Preference preference, @ContentSettingValues @Nullable Integer value, boolean isEmbargoed) { - if (value == null) return; -- setUpPreferenceCommon(preference, value); -- - int content_type = getContentSettingsTypeFromPreferenceKey(preference.getKey()); ++ int content_type = getContentSettingsTypeFromPreferenceKey(preference.getKey()); + BromiteCustomContentSetting cs = + BromiteCustomContentSettingImpl.getContentSetting(content_type); + if (value == null && cs == null) return; @@ -804,24 +846,24 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c + value = WebsitePreferenceBridge.getDefaultContentSetting( + getSiteSettingsDelegate().getBrowserContextHandle(), content_type); + } -+ setUpPreferenceCommon(preference, value); + setUpPreferenceCommon(preference, value); ChromeSwitchPreference switchPreference = (ChromeSwitchPreference) preference; - switchPreference.setChecked(value == ContentSettingValues.ALLOW); + switchPreference.setChecked(value != ContentSettingValues.BLOCK); switchPreference.setSummary(isEmbargoed ? getString(R.string.automatically_blocked) -- : getString(ContentSettingsResources.getCategorySummary(content_type, value))); -+ : getString(ContentSettingsResources.getCategorySummary(content_type, value))); // +- : getString(ContentSettingsResources.getCategorySummary(value))); ++ : getString(ContentSettingsResources.getCategorySummary(content_type, value))); switchPreference.setOnPreferenceChangeListener(this); @ContentSettingsType int contentType = getContentSettingsTypeFromPreferenceKey(preference.getKey()); -@@ -1218,7 +1226,7 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment +@@ -1159,7 +1169,7 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment } mSite.setContentSetting(browserContextHandle, type, permission); -- preference.setSummary(getString(ContentSettingsResources.getCategorySummary(type, permission))); -+ preference.setSummary(getString(ContentSettingsResources.getCategorySummary(type, permission))); // +- preference.setSummary(getString(ContentSettingsResources.getCategorySummary(permission))); ++ preference.setSummary(getString(ContentSettingsResources.getCategorySummary(type, permission))); preference.setIcon(getContentSettingsIcon(type, permission)); if (mWebsiteSettingsObserver != null) { @@ -836,9 +878,27 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c configurePreferences(); updatePreferenceStates(); } +@@ -52,7 +53,7 @@ public class SiteSettings extends SiteSettingsPreferenceFragment + + private void configurePreferences() { + // Remove unsupported settings categories. +- for (@SiteSettingsCategory.Type int type = 0; type < SiteSettingsCategory.Type.NUM_ENTRIES; ++ for (@SiteSettingsCategory.Type int type = 0; type < BromiteCustomContentSettingImpl.NUM_ENTRIES(); + type++) { + if (!getSiteSettingsDelegate().isCategoryVisible(type)) { + getPreferenceScreen().removePreference(findPreference(type)); +@@ -68,7 +69,7 @@ public class SiteSettings extends SiteSettingsPreferenceFragment + @CookieControlsMode + int cookieControlsMode = + UserPrefs.get(browserContextHandle).getInteger(COOKIE_CONTROLS_MODE); +- for (@Type int prefCategory = 0; prefCategory < Type.NUM_ENTRIES; prefCategory++) { ++ for (@Type int prefCategory = 0; prefCategory < BromiteCustomContentSettingImpl.NUM_ENTRIES(); prefCategory++) { + Preference p = findPreference(prefCategory); + int contentType = SiteSettingsCategory.contentSettingsType(prefCategory); + // p can be null if the Preference was removed in configurePreferences. @@ -133,7 +134,7 @@ public class SiteSettings extends SiteSettingsPreferenceFragment } else if (requiresTriStateSetting) { - p.setSummary(ContentSettingsResources.getCategorySummary(contentType, setting)); + p.setSummary(ContentSettingsResources.getCategorySummary(setting)); } else { - p.setSummary(ContentSettingsResources.getCategorySummary(contentType, checked)); + p.setSummary(ContentSettingsResources.getCategorySummary(contentType, checked)); // @@ -848,7 +908,25 @@ 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/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 -@@ -133,6 +133,9 @@ public class SiteSettingsCategory { +@@ -47,7 +47,7 @@ public class SiteSettingsCategory { + Type.PROTECTED_MEDIA, Type.SENSORS, Type.SOUND, Type.USB, Type.VIRTUAL_REALITY, + Type.USE_STORAGE, Type.AUTO_DARK_WEB_CONTENT, Type.REQUEST_DESKTOP_SITE, + Type.FEDERATED_IDENTITY_API, Type.THIRD_PARTY_COOKIES, Type.SITE_DATA, Type.ANTI_ABUSE, +- Type.NUM_ENTRIES}) ++ Type.NUM_ENTRIES_CHROMIUM}) + @Retention(RetentionPolicy.SOURCE) + public @interface Type { + // All updates here must also be reflected in {@link #preferenceKey(int) +@@ -84,7 +84,7 @@ public class SiteSettingsCategory { + /** + * Number of handled categories used for calculating array sizes. + */ +- int NUM_ENTRIES = 29; ++ int NUM_ENTRIES_CHROMIUM = 29; + } + + private final BrowserContextHandle mBrowserContextHandle; +@@ -128,6 +128,9 @@ public class SiteSettingsCategory { } else { permission = ""; } @@ -858,7 +936,25 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c return new SiteSettingsCategory(browserContextHandle, type, permission); } -@@ -230,8 +233,7 @@ public class SiteSettingsCategory { +@@ -136,7 +139,7 @@ public class SiteSettingsCategory { + @ContentSettingsType int contentSettingsType) { + assert contentSettingsType != -1; + assert Type.ALL_SITES == 0; +- for (@Type int i = Type.ALL_SITES; i < Type.NUM_ENTRIES; i++) { ++ for (@Type int i = Type.ALL_SITES; i < BromiteCustomContentSettingImpl.NUM_ENTRIES(); i++) { + if (contentSettingsType(i) == contentSettingsType) { + return createFromType(browserContextHandle, i); + } +@@ -147,7 +150,7 @@ public class SiteSettingsCategory { + public static SiteSettingsCategory createFromPreferenceKey( + BrowserContextHandle browserContextHandle, String preferenceKey) { + assert Type.ALL_SITES == 0; +- for (@Type int i = Type.ALL_SITES; i < Type.NUM_ENTRIES; i++) { ++ for (@Type int i = Type.ALL_SITES; i < BromiteCustomContentSettingImpl.NUM_ENTRIES(); i++) { + if (preferenceKey(i).equals(preferenceKey)) { + return createFromType(browserContextHandle, i); + } +@@ -217,8 +220,7 @@ public class SiteSettingsCategory { case Type.USE_STORAGE: return ContentSettingsType.DEFAULT; // Conversion unavailable. } @@ -868,9 +964,9 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c } /** -@@ -322,8 +324,12 @@ public class SiteSettingsCategory { - case Type.TIMEZONE_OVERRIDE: - return "timezone_override"; +@@ -301,8 +303,12 @@ public class SiteSettingsCategory { + case Type.THIRD_PARTY_COOKIES: + return "third_party_cookies"; default: + { + String value = BromiteCustomContentSettingImpl.getPreferenceKey(type); @@ -928,21 +1024,23 @@ 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 -@@ -277,6 +277,10 @@ public final class Website implements WebsiteEntry { - /*isEmbargoed=*/false); - setContentSettingException(type, exception); +@@ -244,6 +244,12 @@ public final class Website implements WebsiteEntry { + RecordUserAction.record("SoundContentSetting.UnmuteBy.SiteSettings"); } -+ } else if (exception == null) { + } ++ ++ if (exception == null) { + exception = BromiteCustomContentSettingImpl.createCustomException(type, value, getAddress()); + if (exception != null) + setContentSettingException(type, exception); - } ++ } // We want to call setContentSetting even after explicitly setting // mContentSettingException above because this will trigger the actual change + // on the PrefServiceBridge. diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java -@@ -96,7 +96,7 @@ public class WebsitePermissionsFetcher { +@@ -93,7 +93,7 @@ public class WebsitePermissionsFetcher { case ContentSettingsType.USB_GUARD: return WebsitePermissionsType.CHOSEN_OBJECT_INFO; default: @@ -955,7 +1053,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java @@ -246,7 +246,7 @@ public class WebsitePreferenceBridge { - case ContentSettingsType.TIMEZONE_OVERRIDE: + case ContentSettingsType.PROTECTED_MEDIA_IDENTIFIER: return true; default: - return false; @@ -971,6 +1069,116 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c return isContentSettingEnabled(browserContextHandle, contentSettingsType); } +diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/include_all_directory.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/include_all_directory.java +new file mode 100644 +--- /dev/null ++++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/include_all_directory.java +@@ -0,0 +1 @@ ++this file is intentionally empty +diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/java_template/BromiteCustomContentSettingImplBase.java.tmpl b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/java_template/BromiteCustomContentSettingImplBase.java.tmpl +new file mode 100644 +--- /dev/null ++++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/java_template/BromiteCustomContentSettingImplBase.java.tmpl +@@ -0,0 +1,48 @@ ++/* ++ This file is part of Bromite. ++ ++ Bromite is free software: you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation, either version 3 of the License, or ++ (at your option) any later version. ++ ++ Bromite is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with Bromite. If not, see . ++ ++*/ ++ ++{DESCRIPTION} ++ ++package org.chromium.components.browser_ui.site_settings; ++ ++import org.chromium.components.browser_ui.site_settings.SiteSettingsCategory; ++import org.chromium.components.browser_ui.site_settings.BromiteCustomContentSetting; ++ ++import java.util.ArrayList; ++ ++{IMPORT_CLAUSE} ++ ++public class BromiteCustomContentSettingImplBase {{ ++ ++ static protected final ArrayList mItemList; ++ ++ private static void add(BromiteCustomContentSetting setting) {{ ++ setting.setSiteSettingsCategory(NUM_ENTRIES()); ++ mItemList.add(setting); ++ }} ++ ++ protected static int NUM_ENTRIES() {{ ++ return SiteSettingsCategory.Type.NUM_ENTRIES_CHROMIUM + mItemList.size(); ++ }} ++ ++ static {{ ++ mItemList = new ArrayList(); ++{ADD_CLAUSE} ++ }} ++ ++}} +diff --git a/components/browser_ui/strings/android/bromite_content_settings/placeholder.txt b/components/browser_ui/strings/android/bromite_content_settings/placeholder.txt +new file mode 100644 +--- /dev/null ++++ b/components/browser_ui/strings/android/bromite_content_settings/placeholder.txt +@@ -0,0 +1 @@ ++this file is intentionally empty +diff --git a/components/browser_ui/strings/android/browser_ui_strings.grd b/components/browser_ui/strings/android/browser_ui_strings.grd +--- a/components/browser_ui/strings/android/browser_ui_strings.grd ++++ b/components/browser_ui/strings/android/browser_ui_strings.grd +@@ -174,6 +174,7 @@ + + + ++ + + + Got it +diff --git a/components/components_strings.grd b/components/components_strings.grd +--- a/components/components_strings.grd ++++ b/components/components_strings.grd +@@ -281,6 +281,7 @@ + + + ++ + + + +diff --git a/components/content_settings/core/browser/BUILD.gn b/components/content_settings/core/browser/BUILD.gn +--- a/components/content_settings/core/browser/BUILD.gn ++++ b/components/content_settings/core/browser/BUILD.gn +@@ -80,6 +80,13 @@ static_library("browser") { + } + + configs += [ "//build/config/compiler:wexit_time_destructors" ] ++ ++ deps += [ ":bromite_content_settings" ] ++} ++ ++cpp_bromite_include("bromite_content_settings") { ++ directories = [ "bromite_content_settings/placeholder.txt" ] ++ output_file = "bromite_content_settings.inc" + } + + source_set("unit_tests") { +diff --git a/components/content_settings/core/browser/bromite_content_settings/placeholder.txt b/components/content_settings/core/browser/bromite_content_settings/placeholder.txt +new file mode 100644 +--- /dev/null ++++ b/components/content_settings/core/browser/bromite_content_settings/placeholder.txt +@@ -0,0 +1 @@ ++this file is intentionally empty 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 @@ -983,25 +1191,36 @@ diff --git a/components/content_settings/core/browser/content_settings_registry. namespace content_settings { -@@ -616,7 +618,10 @@ void ContentSettingsRegistry::Register( +@@ -592,6 +594,8 @@ void ContentSettingsRegistry::Init() { + WebsiteSettingsRegistry::ALL_PLATFORMS, + ContentSettingsInfo::INHERIT_IN_INCOGNITO, + ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); ++ ++#include "components/content_settings/core/browser/bromite_content_settings.inc" + } + + void ContentSettingsRegistry::Register( +@@ -604,7 +608,11 @@ void ContentSettingsRegistry::Register( WebsiteSettingsInfo::ScopingType scoping_type, Platforms platforms, ContentSettingsInfo::IncognitoBehavior incognito_behavior, - ContentSettingsInfo::OriginRestriction origin_restriction) { + ContentSettingsInfo::OriginRestriction origin_restriction, + bool show_into_info_page, ++ bool is_renderer_content_setting, + int permission_type_ui, + int permission_type_ui_mid_sentence) { // Ensure that nothing has been registered yet for the given type. DCHECK(!website_settings_registry_->Get(type)); -@@ -625,7 +630,9 @@ void ContentSettingsRegistry::Register( +@@ -613,7 +621,10 @@ void ContentSettingsRegistry::Register( website_settings_registry_->Register( type, name, std::move(default_value), sync_status, WebsiteSettingsInfo::NOT_LOSSY, scoping_type, platforms, - WebsiteSettingsInfo::INHERIT_IN_INCOGNITO); + WebsiteSettingsInfo::INHERIT_IN_INCOGNITO, -+ show_into_info_page, permission_type_ui, ++ show_into_info_page, is_renderer_content_setting, ++ permission_type_ui, + permission_type_ui_mid_sentence); // WebsiteSettingsInfo::Register() will return nullptr if content setting type @@ -1009,40 +1228,72 @@ diff --git a/components/content_settings/core/browser/content_settings_registry. diff --git a/components/content_settings/core/browser/content_settings_registry.h b/components/content_settings/core/browser/content_settings_registry.h --- a/components/content_settings/core/browser/content_settings_registry.h +++ b/components/content_settings/core/browser/content_settings_registry.h -@@ -70,7 +70,10 @@ class ContentSettingsRegistry { +@@ -70,7 +70,11 @@ class ContentSettingsRegistry { WebsiteSettingsInfo::ScopingType scoping_type, Platforms platforms, ContentSettingsInfo::IncognitoBehavior incognito_behavior, - ContentSettingsInfo::OriginRestriction origin_restriction); + ContentSettingsInfo::OriginRestriction origin_restriction, + bool show_into_info_page = false, ++ bool is_renderer_content_setting = false, + int permission_type_ui = 0, + int permission_type_ui_mid_sentence = 0); Map content_settings_info_; raw_ptr website_settings_registry_; +diff --git a/components/content_settings/core/browser/content_settings_utils.cc b/components/content_settings/core/browser/content_settings_utils.cc +--- a/components/content_settings/core/browser/content_settings_utils.cc ++++ b/components/content_settings/core/browser/content_settings_utils.cc +@@ -14,6 +14,7 @@ + #include "build/build_config.h" + #include "components/content_settings/core/browser/content_settings_registry.h" + #include "components/content_settings/core/browser/host_content_settings_map.h" ++#include "components/content_settings/core/browser/website_settings_registry.h" + #include "components/content_settings/core/common/content_settings.h" + #include "components/content_settings/core/common/content_settings_types.h" + #include "components/content_settings/core/common/content_settings_utils.h" +@@ -122,6 +123,17 @@ PatternPair ParsePatternString(const std::string& pattern_str) { + + void GetRendererContentSettingRules(const HostContentSettingsMap* map, + RendererContentSettingRules* rules) { ++ content_settings::WebsiteSettingsRegistry* website_settings = ++ content_settings::WebsiteSettingsRegistry::GetInstance(); ++ rules->settings_rules.clear(); ++ for (const content_settings::WebsiteSettingsInfo* info : *website_settings) { ++ if (info->is_renderer_content_setting()) { ++ ContentSettingRuleSource rule; ++ rule.type = (int32_t)info->type(); ++ map->GetSettingsForOneType(info->type(), &rule.rules); ++ rules->settings_rules.push_back(rule); ++ } ++ } + #if !BUILDFLAG(IS_ANDROID) + map->GetSettingsForOneType(ContentSettingsType::IMAGES, + &(rules->image_rules)); diff --git a/components/content_settings/core/browser/website_settings_info.cc b/components/content_settings/core/browser/website_settings_info.cc --- a/components/content_settings/core/browser/website_settings_info.cc +++ b/components/content_settings/core/browser/website_settings_info.cc -@@ -33,7 +33,10 @@ WebsiteSettingsInfo::WebsiteSettingsInfo(ContentSettingsType type, +@@ -33,7 +33,11 @@ WebsiteSettingsInfo::WebsiteSettingsInfo(ContentSettingsType type, SyncStatus sync_status, LossyStatus lossy_status, ScopingType scoping_type, - IncognitoBehavior incognito_behavior) + IncognitoBehavior incognito_behavior, -+ bool show_into_info_page, -+ int permission_type_ui, -+ int permission_type_ui_mid_sentence) ++ bool show_into_info_page, ++ bool is_renderer_content_setting, ++ int permission_type_ui, ++ int permission_type_ui_mid_sentence) : type_(type), name_(name), pref_name_(GetPreferenceName(name, kPrefPrefix)), -@@ -42,7 +45,10 @@ WebsiteSettingsInfo::WebsiteSettingsInfo(ContentSettingsType type, +@@ -42,7 +46,11 @@ WebsiteSettingsInfo::WebsiteSettingsInfo(ContentSettingsType type, sync_status_(sync_status), lossy_status_(lossy_status), scoping_type_(scoping_type), - incognito_behavior_(incognito_behavior) { + incognito_behavior_(incognito_behavior), + show_into_info_page_(show_into_info_page), ++ is_renderer_content_setting_(is_renderer_content_setting), + permission_type_ui_(permission_type_ui), + permission_type_ui_mid_sentence_(permission_type_ui_mid_sentence) { // For legacy reasons the default value is currently restricted to be an int @@ -1051,34 +1302,37 @@ diff --git a/components/content_settings/core/browser/website_settings_info.cc b diff --git a/components/content_settings/core/browser/website_settings_info.h b/components/content_settings/core/browser/website_settings_info.h --- a/components/content_settings/core/browser/website_settings_info.h +++ b/components/content_settings/core/browser/website_settings_info.h -@@ -95,7 +95,10 @@ class WebsiteSettingsInfo { +@@ -95,7 +95,11 @@ class WebsiteSettingsInfo { SyncStatus sync_status, LossyStatus lossy_status, ScopingType scoping_type, - IncognitoBehavior incognito_behavior); + IncognitoBehavior incognito_behavior, + bool show_into_info_page, ++ bool is_renderer_content_setting, + int permission_type_ui, + int permission_type_ui_mid_sentence); WebsiteSettingsInfo(const WebsiteSettingsInfo&) = delete; WebsiteSettingsInfo& operator=(const WebsiteSettingsInfo&) = delete; -@@ -120,6 +123,10 @@ class WebsiteSettingsInfo { +@@ -120,6 +124,11 @@ class WebsiteSettingsInfo { ScopingType scoping_type() const { return scoping_type_; } IncognitoBehavior incognito_behavior() const { return incognito_behavior_; } + bool show_into_info_page() const { return show_into_info_page_; } ++ bool is_renderer_content_setting() const { return is_renderer_content_setting_; } + int permission_type_ui() const { return permission_type_ui_; } + int permission_type_ui_mid_sentence() const { return permission_type_ui_mid_sentence_; } + private: const ContentSettingsType type_; const std::string name_; -@@ -131,6 +138,9 @@ class WebsiteSettingsInfo { +@@ -131,6 +140,10 @@ class WebsiteSettingsInfo { const LossyStatus lossy_status_; const ScopingType scoping_type_; const IncognitoBehavior incognito_behavior_; + const bool show_into_info_page_; ++ const bool is_renderer_content_setting_; + const int permission_type_ui_; + const int permission_type_ui_mid_sentence_; }; @@ -1087,47 +1341,308 @@ diff --git a/components/content_settings/core/browser/website_settings_info.h b/ diff --git a/components/content_settings/core/browser/website_settings_registry.cc b/components/content_settings/core/browser/website_settings_registry.cc --- a/components/content_settings/core/browser/website_settings_registry.cc +++ b/components/content_settings/core/browser/website_settings_registry.cc -@@ -62,7 +62,10 @@ const WebsiteSettingsInfo* WebsiteSettingsRegistry::Register( +@@ -62,7 +62,11 @@ const WebsiteSettingsInfo* WebsiteSettingsRegistry::Register( WebsiteSettingsInfo::LossyStatus lossy_status, WebsiteSettingsInfo::ScopingType scoping_type, Platforms platform, - WebsiteSettingsInfo::IncognitoBehavior incognito_behavior) { + WebsiteSettingsInfo::IncognitoBehavior incognito_behavior, + bool show_into_info_page, ++ bool is_renderer_content_setting, + int permission_type_ui, + int permission_type_ui_mid_sentence) { #if BUILDFLAG(IS_WIN) if (!(platform & PLATFORM_WINDOWS)) return nullptr; -@@ -98,7 +101,8 @@ const WebsiteSettingsInfo* WebsiteSettingsRegistry::Register( +@@ -98,7 +102,9 @@ const WebsiteSettingsInfo* WebsiteSettingsRegistry::Register( WebsiteSettingsInfo* info = new WebsiteSettingsInfo( type, name, std::move(initial_default_value), sync_status, lossy_status, - scoping_type, incognito_behavior); + scoping_type, incognito_behavior, -+ show_into_info_page, permission_type_ui, permission_type_ui_mid_sentence); ++ show_into_info_page, is_renderer_content_setting, ++ permission_type_ui, permission_type_ui_mid_sentence); website_settings_info_[info->type()] = base::WrapUnique(info); return info; } diff --git a/components/content_settings/core/browser/website_settings_registry.h b/components/content_settings/core/browser/website_settings_registry.h --- a/components/content_settings/core/browser/website_settings_registry.h +++ b/components/content_settings/core/browser/website_settings_registry.h -@@ -76,7 +76,10 @@ class WebsiteSettingsRegistry { +@@ -76,7 +76,11 @@ class WebsiteSettingsRegistry { WebsiteSettingsInfo::LossyStatus lossy_status, WebsiteSettingsInfo::ScopingType scoping_type, Platforms platforms, - WebsiteSettingsInfo::IncognitoBehavior incognito_behavior); + WebsiteSettingsInfo::IncognitoBehavior incognito_behavior, + bool show_into_info_page = false, ++ bool is_renderer_content_setting = false, + int permission_type_ui = 0, + int permission_type_ui_mid_sentence = 0); const_iterator begin() const; const_iterator end() const; +diff --git a/components/content_settings/core/common/BUILD.gn b/components/content_settings/core/common/BUILD.gn +--- a/components/content_settings/core/common/BUILD.gn ++++ b/components/content_settings/core/common/BUILD.gn +@@ -48,6 +48,12 @@ static_library("common") { + if (use_blink) { + deps += [ "//components/privacy_sandbox:features" ] + } ++ deps += [ ":bromite_content_settings" ] ++} ++ ++cpp_bromite_include("bromite_content_settings") { ++ directories = [ "bromite_content_settings/placeholder.txt" ] ++ output_file = "bromite_content_settings.inc" + } + + source_set("unit_tests") { +diff --git a/components/content_settings/core/common/bromite_content_settings/placeholder.txt b/components/content_settings/core/common/bromite_content_settings/placeholder.txt +new file mode 100644 +--- /dev/null ++++ b/components/content_settings/core/common/bromite_content_settings/placeholder.txt +@@ -0,0 +1 @@ ++this file is intentionally empty +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 +@@ -13,6 +13,7 @@ + #include "build/build_config.h" + #include "components/content_settings/core/common/content_settings_metadata.h" + #include "components/content_settings/core/common/content_settings_utils.h" ++#include "components/content_settings/core/browser/website_settings_registry.h" + + namespace { + +@@ -143,6 +144,7 @@ ContentSetting IntToContentSetting(int content_setting) { + int ContentSettingTypeToHistogramValue(ContentSettingsType content_setting, + size_t* num_values) { + *num_values = std::size(kHistogramValue); ++ if ((true)) return 0; + + // Verify the array is sorted by enum type and contains all values. + DCHECK(std::is_sorted(std::begin(kHistogramValue), std::end(kHistogramValue), +@@ -212,6 +214,13 @@ bool ContentSettingPatternSource::IsExpired() const { + // static + bool RendererContentSettingRules::IsRendererContentSetting( + ContentSettingsType content_type) { ++ content_settings::WebsiteSettingsRegistry* website_settings = ++ content_settings::WebsiteSettingsRegistry::GetInstance(); ++ for (const content_settings::WebsiteSettingsInfo* info : *website_settings) { ++ if (info->type() == content_type && info->is_renderer_content_setting()) { ++ return true; ++ } ++ } + return content_type == ContentSettingsType::IMAGES || + content_type == ContentSettingsType::JAVASCRIPT || + content_type == ContentSettingsType::POPUPS || +@@ -221,6 +230,9 @@ bool RendererContentSettingRules::IsRendererContentSetting( + + void RendererContentSettingRules::FilterRulesByOutermostMainFrameURL( + const GURL& outermost_main_frame_url) { ++ for (ContentSettingRuleSource& info : settings_rules) { ++ FilterRulesForType(info.rules, outermost_main_frame_url); ++ } + FilterRulesForType(image_rules, outermost_main_frame_url); + FilterRulesForType(script_rules, outermost_main_frame_url); + FilterRulesForType(popup_redirect_rules, outermost_main_frame_url); +@@ -243,3 +255,10 @@ RendererContentSettingRules& RendererContentSettingRules::operator=( + + RendererContentSettingRules& RendererContentSettingRules::operator=( + RendererContentSettingRules&& rules) = default; ++ ++ContentSettingRuleSource::ContentSettingRuleSource() = default; ++ ++ContentSettingRuleSource::~ContentSettingRuleSource() = default; ++ ++ContentSettingRuleSource::ContentSettingRuleSource( ++ const ContentSettingRuleSource&) = default; +diff --git a/components/content_settings/core/common/content_settings.h b/components/content_settings/core/common/content_settings.h +--- a/components/content_settings/core/common/content_settings.h ++++ b/components/content_settings/core/common/content_settings.h +@@ -69,10 +69,20 @@ struct ContentSettingPatternSource { + + typedef std::vector ContentSettingsForOneType; + ++struct ContentSettingRuleSource { ++ int type; ++ ContentSettingsForOneType rules; ++ ++ ContentSettingRuleSource(); ++ ~ContentSettingRuleSource(); ++ ContentSettingRuleSource(const ContentSettingRuleSource& source); ++}; ++ + struct RendererContentSettingRules { + // Returns true if |content_type| is a type that is contained in this class. + // Any new type added below must also update this method. + static bool IsRendererContentSetting(ContentSettingsType content_type); ++ std::vector settings_rules; + + // Filters all the rules by matching the primary pattern with + // |outermost_main_frame_url|. Any new type added below that needs to match +diff --git a/components/content_settings/core/common/content_settings.mojom b/components/content_settings/core/common/content_settings.mojom +--- a/components/content_settings/core/common/content_settings.mojom ++++ b/components/content_settings/core/common/content_settings.mojom +@@ -61,6 +61,11 @@ enum ContentSetting { + DETECT_IMPORTANT_CONTENT + }; + ++struct ContentSettingRuleSource { ++ int32 type; ++ array rules; ++}; ++ + // This mirrors the C++ type in content_settings.h. + struct ContentSettingPatternSource { + ContentSettingsPattern primary_pattern; +@@ -73,6 +78,7 @@ struct ContentSettingPatternSource { + + // This mirrors the C++ type in content_settings.h. + struct RendererContentSettingRules { ++ array settings_rules; + array image_rules; + array script_rules; + array popup_redirect_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 +--- a/components/content_settings/core/common/content_settings_mojom_traits.cc ++++ b/components/content_settings/core/common/content_settings_mojom_traits.cc +@@ -93,12 +93,22 @@ bool StructTraitssource); + } + ++// static ++bool StructTraits:: ++ Read(content_settings::mojom::ContentSettingRuleSourceDataView data, ++ ContentSettingRuleSource* out) { ++ out->type = data.type(); ++ return data.ReadRules(&out->rules); ++} ++ + // static + bool StructTraits:: + Read(content_settings::mojom::RendererContentSettingRulesDataView data, + RendererContentSettingRules* out) { +- return data.ReadImageRules(&out->image_rules) && ++ return data.ReadSettingsRules(&out->settings_rules) && ++ data.ReadImageRules(&out->image_rules) && + data.ReadScriptRules(&out->script_rules) && + data.ReadPopupRedirectRules(&out->popup_redirect_rules) && + data.ReadMixedContentRules(&out->mixed_content_rules) && +diff --git a/components/content_settings/core/common/content_settings_mojom_traits.h b/components/content_settings/core/common/content_settings_mojom_traits.h +--- a/components/content_settings/core/common/content_settings_mojom_traits.h ++++ b/components/content_settings/core/common/content_settings_mojom_traits.h +@@ -121,10 +121,34 @@ struct StructTraits< + ContentSettingPatternSource* out); + }; + ++template <> ++struct StructTraits< ++ content_settings::mojom::ContentSettingRuleSourceDataView, ++ ContentSettingRuleSource> { ++ static int type( ++ const ContentSettingRuleSource& r) { ++ return r.type; ++ } ++ ++ static const std::vector& rules( ++ const ContentSettingRuleSource& r) { ++ return r.rules; ++ } ++ ++ static bool Read( ++ content_settings::mojom::ContentSettingRuleSourceDataView data, ++ ContentSettingRuleSource* out); ++}; ++ + template <> + struct StructTraits< + content_settings::mojom::RendererContentSettingRulesDataView, + RendererContentSettingRules> { ++ static const std::vector& settings_rules( ++ const RendererContentSettingRules& r) { ++ return r.settings_rules; ++ } ++ + static const std::vector& image_rules( + const RendererContentSettingRules& r) { + return r.image_rules; +diff --git a/components/content_settings/core/common/content_settings_types.h b/components/content_settings/core/common/content_settings_types.h +--- a/components/content_settings/core/common/content_settings_types.h ++++ b/components/content_settings/core/common/content_settings_types.h +@@ -274,6 +274,8 @@ enum class ContentSettingsType : int32_t { + // site instead of the mobile one. + REQUEST_DESKTOP_SITE, + ++#include "components/content_settings/core/common/bromite_content_settings.inc" ++ + // Setting to indicate whether browser should allow signing into a website via + // the browser FedCM API. + FEDERATED_IDENTITY_API, +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 +@@ -201,6 +201,39 @@ void ContentSettingsAgentImpl::SendRendererContentSettingRules( + std::move(renderer_settings)); + } + ++ContentSetting ContentSettingsAgentImpl::GetContentSetting( ++ ContentSettingsType type, ContentSetting default_value) { ++ if (!content_setting_rules_) ++ return default_value; ++ ++ blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); ++ const GURL secondary_url = ++ url::Origin(frame->GetDocument().GetSecurityOrigin()).GetURL(); ++ for (ContentSettingRuleSource& info : content_setting_rules_->settings_rules) { ++ if (info.type == (int)type) { ++ return GetContentSettingFromRules(info.rules, secondary_url); ++ } ++ } ++ return default_value; ++} ++ ++bool ContentSettingsAgentImpl::AllowContentSetting( ++ ContentSettingsType type, bool default_value) { ++ if (!content_setting_rules_) ++ return default_value; ++ ++ blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); ++ const GURL secondary_url = ++ url::Origin(frame->GetDocument().GetSecurityOrigin()).GetURL(); ++ for (ContentSettingRuleSource& info : content_setting_rules_->settings_rules) { ++ if (info.type == (int)type) { ++ return CONTENT_SETTING_ALLOW == GetContentSettingFromRules( ++ info.rules, secondary_url); ++ } ++ } ++ return default_value; ++} ++ + void ContentSettingsAgentImpl::OnContentSettingsAgentRequest( + mojo::PendingAssociatedReceiver receiver) { + receivers_.Add(this, std::move(receiver)); +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 +@@ -75,6 +75,11 @@ class ContentSettingsAgentImpl + static mojom::ContentSettingsManager::StorageType ConvertToMojoStorageType( + StorageType storage_type); + ++ bool AllowContentSetting( ++ ContentSettingsType type, bool default_value) override; ++ ContentSetting GetContentSetting( ++ ContentSettingsType type, ContentSetting default_value); ++ + // blink::WebContentSettingsClient: + void AllowStorageAccess(StorageType storage_type, + base::OnceCallback callback) override; diff --git a/components/page_info/android/java/src/org/chromium/components/page_info/PermissionParamsListBuilder.java b/components/page_info/android/java/src/org/chromium/components/page_info/PermissionParamsListBuilder.java --- a/components/page_info/android/java/src/org/chromium/components/page_info/PermissionParamsListBuilder.java +++ b/components/page_info/android/java/src/org/chromium/components/page_info/PermissionParamsListBuilder.java -@@ -104,6 +104,7 @@ public class PermissionParamsListBuilder { +@@ -109,6 +109,7 @@ public class PermissionParamsListBuilder { permissionParams.allowed = true; break; case ContentSettingValues.BLOCK: @@ -1146,7 +1661,7 @@ diff --git a/components/page_info/android/page_info_controller_android.cc b/comp #include "components/content_settings/core/common/content_settings.h" #include "components/content_settings/core/common/content_settings_types.h" #include "components/page_info/android/jni_headers/PageInfoController_jni.h" -@@ -153,6 +154,14 @@ void PageInfoControllerAndroid::SetPermissionInfo( +@@ -151,6 +152,14 @@ void PageInfoControllerAndroid::SetPermissionInfo( ContentSettingsType::FEDERATED_IDENTITY_API); } @@ -1160,23 +1675,23 @@ diff --git a/components/page_info/android/page_info_controller_android.cc b/comp + std::map user_specified_settings_to_display; - -@@ -229,6 +238,15 @@ absl::optional PageInfoControllerAndroid::GetSettingToDisplay( - // The images content setting should show up if it is blocked globally - // to give users an easy way to create exceptions. - return permission.default_setting; -+ } else { -+ content_settings::WebsiteSettingsRegistry* website_settings = -+ content_settings::WebsiteSettingsRegistry::GetInstance(); -+ for (const content_settings::WebsiteSettingsInfo* info : *website_settings) { -+ if (info->type() == permission.type && -+ info->show_into_info_page()) { -+ return permission.default_setting; -+ } -+ } + std::map +@@ -210,6 +219,15 @@ absl::optional PageInfoControllerAndroid::GetSettingToDisplay( + return permission.setting; } - // TODO(crbug.com/1077766): Also return permissions that are non ++ content_settings::WebsiteSettingsRegistry* website_settings = ++ content_settings::WebsiteSettingsRegistry::GetInstance(); ++ for (const content_settings::WebsiteSettingsInfo* info : *website_settings) { ++ if (info->type() == permission.type && ++ info->show_into_info_page()) { ++ return permission.default_setting; ++ } ++ } ++ + // Handle exceptions for permissions which need to be displayed even if they + // are set to the default. + if (permission.type == ContentSettingsType::ADS) { diff --git a/components/page_info/page_info.cc b/components/page_info/page_info.cc --- a/components/page_info/page_info.cc +++ b/components/page_info/page_info.cc @@ -1188,10 +1703,10 @@ diff --git a/components/page_info/page_info.cc b/components/page_info/page_info. #include "components/content_settings/browser/ui/cookie_controls_controller.h" #include "components/content_settings/core/browser/content_settings_registry.h" #include "components/content_settings/core/browser/content_settings_utils.h" -@@ -172,6 +173,15 @@ bool ShouldShowPermission(const PageInfo::PermissionInfo& info, - return true; - } - +@@ -139,6 +140,14 @@ bool ShouldShowPermission(const PageInfo::PermissionInfo& info, + content::WebContents* web_contents, + bool changed_since_last_page_load, + bool is_subresource_filter_activated) { + content_settings::WebsiteSettingsRegistry* website_settings = + content_settings::WebsiteSettingsRegistry::GetInstance(); + for (const content_settings::WebsiteSettingsInfo* winfo : *website_settings) { @@ -1200,11 +1715,10 @@ diff --git a/components/page_info/page_info.cc b/components/page_info/page_info. + return true; + } + } -+ - const bool is_incognito = web_contents->GetBrowserContext()->IsOffTheRecord(); - #if BUILDFLAG(IS_ANDROID) - // Special geolocation DSE settings apply only on Android, so make sure it -@@ -1195,7 +1205,18 @@ void PageInfo::PresentSitePermissions() { + // Note |ContentSettingsType::ADS| will show up regardless of its default + // value when it has been activated on the current origin. + if (info.type == ContentSettingsType::ADS) { +@@ -1180,7 +1189,18 @@ void PageInfo::PresentSitePermissions() { PermissionInfo permission_info; HostContentSettingsMap* content_settings = GetContentSettings(); DCHECK(web_contents_); @@ -1235,7 +1749,7 @@ diff --git a/components/page_info/page_info_ui.cc b/components/page_info/page_in #include "components/omnibox/common/omnibox_features.h" #include "components/page_info/core/features.h" #include "components/page_info/page_info.h" -@@ -577,6 +578,12 @@ std::u16string PageInfoUI::PermissionTypeToUIString(ContentSettingsType type) { +@@ -574,6 +575,12 @@ std::u16string PageInfoUI::PermissionTypeToUIString(ContentSettingsType type) { if (info.type == type) return l10n_util::GetStringUTF16(info.string_id); } @@ -1248,7 +1762,7 @@ diff --git a/components/page_info/page_info_ui.cc b/components/page_info/page_in NOTREACHED(); return std::u16string(); } -@@ -588,6 +595,12 @@ std::u16string PageInfoUI::PermissionTypeToUIStringMidSentence( +@@ -585,6 +592,12 @@ std::u16string PageInfoUI::PermissionTypeToUIStringMidSentence( if (info.type == type) return l10n_util::GetStringUTF16(info.string_id_mid_sentence); } @@ -1261,7 +1775,7 @@ diff --git a/components/page_info/page_info_ui.cc b/components/page_info/page_in NOTREACHED(); return std::u16string(); } -@@ -975,6 +988,11 @@ bool PageInfoUI::ContentSettingsTypeInPageInfo(ContentSettingsType type) { +@@ -972,6 +985,11 @@ bool PageInfoUI::ContentSettingsTypeInPageInfo(ContentSettingsType type) { if (info.type == type) return true; } @@ -1273,5 +1787,75 @@ diff --git a/components/page_info/page_info_ui.cc b/components/page_info/page_in return false; } +diff --git a/third_party/blink/public/platform/web_content_settings_client.h b/third_party/blink/public/platform/web_content_settings_client.h +--- a/third_party/blink/public/platform/web_content_settings_client.h ++++ b/third_party/blink/public/platform/web_content_settings_client.h +@@ -10,6 +10,7 @@ + + #include "base/functional/callback.h" + #include "base/time/time.h" ++#include "components/content_settings/core/common/content_settings_types.h" + #include "third_party/blink/public/common/client_hints/enabled_client_hints.h" + + namespace blink { +@@ -68,6 +69,10 @@ class WebContentSettingsClient { + return enabled_per_settings; + } + ++ virtual bool AllowContentSetting(ContentSettingsType type, bool enabled_per_settings) { ++ return enabled_per_settings; ++ } ++ + // Controls whether auto dark web content is allowed for this frame. + virtual bool AllowAutoDarkWebContent(bool enabled_per_settings) { + return enabled_per_settings; +diff --git a/third_party/blink/renderer/core/execution_context/execution_context.cc b/third_party/blink/renderer/core/execution_context/execution_context.cc +--- a/third_party/blink/renderer/core/execution_context/execution_context.cc ++++ b/third_party/blink/renderer/core/execution_context/execution_context.cc +@@ -68,6 +68,22 @@ + + namespace blink { + ++blink::WebContentSettingsClient* GetContentSettingsClientFor( ++ ExecutionContext* context) { ++ blink::WebContentSettingsClient* settings = nullptr; ++ if (!context) ++ return settings; ++ if (auto* window = blink::DynamicTo(context)) { ++ auto* frame = window->GetFrame(); ++ if (frame) ++ settings = frame->GetContentSettingsClient(); ++ } else if (context->IsWorkerGlobalScope()) { ++ settings = ++ blink::To(context)->ContentSettingsClient(); ++ } ++ return settings; ++} ++ + ExecutionContext::ExecutionContext(v8::Isolate* isolate, + Agent* agent, + bool is_window) +diff --git a/third_party/blink/renderer/core/execution_context/execution_context.h b/third_party/blink/renderer/core/execution_context/execution_context.h +--- a/third_party/blink/renderer/core/execution_context/execution_context.h ++++ b/third_party/blink/renderer/core/execution_context/execution_context.h +@@ -44,6 +44,7 @@ + #include "third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom-blink-forward.h" + #include "third_party/blink/public/mojom/permissions_policy/policy_disposition.mojom-blink-forward.h" + #include "third_party/blink/public/mojom/v8_cache_options.mojom-blink-forward.h" ++#include "third_party/blink/public/platform/web_content_settings_client.h" + #include "third_party/blink/renderer/bindings/core/v8/sanitize_script_errors.h" + #include "third_party/blink/renderer/core/core_export.h" + #include "third_party/blink/renderer/core/execution_context/security_context.h" +@@ -104,6 +105,10 @@ class SecurityOrigin; + class ScriptState; + class ScriptWrappable; + class TrustedTypePolicyFactory; ++class WebContentSettingsClient; ++ ++CORE_EXPORT WebContentSettingsClient* GetContentSettingsClientFor( ++ ExecutionContext* context); + + enum ReasonForCallingCanExecuteScripts { + kAboutToExecuteScript, -- 2.25.1 diff --git a/build/patches/JIT-site-settings.patch b/build/patches/JIT-site-settings.patch index 19aca20e..69942e0b 100644 --- a/build/patches/JIT-site-settings.patch +++ b/build/patches/JIT-site-settings.patch @@ -12,71 +12,62 @@ note: needs SitePerProcess and StrictOriginIsolation flags enabled License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html --- - .../browser_ui/site_settings/android/BUILD.gn | 5 +++++ + .../browser_ui/site_settings/android/BUILD.gn | 5 + .../permission_javascript_jit.png | Bin 0 -> 433 bytes .../permission_javascript_jit.png | Bin 0 -> 377 bytes .../permission_javascript_jit.png | Bin 0 -> 518 bytes .../permission_javascript_jit.png | Bin 0 -> 629 bytes .../permission_javascript_jit.png | Bin 0 -> 797 bytes - .../res/xml/site_settings_preferences.xml | 4 ++++ - .../ContentSettingsResources.java | 7 ++++++ - .../site_settings/SingleCategorySettings.java | 9 ++++++++ - .../site_settings/SingleWebsiteSettings.java | 21 ++++++++++++++++++ - .../site_settings/SiteSettingsCategory.java | 9 ++++++-- - .../site_settings/SiteSettingsUtil.java | 1 + - .../browser_ui/site_settings/Website.java | 7 ++++++ - .../android/website_preference_bridge.cc | 1 + - .../strings/android/site_settings.grdp | 17 ++++++++++++++ - .../core/browser/content_settings_registry.cc | 2 +- - .../android/page_info_controller_android.cc | 3 +++ - components/page_info/page_info.cc | 6 +++++ - components/page_info/page_info_ui.cc | 2 ++ - components/site_settings_strings.grdp | 6 +++++ - 20 files changed, 97 insertions(+), 3 deletions(-) + .../BromiteJavascriptJITContentSetting.java | 87 ++++++++++++++++++ + .../javascript_jit.grdp | 18 ++++ + .../core/browser/content_settings_registry.cc | 8 +- + 9 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-hdpi/permission_javascript_jit.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-mdpi/permission_javascript_jit.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xhdpi/permission_javascript_jit.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xxhdpi/permission_javascript_jit.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xxxhdpi/permission_javascript_jit.png + create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteJavascriptJITContentSetting.java + create mode 100644 components/browser_ui/strings/android/bromite_content_settings/javascript_jit.grdp 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 -@@ -187,6 +187,7 @@ android_resources("java_resources") { - "java/res/drawable-hdpi/ic_volume_up_grey600_24dp.png", +@@ -203,6 +203,7 @@ android_resources("java_resources") { "java/res/drawable-hdpi/permission_background_sync.png", + "java/res/drawable-hdpi/permission_images.png", "java/res/drawable-hdpi/permission_javascript.png", + "java/res/drawable-hdpi/permission_javascript_jit.png", "java/res/drawable-hdpi/permission_popups.png", "java/res/drawable-hdpi/permission_protected_media.png", "java/res/drawable-hdpi/settings_sensors.png", -@@ -194,6 +195,7 @@ android_resources("java_resources") { - "java/res/drawable-mdpi/ic_volume_up_grey600_24dp.png", +@@ -211,6 +212,7 @@ android_resources("java_resources") { "java/res/drawable-mdpi/permission_background_sync.png", + "java/res/drawable-mdpi/permission_images.png", "java/res/drawable-mdpi/permission_javascript.png", + "java/res/drawable-mdpi/permission_javascript_jit.png", "java/res/drawable-hdpi/settings_autoplay.png", "java/res/drawable-xhdpi/settings_autoplay.png", "java/res/drawable-xxhdpi/settings_autoplay.png", -@@ -206,6 +208,7 @@ android_resources("java_resources") { - "java/res/drawable-xhdpi/ic_volume_up_grey600_24dp.png", +@@ -224,6 +226,7 @@ android_resources("java_resources") { "java/res/drawable-xhdpi/permission_background_sync.png", + "java/res/drawable-xhdpi/permission_images.png", "java/res/drawable-xhdpi/permission_javascript.png", + "java/res/drawable-xhdpi/permission_javascript_jit.png", "java/res/drawable-xhdpi/permission_popups.png", "java/res/drawable-xhdpi/permission_protected_media.png", "java/res/drawable-xhdpi/settings_sensors.png", -@@ -213,6 +216,7 @@ android_resources("java_resources") { - "java/res/drawable-xxhdpi/ic_volume_up_grey600_24dp.png", +@@ -232,6 +235,7 @@ android_resources("java_resources") { "java/res/drawable-xxhdpi/permission_background_sync.png", + "java/res/drawable-xxhdpi/permission_images.png", "java/res/drawable-xxhdpi/permission_javascript.png", + "java/res/drawable-xxhdpi/permission_javascript_jit.png", "java/res/drawable-xxhdpi/permission_popups.png", "java/res/drawable-xxhdpi/permission_protected_media.png", "java/res/drawable-xxhdpi/settings_sensors.png", -@@ -220,6 +224,7 @@ android_resources("java_resources") { - "java/res/drawable-xxxhdpi/ic_volume_up_grey600_24dp.png", +@@ -240,6 +244,7 @@ android_resources("java_resources") { "java/res/drawable-xxxhdpi/permission_background_sync.png", + "java/res/drawable-xxxhdpi/permission_images.png", "java/res/drawable-xxxhdpi/permission_javascript.png", + "java/res/drawable-xxxhdpi/permission_javascript_jit.png", "java/res/drawable-xxxhdpi/permission_popups.png", @@ -180,228 +171,125 @@ G2~7a)DNWn} literal 0 HcmV?d00001 -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 -@@ -43,6 +43,10 @@ Also add new settings to site_settings_preferences_with_categories.xml! - -+ -+ - - . ++*/ ++ ++package org.chromium.components.browser_ui.site_settings.impl; ++ ++import org.chromium.components.browser_ui.site_settings.R; ++ ++import org.chromium.components.browser_ui.site_settings.BromiteCustomContentSetting; ++import org.chromium.components.browser_ui.site_settings.ContentSettingsResources; ++import org.chromium.components.browser_ui.site_settings.SiteSettingsCategory; ++import org.chromium.components.content_settings.ContentSettingValues; ++import org.chromium.components.content_settings.ContentSettingsType; ++import org.chromium.content_public.browser.BrowserContextHandle; ++ ++import androidx.annotation.Nullable; ++import androidx.preference.Preference; ++import androidx.preference.PreferenceScreen; ++ ++import java.util.ArrayList; ++ ++public class BromiteJavascriptJITContentSetting extends BromiteCustomContentSetting { ++ public BromiteJavascriptJITContentSetting() { ++ super(/*contentSettingsType*/ ContentSettingsType.JAVASCRIPT_JIT, ++ /*defaultEnabledValue*/ ContentSettingValues.ALLOW, ++ /*defaultDisabledValue*/ ContentSettingValues.BLOCK, ++ /*allowException*/ true, ++ /*preferenceKey*/ "javascript_jit", ++ /*profilePrefKey*/ "javascript_jit"); + } + - /** - * Updates the ads list preference based on whether the site is a candidate for blocking. This - * has some custom behavior. -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 -@@ -47,7 +47,7 @@ public class SiteSettingsCategory { - Type.PROTECTED_MEDIA, Type.SENSORS, Type.SOUND, Type.USB, Type.VIRTUAL_REALITY, - Type.USE_STORAGE, Type.AUTO_DARK_WEB_CONTENT, Type.REQUEST_DESKTOP_SITE, - Type.FEDERATED_IDENTITY_API, Type.THIRD_PARTY_COOKIES, Type.SITE_DATA, Type.ANTI_ABUSE, -- Type.TIMEZONE_OVERRIDE, Type.AUTOPLAY, -+ Type.TIMEZONE_OVERRIDE, Type.AUTOPLAY, Type.JAVASCRIPT_JIT, - Type.NUM_ENTRIES}) - @Retention(RetentionPolicy.SOURCE) - public @interface Type { -@@ -84,10 +84,11 @@ public class SiteSettingsCategory { - int ANTI_ABUSE = 28; - int TIMEZONE_OVERRIDE = 29; - int AUTOPLAY = 30; -+ int JAVASCRIPT_JIT = 31; - /** - * Number of handled categories used for calculating array sizes. - */ -- int NUM_ENTRIES = 31; -+ int NUM_ENTRIES = 32; - } - - private final BrowserContextHandle mBrowserContextHandle; -@@ -198,6 +199,8 @@ public class SiteSettingsCategory { - return ContentSettingsType.IDLE_DETECTION; - case Type.JAVASCRIPT: - return ContentSettingsType.JAVASCRIPT; -+ case Type.JAVASCRIPT_JIT: -+ return ContentSettingsType.JAVASCRIPT_JIT; - case Type.MICROPHONE: - return ContentSettingsType.MEDIASTREAM_MIC; - case Type.NFC: -@@ -285,6 +288,8 @@ public class SiteSettingsCategory { - return "javascript"; - case Type.MICROPHONE: - return "microphone"; -+ case Type.JAVASCRIPT_JIT: -+ return "javascript_jit"; - case Type.NFC: - return "nfc"; - case Type.NOTIFICATIONS: -diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsUtil.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsUtil.java ---- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsUtil.java -+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsUtil.java -@@ -26,6 +26,7 @@ public class SiteSettingsUtil { - ContentSettingsType.MEDIASTREAM_MIC, - ContentSettingsType.NOTIFICATIONS, - ContentSettingsType.JAVASCRIPT, -+ ContentSettingsType.JAVASCRIPT_JIT, - ContentSettingsType.POPUPS, - ContentSettingsType.ADS, - ContentSettingsType.BACKGROUND_SYNC, -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 -@@ -230,6 +230,13 @@ public final class Website implements WebsiteEntry { - } else { - RecordUserAction.record("JavascriptContentSetting.DisableBy.SiteSettings"); - } -+ } else if (type == ContentSettingsType.JAVASCRIPT_JIT) { -+ if (exception == null) { -+ exception = new ContentSettingException( -+ ContentSettingsType.JAVASCRIPT_JIT, getAddress().getHost(), value, "", -+ /*isEmbargoed=*/false); -+ setContentSettingException(type, exception); -+ } - } else if (type == ContentSettingsType.AUTOPLAY) { - // It is possible to set the permission without having an existing exception, - // because we always show the autoplay permission in Site Settings. -diff --git a/components/browser_ui/site_settings/android/website_preference_bridge.cc b/components/browser_ui/site_settings/android/website_preference_bridge.cc ---- a/components/browser_ui/site_settings/android/website_preference_bridge.cc -+++ b/components/browser_ui/site_settings/android/website_preference_bridge.cc -@@ -823,6 +823,7 @@ static void JNI_WebsitePreferenceBridge_SetContentSettingEnabled( - case ContentSettingsType::COOKIES: - case ContentSettingsType::FEDERATED_IDENTITY_API: - case ContentSettingsType::JAVASCRIPT: -+ case ContentSettingsType::JAVASCRIPT_JIT: - case ContentSettingsType::POPUPS: - case ContentSettingsType::REQUEST_DESKTOP_SITE: - case ContentSettingsType::SENSORS: -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 -@@ -79,6 +79,9 @@ - - JavaScript - ++ @Override ++ public ContentSettingsResources.ResourceItem getResourceItem() { ++ return new ContentSettingsResources.ResourceItem( ++ /*icon*/ R.drawable.web_asset, ++ /*title*/ R.string.javascript_jit_permission_title, ++ /*defaultEnabledValue*/ getDefaultEnabledValue(), ++ /*defaultDisabledValue*/ getDefaultDisabledValue(), ++ /*enabledSummary*/ R.string.website_settings_category_javascript_jit_enabled, ++ /*disabledSummary*/ R.string.website_settings_category_javascript_jit_disabled); ++ } ++ ++ @Override ++ public int getCategorySummary(@Nullable @ContentSettingValues int value) { ++ switch (value) { ++ case ContentSettingValues.ALLOW: ++ return R.string.website_settings_category_javascript_jit_enabled; ++ case ContentSettingValues.BLOCK: ++ return R.string.website_settings_category_javascript_jit_disabled; ++ default: ++ return 0; ++ } ++ } ++ ++ @Override ++ public boolean requiresTriStateContentSetting() { ++ return false; ++ } ++ ++ @Override ++ public boolean showOnlyDescriptions() { ++ return true; ++ } ++ ++ @Override ++ public int getAddExceptionDialogMessage() { ++ return R.string.website_settings_category_javascript_jit_enabled; ++ } ++ ++ @Override ++ public @Nullable Boolean considerException(SiteSettingsCategory category, @ContentSettingValues int value) { ++ return value != ContentSettingValues.BLOCK; ++ } ++} +diff --git a/components/browser_ui/strings/android/bromite_content_settings/javascript_jit.grdp b/components/browser_ui/strings/android/bromite_content_settings/javascript_jit.grdp +new file mode 100644 +--- /dev/null ++++ b/components/browser_ui/strings/android/bromite_content_settings/javascript_jit.grdp +@@ -0,0 +1,18 @@ ++ ++ + + JavaScript JIT + - - Location - -@@ -658,6 +661,20 @@ - Block JavaScript for a specific site. - - -+ -+ -+ Allow sites to use just-in-time compilation; more performant but a constant source of security vulnerabilities. -+ -+ -+ Block sites from using just-in-time compilation, using only interpreted JavaScript; less performant but more secure against security vulnerabilities. -+ -+ ++ + Allow JIT on a specific site. + -+ ++ + Block JIT on a specific site. + -+ - - - ++ ++ Allow sites to use just-in-time compilation; more performant but a constant source of security vulnerabilities. ++ ++ ++ Block sites from using just-in-time compilation, using only interpreted JavaScript; less performant but more secure against security vulnerabilities. ++ ++ 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 -@@ -508,7 +508,7 @@ void ContentSettingsRegistry::Init() { +@@ -518,14 +518,18 @@ void ContentSettingsRegistry::Init() { ContentSettingsInfo::EXCEPTIONS_ON_SECURE_ORIGINS_ONLY); Register(ContentSettingsType::JAVASCRIPT_JIT, "javascript-jit", @@ -410,76 +298,17 @@ diff --git a/components/content_settings/core/browser/content_settings_registry. /*allowlisted_schemes=*/{}, /*valid_settings=*/{CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK}, WebsiteSettingsInfo::TOP_ORIGIN_ONLY_SCOPE, -diff --git a/components/page_info/android/page_info_controller_android.cc b/components/page_info/android/page_info_controller_android.cc ---- a/components/page_info/android/page_info_controller_android.cc -+++ b/components/page_info/android/page_info_controller_android.cc -@@ -134,6 +134,7 @@ void PageInfoControllerAndroid::SetPermissionInfo( - permissions_to_display.push_back(ContentSettingsType::IDLE_DETECTION); - permissions_to_display.push_back(ContentSettingsType::IMAGES); - permissions_to_display.push_back(ContentSettingsType::JAVASCRIPT); -+ permissions_to_display.push_back(ContentSettingsType::JAVASCRIPT_JIT); - permissions_to_display.push_back(ContentSettingsType::POPUPS); - permissions_to_display.push_back(ContentSettingsType::ADS); - permissions_to_display.push_back( -@@ -217,6 +218,8 @@ absl::optional PageInfoControllerAndroid::GetSettingToDisplay( - // The javascript content setting should show up if it is blocked globally - // to give users an easy way to create exceptions. - return permission.default_setting; -+ } else if (permission.type == ContentSettingsType::JAVASCRIPT_JIT) { -+ return permission.default_setting; - } else if (permission.type == ContentSettingsType::SOUND) { - // The sound content setting should always show up when the tab has played - // audio since last navigation. -diff --git a/components/page_info/page_info.cc b/components/page_info/page_info.cc ---- a/components/page_info/page_info.cc -+++ b/components/page_info/page_info.cc -@@ -130,6 +130,7 @@ ContentSettingsType kPermissionType[] = { - ContentSettingsType::AR, - ContentSettingsType::IDLE_DETECTION, - ContentSettingsType::FEDERATED_IDENTITY_API, -+ ContentSettingsType::JAVASCRIPT_JIT, - }; + WebsiteSettingsRegistry::DESKTOP | + WebsiteSettingsRegistry::PLATFORM_ANDROID, + ContentSettingsInfo::INHERIT_IN_INCOGNITO, +- ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); ++ ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS, ++ /*show_into_info_page*/ true, ++ /*is_renderer_content_setting*/ true, ++ /*permission_type_ui*/ IDS_JAVASCRIPT_JIT_PERMISSION_TITLE, ++ /*permission_type_ui_mid_sentence*/ IDS_JAVASCRIPT_JIT_PERMISSION_TITLE); - // Determines whether to show permission |type| in the Page Info UI. Only -@@ -163,6 +164,11 @@ bool ShouldShowPermission(const PageInfo::PermissionInfo& info, - return true; - } - -+ // Always show JIT settings UI when when it has a site-specific override. -+ if (info.type == ContentSettingsType::JAVASCRIPT_JIT) { -+ return true; -+ } -+ - const bool is_incognito = web_contents->GetBrowserContext()->IsOffTheRecord(); - #if BUILDFLAG(IS_ANDROID) - // Special geolocation DSE settings apply only on Android, so make sure it -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 -@@ -137,6 +137,8 @@ base::span GetContentSettingsUIInfo() { - IDS_SITE_SETTINGS_TYPE_COOKIES_MID_SENTENCE}, - {ContentSettingsType::JAVASCRIPT, IDS_SITE_SETTINGS_TYPE_JAVASCRIPT, - IDS_SITE_SETTINGS_TYPE_JAVASCRIPT_MID_SENTENCE}, -+ {ContentSettingsType::JAVASCRIPT_JIT, IDS_SITE_SETTINGS_TYPE_JAVASCRIPT_JIT, -+ IDS_SITE_SETTINGS_TYPE_JAVASCRIPT_JIT_MID_SENTENCE}, - {ContentSettingsType::POPUPS, IDS_SITE_SETTINGS_TYPE_POPUPS_REDIRECTS, - IDS_SITE_SETTINGS_TYPE_POPUPS_REDIRECTS_MID_SENTENCE}, - {ContentSettingsType::GEOLOCATION, IDS_SITE_SETTINGS_TYPE_LOCATION, -diff --git a/components/site_settings_strings.grdp b/components/site_settings_strings.grdp ---- a/components/site_settings_strings.grdp -+++ b/components/site_settings_strings.grdp -@@ -82,6 +82,12 @@ - - javascript - -+ -+ JavaScript JIT -+ -+ -+ javascript JIT -+ - - Location - + Register(ContentSettingsType::PRIVATE_NETWORK_GUARD, "private-network-guard", + CONTENT_SETTING_ASK, WebsiteSettingsInfo::UNSYNCABLE, -- 2.25.1 diff --git a/build/patches/Revert-the-removal-of-an-option-to-block-autoplay.patch b/build/patches/Revert-the-removal-of-an-option-to-block-autoplay.patch index 644e6699..0c83f3ae 100644 --- a/build/patches/Revert-the-removal-of-an-option-to-block-autoplay.patch +++ b/build/patches/Revert-the-removal-of-an-option-to-block-autoplay.patch @@ -5,48 +5,30 @@ Subject: Revert the removal of an option to block autoplay Original License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html --- - .../browser_ui/site_settings/android/BUILD.gn | 5 ++++ + .../browser_ui/site_settings/android/BUILD.gn | 5 + .../res/drawable-hdpi/settings_autoplay.png | Bin 0 -> 456 bytes .../res/drawable-mdpi/settings_autoplay.png | Bin 0 -> 296 bytes .../res/drawable-xhdpi/settings_autoplay.png | Bin 0 -> 551 bytes .../res/drawable-xxhdpi/settings_autoplay.png | Bin 0 -> 792 bytes .../drawable-xxxhdpi/settings_autoplay.png | Bin 0 -> 1064 bytes - .../res/xml/site_settings_preferences.xml | 4 ++++ - .../ContentSettingsResources.java | 5 +++- - .../site_settings/SingleCategorySettings.java | 9 +++++++ - .../site_settings/SingleWebsiteSettings.java | 22 ++++++++++++++++++ - .../site_settings/SiteSettingsCategory.java | 9 +++++-- - .../browser_ui/site_settings/Website.java | 9 +++++++ - .../WebsitePermissionsFetcher.java | 1 + - .../android/website_preference_bridge.cc | 1 + - .../strings/android/site_settings.grdp | 9 +++++++ - .../core/browser/content_settings_registry.cc | 2 +- - .../core/browser/content_settings_utils.cc | 2 ++ - .../core/common/content_settings.cc | 2 ++ - .../core/common/content_settings.h | 1 + - .../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.h | 1 + - .../android/page_info_controller_android.cc | 1 + - components/page_info/page_info.cc | 6 +++++ - components/page_info/page_info_ui.cc | 1 + - components/site_settings_strings.grdp | 3 +++ - .../platform/web_content_settings_client.h | 3 +++ - .../core/html/media/autoplay_policy.cc | 12 ++++++++++ - .../core/html/media/autoplay_policy.h | 4 ++++ - 31 files changed, 126 insertions(+), 4 deletions(-) + .../impl/BromiteAutoplayContentSetting.java | 87 ++++++++++++++++++ + .../bromite_content_settings/autoplay.grdp | 15 +++ + .../core/browser/content_settings_registry.cc | 8 +- + .../core/html/media/autoplay_policy.cc | 14 +++ + .../core/html/media/autoplay_policy.h | 4 + + 11 files changed, 131 insertions(+), 2 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 create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xxhdpi/settings_autoplay.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xxxhdpi/settings_autoplay.png + create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteAutoplayContentSetting.java + create mode 100644 components/browser_ui/strings/android/bromite_content_settings/autoplay.grdp 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 -@@ -194,6 +194,11 @@ android_resources("java_resources") { +@@ -209,6 +209,11 @@ android_resources("java_resources") { "java/res/drawable-mdpi/ic_volume_up_grey600_24dp.png", "java/res/drawable-mdpi/permission_background_sync.png", "java/res/drawable-mdpi/permission_javascript.png", @@ -166,214 +148,122 @@ ib6hJ{tXQ#P#rX?0El=KlH_u1_0000 -+ -+ - - . ++*/ ++ ++package org.chromium.components.browser_ui.site_settings.impl; ++ ++import org.chromium.components.browser_ui.site_settings.R; ++ ++import org.chromium.components.browser_ui.site_settings.BromiteCustomContentSetting; ++import org.chromium.components.browser_ui.site_settings.ContentSettingsResources; ++import org.chromium.components.browser_ui.site_settings.SiteSettingsCategory; ++import org.chromium.components.content_settings.ContentSettingValues; ++import org.chromium.components.content_settings.ContentSettingsType; ++import org.chromium.content_public.browser.BrowserContextHandle; ++ ++import androidx.annotation.Nullable; ++import androidx.preference.Preference; ++import androidx.preference.PreferenceScreen; ++ ++import java.util.ArrayList; ++ ++public class BromiteAutoplayContentSetting extends BromiteCustomContentSetting { ++ public BromiteAutoplayContentSetting() { ++ super(/*contentSettingsType*/ ContentSettingsType.AUTOPLAY, ++ /*defaultEnabledValue*/ ContentSettingValues.ALLOW, ++ /*defaultDisabledValue*/ ContentSettingValues.BLOCK, ++ /*allowException*/ true, ++ /*preferenceKey*/ "autoplay", ++ /*profilePrefKey*/ "autoplay"); + } + - private void setUpJavascriptPreference(Preference preference) { - BrowserContextHandle browserContextHandle = - 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 -@@ -47,7 +47,7 @@ public class SiteSettingsCategory { - Type.PROTECTED_MEDIA, Type.SENSORS, Type.SOUND, Type.USB, Type.VIRTUAL_REALITY, - Type.USE_STORAGE, Type.AUTO_DARK_WEB_CONTENT, Type.REQUEST_DESKTOP_SITE, - Type.FEDERATED_IDENTITY_API, Type.THIRD_PARTY_COOKIES, Type.SITE_DATA, Type.ANTI_ABUSE, -- Type.TIMEZONE_OVERRIDE, -+ Type.TIMEZONE_OVERRIDE, Type.AUTOPLAY, - Type.NUM_ENTRIES}) - @Retention(RetentionPolicy.SOURCE) - public @interface Type { -@@ -83,10 +83,11 @@ public class SiteSettingsCategory { - int SITE_DATA = 27; - int ANTI_ABUSE = 28; - int TIMEZONE_OVERRIDE = 29; -+ int AUTOPLAY = 30; - /** - * Number of handled categories used for calculating array sizes. - */ -- int NUM_ENTRIES = 30; -+ int NUM_ENTRIES = 31; - } - - private final BrowserContextHandle mBrowserContextHandle; -@@ -203,6 +204,8 @@ public class SiteSettingsCategory { - return ContentSettingsType.NFC; - case Type.NOTIFICATIONS: - return ContentSettingsType.NOTIFICATIONS; -+ case Type.AUTOPLAY: -+ return ContentSettingsType.AUTOPLAY; - case Type.POPUPS: - return ContentSettingsType.POPUPS; - case Type.PROTECTED_MEDIA: -@@ -286,6 +289,8 @@ public class SiteSettingsCategory { - return "nfc"; - case Type.NOTIFICATIONS: - return "notifications"; -+ case Type.AUTOPLAY: -+ return "autoplay"; - case Type.POPUPS: - return "popups"; - case Type.PROTECTED_MEDIA: -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 -@@ -230,6 +230,15 @@ public final class Website implements WebsiteEntry { - } else { - RecordUserAction.record("JavascriptContentSetting.DisableBy.SiteSettings"); - } -+ } else if (type == ContentSettingsType.AUTOPLAY) { -+ // It is possible to set the permission without having an existing exception, -+ // because we always show the autoplay permission in Site Settings. -+ if (exception == null) { -+ exception = new ContentSettingException( -+ ContentSettingsType.AUTOPLAY, getAddress().getHost(), value, "", -+ /*isEmbargoed=*/false); -+ setContentSettingException(type, exception); -+ } - } else if (type == ContentSettingsType.SOUND) { - // It is possible to set the permission without having an existing exception, - // because we always show the sound permission in Site Settings. -diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java ---- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java -+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java -@@ -68,6 +68,7 @@ public class WebsitePermissionsFetcher { - case ContentSettingsType.AUTOMATIC_DOWNLOADS: - case ContentSettingsType.BACKGROUND_SYNC: - case ContentSettingsType.BLUETOOTH_SCANNING: -+ case ContentSettingsType.AUTOPLAY: - case ContentSettingsType.COOKIES: - case ContentSettingsType.FEDERATED_IDENTITY_API: - case ContentSettingsType.JAVASCRIPT: -diff --git a/components/browser_ui/site_settings/android/website_preference_bridge.cc b/components/browser_ui/site_settings/android/website_preference_bridge.cc ---- a/components/browser_ui/site_settings/android/website_preference_bridge.cc -+++ b/components/browser_ui/site_settings/android/website_preference_bridge.cc -@@ -827,6 +827,7 @@ static void JNI_WebsitePreferenceBridge_SetContentSettingEnabled( - case ContentSettingsType::REQUEST_DESKTOP_SITE: - case ContentSettingsType::SENSORS: - case ContentSettingsType::SOUND: -+ case ContentSettingsType::AUTOPLAY: - value = CONTENT_SETTING_ALLOW; - break; - default: -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 -@@ -22,6 +22,15 @@ - - Auto-verify - -+ ++ @Override ++ public ContentSettingsResources.ResourceItem getResourceItem() { ++ return new ContentSettingsResources.ResourceItem( ++ /*icon*/ R.drawable.web_asset, ++ /*title*/ R.string.autoplay_permission_title, ++ /*defaultEnabledValue*/ getDefaultEnabledValue(), ++ /*defaultDisabledValue*/ getDefaultDisabledValue(), ++ /*enabledSummary*/ R.string.website_settings_category_autoplay_enabled, ++ /*disabledSummary*/ R.string.website_settings_category_autoplay_disabled); ++ } ++ ++ @Override ++ public int getCategorySummary(@Nullable @ContentSettingValues int value) { ++ switch (value) { ++ case ContentSettingValues.ALLOW: ++ return R.string.website_settings_category_autoplay_enabled; ++ case ContentSettingValues.BLOCK: ++ return R.string.website_settings_category_autoplay_disabled; ++ default: ++ return 0; ++ } ++ } ++ ++ @Override ++ public boolean requiresTriStateContentSetting() { ++ return false; ++ } ++ ++ @Override ++ public boolean showOnlyDescriptions() { ++ return true; ++ } ++ ++ @Override ++ public int getAddExceptionDialogMessage() { ++ return R.string.website_settings_category_autoplay_enabled; ++ } ++ ++ @Override ++ public @Nullable Boolean considerException(SiteSettingsCategory category, @ContentSettingValues int value) { ++ return value != ContentSettingValues.BLOCK; ++ } ++} +diff --git a/components/browser_ui/strings/android/bromite_content_settings/autoplay.grdp b/components/browser_ui/strings/android/bromite_content_settings/autoplay.grdp +new file mode 100644 +--- /dev/null ++++ b/components/browser_ui/strings/android/bromite_content_settings/autoplay.grdp +@@ -0,0 +1,15 @@ ++ ++ ++ + Autoplay + + -+ Allow autoplay of muted videos for a specific site. ++ Allow autoplay for a specific site. + -+ -+ Allow sites to automatically play muted videos (recommended) ++ ++ Allow sites to automatically play muted videos + - - Augmented reality - ++ ++ Autoplay disabled ++ ++ 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 -@@ -236,7 +236,7 @@ void ContentSettingsRegistry::Init() { +@@ -238,14 +238,18 @@ void ContentSettingsRegistry::Init() { ContentSettingsInfo::INHERIT_IN_INCOGNITO, ContentSettingsInfo::EXCEPTIONS_ON_SECURE_ORIGINS_ONLY); @@ -382,188 +272,18 @@ diff --git a/components/content_settings/core/browser/content_settings_registry. WebsiteSettingsInfo::UNSYNCABLE, /*allowlisted_schemes=*/{}, /*valid_settings=*/{CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK}, WebsiteSettingsInfo::TOP_ORIGIN_ONLY_SCOPE, -diff --git a/components/content_settings/core/browser/content_settings_utils.cc b/components/content_settings/core/browser/content_settings_utils.cc ---- a/components/content_settings/core/browser/content_settings_utils.cc -+++ b/components/content_settings/core/browser/content_settings_utils.cc -@@ -151,6 +151,8 @@ void GetRendererContentSettingRules(const HostContentSettingsMap* map, - #endif - map->GetSettingsForOneType(ContentSettingsType::JAVASCRIPT, - &(rules->script_rules)); -+ map->GetSettingsForOneType(ContentSettingsType::AUTOPLAY, -+ &(rules->autoplay_rules)); - map->GetSettingsForOneType(ContentSettingsType::POPUPS, - &(rules->popup_redirect_rules)); + WebsiteSettingsRegistry::DESKTOP | + WebsiteSettingsRegistry::PLATFORM_ANDROID, + ContentSettingsInfo::INHERIT_IN_INCOGNITO, +- ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); ++ ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS, ++ /*show_into_info_page*/ false, ++ /*is_renderer_content_setting*/ true, ++ /*permission_type_ui*/ IDS_AUTOPLAY_PERMISSION_TITLE, ++ /*permission_type_ui_mid_sentence*/ IDS_AUTOPLAY_PERMISSION_TITLE); -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 -@@ -215,6 +215,7 @@ bool RendererContentSettingRules::IsRendererContentSetting( - return content_type == ContentSettingsType::IMAGES || - content_type == ContentSettingsType::JAVASCRIPT || - content_type == ContentSettingsType::POPUPS || -+ content_type == ContentSettingsType::AUTOPLAY || - content_type == ContentSettingsType::MIXEDSCRIPT || - content_type == ContentSettingsType::AUTO_DARK_WEB_CONTENT || - content_type == ContentSettingsType::TIMEZONE_OVERRIDE; -@@ -228,6 +229,7 @@ void RendererContentSettingRules::FilterRulesByOutermostMainFrameURL( - FilterRulesForType(mixed_content_rules, outermost_main_frame_url); - FilterRulesForType(auto_dark_content_rules, outermost_main_frame_url); - FilterRulesForType(timezone_override_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 ---- a/components/content_settings/core/common/content_settings.h -+++ b/components/content_settings/core/common/content_settings.h -@@ -90,6 +90,7 @@ struct RendererContentSettingRules { - - ContentSettingsForOneType image_rules; - ContentSettingsForOneType script_rules; -+ ContentSettingsForOneType autoplay_rules; - ContentSettingsForOneType popup_redirect_rules; - ContentSettingsForOneType mixed_content_rules; - ContentSettingsForOneType auto_dark_content_rules; -diff --git a/components/content_settings/core/common/content_settings.mojom b/components/content_settings/core/common/content_settings.mojom ---- a/components/content_settings/core/common/content_settings.mojom -+++ b/components/content_settings/core/common/content_settings.mojom -@@ -75,6 +75,7 @@ struct ContentSettingPatternSource { - struct RendererContentSettingRules { - array image_rules; - array script_rules; -+ array autoplay_rules; - array popup_redirect_rules; - array mixed_content_rules; - array auto_dark_content_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 ---- a/components/content_settings/core/common/content_settings_mojom_traits.cc -+++ b/components/content_settings/core/common/content_settings_mojom_traits.cc -@@ -100,6 +100,7 @@ bool StructTraitsimage_rules) && - data.ReadScriptRules(&out->script_rules) && -+ data.ReadAutoplayRules(&out->autoplay_rules) && - data.ReadPopupRedirectRules(&out->popup_redirect_rules) && - data.ReadMixedContentRules(&out->mixed_content_rules) && - data.ReadAutoDarkContentRules(&out->auto_dark_content_rules) && -diff --git a/components/content_settings/core/common/content_settings_mojom_traits.h b/components/content_settings/core/common/content_settings_mojom_traits.h ---- a/components/content_settings/core/common/content_settings_mojom_traits.h -+++ b/components/content_settings/core/common/content_settings_mojom_traits.h -@@ -135,6 +135,11 @@ struct StructTraits< - return r.script_rules; - } - -+ static const std::vector& autoplay_rules( -+ const RendererContentSettingRules& r) { -+ return r.autoplay_rules; -+ } -+ - static const std::vector& popup_redirect_rules( - const RendererContentSettingRules& r) { - return r.popup_redirect_rules; -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 -@@ -388,6 +388,17 @@ bool ContentSettingsAgentImpl::AllowRunningInsecureContent( - return false; - } - -+bool ContentSettingsAgentImpl::AllowAutoplay(bool default_value) { -+ if (!content_setting_rules_) -+ return default_value; -+ -+ blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); -+ return GetContentSettingFromRules( -+ content_setting_rules_->autoplay_rules, -+ url::Origin(frame->GetDocument().GetSecurityOrigin()).GetURL()) == -+ CONTENT_SETTING_ALLOW; -+} -+ - bool ContentSettingsAgentImpl::AllowPopupsAndRedirects(bool default_value) { - if (!content_setting_rules_) - return default_value; -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 - void DidNotAllowScript() override; - bool AllowRunningInsecureContent(bool allowed_per_settings, - const blink::WebURL& url) override; -+ bool AllowAutoplay(bool default_value) override; - bool AllowPopupsAndRedirects(bool default_value) override; - bool ShouldAutoupgradeMixedContent() override; - -diff --git a/components/page_info/android/page_info_controller_android.cc b/components/page_info/android/page_info_controller_android.cc ---- a/components/page_info/android/page_info_controller_android.cc -+++ b/components/page_info/android/page_info_controller_android.cc -@@ -138,6 +138,7 @@ void PageInfoControllerAndroid::SetPermissionInfo( - permissions_to_display.push_back(ContentSettingsType::ADS); - permissions_to_display.push_back( - ContentSettingsType::PROTECTED_MEDIA_IDENTIFIER); -+ permissions_to_display.push_back(ContentSettingsType::AUTOPLAY); - permissions_to_display.push_back(ContentSettingsType::SOUND); - if (base::FeatureList::IsEnabled(features::kWebNfc)) - permissions_to_display.push_back(ContentSettingsType::NFC); -diff --git a/components/page_info/page_info.cc b/components/page_info/page_info.cc ---- a/components/page_info/page_info.cc -+++ b/components/page_info/page_info.cc -@@ -107,6 +107,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, -@@ -150,6 +151,11 @@ bool ShouldShowPermission(const PageInfo::PermissionInfo& info, - return is_subresource_filter_activated; - } - -+ // Always show autoplay when it has a site-specific override -+ if (info.type == ContentSettingsType::AUTOPLAY) { -+ return true; -+ } -+ - if (info.type == ContentSettingsType::SOUND) { - // The sound content setting should always show up when the tab has played - // audio. -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 -@@ -162,6 +162,7 @@ base::span GetContentSettingsUIInfo() { - #endif - {ContentSettingsType::ADS, IDS_SITE_SETTINGS_TYPE_ADS, - IDS_SITE_SETTINGS_TYPE_ADS_MID_SENTENCE}, -+ {ContentSettingsType::AUTOPLAY, IDS_SITE_SETTINGS_TYPE_AUTOPLAY}, - {ContentSettingsType::SOUND, IDS_SITE_SETTINGS_TYPE_SOUND, - IDS_SITE_SETTINGS_TYPE_SOUND_MID_SENTENCE}, - {ContentSettingsType::CLIPBOARD_READ_WRITE, -diff --git a/components/site_settings_strings.grdp b/components/site_settings_strings.grdp ---- a/components/site_settings_strings.grdp -+++ b/components/site_settings_strings.grdp -@@ -139,6 +139,9 @@ - - Sound - -+ -+ Autoplay -+ - - sound - -diff --git a/third_party/blink/public/platform/web_content_settings_client.h b/third_party/blink/public/platform/web_content_settings_client.h ---- a/third_party/blink/public/platform/web_content_settings_client.h -+++ b/third_party/blink/public/platform/web_content_settings_client.h -@@ -92,6 +92,9 @@ class WebContentSettingsClient { - // interface. - virtual bool AllowMutationEvents(bool default_value) { return default_value; } - -+ // Controls whether autoplay is allowed for this frame. -+ virtual bool AllowAutoplay(bool default_value) { return default_value; } -+ - virtual bool AllowPopupsAndRedirects(bool default_value) { - return default_value; - } + Register(ContentSettingsType::SOUND, "sound", CONTENT_SETTING_ALLOW, + WebsiteSettingsInfo::UNSYNCABLE, /*allowlisted_schemes=*/{}, diff --git a/third_party/blink/renderer/core/html/media/autoplay_policy.cc b/third_party/blink/renderer/core/html/media/autoplay_policy.cc --- a/third_party/blink/renderer/core/html/media/autoplay_policy.cc +++ b/third_party/blink/renderer/core/html/media/autoplay_policy.cc @@ -584,7 +304,7 @@ diff --git a/third_party/blink/renderer/core/html/media/autoplay_policy.cc b/thi if (!IsLockedPendingUserGesture()) return false; -@@ -408,6 +411,15 @@ void AutoplayPolicy::MaybeSetAutoplayInitiated() { +@@ -408,6 +411,17 @@ void AutoplayPolicy::MaybeSetAutoplayInitiated() { } } @@ -592,8 +312,10 @@ diff --git a/third_party/blink/renderer/core/html/media/autoplay_policy.cc b/thi + LocalFrame* frame = element_->GetDocument().GetFrame(); + if (!frame) + return false; -+ if (auto* settings_client = frame->GetContentSettingsClient()) -+ return settings_client->AllowAutoplay(false /* default_value */); ++ if (auto* settings_client = frame->GetContentSettingsClient()) { ++ return settings_client->AllowContentSetting( ++ ContentSettingsType::AUTOPLAY, /*default_value*/ false); ++ } + return true; +} + diff --git a/build/patches/Show-site-settings-for-cookies-javascript-and-ads.patch b/build/patches/Show-site-settings-for-cookies-javascript-and-ads.patch index 1e16e2bb..ff04be6e 100644 --- a/build/patches/Show-site-settings-for-cookies-javascript-and-ads.patch +++ b/build/patches/Show-site-settings-for-cookies-javascript-and-ads.patch @@ -13,7 +13,7 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html 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 -@@ -524,6 +524,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment +@@ -517,6 +517,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment setUpSoundPreference(preference); } else if (type == ContentSettingsType.JAVASCRIPT) { setUpJavascriptPreference(preference); @@ -21,8 +21,8 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c + setUpCookiesPreference(preference); } else if (type == ContentSettingsType.GEOLOCATION) { setUpLocationPreference(preference); - } else if (type == ContentSettingsType.IMAGES) { -@@ -882,16 +884,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment + } else if (type == ContentSettingsType.NOTIFICATIONS) { +@@ -876,16 +878,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment private void setUpAdsInformationalBanner() { // Add the informational banner which shows at the top of the UI if ad blocking is // activated on this site. @@ -39,7 +39,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c } private SiteSettingsCategory getWarningCategory() { -@@ -1077,17 +1071,35 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment +@@ -1057,17 +1051,35 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment @Nullable Integer currentValue = mSite.getContentSetting(browserContextHandle, ContentSettingsType.JAVASCRIPT); @@ -78,10 +78,10 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c + setupContentSettingsPreference(preference, currentValue, false /* isEmbargoed */); + } + - private void setUpJavascriptJitPreference(Preference preference) { - BrowserContextHandle browserContextHandle = - getSiteSettingsDelegate().getBrowserContextHandle(); -@@ -1120,22 +1132,10 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment + /** + * Updates the ads list preference based on whether the site is a candidate for blocking. This + * has some custom behavior. +@@ -1083,22 +1095,10 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment setupContentSettingsPreference(preference, null, false); return; } diff --git a/build/patches/Site-setting-for-images.patch b/build/patches/Site-setting-for-images.patch index 1f16fdce..6f303ba6 100644 --- a/build/patches/Site-setting-for-images.patch +++ b/build/patches/Site-setting-for-images.patch @@ -5,78 +5,68 @@ Subject: Site setting for images Original License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html --- - .../browser_ui/site_settings/android/BUILD.gn | 5 ++++ + .../browser_ui/site_settings/android/BUILD.gn | 5 + .../res/drawable-hdpi/permission_images.png | Bin 0 -> 257 bytes .../res/drawable-mdpi/permission_images.png | Bin 0 -> 186 bytes .../res/drawable-xhdpi/permission_images.png | Bin 0 -> 316 bytes .../res/drawable-xxhdpi/permission_images.png | Bin 0 -> 449 bytes .../drawable-xxxhdpi/permission_images.png | Bin 0 -> 532 bytes - .../res/xml/site_settings_preferences.xml | 4 ++++ - .../ContentSettingsResources.java | 4 ++++ - .../site_settings/SingleCategorySettings.java | 9 +++++++ - .../site_settings/SingleWebsiteSettings.java | 22 ++++++++++++++++++ - .../site_settings/SiteSettingsCategory.java | 9 +++++-- - .../site_settings/SiteSettingsUtil.java | 1 + - .../browser_ui/site_settings/Website.java | 7 ++++++ - .../WebsitePermissionsFetcher.java | 1 + - .../android/website_preference_bridge.cc | 1 + - .../strings/android/site_settings.grdp | 6 +++++ - .../core/browser/content_settings_registry.cc | 3 ++- - .../core/browser/content_settings_utils.cc | 8 ++----- - .../android/page_info_controller_android.cc | 4 ++++ - components/page_info/page_info.cc | 7 ++++-- - components/page_info/page_info_ui.cc | 4 ++-- - components/site_settings_strings.grdp | 12 +++++----- - 22 files changed, 88 insertions(+), 19 deletions(-) + .../impl/BromiteImagesContentSetting.java | 87 ++++++++++++++++++ + .../bromite_content_settings/images.grdp | 23 +++++ + .../core/browser/content_settings_registry.cc | 8 +- + .../core/browser/content_settings_utils.cc | 8 +- + 10 files changed, 123 insertions(+), 8 deletions(-) create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-hdpi/permission_images.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-mdpi/permission_images.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xhdpi/permission_images.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xxhdpi/permission_images.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xxxhdpi/permission_images.png + create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteImagesContentSetting.java + create mode 100644 components/browser_ui/strings/android/bromite_content_settings/images.grdp 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 -@@ -186,6 +186,7 @@ android_resources("java_resources") { +@@ -201,6 +201,7 @@ android_resources("java_resources") { sources = [ "java/res/drawable-hdpi/ic_volume_up_grey600_24dp.png", "java/res/drawable-hdpi/permission_background_sync.png", + "java/res/drawable-hdpi/permission_images.png", "java/res/drawable-hdpi/permission_javascript.png", - "java/res/drawable-hdpi/permission_javascript_jit.png", "java/res/drawable-hdpi/permission_popups.png", -@@ -194,6 +195,7 @@ android_resources("java_resources") { + "java/res/drawable-hdpi/permission_protected_media.png", +@@ -208,6 +209,7 @@ android_resources("java_resources") { "java/res/drawable-hdpi/web_asset.png", "java/res/drawable-mdpi/ic_volume_up_grey600_24dp.png", "java/res/drawable-mdpi/permission_background_sync.png", + "java/res/drawable-mdpi/permission_images.png", "java/res/drawable-mdpi/permission_javascript.png", - "java/res/drawable-mdpi/permission_javascript_jit.png", "java/res/drawable-hdpi/settings_autoplay.png", -@@ -207,6 +209,7 @@ android_resources("java_resources") { + "java/res/drawable-xhdpi/settings_autoplay.png", +@@ -220,6 +222,7 @@ android_resources("java_resources") { "java/res/drawable-mdpi/web_asset.png", "java/res/drawable-xhdpi/ic_volume_up_grey600_24dp.png", "java/res/drawable-xhdpi/permission_background_sync.png", + "java/res/drawable-xhdpi/permission_images.png", "java/res/drawable-xhdpi/permission_javascript.png", - "java/res/drawable-xhdpi/permission_javascript_jit.png", "java/res/drawable-xhdpi/permission_popups.png", -@@ -215,6 +218,7 @@ android_resources("java_resources") { + "java/res/drawable-xhdpi/permission_protected_media.png", +@@ -227,6 +230,7 @@ android_resources("java_resources") { "java/res/drawable-xhdpi/web_asset.png", "java/res/drawable-xxhdpi/ic_volume_up_grey600_24dp.png", "java/res/drawable-xxhdpi/permission_background_sync.png", + "java/res/drawable-xxhdpi/permission_images.png", "java/res/drawable-xxhdpi/permission_javascript.png", - "java/res/drawable-xxhdpi/permission_javascript_jit.png", "java/res/drawable-xxhdpi/permission_popups.png", -@@ -223,6 +227,7 @@ android_resources("java_resources") { + "java/res/drawable-xxhdpi/permission_protected_media.png", +@@ -234,6 +238,7 @@ android_resources("java_resources") { "java/res/drawable-xxhdpi/web_asset.png", "java/res/drawable-xxxhdpi/ic_volume_up_grey600_24dp.png", "java/res/drawable-xxxhdpi/permission_background_sync.png", + "java/res/drawable-xxxhdpi/permission_images.png", "java/res/drawable-xxxhdpi/permission_javascript.png", - "java/res/drawable-xxxhdpi/permission_javascript_jit.png", "java/res/drawable-xxxhdpi/permission_popups.png", + "java/res/drawable-xxxhdpi/permission_protected_media.png", diff --git a/components/browser_ui/site_settings/android/java/res/drawable-hdpi/permission_images.png b/components/browser_ui/site_settings/android/java/res/drawable-hdpi/permission_images.png new file mode 100644 index 0000000000000000000000000000000000000000..cafee5acf2299e534676a15fb029192e066551c9 @@ -159,239 +149,149 @@ F0RV{K+KvDK literal 0 HcmV?d00001 -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 -@@ -51,6 +51,10 @@ Also add new settings to site_settings_preferences_with_categories.xml! - -+ -+ - - . ++*/ ++ ++package org.chromium.components.browser_ui.site_settings.impl; ++ ++import org.chromium.components.browser_ui.site_settings.R; ++ ++import org.chromium.components.browser_ui.site_settings.BromiteCustomContentSetting; ++import org.chromium.components.browser_ui.site_settings.ContentSettingsResources; ++import org.chromium.components.browser_ui.site_settings.SiteSettingsCategory; ++import org.chromium.components.content_settings.ContentSettingValues; ++import org.chromium.components.content_settings.ContentSettingsType; ++import org.chromium.content_public.browser.BrowserContextHandle; ++ ++import androidx.annotation.Nullable; ++import androidx.preference.Preference; ++import androidx.preference.PreferenceScreen; ++ ++import java.util.ArrayList; ++ ++public class BromiteImagesContentSetting extends BromiteCustomContentSetting { ++ public BromiteImagesContentSetting() { ++ super(/*contentSettingsType*/ ContentSettingsType.IMAGES, ++ /*defaultEnabledValue*/ ContentSettingValues.ALLOW, ++ /*defaultDisabledValue*/ ContentSettingValues.BLOCK, ++ /*allowException*/ true, ++ /*preferenceKey*/ "images", ++ /*profilePrefKey*/ "images"); + } + - private String getDSECategorySummary(@ContentSettingValues int value) { - return value == ContentSettingValues.ALLOW - ? getString(R.string.website_settings_permissions_allowed_dse) -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 -@@ -47,7 +47,7 @@ public class SiteSettingsCategory { - Type.PROTECTED_MEDIA, Type.SENSORS, Type.SOUND, Type.USB, Type.VIRTUAL_REALITY, - Type.USE_STORAGE, Type.AUTO_DARK_WEB_CONTENT, Type.REQUEST_DESKTOP_SITE, - Type.FEDERATED_IDENTITY_API, Type.THIRD_PARTY_COOKIES, Type.SITE_DATA, Type.ANTI_ABUSE, -- Type.TIMEZONE_OVERRIDE, Type.AUTOPLAY, Type.JAVASCRIPT_JIT, -+ Type.TIMEZONE_OVERRIDE, Type.AUTOPLAY, Type.JAVASCRIPT_JIT, Type.IMAGES, - Type.NUM_ENTRIES}) - @Retention(RetentionPolicy.SOURCE) - public @interface Type { -@@ -85,10 +85,11 @@ public class SiteSettingsCategory { - int TIMEZONE_OVERRIDE = 29; - int AUTOPLAY = 30; - int JAVASCRIPT_JIT = 31; -+ int IMAGES = 32; - /** - * Number of handled categories used for calculating array sizes. - */ -- int NUM_ENTRIES = 32; -+ int NUM_ENTRIES = 33; - } - - private final BrowserContextHandle mBrowserContextHandle; -@@ -197,6 +198,8 @@ public class SiteSettingsCategory { - return ContentSettingsType.FEDERATED_IDENTITY_API; - case Type.IDLE_DETECTION: - return ContentSettingsType.IDLE_DETECTION; -+ case Type.IMAGES: -+ return ContentSettingsType.IMAGES; - case Type.JAVASCRIPT: - return ContentSettingsType.JAVASCRIPT; - case Type.JAVASCRIPT_JIT: -@@ -286,6 +289,8 @@ public class SiteSettingsCategory { - return "idle_detection"; - case Type.JAVASCRIPT: - return "javascript"; -+ case Type.IMAGES: -+ return "images"; - case Type.MICROPHONE: - return "microphone"; - case Type.JAVASCRIPT_JIT: -diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsUtil.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsUtil.java ---- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsUtil.java -+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsUtil.java -@@ -35,6 +35,7 @@ public class SiteSettingsUtil { - ContentSettingsType.SOUND, - ContentSettingsType.MIDI_SYSEX, - ContentSettingsType.CLIPBOARD_READ_WRITE, -+ ContentSettingsType.IMAGES, - ContentSettingsType.NFC, - ContentSettingsType.BLUETOOTH_SCANNING, - ContentSettingsType.VR, -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 -@@ -214,6 +214,13 @@ public final class Website implements WebsiteEntry { - /*isEmbargoed=*/false); - setContentSettingException(type, exception); - } -+ } else if (type == ContentSettingsType.IMAGES) { -+ if (exception == null) { -+ exception = new ContentSettingException( -+ ContentSettingsType.IMAGES, getAddress().getHost(), value, "", -+ /*isEmbargoed=*/false); -+ setContentSettingException(type, exception); -+ } - } else if (type == ContentSettingsType.JAVASCRIPT) { - // It is possible to set the permission without having an existing exception, - // because we show the javascript permission in Site Settings if javascript -diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java ---- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java -+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java -@@ -71,6 +71,7 @@ public class WebsitePermissionsFetcher { - case ContentSettingsType.AUTOPLAY: - case ContentSettingsType.COOKIES: - case ContentSettingsType.FEDERATED_IDENTITY_API: -+ case ContentSettingsType.IMAGES: - case ContentSettingsType.JAVASCRIPT: - case ContentSettingsType.JAVASCRIPT_JIT: - case ContentSettingsType.POPUPS: -diff --git a/components/browser_ui/site_settings/android/website_preference_bridge.cc b/components/browser_ui/site_settings/android/website_preference_bridge.cc ---- a/components/browser_ui/site_settings/android/website_preference_bridge.cc -+++ b/components/browser_ui/site_settings/android/website_preference_bridge.cc -@@ -822,6 +822,7 @@ static void JNI_WebsitePreferenceBridge_SetContentSettingEnabled( - case ContentSettingsType::BACKGROUND_SYNC: - case ContentSettingsType::COOKIES: - case ContentSettingsType::FEDERATED_IDENTITY_API: -+ case ContentSettingsType::IMAGES: - case ContentSettingsType::JAVASCRIPT: - case ContentSettingsType::JAVASCRIPT_JIT: - case ContentSettingsType::POPUPS: -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 -@@ -76,6 +76,9 @@ - - Your device use - ++ @Override ++ public ContentSettingsResources.ResourceItem getResourceItem() { ++ return new ContentSettingsResources.ResourceItem( ++ /*icon*/ R.drawable.web_asset, ++ /*title*/ R.string.images_permission_title, ++ /*defaultEnabledValue*/ getDefaultEnabledValue(), ++ /*defaultDisabledValue*/ getDefaultDisabledValue(), ++ /*enabledSummary*/ R.string.website_settings_category_images_enabled, ++ /*disabledSummary*/ R.string.website_settings_category_images_disabled); ++ } ++ ++ @Override ++ public int getCategorySummary(@Nullable @ContentSettingValues int value) { ++ switch (value) { ++ case ContentSettingValues.ALLOW: ++ return R.string.website_settings_category_images_enabled; ++ case ContentSettingValues.BLOCK: ++ return R.string.website_settings_category_images_disabled; ++ default: ++ return 0; ++ } ++ } ++ ++ @Override ++ public boolean requiresTriStateContentSetting() { ++ return false; ++ } ++ ++ @Override ++ public boolean showOnlyDescriptions() { ++ return true; ++ } ++ ++ @Override ++ public int getAddExceptionDialogMessage() { ++ return R.string.website_settings_category_images_enabled; ++ } ++ ++ @Override ++ public @Nullable Boolean considerException(SiteSettingsCategory category, @ContentSettingValues int value) { ++ return value != ContentSettingValues.BLOCK; ++ } ++} +diff --git a/components/browser_ui/strings/android/bromite_content_settings/images.grdp b/components/browser_ui/strings/android/bromite_content_settings/images.grdp +new file mode 100644 +--- /dev/null ++++ b/components/browser_ui/strings/android/bromite_content_settings/images.grdp +@@ -0,0 +1,23 @@ ++ ++ ++ ++ ++ Images ++ ++ ++ images ++ ++ + + Images + - - JavaScript - -@@ -266,6 +269,9 @@ - - Site %1$sgoogle.com added - + + Allow images on websites you specify while blocking them for the rest of the web + - - Site URL - ++ ++ Allow sites to load images ++ ++ ++ Disallow sites to load images ++ ++ 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 -@@ -95,7 +95,8 @@ void ContentSettingsRegistry::Init() { +@@ -97,9 +97,13 @@ void ContentSettingsRegistry::Init() { {kChromeUIScheme, kChromeDevToolsScheme, kExtensionScheme}, /*valid_settings=*/{CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK}, WebsiteSettingsInfo::TOP_ORIGIN_WITH_RESOURCE_EXCEPTIONS_SCOPE, - WebsiteSettingsRegistry::DESKTOP, -+ WebsiteSettingsRegistry::DESKTOP | -+ WebsiteSettingsRegistry::PLATFORM_ANDROID, ++ WebsiteSettingsRegistry::DESKTOP | WebsiteSettingsRegistry::PLATFORM_ANDROID, ContentSettingsInfo::INHERIT_IN_INCOGNITO, - ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); +- ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); ++ ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS, ++ /*show_into_info_page*/ true, ++ /*is_renderer_content_setting*/ true, ++ /*permission_type_ui*/ IDS_SITE_SETTINGS_TYPE_IMAGES, ++ /*permission_type_ui_mid_sentence*/ IDS_SITE_SETTINGS_TYPE_IMAGES_MID_SENTENCE); + Register(ContentSettingsType::JAVASCRIPT, "javascript", CONTENT_SETTING_ALLOW, + WebsiteSettingsInfo::SYNCABLE, diff --git a/components/content_settings/core/browser/content_settings_utils.cc b/components/content_settings/core/browser/content_settings_utils.cc --- a/components/content_settings/core/browser/content_settings_utils.cc +++ b/components/content_settings/core/browser/content_settings_utils.cc -@@ -134,12 +134,8 @@ void GetRendererContentSettingRules(const HostContentSettingsMap* map, +@@ -146,12 +146,8 @@ void GetRendererContentSettingRules(const HostContentSettingsMap* map, ContentSettingToValue(CONTENT_SETTING_ALLOW), std::string(), map->IsOffTheRecord())); #else @@ -406,94 +306,5 @@ diff --git a/components/content_settings/core/browser/content_settings_utils.cc // In Android active mixed content is hard blocked, with no option to allow // it. rules->mixed_content_rules.push_back(ContentSettingPatternSource( -diff --git a/components/page_info/android/page_info_controller_android.cc b/components/page_info/android/page_info_controller_android.cc ---- a/components/page_info/android/page_info_controller_android.cc -+++ b/components/page_info/android/page_info_controller_android.cc -@@ -225,6 +225,10 @@ absl::optional PageInfoControllerAndroid::GetSettingToDisplay( - // audio since last navigation. - if (web_contents_->WasEverAudible()) - return permission.default_setting; -+ } else if (permission.type == ContentSettingsType::IMAGES) { -+ // The images content setting should show up if it is blocked globally -+ // to give users an easy way to create exceptions. -+ 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 ---- a/components/page_info/page_info.cc -+++ b/components/page_info/page_info.cc -@@ -99,9 +99,7 @@ ContentSettingsType kPermissionType[] = { - ContentSettingsType::SENSORS, - ContentSettingsType::NOTIFICATIONS, - ContentSettingsType::JAVASCRIPT, --#if !BUILDFLAG(IS_ANDROID) - ContentSettingsType::IMAGES, --#endif - ContentSettingsType::POPUPS, - ContentSettingsType::WINDOW_MANAGEMENT, - ContentSettingsType::ADS, -@@ -157,6 +155,11 @@ bool ShouldShowPermission(const PageInfo::PermissionInfo& info, - return true; - } - -+ // Always show images when it has a site-specific override -+ if (info.type == ContentSettingsType::IMAGES) { -+ return true; -+ } -+ - if (info.type == ContentSettingsType::SOUND) { - // The sound content setting should always show up when the tab has played - // audio. -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 -@@ -201,6 +201,8 @@ base::span GetContentSettingsUIInfo() { - IDS_SITE_SETTINGS_TYPE_FEDERATED_IDENTITY_API_MID_SENTENCE}, - {ContentSettingsType::IDLE_DETECTION, IDS_SITE_SETTINGS_TYPE_IDLE_DETECTION, - IDS_SITE_SETTINGS_TYPE_IDLE_DETECTION_MID_SENTENCE}, -+ {ContentSettingsType::IMAGES, IDS_SITE_SETTINGS_TYPE_IMAGES, -+ IDS_SITE_SETTINGS_TYPE_IMAGES_MID_SENTENCE}, - #if !BUILDFLAG(IS_ANDROID) - // Page Info Permissions that are not defined in Android. - {ContentSettingsType::FILE_SYSTEM_WRITE_GUARD, -@@ -210,8 +212,6 @@ base::span GetContentSettingsUIInfo() { - IDS_SITE_SETTINGS_TYPE_FONT_ACCESS_MID_SENTENCE}, - {ContentSettingsType::HID_GUARD, IDS_SITE_SETTINGS_TYPE_HID_DEVICES, - IDS_SITE_SETTINGS_TYPE_HID_DEVICES_MID_SENTENCE}, -- {ContentSettingsType::IMAGES, IDS_SITE_SETTINGS_TYPE_IMAGES, -- IDS_SITE_SETTINGS_TYPE_IMAGES_MID_SENTENCE}, - {ContentSettingsType::SERIAL_GUARD, IDS_SITE_SETTINGS_TYPE_SERIAL_PORTS, - IDS_SITE_SETTINGS_TYPE_SERIAL_PORTS_MID_SENTENCE}, - {ContentSettingsType::WINDOW_MANAGEMENT, -diff --git a/components/site_settings_strings.grdp b/components/site_settings_strings.grdp ---- a/components/site_settings_strings.grdp -+++ b/components/site_settings_strings.grdp -@@ -163,6 +163,12 @@ - - virtual reality - -+ -+ Images -+ -+ -+ images -+ - - - -@@ -190,12 +196,6 @@ - - HID devices - -- -- Images -- -- -- images -- - - Insecure content - -- 2.25.1 diff --git a/build/patches/Timezone-customization.patch b/build/patches/Timezone-customization.patch index 59fd3311..35dba817 100644 --- a/build/patches/Timezone-customization.patch +++ b/build/patches/Timezone-customization.patch @@ -15,39 +15,39 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html ...ezoneoverride_site_settings_preference.xml | 68 ++++++ .../res/xml/site_settings_preferences.xml | 4 + .../java/res/xml/website_preferences.xml | 10 + - .../ContentSettingsResources.java | 33 +++ + .../ContentSettingsResources.java | 28 +++ .../site_settings/SingleCategorySettings.java | 60 +++++- - .../site_settings/SingleWebsiteSettings.java | 8 +- + .../site_settings/SingleWebsiteSettings.java | 2 + .../site_settings/SiteSettings.java | 2 +- - .../site_settings/SiteSettingsCategory.java | 8 +- + .../site_settings/SiteSettingsCategory.java | 7 +- .../site_settings/SiteSettingsDelegate.java | 2 + ...imezoneOverrideSiteSettingsPreference.java | 194 ++++++++++++++++++ .../browser_ui/site_settings/Website.java | 11 + .../WebsitePermissionsFetcher.java | 2 + .../WebsitePreferenceBridge.java | 12 ++ .../android/website_preference_bridge.cc | 16 ++ - .../strings/android/site_settings.grdp | 35 ++++ + .../bromite_content_settings/timezone.grdp | 36 ++++ .../browser/content_settings_pref_provider.cc | 16 ++ .../browser/content_settings_pref_provider.h | 4 + - .../core/browser/content_settings_registry.cc | 11 + - .../core/browser/content_settings_utils.cc | 7 + + .../core/browser/content_settings_registry.cc | 13 ++ + .../core/browser/content_settings_utils.cc | 5 + .../core/browser/host_content_settings_map.cc | 8 + .../core/browser/host_content_settings_map.h | 3 + - .../core/common/content_settings.cc | 4 +- - .../core/common/content_settings.h | 2 + - .../core/common/content_settings.mojom | 2 + - .../common/content_settings_mojom_traits.cc | 4 +- - .../common/content_settings_mojom_traits.h | 10 + + .../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 + .../core/common/content_settings_types.h | 3 + .../core/common/pref_names.cc | 3 + .../content_settings/core/common/pref_names.h | 2 + - .../renderer/content_settings_agent_impl.cc | 83 ++++++++ + .../renderer/content_settings_agent_impl.cc | 80 ++++++++ .../renderer/content_settings_agent_impl.h | 11 + .../WebLayerSiteSettingsDelegate.java | 3 + - 35 files changed, 687 insertions(+), 9 deletions(-) + 34 files changed, 664 insertions(+), 6 deletions(-) create mode 100755 components/browser_ui/site_settings/android/java/res/layout/time_zone_select_dialog.xml create mode 100755 components/browser_ui/site_settings/android/java/res/layout/timezoneoverride_site_settings_preference.xml create mode 100755 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/TimezoneOverrideSiteSettingsPreference.java + create mode 100644 components/browser_ui/strings/android/bromite_content_settings/timezone.grdp 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 --- a/chrome/android/java/src/org/chromium/chrome/browser/site_settings/ChromeSiteSettingsDelegate.java @@ -93,7 +93,7 @@ diff --git a/components/browser_ui/site_settings/android/BUILD.gn b/components/b ] annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ] resources_package = "org.chromium.components.browser_ui.site_settings" -@@ -248,6 +249,8 @@ android_resources("java_resources") { +@@ -263,6 +264,8 @@ android_resources("java_resources") { "java/res/xml/site_settings_preferences.xml", "java/res/xml/site_settings_preferences_with_categories.xml", "java/res/xml/website_preferences.xml", @@ -272,13 +272,12 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c + R.string.website_settings_category_timezone_override_custom, + R.string.website_settings_category_timezone_override_random); } - assert false; // NOTREACHED - return null; -@@ -468,6 +474,23 @@ public class ContentSettingsResources { - } + ResourceItem ri = BromiteCustomContentSettingImpl.getResourceItem(contentType); + if (ri != null) return ri; +@@ -471,6 +477,18 @@ public class ContentSettingsResources { } -+ public static int getCategorySummary(int contentType, @Nullable @ContentSettingValues int value) { + public static int getCategorySummary(int contentType, @Nullable @ContentSettingValues int value) { + if (contentType == ContentSettingsType.TIMEZONE_OVERRIDE) { + switch (value) { + case ContentSettingValues.ALLOW: @@ -291,14 +290,10 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c + return 0; + } + } -+ else -+ return getCategorySummary(value); -+ } -+ - /** - * Returns the string resource id for a content type to show with a permission category. - * @param enabled Whether the content type is enabled. -@@ -485,6 +508,9 @@ public class ContentSettingsResources { + int result = BromiteCustomContentSettingImpl.getCategorySummary(contentType, value); + if (result != 0) return result; + return getCategorySummary(value); +@@ -493,6 +511,9 @@ public class ContentSettingsResources { */ public static int getSiteSummary(@ContentSettingValues @Nullable Integer value, @ContentSettingsType int contentSettingsType) { @@ -308,7 +303,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c switch (value) { case ContentSettingValues.ALLOW: return contentSettingsType == ContentSettingsType.REQUEST_DESKTOP_SITE -@@ -610,6 +636,13 @@ public class ContentSettingsResources { +@@ -620,6 +641,13 @@ public class ContentSettingsResources { R.string.website_settings_category_protected_content_blocked}; return descriptionIDs; } @@ -352,9 +347,9 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c // Keys for Allowed/Blocked preference groups/headers. public static final String ALLOWED_GROUP = "allowed_group"; -@@ -306,7 +312,11 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment - Integer contentSetting = website.site().getContentSetting( - browserContextHandle, mCategory.getContentSettingsType()); +@@ -310,7 +316,11 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment + return BromiteCustomContentSettingImpl.isOnBlockList(contentSetting, website, contentSetting); + } if (contentSetting != null) { - return ContentSettingValues.BLOCK == contentSetting; + if (mCategory.getContentSettingsType() == SiteSettingsCategory.Type.TIMEZONE_OVERRIDE) { @@ -365,7 +360,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c } return false; } -@@ -487,7 +497,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -492,7 +502,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment if (queryHasChanged) getInfoForOrigins(); }); @@ -375,7 +370,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c MenuItem help = menu.add( Menu.NONE, R.id.menu_id_site_settings_help, Menu.NONE, R.string.menu_help); help.setIcon(TraceEventVectorDrawableCompat.create( -@@ -498,7 +509,10 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -503,7 +514,10 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.menu_id_site_settings_help) { @@ -387,7 +382,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c getSiteSettingsDelegate().launchProtectedContentHelpAndFeedbackActivity( getActivity()); } else { -@@ -600,6 +614,12 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -610,6 +624,12 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment WebsitePreferenceBridge.setDefaultContentSetting( browserContextHandle, mCategory.getContentSettingsType(), setting); getInfoForOrigins(); @@ -400,7 +395,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c } else if (FOUR_STATE_COOKIE_TOGGLE_KEY.equals(preference.getKey())) { setCookieSettingsPreference((CookieSettingsState) newValue); getInfoForOrigins(); -@@ -786,6 +806,12 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -796,6 +816,12 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment ? R.string.website_settings_blocked_group_heading_request_desktop_site : R.string.website_settings_allowed_group_heading_request_desktop_site; break; @@ -411,9 +406,9 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c + : R.string.website_settings_category_timezone_override_allowed; + break; } - assert resource > 0; - return getString(resource); -@@ -905,6 +931,9 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment + if (resource == 0) + resource = BromiteCustomContentSettingImpl.getAddExceptionDialogMessage(mCategory); +@@ -917,6 +943,9 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment case SiteSettingsCategory.Type.THIRD_PARTY_COOKIES: allowSpecifyingExceptions = getCookieControlsMode() != CookieControlsMode.OFF; break; @@ -423,7 +418,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c default: break; } -@@ -1122,6 +1151,9 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -1138,6 +1167,9 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment PreferenceGroup blockedGroup = screen.findPreference(BLOCKED_GROUP); PreferenceGroup managedGroup = screen.findPreference(MANAGED_GROUP); boolean permissionBlockedByOs = mCategory.showPermissionBlockedMessage(getContext()); @@ -433,7 +428,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c if (mGlobalToggleLayout != GlobalToggleLayout.BINARY_TOGGLE) { screen.removePreference(binaryToggle); -@@ -1135,11 +1167,18 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -1151,11 +1183,18 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment if (mGlobalToggleLayout != GlobalToggleLayout.FOUR_STATE_COOKIE_TOGGLE) { screen.removePreference(fourStateCookieToggle); } @@ -452,9 +447,9 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c configureTriStateToggle(triStateToggle, contentType); break; case GlobalToggleLayout.TRI_STATE_COOKIE_TOGGLE: -@@ -1183,6 +1222,12 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment - screen.removePreference(antiAbuseThingsToConsiderSectionOne); +@@ -1200,6 +1239,12 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment } + BromiteCustomContentSettingImpl.configureGlobalToggles(mCategory, screen); + if (mCategory.getType() == SiteSettingsCategory.Type.TIMEZONE_OVERRIDE) { + screen.removePreference(triStateToggle); @@ -465,8 +460,8 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c if (permissionBlockedByOs) { maybeShowOsWarning(screen); -@@ -1338,6 +1383,15 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment - triStateToggle.initialize(setting, descriptionIds); +@@ -1355,6 +1400,15 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment + triStateToggle.initialize(contentType, setting, descriptionIds); } + private void configureTimeOverrideStateToggle( @@ -484,7 +479,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 -@@ -141,6 +141,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment +@@ -143,6 +143,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment return "popup_permission_list"; case ContentSettingsType.SOUND: return "sound_permission_list"; @@ -493,54 +488,22 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c case ContentSettingsType.AR: return "ar_permission_list"; case ContentSettingsType.MEDIASTREAM_CAMERA: -@@ -945,11 +947,13 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment - if (value == null) return; - setUpPreferenceCommon(preference, value); - -+ int content_type = getContentSettingsTypeFromPreferenceKey(preference.getKey()); -+ - ChromeSwitchPreference switchPreference = (ChromeSwitchPreference) preference; - switchPreference.setChecked(value == ContentSettingValues.ALLOW); - switchPreference.setSummary(isEmbargoed - ? getString(R.string.automatically_blocked) -- : getString(ContentSettingsResources.getCategorySummary(value))); -+ : getString(ContentSettingsResources.getCategorySummary(content_type, value))); - switchPreference.setOnPreferenceChangeListener(this); - @ContentSettingsType - int contentType = getContentSettingsTypeFromPreferenceKey(preference.getKey()); -@@ -1149,7 +1153,7 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment - } - - mSite.setContentSetting(browserContextHandle, type, permission); -- preference.setSummary(getString(ContentSettingsResources.getCategorySummary(permission))); -+ preference.setSummary(getString(ContentSettingsResources.getCategorySummary(type, permission))); - preference.setIcon(getContentSettingsIcon(type, permission)); - - if (mWebsiteSettingsObserver != null) { diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettings.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettings.java --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettings.java +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettings.java -@@ -131,7 +131,7 @@ public class SiteSettings extends SiteSettingsPreferenceFragment +@@ -132,7 +132,7 @@ public class SiteSettings extends SiteSettingsPreferenceFragment } else if (Type.AUTO_DARK_WEB_CONTENT == prefCategory) { p.setSummary(ContentSettingsResources.getAutoDarkWebContentListSummary(checked)); } else if (requiresTriStateSetting) { - p.setSummary(ContentSettingsResources.getCategorySummary(setting)); + p.setSummary(ContentSettingsResources.getCategorySummary(contentType, setting)); } else { - p.setSummary(ContentSettingsResources.getCategorySummary(contentType, checked)); + p.setSummary(ContentSettingsResources.getCategorySummary(contentType, checked)); // } 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 -@@ -47,6 +47,7 @@ public class SiteSettingsCategory { - Type.PROTECTED_MEDIA, Type.SENSORS, Type.SOUND, Type.USB, Type.VIRTUAL_REALITY, - Type.USE_STORAGE, Type.AUTO_DARK_WEB_CONTENT, Type.REQUEST_DESKTOP_SITE, - Type.FEDERATED_IDENTITY_API, Type.THIRD_PARTY_COOKIES, Type.SITE_DATA, Type.ANTI_ABUSE, -+ Type.TIMEZONE_OVERRIDE, - Type.NUM_ENTRIES}) - @Retention(RetentionPolicy.SOURCE) - public @interface Type { -@@ -81,10 +82,11 @@ public class SiteSettingsCategory { +@@ -81,10 +81,11 @@ public class SiteSettingsCategory { int THIRD_PARTY_COOKIES = 26; int SITE_DATA = 27; int ANTI_ABUSE = 28; @@ -548,12 +511,12 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c /** * Number of handled categories used for calculating array sizes. */ -- int NUM_ENTRIES = 29; -+ int NUM_ENTRIES = 30; +- int NUM_ENTRIES_CHROMIUM = 29; ++ int NUM_ENTRIES_CHROMIUM = 30; } private final BrowserContextHandle mBrowserContextHandle; -@@ -213,6 +215,8 @@ public class SiteSettingsCategory { +@@ -216,6 +217,8 @@ public class SiteSettingsCategory { return ContentSettingsType.USB_GUARD; case Type.VIRTUAL_REALITY: return ContentSettingsType.VR; @@ -562,15 +525,15 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c case Type.ALL_SITES: case Type.USE_STORAGE: return ContentSettingsType.DEFAULT; // Conversion unavailable. -@@ -300,6 +304,8 @@ public class SiteSettingsCategory { +@@ -302,6 +305,8 @@ public class SiteSettingsCategory { return "site_data"; case Type.THIRD_PARTY_COOKIES: return "third_party_cookies"; + case Type.TIMEZONE_OVERRIDE: + return "timezone_override"; default: - assert false; - return ""; + { + String value = BromiteCustomContentSettingImpl.getPreferenceKey(type); diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsDelegate.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsDelegate.java --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsDelegate.java +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsDelegate.java @@ -801,8 +764,8 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c + setContentSettingException(type, exception); + } } - // We want to call setContentSetting even after explicitly setting - // mContentSettingException above because this will trigger the actual change + + if (exception == null) { diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java @@ -825,16 +788,16 @@ 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/WebsitePreferenceBridge.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java -@@ -243,6 +243,8 @@ public class WebsitePreferenceBridge { +@@ -245,6 +245,8 @@ public class WebsitePreferenceBridge { switch (contentSettingsType) { case ContentSettingsType.PROTECTED_MEDIA_IDENTIFIER: return true; + case ContentSettingsType.TIMEZONE_OVERRIDE: + return true; default: - return false; + return BromiteCustomContentSettingImpl.requiresTriStateContentSetting(contentSettingsType); } -@@ -383,6 +385,14 @@ public class WebsitePreferenceBridge { +@@ -384,6 +386,14 @@ public class WebsitePreferenceBridge { return WebsitePreferenceBridgeJni.get().toHostOnlyPattern(pattern); } @@ -849,7 +812,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c @NativeMethods public interface Natives { boolean isNotificationEmbargoedForOrigin( -@@ -447,5 +457,7 @@ public class WebsitePreferenceBridge { +@@ -448,5 +458,7 @@ public class WebsitePreferenceBridge { boolean getLocationAllowedByPolicy(BrowserContextHandle browserContextHandle); String toDomainWildcardPattern(String pattern); String toHostOnlyPattern(String pattern); @@ -860,7 +823,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c diff --git a/components/browser_ui/site_settings/android/website_preference_bridge.cc b/components/browser_ui/site_settings/android/website_preference_bridge.cc --- a/components/browser_ui/site_settings/android/website_preference_bridge.cc +++ b/components/browser_ui/site_settings/android/website_preference_bridge.cc -@@ -1018,3 +1018,19 @@ JNI_WebsitePreferenceBridge_ToHostOnlyPattern( +@@ -1019,3 +1019,19 @@ JNI_WebsitePreferenceBridge_ToHostOnlyPattern( ContentSettingsPattern::FromString(pattern_string)); return ConvertUTF8ToJavaString(env, host_only_pattern.ToString()); } @@ -880,24 +843,13 @@ diff --git a/components/browser_ui/site_settings/android/website_preference_brid + GetHostContentSettingsMap(jbrowser_context_handle)->GetTimezoneOverrideValue(custom_timezone); + return ConvertUTF8ToJavaString(env, custom_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 -@@ -109,6 +109,9 @@ - - Dark theme for sites - -+ -+ Timezone override -+ - - Desktop site - -@@ -742,6 +745,38 @@ - Block sites from playing protected content - - -+ +diff --git a/components/browser_ui/strings/android/bromite_content_settings/timezone.grdp b/components/browser_ui/strings/android/bromite_content_settings/timezone.grdp +new file mode 100644 +--- /dev/null ++++ b/components/browser_ui/strings/android/bromite_content_settings/timezone.grdp +@@ -0,0 +1,36 @@ ++ ++ + + Override timezone with a custom or random one, or use the system timezone + @@ -928,10 +880,10 @@ diff --git a/components/browser_ui/strings/android/site_settings.grdp b/componen + + Select + -+ - - - ++ ++ Timezone override ++ ++ diff --git a/components/content_settings/core/browser/content_settings_pref_provider.cc b/components/content_settings/core/browser/content_settings_pref_provider.cc --- a/components/content_settings/core/browser/content_settings_pref_provider.cc +++ b/components/content_settings/core/browser/content_settings_pref_provider.cc @@ -944,7 +896,7 @@ diff --git a/components/content_settings/core/browser/content_settings_pref_prov // Obsolete prefs ---------------------------------------------------------- // These prefs have been removed, but need to be registered so they can -@@ -165,6 +167,10 @@ PrefProvider::PrefProvider(PrefService* prefs, +@@ -171,6 +173,10 @@ PrefProvider::PrefProvider(PrefService* prefs, event_args->set_number_of_exceptions( num_exceptions); // PrefProvider::PrefProvider. }); @@ -955,7 +907,7 @@ diff --git a/components/content_settings/core/browser/content_settings_pref_prov } PrefProvider::~PrefProvider() { -@@ -351,4 +357,14 @@ void PrefProvider::SetClockForTesting(base::Clock* clock) { +@@ -357,4 +363,14 @@ void PrefProvider::SetClockForTesting(base::Clock* clock) { clock_ = clock; } @@ -973,7 +925,7 @@ diff --git a/components/content_settings/core/browser/content_settings_pref_prov diff --git a/components/content_settings/core/browser/content_settings_pref_provider.h b/components/content_settings/core/browser/content_settings_pref_provider.h --- a/components/content_settings/core/browser/content_settings_pref_provider.h +++ b/components/content_settings/core/browser/content_settings_pref_provider.h -@@ -68,6 +68,9 @@ class PrefProvider : public UserModifiableProvider { +@@ -69,6 +69,9 @@ class PrefProvider : public UserModifiableProvider { ContentSettingsPref* GetPref(ContentSettingsType type) const; @@ -983,7 +935,7 @@ diff --git a/components/content_settings/core/browser/content_settings_pref_prov private: friend class DeadlockCheckerObserver; // For testing. -@@ -104,6 +107,7 @@ class PrefProvider : public UserModifiableProvider { +@@ -106,6 +109,7 @@ class PrefProvider : public UserModifiableProvider { base::ThreadChecker thread_checker_; raw_ptr clock_; @@ -994,7 +946,7 @@ diff --git a/components/content_settings/core/browser/content_settings_pref_prov 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 -@@ -555,6 +555,17 @@ void ContentSettingsRegistry::Init() { +@@ -557,6 +557,19 @@ void ContentSettingsRegistry::Init() { ContentSettingsInfo::INHERIT_IN_INCOGNITO, ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); @@ -1007,7 +959,9 @@ diff --git a/components/content_settings/core/browser/content_settings_registry. + WebsiteSettingsInfo::TOP_ORIGIN_ONLY_SCOPE, + WebsiteSettingsRegistry::PLATFORM_ANDROID, + ContentSettingsInfo::INHERIT_IN_INCOGNITO, -+ ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); ++ ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS, ++ /*show_into_info_page*/ false, ++ /*is_renderer_content_setting*/ true); + Register(ContentSettingsType::FEDERATED_IDENTITY_API, "webid-api", CONTENT_SETTING_ALLOW, WebsiteSettingsInfo::UNSYNCABLE, @@ -1015,14 +969,12 @@ diff --git a/components/content_settings/core/browser/content_settings_registry. diff --git a/components/content_settings/core/browser/content_settings_utils.cc b/components/content_settings/core/browser/content_settings_utils.cc --- a/components/content_settings/core/browser/content_settings_utils.cc +++ b/components/content_settings/core/browser/content_settings_utils.cc -@@ -153,6 +153,13 @@ void GetRendererContentSettingRules(const HostContentSettingsMap* map, +@@ -165,6 +165,11 @@ void GetRendererContentSettingRules(const HostContentSettingsMap* map, &(rules->script_rules)); map->GetSettingsForOneType(ContentSettingsType::POPUPS, &(rules->popup_redirect_rules)); + -+ // pass custom timezone rules and value to the render process -+ map->GetSettingsForOneType(ContentSettingsType::TIMEZONE_OVERRIDE, -+ &(rules->timezone_override_rules)); ++ // pass custom timezone value to the render process + std::string timezone; + map->GetTimezoneOverrideValue(timezone); + rules->timezone_override_value = timezone; @@ -1032,7 +984,7 @@ diff --git a/components/content_settings/core/browser/content_settings_utils.cc diff --git a/components/content_settings/core/browser/host_content_settings_map.cc b/components/content_settings/core/browser/host_content_settings_map.cc --- a/components/content_settings/core/browser/host_content_settings_map.cc +++ b/components/content_settings/core/browser/host_content_settings_map.cc -@@ -611,6 +611,14 @@ void HostContentSettingsMap::SetClockForTesting(base::Clock* clock) { +@@ -613,6 +613,14 @@ void HostContentSettingsMap::SetClockForTesting(base::Clock* clock) { provider->SetClockForTesting(clock); } @@ -1050,7 +1002,7 @@ diff --git a/components/content_settings/core/browser/host_content_settings_map. diff --git a/components/content_settings/core/browser/host_content_settings_map.h b/components/content_settings/core/browser/host_content_settings_map.h --- a/components/content_settings/core/browser/host_content_settings_map.h +++ b/components/content_settings/core/browser/host_content_settings_map.h -@@ -334,6 +334,9 @@ class HostContentSettingsMap : public content_settings::Observer, +@@ -335,6 +335,9 @@ class HostContentSettingsMap : public content_settings::Observer, allow_invalid_secondary_pattern_for_testing_ = allow; } @@ -1060,35 +1012,13 @@ diff --git a/components/content_settings/core/browser/host_content_settings_map. private: friend class base::RefCountedThreadSafe; friend class content_settings::TestUtils; -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 -@@ -216,7 +216,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::TIMEZONE_OVERRIDE; - } - - void RendererContentSettingRules::FilterRulesByOutermostMainFrameURL( -@@ -226,6 +227,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(timezone_override_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 --- a/components/content_settings/core/common/content_settings.h +++ b/components/content_settings/core/common/content_settings.h -@@ -93,6 +93,8 @@ struct RendererContentSettingRules { +@@ -103,6 +103,7 @@ struct RendererContentSettingRules { ContentSettingsForOneType popup_redirect_rules; ContentSettingsForOneType mixed_content_rules; ContentSettingsForOneType auto_dark_content_rules; -+ ContentSettingsForOneType timezone_override_rules; + std::string timezone_override_value; }; @@ -1096,23 +1026,21 @@ diff --git a/components/content_settings/core/common/content_settings.h b/compon diff --git a/components/content_settings/core/common/content_settings.mojom b/components/content_settings/core/common/content_settings.mojom --- a/components/content_settings/core/common/content_settings.mojom +++ b/components/content_settings/core/common/content_settings.mojom -@@ -78,4 +78,6 @@ struct RendererContentSettingRules { +@@ -84,4 +84,5 @@ struct RendererContentSettingRules { array popup_redirect_rules; array mixed_content_rules; array auto_dark_content_rules; -+ array timezone_override_rules; + string timezone_override_value; }; diff --git a/components/content_settings/core/common/content_settings_mojom_traits.cc b/components/content_settings/core/common/content_settings_mojom_traits.cc --- a/components/content_settings/core/common/content_settings_mojom_traits.cc +++ b/components/content_settings/core/common/content_settings_mojom_traits.cc -@@ -102,7 +102,9 @@ 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.ReadTimezoneOverrideRules(&out->timezone_override_rules) && + data.ReadTimezoneOverrideValue(&out->timezone_override_value); } @@ -1120,15 +1048,10 @@ diff --git a/components/content_settings/core/common/content_settings_mojom_trai diff --git a/components/content_settings/core/common/content_settings_mojom_traits.h b/components/content_settings/core/common/content_settings_mojom_traits.h --- 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,16 @@ struct StructTraits< +@@ -174,6 +174,11 @@ struct StructTraits< return r.auto_dark_content_rules; } -+ static const std::vector& timezone_override_rules( -+ const RendererContentSettingRules& r) { -+ return r.timezone_override_rules; -+ } -+ + static const std::string& timezone_override_value( + const RendererContentSettingRules& r) { + return r.timezone_override_value; @@ -1187,7 +1110,7 @@ diff --git a/components/content_settings/renderer/content_settings_agent_impl.cc #include "components/content_settings/core/common/content_settings.h" #include "components/content_settings/core/common/content_settings.mojom.h" #include "components/content_settings/core/common/content_settings_pattern.h" -@@ -321,6 +323,10 @@ bool ContentSettingsAgentImpl::AllowScript(bool enabled_per_settings) { +@@ -354,6 +356,10 @@ bool ContentSettingsAgentImpl::AllowScript(bool enabled_per_settings) { allow = allow || IsAllowlistedForContentSettings(); cached_script_permissions_[frame] = allow; @@ -1198,7 +1121,7 @@ diff --git a/components/content_settings/renderer/content_settings_agent_impl.cc return allow; } -@@ -457,4 +463,81 @@ bool ContentSettingsAgentImpl::IsAllowlistedForContentSettings() const { +@@ -490,4 +496,78 @@ bool ContentSettingsAgentImpl::IsAllowlistedForContentSettings() const { return false; } @@ -1207,11 +1130,8 @@ diff --git a/components/content_settings/renderer/content_settings_agent_impl.cc + ContentSetting setting = CONTENT_SETTING_ALLOW; + + if (content_setting_rules_) { -+ blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); -+ -+ setting = GetContentSettingFromRules( -+ content_setting_rules_->timezone_override_rules, -+ url::Origin(frame->GetDocument().GetSecurityOrigin()).GetURL()); ++ setting = GetContentSetting( ++ ContentSettingsType::TIMEZONE_OVERRIDE, setting); + } + return UpdateTimeZoneOverride( + setting, content_setting_rules_->timezone_override_value); @@ -1295,7 +1215,7 @@ diff --git a/components/content_settings/renderer/content_settings_agent_impl.h namespace blink { class WebFrame; class WebURL; -@@ -167,6 +172,12 @@ class ContentSettingsAgentImpl +@@ -172,6 +177,12 @@ class ContentSettingsAgentImpl std::unique_ptr delegate_; mojo::AssociatedReceiverSet receivers_; From 617ea58d201c204d988561a29bf6d98a26aa0c87 Mon Sep 17 00:00:00 2001 From: Carmelo Messina Date: Sat, 17 Jun 2023 16:28:04 +0200 Subject: [PATCH 2/3] stage 2 - windows version --- .../00Viewport-Protection-Site-Setting.patch | 297 +----- .../00WIN-ADDTO-Add-webGL-site-setting.patch | 241 ----- ...00WIN-ADDTO-Add-webRTC-site-settings.patch | 241 ----- ...0WIN-ADDTO-JIT-site-settings--fixup-.patch | 22 - .../00WIN-ADDTO-JIT-site-settings.patch | 271 ----- ...Revert-the-removal-to-block-autoplay.patch | 258 ----- .../00WIN-ADDTO-Timezone-customization.patch | 254 ----- build/patches/00bromite-build-utils.patch | 80 +- build/patches/Add-webGL-site-setting.patch | 64 +- build/patches/Add-webRTC-site-settings.patch | 68 +- .../Content-settings-infrastructure.patch | 925 ++++++++++++++---- build/patches/JIT-site-settings.patch | 84 +- ...moval-of-an-option-to-block-autoplay.patch | 73 +- build/patches/Site-setting-for-images.patch | 68 +- build/patches/Timezone-customization.patch | 123 +-- 15 files changed, 1115 insertions(+), 1954 deletions(-) delete mode 100644 build/patches/00WIN-ADDTO-Add-webGL-site-setting.patch delete mode 100644 build/patches/00WIN-ADDTO-Add-webRTC-site-settings.patch delete mode 100644 build/patches/00WIN-ADDTO-JIT-site-settings--fixup-.patch delete mode 100644 build/patches/00WIN-ADDTO-JIT-site-settings.patch delete mode 100644 build/patches/00WIN-ADDTO-Revert-the-removal-to-block-autoplay.patch delete mode 100644 build/patches/00WIN-ADDTO-Timezone-customization.patch diff --git a/build/patches/00Viewport-Protection-Site-Setting.patch b/build/patches/00Viewport-Protection-Site-Setting.patch index 88f9d653..d183cad0 100644 --- a/build/patches/00Viewport-Protection-Site-Setting.patch +++ b/build/patches/00Viewport-Protection-Site-Setting.patch @@ -1,258 +1,26 @@ From: Your Name -Date: Tue, 20 Dec 2022 14:27:02 +0000 +Date: Fri, 16 Jun 2023 15:56:35 +0000 Subject: Viewport Protection Site Setting --- - chrome/app/settings_strings.grdp | 19 ++++ - chrome/browser/resources/settings/icons.html | 2 + - .../settings/privacy_page/privacy_page.html | 22 +++++ - chrome/browser/resources/settings/route.ts | 1 + - chrome/browser/resources/settings/router.ts | 1 + - .../site_settings/category_default_setting.ts | 1 + - .../settings/site_settings/constants.ts | 1 + - .../settings_category_default_radio_group.ts | 1 + - .../settings/site_settings/site_details.html | 5 ++ - .../site_settings_page/site_settings_page.ts | 9 ++ - .../site_settings_page_util.ts | 2 + - .../views/page_info/page_info_view_factory.cc | 3 + - .../settings_localized_strings_provider.cc | 7 ++ - .../ui/webui/settings/site_settings_helper.cc | 1 + - .../impl/BromiteViewportContentSetting.java | 88 +++++++++++++++++++ - .../bromite_content_settings/viewport.grdp | 18 ++++ - .../bromite_content_settings/viewport.inc | 13 +++ + .../impl/BromiteViewportContentSetting.java | 93 +++++++++++++++++++ + .../bromite_content_settings/viewport.grdp | 27 ++++++ + .../bromite_content_settings/viewport.inc | 22 +++++ .../bromite_content_settings/VIEWPORT.inc | 1 + third_party/blink/common/features.cc | 2 +- .../renderer/core/frame/local_dom_window.cc | 2 + third_party/blink/renderer/core/page/page.cc | 3 + - 21 files changed, 201 insertions(+), 1 deletion(-) + 7 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteViewportContentSetting.java - create mode 100644 components/browser_ui/strings/android/bromite_content_settings/viewport.grdp + create mode 100644 components/browser_ui/strings/bromite_content_settings/viewport.grdp create mode 100644 components/content_settings/core/browser/bromite_content_settings/viewport.inc create mode 100644 components/content_settings/core/common/bromite_content_settings/VIEWPORT.inc -diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp ---- a/chrome/app/settings_strings.grdp -+++ b/chrome/app/settings_strings.grdp -@@ -4434,6 +4434,25 @@ - Not allowed to use WebRTC - - -+ -+ Viewport Protection -+ -+ -+ Enable Viewport Protection -+ -+ -+ Viewport Protection is enabled -+ -+ -+ Viewport Protection is disabled -+ -+ -+ Allowed to use Viewport Protection -+ -+ -+ Not allowed to use Viewport Protection -+ -+ - - - -diff --git a/chrome/browser/resources/settings/icons.html b/chrome/browser/resources/settings/icons.html ---- a/chrome/browser/resources/settings/icons.html -+++ b/chrome/browser/resources/settings/icons.html -@@ -201,6 +201,8 @@ NOTE: Chrome OS icons go in ./chromeos/os_icons.html. - - - -+ -+ - - - -diff --git a/chrome/browser/resources/settings/privacy_page/privacy_page.html b/chrome/browser/resources/settings/privacy_page/privacy_page.html ---- a/chrome/browser/resources/settings/privacy_page/privacy_page.html -+++ b/chrome/browser/resources/settings/privacy_page/privacy_page.html -@@ -1214,4 +1214,26 @@ - - - -+ - -diff --git a/chrome/browser/resources/settings/route.ts b/chrome/browser/resources/settings/route.ts ---- a/chrome/browser/resources/settings/route.ts -+++ b/chrome/browser/resources/settings/route.ts -@@ -127,6 +127,7 @@ function addPrivacyChildRoutes(r: Partial) { - r.SITE_SETTINGS_TIMEZONE_OVERRIDE = r.SITE_SETTINGS.createChild('timezone-override'); - r.SITE_SETTINGS_WEBGL = r.SITE_SETTINGS.createChild('webgl'); - r.SITE_SETTINGS_WEBRTC = r.SITE_SETTINGS.createChild('webrtc'); -+ r.SITE_SETTINGS_VIEWPORT = r.SITE_SETTINGS.createChild('viewport-protection'); - } - - /** -diff --git a/chrome/browser/resources/settings/router.ts b/chrome/browser/resources/settings/router.ts ---- a/chrome/browser/resources/settings/router.ts -+++ b/chrome/browser/resources/settings/router.ts -@@ -109,6 +109,7 @@ export interface SettingsRoutes { - SITE_SETTINGS_TIMEZONE_OVERRIDE: Route; - SITE_SETTINGS_WEBGL: Route; - SITE_SETTINGS_WEBRTC: Route; -+ SITE_SETTINGS_VIEWPORT: Route; - } - - /** Class for navigable routes. */ -diff --git a/chrome/browser/resources/settings/site_settings/category_default_setting.ts b/chrome/browser/resources/settings/site_settings/category_default_setting.ts ---- a/chrome/browser/resources/settings/site_settings/category_default_setting.ts -+++ b/chrome/browser/resources/settings/site_settings/category_default_setting.ts -@@ -200,6 +200,7 @@ export class CategoryDefaultSettingElement extends - case ContentSettingsTypes.TIMEZONE_OVERRIDE: - case ContentSettingsTypes.WEBGL: - case ContentSettingsTypes.WEBRTC: -+ case ContentSettingsTypes.VIEWPORT: - // "Allowed" vs "Blocked". - this.browserProxy.setDefaultValueForContentType( - this.category, -diff --git a/chrome/browser/resources/settings/site_settings/constants.ts b/chrome/browser/resources/settings/site_settings/constants.ts ---- a/chrome/browser/resources/settings/site_settings/constants.ts -+++ b/chrome/browser/resources/settings/site_settings/constants.ts -@@ -51,6 +51,7 @@ export enum ContentSettingsTypes { - TIMEZONE_OVERRIDE = 'timezone-override', - WEBGL = 'webgl', - WEBRTC = 'webrtc', -+ VIEWPORT = 'viewport', - - // The following items are not in the C++ kContentSettingsTypeGroupNames, but - // are used everywhere where ContentSettingsTypes is used in JS. -diff --git a/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts b/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts ---- a/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts -+++ b/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts -@@ -144,6 +144,7 @@ export class SettingsCategoryDefaultRadioGroupElement extends - case ContentSettingsTypes.TIMEZONE_OVERRIDE: - case ContentSettingsTypes.WEBGL: - case ContentSettingsTypes.WEBRTC: -+ case ContentSettingsTypes.VIEWPORT: - // "Allowed" vs "Blocked". - return ContentSetting.ALLOW; - case ContentSettingsTypes.AR: -diff --git a/chrome/browser/resources/settings/site_settings/site_details.html b/chrome/browser/resources/settings/site_settings/site_details.html ---- a/chrome/browser/resources/settings/site_settings/site_details.html -+++ b/chrome/browser/resources/settings/site_settings/site_details.html -@@ -291,4 +291,9 @@ - icon="settings:webrtc" - label="$i18n{siteSettingsWebRTC}"> - -+ -+ - -diff --git a/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts b/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts ---- a/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts -+++ b/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts -@@ -374,6 +374,14 @@ function getCategoryItemMap(): Map { - enabledLabel: 'siteSettingsWebRTCAllowed', - disabledLabel: 'siteSettingsWebRTCBlocked', - }, -+ { -+ route: routes.SITE_SETTINGS_VIEWPORT, -+ id: Id.VIEWPORT, -+ label: 'siteSettingsViewportProtection', -+ icon: 'settings:viewport-protection', -+ enabledLabel: 'siteSettingsViewportProtectionAllowed', -+ disabledLabel: 'siteSettingsViewportProtectionBlocked', -+ }, - ]; - - categoryItemMap = new Map(categoryList.map(item => [item.id, item])); -@@ -472,6 +480,7 @@ export class SettingsSiteSettingsPageElement extends - Id.TIMEZONE_OVERRIDE, - Id.WEBGL, - Id.WEBRTC, -+ Id.VIEWPORT, - ]), - }; - }, -diff --git a/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts b/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts ---- a/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts -+++ b/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts -@@ -87,6 +87,8 @@ export function getLocalizationStringForContentType( - return 'siteSettingsWebglMidSentence'; - case ContentSettingsTypes.WEBRTC: - return 'siteSettingsWebRTCMidSentence'; -+ case ContentSettingsTypes.VIEWPORT: -+ return 'siteSettingsViewportProtectionMidSentence'; - // The following members do not have a mid-sentence localization. - case ContentSettingsTypes.ANTI_ABUSE: - case ContentSettingsTypes.PDF_DOCUMENTS: -diff --git a/chrome/browser/ui/views/page_info/page_info_view_factory.cc b/chrome/browser/ui/views/page_info/page_info_view_factory.cc ---- a/chrome/browser/ui/views/page_info/page_info_view_factory.cc -+++ b/chrome/browser/ui/views/page_info/page_info_view_factory.cc -@@ -384,6 +384,9 @@ const ui::ImageModel PageInfoViewFactory::GetPermissionIcon( - case ContentSettingsType::WEBRTC: - icon = &vector_icons::kProtectedContentIcon; - break; -+ case ContentSettingsType::VIEWPORT: -+ icon = &vector_icons::kProtectedContentIcon; -+ break; - default: - // All other |ContentSettingsType|s do not have icons on desktop or are - // not shown in the Page Info bubble. -diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc ---- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc -+++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc -@@ -2556,6 +2556,13 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, - {"siteSettingsWebRTCAllowedExceptions",IDS_SETTINGS_SITE_SETTINGS_WEBRTC_ALLOWED_EXCEPTIONS}, - {"siteSettingsWebRTCBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_WEBRTC_BLOCKED_EXCEPTIONS}, - {"siteSettingsWebRTCMidSentence", IDS_SITE_SETTINGS_WEBRTC_TITLE}, -+ {"siteSettingsViewportProtection", IDS_SITE_SETTINGS_VIEWPORT_PROTECTION_TITLE}, -+ {"siteSettingsViewportProtectionDescription", IDS_SETTINGS_SITE_SETTINGS_VIEWPORT_PROTECTION_DESCRIPTION}, -+ {"siteSettingsViewportProtectionAllowed", IDS_SETTINGS_SITE_SETTINGS_VIEWPORT_PROTECTION_ALLOWED}, -+ {"siteSettingsViewportProtectionBlocked", IDS_SETTINGS_SITE_SETTINGS_VIEWPORT_PROTECTION_BLOCKED}, -+ {"siteSettingsViewportProtectionAllowedExceptions",IDS_SETTINGS_SITE_SETTINGS_VIEWPORT_PROTECTION_ALLOWED_EXCEPTIONS}, -+ {"siteSettingsViewportProtectionBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_VIEWPORT_PROTECTION_BLOCKED_EXCEPTIONS}, -+ {"siteSettingsViewportProtectionMidSentence", IDS_SITE_SETTINGS_VIEWPORT_PROTECTION_TITLE}, - {"addSite", IDS_SETTINGS_ADD_SITE}, - {"addSiteTitle", IDS_SETTINGS_ADD_SITE_TITLE}, - #if BUILDFLAG(IS_CHROMEOS_ASH) -diff --git a/chrome/browser/ui/webui/settings/site_settings_helper.cc b/chrome/browser/ui/webui/settings/site_settings_helper.cc ---- a/chrome/browser/ui/webui/settings/site_settings_helper.cc -+++ b/chrome/browser/ui/webui/settings/site_settings_helper.cc -@@ -130,6 +130,7 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = { - {ContentSettingsType::TIMEZONE_OVERRIDE, "timezone-override"}, - {ContentSettingsType::WEBGL, "webgl"}, - {ContentSettingsType::WEBRTC, "webrtc"}, -+ {ContentSettingsType::VIEWPORT, "viewport"}, - - // Add new content settings here if a corresponding Javascript string - // representation for it is not required, for example if the content setting diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteViewportContentSetting.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteViewportContentSetting.java new file mode 100644 --- /dev/null +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteViewportContentSetting.java -@@ -0,0 +1,88 @@ +@@ -0,0 +1,93 @@ +/* + This file is part of Bromite. + @@ -322,6 +90,11 @@ new file mode 100644 + } + + @Override ++ public int getCategoryDescription() { ++ return R.string.settings_site_settings_viewport_protection_description; ++ } ++ ++ @Override + public boolean requiresTriStateContentSetting() { + return false; + } @@ -341,34 +114,43 @@ new file mode 100644 + return value != ContentSettingValues.BLOCK; + } +} -diff --git a/components/browser_ui/strings/android/bromite_content_settings/viewport.grdp b/components/browser_ui/strings/android/bromite_content_settings/viewport.grdp +diff --git a/components/browser_ui/strings/bromite_content_settings/viewport.grdp b/components/browser_ui/strings/bromite_content_settings/viewport.grdp new file mode 100644 --- /dev/null -+++ b/components/browser_ui/strings/android/bromite_content_settings/viewport.grdp -@@ -0,0 +1,18 @@ ++++ b/components/browser_ui/strings/bromite_content_settings/viewport.grdp +@@ -0,0 +1,27 @@ + + -+ ++ + Viewport Size Protection + -+ ++ + Viewport Size Protection + -+ ++ + Viewport Size Protection + -+ ++ ++ Hides the screen size by randomly changing the values for each website ++ ++ + Enabled + -+ ++ + Disabled + ++ ++ Viewport Protection is enabled with these websites ++ ++ ++ Not allowed to use Viewport Protection ++ + diff --git a/components/content_settings/core/browser/bromite_content_settings/viewport.inc b/components/content_settings/core/browser/bromite_content_settings/viewport.inc new file mode 100644 --- /dev/null +++ b/components/content_settings/core/browser/bromite_content_settings/viewport.inc -@@ -0,0 +1,13 @@ +@@ -0,0 +1,22 @@ + Register(ContentSettingsType::VIEWPORT, "viewport", CONTENT_SETTING_ALLOW, + WebsiteSettingsInfo::SYNCABLE, + /*allowlisted_schemes=*/{}, @@ -377,11 +159,20 @@ new file mode 100644 + WebsiteSettingsInfo::TOP_ORIGIN_ONLY_SCOPE, + WebsiteSettingsRegistry::ALL_PLATFORMS, + ContentSettingsInfo::INHERIT_IN_INCOGNITO, -+ ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS, -+ /*show_into_info_page*/ true, -+ /*is_renderer_content_setting*/ true, -+ /*permission_type_ui*/ IDS_SITE_SETTINGS_TYPE_VIEWPORT, -+ /*permission_type_ui_mid_sentence*/ IDS_SITE_SETTINGS_TYPE_VIEWPORT_MID_SENTENCE); ++ ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); ++ ++ content_settings::WebsiteSettingsRegistry::GetInstance() ++ ->GetMutable(ContentSettingsType::VIEWPORT) ++ ->set_show_into_info_page() ++ .set_desktop_ui() ++ .set_is_renderer_content_setting() ++ .set_title_ui(IDS_SITE_SETTINGS_TYPE_VIEWPORT) ++ .set_description_ui(IDS_SETTINGS_SITE_SETTINGS_VIEWPORT_PROTECTION_DESCRIPTION) ++ .set_allowed_ui(IDS_WEBSITE_SETTINGS_CATEGORY_VIEWPORT_ENABLED) ++ .set_blocked_ui(IDS_WEBSITE_SETTINGS_CATEGORY_VIEWPORT_DISABLED) ++ .set_allowed_exceptions_ui(IDS_SETTINGS_SITE_SETTINGS_VIEWPORT_PROTECTION_ALLOWED_EXCEPTIONS) ++ .set_blocked_exceptions_ui(IDS_SETTINGS_SITE_SETTINGS_VIEWPORT_PROTECTION_BLOCKED_EXCEPTIONS) ++ .set_mid_sentence_ui(IDS_SITE_SETTINGS_TYPE_VIEWPORT_MID_SENTENCE); diff --git a/components/content_settings/core/common/bromite_content_settings/VIEWPORT.inc b/components/content_settings/core/common/bromite_content_settings/VIEWPORT.inc new file mode 100644 --- /dev/null diff --git a/build/patches/00WIN-ADDTO-Add-webGL-site-setting.patch b/build/patches/00WIN-ADDTO-Add-webGL-site-setting.patch deleted file mode 100644 index 4d3f8616..00000000 --- a/build/patches/00WIN-ADDTO-Add-webGL-site-setting.patch +++ /dev/null @@ -1,241 +0,0 @@ -From: Your Name -Date: Thu, 13 Oct 2022 08:12:18 +0000 -Subject: WIN ADDTO Add webGL site setting - ---- - chrome/app/settings_strings.grdp | 19 ++++++++++++++++ - chrome/browser/resources/settings/icons.html | 2 ++ - .../settings/privacy_page/privacy_page.html | 22 +++++++++++++++++++ - chrome/browser/resources/settings/route.ts | 1 + - chrome/browser/resources/settings/router.ts | 1 + - .../site_settings/category_default_setting.ts | 1 + - .../settings/site_settings/constants.ts | 1 + - .../settings_category_default_radio_group.ts | 1 + - .../settings/site_settings/site_details.html | 5 +++++ - .../site_settings_page/site_settings_page.ts | 9 ++++++++ - .../site_settings_page_util.ts | 2 ++ - .../views/page_info/page_info_view_factory.cc | 3 +++ - .../settings_localized_strings_provider.cc | 7 ++++++ - .../ui/webui/settings/site_settings_helper.cc | 1 + - 14 files changed, 75 insertions(+) - -diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp ---- a/chrome/app/settings_strings.grdp -+++ b/chrome/app/settings_strings.grdp -@@ -4396,6 +4396,25 @@ - Random Timezone override - - -+ -+ Webgl -+ -+ -+ Enable Webgl -+ -+ -+ Webgl is enabled -+ -+ -+ Webgl is disabled -+ -+ -+ Allowed to use webgl -+ -+ -+ Not allowed to use webgl -+ -+ - - - -diff --git a/chrome/browser/resources/settings/icons.html b/chrome/browser/resources/settings/icons.html ---- a/chrome/browser/resources/settings/icons.html -+++ b/chrome/browser/resources/settings/icons.html -@@ -197,6 +197,8 @@ NOTE: Chrome OS icons go in ./chromeos/os_icons.html. - - - -+ -+ - - - -diff --git a/chrome/browser/resources/settings/privacy_page/privacy_page.html b/chrome/browser/resources/settings/privacy_page/privacy_page.html ---- a/chrome/browser/resources/settings/privacy_page/privacy_page.html -+++ b/chrome/browser/resources/settings/privacy_page/privacy_page.html -@@ -1170,4 +1170,26 @@ - - - -+ - -diff --git a/chrome/browser/resources/settings/route.ts b/chrome/browser/resources/settings/route.ts ---- a/chrome/browser/resources/settings/route.ts -+++ b/chrome/browser/resources/settings/route.ts -@@ -125,6 +125,7 @@ function addPrivacyChildRoutes(r: Partial) { - r.SITE_SETTINGS_AUTOPLAY = r.SITE_SETTINGS.createChild('autoplay'); - r.SITE_SETTINGS_JAVASCRIPT_JIT = r.SITE_SETTINGS.createChild('javascript-jit'); - r.SITE_SETTINGS_TIMEZONE_OVERRIDE = r.SITE_SETTINGS.createChild('timezone-override'); -+ r.SITE_SETTINGS_WEBGL = r.SITE_SETTINGS.createChild('webgl'); - } - - /** -diff --git a/chrome/browser/resources/settings/router.ts b/chrome/browser/resources/settings/router.ts ---- a/chrome/browser/resources/settings/router.ts -+++ b/chrome/browser/resources/settings/router.ts -@@ -107,6 +107,7 @@ export interface SettingsRoutes { - SITE_SETTINGS_AUTOPLAY: Route; - SITE_SETTINGS_JAVASCRIPT_JIT: Route; - SITE_SETTINGS_TIMEZONE_OVERRIDE: Route; -+ SITE_SETTINGS_WEBGL: Route; - } - - /** Class for navigable routes. */ -diff --git a/chrome/browser/resources/settings/site_settings/category_default_setting.ts b/chrome/browser/resources/settings/site_settings/category_default_setting.ts ---- a/chrome/browser/resources/settings/site_settings/category_default_setting.ts -+++ b/chrome/browser/resources/settings/site_settings/category_default_setting.ts -@@ -198,6 +198,7 @@ export class CategoryDefaultSettingElement extends - case ContentSettingsTypes.AUTOPLAY: - case ContentSettingsTypes.JAVASCRIPT_JIT: - case ContentSettingsTypes.TIMEZONE_OVERRIDE: -+ case ContentSettingsTypes.WEBGL: - // "Allowed" vs "Blocked". - this.browserProxy.setDefaultValueForContentType( - this.category, -diff --git a/chrome/browser/resources/settings/site_settings/constants.ts b/chrome/browser/resources/settings/site_settings/constants.ts ---- a/chrome/browser/resources/settings/site_settings/constants.ts -+++ b/chrome/browser/resources/settings/site_settings/constants.ts -@@ -49,6 +49,7 @@ export enum ContentSettingsTypes { - AUTOPLAY = 'autoplay', - JAVASCRIPT_JIT = 'javascript-jit', - TIMEZONE_OVERRIDE = 'timezone-override', -+ WEBGL = 'webgl', - - // The following items are not in the C++ kContentSettingsTypeGroupNames, but - // are used everywhere where ContentSettingsTypes is used in JS. -diff --git a/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts b/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts ---- a/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts -+++ b/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts -@@ -142,6 +142,7 @@ export class SettingsCategoryDefaultRadioGroupElement extends - case ContentSettingsTypes.AUTOPLAY: - case ContentSettingsTypes.JAVASCRIPT_JIT: - case ContentSettingsTypes.TIMEZONE_OVERRIDE: -+ case ContentSettingsTypes.WEBGL: - // "Allowed" vs "Blocked". - return ContentSetting.ALLOW; - case ContentSettingsTypes.AR: -diff --git a/chrome/browser/resources/settings/site_settings/site_details.html b/chrome/browser/resources/settings/site_settings/site_details.html ---- a/chrome/browser/resources/settings/site_settings/site_details.html -+++ b/chrome/browser/resources/settings/site_settings/site_details.html -@@ -281,4 +281,9 @@ - icon="settings:timezone-override" - label="$i18n{siteSettingsTimezoneOverride}"> - -+ -+ - -diff --git a/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts b/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts ---- a/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts -+++ b/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts -@@ -358,6 +358,14 @@ function getCategoryItemMap(): Map { - enabledLabel: 'siteSettingsTimezoneOverrideAllowed', - disabledLabel: 'siteSettingsTimezoneOverrideBlocked', - }, -+ { -+ route: routes.SITE_SETTINGS_WEBGL, -+ id: Id.WEBGL, -+ label: 'siteSettingsWebgl', -+ icon: 'settings:webgl', -+ enabledLabel: 'siteSettingsWebglAllowed', -+ disabledLabel: 'siteSettingsWebglBlocked', -+ }, - ]; - - categoryItemMap = new Map(categoryList.map(item => [item.id, item])); -@@ -454,6 +462,7 @@ export class SettingsSiteSettingsPageElement extends - Id.AUTOPLAY, - Id.JAVASCRIPT_JIT, - Id.TIMEZONE_OVERRIDE, -+ Id.WEBGL, - ]), - }; - }, -diff --git a/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts b/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts ---- a/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts -+++ b/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts -@@ -83,6 +83,8 @@ export function getLocalizationStringForContentType( - return 'siteSettingsJavascriptJITMidSentence'; - case ContentSettingsTypes.TIMEZONE_OVERRIDE: - return 'siteSettingsTimezoneOverrideMidSentence'; -+ case ContentSettingsTypes.WEBGL: -+ return 'siteSettingsWebglMidSentence'; - // The following members do not have a mid-sentence localization. - case ContentSettingsTypes.ANTI_ABUSE: - case ContentSettingsTypes.PDF_DOCUMENTS: -diff --git a/chrome/browser/ui/views/page_info/page_info_view_factory.cc b/chrome/browser/ui/views/page_info/page_info_view_factory.cc ---- a/chrome/browser/ui/views/page_info/page_info_view_factory.cc -+++ b/chrome/browser/ui/views/page_info/page_info_view_factory.cc -@@ -378,6 +378,9 @@ const ui::ImageModel PageInfoViewFactory::GetPermissionIcon( - case ContentSettingsType::TIMEZONE_OVERRIDE: - icon = &vector_icons::kAccountCircleIcon; - break; -+ case ContentSettingsType::WEBGL: -+ icon = &vector_icons::kProtectedContentIcon; -+ break; - default: - // All other |ContentSettingsType|s do not have icons on desktop or are - // not shown in the Page Info bubble. -diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc ---- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc -+++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc -@@ -2542,6 +2542,13 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, - {"siteSettingsTimezoneOverrideAllowedExceptions",IDS_SETTINGS_SITE_SETTINGS_TIMEZONE_OVERRIDE_ALLOWED_EXCEPTIONS}, - {"siteSettingsTimezoneOverrideBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_TIMEZONE_OVERRIDE_BLOCKED_EXCEPTIONS}, - {"siteSettingsTimezoneOverrideMidSentence", IDS_SITE_SETTINGS_TIMEZONE_OVERRIDE_TITLE}, -+ {"siteSettingsWebgl", IDS_SITE_SETTINGS_WEBGL_TITLE}, -+ {"siteSettingsWebglDescription", IDS_SETTINGS_SITE_SETTINGS_WEBGL_DESCRIPTION}, -+ {"siteSettingsWebglAllowed", IDS_SETTINGS_SITE_SETTINGS_WEBGL_ALLOWED}, -+ {"siteSettingsWebglBlocked", IDS_SETTINGS_SITE_SETTINGS_WEBGL_BLOCKED}, -+ {"siteSettingsWebglAllowedExceptions",IDS_SETTINGS_SITE_SETTINGS_WEBGL_ALLOWED_EXCEPTIONS}, -+ {"siteSettingsWebglBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_WEBGL_BLOCKED_EXCEPTIONS}, -+ {"siteSettingsWebglMidSentence", IDS_SITE_SETTINGS_WEBGL_TITLE}, - {"addSite", IDS_SETTINGS_ADD_SITE}, - {"addSiteTitle", IDS_SETTINGS_ADD_SITE_TITLE}, - #if BUILDFLAG(IS_CHROMEOS_ASH) -diff --git a/chrome/browser/ui/webui/settings/site_settings_helper.cc b/chrome/browser/ui/webui/settings/site_settings_helper.cc ---- a/chrome/browser/ui/webui/settings/site_settings_helper.cc -+++ b/chrome/browser/ui/webui/settings/site_settings_helper.cc -@@ -128,6 +128,7 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = { - {ContentSettingsType::AUTOPLAY, "autoplay"}, - {ContentSettingsType::JAVASCRIPT_JIT, "javascript-jit"}, - {ContentSettingsType::TIMEZONE_OVERRIDE, "timezone-override"}, -+ {ContentSettingsType::WEBGL, "webgl"}, - - // Add new content settings here if a corresponding Javascript string - // representation for it is not required, for example if the content setting --- -2.25.1 diff --git a/build/patches/00WIN-ADDTO-Add-webRTC-site-settings.patch b/build/patches/00WIN-ADDTO-Add-webRTC-site-settings.patch deleted file mode 100644 index d167e3de..00000000 --- a/build/patches/00WIN-ADDTO-Add-webRTC-site-settings.patch +++ /dev/null @@ -1,241 +0,0 @@ -From: Your Name -Date: Thu, 13 Oct 2022 08:52:11 +0000 -Subject: WIN ADDTO Add webRTC site settings - ---- - chrome/app/settings_strings.grdp | 19 ++++++++++++++++ - chrome/browser/resources/settings/icons.html | 2 ++ - .../settings/privacy_page/privacy_page.html | 22 +++++++++++++++++++ - chrome/browser/resources/settings/route.ts | 1 + - chrome/browser/resources/settings/router.ts | 1 + - .../site_settings/category_default_setting.ts | 1 + - .../settings/site_settings/constants.ts | 1 + - .../settings_category_default_radio_group.ts | 1 + - .../settings/site_settings/site_details.html | 5 +++++ - .../site_settings_page/site_settings_page.ts | 9 ++++++++ - .../site_settings_page_util.ts | 2 ++ - .../views/page_info/page_info_view_factory.cc | 3 +++ - .../settings_localized_strings_provider.cc | 7 ++++++ - .../ui/webui/settings/site_settings_helper.cc | 1 + - 14 files changed, 75 insertions(+) - -diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp ---- a/chrome/app/settings_strings.grdp -+++ b/chrome/app/settings_strings.grdp -@@ -4415,6 +4415,25 @@ - Not allowed to use webgl - - -+ -+ WebRTC -+ -+ -+ Enable WebRTC -+ -+ -+ WebRTC is enabled -+ -+ -+ WebRTC is disabled -+ -+ -+ Allowed to use WebRTC -+ -+ -+ Not allowed to use WebRTC -+ -+ - - - -diff --git a/chrome/browser/resources/settings/icons.html b/chrome/browser/resources/settings/icons.html ---- a/chrome/browser/resources/settings/icons.html -+++ b/chrome/browser/resources/settings/icons.html -@@ -199,6 +199,8 @@ NOTE: Chrome OS icons go in ./chromeos/os_icons.html. - - - -+ -+ - - - -diff --git a/chrome/browser/resources/settings/privacy_page/privacy_page.html b/chrome/browser/resources/settings/privacy_page/privacy_page.html ---- a/chrome/browser/resources/settings/privacy_page/privacy_page.html -+++ b/chrome/browser/resources/settings/privacy_page/privacy_page.html -@@ -1192,4 +1192,26 @@ - - - -+ - -diff --git a/chrome/browser/resources/settings/route.ts b/chrome/browser/resources/settings/route.ts ---- a/chrome/browser/resources/settings/route.ts -+++ b/chrome/browser/resources/settings/route.ts -@@ -126,6 +126,7 @@ function addPrivacyChildRoutes(r: Partial) { - r.SITE_SETTINGS_JAVASCRIPT_JIT = r.SITE_SETTINGS.createChild('javascript-jit'); - r.SITE_SETTINGS_TIMEZONE_OVERRIDE = r.SITE_SETTINGS.createChild('timezone-override'); - r.SITE_SETTINGS_WEBGL = r.SITE_SETTINGS.createChild('webgl'); -+ r.SITE_SETTINGS_WEBRTC = r.SITE_SETTINGS.createChild('webrtc'); - } - - /** -diff --git a/chrome/browser/resources/settings/router.ts b/chrome/browser/resources/settings/router.ts ---- a/chrome/browser/resources/settings/router.ts -+++ b/chrome/browser/resources/settings/router.ts -@@ -108,6 +108,7 @@ export interface SettingsRoutes { - SITE_SETTINGS_JAVASCRIPT_JIT: Route; - SITE_SETTINGS_TIMEZONE_OVERRIDE: Route; - SITE_SETTINGS_WEBGL: Route; -+ SITE_SETTINGS_WEBRTC: Route; - } - - /** Class for navigable routes. */ -diff --git a/chrome/browser/resources/settings/site_settings/category_default_setting.ts b/chrome/browser/resources/settings/site_settings/category_default_setting.ts ---- a/chrome/browser/resources/settings/site_settings/category_default_setting.ts -+++ b/chrome/browser/resources/settings/site_settings/category_default_setting.ts -@@ -199,6 +199,7 @@ export class CategoryDefaultSettingElement extends - case ContentSettingsTypes.JAVASCRIPT_JIT: - case ContentSettingsTypes.TIMEZONE_OVERRIDE: - case ContentSettingsTypes.WEBGL: -+ case ContentSettingsTypes.WEBRTC: - // "Allowed" vs "Blocked". - this.browserProxy.setDefaultValueForContentType( - this.category, -diff --git a/chrome/browser/resources/settings/site_settings/constants.ts b/chrome/browser/resources/settings/site_settings/constants.ts ---- a/chrome/browser/resources/settings/site_settings/constants.ts -+++ b/chrome/browser/resources/settings/site_settings/constants.ts -@@ -50,6 +50,7 @@ export enum ContentSettingsTypes { - JAVASCRIPT_JIT = 'javascript-jit', - TIMEZONE_OVERRIDE = 'timezone-override', - WEBGL = 'webgl', -+ WEBRTC = 'webrtc', - - // The following items are not in the C++ kContentSettingsTypeGroupNames, but - // are used everywhere where ContentSettingsTypes is used in JS. -diff --git a/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts b/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts ---- a/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts -+++ b/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts -@@ -143,6 +143,7 @@ export class SettingsCategoryDefaultRadioGroupElement extends - case ContentSettingsTypes.JAVASCRIPT_JIT: - case ContentSettingsTypes.TIMEZONE_OVERRIDE: - case ContentSettingsTypes.WEBGL: -+ case ContentSettingsTypes.WEBRTC: - // "Allowed" vs "Blocked". - return ContentSetting.ALLOW; - case ContentSettingsTypes.AR: -diff --git a/chrome/browser/resources/settings/site_settings/site_details.html b/chrome/browser/resources/settings/site_settings/site_details.html ---- a/chrome/browser/resources/settings/site_settings/site_details.html -+++ b/chrome/browser/resources/settings/site_settings/site_details.html -@@ -286,4 +286,9 @@ - icon="settings:webgl" - label="$i18n{siteSettingsWebgl}"> - -+ -+ - -diff --git a/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts b/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts ---- a/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts -+++ b/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts -@@ -366,6 +366,14 @@ function getCategoryItemMap(): Map { - enabledLabel: 'siteSettingsWebglAllowed', - disabledLabel: 'siteSettingsWebglBlocked', - }, -+ { -+ route: routes.SITE_SETTINGS_WEBRTC, -+ id: Id.WEBRTC, -+ label: 'siteSettingsWebRTC', -+ icon: 'settings:webrtc', -+ enabledLabel: 'siteSettingsWebRTCAllowed', -+ disabledLabel: 'siteSettingsWebRTCBlocked', -+ }, - ]; - - categoryItemMap = new Map(categoryList.map(item => [item.id, item])); -@@ -463,6 +471,7 @@ export class SettingsSiteSettingsPageElement extends - Id.JAVASCRIPT_JIT, - Id.TIMEZONE_OVERRIDE, - Id.WEBGL, -+ Id.WEBRTC, - ]), - }; - }, -diff --git a/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts b/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts ---- a/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts -+++ b/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts -@@ -85,6 +85,8 @@ export function getLocalizationStringForContentType( - return 'siteSettingsTimezoneOverrideMidSentence'; - case ContentSettingsTypes.WEBGL: - return 'siteSettingsWebglMidSentence'; -+ case ContentSettingsTypes.WEBRTC: -+ return 'siteSettingsWebRTCMidSentence'; - // The following members do not have a mid-sentence localization. - case ContentSettingsTypes.ANTI_ABUSE: - case ContentSettingsTypes.PDF_DOCUMENTS: -diff --git a/chrome/browser/ui/views/page_info/page_info_view_factory.cc b/chrome/browser/ui/views/page_info/page_info_view_factory.cc ---- a/chrome/browser/ui/views/page_info/page_info_view_factory.cc -+++ b/chrome/browser/ui/views/page_info/page_info_view_factory.cc -@@ -381,6 +381,9 @@ const ui::ImageModel PageInfoViewFactory::GetPermissionIcon( - case ContentSettingsType::WEBGL: - icon = &vector_icons::kProtectedContentIcon; - break; -+ case ContentSettingsType::WEBRTC: -+ icon = &vector_icons::kProtectedContentIcon; -+ break; - default: - // All other |ContentSettingsType|s do not have icons on desktop or are - // not shown in the Page Info bubble. -diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc ---- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc -+++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc -@@ -2549,6 +2549,13 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, - {"siteSettingsWebglAllowedExceptions",IDS_SETTINGS_SITE_SETTINGS_WEBGL_ALLOWED_EXCEPTIONS}, - {"siteSettingsWebglBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_WEBGL_BLOCKED_EXCEPTIONS}, - {"siteSettingsWebglMidSentence", IDS_SITE_SETTINGS_WEBGL_TITLE}, -+ {"siteSettingsWebRTC", IDS_SITE_SETTINGS_WEBRTC_TITLE}, -+ {"siteSettingsWebRTCDescription", IDS_SETTINGS_SITE_SETTINGS_WEBRTC_DESCRIPTION}, -+ {"siteSettingsWebRTCAllowed", IDS_SETTINGS_SITE_SETTINGS_WEBRTC_ALLOWED}, -+ {"siteSettingsWebRTCBlocked", IDS_SETTINGS_SITE_SETTINGS_WEBRTC_BLOCKED}, -+ {"siteSettingsWebRTCAllowedExceptions",IDS_SETTINGS_SITE_SETTINGS_WEBRTC_ALLOWED_EXCEPTIONS}, -+ {"siteSettingsWebRTCBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_WEBRTC_BLOCKED_EXCEPTIONS}, -+ {"siteSettingsWebRTCMidSentence", IDS_SITE_SETTINGS_WEBRTC_TITLE}, - {"addSite", IDS_SETTINGS_ADD_SITE}, - {"addSiteTitle", IDS_SETTINGS_ADD_SITE_TITLE}, - #if BUILDFLAG(IS_CHROMEOS_ASH) -diff --git a/chrome/browser/ui/webui/settings/site_settings_helper.cc b/chrome/browser/ui/webui/settings/site_settings_helper.cc ---- a/chrome/browser/ui/webui/settings/site_settings_helper.cc -+++ b/chrome/browser/ui/webui/settings/site_settings_helper.cc -@@ -129,6 +129,7 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = { - {ContentSettingsType::JAVASCRIPT_JIT, "javascript-jit"}, - {ContentSettingsType::TIMEZONE_OVERRIDE, "timezone-override"}, - {ContentSettingsType::WEBGL, "webgl"}, -+ {ContentSettingsType::WEBRTC, "webrtc"}, - - // Add new content settings here if a corresponding Javascript string - // representation for it is not required, for example if the content setting --- -2.25.1 diff --git a/build/patches/00WIN-ADDTO-JIT-site-settings--fixup-.patch b/build/patches/00WIN-ADDTO-JIT-site-settings--fixup-.patch deleted file mode 100644 index 7e431122..00000000 --- a/build/patches/00WIN-ADDTO-JIT-site-settings--fixup-.patch +++ /dev/null @@ -1,22 +0,0 @@ -From: Your Name -Date: Tue, 13 Jun 2023 15:52:08 +0000 -Subject: WIN ADDTO JIT site settings (fixup) - ---- - .../ui/webui/settings/settings_localized_strings_provider.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc ---- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc -+++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc -@@ -2534,7 +2534,7 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, - {"siteSettingsJavascriptJITBlocked", IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_JIT_BLOCKED}, - {"siteSettingsJavascriptJITAllowedExceptions",IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_JIT_ALLOWED_EXCEPTIONS}, - {"siteSettingsJavascriptJITBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_JIT_BLOCKED_EXCEPTIONS}, -- {"siteSettingsJavascriptJITMidSentence", IDS_SITE_SETTINGS_TYPE_JAVASCRIPT_JIT}, -+ {"siteSettingsJavascriptJITMidSentence", IDS_JAVASCRIPT_JIT_PERMISSION_TITLE}, - {"siteSettingsTimezoneOverride", IDS_SITE_SETTINGS_TIMEZONE_OVERRIDE_TITLE}, - {"siteSettingsTimezoneOverrideDescription", IDS_SETTINGS_SITE_SETTINGS_TIMEZONE_OVERRIDE_DESCRIPTION}, - {"siteSettingsTimezoneOverrideAllowed", IDS_SETTINGS_SITE_SETTINGS_TIMEZONE_OVERRIDE_ALLOWED}, --- -2.25.1 diff --git a/build/patches/00WIN-ADDTO-JIT-site-settings.patch b/build/patches/00WIN-ADDTO-JIT-site-settings.patch deleted file mode 100644 index 0e037611..00000000 --- a/build/patches/00WIN-ADDTO-JIT-site-settings.patch +++ /dev/null @@ -1,271 +0,0 @@ -From: Your Name -Date: Wed, 12 Oct 2022 14:03:37 +0000 -Subject: WIN ADDTO JIT site settings - ---- - chrome/app/settings_strings.grdp | 19 ++++++++++++++++ - chrome/browser/resources/settings/icons.html | 2 ++ - .../settings/privacy_page/privacy_page.html | 22 +++++++++++++++++++ - chrome/browser/resources/settings/route.ts | 1 + - chrome/browser/resources/settings/router.ts | 1 + - .../site_settings/category_default_setting.ts | 1 + - .../settings/site_settings/constants.ts | 1 + - .../settings_category_default_radio_group.ts | 1 + - .../settings/site_settings/site_details.html | 5 +++++ - .../site_settings_page/site_settings_page.ts | 9 ++++++++ - .../site_settings_page_util.ts | 2 ++ - .../views/page_info/page_info_view_factory.cc | 3 +++ - .../settings_localized_strings_provider.cc | 7 ++++++ - .../ui/webui/settings/site_settings_helper.cc | 3 ++- - .../core/browser/content_settings_registry.cc | 3 ++- - 15 files changed, 78 insertions(+), 2 deletions(-) - -diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp ---- a/chrome/app/settings_strings.grdp -+++ b/chrome/app/settings_strings.grdp -@@ -4358,6 +4358,25 @@ - Not allowed to autoplay - - -+ -+ Javascript JIT -+ -+ -+ Enable the JIT compiler in V8 -+ -+ -+ Javascript JIT is enabled -+ -+ -+ Javascript JIT is disabled -+ -+ -+ Allowed to Javascript JIT -+ -+ -+ Not allowed to Javascript JIT -+ -+ - - - -diff --git a/chrome/browser/resources/settings/icons.html b/chrome/browser/resources/settings/icons.html ---- a/chrome/browser/resources/settings/icons.html -+++ b/chrome/browser/resources/settings/icons.html -@@ -193,6 +193,8 @@ NOTE: Chrome OS icons go in ./chromeos/os_icons.html. - - - -+ -+ - - - -diff --git a/chrome/browser/resources/settings/privacy_page/privacy_page.html b/chrome/browser/resources/settings/privacy_page/privacy_page.html ---- a/chrome/browser/resources/settings/privacy_page/privacy_page.html -+++ b/chrome/browser/resources/settings/privacy_page/privacy_page.html -@@ -1126,4 +1126,26 @@ - - - -+ - -diff --git a/chrome/browser/resources/settings/route.ts b/chrome/browser/resources/settings/route.ts ---- a/chrome/browser/resources/settings/route.ts -+++ b/chrome/browser/resources/settings/route.ts -@@ -123,6 +123,7 @@ function addPrivacyChildRoutes(r: Partial) { - r.SITE_SETTINGS_FILE_SYSTEM_WRITE = r.SITE_SETTINGS.createChild('filesystem'); - r.SITE_SETTINGS_LOCAL_FONTS = r.SITE_SETTINGS.createChild('localFonts'); - r.SITE_SETTINGS_AUTOPLAY = r.SITE_SETTINGS.createChild('autoplay'); -+ r.SITE_SETTINGS_JAVASCRIPT_JIT = r.SITE_SETTINGS.createChild('javascript-jit'); - } - - /** -diff --git a/chrome/browser/resources/settings/router.ts b/chrome/browser/resources/settings/router.ts ---- a/chrome/browser/resources/settings/router.ts -+++ b/chrome/browser/resources/settings/router.ts -@@ -105,6 +105,7 @@ export interface SettingsRoutes { - SYSTEM: Route; - TRIGGERED_RESET_DIALOG: Route; - SITE_SETTINGS_AUTOPLAY: Route; -+ SITE_SETTINGS_JAVASCRIPT_JIT: Route; - } - - /** Class for navigable routes. */ -diff --git a/chrome/browser/resources/settings/site_settings/category_default_setting.ts b/chrome/browser/resources/settings/site_settings/category_default_setting.ts ---- a/chrome/browser/resources/settings/site_settings/category_default_setting.ts -+++ b/chrome/browser/resources/settings/site_settings/category_default_setting.ts -@@ -196,6 +196,7 @@ export class CategoryDefaultSettingElement extends - case ContentSettingsTypes.SENSORS: - case ContentSettingsTypes.SOUND: - case ContentSettingsTypes.AUTOPLAY: -+ case ContentSettingsTypes.JAVASCRIPT_JIT: - // "Allowed" vs "Blocked". - this.browserProxy.setDefaultValueForContentType( - this.category, -diff --git a/chrome/browser/resources/settings/site_settings/constants.ts b/chrome/browser/resources/settings/site_settings/constants.ts ---- a/chrome/browser/resources/settings/site_settings/constants.ts -+++ b/chrome/browser/resources/settings/site_settings/constants.ts -@@ -47,6 +47,7 @@ export enum ContentSettingsTypes { - WINDOW_MANAGEMENT = 'window-placement', - ZOOM_LEVELS = 'zoom-levels', - AUTOPLAY = 'autoplay', -+ JAVASCRIPT_JIT = 'javascript-jit', - - // The following items are not in the C++ kContentSettingsTypeGroupNames, but - // are used everywhere where ContentSettingsTypes is used in JS. -diff --git a/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts b/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts ---- a/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts -+++ b/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts -@@ -140,6 +140,7 @@ export class SettingsCategoryDefaultRadioGroupElement extends - case ContentSettingsTypes.SENSORS: - case ContentSettingsTypes.SOUND: - case ContentSettingsTypes.AUTOPLAY: -+ case ContentSettingsTypes.JAVASCRIPT_JIT: - // "Allowed" vs "Blocked". - return ContentSetting.ALLOW; - case ContentSettingsTypes.AR: -diff --git a/chrome/browser/resources/settings/site_settings/site_details.html b/chrome/browser/resources/settings/site_settings/site_details.html ---- a/chrome/browser/resources/settings/site_settings/site_details.html -+++ b/chrome/browser/resources/settings/site_settings/site_details.html -@@ -271,4 +271,9 @@ - icon="settings:federated-identity-api" - label="$i18n{siteSettingsFederatedIdentityApi}"> - -+ -+ - -diff --git a/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts b/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts ---- a/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts -+++ b/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts -@@ -342,6 +342,14 @@ function getCategoryItemMap(): Map { - enabledLabel: 'siteSettingsAutoplayAllowed', - disabledLabel: 'siteSettingsAutoplayBlocked', - }, -+ { -+ route: routes.SITE_SETTINGS_JAVASCRIPT_JIT, -+ id: Id.JAVASCRIPT_JIT, -+ label: 'siteSettingsJavascriptJIT', -+ icon: 'settings:javascript-jit', -+ enabledLabel: 'siteSettingsJavascriptJITAllowed', -+ disabledLabel: 'siteSettingsJavascriptJITBlocked', -+ }, - ]; - - categoryItemMap = new Map(categoryList.map(item => [item.id, item])); -@@ -436,6 +444,7 @@ export class SettingsSiteSettingsPageElement extends - Id.ANTI_ABUSE, - Id.SITE_DATA, - Id.AUTOPLAY, -+ Id.JAVASCRIPT_JIT, - ]), - }; - }, -diff --git a/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts b/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts ---- a/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts -+++ b/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts -@@ -79,6 +79,8 @@ export function getLocalizationStringForContentType( - return 'siteSettingsZoomLevelsMidSentence'; - case ContentSettingsTypes.AUTOPLAY: - return 'siteSettingsAutoplayMidSentence'; -+ case ContentSettingsTypes.JAVASCRIPT_JIT: -+ return 'siteSettingsJavascriptJITMidSentence'; - // The following members do not have a mid-sentence localization. - case ContentSettingsTypes.ANTI_ABUSE: - case ContentSettingsTypes.PDF_DOCUMENTS: -diff --git a/chrome/browser/ui/views/page_info/page_info_view_factory.cc b/chrome/browser/ui/views/page_info/page_info_view_factory.cc ---- a/chrome/browser/ui/views/page_info/page_info_view_factory.cc -+++ b/chrome/browser/ui/views/page_info/page_info_view_factory.cc -@@ -372,6 +372,9 @@ const ui::ImageModel PageInfoViewFactory::GetPermissionIcon( - case ContentSettingsType::AUTOPLAY: - icon = &vector_icons::kProtectedContentIcon; - break; -+ case ContentSettingsType::JAVASCRIPT_JIT: -+ icon = &vector_icons::kCodeIcon; -+ break; - default: - // All other |ContentSettingsType|s do not have icons on desktop or are - // not shown in the Page Info bubble. -diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc ---- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc -+++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc -@@ -2528,6 +2528,13 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, - {"siteSettingsAutoplayAllowedExceptions",IDS_SETTINGS_SITE_SETTINGS_AUTOPLAY_ALLOWED_EXCEPTIONS}, - {"siteSettingsAutoplayBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_AUTOPLAY_BLOCKED_EXCEPTIONS}, - {"siteSettingsAutoplayMidSentence", IDS_AUTOPLAY_PERMISSION_TITLE}, -+ {"siteSettingsJavascriptJIT", IDS_SITE_SETTINGS_JAVASCRIPT_JIT_TITLE}, -+ {"siteSettingsJavascriptJITDescription", IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_JIT_DESCRIPTION}, -+ {"siteSettingsJavascriptJITAllowed", IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_JIT_ALLOWED}, -+ {"siteSettingsJavascriptJITBlocked", IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_JIT_BLOCKED}, -+ {"siteSettingsJavascriptJITAllowedExceptions",IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_JIT_ALLOWED_EXCEPTIONS}, -+ {"siteSettingsJavascriptJITBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_JIT_BLOCKED_EXCEPTIONS}, -+ {"siteSettingsJavascriptJITMidSentence", IDS_SITE_SETTINGS_TYPE_JAVASCRIPT_JIT}, - {"addSite", IDS_SETTINGS_ADD_SITE}, - {"addSiteTitle", IDS_SETTINGS_ADD_SITE_TITLE}, - #if BUILDFLAG(IS_CHROMEOS_ASH) -diff --git a/chrome/browser/ui/webui/settings/site_settings_helper.cc b/chrome/browser/ui/webui/settings/site_settings_helper.cc ---- a/chrome/browser/ui/webui/settings/site_settings_helper.cc -+++ b/chrome/browser/ui/webui/settings/site_settings_helper.cc -@@ -126,6 +126,7 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = { - "private-network-devices-data"}, - {ContentSettingsType::ANTI_ABUSE, "anti-abuse"}, - {ContentSettingsType::AUTOPLAY, "autoplay"}, -+ {ContentSettingsType::JAVASCRIPT_JIT, "javascript-jit"}, - - // Add new content settings here if a corresponding Javascript string - // representation for it is not required, for example if the content setting -@@ -162,7 +163,6 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = { - {ContentSettingsType::FILE_SYSTEM_LAST_PICKED_DIRECTORY, nullptr}, - {ContentSettingsType::DISPLAY_CAPTURE, nullptr}, - {ContentSettingsType::FEDERATED_IDENTITY_SHARING, nullptr}, -- {ContentSettingsType::JAVASCRIPT_JIT, nullptr}, - {ContentSettingsType::HTTP_ALLOWED, nullptr}, - {ContentSettingsType::HTTPS_ENFORCED, nullptr}, - {ContentSettingsType::FORMFILL_METADATA, nullptr}, -@@ -536,6 +536,7 @@ const std::vector& GetVisiblePermissionCategories() { - } - - base_types->push_back(ContentSettingsType::AUTOPLAY); -+ base_types->push_back(ContentSettingsType::JAVASCRIPT_JIT); - - initialized = true; - } -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 -@@ -518,7 +518,8 @@ void ContentSettingsRegistry::Init() { - ContentSettingsInfo::EXCEPTIONS_ON_SECURE_ORIGINS_ONLY); - - Register(ContentSettingsType::JAVASCRIPT_JIT, "javascript-jit", -- CONTENT_SETTING_BLOCK, WebsiteSettingsInfo::UNSYNCABLE, -+ CONTENT_SETTING_BLOCK, -+ WebsiteSettingsInfo::UNSYNCABLE, - /*allowlisted_schemes=*/{}, - /*valid_settings=*/{CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK}, - WebsiteSettingsInfo::TOP_ORIGIN_ONLY_SCOPE, --- -2.25.1 diff --git a/build/patches/00WIN-ADDTO-Revert-the-removal-to-block-autoplay.patch b/build/patches/00WIN-ADDTO-Revert-the-removal-to-block-autoplay.patch deleted file mode 100644 index 03a3ef64..00000000 --- a/build/patches/00WIN-ADDTO-Revert-the-removal-to-block-autoplay.patch +++ /dev/null @@ -1,258 +0,0 @@ -From: Your Name -Date: Wed, 12 Oct 2022 12:49:31 +0000 -Subject: WIN ADDTO Revert the removal to block autoplay - ---- - chrome/app/settings_strings.grdp | 19 ++++++++++++++++ - chrome/browser/resources/settings/icons.html | 2 ++ - .../settings/privacy_page/privacy_page.html | 22 +++++++++++++++++++ - chrome/browser/resources/settings/route.ts | 1 + - chrome/browser/resources/settings/router.ts | 1 + - .../site_settings/category_default_setting.ts | 1 + - .../settings/site_settings/constants.ts | 1 + - .../settings_category_default_radio_group.ts | 1 + - .../settings/site_settings/site_details.html | 5 +++++ - .../site_settings_page/site_settings_page.ts | 9 ++++++++ - .../site_settings_page_util.ts | 2 ++ - .../views/page_info/page_info_view_factory.cc | 3 +++ - .../settings_localized_strings_provider.cc | 7 ++++++ - .../ui/webui/settings/site_settings_helper.cc | 4 +++- - 14 files changed, 77 insertions(+), 1 deletion(-) - -diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp ---- a/chrome/app/settings_strings.grdp -+++ b/chrome/app/settings_strings.grdp -@@ -4339,6 +4339,25 @@ - Control how your browsing history is used to personalize Search and more - - -+ -+ Autoplay -+ -+ -+ Allow automatic start of video contents -+ -+ -+ Autoplay is enabled -+ -+ -+ Autoplay is disabled -+ -+ -+ Allowed to autoplay -+ -+ -+ Not allowed to autoplay -+ -+ - - - -diff --git a/chrome/browser/resources/settings/icons.html b/chrome/browser/resources/settings/icons.html ---- a/chrome/browser/resources/settings/icons.html -+++ b/chrome/browser/resources/settings/icons.html -@@ -191,6 +191,8 @@ NOTE: Chrome OS icons go in ./chromeos/os_icons.html. - - - -+ -+ - - - -diff --git a/chrome/browser/resources/settings/privacy_page/privacy_page.html b/chrome/browser/resources/settings/privacy_page/privacy_page.html ---- a/chrome/browser/resources/settings/privacy_page/privacy_page.html -+++ b/chrome/browser/resources/settings/privacy_page/privacy_page.html -@@ -1104,4 +1104,26 @@ - - - -+ - -diff --git a/chrome/browser/resources/settings/route.ts b/chrome/browser/resources/settings/route.ts ---- a/chrome/browser/resources/settings/route.ts -+++ b/chrome/browser/resources/settings/route.ts -@@ -122,6 +122,7 @@ function addPrivacyChildRoutes(r: Partial) { - r.SITE_SETTINGS.createChild('windowManagement'); - r.SITE_SETTINGS_FILE_SYSTEM_WRITE = r.SITE_SETTINGS.createChild('filesystem'); - r.SITE_SETTINGS_LOCAL_FONTS = r.SITE_SETTINGS.createChild('localFonts'); -+ r.SITE_SETTINGS_AUTOPLAY = r.SITE_SETTINGS.createChild('autoplay'); - } - - /** -diff --git a/chrome/browser/resources/settings/router.ts b/chrome/browser/resources/settings/router.ts ---- a/chrome/browser/resources/settings/router.ts -+++ b/chrome/browser/resources/settings/router.ts -@@ -104,6 +104,7 @@ export interface SettingsRoutes { - SYNC_ADVANCED: Route; - SYSTEM: Route; - TRIGGERED_RESET_DIALOG: Route; -+ SITE_SETTINGS_AUTOPLAY: Route; - } - - /** Class for navigable routes. */ -diff --git a/chrome/browser/resources/settings/site_settings/category_default_setting.ts b/chrome/browser/resources/settings/site_settings/category_default_setting.ts ---- a/chrome/browser/resources/settings/site_settings/category_default_setting.ts -+++ b/chrome/browser/resources/settings/site_settings/category_default_setting.ts -@@ -195,6 +195,7 @@ export class CategoryDefaultSettingElement extends - case ContentSettingsTypes.PROTOCOL_HANDLERS: - case ContentSettingsTypes.SENSORS: - case ContentSettingsTypes.SOUND: -+ case ContentSettingsTypes.AUTOPLAY: - // "Allowed" vs "Blocked". - this.browserProxy.setDefaultValueForContentType( - this.category, -diff --git a/chrome/browser/resources/settings/site_settings/constants.ts b/chrome/browser/resources/settings/site_settings/constants.ts ---- a/chrome/browser/resources/settings/site_settings/constants.ts -+++ b/chrome/browser/resources/settings/site_settings/constants.ts -@@ -46,6 +46,7 @@ export enum ContentSettingsTypes { - VR = 'vr', - WINDOW_MANAGEMENT = 'window-placement', - ZOOM_LEVELS = 'zoom-levels', -+ AUTOPLAY = 'autoplay', - - // The following items are not in the C++ kContentSettingsTypeGroupNames, but - // are used everywhere where ContentSettingsTypes is used in JS. -diff --git a/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts b/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts ---- a/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts -+++ b/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts -@@ -139,6 +139,7 @@ export class SettingsCategoryDefaultRadioGroupElement extends - case ContentSettingsTypes.PROTOCOL_HANDLERS: - case ContentSettingsTypes.SENSORS: - case ContentSettingsTypes.SOUND: -+ case ContentSettingsTypes.AUTOPLAY: - // "Allowed" vs "Blocked". - return ContentSetting.ALLOW; - case ContentSettingsTypes.AR: -diff --git a/chrome/browser/resources/settings/site_settings/site_details.html b/chrome/browser/resources/settings/site_settings/site_details.html ---- a/chrome/browser/resources/settings/site_settings/site_details.html -+++ b/chrome/browser/resources/settings/site_settings/site_details.html -@@ -266,4 +266,9 @@ - category="[[contentSettingsTypesEnum_.LOCAL_FONTS]]" - icon="settings:local-fonts" label="$i18n{fonts}"> - -+ -+ - -diff --git a/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts b/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts ---- a/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts -+++ b/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts -@@ -334,6 +334,14 @@ function getCategoryItemMap(): Map { - label: 'siteSettingsZoomLevels', - icon: 'settings:zoom-in', - }, -+ { -+ route: routes.SITE_SETTINGS_AUTOPLAY, -+ id: Id.AUTOPLAY, -+ label: 'siteSettingsAutoplay', -+ icon: 'settings:autoplay', -+ enabledLabel: 'siteSettingsAutoplayAllowed', -+ disabledLabel: 'siteSettingsAutoplayBlocked', -+ }, - ]; - - categoryItemMap = new Map(categoryList.map(item => [item.id, item])); -@@ -427,6 +435,7 @@ export class SettingsSiteSettingsPageElement extends - Id.FEDERATED_IDENTITY_API, - Id.ANTI_ABUSE, - Id.SITE_DATA, -+ Id.AUTOPLAY, - ]), - }; - }, -diff --git a/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts b/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts ---- a/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts -+++ b/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts -@@ -77,6 +77,8 @@ export function getLocalizationStringForContentType( - return 'siteSettingsWindowManagementMidSentence'; - case ContentSettingsTypes.ZOOM_LEVELS: - return 'siteSettingsZoomLevelsMidSentence'; -+ case ContentSettingsTypes.AUTOPLAY: -+ return 'siteSettingsAutoplayMidSentence'; - // The following members do not have a mid-sentence localization. - case ContentSettingsTypes.ANTI_ABUSE: - case ContentSettingsTypes.PDF_DOCUMENTS: -diff --git a/chrome/browser/ui/views/page_info/page_info_view_factory.cc b/chrome/browser/ui/views/page_info/page_info_view_factory.cc ---- a/chrome/browser/ui/views/page_info/page_info_view_factory.cc -+++ b/chrome/browser/ui/views/page_info/page_info_view_factory.cc -@@ -369,6 +369,9 @@ const ui::ImageModel PageInfoViewFactory::GetPermissionIcon( - case ContentSettingsType::IDLE_DETECTION: - icon = &vector_icons::kDevicesIcon; - break; -+ case ContentSettingsType::AUTOPLAY: -+ icon = &vector_icons::kProtectedContentIcon; -+ break; - default: - // All other |ContentSettingsType|s do not have icons on desktop or are - // not shown in the Page Info bubble. -diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc ---- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc -+++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc -@@ -2521,6 +2521,13 @@ void AddSearchEnginesStrings(content::WebUIDataSource* html_source) { - void AddSiteSettingsStrings(content::WebUIDataSource* html_source, - Profile* profile) { - static constexpr webui::LocalizedString kLocalizedStrings[] = { -+ {"siteSettingsAutoplay", IDS_SITE_SETTINGS_AUTOPLAY_TITLE}, -+ {"siteSettingsAutoplayDescription", IDS_SETTINGS_SITE_SETTINGS_AUTOPLAY_DESCRIPTION}, -+ {"siteSettingsAutoplayAllowed", IDS_SETTINGS_SITE_SETTINGS_AUTOPLAY_ALLOWED}, -+ {"siteSettingsAutoplayBlocked", IDS_SETTINGS_SITE_SETTINGS_AUTOPLAY_BLOCKED}, -+ {"siteSettingsAutoplayAllowedExceptions",IDS_SETTINGS_SITE_SETTINGS_AUTOPLAY_ALLOWED_EXCEPTIONS}, -+ {"siteSettingsAutoplayBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_AUTOPLAY_BLOCKED_EXCEPTIONS}, -+ {"siteSettingsAutoplayMidSentence", IDS_AUTOPLAY_PERMISSION_TITLE}, - {"addSite", IDS_SETTINGS_ADD_SITE}, - {"addSiteTitle", IDS_SETTINGS_ADD_SITE_TITLE}, - #if BUILDFLAG(IS_CHROMEOS_ASH) -diff --git a/chrome/browser/ui/webui/settings/site_settings_helper.cc b/chrome/browser/ui/webui/settings/site_settings_helper.cc ---- a/chrome/browser/ui/webui/settings/site_settings_helper.cc -+++ b/chrome/browser/ui/webui/settings/site_settings_helper.cc -@@ -125,6 +125,7 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = { - {ContentSettingsType::PRIVATE_NETWORK_CHOOSER_DATA, - "private-network-devices-data"}, - {ContentSettingsType::ANTI_ABUSE, "anti-abuse"}, -+ {ContentSettingsType::AUTOPLAY, "autoplay"}, - - // Add new content settings here if a corresponding Javascript string - // representation for it is not required, for example if the content setting -@@ -136,7 +137,6 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = { - {ContentSettingsType::APP_BANNER, nullptr}, - {ContentSettingsType::SITE_ENGAGEMENT, nullptr}, - {ContentSettingsType::DURABLE_STORAGE, nullptr}, -- {ContentSettingsType::AUTOPLAY, nullptr}, - {ContentSettingsType::IMPORTANT_SITE_INFO, nullptr}, - {ContentSettingsType::PERMISSION_AUTOBLOCKER_DATA, nullptr}, - {ContentSettingsType::ADS_DATA, nullptr}, -@@ -535,6 +535,8 @@ const std::vector& GetVisiblePermissionCategories() { - base_types->push_back(ContentSettingsType::PRIVATE_NETWORK_GUARD); - } - -+ base_types->push_back(ContentSettingsType::AUTOPLAY); -+ - initialized = true; - } - --- -2.25.1 diff --git a/build/patches/00WIN-ADDTO-Timezone-customization.patch b/build/patches/00WIN-ADDTO-Timezone-customization.patch deleted file mode 100644 index 255771ca..00000000 --- a/build/patches/00WIN-ADDTO-Timezone-customization.patch +++ /dev/null @@ -1,254 +0,0 @@ -From: Your Name -Date: Wed, 12 Oct 2022 16:03:16 +0000 -Subject: WIN ADDTO Timezone customization - ---- - chrome/app/settings_strings.grdp | 19 ++++++++++++++++ - chrome/browser/resources/settings/icons.html | 2 ++ - .../settings/privacy_page/privacy_page.html | 22 +++++++++++++++++++ - chrome/browser/resources/settings/route.ts | 1 + - chrome/browser/resources/settings/router.ts | 1 + - .../site_settings/category_default_setting.ts | 1 + - .../settings/site_settings/constants.ts | 1 + - .../settings_category_default_radio_group.ts | 1 + - .../settings/site_settings/site_details.html | 5 +++++ - .../site_settings_page/site_settings_page.ts | 9 ++++++++ - .../site_settings_page_util.ts | 2 ++ - .../views/page_info/page_info_view_factory.cc | 3 +++ - .../settings_localized_strings_provider.cc | 7 ++++++ - .../ui/webui/settings/site_settings_helper.cc | 1 + - .../core/browser/content_settings_registry.cc | 2 +- - 15 files changed, 76 insertions(+), 1 deletion(-) - -diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp ---- a/chrome/app/settings_strings.grdp -+++ b/chrome/app/settings_strings.grdp -@@ -4377,6 +4377,25 @@ - Not allowed to Javascript JIT - - -+ -+ Timezone override -+ -+ -+ Enable the Timezone override -+ -+ -+ System Timezone -+ -+ -+ Random Timezone -+ -+ -+ System Timezone override -+ -+ -+ Random Timezone override -+ -+ - - - -diff --git a/chrome/browser/resources/settings/icons.html b/chrome/browser/resources/settings/icons.html ---- a/chrome/browser/resources/settings/icons.html -+++ b/chrome/browser/resources/settings/icons.html -@@ -195,6 +195,8 @@ NOTE: Chrome OS icons go in ./chromeos/os_icons.html. - - - -+ -+ - - - -diff --git a/chrome/browser/resources/settings/privacy_page/privacy_page.html b/chrome/browser/resources/settings/privacy_page/privacy_page.html ---- a/chrome/browser/resources/settings/privacy_page/privacy_page.html -+++ b/chrome/browser/resources/settings/privacy_page/privacy_page.html -@@ -1148,4 +1148,26 @@ - - - -+ - -diff --git a/chrome/browser/resources/settings/route.ts b/chrome/browser/resources/settings/route.ts ---- a/chrome/browser/resources/settings/route.ts -+++ b/chrome/browser/resources/settings/route.ts -@@ -124,6 +124,7 @@ function addPrivacyChildRoutes(r: Partial) { - r.SITE_SETTINGS_LOCAL_FONTS = r.SITE_SETTINGS.createChild('localFonts'); - r.SITE_SETTINGS_AUTOPLAY = r.SITE_SETTINGS.createChild('autoplay'); - r.SITE_SETTINGS_JAVASCRIPT_JIT = r.SITE_SETTINGS.createChild('javascript-jit'); -+ r.SITE_SETTINGS_TIMEZONE_OVERRIDE = r.SITE_SETTINGS.createChild('timezone-override'); - } - - /** -diff --git a/chrome/browser/resources/settings/router.ts b/chrome/browser/resources/settings/router.ts ---- a/chrome/browser/resources/settings/router.ts -+++ b/chrome/browser/resources/settings/router.ts -@@ -106,6 +106,7 @@ export interface SettingsRoutes { - TRIGGERED_RESET_DIALOG: Route; - SITE_SETTINGS_AUTOPLAY: Route; - SITE_SETTINGS_JAVASCRIPT_JIT: Route; -+ SITE_SETTINGS_TIMEZONE_OVERRIDE: Route; - } - - /** Class for navigable routes. */ -diff --git a/chrome/browser/resources/settings/site_settings/category_default_setting.ts b/chrome/browser/resources/settings/site_settings/category_default_setting.ts ---- a/chrome/browser/resources/settings/site_settings/category_default_setting.ts -+++ b/chrome/browser/resources/settings/site_settings/category_default_setting.ts -@@ -197,6 +197,7 @@ export class CategoryDefaultSettingElement extends - case ContentSettingsTypes.SOUND: - case ContentSettingsTypes.AUTOPLAY: - case ContentSettingsTypes.JAVASCRIPT_JIT: -+ case ContentSettingsTypes.TIMEZONE_OVERRIDE: - // "Allowed" vs "Blocked". - this.browserProxy.setDefaultValueForContentType( - this.category, -diff --git a/chrome/browser/resources/settings/site_settings/constants.ts b/chrome/browser/resources/settings/site_settings/constants.ts ---- a/chrome/browser/resources/settings/site_settings/constants.ts -+++ b/chrome/browser/resources/settings/site_settings/constants.ts -@@ -48,6 +48,7 @@ export enum ContentSettingsTypes { - ZOOM_LEVELS = 'zoom-levels', - AUTOPLAY = 'autoplay', - JAVASCRIPT_JIT = 'javascript-jit', -+ TIMEZONE_OVERRIDE = 'timezone-override', - - // The following items are not in the C++ kContentSettingsTypeGroupNames, but - // are used everywhere where ContentSettingsTypes is used in JS. -diff --git a/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts b/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts ---- a/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts -+++ b/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts -@@ -141,6 +141,7 @@ export class SettingsCategoryDefaultRadioGroupElement extends - case ContentSettingsTypes.SOUND: - case ContentSettingsTypes.AUTOPLAY: - case ContentSettingsTypes.JAVASCRIPT_JIT: -+ case ContentSettingsTypes.TIMEZONE_OVERRIDE: - // "Allowed" vs "Blocked". - return ContentSetting.ALLOW; - case ContentSettingsTypes.AR: -diff --git a/chrome/browser/resources/settings/site_settings/site_details.html b/chrome/browser/resources/settings/site_settings/site_details.html ---- a/chrome/browser/resources/settings/site_settings/site_details.html -+++ b/chrome/browser/resources/settings/site_settings/site_details.html -@@ -276,4 +276,9 @@ - icon="settings:javascript-jit" - label="$i18n{siteSettingsJavascriptJIT}"> - -+ -+ - -diff --git a/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts b/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts ---- a/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts -+++ b/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts -@@ -350,6 +350,14 @@ function getCategoryItemMap(): Map { - enabledLabel: 'siteSettingsJavascriptJITAllowed', - disabledLabel: 'siteSettingsJavascriptJITBlocked', - }, -+ { -+ route: routes.SITE_SETTINGS_TIMEZONE_OVERRIDE, -+ id: Id.TIMEZONE_OVERRIDE, -+ label: 'siteSettingsTimezoneOverride', -+ icon: 'settings:timezone-override', -+ enabledLabel: 'siteSettingsTimezoneOverrideAllowed', -+ disabledLabel: 'siteSettingsTimezoneOverrideBlocked', -+ }, - ]; - - categoryItemMap = new Map(categoryList.map(item => [item.id, item])); -@@ -445,6 +453,7 @@ export class SettingsSiteSettingsPageElement extends - Id.SITE_DATA, - Id.AUTOPLAY, - Id.JAVASCRIPT_JIT, -+ Id.TIMEZONE_OVERRIDE, - ]), - }; - }, -diff --git a/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts b/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts ---- a/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts -+++ b/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts -@@ -81,6 +81,8 @@ export function getLocalizationStringForContentType( - return 'siteSettingsAutoplayMidSentence'; - case ContentSettingsTypes.JAVASCRIPT_JIT: - return 'siteSettingsJavascriptJITMidSentence'; -+ case ContentSettingsTypes.TIMEZONE_OVERRIDE: -+ return 'siteSettingsTimezoneOverrideMidSentence'; - // The following members do not have a mid-sentence localization. - case ContentSettingsTypes.ANTI_ABUSE: - case ContentSettingsTypes.PDF_DOCUMENTS: -diff --git a/chrome/browser/ui/views/page_info/page_info_view_factory.cc b/chrome/browser/ui/views/page_info/page_info_view_factory.cc ---- a/chrome/browser/ui/views/page_info/page_info_view_factory.cc -+++ b/chrome/browser/ui/views/page_info/page_info_view_factory.cc -@@ -375,6 +375,9 @@ const ui::ImageModel PageInfoViewFactory::GetPermissionIcon( - case ContentSettingsType::JAVASCRIPT_JIT: - icon = &vector_icons::kCodeIcon; - break; -+ case ContentSettingsType::TIMEZONE_OVERRIDE: -+ icon = &vector_icons::kAccountCircleIcon; -+ break; - default: - // All other |ContentSettingsType|s do not have icons on desktop or are - // not shown in the Page Info bubble. -diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc ---- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc -+++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc -@@ -2535,6 +2535,13 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, - {"siteSettingsJavascriptJITAllowedExceptions",IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_JIT_ALLOWED_EXCEPTIONS}, - {"siteSettingsJavascriptJITBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_JIT_BLOCKED_EXCEPTIONS}, - {"siteSettingsJavascriptJITMidSentence", IDS_SITE_SETTINGS_TYPE_JAVASCRIPT_JIT}, -+ {"siteSettingsTimezoneOverride", IDS_SITE_SETTINGS_TIMEZONE_OVERRIDE_TITLE}, -+ {"siteSettingsTimezoneOverrideDescription", IDS_SETTINGS_SITE_SETTINGS_TIMEZONE_OVERRIDE_DESCRIPTION}, -+ {"siteSettingsTimezoneOverrideAllowed", IDS_SETTINGS_SITE_SETTINGS_TIMEZONE_OVERRIDE_ALLOWED}, -+ {"siteSettingsTimezoneOverrideBlocked", IDS_SETTINGS_SITE_SETTINGS_TIMEZONE_OVERRIDE_BLOCKED}, -+ {"siteSettingsTimezoneOverrideAllowedExceptions",IDS_SETTINGS_SITE_SETTINGS_TIMEZONE_OVERRIDE_ALLOWED_EXCEPTIONS}, -+ {"siteSettingsTimezoneOverrideBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_TIMEZONE_OVERRIDE_BLOCKED_EXCEPTIONS}, -+ {"siteSettingsTimezoneOverrideMidSentence", IDS_SITE_SETTINGS_TIMEZONE_OVERRIDE_TITLE}, - {"addSite", IDS_SETTINGS_ADD_SITE}, - {"addSiteTitle", IDS_SETTINGS_ADD_SITE_TITLE}, - #if BUILDFLAG(IS_CHROMEOS_ASH) -diff --git a/chrome/browser/ui/webui/settings/site_settings_helper.cc b/chrome/browser/ui/webui/settings/site_settings_helper.cc ---- a/chrome/browser/ui/webui/settings/site_settings_helper.cc -+++ b/chrome/browser/ui/webui/settings/site_settings_helper.cc -@@ -127,6 +127,7 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = { - {ContentSettingsType::ANTI_ABUSE, "anti-abuse"}, - {ContentSettingsType::AUTOPLAY, "autoplay"}, - {ContentSettingsType::JAVASCRIPT_JIT, "javascript-jit"}, -+ {ContentSettingsType::TIMEZONE_OVERRIDE, "timezone-override"}, - - // Add new content settings here if a corresponding Javascript string - // representation for it is not required, for example if the content setting -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 -@@ -577,7 +577,7 @@ void ContentSettingsRegistry::Init() { - CONTENT_SETTING_ASK, // custom timezone, default UTC - CONTENT_SETTING_BLOCK}, // random - WebsiteSettingsInfo::TOP_ORIGIN_ONLY_SCOPE, -- WebsiteSettingsRegistry::PLATFORM_ANDROID, -+ WebsiteSettingsRegistry::ALL_PLATFORMS, - ContentSettingsInfo::INHERIT_IN_INCOGNITO, - ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS, - /*show_into_info_page*/ false, --- -2.25.1 diff --git a/build/patches/00bromite-build-utils.patch b/build/patches/00bromite-build-utils.patch index dffe6826..3111800d 100644 --- a/build/patches/00bromite-build-utils.patch +++ b/build/patches/00bromite-build-utils.patch @@ -5,15 +5,16 @@ Subject: bromite build utils --- build/android/gyp/java_cpp_enum.py | 36 ++++++-- build/android/gyp/util/build_utils.py | 25 +++++- - build/bromite/bromite_utils.gni | 68 +++++++++++++++ + build/bromite/bromite_utils.gni | 69 ++++++++++++++ build/bromite/gyp/cpp_bromite_include.py | 35 ++++++++ build/bromite/gyp/cpp_bromite_include.pydeps | 9 ++ - build/bromite/gyp/java_bromite_impl.py | 92 ++++++++++++++++++++ + build/bromite/gyp/java_bromite_impl.py | 94 ++++++++++++++++++++ build/bromite/gyp/java_bromite_impl.pydeps | 9 ++ build/config/BUILDCONFIG.gn | 1 + build/config/android/rules.gni | 4 + tools/grit/grit/grd_reader.py | 27 ++++-- - 10 files changed, 294 insertions(+), 12 deletions(-) + tools/grit/preprocess_if_expr.py | 32 ++++++- + 11 files changed, 328 insertions(+), 13 deletions(-) create mode 100644 build/bromite/bromite_utils.gni create mode 100644 build/bromite/gyp/cpp_bromite_include.py create mode 100644 build/bromite/gyp/cpp_bromite_include.pydeps @@ -153,7 +154,7 @@ diff --git a/build/bromite/bromite_utils.gni b/build/bromite/bromite_utils.gni new file mode 100644 --- /dev/null +++ b/build/bromite/bromite_utils.gni -@@ -0,0 +1,68 @@ +@@ -0,0 +1,69 @@ +import("//build/config/python.gni") + +# generates the file specified in ouput_file containing @@ -179,10 +180,11 @@ new file mode 100644 + forward_variables_from(invoker, + TESTONLY_AND_VISIBILITY + [ + "deps", ++ "inputs", + ]) + script = "//build/bromite/gyp/cpp_bromite_include.py" + -+ _rebased_directories = rebase_path(invoker.directories, root_build_dir) ++ _rebased_directories = rebase_path(invoker.inputs, root_build_dir) + _output = "$target_gen_dir/" + invoker.output_file + _output_rebased = rebase_path(_output) + @@ -210,7 +212,7 @@ new file mode 100644 + + _srcjar_path = "${target_gen_dir}/${target_name}.srcjar" + _rebased_srcjar_path = rebase_path(_srcjar_path, root_build_dir) -+ _rebased_directories = rebase_path(invoker.directories, root_build_dir) ++ _rebased_directories = rebase_path(invoker.inputs, root_build_dir) + _rebased_template = rebase_path(invoker.template, root_build_dir) + + args = [ @@ -249,7 +251,7 @@ new file mode 100644 + directory = os.path.dirname(include_file) + files = [] + for root, dirs, directory_files in os.walk(directory): -+ for directory_file in directory_files: ++ for directory_file in sorted(directory_files): + files.append(os.path.join(directory, directory_file)) + + files = [f for f in files if f.endswith('.inc')] @@ -280,7 +282,7 @@ diff --git a/build/bromite/gyp/java_bromite_impl.py b/build/bromite/gyp/java_bro new file mode 100644 --- /dev/null +++ b/build/bromite/gyp/java_bromite_impl.py -@@ -0,0 +1,92 @@ +@@ -0,0 +1,94 @@ +#!/usr/bin/env python3 + +import argparse @@ -336,8 +338,10 @@ new file mode 100644 + strings = [] + + for directory in source_paths: -+ for root, dirs, directory_files in os.walk(directory): -+ for directory_file in directory_files: ++ if not directory.endswith('include_all_directory.java'): ++ raise Exception("input path not ends with 'include_all_directory.java'") ++ for root, dirs, directory_files in os.walk(os.path.dirname(directory)): ++ for directory_file in sorted(directory_files): + strings.append(directory_file) + + strings = [f.replace('.java', '') for f in strings @@ -449,5 +453,61 @@ diff --git a/tools/grit/grit/grd_reader.py b/tools/grit/grit/grd_reader.py if self.debug: print("End parsing of element %s" % name) +diff --git a/tools/grit/preprocess_if_expr.py b/tools/grit/preprocess_if_expr.py +--- a/tools/grit/preprocess_if_expr.py ++++ b/tools/grit/preprocess_if_expr.py +@@ -8,6 +8,7 @@ import io + import json + import os + import sys ++import re + + # For Node, EvaluateExpression + import grit.node.base +@@ -71,6 +72,35 @@ def ExtensionForComments(input_file): + extension = '.html' + return extension + ++def _extract_template_from_dir(html_file): ++ template = '' ++ directory = os.path.dirname(html_file) ++ for root, dirs, directory_files in os.walk(directory): ++ for directory_file in directory_files: ++ if directory_file.endswith(".html"): ++ template += _extract_template(os.path.join(directory, directory_file)) ++ ++ return template ++ ++def _extract_template(html_file): ++ include_re = re.compile(r'^\s*') ++ with io.open(html_file, encoding='utf-8', mode='r') as f: ++ lines = f.readlines() ++ ++ template_lines = [] ++ for line in lines: ++ include_line = include_re.match(line) ++ if include_line: ++ include_file = include_line.groups()[0] ++ file_to_include = os.path.join(os.path.dirname(html_file), include_file) ++ if file_to_include.endswith("placeholder.txt"): ++ line = _extract_template_from_dir(file_to_include) ++ else: ++ line = _extract_template(file_to_include) ++ template_lines.append(line) ++ ++ template = ''.join(template_lines) ++ return template + + def main(argv): + parser = argparse.ArgumentParser() +@@ -95,7 +125,7 @@ def main(argv): + in_path = os.path.join(in_folder, input_file) + content = "" + with open(in_path, encoding='utf-8') as f: +- content = f.read() ++ content = _extract_template(in_path) + + removal_comments_extension = None # None means no removal comments + if args.enable_removal_comments: -- 2.25.1 diff --git a/build/patches/Add-webGL-site-setting.patch b/build/patches/Add-webGL-site-setting.patch index ee09d561..ef72ab78 100644 --- a/build/patches/Add-webGL-site-setting.patch +++ b/build/patches/Add-webGL-site-setting.patch @@ -9,17 +9,17 @@ Requires patch: Content-settings-infrastructure.patch Original License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html --- - .../impl/BromiteWebGLContentSetting.java | 87 +++++++++++++++++++ - .../bromite_content_settings/webgl.grdp | 18 ++++ - .../bromite_content_settings/webgl.inc | 13 +++ + .../impl/BromiteWebGLContentSetting.java | 92 +++++++++++++++++++ + .../bromite_content_settings/webgl.grdp | 27 ++++++ + .../bromite_content_settings/webgl.inc | 23 +++++ .../common/bromite_content_settings/WEBGL.inc | 1 + .../execution_context/execution_context.cc | 7 ++ .../execution_context/execution_context.h | 2 + .../webgl/webgl_rendering_context_base.cc | 32 +++---- .../webgl/webgl_rendering_context_base.h | 2 + - 8 files changed, 143 insertions(+), 19 deletions(-) + 8 files changed, 167 insertions(+), 19 deletions(-) create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteWebGLContentSetting.java - create mode 100644 components/browser_ui/strings/android/bromite_content_settings/webgl.grdp + create mode 100644 components/browser_ui/strings/bromite_content_settings/webgl.grdp create mode 100644 components/content_settings/core/browser/bromite_content_settings/webgl.inc create mode 100644 components/content_settings/core/common/bromite_content_settings/WEBGL.inc @@ -27,7 +27,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/impl/BromiteWebGLContentSetting.java -@@ -0,0 +1,87 @@ +@@ -0,0 +1,92 @@ +/* + This file is part of Bromite. + @@ -96,6 +96,11 @@ new file mode 100644 + } + + @Override ++ public int getCategoryDescription() { ++ return R.string.settings_site_settings_webgl_description; ++ } ++ ++ @Override + public boolean requiresTriStateContentSetting() { + return false; + } @@ -115,34 +120,43 @@ new file mode 100644 + return value != ContentSettingValues.BLOCK; + } +} -diff --git a/components/browser_ui/strings/android/bromite_content_settings/webgl.grdp b/components/browser_ui/strings/android/bromite_content_settings/webgl.grdp +diff --git a/components/browser_ui/strings/bromite_content_settings/webgl.grdp b/components/browser_ui/strings/bromite_content_settings/webgl.grdp new file mode 100644 --- /dev/null -+++ b/components/browser_ui/strings/android/bromite_content_settings/webgl.grdp -@@ -0,0 +1,18 @@ ++++ b/components/browser_ui/strings/bromite_content_settings/webgl.grdp +@@ -0,0 +1,27 @@ + + -+ ++ + Webgl + -+ ++ ++ Enable Webgl, a JavaScript API for rendering high-performance interactive 3D and 2D graphics ++ ++ + webgl + -+ ++ + Webgl + -+ ++ + Enabled + -+ ++ + Disabled + ++ ++ Allowed to use webgl ++ ++ ++ Not allowed to use webgl ++ + diff --git a/components/content_settings/core/browser/bromite_content_settings/webgl.inc b/components/content_settings/core/browser/bromite_content_settings/webgl.inc new file mode 100644 --- /dev/null +++ b/components/content_settings/core/browser/bromite_content_settings/webgl.inc -@@ -0,0 +1,13 @@ +@@ -0,0 +1,23 @@ + Register(ContentSettingsType::WEBGL, "webgl", CONTENT_SETTING_BLOCK, + WebsiteSettingsInfo::SYNCABLE, + /*allowlisted_schemes=*/{}, @@ -151,11 +165,21 @@ new file mode 100644 + WebsiteSettingsInfo::TOP_ORIGIN_ONLY_SCOPE, + WebsiteSettingsRegistry::ALL_PLATFORMS, + ContentSettingsInfo::INHERIT_IN_INCOGNITO, -+ ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS, -+ /*show_into_info_page*/ true, -+ /*is_renderer_content_setting*/ true, -+ /*permission_type_ui*/ IDS_SITE_SETTINGS_TYPE_WEBGL, -+ /*permission_type_ui_mid_sentence*/ IDS_SITE_SETTINGS_TYPE_WEBGL_MID_SENTENCE); ++ ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); ++ ++ content_settings::WebsiteSettingsRegistry::GetInstance() ++ ->GetMutable(ContentSettingsType::WEBGL) ++ ->set_show_into_info_page() ++ .set_desktop_ui() ++ .set_is_renderer_content_setting() ++ .set_title_ui(IDS_SITE_SETTINGS_TYPE_WEBGL) ++ .set_description_ui(IDS_SETTINGS_SITE_SETTINGS_WEBGL_DESCRIPTION) ++ .set_allowed_ui(IDS_WEBSITE_SETTINGS_CATEGORY_WEBGL_ENABLED) ++ .set_blocked_ui(IDS_WEBSITE_SETTINGS_CATEGORY_WEBGL_DISABLED) ++ .set_allowed_exceptions_ui(IDS_SETTINGS_SITE_SETTINGS_WEBGL_ALLOWED_EXCEPTIONS) ++ .set_blocked_exceptions_ui(IDS_SETTINGS_SITE_SETTINGS_WEBGL_BLOCKED_EXCEPTIONS) ++ .set_mid_sentence_ui(IDS_SITE_SETTINGS_TYPE_WEBGL); ++ diff --git a/components/content_settings/core/common/bromite_content_settings/WEBGL.inc b/components/content_settings/core/common/bromite_content_settings/WEBGL.inc new file mode 100644 --- /dev/null diff --git a/build/patches/Add-webRTC-site-settings.patch b/build/patches/Add-webRTC-site-settings.patch index 94d95b69..70a0edcd 100644 --- a/build/patches/Add-webRTC-site-settings.patch +++ b/build/patches/Add-webRTC-site-settings.patch @@ -7,16 +7,16 @@ Requires patch: Content-settings-infrastructure.patch Original License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html --- - .../impl/BromiteWebRTCContentSetting.java | 88 +++++++++++++++++++ - .../bromite_content_settings/webrtc.grdp | 18 ++++ - .../bromite_content_settings/webrtc.inc | 13 +++ + .../impl/BromiteWebRTCContentSetting.java | 93 +++++++++++++++++++ + .../bromite_content_settings/webrtc.grdp | 27 ++++++ + .../bromite_content_settings/webrtc.inc | 23 +++++ .../bromite_content_settings/WEBRTC.inc | 1 + .../peer_connection_dependency_factory.cc | 6 ++ - .../peerconnection/rtc_rtp_receiver.cc | 10 +++ - .../modules/peerconnection/rtc_rtp_sender.cc | 10 +++ - 7 files changed, 146 insertions(+) + .../peerconnection/rtc_rtp_receiver.cc | 10 ++ + .../modules/peerconnection/rtc_rtp_sender.cc | 10 ++ + 7 files changed, 170 insertions(+) create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteWebRTCContentSetting.java - create mode 100644 components/browser_ui/strings/android/bromite_content_settings/webrtc.grdp + create mode 100644 components/browser_ui/strings/bromite_content_settings/webrtc.grdp create mode 100644 components/content_settings/core/browser/bromite_content_settings/webrtc.inc create mode 100644 components/content_settings/core/common/bromite_content_settings/WEBRTC.inc @@ -24,7 +24,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/impl/BromiteWebRTCContentSetting.java -@@ -0,0 +1,88 @@ +@@ -0,0 +1,93 @@ +/* + This file is part of Bromite. + @@ -94,6 +94,11 @@ new file mode 100644 + } + + @Override ++ public int getCategoryDescription() { ++ return R.string.settings_site_settings_webrtc_description; ++ } ++ ++ @Override + public boolean requiresTriStateContentSetting() { + return false; + } @@ -113,34 +118,43 @@ new file mode 100644 + return value != ContentSettingValues.BLOCK; + } +} -diff --git a/components/browser_ui/strings/android/bromite_content_settings/webrtc.grdp b/components/browser_ui/strings/android/bromite_content_settings/webrtc.grdp +diff --git a/components/browser_ui/strings/bromite_content_settings/webrtc.grdp b/components/browser_ui/strings/bromite_content_settings/webrtc.grdp new file mode 100644 --- /dev/null -+++ b/components/browser_ui/strings/android/bromite_content_settings/webrtc.grdp -@@ -0,0 +1,18 @@ ++++ b/components/browser_ui/strings/bromite_content_settings/webrtc.grdp +@@ -0,0 +1,27 @@ + + -+ ++ + WebRTC + -+ ++ + webRTC + -+ ++ ++ Enable WebRTC, a JavaScript API for real-time communication and direct peer-to-peer communication ++ ++ + WebRTC + -+ ++ + Enabled + -+ ++ + Disabled + ++ ++ Allowed to use WebRTC ++ ++ ++ Not allowed to use WebRTC ++ + diff --git a/components/content_settings/core/browser/bromite_content_settings/webrtc.inc b/components/content_settings/core/browser/bromite_content_settings/webrtc.inc new file mode 100644 --- /dev/null +++ b/components/content_settings/core/browser/bromite_content_settings/webrtc.inc -@@ -0,0 +1,13 @@ +@@ -0,0 +1,23 @@ + Register(ContentSettingsType::WEBRTC, "webrtc", CONTENT_SETTING_BLOCK, + WebsiteSettingsInfo::SYNCABLE, + /*allowlisted_schemes=*/{}, @@ -149,11 +163,21 @@ new file mode 100644 + WebsiteSettingsInfo::TOP_ORIGIN_ONLY_SCOPE, + WebsiteSettingsRegistry::ALL_PLATFORMS, + ContentSettingsInfo::INHERIT_IN_INCOGNITO, -+ ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS, -+ /*show_into_info_page*/ true, -+ /*is_renderer_content_setting*/ true, -+ /*permission_type_ui*/ IDS_SITE_SETTINGS_TYPE_WEBRTC, -+ /*permission_type_ui_mid_sentence*/ IDS_SITE_SETTINGS_TYPE_WEBRTC_MID_SENTENCE); ++ ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); ++ ++ content_settings::WebsiteSettingsRegistry::GetInstance() ++ ->GetMutable(ContentSettingsType::WEBRTC) ++ ->set_show_into_info_page() ++ .set_desktop_ui() ++ .set_is_renderer_content_setting() ++ .set_title_ui(IDS_SITE_SETTINGS_TYPE_WEBRTC) ++ .set_description_ui(IDS_SETTINGS_SITE_SETTINGS_WEBRTC_DESCRIPTION) ++ .set_allowed_ui(IDS_WEBSITE_SETTINGS_CATEGORY_WEBRTC_ENABLED) ++ .set_blocked_ui(IDS_WEBSITE_SETTINGS_CATEGORY_WEBRTC_DISABLED) ++ .set_allowed_exceptions_ui(IDS_SETTINGS_SITE_SETTINGS_WEBRTC_ALLOWED_EXCEPTIONS) ++ .set_blocked_exceptions_ui(IDS_SETTINGS_SITE_SETTINGS_WEBRTC_BLOCKED_EXCEPTIONS) ++ .set_mid_sentence_ui(IDS_SITE_SETTINGS_TYPE_WEBRTC_MID_SENTENCE); ++ diff --git a/components/content_settings/core/common/bromite_content_settings/WEBRTC.inc b/components/content_settings/core/common/bromite_content_settings/WEBRTC.inc new file mode 100644 --- /dev/null diff --git a/build/patches/Content-settings-infrastructure.patch b/build/patches/Content-settings-infrastructure.patch index 81b7e100..1d6341e5 100644 --- a/build/patches/Content-settings-infrastructure.patch +++ b/build/patches/Content-settings-infrastructure.patch @@ -10,64 +10,555 @@ See BromiteCustomContentSetting_README.md for more information. Original License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html --- - .../browser_ui/site_settings/android/BUILD.gn | 15 + - .../BromiteCustomContentSetting.java | 127 ++++++++ - .../BromiteCustomContentSettingImpl.java | 275 ++++++++++++++++++ + .../installable/installed_webapp_bridge.cc | 2 +- + .../settings/privacy_page/privacy_page.html | 1 + + .../settings/privacy_page/privacy_page.ts | 44 ++- + chrome/browser/resources/settings/route.ts | 3 + + .../site_settings/category_default_setting.ts | 11 + + .../settings_category_default_radio_group.ts | 7 + + .../settings/site_settings/site_details.html | 1 + + .../settings/site_settings/site_details.ts | 16 +- + .../site_settings_page/site_settings_page.ts | 28 +- + .../site_settings_page_util.ts | 55 ++++ + chrome/browser/ui/BUILD.gn | 1 + + .../views/page_info/page_info_view_factory.cc | 13 + + .../settings_localized_strings_provider.cc | 39 +++ + .../ui/webui/settings/site_settings_helper.cc | 33 +- + .../browser_ui/site_settings/android/BUILD.gn | 14 + + .../BromiteCustomContentSetting.java | 128 ++++++++ + .../BromiteCustomContentSettingImpl.java | 284 ++++++++++++++++++ .../BromiteCustomContentSetting_README.md | 151 ++++++++++ .../ContentSettingsResources.java | 14 +- - .../site_settings/SingleCategorySettings.java | 27 +- - .../site_settings/SingleWebsiteSettings.java | 22 +- + .../site_settings/SingleCategorySettings.java | 33 +- + .../site_settings/SingleWebsiteSettings.java | 26 +- .../site_settings/SiteSettings.java | 7 +- .../site_settings/SiteSettingsCategory.java | 18 +- .../TriStateSiteSettingsPreference.java | 13 +- .../browser_ui/site_settings/Website.java | 6 + - .../WebsitePermissionsFetcher.java | 2 +- + .../WebsitePermissionsFetcher.java | 4 +- .../WebsitePreferenceBridge.java | 3 +- .../impl/include_all_directory.java | 1 + ...miteCustomContentSettingImplBase.java.tmpl | 48 +++ - .../bromite_content_settings/placeholder.txt | 1 + - .../strings/android/browser_ui_strings.grd | 1 + - components/components_strings.grd | 1 + + .../bromite_content_settings/placeholder.txt | 2 + .../content_settings/core/browser/BUILD.gn | 7 + .../bromite_content_settings/placeholder.txt | 1 + - .../core/browser/content_settings_registry.cc | 15 +- - .../core/browser/content_settings_registry.h | 6 +- + .../core/browser/content_settings_registry.cc | 3 + .../core/browser/content_settings_utils.cc | 12 + - .../core/browser/website_settings_info.cc | 12 +- - .../core/browser/website_settings_info.h | 15 +- - .../core/browser/website_settings_registry.cc | 10 +- - .../core/browser/website_settings_registry.h | 6 +- + .../core/browser/website_settings_info.h | 35 +++ + .../core/browser/website_settings_registry.cc | 6 + + .../core/browser/website_settings_registry.h | 1 + .../content_settings/core/common/BUILD.gn | 6 + .../bromite_content_settings/placeholder.txt | 1 + - .../core/common/content_settings.cc | 19 ++ + .../core/common/content_settings.cc | 21 +- .../core/common/content_settings.h | 10 + .../core/common/content_settings.mojom | 6 + .../common/content_settings_mojom_traits.cc | 12 +- .../common/content_settings_mojom_traits.h | 24 ++ - .../core/common/content_settings_types.h | 2 + - .../renderer/content_settings_agent_impl.cc | 33 +++ + .../common/content_settings_param_traits.h | 2 +- + .../core/common/content_settings_types.h | 4 +- + .../renderer/content_settings_agent_impl.cc | 33 ++ .../renderer/content_settings_agent_impl.h | 5 + + .../PageInfoPermissionsController.java | 9 + .../PermissionParamsListBuilder.java | 1 + .../android/page_info_controller_android.cc | 18 ++ components/page_info/page_info.cc | 22 +- components/page_info/page_info_ui.cc | 18 ++ + components/site_settings_strings.grdp | 1 + .../platform/web_content_settings_client.h | 5 + .../execution_context/execution_context.cc | 16 + .../execution_context/execution_context.h | 5 + - 44 files changed, 986 insertions(+), 33 deletions(-) + 57 files changed, 1252 insertions(+), 38 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 create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/include_all_directory.java create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/java_template/BromiteCustomContentSettingImplBase.java.tmpl - create mode 100644 components/browser_ui/strings/android/bromite_content_settings/placeholder.txt + create mode 100644 components/browser_ui/strings/bromite_content_settings/placeholder.txt create mode 100644 components/content_settings/core/browser/bromite_content_settings/placeholder.txt create mode 100644 components/content_settings/core/common/bromite_content_settings/placeholder.txt +diff --git a/chrome/browser/installable/installed_webapp_bridge.cc b/chrome/browser/installable/installed_webapp_bridge.cc +--- a/chrome/browser/installable/installed_webapp_bridge.cc ++++ b/chrome/browser/installable/installed_webapp_bridge.cc +@@ -18,7 +18,7 @@ using base::android::ScopedJavaLocalRef; + static void JNI_InstalledWebappBridge_NotifyPermissionsChange(JNIEnv* env, + jlong j_provider, + int type) { +- DCHECK_LT(type, static_cast(ContentSettingsType::NUM_TYPES)); ++ DCHECK_LT(type, static_cast(ContentSettingsType::NUM_TYPES_BROMITE)); + InstalledWebappProvider* provider = + reinterpret_cast(j_provider); + provider->Notify(static_cast(type)); +diff --git a/chrome/browser/resources/settings/privacy_page/privacy_page.html b/chrome/browser/resources/settings/privacy_page/privacy_page.html +--- a/chrome/browser/resources/settings/privacy_page/privacy_page.html ++++ b/chrome/browser/resources/settings/privacy_page/privacy_page.html +@@ -1104,4 +1104,5 @@ + + + ++
+ +diff --git a/chrome/browser/resources/settings/privacy_page/privacy_page.ts b/chrome/browser/resources/settings/privacy_page/privacy_page.ts +--- a/chrome/browser/resources/settings/privacy_page/privacy_page.ts ++++ b/chrome/browser/resources/settings/privacy_page/privacy_page.ts +@@ -67,7 +67,49 @@ export class SettingsPrivacyPageElement extends SettingsPrivacyPageElementBase { + } + + static get template() { +- return getTemplate(); ++ let template = getTemplate(); ++ let content = template.content.getElementById("bromite-placeholder")!; ++ ++ for (let index=0; index < loadTimeData.getInteger("br_cs_count"); index++) { ++ let obj = JSON.parse(loadTimeData.getString("br_cs_" + index)); ++ let name = obj["name"]; ++ let tag_name = obj["tag_ui"]; if (!tag_name) tag_name = obj["name"]; ++ ++ let template = document.createElement("settings-subpage"); ++ template.setAttribute("page-title", loadTimeData.getString(`brSiteSettings${name}`)); ++ template.setAttribute("search-title", loadTimeData.getString("siteSettingsAllSitesSearch")); ++ template.setAttribute("search-term", "{{searchFilter_}}"); ++ ++ let divElement = document.createElement("div"); ++ divElement.setAttribute("class", "content-settings-header secondary"); ++ divElement.innerText = loadTimeData.getString(`brSiteSettings${name}Description`); ++ template.appendChild(divElement); ++ ++ let radioGroup = document.createElement("settings-category-default-radio-group"); ++ radioGroup.setAttribute("category", name); ++ radioGroup.setAttribute("allow-option-label", loadTimeData.getString(`brSiteSettings${name}Allowed`)); ++ radioGroup.setAttribute("allow-option-icon", `br-settings:${name}`); ++ radioGroup.setAttribute("block-option-label", loadTimeData.getString(`brSiteSettings${name}Blocked`)); ++ radioGroup.setAttribute("block-option-icon", `br-settings:${name}-off`); ++ template.appendChild(radioGroup); ++ ++ let exceptions = document.createElement("category-setting-exceptions"); ++ exceptions.setAttribute("category", name); ++ exceptions.setAttribute("allow-header", loadTimeData.getString(`brSiteSettings${name}AllowedExceptions`)); ++ exceptions.setAttribute("block-header", loadTimeData.getString(`brSiteSettings${name}BlockedExceptions`)); ++ exceptions.setAttribute("search-filter", "[[searchFilter_]]"); ++ template.appendChild(exceptions); ++ ++ let tag = document.createElement("template"); ++ tag.setAttribute("is", "dom-if"); ++ tag.setAttribute("route-path", `/content/${tag_name}`); ++ tag.setAttribute("no-search", ""); ++ tag.content.appendChild(template); ++ ++ content.parentElement!.insertBefore(tag, content); ++ } ++ content.parentElement!.removeChild(content); ++ return template; + } + + static get properties() { +diff --git a/chrome/browser/resources/settings/route.ts b/chrome/browser/resources/settings/route.ts +--- a/chrome/browser/resources/settings/route.ts ++++ b/chrome/browser/resources/settings/route.ts +@@ -7,6 +7,7 @@ import {loadTimeData} from 'chrome://resources/js/load_time_data.js'; + + import {pageVisibility} from './page_visibility.js'; + import {Route, Router, SettingsRoutes} from './router.js'; ++import {setupContentSettingsRoutes} from './site_settings_page/site_settings_page_util.js' + + /** + * Add all of the child routes that originate from the privacy route, +@@ -122,6 +123,8 @@ function addPrivacyChildRoutes(r: Partial) { + r.SITE_SETTINGS.createChild('windowManagement'); + r.SITE_SETTINGS_FILE_SYSTEM_WRITE = r.SITE_SETTINGS.createChild('filesystem'); + r.SITE_SETTINGS_LOCAL_FONTS = r.SITE_SETTINGS.createChild('localFonts'); ++ ++ setupContentSettingsRoutes(r); + } + + /** +diff --git a/chrome/browser/resources/settings/site_settings/category_default_setting.ts b/chrome/browser/resources/settings/site_settings/category_default_setting.ts +--- a/chrome/browser/resources/settings/site_settings/category_default_setting.ts ++++ b/chrome/browser/resources/settings/site_settings/category_default_setting.ts +@@ -224,6 +224,17 @@ export class CategoryDefaultSettingElement extends + this.categoryEnabled ? ContentSetting.ASK : ContentSetting.BLOCK); + break; + default: ++ for (let index=0; index < loadTimeData.getInteger("br_cs_count"); index++) { ++ let obj = JSON.parse(loadTimeData.getString("br_cs_" + index)); ++ let name = obj["name"]; ++ if (this.category == name) { ++ // "Allowed" vs "Blocked". ++ this.browserProxy.setDefaultValueForContentType( ++ this.category, ++ this.categoryEnabled ? ContentSetting.ALLOW : ContentSetting.BLOCK); ++ break; ++ } ++ } + assertNotReached('Invalid category: ' + this.category); + } + } +diff --git a/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts b/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts +--- a/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts ++++ b/chrome/browser/resources/settings/site_settings/settings_category_default_radio_group.ts +@@ -162,6 +162,13 @@ export class SettingsCategoryDefaultRadioGroupElement extends + // "Ask" vs "Blocked". + return ContentSetting.ASK; + default: ++ for (let index=0; index < loadTimeData.getInteger("br_cs_count"); index++) { ++ let obj = JSON.parse(loadTimeData.getString("br_cs_" + index)); ++ let name = obj["name"]; ++ if (this.category == name) { ++ return ContentSetting.ALLOW; ++ } ++ } + assertNotReached('Invalid category: ' + this.category); + } + } +diff --git a/chrome/browser/resources/settings/site_settings/site_details.html b/chrome/browser/resources/settings/site_settings/site_details.html +--- a/chrome/browser/resources/settings/site_settings/site_details.html ++++ b/chrome/browser/resources/settings/site_settings/site_details.html +@@ -266,4 +266,5 @@ + category="[[contentSettingsTypesEnum_.LOCAL_FONTS]]" + icon="settings:local-fonts" label="$i18n{fonts}"> + ++
+
+diff --git a/chrome/browser/resources/settings/site_settings/site_details.ts b/chrome/browser/resources/settings/site_settings/site_details.ts +--- a/chrome/browser/resources/settings/site_settings/site_details.ts ++++ b/chrome/browser/resources/settings/site_settings/site_details.ts +@@ -61,7 +61,21 @@ export class SiteDetailsElement extends SiteDetailsElementBase { + } + + static get template() { +- return getTemplate(); ++ let template = getTemplate(); ++ let content = template.content.getElementById("bromite-placeholder")!; ++ ++ for (let index=0; index < loadTimeData.getInteger("br_cs_count"); index++) { ++ let obj = JSON.parse(loadTimeData.getString("br_cs_" + index)); ++ let name = obj["name"]; ++ ++ let tag = document.createElement("site-details-permission"); ++ tag.setAttribute("category", name); ++ tag.setAttribute("icon", `br-settings:${name}`); ++ tag.setAttribute("label", loadTimeData.getString(`brSiteSettings${name}`)); ++ content.parentElement!.insertBefore(tag, content); ++ } ++ content.parentElement!.removeChild(content); ++ return template; + } + + static get properties() { +diff --git a/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts b/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts +--- a/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts ++++ b/chrome/browser/resources/settings/site_settings_page/site_settings_page.ts +@@ -41,7 +41,7 @@ function getCategoryItemMap(): Map { + } + // The following list is ordered alphabetically by |id|. The order in which + // these appear in the UI is determined elsewhere in this file. +- const categoryList = [ ++ let categoryList = [ + { + route: routes.SITE_SETTINGS_ADS, + id: Id.ADS, +@@ -336,10 +336,34 @@ function getCategoryItemMap(): Map { + }, + ]; + ++ for (let index=0; index < loadTimeData.getInteger("br_cs_count"); index++) { ++ let obj = JSON.parse(loadTimeData.getString("br_cs_" + index)); ++ let name = obj["name"]; ++ ++ categoryList.push({ ++ route: (routes as any)[`SITE_SETTINGS_${name.toUpperCase()}`], ++ id: name, ++ label: `brSiteSettings${name}`, ++ icon: `br-settings:${name}`, ++ enabledLabel: `brSiteSettings${name}Allowed`, ++ disabledLabel: `brSiteSettings${name}Blocked`, ++ }); ++ } ++ + categoryItemMap = new Map(categoryList.map(item => [item.id, item])); + return categoryItemMap; + } + ++function buildBromiteItemListFromIds(orderedIdList: ContentSettingsTypes[]): ++ CategoryListItem[] { ++ for (let index=0; index < loadTimeData.getInteger("br_cs_count"); index++) { ++ let obj = JSON.parse(loadTimeData.getString("br_cs_" + index)); ++ let name = obj["name"]; ++ orderedIdList.push(name); ++ } ++ return buildItemListFromIds(orderedIdList); ++} ++ + function buildItemListFromIds(orderedIdList: ContentSettingsTypes[]): + CategoryListItem[] { + const map = getCategoryItemMap(); +@@ -417,7 +441,7 @@ export class SettingsSiteSettingsPageElement extends + Id.IMAGES, + Id.POPUPS, + ]), +- contentAdvanced: buildItemListFromIds([ ++ contentAdvanced: buildBromiteItemListFromIds([ + Id.SOUND, + Id.ADS, + Id.ZOOM_LEVELS, +diff --git a/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts b/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts +--- a/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts ++++ b/chrome/browser/resources/settings/site_settings_page/site_settings_page_util.ts +@@ -6,6 +6,54 @@ import {assertNotReached} from 'chrome://resources/js/assert_ts.js'; + + import {ContentSettingsTypes} from '../site_settings/constants.js'; + ++import {loadTimeData} from 'chrome://resources/js/load_time_data.js'; ++import {Route, Router, SettingsRoutes} from '../router.js'; ++ ++function createPath_(content: string) : Node { ++ let path = document.createElementNS("http://www.w3.org/2000/svg", "path"); ++ path.setAttribute("d", content); ++ path.setAttribute("fill", "#5F6368"); ++ return path; ++} ++ ++export function setupContentSettingsRoutes(r: Partial) { ++ let iconset = document.createElement("iron-iconset-svg"); ++ iconset.setAttribute("name", "br-settings"); ++ iconset.setAttribute("size", "24"); ++ ++ const svg_ns = "http://www.w3.org/2000/svg"; ++ let svg = document.createElementNS(svg_ns, "svg"); ++ iconset.appendChild(svg); ++ ++ let defs = document.createElementNS(svg_ns, "defs"); ++ svg.appendChild(defs); ++ ++ let routes: any = r; ++ for (let index=0; index < loadTimeData.getInteger("br_cs_count"); index++) { ++ // create the enum ++ let obj = JSON.parse(loadTimeData.getString("br_cs_" + index)); ++ let name = obj["name"]; ++ let tag_name = obj["tag_ui"]; if (!tag_name) tag_name = name; ++ routes["SITE_SETTINGS_" + name.toUpperCase()] = r.SITE_SETTINGS!.createChild(tag_name); ++ ++ // add the icons (on) ++ let g_on = document.createElementNS(svg_ns, "g"); ++ g_on.setAttribute("id", `${name}`); ++ g_on.appendChild(createPath_("M8 16h8v2H8v-2zm0-4h8v2H8v-2zm6-10H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z")); ++ defs.appendChild(g_on); ++ ++ // add the icons (off) ++ let g_off = document.createElementNS(svg_ns, "g"); ++ g_off.setAttribute("id", `${name}-off`); ++ g_off.appendChild(createPath_("M13.002 4.001H7.106L5.252 2.148c.232-.094.485-.147.75-.147h8l6 6v8.896l-2-2V9.001h-5v-5z")); ++ g_off.appendChild(createPath_("M16.002 12.001h-.896l.896.896v-.896zM.6 3.45l1.414-1.414 19.94 19.94-1.414 1.414L.6 3.45zM3.986 20.01V6.84l2 2V20.01h11.172l1.765 1.766c-.28.15-.599.234-.937.234H5.976c-1.1 0-1.99-.9-1.99-2z")); ++ g_off.appendChild(createPath_("M9.158 12.01H7.986v2h3.172l-2-2zM13.158 16.01H7.986v2h7.172l-2-2z")); ++ defs.appendChild(g_off); ++ } ++ ++ document.head.appendChild(iconset); ++} ++ + /** + * Determine localization string for i18n for a given content settings type. + * Sorted alphabetically by |ContentSettingsType|. +@@ -84,6 +132,13 @@ export function getLocalizationStringForContentType( + case ContentSettingsTypes.SITE_DATA: + return null; + default: ++ for (let index=0; index < loadTimeData.getInteger("br_cs_count"); index++) { ++ let obj = JSON.parse(loadTimeData.getString("br_cs_" + index)); ++ let name = obj["name"]; ++ if (name == contentSettingsType) { ++ return `brSiteSettings${name}MidSentence`; ++ } ++ } + assertNotReached(); + } + } +diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn +--- a/chrome/browser/ui/BUILD.gn ++++ b/chrome/browser/ui/BUILD.gn +@@ -1859,6 +1859,7 @@ static_library("ui") { + "//components/commerce/core:shopping_service", + "//components/commerce/core/mojom:mojo_bindings", + "//components/commerce/core/webui", ++ "//components/content_settings/core/browser:browser", + "//components/enterprise/common:files_scan_data", + "//components/feedback/proto", + "//components/headless/policy", +diff --git a/chrome/browser/ui/views/page_info/page_info_view_factory.cc b/chrome/browser/ui/views/page_info/page_info_view_factory.cc +--- a/chrome/browser/ui/views/page_info/page_info_view_factory.cc ++++ b/chrome/browser/ui/views/page_info/page_info_view_factory.cc +@@ -25,6 +25,8 @@ + #include "chrome/browser/ui/views/page_info/page_info_navigation_handler.h" + #include "chrome/browser/ui/views/page_info/page_info_permission_content_view.h" + #include "chrome/browser/ui/views/page_info/page_info_security_content_view.h" ++#include "components/content_settings/core/browser/website_settings_info.h" ++#include "components/content_settings/core/browser/website_settings_registry.h" + #include "components/page_info/core/features.h" + #include "components/page_info/core/proto/about_this_site_metadata.pb.h" + #include "components/page_info/page_info.h" +@@ -370,6 +372,17 @@ const ui::ImageModel PageInfoViewFactory::GetPermissionIcon( + icon = &vector_icons::kDevicesIcon; + break; + default: ++ bool found = false; ++ content_settings::WebsiteSettingsRegistry* website_settings = ++ content_settings::WebsiteSettingsRegistry::GetInstance(); ++ for (const content_settings::WebsiteSettingsInfo* cs : *website_settings) { ++ if (cs->type() == info.type && cs->show_into_info_page()) { ++ icon = &vector_icons::kProtectedContentIcon; ++ found = true; ++ break; ++ } ++ } ++ if (found) break; + // All other |ContentSettingsType|s do not have icons on desktop or are + // not shown in the Page Info bubble. + NOTREACHED_NORETURN(); +diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +--- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc ++++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +@@ -13,6 +13,7 @@ + #include "base/strings/escape.h" + #include "base/strings/string_number_conversions.h" + #include "base/strings/utf_string_conversions.h" ++#include "base/json/json_writer.h" + #include "build/branding_buildflags.h" + #include "build/build_config.h" + #include "build/buildflag.h" +@@ -71,6 +72,8 @@ + #include "components/dom_distiller/core/dom_distiller_features.h" + #include "components/google/core/common/google_util.h" + #include "components/omnibox/common/omnibox_features.h" ++#include "components/content_settings/core/browser/website_settings_info.h" ++#include "components/content_settings/core/browser/website_settings_registry.h" + #include "components/password_manager/core/browser/leak_detection_dialog_utils.h" + #include "components/password_manager/core/browser/manage_passwords_referrer.h" + #include "components/password_manager/core/common/password_manager_features.h" +@@ -3730,6 +3733,42 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source, + policy_indicator::AddLocalizedStrings(html_source); + AddSecurityKeysStrings(html_source); + ++ content_settings::WebsiteSettingsRegistry* website_settings = ++ content_settings::WebsiteSettingsRegistry::GetInstance(); ++ int index = 0; ++ for (const content_settings::WebsiteSettingsInfo* info : *website_settings) { ++ if (info->desktop_ui()) { ++ std::string name = info->name(); ++ std::string prefix = "brSiteSettings" + name; ++ ++ html_source->AddLocalizedString(prefix, info->title_ui()); ++ html_source->AddLocalizedString(prefix + "Description", info->description_ui()); ++ html_source->AddLocalizedString(prefix + "Allowed", info->allowed_ui()); ++ html_source->AddLocalizedString(prefix + "Blocked", info->blocked_ui()); ++ html_source->AddLocalizedString(prefix + "AllowedExceptions", info->allowed_exceptions_ui()); ++ html_source->AddLocalizedString(prefix + "BlockedExceptions", info->blocked_exceptions_ui()); ++ html_source->AddLocalizedString(prefix + "MidSentence", info->mid_sentence_ui()); ++ ++ base::Value::Dict dict; ++ dict.Set("name", name); ++ dict.Set("type", (int)info->type()); ++ dict.Set("tag_ui", info->tag_ui()); ++ dict.Set("default", ++ info->initial_default_value().GetInt() == (int)CONTENT_SETTING_ALLOW ? "allow" : ++ info->initial_default_value().GetInt() == (int)CONTENT_SETTING_BLOCK ? "block" : ++ "ask"); ++ ++ std::string json_string; ++ base::JSONWriter::WriteWithOptions( ++ dict, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json_string); ++ base::TrimWhitespaceASCII(json_string, base::TRIM_ALL, &json_string); ++ ++ html_source->AddString("br_cs_" + base::NumberToString(index), json_string); ++ index++; ++ } ++ } ++ html_source->AddInteger("br_cs_count", index); ++ + html_source->UseStringsJs(); + } + +diff --git a/chrome/browser/ui/webui/settings/site_settings_helper.cc b/chrome/browser/ui/webui/settings/site_settings_helper.cc +--- a/chrome/browser/ui/webui/settings/site_settings_helper.cc ++++ b/chrome/browser/ui/webui/settings/site_settings_helper.cc +@@ -38,6 +38,8 @@ + #include "chrome/common/pref_names.h" + #include "chrome/common/url_constants.h" + #include "components/content_settings/core/browser/host_content_settings_map.h" ++#include "components/content_settings/core/browser/website_settings_info.h" ++#include "components/content_settings/core/browser/website_settings_registry.h" + #include "components/content_settings/core/common/content_settings.h" + #include "components/content_settings/core/common/content_settings_pattern.h" + #include "components/content_settings/core/common/content_settings_utils.h" +@@ -190,7 +192,7 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = { + + static_assert(std::size(kContentSettingsTypeGroupNames) == + // ContentSettingsType starts at -1, so add 1 here. +- static_cast(ContentSettingsType::NUM_TYPES) + 1, ++ static_cast(ContentSettingsType::NUM_TYPES_CHROMIUM) + 1, + "kContentSettingsTypeGroupNames should have " + "CONTENT_SETTINGS_NUM_TYPES elements"); + +@@ -440,6 +442,13 @@ bool HasRegisteredGroupName(ContentSettingsType type) { + return true; + } + } ++ content_settings::WebsiteSettingsRegistry* website_settings = ++ content_settings::WebsiteSettingsRegistry::GetInstance(); ++ for (const content_settings::WebsiteSettingsInfo* cs : *website_settings) { ++ if (type == cs->type() && cs->desktop_ui()) { ++ return true; ++ } ++ } + return false; + } + +@@ -453,7 +462,13 @@ ContentSettingsType ContentSettingsTypeFromGroupName(base::StringPiece name) { + return entry.type; + } + } +- ++ content_settings::WebsiteSettingsRegistry* website_settings = ++ content_settings::WebsiteSettingsRegistry::GetInstance(); ++ for (const content_settings::WebsiteSettingsInfo* cs : *website_settings) { ++ if (name == cs->name() && cs->desktop_ui()) { ++ return cs->type(); ++ } ++ } + return ContentSettingsType::DEFAULT; + } + +@@ -467,6 +482,13 @@ base::StringPiece ContentSettingsTypeToGroupName(ContentSettingsType type) { + } + } + ++ content_settings::WebsiteSettingsRegistry* website_settings = ++ content_settings::WebsiteSettingsRegistry::GetInstance(); ++ for (const content_settings::WebsiteSettingsInfo* cs : *website_settings) { ++ if (type == cs->type() && cs->desktop_ui()) { ++ return cs->name(); ++ } ++ } + NOTREACHED() << static_cast(type) + << " is not a recognized content settings type."; + return base::StringPiece(); +@@ -535,6 +557,13 @@ const std::vector& GetVisiblePermissionCategories() { + base_types->push_back(ContentSettingsType::PRIVATE_NETWORK_GUARD); + } + ++ content_settings::WebsiteSettingsRegistry* website_settings = ++ content_settings::WebsiteSettingsRegistry::GetInstance(); ++ for (const content_settings::WebsiteSettingsInfo* cs : *website_settings) { ++ if (cs->desktop_ui()) { ++ base_types->push_back(cs->type()); ++ } ++ } + initialized = true; + } + 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 -@@ -139,6 +139,21 @@ android_library("java") { +@@ -139,6 +139,20 @@ android_library("java") { ] srcjar_deps = [ "//components/content_settings/android:java_pref_names_srcjar" ] @@ -84,7 +575,6 @@ diff --git a/components/browser_ui/site_settings/android/BUILD.gn b/components/b + +java_bromite_impl("java_bromite_content_settings") { + inputs = [ "java/src/org/chromium/components/browser_ui/site_settings/impl/include_all_directory.java" ] -+ directories = [ "java/src/org/chromium/components/browser_ui/site_settings/impl" ] + template = "java/src/org/chromium/components/browser_ui/site_settings/impl/java_template/BromiteCustomContentSettingImplBase.java.tmpl" } @@ -93,7 +583,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/BromiteCustomContentSetting.java -@@ -0,0 +1,127 @@ +@@ -0,0 +1,128 @@ +/* + This file is part of Bromite. + @@ -188,6 +678,7 @@ new file mode 100644 + public abstract ContentSettingsResources.ResourceItem getResourceItem(); + public abstract int getCategorySummary(@Nullable @ContentSettingValues int value); + public abstract int getAddExceptionDialogMessage(); ++ public abstract int getCategoryDescription(); + + public boolean processOnBlockList(@ContentSettingValues Integer value) { + return true; @@ -225,7 +716,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,275 @@ +@@ -0,0 +1,284 @@ +/* + This file is part of Bromite. + @@ -347,6 +838,15 @@ new file mode 100644 + return null; + } + ++ public static int getCategoryDescription(SiteSettingsCategory category) { ++ for (BromiteCustomContentSetting cs : mItemList) { ++ if (category.getType() == cs.getSiteSettingsCategory()) { ++ return cs.getCategoryDescription(); ++ } ++ } ++ return 0; ++ } ++ + public static boolean onPreferenceChange(SiteSettingsCategory category, + BrowserContextHandle browserContextHandle, + Preference preference, Object newValue) { @@ -770,7 +1270,20 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c return (triStateToggle.getCheckedSetting() == ContentSettingValues.BLOCK); case GlobalToggleLayout.FOUR_STATE_COOKIE_TOGGLE: FourStateCookieSettingsPreference fourStateCookieToggle = -@@ -1182,6 +1198,7 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -1158,7 +1174,11 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment + } else if (mCategory.getType() == SiteSettingsCategory.Type.THIRD_PARTY_COOKIES) { + infoText.setSummary(R.string.website_settings_third_party_cookies_page_description); + } else { +- screen.removePreference(infoText); ++ int infoMessage = BromiteCustomContentSettingImpl.getCategoryDescription(mCategory); ++ if (infoMessage == 0) ++ screen.removePreference(infoText); ++ else ++ infoText.setSummary(infoMessage); + } + + // Hide the anti-abuse text preferences, as needed. +@@ -1182,6 +1202,7 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment screen.removePreference(antiAbuseThingsToConsiderHeader); screen.removePreference(antiAbuseThingsToConsiderSectionOne); } @@ -778,7 +1291,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c if (permissionBlockedByOs) { maybeShowOsWarning(screen); -@@ -1335,7 +1352,7 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -1335,7 +1356,7 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment getSiteSettingsDelegate().getBrowserContextHandle(), contentType); int[] descriptionIds = ContentSettingsResources.getTriStateSettingDescriptionIDs(contentType); @@ -787,7 +1300,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c } private void configureBinaryToggle(ChromeSwitchPreference binaryToggle, int contentType) { -@@ -1439,6 +1456,14 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -1439,6 +1460,14 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment @ContentSettingValues Integer value = site.getContentSetting(browserContextHandle, contentSettingsType); @@ -858,6 +1371,15 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c switchPreference.setOnPreferenceChangeListener(this); @ContentSettingsType int contentType = getContentSettingsTypeFromPreferenceKey(preference.getKey()); +@@ -1121,7 +1131,7 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment + public @ContentSettingsType int getContentSettingsTypeFromPreferenceKey(String preferenceKey) { + if (mPreferenceMap == null) { + mPreferenceMap = new HashMap<>(); +- for (@ContentSettingsType int type = 0; type < ContentSettingsType.NUM_TYPES; type++) { ++ for (@ContentSettingsType int type = 0; type < ContentSettingsType.NUM_TYPES_BROMITE; type++) { + String key = getPreferenceKey(type); + if (key != null) { + mPreferenceMap.put(key, type); @@ -1159,7 +1169,7 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment } @@ -867,6 +1389,15 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c preference.setIcon(getContentSettingsIcon(type, permission)); if (mWebsiteSettingsObserver != null) { +@@ -1189,7 +1199,7 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment + // TODO(mvanouwerkerk): Refactor this class so that it does not depend on the screen state + // for its logic. This class should maintain its own data model, and only update the screen + // after a change is made. +- for (@ContentSettingsType int type = 0; type < ContentSettingsType.NUM_TYPES; type++) { ++ for (@ContentSettingsType int type = 0; type < ContentSettingsType.NUM_TYPES_BROMITE; type++) { + String key = getPreferenceKey(type); + if (key != null) { + removePreferenceSafely(key); diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettings.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettings.java --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettings.java +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettings.java @@ -1049,6 +1580,15 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c } } +@@ -209,7 +209,7 @@ public class WebsitePermissionsFetcher { + if (SiteSettingsFeatureList.isEnabled(SiteSettingsFeatureList.SITE_DATA_IMPROVEMENTS)) { + queue.add(new CookiesInfoFetcher()); + } +- for (@ContentSettingsType int type = 0; type < ContentSettingsType.NUM_TYPES; type++) { ++ for (@ContentSettingsType int type = 0; type < ContentSettingsType.NUM_TYPES_BROMITE; type++) { + addFetcherForContentSettingsType(queue, type); + } + } diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java @@ -1128,34 +1668,13 @@ new file mode 100644 + }} + +}} -diff --git a/components/browser_ui/strings/android/bromite_content_settings/placeholder.txt b/components/browser_ui/strings/android/bromite_content_settings/placeholder.txt +diff --git a/components/browser_ui/strings/bromite_content_settings/placeholder.txt b/components/browser_ui/strings/bromite_content_settings/placeholder.txt new file mode 100644 --- /dev/null -+++ b/components/browser_ui/strings/android/bromite_content_settings/placeholder.txt -@@ -0,0 +1 @@ ++++ b/components/browser_ui/strings/bromite_content_settings/placeholder.txt +@@ -0,0 +1,2 @@ +this file is intentionally empty -diff --git a/components/browser_ui/strings/android/browser_ui_strings.grd b/components/browser_ui/strings/android/browser_ui_strings.grd ---- a/components/browser_ui/strings/android/browser_ui_strings.grd -+++ b/components/browser_ui/strings/android/browser_ui_strings.grd -@@ -174,6 +174,7 @@ - - - -+ - - - Got it -diff --git a/components/components_strings.grd b/components/components_strings.grd ---- a/components/components_strings.grd -+++ b/components/components_strings.grd -@@ -281,6 +281,7 @@ - - - -+ - - - ++ diff --git a/components/content_settings/core/browser/BUILD.gn b/components/content_settings/core/browser/BUILD.gn --- a/components/content_settings/core/browser/BUILD.gn +++ b/components/content_settings/core/browser/BUILD.gn @@ -1168,7 +1687,7 @@ diff --git a/components/content_settings/core/browser/BUILD.gn b/components/cont +} + +cpp_bromite_include("bromite_content_settings") { -+ directories = [ "bromite_content_settings/placeholder.txt" ] ++ inputs = [ "bromite_content_settings/placeholder.txt" ] + output_file = "bromite_content_settings.inc" } @@ -1182,16 +1701,15 @@ new file mode 100644 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 -@@ -15,6 +15,8 @@ +@@ -15,6 +15,7 @@ #include "components/content_settings/core/browser/website_settings_registry.h" #include "components/content_settings/core/common/content_settings.h" #include "components/content_settings/core/common/features.h" -+#include "components/strings/grit/components_chromium_strings.h" +#include "components/strings/grit/components_strings.h" namespace content_settings { -@@ -592,6 +594,8 @@ void ContentSettingsRegistry::Init() { +@@ -592,6 +593,8 @@ void ContentSettingsRegistry::Init() { WebsiteSettingsRegistry::ALL_PLATFORMS, ContentSettingsInfo::INHERIT_IN_INCOGNITO, ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); @@ -1200,47 +1718,6 @@ diff --git a/components/content_settings/core/browser/content_settings_registry. } void ContentSettingsRegistry::Register( -@@ -604,7 +608,11 @@ void ContentSettingsRegistry::Register( - WebsiteSettingsInfo::ScopingType scoping_type, - Platforms platforms, - ContentSettingsInfo::IncognitoBehavior incognito_behavior, -- ContentSettingsInfo::OriginRestriction origin_restriction) { -+ ContentSettingsInfo::OriginRestriction origin_restriction, -+ bool show_into_info_page, -+ bool is_renderer_content_setting, -+ int permission_type_ui, -+ int permission_type_ui_mid_sentence) { - // Ensure that nothing has been registered yet for the given type. - DCHECK(!website_settings_registry_->Get(type)); - -@@ -613,7 +621,10 @@ void ContentSettingsRegistry::Register( - website_settings_registry_->Register( - type, name, std::move(default_value), sync_status, - WebsiteSettingsInfo::NOT_LOSSY, scoping_type, platforms, -- WebsiteSettingsInfo::INHERIT_IN_INCOGNITO); -+ WebsiteSettingsInfo::INHERIT_IN_INCOGNITO, -+ show_into_info_page, is_renderer_content_setting, -+ permission_type_ui, -+ permission_type_ui_mid_sentence); - - // WebsiteSettingsInfo::Register() will return nullptr if content setting type - // is not used on the current platform and doesn't need to be registered. -diff --git a/components/content_settings/core/browser/content_settings_registry.h b/components/content_settings/core/browser/content_settings_registry.h ---- a/components/content_settings/core/browser/content_settings_registry.h -+++ b/components/content_settings/core/browser/content_settings_registry.h -@@ -70,7 +70,11 @@ class ContentSettingsRegistry { - WebsiteSettingsInfo::ScopingType scoping_type, - Platforms platforms, - ContentSettingsInfo::IncognitoBehavior incognito_behavior, -- ContentSettingsInfo::OriginRestriction origin_restriction); -+ ContentSettingsInfo::OriginRestriction origin_restriction, -+ bool show_into_info_page = false, -+ bool is_renderer_content_setting = false, -+ int permission_type_ui = 0, -+ int permission_type_ui_mid_sentence = 0); - - Map content_settings_info_; - raw_ptr website_settings_registry_; diff --git a/components/content_settings/core/browser/content_settings_utils.cc b/components/content_settings/core/browser/content_settings_utils.cc --- a/components/content_settings/core/browser/content_settings_utils.cc +++ b/components/content_settings/core/browser/content_settings_utils.cc @@ -1270,117 +1747,85 @@ diff --git a/components/content_settings/core/browser/content_settings_utils.cc #if !BUILDFLAG(IS_ANDROID) map->GetSettingsForOneType(ContentSettingsType::IMAGES, &(rules->image_rules)); -diff --git a/components/content_settings/core/browser/website_settings_info.cc b/components/content_settings/core/browser/website_settings_info.cc ---- a/components/content_settings/core/browser/website_settings_info.cc -+++ b/components/content_settings/core/browser/website_settings_info.cc -@@ -33,7 +33,11 @@ WebsiteSettingsInfo::WebsiteSettingsInfo(ContentSettingsType type, - SyncStatus sync_status, - LossyStatus lossy_status, - ScopingType scoping_type, -- IncognitoBehavior incognito_behavior) -+ IncognitoBehavior incognito_behavior, -+ bool show_into_info_page, -+ bool is_renderer_content_setting, -+ int permission_type_ui, -+ int permission_type_ui_mid_sentence) - : type_(type), - name_(name), - pref_name_(GetPreferenceName(name, kPrefPrefix)), -@@ -42,7 +46,11 @@ WebsiteSettingsInfo::WebsiteSettingsInfo(ContentSettingsType type, - sync_status_(sync_status), - lossy_status_(lossy_status), - scoping_type_(scoping_type), -- incognito_behavior_(incognito_behavior) { -+ incognito_behavior_(incognito_behavior), -+ show_into_info_page_(show_into_info_page), -+ is_renderer_content_setting_(is_renderer_content_setting), -+ permission_type_ui_(permission_type_ui), -+ permission_type_ui_mid_sentence_(permission_type_ui_mid_sentence) { - // For legacy reasons the default value is currently restricted to be an int - // or none. - // TODO(raymes): We should migrate the underlying pref to be a dictionary diff --git a/components/content_settings/core/browser/website_settings_info.h b/components/content_settings/core/browser/website_settings_info.h --- a/components/content_settings/core/browser/website_settings_info.h +++ b/components/content_settings/core/browser/website_settings_info.h -@@ -95,7 +95,11 @@ class WebsiteSettingsInfo { - SyncStatus sync_status, - LossyStatus lossy_status, - ScopingType scoping_type, -- IncognitoBehavior incognito_behavior); -+ IncognitoBehavior incognito_behavior, -+ bool show_into_info_page, -+ bool is_renderer_content_setting, -+ int permission_type_ui, -+ int permission_type_ui_mid_sentence); - - WebsiteSettingsInfo(const WebsiteSettingsInfo&) = delete; - WebsiteSettingsInfo& operator=(const WebsiteSettingsInfo&) = delete; -@@ -120,6 +124,11 @@ class WebsiteSettingsInfo { +@@ -120,6 +120,30 @@ class WebsiteSettingsInfo { ScopingType scoping_type() const { return scoping_type_; } IncognitoBehavior incognito_behavior() const { return incognito_behavior_; } + bool show_into_info_page() const { return show_into_info_page_; } + bool is_renderer_content_setting() const { return is_renderer_content_setting_; } -+ int permission_type_ui() const { return permission_type_ui_; } -+ int permission_type_ui_mid_sentence() const { return permission_type_ui_mid_sentence_; } ++ bool desktop_ui() const { return desktop_ui_; } ++ std::string tag_ui() const { return tag_ui_; } ++ int title_ui() const { return title_ui_; } ++ int description_ui() const { return description_ui_; } ++ int allowed_ui() const { return allowed_ui_; } ++ int blocked_ui() const { return blocked_ui_; } ++ int allowed_exceptions_ui() const { return allowed_exceptions_ui_; } ++ int blocked_exceptions_ui() const { return blocked_exceptions_ui_; } ++ int mid_sentence_ui() const { return mid_sentence_ui_; } ++ ++ WebsiteSettingsInfo& set_show_into_info_page() { show_into_info_page_ = true; return *this; } ++ WebsiteSettingsInfo& set_is_renderer_content_setting() { is_renderer_content_setting_ = true; return *this; } ++ WebsiteSettingsInfo& set_desktop_ui() { desktop_ui_ = true; return *this; } ++ WebsiteSettingsInfo& set_tag_ui(const std::string& value) { tag_ui_ = value; return *this; } ++ WebsiteSettingsInfo& set_title_ui(int value) { title_ui_ = value; return *this; } ++ WebsiteSettingsInfo& set_description_ui(int value) { description_ui_ = value; return *this; } ++ WebsiteSettingsInfo& set_allowed_ui(int value) { allowed_ui_ = value; return *this; } ++ WebsiteSettingsInfo& set_blocked_ui(int value) { blocked_ui_ = value; return *this; } ++ WebsiteSettingsInfo& set_allowed_exceptions_ui(int value) { allowed_exceptions_ui_ = value; return *this; } ++ WebsiteSettingsInfo& set_blocked_exceptions_ui(int value) { blocked_exceptions_ui_ = value; return *this; } ++ WebsiteSettingsInfo& set_mid_sentence_ui(int value) { mid_sentence_ui_ = value; return *this; } + private: const ContentSettingsType type_; const std::string name_; -@@ -131,6 +140,10 @@ class WebsiteSettingsInfo { +@@ -131,6 +155,17 @@ class WebsiteSettingsInfo { const LossyStatus lossy_status_; const ScopingType scoping_type_; const IncognitoBehavior incognito_behavior_; -+ const bool show_into_info_page_; -+ const bool is_renderer_content_setting_; -+ const int permission_type_ui_; -+ const int permission_type_ui_mid_sentence_; ++ bool show_into_info_page_ = false; ++ bool is_renderer_content_setting_ = false; ++ bool desktop_ui_ = false; ++ std::string tag_ui_; ++ int title_ui_ = 0; ++ int description_ui_ = 0; ++ int allowed_ui_ = 0; ++ int blocked_ui_ = 0; ++ int allowed_exceptions_ui_ = 0; ++ int blocked_exceptions_ui_ = 0; ++ int mid_sentence_ui_ = 0; }; } // namespace content_settings diff --git a/components/content_settings/core/browser/website_settings_registry.cc b/components/content_settings/core/browser/website_settings_registry.cc --- a/components/content_settings/core/browser/website_settings_registry.cc +++ b/components/content_settings/core/browser/website_settings_registry.cc -@@ -62,7 +62,11 @@ const WebsiteSettingsInfo* WebsiteSettingsRegistry::Register( - WebsiteSettingsInfo::LossyStatus lossy_status, - WebsiteSettingsInfo::ScopingType scoping_type, - Platforms platform, -- WebsiteSettingsInfo::IncognitoBehavior incognito_behavior) { -+ WebsiteSettingsInfo::IncognitoBehavior incognito_behavior, -+ bool show_into_info_page, -+ bool is_renderer_content_setting, -+ int permission_type_ui, -+ int permission_type_ui_mid_sentence) { - #if BUILDFLAG(IS_WIN) - if (!(platform & PLATFORM_WINDOWS)) - return nullptr; -@@ -98,7 +102,9 @@ const WebsiteSettingsInfo* WebsiteSettingsRegistry::Register( - - WebsiteSettingsInfo* info = new WebsiteSettingsInfo( - type, name, std::move(initial_default_value), sync_status, lossy_status, -- scoping_type, incognito_behavior); -+ scoping_type, incognito_behavior, -+ show_into_info_page, is_renderer_content_setting, -+ permission_type_ui, permission_type_ui_mid_sentence); - website_settings_info_[info->type()] = base::WrapUnique(info); - return info; +@@ -45,6 +45,12 @@ const WebsiteSettingsInfo* WebsiteSettingsRegistry::Get( + return nullptr; } + ++raw_ptr WebsiteSettingsRegistry::GetMutable( ++ ContentSettingsType type) { ++ const auto& it = website_settings_info_.find(type); ++ return it->second.get(); ++} ++ + const WebsiteSettingsInfo* WebsiteSettingsRegistry::GetByName( + const std::string& name) const { + for (const auto& entry : website_settings_info_) { diff --git a/components/content_settings/core/browser/website_settings_registry.h b/components/content_settings/core/browser/website_settings_registry.h --- a/components/content_settings/core/browser/website_settings_registry.h +++ b/components/content_settings/core/browser/website_settings_registry.h -@@ -76,7 +76,11 @@ class WebsiteSettingsRegistry { - WebsiteSettingsInfo::LossyStatus lossy_status, - WebsiteSettingsInfo::ScopingType scoping_type, - Platforms platforms, -- WebsiteSettingsInfo::IncognitoBehavior incognito_behavior); -+ WebsiteSettingsInfo::IncognitoBehavior incognito_behavior, -+ bool show_into_info_page = false, -+ bool is_renderer_content_setting = false, -+ int permission_type_ui = 0, -+ int permission_type_ui_mid_sentence = 0); +@@ -61,6 +61,7 @@ class WebsiteSettingsRegistry { + void ResetForTest(); - const_iterator begin() const; - const_iterator end() const; + const WebsiteSettingsInfo* Get(ContentSettingsType type) const; ++ raw_ptr GetMutable(ContentSettingsType type); + const WebsiteSettingsInfo* GetByName(const std::string& name) const; + + // Register a new website setting. This maps an origin to an arbitrary diff --git a/components/content_settings/core/common/BUILD.gn b/components/content_settings/core/common/BUILD.gn --- a/components/content_settings/core/common/BUILD.gn +++ b/components/content_settings/core/common/BUILD.gn @@ -1392,7 +1837,7 @@ diff --git a/components/content_settings/core/common/BUILD.gn b/components/conte +} + +cpp_bromite_include("bromite_content_settings") { -+ directories = [ "bromite_content_settings/placeholder.txt" ] ++ inputs = [ "bromite_content_settings/placeholder.txt" ] + output_file = "bromite_content_settings.inc" } @@ -1422,6 +1867,15 @@ diff --git a/components/content_settings/core/common/content_settings.cc b/compo // Verify the array is sorted by enum type and contains all values. DCHECK(std::is_sorted(std::begin(kHistogramValue), std::end(kHistogramValue), +@@ -152,7 +154,7 @@ int ContentSettingTypeToHistogramValue(ContentSettingsType content_setting, + static_assert( + kHistogramValue[std::size(kHistogramValue) - 1].type == + ContentSettingsType( +- static_cast(ContentSettingsType::NUM_TYPES) - 1), ++ static_cast(ContentSettingsType::NUM_TYPES_CHROMIUM) - 1), + "Update content settings histogram lookup"); + + const HistogramValue* found = std::lower_bound( @@ -212,6 +214,13 @@ bool ContentSettingPatternSource::IsExpired() const { // static bool RendererContentSettingRules::IsRendererContentSetting( @@ -1569,18 +2023,32 @@ diff --git a/components/content_settings/core/common/content_settings_mojom_trai static const std::vector& image_rules( const RendererContentSettingRules& r) { return r.image_rules; +diff --git a/components/content_settings/core/common/content_settings_param_traits.h b/components/content_settings/core/common/content_settings_param_traits.h +--- a/components/content_settings/core/common/content_settings_param_traits.h ++++ b/components/content_settings/core/common/content_settings_param_traits.h +@@ -9,7 +9,7 @@ + #include "ipc/ipc_message_macros.h" + + IPC_ENUM_TRAITS_MAX_VALUE(ContentSettingsType, +- static_cast(ContentSettingsType::NUM_TYPES) - ++ static_cast(ContentSettingsType::NUM_TYPES_BROMITE) - + 1) + + #endif // COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_PARAM_TRAITS_H_ diff --git a/components/content_settings/core/common/content_settings_types.h b/components/content_settings/core/common/content_settings_types.h --- a/components/content_settings/core/common/content_settings_types.h +++ b/components/content_settings/core/common/content_settings_types.h -@@ -274,6 +274,8 @@ enum class ContentSettingsType : int32_t { - // site instead of the mobile one. - REQUEST_DESKTOP_SITE, +@@ -330,7 +330,9 @@ enum class ContentSettingsType : int32_t { + // Used to indicate whether HTTPS-First Mode is enabled on the hostname. + HTTPS_ENFORCED, +- NUM_TYPES, ++ NUM_TYPES_CHROMIUM, +#include "components/content_settings/core/common/bromite_content_settings.inc" -+ - // Setting to indicate whether browser should allow signing into a website via - // the browser FedCM API. - FEDERATED_IDENTITY_API, ++ NUM_TYPES_BROMITE, + }; + + struct ContentSettingsTypeHash { 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 @@ -1639,6 +2107,25 @@ diff --git a/components/content_settings/renderer/content_settings_agent_impl.h // blink::WebContentSettingsClient: void AllowStorageAccess(StorageType storage_type, base::OnceCallback callback) override; +diff --git a/components/page_info/android/java/src/org/chromium/components/page_info/PageInfoPermissionsController.java b/components/page_info/android/java/src/org/chromium/components/page_info/PageInfoPermissionsController.java +--- a/components/page_info/android/java/src/org/chromium/components/page_info/PageInfoPermissionsController.java ++++ b/components/page_info/android/java/src/org/chromium/components/page_info/PageInfoPermissionsController.java +@@ -174,6 +174,15 @@ public class PageInfoPermissionsController + : perm1.nameMidSentence.toString()); + } + ++ String value = ""; ++ for (PermissionObject perm : permissions) { ++ if (perm.allowed) { ++ if (!value.equals("")) value += ", "; ++ value += perm.nameMidSentence.toString(); ++ } ++ } ++ if ((true)) return value; ++ + // More than 2 permissions. + if (same) { + int resId = perm1.allowed ? R.plurals.page_info_permissions_summary_more_allowed diff --git a/components/page_info/android/java/src/org/chromium/components/page_info/PermissionParamsListBuilder.java b/components/page_info/android/java/src/org/chromium/components/page_info/PermissionParamsListBuilder.java --- a/components/page_info/android/java/src/org/chromium/components/page_info/PermissionParamsListBuilder.java +++ b/components/page_info/android/java/src/org/chromium/components/page_info/PermissionParamsListBuilder.java @@ -1661,14 +2148,15 @@ diff --git a/components/page_info/android/page_info_controller_android.cc b/comp #include "components/content_settings/core/common/content_settings.h" #include "components/content_settings/core/common/content_settings_types.h" #include "components/page_info/android/jni_headers/PageInfoController_jni.h" -@@ -151,6 +152,14 @@ void PageInfoControllerAndroid::SetPermissionInfo( +@@ -151,6 +152,15 @@ void PageInfoControllerAndroid::SetPermissionInfo( ContentSettingsType::FEDERATED_IDENTITY_API); } + content_settings::WebsiteSettingsRegistry* website_settings = + content_settings::WebsiteSettingsRegistry::GetInstance(); + for (const content_settings::WebsiteSettingsInfo* info : *website_settings) { -+ if (info->show_into_info_page()) { ++ if (info->show_into_info_page() && ++ !base::Contains(permissions_to_display, info->type())) { + permissions_to_display.push_back(info->type()); + } + } @@ -1676,15 +2164,14 @@ diff --git a/components/page_info/android/page_info_controller_android.cc b/comp std::map user_specified_settings_to_display; std::map -@@ -210,6 +219,15 @@ absl::optional PageInfoControllerAndroid::GetSettingToDisplay( +@@ -210,6 +220,14 @@ absl::optional PageInfoControllerAndroid::GetSettingToDisplay( return permission.setting; } + content_settings::WebsiteSettingsRegistry* website_settings = + content_settings::WebsiteSettingsRegistry::GetInstance(); + for (const content_settings::WebsiteSettingsInfo* info : *website_settings) { -+ if (info->type() == permission.type && -+ info->show_into_info_page()) { ++ if (info->type() == permission.type && info->show_into_info_page()) { + return permission.default_setting; + } + } @@ -1749,32 +2236,32 @@ diff --git a/components/page_info/page_info_ui.cc b/components/page_info/page_in #include "components/omnibox/common/omnibox_features.h" #include "components/page_info/core/features.h" #include "components/page_info/page_info.h" -@@ -574,6 +575,12 @@ std::u16string PageInfoUI::PermissionTypeToUIString(ContentSettingsType type) { +@@ -570,6 +571,12 @@ PageInfoUI::~PageInfoUI() = default; + + // static + std::u16string PageInfoUI::PermissionTypeToUIString(ContentSettingsType type) { ++ const content_settings::WebsiteSettingsInfo* settingInfo = ++ content_settings::WebsiteSettingsRegistry::GetInstance()->Get(type); ++ if (settingInfo && settingInfo->show_into_info_page()) { ++ if (settingInfo->title_ui() != 0) ++ return l10n_util::GetStringUTF16(settingInfo->title_ui()); ++ } + for (const PermissionUIInfo& info : GetContentSettingsUIInfo()) { if (info.type == type) return l10n_util::GetStringUTF16(info.string_id); - } +@@ -581,6 +588,12 @@ std::u16string PageInfoUI::PermissionTypeToUIString(ContentSettingsType type) { + // static + std::u16string PageInfoUI::PermissionTypeToUIStringMidSentence( + ContentSettingsType type) { + const content_settings::WebsiteSettingsInfo* settingInfo = + content_settings::WebsiteSettingsRegistry::GetInstance()->Get(type); -+ if (settingInfo && settingInfo->show_into_info_page() && -+ settingInfo->permission_type_ui() != 0) { -+ return l10n_util::GetStringUTF16(settingInfo->permission_type_ui()); ++ if (settingInfo && settingInfo->show_into_info_page()) { ++ if (settingInfo->mid_sentence_ui() != 0) ++ return l10n_util::GetStringUTF16(settingInfo->mid_sentence_ui()); + } - NOTREACHED(); - return std::u16string(); - } -@@ -585,6 +592,12 @@ std::u16string PageInfoUI::PermissionTypeToUIStringMidSentence( + for (const PermissionUIInfo& info : GetContentSettingsUIInfo()) { if (info.type == type) return l10n_util::GetStringUTF16(info.string_id_mid_sentence); - } -+ const content_settings::WebsiteSettingsInfo* settingInfo = -+ content_settings::WebsiteSettingsRegistry::GetInstance()->Get(type); -+ if (settingInfo && settingInfo->show_into_info_page() && -+ settingInfo->permission_type_ui_mid_sentence() != 0) { -+ return l10n_util::GetStringUTF16(settingInfo->permission_type_ui_mid_sentence()); -+ } - NOTREACHED(); - return std::u16string(); - } @@ -972,6 +985,11 @@ bool PageInfoUI::ContentSettingsTypeInPageInfo(ContentSettingsType type) { if (info.type == type) return true; @@ -1787,6 +2274,16 @@ diff --git a/components/page_info/page_info_ui.cc b/components/page_info/page_in return false; } +diff --git a/components/site_settings_strings.grdp b/components/site_settings_strings.grdp +--- a/components/site_settings_strings.grdp ++++ b/components/site_settings_strings.grdp +@@ -1,5 +1,6 @@ + + ++ + + + Intrusive ads diff --git a/third_party/blink/public/platform/web_content_settings_client.h b/third_party/blink/public/platform/web_content_settings_client.h --- a/third_party/blink/public/platform/web_content_settings_client.h +++ b/third_party/blink/public/platform/web_content_settings_client.h diff --git a/build/patches/JIT-site-settings.patch b/build/patches/JIT-site-settings.patch index 69942e0b..6fcead8f 100644 --- a/build/patches/JIT-site-settings.patch +++ b/build/patches/JIT-site-settings.patch @@ -18,22 +18,24 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html .../permission_javascript_jit.png | Bin 0 -> 518 bytes .../permission_javascript_jit.png | Bin 0 -> 629 bytes .../permission_javascript_jit.png | Bin 0 -> 797 bytes - .../BromiteJavascriptJITContentSetting.java | 87 ++++++++++++++++++ - .../javascript_jit.grdp | 18 ++++ - .../core/browser/content_settings_registry.cc | 8 +- - 9 files changed, 116 insertions(+), 2 deletions(-) + .../BromiteJavascriptJITContentSetting.java | 92 ++++++++++++++++++ + .../javascript_jit.grdp | 21 ++++ + .../javascript_jit.inc | 13 +++ + .../core/browser/content_settings_registry.cc | 2 +- + 10 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-hdpi/permission_javascript_jit.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-mdpi/permission_javascript_jit.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xhdpi/permission_javascript_jit.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xxhdpi/permission_javascript_jit.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xxxhdpi/permission_javascript_jit.png create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteJavascriptJITContentSetting.java - create mode 100644 components/browser_ui/strings/android/bromite_content_settings/javascript_jit.grdp + create mode 100644 components/browser_ui/strings/bromite_content_settings/javascript_jit.grdp + create mode 100644 components/content_settings/core/browser/bromite_content_settings/javascript_jit.inc 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 -@@ -203,6 +203,7 @@ android_resources("java_resources") { +@@ -202,6 +202,7 @@ android_resources("java_resources") { "java/res/drawable-hdpi/permission_background_sync.png", "java/res/drawable-hdpi/permission_images.png", "java/res/drawable-hdpi/permission_javascript.png", @@ -41,7 +43,7 @@ diff --git a/components/browser_ui/site_settings/android/BUILD.gn b/components/b "java/res/drawable-hdpi/permission_popups.png", "java/res/drawable-hdpi/permission_protected_media.png", "java/res/drawable-hdpi/settings_sensors.png", -@@ -211,6 +212,7 @@ android_resources("java_resources") { +@@ -210,6 +211,7 @@ android_resources("java_resources") { "java/res/drawable-mdpi/permission_background_sync.png", "java/res/drawable-mdpi/permission_images.png", "java/res/drawable-mdpi/permission_javascript.png", @@ -49,7 +51,7 @@ diff --git a/components/browser_ui/site_settings/android/BUILD.gn b/components/b "java/res/drawable-hdpi/settings_autoplay.png", "java/res/drawable-xhdpi/settings_autoplay.png", "java/res/drawable-xxhdpi/settings_autoplay.png", -@@ -224,6 +226,7 @@ android_resources("java_resources") { +@@ -223,6 +225,7 @@ android_resources("java_resources") { "java/res/drawable-xhdpi/permission_background_sync.png", "java/res/drawable-xhdpi/permission_images.png", "java/res/drawable-xhdpi/permission_javascript.png", @@ -57,7 +59,7 @@ diff --git a/components/browser_ui/site_settings/android/BUILD.gn b/components/b "java/res/drawable-xhdpi/permission_popups.png", "java/res/drawable-xhdpi/permission_protected_media.png", "java/res/drawable-xhdpi/settings_sensors.png", -@@ -232,6 +235,7 @@ android_resources("java_resources") { +@@ -231,6 +234,7 @@ android_resources("java_resources") { "java/res/drawable-xxhdpi/permission_background_sync.png", "java/res/drawable-xxhdpi/permission_images.png", "java/res/drawable-xxhdpi/permission_javascript.png", @@ -65,7 +67,7 @@ diff --git a/components/browser_ui/site_settings/android/BUILD.gn b/components/b "java/res/drawable-xxhdpi/permission_popups.png", "java/res/drawable-xxhdpi/permission_protected_media.png", "java/res/drawable-xxhdpi/settings_sensors.png", -@@ -240,6 +244,7 @@ android_resources("java_resources") { +@@ -239,6 +243,7 @@ android_resources("java_resources") { "java/res/drawable-xxxhdpi/permission_background_sync.png", "java/res/drawable-xxxhdpi/permission_images.png", "java/res/drawable-xxxhdpi/permission_javascript.png", @@ -175,7 +177,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/impl/BromiteJavascriptJITContentSetting.java -@@ -0,0 +1,87 @@ +@@ -0,0 +1,92 @@ +/* + This file is part of Bromite. + @@ -244,6 +246,11 @@ new file mode 100644 + } + + @Override ++ public int getCategoryDescription() { ++ return R.string.settings_site_settings_javascript_jit_description; ++ } ++ ++ @Override + public boolean requiresTriStateContentSetting() { + return false; + } @@ -263,33 +270,54 @@ new file mode 100644 + return value != ContentSettingValues.BLOCK; + } +} -diff --git a/components/browser_ui/strings/android/bromite_content_settings/javascript_jit.grdp b/components/browser_ui/strings/android/bromite_content_settings/javascript_jit.grdp +diff --git a/components/browser_ui/strings/bromite_content_settings/javascript_jit.grdp b/components/browser_ui/strings/bromite_content_settings/javascript_jit.grdp new file mode 100644 --- /dev/null -+++ b/components/browser_ui/strings/android/bromite_content_settings/javascript_jit.grdp -@@ -0,0 +1,18 @@ ++++ b/components/browser_ui/strings/bromite_content_settings/javascript_jit.grdp +@@ -0,0 +1,21 @@ + + -+ ++ + JavaScript JIT + -+ -+ Allow JIT on a specific site. ++ ++ Enable the JIT compiler and WebAssembly support in V8 + -+ -+ Block JIT on a specific site. ++ ++ Allow JIT and WebAssembly on a specific site. + -+ ++ ++ Block JIT and WebAssembly on a specific site. ++ ++ + Allow sites to use just-in-time compilation; more performant but a constant source of security vulnerabilities. + -+ ++ + Block sites from using just-in-time compilation, using only interpreted JavaScript; less performant but more secure against security vulnerabilities. + + +diff --git a/components/content_settings/core/browser/bromite_content_settings/javascript_jit.inc b/components/content_settings/core/browser/bromite_content_settings/javascript_jit.inc +new file mode 100644 +--- /dev/null ++++ b/components/content_settings/core/browser/bromite_content_settings/javascript_jit.inc +@@ -0,0 +1,13 @@ ++ content_settings::WebsiteSettingsRegistry::GetInstance() ++ ->GetMutable(ContentSettingsType::JAVASCRIPT_JIT) ++ ->set_show_into_info_page() ++ .set_desktop_ui() ++ .set_is_renderer_content_setting() ++ .set_title_ui(IDS_JAVASCRIPT_JIT_PERMISSION_TITLE) ++ .set_description_ui(IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_JIT_DESCRIPTION) ++ .set_allowed_ui(IDS_WEBSITE_SETTINGS_CATEGORY_JAVASCRIPT_JIT_ENABLED) ++ .set_blocked_ui(IDS_WEBSITE_SETTINGS_CATEGORY_JAVASCRIPT_JIT_DISABLED) ++ .set_allowed_exceptions_ui(IDS_WEBSITE_SETTINGS_ADD_SITE_DESCRIPTION_JAVASCRIPT_JIT_ALLOW) ++ .set_blocked_exceptions_ui(IDS_WEBSITE_SETTINGS_ADD_SITE_DESCRIPTION_JAVASCRIPT_JIT_BLOCK) ++ .set_mid_sentence_ui(IDS_JAVASCRIPT_JIT_PERMISSION_TITLE); ++ 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 -@@ -518,14 +518,18 @@ void ContentSettingsRegistry::Init() { +@@ -509,7 +509,7 @@ void ContentSettingsRegistry::Init() { ContentSettingsInfo::EXCEPTIONS_ON_SECURE_ORIGINS_ONLY); Register(ContentSettingsType::JAVASCRIPT_JIT, "javascript-jit", @@ -298,17 +326,5 @@ diff --git a/components/content_settings/core/browser/content_settings_registry. /*allowlisted_schemes=*/{}, /*valid_settings=*/{CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK}, WebsiteSettingsInfo::TOP_ORIGIN_ONLY_SCOPE, - WebsiteSettingsRegistry::DESKTOP | - WebsiteSettingsRegistry::PLATFORM_ANDROID, - ContentSettingsInfo::INHERIT_IN_INCOGNITO, -- ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); -+ ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS, -+ /*show_into_info_page*/ true, -+ /*is_renderer_content_setting*/ true, -+ /*permission_type_ui*/ IDS_JAVASCRIPT_JIT_PERMISSION_TITLE, -+ /*permission_type_ui_mid_sentence*/ IDS_JAVASCRIPT_JIT_PERMISSION_TITLE); - - Register(ContentSettingsType::PRIVATE_NETWORK_GUARD, "private-network-guard", - CONTENT_SETTING_ASK, WebsiteSettingsInfo::UNSYNCABLE, -- 2.25.1 diff --git a/build/patches/Revert-the-removal-of-an-option-to-block-autoplay.patch b/build/patches/Revert-the-removal-of-an-option-to-block-autoplay.patch index 0c83f3ae..46dc7fa1 100644 --- a/build/patches/Revert-the-removal-of-an-option-to-block-autoplay.patch +++ b/build/patches/Revert-the-removal-of-an-option-to-block-autoplay.patch @@ -11,24 +11,26 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html .../res/drawable-xhdpi/settings_autoplay.png | Bin 0 -> 551 bytes .../res/drawable-xxhdpi/settings_autoplay.png | Bin 0 -> 792 bytes .../drawable-xxxhdpi/settings_autoplay.png | Bin 0 -> 1064 bytes - .../impl/BromiteAutoplayContentSetting.java | 87 ++++++++++++++++++ - .../bromite_content_settings/autoplay.grdp | 15 +++ - .../core/browser/content_settings_registry.cc | 8 +- + .../impl/BromiteAutoplayContentSetting.java | 92 ++++++++++++++++++ + .../bromite_content_settings/autoplay.grdp | 21 ++++ + .../bromite_content_settings/autoplay.inc | 13 +++ + .../core/browser/content_settings_registry.cc | 2 +- .../core/html/media/autoplay_policy.cc | 14 +++ .../core/html/media/autoplay_policy.h | 4 + - 11 files changed, 131 insertions(+), 2 deletions(-) + 12 files changed, 150 insertions(+), 1 deletion(-) 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 create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xxhdpi/settings_autoplay.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xxxhdpi/settings_autoplay.png create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteAutoplayContentSetting.java - create mode 100644 components/browser_ui/strings/android/bromite_content_settings/autoplay.grdp + create mode 100644 components/browser_ui/strings/bromite_content_settings/autoplay.grdp + create mode 100644 components/content_settings/core/browser/bromite_content_settings/autoplay.inc 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 -@@ -209,6 +209,11 @@ android_resources("java_resources") { +@@ -208,6 +208,11 @@ android_resources("java_resources") { "java/res/drawable-mdpi/ic_volume_up_grey600_24dp.png", "java/res/drawable-mdpi/permission_background_sync.png", "java/res/drawable-mdpi/permission_javascript.png", @@ -152,7 +154,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/impl/BromiteAutoplayContentSetting.java -@@ -0,0 +1,87 @@ +@@ -0,0 +1,92 @@ +/* + This file is part of Bromite. + @@ -221,6 +223,11 @@ new file mode 100644 + } + + @Override ++ public int getCategoryDescription() { ++ return R.string.website_settings_add_site_description_autoplay; ++ } ++ ++ @Override + public boolean requiresTriStateContentSetting() { + return false; + } @@ -240,30 +247,54 @@ new file mode 100644 + return value != ContentSettingValues.BLOCK; + } +} -diff --git a/components/browser_ui/strings/android/bromite_content_settings/autoplay.grdp b/components/browser_ui/strings/android/bromite_content_settings/autoplay.grdp +diff --git a/components/browser_ui/strings/bromite_content_settings/autoplay.grdp b/components/browser_ui/strings/bromite_content_settings/autoplay.grdp new file mode 100644 --- /dev/null -+++ b/components/browser_ui/strings/android/bromite_content_settings/autoplay.grdp -@@ -0,0 +1,15 @@ ++++ b/components/browser_ui/strings/bromite_content_settings/autoplay.grdp +@@ -0,0 +1,21 @@ + + -+ ++ + Autoplay + -+ ++ + Allow autoplay for a specific site. + -+ ++ + Allow sites to automatically play muted videos + -+ ++ + Autoplay disabled + ++ ++ Allowed to autoplay ++ ++ ++ Not allowed to autoplay ++ + +diff --git a/components/content_settings/core/browser/bromite_content_settings/autoplay.inc b/components/content_settings/core/browser/bromite_content_settings/autoplay.inc +new file mode 100644 +--- /dev/null ++++ b/components/content_settings/core/browser/bromite_content_settings/autoplay.inc +@@ -0,0 +1,13 @@ ++ content_settings::WebsiteSettingsRegistry::GetInstance() ++ ->GetMutable(ContentSettingsType::AUTOPLAY) ++ ->set_show_into_info_page() ++ .set_desktop_ui() ++ .set_is_renderer_content_setting() ++ .set_title_ui(IDS_AUTOPLAY_PERMISSION_TITLE) ++ .set_description_ui(IDS_WEBSITE_SETTINGS_ADD_SITE_DESCRIPTION_AUTOPLAY) ++ .set_allowed_ui(IDS_WEBSITE_SETTINGS_CATEGORY_AUTOPLAY_ENABLED) ++ .set_blocked_ui(IDS_WEBSITE_SETTINGS_CATEGORY_AUTOPLAY_DISABLED) ++ .set_allowed_exceptions_ui(IDS_SETTINGS_SITE_SETTINGS_AUTOPLAY_ALLOWED_EXCEPTIONS) ++ .set_blocked_exceptions_ui(IDS_SETTINGS_SITE_SETTINGS_AUTOPLAY_BLOCKED_EXCEPTIONS) ++ .set_mid_sentence_ui(IDS_AUTOPLAY_PERMISSION_TITLE); ++ 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 -@@ -238,14 +238,18 @@ void ContentSettingsRegistry::Init() { +@@ -237,7 +237,7 @@ void ContentSettingsRegistry::Init() { ContentSettingsInfo::INHERIT_IN_INCOGNITO, ContentSettingsInfo::EXCEPTIONS_ON_SECURE_ORIGINS_ONLY); @@ -272,18 +303,6 @@ diff --git a/components/content_settings/core/browser/content_settings_registry. WebsiteSettingsInfo::UNSYNCABLE, /*allowlisted_schemes=*/{}, /*valid_settings=*/{CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK}, WebsiteSettingsInfo::TOP_ORIGIN_ONLY_SCOPE, - WebsiteSettingsRegistry::DESKTOP | - WebsiteSettingsRegistry::PLATFORM_ANDROID, - ContentSettingsInfo::INHERIT_IN_INCOGNITO, -- ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); -+ ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS, -+ /*show_into_info_page*/ false, -+ /*is_renderer_content_setting*/ true, -+ /*permission_type_ui*/ IDS_AUTOPLAY_PERMISSION_TITLE, -+ /*permission_type_ui_mid_sentence*/ IDS_AUTOPLAY_PERMISSION_TITLE); - - Register(ContentSettingsType::SOUND, "sound", CONTENT_SETTING_ALLOW, - WebsiteSettingsInfo::UNSYNCABLE, /*allowlisted_schemes=*/{}, diff --git a/third_party/blink/renderer/core/html/media/autoplay_policy.cc b/third_party/blink/renderer/core/html/media/autoplay_policy.cc --- a/third_party/blink/renderer/core/html/media/autoplay_policy.cc +++ b/third_party/blink/renderer/core/html/media/autoplay_policy.cc diff --git a/build/patches/Site-setting-for-images.patch b/build/patches/Site-setting-for-images.patch index 6f303ba6..c674c53e 100644 --- a/build/patches/Site-setting-for-images.patch +++ b/build/patches/Site-setting-for-images.patch @@ -11,23 +11,25 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html .../res/drawable-xhdpi/permission_images.png | Bin 0 -> 316 bytes .../res/drawable-xxhdpi/permission_images.png | Bin 0 -> 449 bytes .../drawable-xxxhdpi/permission_images.png | Bin 0 -> 532 bytes - .../impl/BromiteImagesContentSetting.java | 87 ++++++++++++++++++ + .../impl/BromiteImagesContentSetting.java | 92 ++++++++++++++++++ .../bromite_content_settings/images.grdp | 23 +++++ - .../core/browser/content_settings_registry.cc | 8 +- + .../bromite_content_settings/images.inc | 7 ++ + .../core/browser/content_settings_registry.cc | 2 +- .../core/browser/content_settings_utils.cc | 8 +- - 10 files changed, 123 insertions(+), 8 deletions(-) + 11 files changed, 130 insertions(+), 7 deletions(-) create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-hdpi/permission_images.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-mdpi/permission_images.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xhdpi/permission_images.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xxhdpi/permission_images.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xxxhdpi/permission_images.png create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteImagesContentSetting.java - create mode 100644 components/browser_ui/strings/android/bromite_content_settings/images.grdp + create mode 100644 components/browser_ui/strings/bromite_content_settings/images.grdp + create mode 100644 components/content_settings/core/browser/bromite_content_settings/images.inc 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 -@@ -201,6 +201,7 @@ android_resources("java_resources") { +@@ -200,6 +200,7 @@ android_resources("java_resources") { sources = [ "java/res/drawable-hdpi/ic_volume_up_grey600_24dp.png", "java/res/drawable-hdpi/permission_background_sync.png", @@ -35,7 +37,7 @@ diff --git a/components/browser_ui/site_settings/android/BUILD.gn b/components/b "java/res/drawable-hdpi/permission_javascript.png", "java/res/drawable-hdpi/permission_popups.png", "java/res/drawable-hdpi/permission_protected_media.png", -@@ -208,6 +209,7 @@ android_resources("java_resources") { +@@ -207,6 +208,7 @@ android_resources("java_resources") { "java/res/drawable-hdpi/web_asset.png", "java/res/drawable-mdpi/ic_volume_up_grey600_24dp.png", "java/res/drawable-mdpi/permission_background_sync.png", @@ -43,7 +45,7 @@ diff --git a/components/browser_ui/site_settings/android/BUILD.gn b/components/b "java/res/drawable-mdpi/permission_javascript.png", "java/res/drawable-hdpi/settings_autoplay.png", "java/res/drawable-xhdpi/settings_autoplay.png", -@@ -220,6 +222,7 @@ android_resources("java_resources") { +@@ -219,6 +221,7 @@ android_resources("java_resources") { "java/res/drawable-mdpi/web_asset.png", "java/res/drawable-xhdpi/ic_volume_up_grey600_24dp.png", "java/res/drawable-xhdpi/permission_background_sync.png", @@ -51,7 +53,7 @@ diff --git a/components/browser_ui/site_settings/android/BUILD.gn b/components/b "java/res/drawable-xhdpi/permission_javascript.png", "java/res/drawable-xhdpi/permission_popups.png", "java/res/drawable-xhdpi/permission_protected_media.png", -@@ -227,6 +230,7 @@ android_resources("java_resources") { +@@ -226,6 +229,7 @@ android_resources("java_resources") { "java/res/drawable-xhdpi/web_asset.png", "java/res/drawable-xxhdpi/ic_volume_up_grey600_24dp.png", "java/res/drawable-xxhdpi/permission_background_sync.png", @@ -59,7 +61,7 @@ diff --git a/components/browser_ui/site_settings/android/BUILD.gn b/components/b "java/res/drawable-xxhdpi/permission_javascript.png", "java/res/drawable-xxhdpi/permission_popups.png", "java/res/drawable-xxhdpi/permission_protected_media.png", -@@ -234,6 +238,7 @@ android_resources("java_resources") { +@@ -233,6 +237,7 @@ android_resources("java_resources") { "java/res/drawable-xxhdpi/web_asset.png", "java/res/drawable-xxxhdpi/ic_volume_up_grey600_24dp.png", "java/res/drawable-xxxhdpi/permission_background_sync.png", @@ -153,7 +155,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/impl/BromiteImagesContentSetting.java -@@ -0,0 +1,87 @@ +@@ -0,0 +1,92 @@ +/* + This file is part of Bromite. + @@ -222,6 +224,11 @@ new file mode 100644 + } + + @Override ++ public int getCategoryDescription() { ++ return 0; ++ } ++ ++ @Override + public boolean requiresTriStateContentSetting() { + return false; + } @@ -241,53 +248,58 @@ new file mode 100644 + return value != ContentSettingValues.BLOCK; + } +} -diff --git a/components/browser_ui/strings/android/bromite_content_settings/images.grdp b/components/browser_ui/strings/android/bromite_content_settings/images.grdp +diff --git a/components/browser_ui/strings/bromite_content_settings/images.grdp b/components/browser_ui/strings/bromite_content_settings/images.grdp new file mode 100644 --- /dev/null -+++ b/components/browser_ui/strings/android/bromite_content_settings/images.grdp ++++ b/components/browser_ui/strings/bromite_content_settings/images.grdp @@ -0,0 +1,23 @@ + + + -+ ++ + Images + -+ -+ images ++ ++ Images + + -+ ++ + Images + -+ ++ + Allow images on websites you specify while blocking them for the rest of the web + -+ ++ + Allow sites to load images + -+ ++ + Disallow sites to load images + + +diff --git a/components/content_settings/core/browser/bromite_content_settings/images.inc b/components/content_settings/core/browser/bromite_content_settings/images.inc +new file mode 100644 +--- /dev/null ++++ b/components/content_settings/core/browser/bromite_content_settings/images.inc +@@ -0,0 +1,7 @@ ++ content_settings::WebsiteSettingsRegistry::GetInstance() ++ ->GetMutable(ContentSettingsType::IMAGES) ++ ->set_show_into_info_page() ++ .set_is_renderer_content_setting() ++ .set_title_ui(IDS_SITE_SETTINGS_TYPE_IMAGES) ++ .set_mid_sentence_ui(IDS_SITE_SETTINGS_TYPE_IMAGES_MID_SENTENCE); ++ 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 -@@ -97,9 +97,13 @@ void ContentSettingsRegistry::Init() { +@@ -96,7 +96,7 @@ void ContentSettingsRegistry::Init() { {kChromeUIScheme, kChromeDevToolsScheme, kExtensionScheme}, /*valid_settings=*/{CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK}, WebsiteSettingsInfo::TOP_ORIGIN_WITH_RESOURCE_EXCEPTIONS_SCOPE, - WebsiteSettingsRegistry::DESKTOP, + WebsiteSettingsRegistry::DESKTOP | WebsiteSettingsRegistry::PLATFORM_ANDROID, ContentSettingsInfo::INHERIT_IN_INCOGNITO, -- ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); -+ ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS, -+ /*show_into_info_page*/ true, -+ /*is_renderer_content_setting*/ true, -+ /*permission_type_ui*/ IDS_SITE_SETTINGS_TYPE_IMAGES, -+ /*permission_type_ui_mid_sentence*/ IDS_SITE_SETTINGS_TYPE_IMAGES_MID_SENTENCE); + ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); - Register(ContentSettingsType::JAVASCRIPT, "javascript", CONTENT_SETTING_ALLOW, - WebsiteSettingsInfo::SYNCABLE, diff --git a/components/content_settings/core/browser/content_settings_utils.cc b/components/content_settings/core/browser/content_settings_utils.cc --- a/components/content_settings/core/browser/content_settings_utils.cc +++ b/components/content_settings/core/browser/content_settings_utils.cc diff --git a/build/patches/Timezone-customization.patch b/build/patches/Timezone-customization.patch index 35dba817..9c94cfd9 100644 --- a/build/patches/Timezone-customization.patch +++ b/build/patches/Timezone-customization.patch @@ -26,28 +26,30 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html .../WebsitePermissionsFetcher.java | 2 + .../WebsitePreferenceBridge.java | 12 ++ .../android/website_preference_bridge.cc | 16 ++ - .../bromite_content_settings/timezone.grdp | 36 ++++ + .../bromite_content_settings/timezone.grdp | 39 ++++ + .../timezone_override.inc | 24 +++ .../browser/content_settings_pref_provider.cc | 16 ++ .../browser/content_settings_pref_provider.h | 4 + - .../core/browser/content_settings_registry.cc | 13 ++ .../core/browser/content_settings_utils.cc | 5 + .../core/browser/host_content_settings_map.cc | 8 + .../core/browser/host_content_settings_map.h | 3 + + .../bromite_content_settings/TIMEZONE.inc | 2 + .../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 + - .../core/common/content_settings_types.h | 3 + .../core/common/pref_names.cc | 3 + .../content_settings/core/common/pref_names.h | 2 + .../renderer/content_settings_agent_impl.cc | 80 ++++++++ .../renderer/content_settings_agent_impl.h | 11 + .../WebLayerSiteSettingsDelegate.java | 3 + - 34 files changed, 664 insertions(+), 6 deletions(-) + 34 files changed, 677 insertions(+), 6 deletions(-) create mode 100755 components/browser_ui/site_settings/android/java/res/layout/time_zone_select_dialog.xml create mode 100755 components/browser_ui/site_settings/android/java/res/layout/timezoneoverride_site_settings_preference.xml create mode 100755 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/TimezoneOverrideSiteSettingsPreference.java - create mode 100644 components/browser_ui/strings/android/bromite_content_settings/timezone.grdp + create mode 100644 components/browser_ui/strings/bromite_content_settings/timezone.grdp + create mode 100644 components/content_settings/core/browser/bromite_content_settings/timezone_override.inc + create mode 100644 components/content_settings/core/common/bromite_content_settings/TIMEZONE.inc 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 --- a/chrome/android/java/src/org/chromium/chrome/browser/site_settings/ChromeSiteSettingsDelegate.java @@ -93,7 +95,7 @@ diff --git a/components/browser_ui/site_settings/android/BUILD.gn b/components/b ] annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ] resources_package = "org.chromium.components.browser_ui.site_settings" -@@ -263,6 +264,8 @@ android_resources("java_resources") { +@@ -262,6 +263,8 @@ android_resources("java_resources") { "java/res/xml/site_settings_preferences.xml", "java/res/xml/site_settings_preferences_with_categories.xml", "java/res/xml/website_preferences.xml", @@ -447,7 +449,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c configureTriStateToggle(triStateToggle, contentType); break; case GlobalToggleLayout.TRI_STATE_COOKIE_TOGGLE: -@@ -1200,6 +1239,12 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -1204,6 +1243,12 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment } BromiteCustomContentSettingImpl.configureGlobalToggles(mCategory, screen); @@ -460,7 +462,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c if (permissionBlockedByOs) { maybeShowOsWarning(screen); -@@ -1355,6 +1400,15 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -1359,6 +1404,15 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment triStateToggle.initialize(contentType, setting, descriptionIds); } @@ -778,7 +780,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c case ContentSettingsType.AR: case ContentSettingsType.CLIPBOARD_READ_WRITE: @@ -212,6 +213,7 @@ public class WebsitePermissionsFetcher { - for (@ContentSettingsType int type = 0; type < ContentSettingsType.NUM_TYPES; type++) { + for (@ContentSettingsType int type = 0; type < ContentSettingsType.NUM_TYPES_BROMITE; type++) { addFetcherForContentSettingsType(queue, type); } + queue.add(new ExceptionInfoFetcher(ContentSettingsType.TIMEZONE_OVERRIDE)); @@ -843,47 +845,79 @@ diff --git a/components/browser_ui/site_settings/android/website_preference_brid + GetHostContentSettingsMap(jbrowser_context_handle)->GetTimezoneOverrideValue(custom_timezone); + return ConvertUTF8ToJavaString(env, custom_timezone); +} -diff --git a/components/browser_ui/strings/android/bromite_content_settings/timezone.grdp b/components/browser_ui/strings/android/bromite_content_settings/timezone.grdp +diff --git a/components/browser_ui/strings/bromite_content_settings/timezone.grdp b/components/browser_ui/strings/bromite_content_settings/timezone.grdp new file mode 100644 --- /dev/null -+++ b/components/browser_ui/strings/android/bromite_content_settings/timezone.grdp -@@ -0,0 +1,36 @@ ++++ b/components/browser_ui/strings/bromite_content_settings/timezone.grdp +@@ -0,0 +1,39 @@ + + -+ ++ ++ Timezone override ++ ++ + Override timezone with a custom or random one, or use the system timezone + -+ ++ + None (use system timezone) + -+ ++ + Random + -+ ++ + System timezone + -+ ++ + Custom timezone + -+ ++ + Specify a custom timezone (default UTC) + -+ ++ + Random (for each page) + -+ ++ + Choose Timezone... + -+ ++ + Choose Timezone + -+ ++ + Select + -+ ++ + Timezone override + + +diff --git a/components/content_settings/core/browser/bromite_content_settings/timezone_override.inc b/components/content_settings/core/browser/bromite_content_settings/timezone_override.inc +new file mode 100644 +--- /dev/null ++++ b/components/content_settings/core/browser/bromite_content_settings/timezone_override.inc +@@ -0,0 +1,24 @@ ++ Register(ContentSettingsType::TIMEZONE_OVERRIDE, "timezone-override", CONTENT_SETTING_ALLOW, ++ WebsiteSettingsInfo::SYNCABLE, ++ /*allowlisted_schemes=*/{}, ++ /*valid_settings=*/{CONTENT_SETTING_ALLOW, // use system time ++ CONTENT_SETTING_ASK, // custom timezone, default UTC ++ CONTENT_SETTING_BLOCK}, // random ++ WebsiteSettingsInfo::TOP_ORIGIN_ONLY_SCOPE, ++ WebsiteSettingsRegistry::ALL_PLATFORMS, ++ ContentSettingsInfo::INHERIT_IN_INCOGNITO, ++ ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); ++ ++ content_settings::WebsiteSettingsRegistry::GetInstance() ++ ->GetMutable(ContentSettingsType::TIMEZONE_OVERRIDE) ++ ->set_show_into_info_page() ++ .set_desktop_ui() ++ .set_is_renderer_content_setting() ++ .set_title_ui(IDS_SITE_SETTINGS_TIMEZONE_OVERRIDE_TITLE) ++ .set_description_ui(IDS_WEBSITE_SETTINGS_TIMEOVERRIDE_INFO) ++ .set_allowed_ui(IDS_WEBSITE_SETTINGS_CATEGORY_TIMEZONE_OVERRIDE_ALLOWED) ++ .set_blocked_ui(IDS_WEBSITE_SETTINGS_CATEGORY_TIMEZONE_OVERRIDE_RANDOM) ++ .set_allowed_exceptions_ui(IDS_WEBSITE_SETTINGS_CATEGORY_TIMEZONE_OVERRIDE_ALLOWED) ++ .set_blocked_exceptions_ui(IDS_WEBSITE_SETTINGS_CATEGORY_TIMEZONE_OVERRIDE_RANDOM) ++ .set_mid_sentence_ui(IDS_SITE_SETTINGS_TIMEZONE_OVERRIDE_TITLE); ++ diff --git a/components/content_settings/core/browser/content_settings_pref_provider.cc b/components/content_settings/core/browser/content_settings_pref_provider.cc --- a/components/content_settings/core/browser/content_settings_pref_provider.cc +++ b/components/content_settings/core/browser/content_settings_pref_provider.cc @@ -943,29 +977,6 @@ diff --git a/components/content_settings/core/browser/content_settings_pref_prov }; } // namespace content_settings -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 -@@ -557,6 +557,19 @@ void ContentSettingsRegistry::Init() { - ContentSettingsInfo::INHERIT_IN_INCOGNITO, - ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); - -+ Register(ContentSettingsType::TIMEZONE_OVERRIDE, "timezone-override", CONTENT_SETTING_ALLOW, -+ WebsiteSettingsInfo::SYNCABLE, -+ /*allowlisted_schemes=*/{}, -+ /*valid_settings=*/{CONTENT_SETTING_ALLOW, // use system time -+ CONTENT_SETTING_ASK, // custom timezone, default UTC -+ CONTENT_SETTING_BLOCK}, // random -+ WebsiteSettingsInfo::TOP_ORIGIN_ONLY_SCOPE, -+ WebsiteSettingsRegistry::PLATFORM_ANDROID, -+ ContentSettingsInfo::INHERIT_IN_INCOGNITO, -+ ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS, -+ /*show_into_info_page*/ false, -+ /*is_renderer_content_setting*/ true); -+ - Register(ContentSettingsType::FEDERATED_IDENTITY_API, "webid-api", - CONTENT_SETTING_ALLOW, WebsiteSettingsInfo::UNSYNCABLE, - /*allowlisted_schemes=*/{}, diff --git a/components/content_settings/core/browser/content_settings_utils.cc b/components/content_settings/core/browser/content_settings_utils.cc --- a/components/content_settings/core/browser/content_settings_utils.cc +++ b/components/content_settings/core/browser/content_settings_utils.cc @@ -1012,6 +1023,13 @@ diff --git a/components/content_settings/core/browser/host_content_settings_map. private: friend class base::RefCountedThreadSafe; friend class content_settings::TestUtils; +diff --git a/components/content_settings/core/common/bromite_content_settings/TIMEZONE.inc b/components/content_settings/core/common/bromite_content_settings/TIMEZONE.inc +new file mode 100644 +--- /dev/null ++++ b/components/content_settings/core/common/bromite_content_settings/TIMEZONE.inc +@@ -0,0 +1,2 @@ ++ // Content setting for timezone customization functionality. ++ TIMEZONE_OVERRIDE, diff --git a/components/content_settings/core/common/content_settings.h b/components/content_settings/core/common/content_settings.h --- a/components/content_settings/core/common/content_settings.h +++ b/components/content_settings/core/common/content_settings.h @@ -1060,19 +1078,6 @@ diff --git a/components/content_settings/core/common/content_settings_mojom_trai static bool Read( content_settings::mojom::RendererContentSettingRulesDataView data, RendererContentSettingRules* out); -diff --git a/components/content_settings/core/common/content_settings_types.h b/components/content_settings/core/common/content_settings_types.h ---- a/components/content_settings/core/common/content_settings_types.h -+++ b/components/content_settings/core/common/content_settings_types.h -@@ -226,6 +226,9 @@ enum class ContentSettingsType : int32_t { - // by the File System Access API. - FILE_SYSTEM_LAST_PICKED_DIRECTORY, - -+ // Content setting for timezone customization functionality. -+ TIMEZONE_OVERRIDE, -+ - // Controls access to the getDisplayMedia API when {preferCurrentTab: true} - // is specified. - // TODO(crbug.com/1150788): Also apply this when getDisplayMedia() is called diff --git a/components/content_settings/core/common/pref_names.cc b/components/content_settings/core/common/pref_names.cc --- a/components/content_settings/core/common/pref_names.cc +++ b/components/content_settings/core/common/pref_names.cc From ab5e89c1049f231fef8f38fa480c3a05c41819e5 Mon Sep 17 00:00:00 2001 From: Carmelo Messina Date: Tue, 20 Jun 2023 12:33:44 +0200 Subject: [PATCH 3/3] final version --- build/bromite_patches_list.txt | 30 +- ...isable-speechSynthesis-getVoices-API.patch | 21 +- ....patch => Add-autoplay-site-setting.patch} | 23 +- .../Content-settings-infrastructure.patch | 186 +++++- build/patches/JIT-site-settings.patch | 49 +- ...tings-for-cookies-javascript-and-ads.patch | 8 +- build/patches/Site-setting-for-images.patch | 49 +- build/patches/Timezone-customization.patch | 602 +++++------------- ...=> Viewport-Protection-Site-Setting.patch} | 3 +- ...g.patch => Viewport-Protection-flag.patch} | 0 ...-utils.patch => bromite-build-utils.patch} | 2 +- 11 files changed, 360 insertions(+), 613 deletions(-) rename build/patches/{Revert-the-removal-of-an-option-to-block-autoplay.patch => Add-autoplay-site-setting.patch} (93%) rename build/patches/{00Viewport-Protection-Site-Setting.patch => Viewport-Protection-Site-Setting.patch} (99%) rename build/patches/{00Viewport-Protection-flag.patch => Viewport-Protection-flag.patch} (100%) rename build/patches/{00bromite-build-utils.patch => bromite-build-utils.patch} (99%) diff --git a/build/bromite_patches_list.txt b/build/bromite_patches_list.txt index f30c26b2..f98057fc 100644 --- a/build/bromite_patches_list.txt +++ b/build/bromite_patches_list.txt @@ -11,14 +11,7 @@ Remove-binary-blob-integrations.patch Remove-SMS-integration.patch Remove-voice-recognition-integration.patch Do-not-compile-QR-code-sharing.patch -Timezone-customization.patch -Revert-the-removal-of-an-option-to-block-autoplay.patch Add-support-for-ISupportHelpAndFeedback.patch -JIT-site-settings.patch -Site-setting-for-images.patch -Content-settings-infrastructure.patch -Add-webGL-site-setting.patch -Add-webRTC-site-settings.patch Switch-to-fstack-protector-strong.patch Enable-fwrapv-in-Clang-for-non-UBSan-builds.patch Bromite-package-name.patch @@ -100,7 +93,6 @@ Reduce-HTTP-headers-in-DoH-requests-to-bare-minimum.patch Revert-flags-remove-disable-pull-to-refresh-effect.patch Use-dummy-DFM-installer.patch Disable-feeds-support-by-default.patch -Show-site-settings-for-cookies-javascript-and-ads.patch Disable-DRM-media-origin-IDs-preprovisioning.patch Disable-smart-selection-by-default.patch Guard-for-user-agent-reduction.patch @@ -214,12 +206,6 @@ eyeo-beta-114.0.5735.53-v1-extension_api.patch 00WIN-ADDTO-Add-flag-to-disable-external-intent-re.patch 00WIN-ADDTO-Restore-Search-Ready-Omnibox-flag.patch 00WIN-ADDTO-Disable-requests-for-single-word-Omni.patch -00WIN-ADDTO-Revert-the-removal-to-block-autoplay.patch -00WIN-ADDTO-JIT-site-settings.patch -00WIN-ADDTO-Timezone-customization.patch -00WIN-ADDTO-Add-webGL-site-setting.patch -00WIN-ADDTO-Add-webRTC-site-settings.patch -00WIN-ADDTO-Content-settings-infrastructure.patch 00WIN-ADDTO-Logcat-crash-reports-UI.patch 00WIN-ADDTO-Add-AllowUserCertificates-flag.patch 00WIN-enable-pdf-plugin.patch @@ -239,8 +225,6 @@ eyeo-beta-114.0.5735.53-v1-extension_api.patch AudioBuffer-AnalyserNode-fp-mitigations.patch 00Disable-Component-Updates.patch 00add-browser-policy.patch -00Viewport-Protection-flag.patch -00Viewport-Protection-Site-Setting.patch 00Always-open-browser-controls-in-new-tab.patch 00Partitioning-all-cookies-by-top-frame-domain.patch 00Disable-FedCm.patch @@ -266,7 +250,6 @@ AudioBuffer-AnalyserNode-fp-mitigations.patch 00Remove-auth-header-upon-cross-origin-redirect.patch 00Clear-CORS-Preflight-Cache-on-clearing-data.patch 00Multi-Screen-Window-Placement-API-fix.patch -00Disable-speechSynthesis-getVoices-API.patch 00Remove-https-connection-from-chrome-discards.patch 00Add-a-flag-to-disable-GamePad-API.patch 00Disable-WebGPU.patch @@ -284,3 +267,16 @@ AudioBuffer-AnalyserNode-fp-mitigations.patch 00TEMP-Enable-MojoDirectSharedMemoryAndroid.patch 00v113-temp-fix-build.patch 00114-temp-disable-find-bad-constructs-external-repo.patch + +bromite-build-utils.patch +Content-settings-infrastructure.patch +Add-autoplay-site-setting.patch +Site-setting-for-images.patch +JIT-site-settings.patch +Add-webGL-site-setting.patch +Add-webRTC-site-settings.patch +Show-site-settings-for-cookies-javascript-and-ads.patch +Viewport-Protection-flag.patch +Viewport-Protection-Site-Setting.patch +Timezone-customization.patch +00Disable-speechSynthesis-getVoices-API.patch \ No newline at end of file diff --git a/build/patches/00Disable-speechSynthesis-getVoices-API.patch b/build/patches/00Disable-speechSynthesis-getVoices-API.patch index deeb98d2..eaf0fb27 100644 --- a/build/patches/00Disable-speechSynthesis-getVoices-API.patch +++ b/build/patches/00Disable-speechSynthesis-getVoices-API.patch @@ -6,20 +6,21 @@ Adds flag disable-speechsynthesis-voice-list to disable SpeechSynthesis.getVoices() call. If not active the user must also set the system timezone override to enable it. +Require: Timezone-customization.patch --- chrome/browser/about_flags.cc | 5 +++++ - .../renderer/content_settings_agent_impl.cc | 11 ++++++++++- + .../renderer/content_settings_agent_impl.cc | 9 ++++++++- .../renderer/content_settings_agent_impl.h | 2 ++ third_party/blink/common/features.cc | 4 ++++ third_party/blink/public/common/features.h | 2 ++ .../platform/web_content_settings_client.h | 2 ++ .../renderer/modules/speech/speech_synthesis.cc | 17 ++++++++++++++--- - 7 files changed, 39 insertions(+), 4 deletions(-) + 7 files changed, 37 insertions(+), 4 deletions(-) diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc -@@ -7221,6 +7221,11 @@ const FeatureEntry kFeatureEntries[] = { +@@ -7217,6 +7217,11 @@ const FeatureEntry kFeatureEntries[] = { flag_descriptions::kFileHandlingIconsDescription, kOsDesktop, FEATURE_VALUE_TYPE(blink::features::kFileHandlingIcons)}, @@ -34,24 +35,22 @@ diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc 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 -@@ -501,6 +501,16 @@ bool ContentSettingsAgentImpl::IsAllowlistedForContentSettings() const { +@@ -496,6 +496,14 @@ bool ContentSettingsAgentImpl::IsAllowlistedForContentSettings() const { return false; } +bool ContentSettingsAgentImpl::IsTimezoneChanged() { + if (!content_setting_rules_) + return false; -+ blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); + // CONTENT_SETTING_ALLOW = use system time -+ return CONTENT_SETTING_ALLOW != GetContentSettingFromRules( -+ content_setting_rules_->timezone_override_rules, -+ url::Origin(frame->GetDocument().GetSecurityOrigin()).GetURL()); ++ return CONTENT_SETTING_ALLOW != GetContentSetting( ++ ContentSettingsType::TIMEZONE_OVERRIDE, CONTENT_SETTING_ALLOW); +} + bool ContentSettingsAgentImpl::UpdateOverrides() { // Evaluate the content setting rules ContentSetting setting = CONTENT_SETTING_ALLOW; -@@ -514,7 +524,6 @@ bool ContentSettingsAgentImpl::UpdateOverrides() { +@@ -506,7 +514,6 @@ bool ContentSettingsAgentImpl::UpdateOverrides() { } return UpdateTimeZoneOverride( setting, content_setting_rules_->timezone_override_value); @@ -62,7 +61,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 -@@ -116,6 +116,8 @@ class ContentSettingsAgentImpl +@@ -117,6 +117,8 @@ class ContentSettingsAgentImpl void SetRendererContentSettingRulesForTest( const RendererContentSettingRules& rules); @@ -100,7 +99,7 @@ diff --git a/third_party/blink/public/common/features.h b/third_party/blink/publ diff --git a/third_party/blink/public/platform/web_content_settings_client.h b/third_party/blink/public/platform/web_content_settings_client.h --- a/third_party/blink/public/platform/web_content_settings_client.h +++ b/third_party/blink/public/platform/web_content_settings_client.h -@@ -123,6 +123,8 @@ class WebContentSettingsClient { +@@ -119,6 +119,8 @@ class WebContentSettingsClient { // frame. virtual bool ShouldAutoupgradeMixedContent() { return true; } diff --git a/build/patches/Revert-the-removal-of-an-option-to-block-autoplay.patch b/build/patches/Add-autoplay-site-setting.patch similarity index 93% rename from build/patches/Revert-the-removal-of-an-option-to-block-autoplay.patch rename to build/patches/Add-autoplay-site-setting.patch index 46dc7fa1..a1ad7c95 100644 --- a/build/patches/Revert-the-removal-of-an-option-to-block-autoplay.patch +++ b/build/patches/Add-autoplay-site-setting.patch @@ -1,11 +1,11 @@ From: uazo Date: Sat, 7 Nov 2020 21:59:18 +0000 -Subject: Revert the removal of an option to block autoplay +Subject: Add autoplay site setting Original License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html +Require: Content-settings-infrastructure.patch --- - .../browser_ui/site_settings/android/BUILD.gn | 5 + .../res/drawable-hdpi/settings_autoplay.png | Bin 0 -> 456 bytes .../res/drawable-mdpi/settings_autoplay.png | Bin 0 -> 296 bytes .../res/drawable-xhdpi/settings_autoplay.png | Bin 0 -> 551 bytes @@ -17,7 +17,7 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html .../core/browser/content_settings_registry.cc | 2 +- .../core/html/media/autoplay_policy.cc | 14 +++ .../core/html/media/autoplay_policy.h | 4 + - 12 files changed, 150 insertions(+), 1 deletion(-) + 11 files changed, 145 insertions(+), 1 deletion(-) 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 @@ -27,21 +27,6 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html create mode 100644 components/browser_ui/strings/bromite_content_settings/autoplay.grdp create mode 100644 components/content_settings/core/browser/bromite_content_settings/autoplay.inc -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 -@@ -208,6 +208,11 @@ android_resources("java_resources") { - "java/res/drawable-mdpi/ic_volume_up_grey600_24dp.png", - "java/res/drawable-mdpi/permission_background_sync.png", - "java/res/drawable-mdpi/permission_javascript.png", -+ "java/res/drawable-hdpi/settings_autoplay.png", -+ "java/res/drawable-xhdpi/settings_autoplay.png", -+ "java/res/drawable-xxhdpi/settings_autoplay.png", -+ "java/res/drawable-mdpi/settings_autoplay.png", -+ "java/res/drawable-xxxhdpi/settings_autoplay.png", - "java/res/drawable-mdpi/permission_popups.png", - "java/res/drawable-mdpi/permission_protected_media.png", - "java/res/drawable-mdpi/settings_sensors.png", diff --git a/components/browser_ui/site_settings/android/java/res/drawable-hdpi/settings_autoplay.png b/components/browser_ui/site_settings/android/java/res/drawable-hdpi/settings_autoplay.png new file mode 100644 index 0000000000000000000000000000000000000000..a8a9265f14cd8445ad1f55845099e60dc3c4edf1 @@ -202,7 +187,7 @@ new file mode 100644 + @Override + public ContentSettingsResources.ResourceItem getResourceItem() { + return new ContentSettingsResources.ResourceItem( -+ /*icon*/ R.drawable.web_asset, ++ /*icon*/ R.drawable.settings_autoplay, + /*title*/ R.string.autoplay_permission_title, + /*defaultEnabledValue*/ getDefaultEnabledValue(), + /*defaultDisabledValue*/ getDefaultDisabledValue(), diff --git a/build/patches/Content-settings-infrastructure.patch b/build/patches/Content-settings-infrastructure.patch index 1d6341e5..546d843d 100644 --- a/build/patches/Content-settings-infrastructure.patch +++ b/build/patches/Content-settings-infrastructure.patch @@ -9,7 +9,9 @@ See BromiteCustomContentSetting_README.md for more information. Original License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html +Require: bromite-build-utils.patch --- + .../ChromeSiteSettingsDelegate.java | 15 + .../installable/installed_webapp_bridge.cc | 2 +- .../settings/privacy_page/privacy_page.html | 1 + .../settings/privacy_page/privacy_page.ts | 44 ++- @@ -24,15 +26,16 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html .../views/page_info/page_info_view_factory.cc | 13 + .../settings_localized_strings_provider.cc | 39 +++ .../ui/webui/settings/site_settings_helper.cc | 33 +- - .../browser_ui/site_settings/android/BUILD.gn | 14 + - .../BromiteCustomContentSetting.java | 128 ++++++++ - .../BromiteCustomContentSettingImpl.java | 284 ++++++++++++++++++ - .../BromiteCustomContentSetting_README.md | 151 ++++++++++ + .../browser_ui/site_settings/android/BUILD.gn | 15 + + .../BromiteCustomContentSetting.java | 139 ++++++++ + .../BromiteCustomContentSettingImpl.java | 307 ++++++++++++++++++ + .../BromiteCustomContentSetting_README.md | 151 +++++++++ .../ContentSettingsResources.java | 14 +- - .../site_settings/SingleCategorySettings.java | 33 +- + .../site_settings/SingleCategorySettings.java | 42 ++- .../site_settings/SingleWebsiteSettings.java | 26 +- - .../site_settings/SiteSettings.java | 7 +- + .../site_settings/SiteSettings.java | 14 +- .../site_settings/SiteSettingsCategory.java | 18 +- + .../site_settings/SiteSettingsDelegate.java | 2 + .../TriStateSiteSettingsPreference.java | 13 +- .../browser_ui/site_settings/Website.java | 6 + .../WebsitePermissionsFetcher.java | 4 +- @@ -44,7 +47,7 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html .../bromite_content_settings/placeholder.txt | 1 + .../core/browser/content_settings_registry.cc | 3 + .../core/browser/content_settings_utils.cc | 12 + - .../core/browser/website_settings_info.h | 35 +++ + .../core/browser/website_settings_info.h | 35 ++ .../core/browser/website_settings_registry.cc | 6 + .../core/browser/website_settings_registry.h | 1 + .../content_settings/core/common/BUILD.gn | 6 + @@ -60,14 +63,15 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html .../renderer/content_settings_agent_impl.h | 5 + .../PageInfoPermissionsController.java | 9 + .../PermissionParamsListBuilder.java | 1 + - .../android/page_info_controller_android.cc | 18 ++ + .../android/page_info_controller_android.cc | 18 + components/page_info/page_info.cc | 22 +- - components/page_info/page_info_ui.cc | 18 ++ + components/page_info/page_info_ui.cc | 18 + components/site_settings_strings.grdp | 1 + .../platform/web_content_settings_client.h | 5 + .../execution_context/execution_context.cc | 16 + .../execution_context/execution_context.h | 5 + - 57 files changed, 1252 insertions(+), 38 deletions(-) + .../WebLayerSiteSettingsDelegate.java | 3 + + 60 files changed, 1320 insertions(+), 41 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 @@ -77,6 +81,38 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html create mode 100644 components/content_settings/core/browser/bromite_content_settings/placeholder.txt create mode 100644 components/content_settings/core/common/bromite_content_settings/placeholder.txt +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 +--- 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 +@@ -46,6 +46,10 @@ import org.chromium.url.GURL; + + import java.util.Set; + ++import android.content.Intent; ++import android.provider.Browser; ++import android.net.Uri; ++ + /** + * A SiteSettingsDelegate instance that contains Chrome-specific Site Settings logic. + */ +@@ -267,6 +271,17 @@ public class ChromeSiteSettingsDelegate implements SiteSettingsDelegate { + return PrivacySandboxBridge.getFirstPartySetOwner(memberOrigin); + } + ++ @Override ++ public void launchHelpAndFeedbackActivity(Activity currentActivity, String url) { ++ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); ++ // Let Chromium know that this intent is from Chromium, so that it does not close the app when ++ // the user presses 'back' button. ++ intent.putExtra(Browser.EXTRA_APPLICATION_ID, currentActivity.getPackageName()); ++ intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true); ++ intent.setPackage(currentActivity.getPackageName()); ++ currentActivity.startActivity(intent); ++ } ++ + @Override + public boolean canLaunchClearBrowsingDataDialog() { + return true; diff --git a/chrome/browser/installable/installed_webapp_bridge.cc b/chrome/browser/installable/installed_webapp_bridge.cc --- a/chrome/browser/installable/installed_webapp_bridge.cc +++ b/chrome/browser/installable/installed_webapp_bridge.cc @@ -579,11 +615,19 @@ diff --git a/components/browser_ui/site_settings/android/BUILD.gn b/components/b } android_library("javatests") { +@@ -182,6 +196,7 @@ robolectric_library("junit") { + } + + android_resources("java_resources") { ++ allow_missing_resources = true + sources = [ + "java/res/drawable-hdpi/ic_volume_up_grey600_24dp.png", + "java/res/drawable-hdpi/permission_background_sync.png", diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSetting.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSetting.java new file mode 100644 --- /dev/null +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/BromiteCustomContentSetting.java -@@ -0,0 +1,128 @@ +@@ -0,0 +1,139 @@ +/* + This file is part of Bromite. + @@ -696,6 +740,17 @@ new file mode 100644 + return null; + } + ++ public void configureGlobalToggles(SiteSettingsCategory category, SingleCategorySettings setting) { ++ } ++ ++ public boolean isHelpAndFeedbackEnabled() { ++ return false; ++ } ++ ++ public String getHelpAndFeedbackActivityUrl() { ++ return ""; ++ } ++ + public boolean requiresTriStateContentSetting() { + return false; + } @@ -716,7 +771,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,284 @@ +@@ -0,0 +1,307 @@ +/* + This file is part of Bromite. + @@ -938,7 +993,30 @@ new file mode 100644 + public static void onActivityCreated(SingleCategorySettings singleCategorySettings) { + } + -+ public static void configureGlobalToggles(SiteSettingsCategory category, PreferenceScreen preferences) { ++ public static void configureGlobalToggles(SiteSettingsCategory category, SingleCategorySettings setting) { ++ for (BromiteCustomContentSetting cs : mItemList) { ++ if (category.getType() == cs.getSiteSettingsCategory()) { ++ cs.configureGlobalToggles(category, setting); ++ } ++ } ++ } ++ ++ public static boolean isHelpAndFeedbackEnabled(SiteSettingsCategory category) { ++ for (BromiteCustomContentSetting cs : mItemList) { ++ if (category.getType() == cs.getSiteSettingsCategory()) { ++ return cs.isHelpAndFeedbackEnabled(); ++ } ++ } ++ return false; ++ } ++ ++ public static String getHelpAndFeedbackActivityUrl(SiteSettingsCategory category) { ++ for (BromiteCustomContentSetting cs : mItemList) { ++ if (category.getType() == cs.getSiteSettingsCategory()) { ++ return cs.getHelpAndFeedbackActivityUrl(); ++ } ++ } ++ return ""; + } + + public static ContentSettingException createCustomException(@ContentSettingsType int type, @@ -1231,7 +1309,29 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c configureGlobalToggles(); if (mCategory.getType() == SiteSettingsCategory.Type.REQUEST_DESKTOP_SITE) { RecordUserAction.record("DesktopSiteContentSetting.SettingsPage.Entered"); -@@ -571,6 +576,11 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -487,7 +492,7 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment + if (queryHasChanged) getInfoForOrigins(); + }); + +- if (getSiteSettingsDelegate().isHelpAndFeedbackEnabled()) { ++ if (getSiteSettingsDelegate().isHelpAndFeedbackEnabled() && BromiteCustomContentSettingImpl.isHelpAndFeedbackEnabled(mCategory)) { + MenuItem help = menu.add( + Menu.NONE, R.id.menu_id_site_settings_help, Menu.NONE, R.string.menu_help); + help.setIcon(TraceEventVectorDrawableCompat.create( +@@ -498,6 +503,12 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (item.getItemId() == R.id.menu_id_site_settings_help) { ++ String url = BromiteCustomContentSettingImpl.getHelpAndFeedbackActivityUrl(mCategory); ++ if (!url.equals("")) { ++ getSiteSettingsDelegate() ++ .launchHelpAndFeedbackActivity(getActivity(), url); ++ return true; ++ } + if (mCategory.getType() == SiteSettingsCategory.Type.PROTECTED_MEDIA) { + getSiteSettingsDelegate().launchProtectedContentHelpAndFeedbackActivity( + getActivity()); +@@ -571,6 +582,11 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment BrowserContextHandle browserContextHandle = getSiteSettingsDelegate().getBrowserContextHandle(); PrefService prefService = UserPrefs.get(browserContextHandle); @@ -1243,7 +1343,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c if (BINARY_TOGGLE_KEY.equals(preference.getKey())) { assert !mCategory.isManaged(); boolean toggleValue = (boolean) newValue; -@@ -787,6 +797,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -787,6 +803,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment : R.string.website_settings_allowed_group_heading_request_desktop_site; break; } @@ -1252,7 +1352,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c assert resource > 0; return getString(resource); } -@@ -908,6 +920,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -908,6 +926,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment default: break; } @@ -1261,16 +1361,17 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c if (allowSpecifyingExceptions) { getPreferenceScreen().addPreference(new AddExceptionPreference(getStyledContext(), ADD_EXCEPTION_KEY, getAddExceptionDialogMessage(), mCategory, this)); -@@ -1081,6 +1095,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -1081,6 +1101,9 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment case GlobalToggleLayout.TRI_STATE_TOGGLE: TriStateSiteSettingsPreference triStateToggle = getPreferenceScreen().findPreference(TRI_STATE_TOGGLE_KEY); ++ if (triStateToggle == null) return true; + Boolean blocked = BromiteCustomContentSettingImpl.considerException(mCategory, triStateToggle.getCheckedSetting()); + if (blocked != null) return (boolean)blocked; return (triStateToggle.getCheckedSetting() == ContentSettingValues.BLOCK); case GlobalToggleLayout.FOUR_STATE_COOKIE_TOGGLE: FourStateCookieSettingsPreference fourStateCookieToggle = -@@ -1158,7 +1174,11 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -1158,7 +1181,11 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment } else if (mCategory.getType() == SiteSettingsCategory.Type.THIRD_PARTY_COOKIES) { infoText.setSummary(R.string.website_settings_third_party_cookies_page_description); } else { @@ -1283,15 +1384,15 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c } // Hide the anti-abuse text preferences, as needed. -@@ -1182,6 +1202,7 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -1182,6 +1209,7 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment screen.removePreference(antiAbuseThingsToConsiderHeader); screen.removePreference(antiAbuseThingsToConsiderSectionOne); } -+ BromiteCustomContentSettingImpl.configureGlobalToggles(mCategory, screen); ++ BromiteCustomContentSettingImpl.configureGlobalToggles(mCategory, this); if (permissionBlockedByOs) { maybeShowOsWarning(screen); -@@ -1335,7 +1356,7 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -1335,7 +1363,7 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment getSiteSettingsDelegate().getBrowserContextHandle(), contentType); int[] descriptionIds = ContentSettingsResources.getTriStateSettingDescriptionIDs(contentType); @@ -1300,7 +1401,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c } private void configureBinaryToggle(ChromeSwitchPreference binaryToggle, int contentType) { -@@ -1439,6 +1460,14 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment +@@ -1439,6 +1467,14 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment @ContentSettingValues Integer value = site.getContentSetting(browserContextHandle, contentSettingsType); @@ -1427,12 +1528,20 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c Preference p = findPreference(prefCategory); int contentType = SiteSettingsCategory.contentSettingsType(prefCategory); // p can be null if the Preference was removed in configurePreferences. -@@ -133,7 +134,7 @@ public class SiteSettings extends SiteSettingsPreferenceFragment - } else if (requiresTriStateSetting) { - p.setSummary(ContentSettingsResources.getCategorySummary(setting)); +@@ -130,10 +131,13 @@ public class SiteSettings extends SiteSettingsPreferenceFragment + p.setSummary(ContentSettingsResources.getDesktopSiteListSummary(checked)); + } else if (Type.AUTO_DARK_WEB_CONTENT == prefCategory) { + p.setSummary(ContentSettingsResources.getAutoDarkWebContentListSummary(checked)); +- } else if (requiresTriStateSetting) { +- p.setSummary(ContentSettingsResources.getCategorySummary(setting)); } else { - p.setSummary(ContentSettingsResources.getCategorySummary(contentType, checked)); -+ p.setSummary(ContentSettingsResources.getCategorySummary(contentType, checked)); // ++ int summary = ContentSettingsResources.getCategorySummary(contentType, setting); ++ if (summary != 0) { ++ p.setSummary(summary); ++ } else { ++ p.setSummary(ContentSettingsResources.getCategorySummary(contentType, checked)); ++ } } if (prefCategory != Type.THIRD_PARTY_COOKIES) { @@ -1508,6 +1617,18 @@ 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/SiteSettingsDelegate.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsDelegate.java +--- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsDelegate.java ++++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsDelegate.java +@@ -163,6 +163,8 @@ public interface SiteSettingsDelegate { + */ + String getFirstPartySetOwner(String memberOrigin); + ++ void launchHelpAndFeedbackActivity(Activity currentActivity, String url); ++ + /** + * Returns whether the current implementation of the delegate is able to launch the Clear + * Browsing Data dialog in Settings. diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/TriStateSiteSettingsPreference.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/TriStateSiteSettingsPreference.java --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/TriStateSiteSettingsPreference.java +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/TriStateSiteSettingsPreference.java @@ -2354,5 +2475,18 @@ diff --git a/third_party/blink/renderer/core/execution_context/execution_context enum ReasonForCallingCanExecuteScripts { kAboutToExecuteScript, +diff --git a/weblayer/browser/java/org/chromium/weblayer_private/settings/WebLayerSiteSettingsDelegate.java b/weblayer/browser/java/org/chromium/weblayer_private/settings/WebLayerSiteSettingsDelegate.java +--- a/weblayer/browser/java/org/chromium/weblayer_private/settings/WebLayerSiteSettingsDelegate.java ++++ b/weblayer/browser/java/org/chromium/weblayer_private/settings/WebLayerSiteSettingsDelegate.java +@@ -155,6 +155,9 @@ public class WebLayerSiteSettingsDelegate + @Override + public void dismissPrivacySandboxSnackbar() {} + ++ @Override ++ public void launchHelpAndFeedbackActivity(Activity currentActivity, String url) {} ++ + @Override + public boolean isFirstPartySetsDataAccessEnabled() { + return false; -- 2.25.1 diff --git a/build/patches/JIT-site-settings.patch b/build/patches/JIT-site-settings.patch index 6fcead8f..8e96a667 100644 --- a/build/patches/JIT-site-settings.patch +++ b/build/patches/JIT-site-settings.patch @@ -11,8 +11,8 @@ Without those features, the RenderProcess would be shared between all eTLD+1. note: needs SitePerProcess and StrictOriginIsolation flags enabled License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html +Require: Content-settings-infrastructure.patch --- - .../browser_ui/site_settings/android/BUILD.gn | 5 + .../permission_javascript_jit.png | Bin 0 -> 433 bytes .../permission_javascript_jit.png | Bin 0 -> 377 bytes .../permission_javascript_jit.png | Bin 0 -> 518 bytes @@ -22,7 +22,7 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html .../javascript_jit.grdp | 21 ++++ .../javascript_jit.inc | 13 +++ .../core/browser/content_settings_registry.cc | 2 +- - 10 files changed, 132 insertions(+), 1 deletion(-) + 9 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-hdpi/permission_javascript_jit.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-mdpi/permission_javascript_jit.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xhdpi/permission_javascript_jit.png @@ -32,49 +32,6 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html create mode 100644 components/browser_ui/strings/bromite_content_settings/javascript_jit.grdp create mode 100644 components/content_settings/core/browser/bromite_content_settings/javascript_jit.inc -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 -@@ -202,6 +202,7 @@ android_resources("java_resources") { - "java/res/drawable-hdpi/permission_background_sync.png", - "java/res/drawable-hdpi/permission_images.png", - "java/res/drawable-hdpi/permission_javascript.png", -+ "java/res/drawable-hdpi/permission_javascript_jit.png", - "java/res/drawable-hdpi/permission_popups.png", - "java/res/drawable-hdpi/permission_protected_media.png", - "java/res/drawable-hdpi/settings_sensors.png", -@@ -210,6 +211,7 @@ android_resources("java_resources") { - "java/res/drawable-mdpi/permission_background_sync.png", - "java/res/drawable-mdpi/permission_images.png", - "java/res/drawable-mdpi/permission_javascript.png", -+ "java/res/drawable-mdpi/permission_javascript_jit.png", - "java/res/drawable-hdpi/settings_autoplay.png", - "java/res/drawable-xhdpi/settings_autoplay.png", - "java/res/drawable-xxhdpi/settings_autoplay.png", -@@ -223,6 +225,7 @@ android_resources("java_resources") { - "java/res/drawable-xhdpi/permission_background_sync.png", - "java/res/drawable-xhdpi/permission_images.png", - "java/res/drawable-xhdpi/permission_javascript.png", -+ "java/res/drawable-xhdpi/permission_javascript_jit.png", - "java/res/drawable-xhdpi/permission_popups.png", - "java/res/drawable-xhdpi/permission_protected_media.png", - "java/res/drawable-xhdpi/settings_sensors.png", -@@ -231,6 +234,7 @@ android_resources("java_resources") { - "java/res/drawable-xxhdpi/permission_background_sync.png", - "java/res/drawable-xxhdpi/permission_images.png", - "java/res/drawable-xxhdpi/permission_javascript.png", -+ "java/res/drawable-xxhdpi/permission_javascript_jit.png", - "java/res/drawable-xxhdpi/permission_popups.png", - "java/res/drawable-xxhdpi/permission_protected_media.png", - "java/res/drawable-xxhdpi/settings_sensors.png", -@@ -239,6 +243,7 @@ android_resources("java_resources") { - "java/res/drawable-xxxhdpi/permission_background_sync.png", - "java/res/drawable-xxxhdpi/permission_images.png", - "java/res/drawable-xxxhdpi/permission_javascript.png", -+ "java/res/drawable-xxxhdpi/permission_javascript_jit.png", - "java/res/drawable-xxxhdpi/permission_popups.png", - "java/res/drawable-xxxhdpi/permission_protected_media.png", - "java/res/drawable-xxxhdpi/settings_sensors.png", diff --git a/components/browser_ui/site_settings/android/java/res/drawable-hdpi/permission_javascript_jit.png b/components/browser_ui/site_settings/android/java/res/drawable-hdpi/permission_javascript_jit.png new file mode 100644 index 0000000000000000000000000000000000000000..88f0ec11d6b186923ace473eb426f80341adc5f1 @@ -225,7 +182,7 @@ new file mode 100644 + @Override + public ContentSettingsResources.ResourceItem getResourceItem() { + return new ContentSettingsResources.ResourceItem( -+ /*icon*/ R.drawable.web_asset, ++ /*icon*/ R.drawable.permission_javascript_jit, + /*title*/ R.string.javascript_jit_permission_title, + /*defaultEnabledValue*/ getDefaultEnabledValue(), + /*defaultDisabledValue*/ getDefaultDisabledValue(), diff --git a/build/patches/Show-site-settings-for-cookies-javascript-and-ads.patch b/build/patches/Show-site-settings-for-cookies-javascript-and-ads.patch index ff04be6e..5d2ed815 100644 --- a/build/patches/Show-site-settings-for-cookies-javascript-and-ads.patch +++ b/build/patches/Show-site-settings-for-cookies-javascript-and-ads.patch @@ -13,7 +13,7 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html 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 -@@ -517,6 +517,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment +@@ -515,6 +515,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment setUpSoundPreference(preference); } else if (type == ContentSettingsType.JAVASCRIPT) { setUpJavascriptPreference(preference); @@ -22,7 +22,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c } else if (type == ContentSettingsType.GEOLOCATION) { setUpLocationPreference(preference); } else if (type == ContentSettingsType.NOTIFICATIONS) { -@@ -876,16 +878,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment +@@ -874,16 +876,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment private void setUpAdsInformationalBanner() { // Add the informational banner which shows at the top of the UI if ad blocking is // activated on this site. @@ -39,7 +39,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c } private SiteSettingsCategory getWarningCategory() { -@@ -1057,17 +1051,35 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment +@@ -1055,17 +1049,35 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment @Nullable Integer currentValue = mSite.getContentSetting(browserContextHandle, ContentSettingsType.JAVASCRIPT); @@ -81,7 +81,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c /** * Updates the ads list preference based on whether the site is a candidate for blocking. This * has some custom behavior. -@@ -1083,22 +1095,10 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment +@@ -1081,22 +1093,10 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment setupContentSettingsPreference(preference, null, false); return; } diff --git a/build/patches/Site-setting-for-images.patch b/build/patches/Site-setting-for-images.patch index c674c53e..87f894d2 100644 --- a/build/patches/Site-setting-for-images.patch +++ b/build/patches/Site-setting-for-images.patch @@ -4,8 +4,8 @@ Subject: Site setting for images Original License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html +Require: Content-settings-infrastructure.patch --- - .../browser_ui/site_settings/android/BUILD.gn | 5 + .../res/drawable-hdpi/permission_images.png | Bin 0 -> 257 bytes .../res/drawable-mdpi/permission_images.png | Bin 0 -> 186 bytes .../res/drawable-xhdpi/permission_images.png | Bin 0 -> 316 bytes @@ -16,7 +16,7 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html .../bromite_content_settings/images.inc | 7 ++ .../core/browser/content_settings_registry.cc | 2 +- .../core/browser/content_settings_utils.cc | 8 +- - 11 files changed, 130 insertions(+), 7 deletions(-) + 10 files changed, 125 insertions(+), 7 deletions(-) create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-hdpi/permission_images.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-mdpi/permission_images.png create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xhdpi/permission_images.png @@ -26,49 +26,6 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html create mode 100644 components/browser_ui/strings/bromite_content_settings/images.grdp create mode 100644 components/content_settings/core/browser/bromite_content_settings/images.inc -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 -@@ -200,6 +200,7 @@ android_resources("java_resources") { - sources = [ - "java/res/drawable-hdpi/ic_volume_up_grey600_24dp.png", - "java/res/drawable-hdpi/permission_background_sync.png", -+ "java/res/drawable-hdpi/permission_images.png", - "java/res/drawable-hdpi/permission_javascript.png", - "java/res/drawable-hdpi/permission_popups.png", - "java/res/drawable-hdpi/permission_protected_media.png", -@@ -207,6 +208,7 @@ android_resources("java_resources") { - "java/res/drawable-hdpi/web_asset.png", - "java/res/drawable-mdpi/ic_volume_up_grey600_24dp.png", - "java/res/drawable-mdpi/permission_background_sync.png", -+ "java/res/drawable-mdpi/permission_images.png", - "java/res/drawable-mdpi/permission_javascript.png", - "java/res/drawable-hdpi/settings_autoplay.png", - "java/res/drawable-xhdpi/settings_autoplay.png", -@@ -219,6 +221,7 @@ android_resources("java_resources") { - "java/res/drawable-mdpi/web_asset.png", - "java/res/drawable-xhdpi/ic_volume_up_grey600_24dp.png", - "java/res/drawable-xhdpi/permission_background_sync.png", -+ "java/res/drawable-xhdpi/permission_images.png", - "java/res/drawable-xhdpi/permission_javascript.png", - "java/res/drawable-xhdpi/permission_popups.png", - "java/res/drawable-xhdpi/permission_protected_media.png", -@@ -226,6 +229,7 @@ android_resources("java_resources") { - "java/res/drawable-xhdpi/web_asset.png", - "java/res/drawable-xxhdpi/ic_volume_up_grey600_24dp.png", - "java/res/drawable-xxhdpi/permission_background_sync.png", -+ "java/res/drawable-xxhdpi/permission_images.png", - "java/res/drawable-xxhdpi/permission_javascript.png", - "java/res/drawable-xxhdpi/permission_popups.png", - "java/res/drawable-xxhdpi/permission_protected_media.png", -@@ -233,6 +237,7 @@ android_resources("java_resources") { - "java/res/drawable-xxhdpi/web_asset.png", - "java/res/drawable-xxxhdpi/ic_volume_up_grey600_24dp.png", - "java/res/drawable-xxxhdpi/permission_background_sync.png", -+ "java/res/drawable-xxxhdpi/permission_images.png", - "java/res/drawable-xxxhdpi/permission_javascript.png", - "java/res/drawable-xxxhdpi/permission_popups.png", - "java/res/drawable-xxxhdpi/permission_protected_media.png", diff --git a/components/browser_ui/site_settings/android/java/res/drawable-hdpi/permission_images.png b/components/browser_ui/site_settings/android/java/res/drawable-hdpi/permission_images.png new file mode 100644 index 0000000000000000000000000000000000000000..cafee5acf2299e534676a15fb029192e066551c9 @@ -203,7 +160,7 @@ new file mode 100644 + @Override + public ContentSettingsResources.ResourceItem getResourceItem() { + return new ContentSettingsResources.ResourceItem( -+ /*icon*/ R.drawable.web_asset, ++ /*icon*/ R.drawable.permission_images, + /*title*/ R.string.images_permission_title, + /*defaultEnabledValue*/ getDefaultEnabledValue(), + /*defaultDisabledValue*/ getDefaultDisabledValue(), diff --git a/build/patches/Timezone-customization.patch b/build/patches/Timezone-customization.patch index 9c94cfd9..798e86d4 100644 --- a/build/patches/Timezone-customization.patch +++ b/build/patches/Timezone-customization.patch @@ -8,23 +8,14 @@ See also: https://github.com/bromite/bromite/wiki/TimezoneOverride Original License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html +Require: Content-settings-infrastructure.patch --- - .../ChromeSiteSettingsDelegate.java | 16 ++ .../browser_ui/site_settings/android/BUILD.gn | 3 + .../res/layout/time_zone_select_dialog.xml | 36 ++++ ...ezoneoverride_site_settings_preference.xml | 68 ++++++ - .../res/xml/site_settings_preferences.xml | 4 + - .../java/res/xml/website_preferences.xml | 10 + - .../ContentSettingsResources.java | 28 +++ - .../site_settings/SingleCategorySettings.java | 60 +++++- - .../site_settings/SingleWebsiteSettings.java | 2 + - .../site_settings/SiteSettings.java | 2 +- - .../site_settings/SiteSettingsCategory.java | 7 +- - .../site_settings/SiteSettingsDelegate.java | 2 + ...imezoneOverrideSiteSettingsPreference.java | 194 ++++++++++++++++++ - .../browser_ui/site_settings/Website.java | 11 + - .../WebsitePermissionsFetcher.java | 2 + - .../WebsitePreferenceBridge.java | 12 ++ + .../WebsitePreferenceBridge.java | 10 + + ...BromiteTimezoneOverrideContentSetting.java | 146 +++++++++++++ .../android/website_preference_bridge.cc | 16 ++ .../bromite_content_settings/timezone.grdp | 39 ++++ .../timezone_override.inc | 24 +++ @@ -42,48 +33,15 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html .../content_settings/core/common/pref_names.h | 2 + .../renderer/content_settings_agent_impl.cc | 80 ++++++++ .../renderer/content_settings_agent_impl.h | 11 + - .../WebLayerSiteSettingsDelegate.java | 3 + - 34 files changed, 677 insertions(+), 6 deletions(-) + 23 files changed, 679 insertions(+), 1 deletion(-) create mode 100755 components/browser_ui/site_settings/android/java/res/layout/time_zone_select_dialog.xml create mode 100755 components/browser_ui/site_settings/android/java/res/layout/timezoneoverride_site_settings_preference.xml create mode 100755 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/TimezoneOverrideSiteSettingsPreference.java + create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteTimezoneOverrideContentSetting.java create mode 100644 components/browser_ui/strings/bromite_content_settings/timezone.grdp create mode 100644 components/content_settings/core/browser/bromite_content_settings/timezone_override.inc create mode 100644 components/content_settings/core/common/bromite_content_settings/TIMEZONE.inc -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 ---- 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 -@@ -46,6 +46,10 @@ import org.chromium.url.GURL; - - import java.util.Set; - -+import android.content.Intent; -+import android.provider.Browser; -+import android.net.Uri; -+ - /** - * A SiteSettingsDelegate instance that contains Chrome-specific Site Settings logic. - */ -@@ -267,6 +271,18 @@ public class ChromeSiteSettingsDelegate implements SiteSettingsDelegate { - return PrivacySandboxBridge.getFirstPartySetOwner(memberOrigin); - } - -+ // open wiki page for documentation about the timezone override feature -+ @Override -+ public void launchTimeZoneOverrideHelpAndFeedbackActivity(Activity currentActivity) { -+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/bromite/bromite/wiki/TimezoneOverride")); -+ // Let Chromium know that this intent is from Chromium, so that it does not close the app when -+ // the user presses 'back' button. -+ intent.putExtra(Browser.EXTRA_APPLICATION_ID, currentActivity.getPackageName()); -+ intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true); -+ intent.setPackage(currentActivity.getPackageName()); -+ currentActivity.startActivity(intent); -+ } -+ - @Override - public boolean canLaunchClearBrowsingDataDialog() { - return true; 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 @@ -95,7 +53,7 @@ diff --git a/components/browser_ui/site_settings/android/BUILD.gn b/components/b ] annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ] resources_package = "org.chromium.components.browser_ui.site_settings" -@@ -262,6 +263,8 @@ android_resources("java_resources") { +@@ -263,6 +264,8 @@ android_resources("java_resources") { "java/res/xml/site_settings_preferences.xml", "java/res/xml/site_settings_preferences_with_categories.xml", "java/res/xml/website_preferences.xml", @@ -219,335 +177,6 @@ new file mode 100755 + app:verticalInset="0dp" /> + + -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 -@@ -47,6 +47,10 @@ Also add new settings to site_settings_preferences_with_categories.xml! - -+ -+ - - - -+ -+ -+ -+ - - - -+ -+ -+ - - . ++*/ ++ ++package org.chromium.components.browser_ui.site_settings.impl; ++ ++import org.chromium.components.browser_ui.site_settings.R; ++ ++import org.chromium.components.browser_ui.site_settings.BromiteCustomContentSetting; ++import org.chromium.components.browser_ui.site_settings.ContentSettingsResources; ++import org.chromium.components.browser_ui.site_settings.SingleCategorySettings; ++import org.chromium.components.browser_ui.site_settings.SiteSettingsCategory; ++import org.chromium.components.browser_ui.site_settings.TimezoneOverrideSiteSettingsPreference; ++import org.chromium.components.browser_ui.site_settings.WebsitePreferenceBridge; ++import org.chromium.components.content_settings.ContentSettingValues; ++import org.chromium.components.content_settings.ContentSettingsType; ++import org.chromium.content_public.browser.BrowserContextHandle; ++ ++import android.view.View; ++import androidx.annotation.Nullable; ++import androidx.preference.Preference; ++import androidx.preference.PreferenceScreen; ++ ++import java.util.ArrayList; ++ ++public class BromiteTimezoneOverrideContentSetting extends BromiteCustomContentSetting { ++ private static final String TIMEOVERRIDE_STATE_TOGGLE_KEY = "timeoverride_state_toggle"; ++ ++ public BromiteTimezoneOverrideContentSetting() { ++ super(/*contentSettingsType*/ ContentSettingsType.TIMEZONE_OVERRIDE, ++ /*defaultEnabledValue*/ ContentSettingValues.ALLOW, ++ /*defaultDisabledValue*/ ContentSettingValues.BLOCK, ++ /*allowException*/ true, ++ /*preferenceKey*/ "timezone_override", ++ /*profilePrefKey*/ "timezone_override_permission_list"); ++ } ++ ++ @Override ++ public ContentSettingsResources.ResourceItem getResourceItem() { ++ return new ContentSettingsResources.ResourceItem( ++ /*icon*/ R.drawable.web_asset, ++ /*title*/ R.string.timezone_override_permission_title, ++ /*defaultEnabledValue*/ getDefaultEnabledValue(), ++ /*defaultDisabledValue*/ getDefaultDisabledValue(), ++ /*enabledSummary*/ R.string.website_settings_category_timezone_override_custom, ++ /*disabledSummary*/ R.string.website_settings_category_timezone_override_random); ++ } ++ ++ @Override ++ public int getCategorySummary(@Nullable @ContentSettingValues int value) { ++ switch (value) { ++ case ContentSettingValues.ALLOW: ++ return R.string.website_settings_category_timezone_override_allowed; ++ case ContentSettingValues.ASK: ++ return R.string.website_settings_category_timezone_override_custom; ++ case ContentSettingValues.BLOCK: ++ return R.string.website_settings_category_timezone_override_random; ++ default: ++ return 0; ++ } ++ } ++ ++ @Override ++ public int[] getTriStateSettingDescriptionIDs() { ++ int[] descriptionIDs = { ++ R.string.website_settings_category_timezone_override_allowed, // ALLOWED ++ R.string.website_settings_category_timezone_override_custom, // ASK ++ R.string.website_settings_category_timezone_override_random}; // BLOCKED ++ return descriptionIDs; ++ } ++ ++ @Override ++ public int getCategoryDescription() { ++ return R.string.website_settings_timeoverride_info; ++ } ++ ++ @Override ++ public boolean requiresTriStateContentSetting() { ++ return true; ++ } ++ ++ @Override ++ public boolean showOnlyDescriptions() { ++ return true; ++ } ++ ++ @Override ++ public int getAddExceptionDialogMessage() { ++ return R.string.website_settings_category_timezone_override_allowed; ++ } ++ ++ @Override ++ public @Nullable Boolean considerException(SiteSettingsCategory category, @ContentSettingValues int value) { ++ return value != ContentSettingValues.ALLOW; ++ } ++ ++ @Override ++ public boolean isOnBlockList(@ContentSettingValues Integer contentSetting) { ++ return ContentSettingValues.ALLOW != contentSetting; ++ } ++ ++ @Override ++ public boolean isHelpAndFeedbackEnabled() { ++ return true; ++ } ++ ++ @Override ++ public String getHelpAndFeedbackActivityUrl() { ++ return "https://github.com/bromite/bromite/wiki/TimezoneOverride"; ++ } ++ ++ @Override ++ public void configureGlobalToggles(SiteSettingsCategory category, SingleCategorySettings setting) { ++ BrowserContextHandle browserContext = setting.getSiteSettingsDelegate().getBrowserContextHandle(); ++ PreferenceScreen screen = setting.getPreferenceScreen(); ++ ++ Preference triStateToggle = screen.findPreference( ++ SingleCategorySettings.TRI_STATE_TOGGLE_KEY); ++ int order = triStateToggle.getOrder(); ++ screen.removePreference(triStateToggle); ++ ++ TimezoneOverrideSiteSettingsPreference timeOverrideStatePreference = ++ new TimezoneOverrideSiteSettingsPreference(setting.getContext(), null); ++ screen.addPreference(timeOverrideStatePreference); ++ timeOverrideStatePreference.setOrder(order); ++ ++ timeOverrideStatePreference.setOnPreferenceChangeListener(setting); ++ @ContentSettingValues ++ int value = WebsitePreferenceBridge.getDefaultContentSetting( ++ browserContext, ContentSettingsType.TIMEZONE_OVERRIDE); ++ timeOverrideStatePreference.initialize(value, browserContext); ++ } ++} diff --git a/components/browser_ui/site_settings/android/website_preference_bridge.cc b/components/browser_ui/site_settings/android/website_preference_bridge.cc --- a/components/browser_ui/site_settings/android/website_preference_bridge.cc +++ b/components/browser_ui/site_settings/android/website_preference_bridge.cc @@ -980,7 +711,7 @@ diff --git a/components/content_settings/core/browser/content_settings_pref_prov diff --git a/components/content_settings/core/browser/content_settings_utils.cc b/components/content_settings/core/browser/content_settings_utils.cc --- a/components/content_settings/core/browser/content_settings_utils.cc +++ b/components/content_settings/core/browser/content_settings_utils.cc -@@ -165,6 +165,11 @@ void GetRendererContentSettingRules(const HostContentSettingsMap* map, +@@ -161,6 +161,11 @@ void GetRendererContentSettingRules(const HostContentSettingsMap* map, &(rules->script_rules)); map->GetSettingsForOneType(ContentSettingsType::POPUPS, &(rules->popup_redirect_rules)); @@ -1233,18 +964,5 @@ diff --git a/components/content_settings/renderer/content_settings_agent_impl.h }; } // namespace content_settings -diff --git a/weblayer/browser/java/org/chromium/weblayer_private/settings/WebLayerSiteSettingsDelegate.java b/weblayer/browser/java/org/chromium/weblayer_private/settings/WebLayerSiteSettingsDelegate.java ---- a/weblayer/browser/java/org/chromium/weblayer_private/settings/WebLayerSiteSettingsDelegate.java -+++ b/weblayer/browser/java/org/chromium/weblayer_private/settings/WebLayerSiteSettingsDelegate.java -@@ -155,6 +155,9 @@ public class WebLayerSiteSettingsDelegate - @Override - public void dismissPrivacySandboxSnackbar() {} - -+ @Override -+ public void launchTimeZoneOverrideHelpAndFeedbackActivity(Activity currentActivity) {} -+ - @Override - public boolean isFirstPartySetsDataAccessEnabled() { - return false; -- 2.25.1 diff --git a/build/patches/00Viewport-Protection-Site-Setting.patch b/build/patches/Viewport-Protection-Site-Setting.patch similarity index 99% rename from build/patches/00Viewport-Protection-Site-Setting.patch rename to build/patches/Viewport-Protection-Site-Setting.patch index d183cad0..9ed1060c 100644 --- a/build/patches/00Viewport-Protection-Site-Setting.patch +++ b/build/patches/Viewport-Protection-Site-Setting.patch @@ -1,7 +1,8 @@ -From: Your Name +From: uazo Date: Fri, 16 Jun 2023 15:56:35 +0000 Subject: Viewport Protection Site Setting +Require: Content-settings-infrastructure.patch --- .../impl/BromiteViewportContentSetting.java | 93 +++++++++++++++++++ .../bromite_content_settings/viewport.grdp | 27 ++++++ diff --git a/build/patches/00Viewport-Protection-flag.patch b/build/patches/Viewport-Protection-flag.patch similarity index 100% rename from build/patches/00Viewport-Protection-flag.patch rename to build/patches/Viewport-Protection-flag.patch diff --git a/build/patches/00bromite-build-utils.patch b/build/patches/bromite-build-utils.patch similarity index 99% rename from build/patches/00bromite-build-utils.patch rename to build/patches/bromite-build-utils.patch index 3111800d..e5d944ab 100644 --- a/build/patches/00bromite-build-utils.patch +++ b/build/patches/bromite-build-utils.patch @@ -1,4 +1,4 @@ -From: Your Name +From: uazo Date: Fri, 9 Jun 2023 15:11:46 +0000 Subject: bromite build utils