Skip to content

Instantly share code, notes, and snippets.

@luke-jr
Created March 2, 2025 02:34
Show Gist options
  • Save luke-jr/8d534ab66057e51f23d21ebff2b75f63 to your computer and use it in GitHub Desktop.
Save luke-jr/8d534ab66057e51f23d21ebff2b75f63 to your computer and use it in GitHub Desktop.
Chromium patch to add a quick toggle to the page info popup for JAVASCRIPT_OPTIMIZER
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
index 7fb6575d7f..d85d189a8c 100644
--- a/chrome/browser/ui/views/page_info/page_info_view_factory.cc
+++ b/chrome/browser/ui/views/page_info/page_info_view_factory.cc
@@ -294,6 +294,7 @@ const ui::ImageModel PageInfoViewFactory::GetPermissionIcon(
break;
case ContentSettingsType::JAVASCRIPT:
case ContentSettingsType::JAVASCRIPT_JIT:
+ case ContentSettingsType::JAVASCRIPT_OPTIMIZER:
icon = show_blocked_badge ? &vector_icons::kCodeOffChromeRefreshIcon
: &vector_icons::kCodeChromeRefreshIcon;
break;
@@ -460,6 +461,7 @@ const ui::ImageModel PageInfoViewFactory::GetPermissionIcon(
break;
case ContentSettingsType::JAVASCRIPT:
case ContentSettingsType::JAVASCRIPT_JIT:
+ case ContentSettingsType::JAVASCRIPT_OPTIMIZER:
icon = &vector_icons::kCodeIcon;
break;
case ContentSettingsType::POPUPS:
diff --git a/components/page_info/page_info.cc b/components/page_info/page_info.cc
index d2a6440f62..389f7a8d30 100644
--- a/components/page_info/page_info.cc
+++ b/components/page_info/page_info.cc
@@ -106,6 +106,7 @@ ContentSettingsType kPermissionType[] = {
ContentSettingsType::SENSORS,
ContentSettingsType::NOTIFICATIONS,
ContentSettingsType::JAVASCRIPT,
ContentSettingsType::JAVASCRIPT_JIT,
+ ContentSettingsType::JAVASCRIPT_OPTIMIZER,
#if !BUILDFLAG(IS_ANDROID)
ContentSettingsType::IMAGES,
@@ -1278,7 +1279,7 @@ bool PageInfo::ShouldShowPermission(
return false;
}
- if (info.type == ContentSettingsType::JAVASCRIPT_JIT) {
+ if (info.type == ContentSettingsType::JAVASCRIPT_JIT || info.type == ContentSettingsType::JAVASCRIPT_OPTIMIZER) {
return true;
}
diff --git a/components/page_info/page_info_ui.cc b/components/page_info/page_info_ui.cc
index 5e7f17ebe2..02c537cfc2 100644
--- a/components/page_info/page_info_ui.cc
+++ b/components/page_info/page_info_ui.cc
@@ -150,6 +150,8 @@ base::span<const PageInfoUI::PermissionUIInfo> 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},
+ {ContentSettingsType::JAVASCRIPT_OPTIMIZER, IDS_SITE_SETTINGS_TYPE_JAVASCRIPT_OPTIMIZER,
+ IDS_SITE_SETTINGS_TYPE_JAVASCRIPT_OPTIMIZER},
{ContentSettingsType::POPUPS, IDS_SITE_SETTINGS_TYPE_POPUPS_REDIRECTS,
diff --git a/components/site_settings_strings.grdp b/components/site_settings_strings.grdp
index 0d46161d58..20d46eaa2d 100644
--- a/components/site_settings_strings.grdp
+++ b/components/site_settings_strings.grdp
@@ -112,6 +112,12 @@
<message name="IDS_SITE_SETTINGS_TYPE_JAVASCRIPT_MID_SENTENCE" desc="The label used for JavaScript site settings controls when used mid-sentence.">
javascript
</message>
+ <message name="IDS_SITE_SETTINGS_TYPE_JAVASCRIPT_JIT" desc="The label used for JavaScript JIT site settings controls.">
+ JavaScript JIT
+ </message>
+ <message name="IDS_SITE_SETTINGS_TYPE_JAVASCRIPT_JIT_MID_SENTENCE" desc="The label used for JavaScript JIT site settings controls when used mid-sentence.">
+ javascript JIT
+ </message>
<message name="IDS_SITE_SETTINGS_TYPE_JAVASCRIPT_OPTIMIZER" desc="The label for the JavaScript optimizer site settings controls.">
V8 optimizer
</message>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment