OLD | NEW |
---|---|
1 <div id="pageData-name" class="pageData">Proxy Settings</div> | 1 <div id="pageData-name" class="pageData">Proxy Settings</div> |
2 | 2 |
3 <!-- BEGIN AUTHORED CONTENT --> | 3 <!-- BEGIN AUTHORED CONTENT --> |
4 <p id="classSummary"> | 4 <p id="classSummary"> |
5 Use the <code>chrome.proxy</code> module to manage Chrome's | 5 Use the <code>chrome.proxy</code> module to manage Chrome's |
6 proxy settings. | 6 proxy settings. This module relies on the <a href="preferences.html">preferences |
7 API</a> for getting and setting the proxy configuration. | |
7 </p> | 8 </p> |
8 | 9 |
9 <h2 id="manifest">Manifest</h2> | 10 <h2 id="manifest">Manifest</h2> |
10 <p>You must declare the "proxy" permission | 11 <p>You must declare the "proxy" permission |
11 in the <a href="manifest.html">extension manifest</a> | 12 in the <a href="manifest.html">extension manifest</a> |
12 to use the proxy settings API. | 13 to use the proxy settings API. |
13 For example:</p> | 14 For example:</p> |
14 <pre>{ | 15 <pre>{ |
15 "name": "My extension", | 16 "name": "My extension", |
16 ... | 17 ... |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 range is specified using CIDR notation.<br> | 143 range is specified using CIDR notation.<br> |
143 Examples: <code>"192.168.1.1/16", "fefe:13::abc/33"</code></dd> | 144 Examples: <code>"192.168.1.1/16", "fefe:13::abc/33"</code></dd> |
144 | 145 |
145 <dt><code><local></code></dt> | 146 <dt><code><local></code></dt> |
146 <dd>Match local addresses. An address is local if the host is "127.0.0.1", | 147 <dd>Match local addresses. An address is local if the host is "127.0.0.1", |
147 "::1", or "localhost".<br> | 148 "::1", or "localhost".<br> |
148 Example: <code>"<local>"</code></dd> | 149 Example: <code>"<local>"</code></dd> |
149 </dl> | 150 </dl> |
150 | 151 |
151 | 152 |
152 <h2 id="precedence">Precedence</h2> | |
153 | |
154 <p> | |
155 Chrome manages settings on different layers. The following list describes the | |
156 layers that may influence the effective proxy settings, in increasing order of | |
157 precedence. | |
158 <ol> | |
159 <li>System settings provided by the operating system</li> | |
160 <li>Command line parameters</li> | |
161 <li>Preferences set by extensions</li> | |
162 <li>Policies</li> | |
163 </ol> | |
164 </p> | |
165 | |
166 <p> | |
167 As the list implies, policies might overrule any changes that you specify with | |
168 the proxy settings API. | |
169 </p> | |
170 | |
171 <!-- | |
172 <p> | |
173 Chrome allows using different proxy settings for regular windows and incognito | |
174 windows. The following example illustrates the behavior. Assume that no policy | |
175 overrides the proxy settings and that an extension can set proxy settings for | |
176 regular windows <b>(R)</b> and proxy settings for incognito windows <b>(I)</b>. | |
177 </p> | |
178 | |
179 <p> | |
180 <ul> | |
181 <li>If only <b>(R)</b> is set, these settings are effective for both regular | |
182 and incognito windows.</li> | |
183 <li>If only <b>(I)</b> is set, these settings are effective for only incognito | |
184 windows. Regular windows use the proxy settings determined by the lower layers | |
185 (command-line options and system settings).</li> | |
186 <li>If both <b>(R)</b> and <b>(I)</b> are set, the respective settings are | |
187 used for regular and incognito windows.</li> | |
188 </ul> | |
189 </p> | |
190 | |
191 <p> | |
192 If two extensions want to set proxy settings, the extension installed last takes | |
193 precedence over the other extensions. If the extension installed last sets only | |
194 <b>(I)</b>, the settings of regular windows can be defined by more recently | |
195 installed extensions. | |
196 </p> | |
197 --> | |
198 | |
199 | |
200 | |
201 <h2 id="overview-examples">Examples</h2> | 153 <h2 id="overview-examples">Examples</h2> |
202 | 154 |
203 <p> | 155 <p> |
204 The following code sets a SOCKS 5 proxy for HTTP connections to all servers but | 156 The following code sets a SOCKS 5 proxy for HTTP connections to all servers but |
205 foobar.com and uses direct connections for all other protocols. The settings | 157 foobar.com and uses direct connections for all other protocols. The settings |
206 apply to regular and incognito windows. | 158 apply to regular and incognito windows, as incognito windows inherit preferences |
159 from regular windows. Please also consult the <a | |
160 href="preferences.html">Preferences API</a> documentation. | |
207 </p> | 161 </p> |
208 | 162 |
209 <pre> | 163 <pre> |
210 var config = { | 164 var config = { |
211 mode: "fixed_servers", | 165 mode: "fixed_servers", |
212 rules: { | 166 rules: { |
213 httpProxy: { | 167 httpProxy: { |
214 scheme: "socks5", | 168 scheme: "socks5", |
215 host: "1.2.3.4" | 169 host: "1.2.3.4" |
216 }, | 170 }, |
217 bypassList: ["foobar.com"] | 171 bypassList: ["foobar.com"] |
218 } | 172 } |
219 }; | 173 }; |
220 chrome.proxy.settings.set( | 174 chrome.proxy.settings.set( |
221 {value: config, scope: 'regular'}, | 175 {value: config, scope: 'regular'}, |
222 function() {}); | 176 function() {}); |
223 </pre> | 177 </pre> |
224 | 178 |
225 <p> | 179 <p> |
226 The following code sets a custom pac script. | 180 The following code sets a custom pac script. |
kathyw
2011/05/24 18:57:50
pac -> PAC
(to match other uses)
battre
2011/05/24 19:18:03
Done.
| |
227 </p> | 181 </p> |
228 | 182 |
229 <pre> | 183 <pre> |
230 var config = { | 184 var config = { |
231 mode: "pac_script", | 185 mode: "pac_script", |
232 pacScript: { | 186 pacScript: { |
233 data: "function FindProxyForURL(url, host) {\n" + | 187 data: "function FindProxyForURL(url, host) {\n" + |
234 " if (host == 'foobar.com')\n" + | 188 " if (host == 'foobar.com')\n" + |
235 " return 'PROXY blackhole:80';\n" + | 189 " return 'PROXY blackhole:80';\n" + |
236 " return 'DIRECT';\n" + | 190 " return 'DIRECT';\n" + |
237 "}" | 191 "}" |
238 } | 192 } |
239 }; | 193 }; |
240 chrome.proxy.settings.set( | 194 chrome.proxy.settings.set( |
241 {value: config, scope: 'regular'}, | 195 {value: config, scope: 'regular'}, |
242 function() {}); | 196 function() {}); |
243 </pre> | 197 </pre> |
244 | 198 |
245 <p> | 199 <p> |
246 The next snippet queries the current proxy settings. | 200 The next snippet queries the currently effective proxy settings. The effective |
201 proxy settings can be determined by another extension or by a policy, see the <a | |
kathyw
2011/05/24 18:57:50
, see ->
. See
documentation. ->
documentation f
battre
2011/05/24 19:18:03
Done.
| |
202 href="preferences.html">Preferences API</a> documentation. | |
247 </p> | 203 </p> |
248 | 204 |
249 <pre> | 205 <pre> |
250 chrome.proxy.settings.getEffective( | 206 chrome.proxy.settings.getEffective( |
251 {'incognito': false}, | 207 {'incognito': false}, |
252 function(config) {console.log(JSON.stringify(config));}); | 208 function(config) {console.log(JSON.stringify(config));}); |
253 </pre> | 209 </pre> |
254 | 210 |
255 <p> | 211 <p> |
256 Note that the <code>value</code> object passed to <code>set()</code> is not | 212 Note that the <code>value</code> object passed to <code>set()</code> is not |
257 identical to the <code>value</code> object passed to callback function of | 213 identical to the <code>value</code> object passed to callback function of |
258 <code>getEffective()</code>. The latter will contain a | 214 <code>getEffective()</code>. The latter will contain a |
259 <code>rules.httpProxy.port</code> element. | 215 <code>rules.httpProxy.port</code> element. |
260 </p> | 216 </p> |
261 | 217 |
262 <!-- END AUTHORED CONTENT --> | 218 <!-- END AUTHORED CONTENT --> |
OLD | NEW |