You can use the Chromium proxy settings from the command line. The man page tells you how. So here is an excerpt from man chromium-browser from my Ubuntu Natty:
--proxy-server=host:port
Specify the HTTP/SOCKS4/SOCKS5 proxy server to use for requests. This overrides any environment variables or settings picked via the options dialog. An individual
proxy server is specified using the format:
[<proxy-scheme>://]<proxy-host>[:<proxy-port>]
Where <proxy-scheme> is the protocol of the proxy server, and is one of:
"http", "socks", "socks4", "socks5".
If the <proxy-scheme> is omitted, it defaults to "http". Also note that "socks" is equivalent to "socks5".
Examples:
--proxy-server="foopy:99"
Use the HTTP proxy "foopy:99" to load all URLs.
--proxy-server="socks://foobar:1080"
Use the SOCKS v5 proxy "foobar:1080" to load all URLs.
--proxy-server="sock4://foobar:1080"
Use the SOCKS v4 proxy "foobar:1080" to load all URLs.
--proxy-server="socks5://foobar:66"
Use the SOCKS v5 proxy "foobar:66" to load all URLs.
It is also possible to specify a separate proxy server for different URL types, by prefixing the proxy server specifier with a URL specifier:
Example:
--proxy-server="https=proxy1:80;http=socks4://baz:1080"
Load https://* URLs using the HTTP proxy "proxy1:80". And load http://*
URLs using the SOCKS v4 proxy "baz:1080".
The advantage of using the command line arguments is, that you do not have to change your global system settings.
For example:
$ chromium-browser --proxy-server="http://127.0.0.1:8080"
Also have a look at Justin's post in this thread where he describes how to use the proxy for DNS request also.
Looks like you want to *programmatically* change the proxy settings. Changing them manually would involve opening up the Preferences section of the Chrome browser. What you want to do seems very strange -- what is the underlying goal of what you're trying to accomplish? There may be a simpler way of achieving that goal. – Mike Rowave – 2011-08-11T13:12:48.877
May be explaining why I wish to perform such a thing will help people offer alternate solutions. I wish to record all the traffic being served by Google Chrome. For that, I have a client who acts like a proxy server. Now, if I set the proxy of Chrome to localhost and a certain port, all the traffic will go through my client and my client will be able to record all thats happened. And when I am done recording what I need, I will shutdown chrome and restore its original proxy settings.
I do not wish to use command line arguments passed onto Chrome browser and wish to do this programmatically. – Elitecoder – 2012-02-16T13:50:30.113