Prevent chrome for android from loading images

2,217 views
Skip to first unread message

אבי וזהו

unread,
Apr 26, 2017, 4:10:39 PM4/26/17
to Chromium-dev

Hi,

I'm trying to create a version of chromium that shows no images (for saving network bandwith)

I downloaded the chromium source code for android, I'm trying to find a way to block all images (in the web pages) but i can't seem to figure out where to to it.


Any help will be highly appreciated


Thanks 

Avi

PhistucK

unread,
Apr 26, 2017, 4:37:19 PM4/26/17
to avi...@gmail.com, Chromium-dev
The most hard coded way would probably be to change it here -
To set it to FALSE instead of taking it from the prefs.

Does that work?


PhistucK

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/1dca64b6-d30c-49cc-ba8a-552c12e09229%40chromium.org.

אבי וזהו

unread,
Apr 28, 2017, 4:05:59 AM4/28/17
to Chromium-dev, avi...@gmail.com
Hi,

Thanks a lot .
It worked.  (-:

Now, i'lI would like to find a way to control it from the android app ui.
 As i understand it loads the value from shared preferences.

where would be the place in the java code to add this configuration?

Thanks
Avi

On Wednesday, April 26, 2017 at 11:37:19 PM UTC+3, PhistucK wrote:
The most hard coded way would probably be to change it here -
To set it to FALSE instead of taking it from the prefs.

Does that work?


PhistucK

On Wed, Apr 26, 2017 at 11:10 PM, אבי וזהו <avi...@gmail.com> wrote:

Hi,

I'm trying to create a version of chromium that shows no images (for saving network bandwith)

I downloaded the chromium source code for android, I'm trying to find a way to block all images (in the web pages) but i can't seem to figure out where to to it.


Any help will be highly appreciated


Thanks 

Avi

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.

Christian Dullweber

unread,
Apr 28, 2017, 4:25:56 AM4/28/17
to avi...@gmail.com, Chromium-dev, fin...@chromium.org
+finnur who worked on the image toggle
Chrome for desktop already has a settings ui to disable loading Images (chrome://settings/content). It looks like Android had this setting too but it was removed at some point (http://crbug.com/505844).

You can probably look at how the toggle for Javascript works and implement the same for "images" or you could look at the CL that removed the image toggle and revert the changes. 

The change is already two years old and data saver doesn't work for https sites, which is what nearly every site I visit is using. Not loading images would safe a lot more than loading compressed images if you are on a really slow connection or are throttled due to having exceeded your monthly data plan. Maybe it would be useful to add the image toggle back?

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/44bdcd84-f257-4b3d-b14a-fc796a5748ec%40chromium.org.

אבי וזהו

unread,
May 12, 2017, 8:54:44 AM5/12/17
to Chromium-dev, avi...@gmail.com
HI,
I cant figure out from where in the android java code i controle this feature.

Can anyone lease point me to a place in the java code that i can disable images display?

Thanks a lot

Avi

On Wednesday, April 26, 2017 at 11:37:19 PM UTC+3, PhistucK wrote:
The most hard coded way would probably be to change it here -
To set it to FALSE instead of taking it from the prefs.

Does that work?


PhistucK

On Wed, Apr 26, 2017 at 11:10 PM, אבי וזהו <avi...@gmail.com> wrote:

Hi,

I'm trying to create a version of chromium that shows no images (for saving network bandwith)

I downloaded the chromium source code for android, I'm trying to find a way to block all images (in the web pages) but i can't seem to figure out where to to it.


Any help will be highly appreciated


Thanks 

Avi

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.

Finnur Thorarinsson

unread,
May 12, 2017, 9:56:42 AM5/12/17
to avi...@gmail.com, Chromium-dev
Yeah, I second what Christian said ^.

If you re-add what I removed in this CL and fix whatever has bitrotted, then you not only end up with an image blocker but a UI that lets you configure it on Android -- both globally and per site.

אבי וזהו

unread,
May 13, 2017, 4:53:14 PM5/13/17
to Chromium-dev, avi...@gmail.com
Hi,

Thanks a lot.

But i don't want the full functionality.

I would like to just have a function that will allow me to enable / disable the image loading from within the android code (WIth no connection to the UI).

Could you please direct me to the place and function i need to implement?

Thanks again
Avi

Christian Dullweber

unread,
May 15, 2017, 4:52:18 AM5/15/17
to אבי וזהו, Chromium-dev
The code is in PrefServiceBridge.java in the CL we already linked you (http://crrev.com/1221833002). Just add the same code again and it should work

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/5ca5f803-31f2-429e-8ea0-a05df9477a9b%40chromium.org.

אבי וזהו

unread,
May 24, 2017, 12:58:43 PM5/24/17
to Chromium-dev
Hi,

Making the changes in the "PrefServiceBridge.java" seems to work.

But there is a big delay, what i mean is the following:

I wand to disable (hardcoded) specific websites from displaying images. 

So In the "ExternalNavigationHandler.java => shouldOverrideUrlLoadingInternal" i'm checking if the url  (params.getUrl()) matches the url that i want to block images to, and if it matches, i run the following code:

Runnable r = new Runnable() {
@Override
public void run() {
PrefServiceBridge.getInstance().setImagesEnabled(false);
}
};

And if id doesn't match i set it to true.

The problem is that the images get disabled only after refreshing the page twice.

What would be the best way to perform the URL check and to make sure that on specific websites no images will be displayed.


Thanks a lot
Avi

אבי וזהו

unread,
May 29, 2017, 11:08:05 AM5/29/17
to Chromium-dev
Can anyone please help?


On Wednesday, April 26, 2017 at 11:10:39 PM UTC+3, אבי וזהו wrote:
Reply all
Reply to author
Forward
0 new messages