diff --git a/build/bromite_patches_list.txt b/build/bromite_patches_list.txt index 74022516..fe278ced 100644 --- a/build/bromite_patches_list.txt +++ b/build/bromite_patches_list.txt @@ -164,3 +164,4 @@ Enable-share-intent.patch Automated-domain-substitution.patch Observe-WebContents-in-PPAPIDownloadRequest.patch Prevents-non-browser-processes-from-requesting-memory-dumps.patch +Add-images-contentsettings.patch \ No newline at end of file diff --git a/build/patches/Add-images-contentsettings.patch b/build/patches/Add-images-contentsettings.patch new file mode 100644 index 00000000..3e3e80df --- /dev/null +++ b/build/patches/Add-images-contentsettings.patch @@ -0,0 +1,454 @@ +From: uazo +Date: Tue, 5 Oct 2021 08:38:52 +0000 +Subject: Site setting for images + +--- + .../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 | 4 ++++ + .../site_settings/SingleWebsiteSettings.java | 22 ++++++++++++++++++ + .../site_settings/SiteSettingsCategory.java | 9 +++++-- + .../site_settings/SiteSettingsUtil.java | 1 + + .../browser_ui/site_settings/Website.java | 6 +++++ + .../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 | 9 ++----- + .../android/page_info_controller_android.cc | 4 ++++ + components/page_info/page_info.cc | 7 ++++-- + components/page_info/page_info_ui.cc | 2 +- + 21 files changed, 75 insertions(+), 13 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 + +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") { + 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", +@@ -129,6 +130,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_popups.png", + "java/res/drawable-mdpi/permission_protected_media.png", +@@ -137,6 +139,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", +@@ -145,6 +148,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", +@@ -153,6 +157,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 +GIT binary patch +literal 257 +zcmV+c0sj7pP)B>S3zFJ)`~-FbLEB +zAW2Bk5_vR~8KEwso}fXP_D5Pq{*3w0DQX)*gD~xnN{fodD3paF?-Mi#Y(GH| +zZWQ&MkU`N5M1hFpL7hb?uSFuCQmA700000NkvXX +Hu0mjfaQkDG + +literal 0 +HcmV?d00001 + +diff --git a/components/browser_ui/site_settings/android/java/res/drawable-mdpi/permission_images.png b/components/browser_ui/site_settings/android/java/res/drawable-mdpi/permission_images.png +new file mode 100644 +index 0000000000000000000000000000000000000000..52435094e69ea5278e5c2a60238c7c374961ef08 +GIT binary patch +literal 186 +zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_+iMo$;VkP60Ri7g6uj9(RAslQ|J +zDR75+7h6ZspQr%SKk7Uy7bS)`KY4!Q!HV@QrgIuMJ4s3?32|iJ5IZHaQ|QdA<`XV@ +z2No-Ss#_tz?5vUgmdKI;Vst089i%5C8xG + +literal 0 +HcmV?d00001 + +diff --git a/components/browser_ui/site_settings/android/java/res/drawable-xhdpi/permission_images.png b/components/browser_ui/site_settings/android/java/res/drawable-xhdpi/permission_images.png +new file mode 100644 +index 0000000000000000000000000000000000000000..cf3b7d0e10cd0e660db9b2532c54a317c7ea4c6c +GIT binary patch +literal 316 +zcmV-C0mJ@@P)Azp{U()nEK1|&NKBkysSq;cA4gBBN7g$J>!_JSCeAA(yrc_l +zumk&deC;*l3{ApVAXgFg@$^(4g07sPNoWexRp1z|cnOE!aw0MoP!$Bs#Y~li#6Un* +z=s=S&5Kt95&?K}4RD}s5`k&X-@#hyZwIFr*eRscr*soBS(+b5f^_@FBh3KYE{OnEu +O0000YU6vy#j)Ir6`sdRGHQCx+t4o-6IId=*)FW?jO3G@jZvg!kL>E_acI_m1An@ca% +zLHq+j4wj_lLUKbY=X)QZAIixkYa|WJi7=R~LvKd=fwnXDL7mQjmfaq#y+;NI?oxkb>CpiJdkG +zWDP)ZV?cb4EKVB%;+xJIvW_?HLp`9o1)vwxf@JpWG(2cvR{5%!!yj~rnJ5kn;wQ5W +zm<_%y0?`?AaT*fz-rYwQwfQ**x<)RUq%a`rL81eG`^(`+vxQtTNkKrDn2AsMOE|8( +zi@8x80(9S5&;3weum%g`v|CFrwzgrc(NO|C-8W0J~&sE@f( +z+xPP>#Z`d@SV1LmS`s8zVfkc|N`mAnET2qLDG>EgaTNdmS6BtHs|_@1`0}Os>#6z| +rcuTqBlqE2a!;CjO|0S@dX_|%~l|w?sH+N5m00000NkvXXu0mjfPvFC^ + +literal 0 +HcmV?d00001 + +diff --git a/components/browser_ui/site_settings/android/java/res/drawable-xxxhdpi/permission_images.png b/components/browser_ui/site_settings/android/java/res/drawable-xxxhdpi/permission_images.png +new file mode 100644 +index 0000000000000000000000000000000000000000..cca41100e76e81974b4c22d1d9a1fdffabe9cf60 +GIT binary patch +literal 532 +zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD0wg^q?%&M7z4urJLS>(KvDJM1I5sSeVC!Qr--l?HpO;{)S8Tk~J#v^^72Y!=i?d{cQE)Ag;b*t31_vH9nV +zHE+q!GY^>%($(j4E91N6`!0s(yqgp{MPz5Sl(mY-3OzXbj%l?Y=bDW0B`>bE=rS;J +zI502?G%&CzU@&c->ZCM25B&cuB92+~LH~=K&+k8LyEK}{Uu@Ih3sBg#T-SozH^Gg4 +zORL(#T*i5ynspDne;jWMK{8MQcJJ6zdmUy +znIZIt^-b7CyHznp%AEI@%2rSLmEqQ&vKXj-L$vGf6?;<3penTVXY!_lRAk79>d&0Z +z;?9^WDsRH+$8<~UoXf_^4coe`=U8%Ntp2gcvp~Qg>Zmp6Z*GaTkLIwgb>bq=Zve-^0sWl|`X($0(Fg}|Jzf1=);T3K +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 +@@ -41,6 +41,10 @@ + ++ ++ + + + Your device use + ++ ++ Images ++ + + JavaScript + +@@ -188,6 +191,9 @@ + + Site %1$sgoogle.com added + ++ ++ Allow images on websites you specify while blocking them for the rest of the web ++ + + Site URL + +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 +@@ -144,7 +144,8 @@ void ContentSettingsRegistry::Init() { + kExtensionScheme), + ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK), + WebsiteSettingsInfo::SINGLE_ORIGIN_WITH_EMBEDDED_EXCEPTIONS_SCOPE, +- WebsiteSettingsRegistry::DESKTOP, ++ WebsiteSettingsRegistry::DESKTOP | ++ WebsiteSettingsRegistry::PLATFORM_ANDROID, + ContentSettingsInfo::INHERIT_IN_INCOGNITO, + ContentSettingsInfo::PERSISTENT, + ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); +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 +@@ -126,13 +126,8 @@ void GetRendererContentSettingRules(const HostContentSettingsMap* map, + + &(rules->mixed_content_rules)); + #else +- // Android doesn't use image content settings, so ALLOW rule is added for +- // all origins. +- rules->image_rules.push_back(ContentSettingPatternSource( +- ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), +- base::Value::FromUniquePtrValue( +- ContentSettingToValue(CONTENT_SETTING_ALLOW)), +- std::string(), map->IsOffTheRecord())); ++ map->GetSettingsForOneType(ContentSettingsType::IMAGES, ++ &(rules->image_rules)); + // 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 +@@ -210,6 +210,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 +@@ -90,9 +90,7 @@ ContentSettingsType kPermissionType[] = { + ContentSettingsType::SENSORS, + ContentSettingsType::NOTIFICATIONS, + ContentSettingsType::JAVASCRIPT, +-#if !defined(OS_ANDROID) + ContentSettingsType::IMAGES, +-#endif + ContentSettingsType::POPUPS, + ContentSettingsType::WINDOW_PLACEMENT, + ContentSettingsType::ADS, +@@ -147,6 +145,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 +@@ -138,7 +138,7 @@ base::span GetContentSettingsUIInfo() { + DCHECK(base::FeatureList::GetInstance() != nullptr); + static const PermissionsUIInfo kPermissionsUIInfo[] = { + {ContentSettingsType::COOKIES, 0}, +- {ContentSettingsType::IMAGES, IDS_PAGE_INFO_TYPE_IMAGES}, ++ {ContentSettingsType::IMAGES, IDS_PAGE_INFO_TYPE_IMAGES}, // needed + {ContentSettingsType::JAVASCRIPT, IDS_PAGE_INFO_TYPE_JAVASCRIPT}, + {ContentSettingsType::POPUPS, IDS_PAGE_INFO_TYPE_POPUPS_REDIRECTS}, + {ContentSettingsType::GEOLOCATION, IDS_PAGE_INFO_TYPE_LOCATION}, +-- +2.17.1 +