278 lines
14 KiB
Diff
278 lines
14 KiB
Diff
|
From: uazo <uazo@users.noreply.github.com>
|
||
|
Date: Tue, 5 Oct 2021 08:38:52 +0000
|
||
|
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
|
||
|
---
|
||
|
.../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
|
||
|
.../impl/BromiteImagesContentSetting.java | 92 ++++++++++++++++++
|
||
|
.../bromite_content_settings/images.grdp | 23 +++++
|
||
|
.../bromite_content_settings/images.inc | 6 ++
|
||
|
.../core/browser/content_settings_registry.cc | 2 +-
|
||
|
.../core/browser/content_settings_utils.cc | 7 +-
|
||
|
10 files changed, 123 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/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/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)<h;3K|Lk000e1NJLTq001Na001Ni1ONa4O9@aD0002UNkl<ZcmZP|
|
||
|
z9*lxew#fFVXHox&g^^Dq+e6u~7z8xtKdCUX9g9IA*N_aKVKeAIIdG^OG-}YOL6J+M
|
||
|
z=1{?)$ormr4jfTui8lyg|4by_p9m|Enh1r+w*(DBw;xzO9fR>B>S3zFJ)`~-FbLEB
|
||
|
zAW2Bk5_vR~8KEwso}fXP_D5Pq{*3w<p@5>0DQX)*gD~xnN{fodD3paF?-Mi#Y(GH|
|
||
|
zZWQ&MkU`N5M1hFpL7hb?uSFuCQm<a4yrzwM2CZr74@Ln1pdnSs3x>A700000NkvXX
|
||
|
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?5vUg<mCxxJ{<wc_;o8*?=Y$1H*fl&w8TkOplD%KVEo3c4v%9~rzs1a
|
||
|
k;0l{G+5Dws#s($^mqRr#7AM@F4s;BIr>mdKI;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)<h;3K|Lk000e1NJLTq001xm001xu1ONa4{R=S+00034Nkl<ZcwX(7
|
||
|
zp$@_@5QZ0mAULoyC<KxxKwuEaWxZ2NaJ&Rhft#2akAUGBkO&lNQv*j3gp5D}*APnD
|
||
|
zbv5Mr>Azp{U()nEK1|&NKBkysSq;cA4gBBN7g$<S{7}G(0v4o70hMD#t`?N_zycO%
|
||
|
z!vYqtAcn-HU^{9}+qiQifTQR=0>J>!_JSCeAA(yrc_l<tSwK~cnz)hUVj*WBsVtx>
|
||
|
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
|
||
|
O0000<MNUMnLSTY+QGR&<
|
||
|
|
||
|
literal 0
|
||
|
HcmV?d00001
|
||
|
|
||
|
diff --git a/components/browser_ui/site_settings/android/java/res/drawable-xxhdpi/permission_images.png b/components/browser_ui/site_settings/android/java/res/drawable-xxhdpi/permission_images.png
|
||
|
new file mode 100644
|
||
|
index 0000000000000000000000000000000000000000..d4d1f0c6e9a59ad9e334daeeb830c953f371706f
|
||
|
GIT binary patch
|
||
|
literal 449
|
||
|
zcmV;y0Y3hTP)<h;3K|Lk000e1NJLTq002k;002k`1ONa4|Kxkj0004qNkl<ZcwX(<
|
||
|
zze>YU6vy#j)Ir6`sdRGHQCx+t4o-6IId=*)FW?jO3G@jZvg!kL>E_acI_m1An@ca%
|
||
|
zLHq+j4wj_lLUKbY=X)QZAIixk<iIaY(=;vO#E#h6?*M0FN1Pynf2L)J0tj`6rUlO;
|
||
|
z;RGgm{!5$)An@VD4>Ya|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|<py(hl-Pzt7tR<|mU>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?%&M7z<Ar!#WAEJ?(J+tzrzVUt-OnZ
|
||
|
zj<TsIB)#y^ztG6Yc5Kzg<sLaPP0}u>4urJLS>(KvDJM1I5sSeVC!Qr--l?HpO;<zI
|
||
|
zelGp~lj*0*{_RKXuQCITW?(qR>{)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;j<vY4QX8gzcwZc+BHze1DQPRN&}au8h?uIQReE`FDE=bNX72
|
||
|
zDbcA#dh@q3^@lX89gIJaC%W^=e6Pmof%Cm)czzJS5El4jUD`>WMK{8MQcJJ6zdmUy
|
||
|
znIZIt^-b7CyHznp%AEI@%2rSLmEqQ&vKXj-L$vGf6?;<3penTVXY!_lRAk79>d&0Z
|
||
|
z;?9^WDsRH+$8<~UoXf_^4coe`=U8%Ntp2gcvp~Qg>Zmp6Z*GaTkLIw<kphN9qx`;8
|
||
|
zMn5h;e$c<a*?vF&A4ZoC{sBz&EFw>gb>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/src/org/chromium/components/browser_ui/site_settings/impl/BromiteImagesContentSetting.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteImagesContentSetting.java
|
||
|
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,92 @@
|
||
|
+/*
|
||
|
+ 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 <https://www.gnu.org/licenses/>.
|
||
|
+*/
|
||
|
+
|
||
|
+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");
|
||
|
+ }
|
||
|
+
|
||
|
+ @Override
|
||
|
+ public ContentSettingsResources.ResourceItem getResourceItem() {
|
||
|
+ return new ContentSettingsResources.ResourceItem(
|
||
|
+ /*icon*/ R.drawable.permission_images,
|
||
|
+ /*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 int getCategoryDescription() {
|
||
|
+ 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/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/bromite_content_settings/images.grdp
|
||
|
@@ -0,0 +1,23 @@
|
||
|
+<?xml version="1.0" encoding="utf-8"?>
|
||
|
+<grit-part>
|
||
|
+<if expr="is_android">
|
||
|
+ <message name="IDS_SITE_SETTINGS_TYPE_IMAGES" desc="The label used for images site settings controls." formatter_data="android_java">
|
||
|
+ Images
|
||
|
+ </message>
|
||
|
+ <message name="IDS_SITE_SETTINGS_TYPE_IMAGES_MID_SENTENCE" desc="The label used for images site settings controls when used mid-sentence." formatter_data="android_java">
|
||
|
+ Images
|
||
|
+ </message>
|
||
|
+</if>
|
||
|
+ <message name="IDS_IMAGES_PERMISSION_TITLE" desc="Title of the permission to show images [CHAR-LIMIT=32]" formatter_data="android_java">
|
||
|
+ Images
|
||
|
+ </message>
|
||
|
+ <message name="IDS_WEBSITE_SETTINGS_ADD_SITE_DESCRIPTION_IMAGES" desc="The description for the allow Images on website dialog." formatter_data="android_java">
|
||
|
+ Allow images on websites you specify while blocking them for the rest of the web
|
||
|
+ </message>
|
||
|
+ <message name="IDS_WEBSITE_SETTINGS_CATEGORY_IMAGES_ENABLED" desc="Summary text explaining that sites are allowed to load images." formatter_data="android_java">
|
||
|
+ Allow sites to load images
|
||
|
+ </message>
|
||
|
+ <message name="IDS_WEBSITE_SETTINGS_CATEGORY_IMAGES_DISABLED" desc="Summary text explaining that sites are not allowed to load images." formatter_data="android_java">
|
||
|
+ Disallow sites to load images
|
||
|
+ </message>
|
||
|
+</grit-part>
|
||
|
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,6 @@
|
||
|
+ 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
|
||
|
@@ -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);
|
||
|
|
||
|
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
|
||
|
@@ -145,12 +145,7 @@ void GetRendererContentSettingRules(const HostContentSettingsMap* map,
|
||
|
ContentSettingToValue(CONTENT_SETTING_ALLOW), std::string(),
|
||
|
map->IsOffTheRecord()));
|
||
|
#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(),
|
||
|
- ContentSettingToValue(CONTENT_SETTING_ALLOW), std::string(),
|
||
|
- map->IsOffTheRecord()));
|
||
|
+ rules->image_rules = map->GetSettingsForOneType(ContentSettingsType::IMAGES);
|
||
|
// In Android active mixed content is hard blocked, with no option to allow
|
||
|
// it.
|
||
|
rules->mixed_content_rules.push_back(ContentSettingPatternSource(
|
||
|
--
|
||
|
2.25.1
|