From d86e096dc0f09633756375ab0e765dc2db7c4cc9 Mon Sep 17 00:00:00 2001 From: Carmelo Messina Date: Wed, 23 Feb 2022 17:53:29 +0100 Subject: [PATCH] Implement jit toggle patch --- ...inIsolation-and-SitePerProcess-flags.patch | 65 +++ .../Site-setting-for-javascript-jit.patch | 475 ++++++++++++++++++ 2 files changed, 540 insertions(+) create mode 100644 build/patches/Enable-StrictOriginIsolation-and-SitePerProcess-flags.patch create mode 100644 build/patches/Site-setting-for-javascript-jit.patch diff --git a/build/patches/Enable-StrictOriginIsolation-and-SitePerProcess-flags.patch b/build/patches/Enable-StrictOriginIsolation-and-SitePerProcess-flags.patch new file mode 100644 index 00000000..4bace89f --- /dev/null +++ b/build/patches/Enable-StrictOriginIsolation-and-SitePerProcess-flags.patch @@ -0,0 +1,65 @@ +From: uazo +Date: Sat, 29 Jan 2022 15:25:19 +0000 +Subject: Enable StrictOriginIsolation and SitePerProcess + +--- + chrome/browser/chrome_content_browser_client.cc | 4 ++-- + components/site_isolation/site_isolation_policy.cc | 2 ++ + content/public/common/content_features.cc | 2 +- + 3 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc +--- a/chrome/browser/chrome_content_browser_client.cc ++++ b/chrome/browser/chrome_content_browser_client.cc +@@ -1271,7 +1271,7 @@ void ChromeContentBrowserClient::RegisterLocalStatePrefs( + registry->RegisterFilePathPref(prefs::kDiskCacheDir, base::FilePath()); + registry->RegisterIntegerPref(prefs::kDiskCacheSize, 0); + registry->RegisterStringPref(prefs::kIsolateOrigins, std::string()); +- registry->RegisterBooleanPref(prefs::kSitePerProcess, false); ++ registry->RegisterBooleanPref(prefs::kSitePerProcess, true); + registry->RegisterBooleanPref(prefs::kTabFreezingEnabled, true); + } + +@@ -1284,7 +1284,7 @@ void ChromeContentBrowserClient::RegisterProfilePrefs( + // user policy in addition to the same named ones in Local State (which are + // used for mapping the command-line flags). + registry->RegisterStringPref(prefs::kIsolateOrigins, std::string()); +- registry->RegisterBooleanPref(prefs::kSitePerProcess, false); ++ registry->RegisterBooleanPref(prefs::kSitePerProcess, true); + registry->RegisterListPref( + site_isolation::prefs::kUserTriggeredIsolatedOrigins); + registry->RegisterDictionaryPref( +diff --git a/components/site_isolation/site_isolation_policy.cc b/components/site_isolation/site_isolation_policy.cc +--- a/components/site_isolation/site_isolation_policy.cc ++++ b/components/site_isolation/site_isolation_policy.cc +@@ -85,6 +85,7 @@ bool SiteIsolationPolicy::IsIsolationForOAuthSitesEnabled() { + + // static + bool SiteIsolationPolicy::IsEnterprisePolicyApplicable() { ++ if ((true)) return true; + #if defined(OS_ANDROID) + // https://crbug.com/844118: Limiting policy to devices with > 1GB RAM. + // Using 1077 rather than 1024 because 1) it helps ensure that devices with +@@ -100,6 +101,7 @@ bool SiteIsolationPolicy::IsEnterprisePolicyApplicable() { + // static + bool SiteIsolationPolicy::ShouldDisableSiteIsolationDueToMemoryThreshold( + content::SiteIsolationMode site_isolation_mode) { ++ if ((true)) return false; + // The memory threshold behavior differs for desktop and Android: + // - Android uses a 1900MB default threshold for partial site isolation modes + // and a 3200MB default threshold for strict site isolation. See docs in +diff --git a/content/public/common/content_features.cc b/content/public/common/content_features.cc +--- a/content/public/common/content_features.cc ++++ b/content/public/common/content_features.cc +@@ -876,7 +876,7 @@ const base::Feature kStorageServiceOutOfProcess{ + // Controls whether site isolation should use origins instead of scheme and + // eTLD+1. + const base::Feature kStrictOriginIsolation{"StrictOriginIsolation", +- base::FEATURE_DISABLED_BY_DEFAULT}; ++ base::FEATURE_ENABLED_BY_DEFAULT}; + + // Enables subresource loading with Web Bundles. + const base::Feature kSubresourceWebBundles{"SubresourceWebBundles", +-- +2.25.1 + diff --git a/build/patches/Site-setting-for-javascript-jit.patch b/build/patches/Site-setting-for-javascript-jit.patch new file mode 100644 index 00000000..dee0c62b --- /dev/null +++ b/build/patches/Site-setting-for-javascript-jit.patch @@ -0,0 +1,475 @@ +From: fgei +Date: Sat, 29 Jan 2022 15:22:45 +0000 +Subject: Implement UI for JIT site settings + +note: needs SitePerProcess and StrictOriginIsolation flags enabled +--- + .../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 | 7 ++++++ + .../site_settings/SingleWebsiteSettings.java | 21 ++++++++++++++++++ + .../site_settings/SiteSettingsCategory.java | 9 ++++++-- + .../site_settings/SiteSettingsUtil.java | 1 + + .../browser_ui/site_settings/Website.java | 6 +++++ + .../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, 94 insertions(+), 3 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 + +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 +@@ -121,6 +121,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", +@@ -129,6 +130,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-mdpi/permission_popups.png", + "java/res/drawable-mdpi/permission_protected_media.png", + "java/res/drawable-mdpi/settings_sensors.png", +@@ -137,6 +139,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", +@@ -145,6 +148,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", +@@ -153,6 +157,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 +GIT binary patch +literal 433 +zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8JTOS+@4BLl<6e(pbstUx|flDE4H +z!~gdFGy8!&_7YEDSN5meq5{TNTew%=2MRs)ba4#vIR193A=e=T3AgxL3xfGC+&p@g +zxq@%H!}^D6y&U%raBHM||I>M|)jh@5n_;>qt-4aO=Jn{SdpL;NdW$kh#Vwulipg-_&G}z8XMSF)ko-7% +z3rFxL#;bCHS58EnVqE2EI5A82*pCZV%bVPaq%Za?;S4FhcERGPe87bhk=K|*Cof)P +zJZTY&`R&NhA8)^oa_Rejc2&J;W}U>6#x9$0I?f-rAIrEOoW?)l(3d%VGfMurhSh~n +zzkWP``Iq|?^{v|tcEx$Uv<7-uwZt`|BqgyV)hf9t6-Y4{85kMr8XD>v8HN~GS{a&H +r8JTDs7+4t?X#IcZhN2-iKP5A*61RrvMPa{y8W=oX{an^LB{Ts5WVxh$ + +literal 0 +HcmV?d00001 + +diff --git a/components/browser_ui/site_settings/android/java/res/drawable-mdpi/permission_javascript_jit.png b/components/browser_ui/site_settings/android/java/res/drawable-mdpi/permission_javascript_jit.png +new file mode 100644 +index 0000000000000000000000000000000000000000..97b96dba01ebcae8a232a63f08bdf42ce997dc30 +GIT binary patch +literal 377 +zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_*1mUKs7M+SzC{oH>NS%G|}ByV>Y +zhX3vTXZ8bm>?NMQuIx{_MFotlws5b!4-{JK>Eak-ar*3}jl72p1YGCKrguwpW=1ep +zHhAz%6ft0N{iUJ3p?|rt!k>f!rSnaUse1uys-bF975M8jK$ +zp)d16ffF8Fr<(4~epuY_I&9C*DW^Y6O7W&8{tlIJ7if%p=Tv7F#w3uvcalHD +zvVT4ArrmS9WAybSo6Ewd7v4v2%1Kl_+;bvt-+xn{2bp&^d%SgY&iHtR^{w;n>*xJn +zvCg?`T*7?o3?tCtswJ)wB`Jv|saDBFsX&Us$iT=@*U(Vc$S}mf(#p`p%E(09z`)AD +jKgTe~DWM4fOh$>o + +literal 0 +HcmV?d00001 + +diff --git a/components/browser_ui/site_settings/android/java/res/drawable-xhdpi/permission_javascript_jit.png b/components/browser_ui/site_settings/android/java/res/drawable-xhdpi/permission_javascript_jit.png +new file mode 100644 +index 0000000000000000000000000000000000000000..8f85eb32c30cc965440d44c2eee784c23ea1f2fc +GIT binary patch +literal 518 +zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}a}tmUKs7M+SzC{oH>NS%G|}ByV>Y +zhX3vTXZ8bm>?NMQuIx{_MFotlws5b!&%nTF<>}%W5^?zLG(#_DN0GMu+da9sr#7?- +zZrSpU<(Yuej_L`yvbUee2`erYH!$C@IlN~omnKVOflk>?m8Li6p6F`4yU(L@`2XJT +z`)4LD3|;N3`m?A|Ls`-&ps2RYczT@uw1&@%@5$Cay>x%mgW8+uN56|v7Qd1%;d +z&~kl(v%tLki@$X0g8s~0Kly}ofP$8acDup@xroP`f0xH>5xcPB)BO88Wf+dUpLH!S +zj%kJ<^NDF{4tb|L?1H|pns?TF8dC|wJMrV&j3?M`+j?l?>^C{Tmc*5;u3x2JujJ$Y +z%7~#G7_h1(t`Q|Ei6yC4$wjF^iowXh$WYhNP}j&X#K6+Z(8S8fMBBi?%D_PD|2sDn +d4Y~O#nQ4`{HAF88`vug%;OXk;vd$@?2>=L-$>9J1 + +literal 0 +HcmV?d00001 + +diff --git a/components/browser_ui/site_settings/android/java/res/drawable-xxhdpi/permission_javascript_jit.png b/components/browser_ui/site_settings/android/java/res/drawable-xxhdpi/permission_javascript_jit.png +new file mode 100644 +index 0000000000000000000000000000000000000000..54d86e9b38553720c860b0e0e5d7196fb0dc0dc6 +GIT binary patch +literal 629 +zcmeAS@N?(olHy`uVBq!ia0vp^9w5x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JyMVzr`I;RW_w~PXgy=sM +zFW<0Z#r*y2t5_Ir*?%!C-(vA%|MlC;rWqb>voD`9vnkc%L$|=KaCUR)<++=es^=6k +zdS#hbu1|FIHV@q!yV7(=Ge?sG5UI3_o4szn*>QjOAz*q_Epd$~Nl7e8wMs5Z1yT$~ +z21bUuhK9OEh9L%)R)!{4Mkd+@237_JTL0gPsvQH#H}HEQP?k_1_n=8KbLh* +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 +@@ -41,6 +41,10 @@ + ++ ++ + + + JavaScript + ++ ++ JavaScript JIT ++ + + Location + +@@ -402,6 +405,20 @@ + Block JavaScript for a specific site. + + ++ ++ ++ Allow sites to run JIT, that is, compile JavaScript to native code. ++ ++ ++ Block sites to run JIT, that is, compile JavaScript to interpreter code. ++ ++ ++ Allow v8 JIT to run for a specific site. ++ ++ ++ Block v8 JIT to run for a specific site. ++ ++ + + + +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 +@@ -604,7 +604,7 @@ void ContentSettingsRegistry::Init() { + ContentSettingsInfo::EXCEPTIONS_ON_SECURE_ORIGINS_ONLY); + + Register(ContentSettingsType::JAVASCRIPT_JIT, "javascript-jit", +- CONTENT_SETTING_ALLOW, WebsiteSettingsInfo::UNSYNCABLE, ++ CONTENT_SETTING_BLOCK, WebsiteSettingsInfo::UNSYNCABLE, + AllowlistedSchemes(), + ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK), + WebsiteSettingsInfo::SINGLE_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 +@@ -138,6 +138,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( +@@ -225,6 +226,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 +@@ -119,6 +119,7 @@ ContentSettingsType kPermissionType[] = { + ContentSettingsType::VR, + ContentSettingsType::AR, + ContentSettingsType::IDLE_DETECTION, ++ ContentSettingsType::JAVASCRIPT_JIT, + }; + + // Determines whether to show permission |type| in the Page Info UI. Only +@@ -157,6 +158,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; ++ } ++ + content_settings::WebsiteSettingsRegistry* website_settings = + content_settings::WebsiteSettingsRegistry::GetInstance(); + for (const content_settings::WebsiteSettingsInfo* winfo : *website_settings) { +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 +@@ -73,6 +73,12 @@ + + javascript + ++ ++ JavaScript JIT ++ ++ ++ javascript JIT ++ + + Location + +-- +2.25.1 +