From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: fgei Date: Fri, 28 Jan 2022 20:52:56 +0000 Subject: [PATCH] Implement UI for JIT site settings --- .../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 | 18 +++++++++++++++ .../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, 95 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 index 3a0ad6fe77816..55209c8bd3f33 100644 --- a/components/browser_ui/site_settings/android/BUILD.gn +++ b/components/browser_ui/site_settings/android/BUILD.gn @@ -198,6 +198,7 @@ android_resources("java_resources") { "java/res/drawable-hdpi/ic_volume_up_grey600_24dp.png", "java/res/drawable-hdpi/permission_background_sync.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", @@ -205,6 +206,7 @@ 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-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", @@ -212,6 +214,7 @@ android_resources("java_resources") { "java/res/drawable-xhdpi/ic_volume_up_grey600_24dp.png", "java/res/drawable-xhdpi/permission_background_sync.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", @@ -219,6 +222,7 @@ android_resources("java_resources") { "java/res/drawable-xxhdpi/ic_volume_up_grey600_24dp.png", "java/res/drawable-xxhdpi/permission_background_sync.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", @@ -226,6 +230,7 @@ android_resources("java_resources") { "java/res/drawable-xxxhdpi/ic_volume_up_grey600_24dp.png", "java/res/drawable-xxxhdpi/permission_background_sync.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^9w5xY0wn)GsXhawSkfJR9T^xl_H+M9WCik>lD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%|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 index 34e7635e048ed..50ed3558455e2 100644 --- 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! + + JavaScript + + JavaScript JIT + Location @@ -668,6 +671,21 @@ Block JavaScript for a specific site. + + + + Allow sites to use just-in-time compilation; improve performance at expense of security by compiling JavaScript to native code. + + + Block sites to use just-in-time compilation; improve security at expense of performance by not compiling JavaScript to native code, and using only interpreted code. + + + Allow JIT for a specific site. + + + Block JIT 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 index a01f612ca3c8f..b1a9b66861ba7 100644 --- a/components/content_settings/core/browser/content_settings_registry.cc +++ b/components/content_settings/core/browser/content_settings_registry.cc @@ -537,7 +537,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, /*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 index ee27420c58931..f8df754dc11ef 100644 --- a/components/page_info/android/page_info_controller_android.cc +++ b/components/page_info/android/page_info_controller_android.cc @@ -131,6 +131,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 index 88004c76e9a67..c12fe619bd03e 100644 --- a/components/page_info/page_info.cc +++ b/components/page_info/page_info.cc @@ -104,6 +104,7 @@ ContentSettingsType kPermissionType[] = { ContentSettingsType::SENSORS, ContentSettingsType::NOTIFICATIONS, ContentSettingsType::JAVASCRIPT, + ContentSettingsType::JAVASCRIPT_JIT, #if !BUILDFLAG(IS_ANDROID) ContentSettingsType::IMAGES, #endif @@ -1275,6 +1276,11 @@ bool PageInfo::ShouldShowPermission( } #endif // !BUILDFLAG(IS_ANDROID) + // 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) diff --git a/components/page_info/page_info_ui.cc b/components/page_info/page_info_ui.cc index 8548364389f49..ed576fa026fee 100644 --- a/components/page_info/page_info_ui.cc +++ b/components/page_info/page_info_ui.cc @@ -143,6 +143,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 index 417bc6f5bea60..825b39733c5f5 100644 --- a/components/site_settings_strings.grdp +++ b/components/site_settings_strings.grdp @@ -88,6 +88,12 @@ javascript + + JavaScript JIT + + + javascript JIT + Location