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.experimental.proxysettings</code> module to manage Chrome's | 5 Use the <code>chrome.proxy</code> module to manage Chrome's |
6 proxy settings. This module is still experimental. For information on how to use | 6 proxy settings. |
7 experimental APIs, see the <a href="experimental.html">chrome.experimental.* | |
8 APIs</a> page. | |
9 </p> | 7 </p> |
10 | 8 |
11 <h2 id="manifest">Manifest</h2> | 9 <h2 id="manifest">Manifest</h2> |
12 <p>You must declare the "proxy" permission | 10 <p>You must declare the "proxy" permission |
13 in the <a href="manifest.html">extension manifest</a> | 11 in the <a href="manifest.html">extension manifest</a> |
14 to use the proxy settings API. | 12 to use the proxy settings API. |
15 For example:</p> | 13 For example:</p> |
16 <pre>{ | 14 <pre>{ |
17 "name": "My extension", | 15 "name": "My extension", |
18 ... | 16 ... |
19 <b>"permissions": [ | 17 <b>"permissions": [ |
20 "experimental", "proxy" | 18 "proxy" |
21 ]</b>, | 19 ]</b>, |
22 ... | 20 ... |
23 }</pre> | 21 }</pre> |
24 | 22 |
25 <h2 id="description">Objects and properties</h2> | 23 <h2 id="description">Objects and properties</h2> |
26 | 24 |
27 <p> | 25 <p> |
28 Proxy settings are defined in a | 26 Proxy settings are defined in a |
29 <a href="#type-ProxyConfig"><code>ProxyConfig</code></a> object. Depending on | 27 <a href="#type-ProxyConfig"><code>ProxyConfig</code></a> object. Depending on |
30 Chrome's proxy settings, the settings may contain | 28 Chrome's proxy settings, the settings may contain |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 | 131 |
134 <dt><code>[<em><scheme></em>://]<em><ip-literal></em>[:<em><por t></em>]</code></dt> | 132 <dt><code>[<em><scheme></em>://]<em><ip-literal></em>[:<em><por t></em>]</code></dt> |
135 <dd>Match URLs that are IP address literals.<br> | 133 <dd>Match URLs that are IP address literals.<br> |
136 Conceptually this is the similar to the first case, but with special cases | 134 Conceptually this is the similar to the first case, but with special cases |
137 to handle IP literal canonicalization. For example, matching | 135 to handle IP literal canonicalization. For example, matching |
138 on "[0:0:0::1]" is the same as matching on "[::1]" because | 136 on "[0:0:0::1]" is the same as matching on "[::1]" because |
139 the IPv6 canonicalization is done internally.<br> | 137 the IPv6 canonicalization is done internally.<br> |
140 Examples: <code>"127.0.1", "[0:0::1]", "[::1]", "http://[::1]:99"</code></dd> | 138 Examples: <code>"127.0.1", "[0:0::1]", "[::1]", "http://[::1]:99"</code></dd> |
141 | 139 |
142 <dt><code><em><ip-literal></em>/<em><prefix-length-in-bits></em></ code></dt> | 140 <dt><code><em><ip-literal></em>/<em><prefix-length-in-bits></em></ code></dt> |
143 <dd>Match any URL containing an IP literal within the given range. The IP | 141 <dd>Match any URL containing an IP literal within the given range. The IP |
144 range is specified using CIDR notation.<br> | 142 range is specified using CIDR notation.<br> |
145 Examples: <code>"192.168.1.1/16", "fefe:13::abc/33"</code></dd> | 143 Examples: <code>"192.168.1.1/16", "fefe:13::abc/33"</code></dd> |
146 | 144 |
147 <dt><code><local></code></dt> | 145 <dt><code><local></code></dt> |
148 <dd>Match local addresses. An address is local if the host is "127.0.0.1", | 146 <dd>Match local addresses. An address is local if the host is "127.0.0.1", |
149 "::1", or "localhost".<br> | 147 "::1", or "localhost".<br> |
150 Example: <code>"<local>"</code></dd> | 148 Example: <code>"<local>"</code></dd> |
151 </dl> | 149 </dl> |
152 | 150 |
153 | 151 |
154 <h2 id="precedence">Precedence</h2> | 152 <h2 id="precedence">Precedence</h2> |
155 | 153 |
156 <p> | 154 <p> |
157 Chrome manages settings on different layers. The following list describes the | 155 Chrome manages settings on different layers. The following list describes the |
158 layers that may influence the effective proxy settings, in increasing order of | 156 layers that may influence the effective proxy settings, in increasing order of |
159 precedence. | 157 precedence. |
160 <ol> | 158 <ol> |
161 <li>System settings provided by the operating system</li> | 159 <li>System settings provided by the operating system</li> |
162 <li>Command line parameters</li> | 160 <li>Command line parameters</li> |
163 <li>Preferences set by extensions</li> | 161 <li>Preferences set by extensions</li> |
164 <li>Policies</li> | 162 <li>Policies</li> |
165 </ol> | 163 </ol> |
166 </p> | 164 </p> |
167 | 165 |
168 <p> | 166 <p> |
169 As the list implies, policies might overrule any changes that you specify with | 167 As the list implies, policies might overrule any changes that you specify with |
170 the proxy settings API. | 168 the proxy settings API. |
171 </p> | 169 </p> |
172 | 170 |
171 <!-- | |
173 <p> | 172 <p> |
174 Chrome allows using different proxy settings for regular windows and incognito | 173 Chrome allows using different proxy settings for regular windows and incognito |
175 windows. The following example illustrates the behavior. Assume that no policy | 174 windows. The following example illustrates the behavior. Assume that no policy |
176 overrides the proxy settings and that an extension can set proxy settings for | 175 overrides the proxy settings and that an extension can set proxy settings for |
177 regular windows <b>(R)</b> and proxy settings for incognito windows <b>(I)</b>. | 176 regular windows <b>(R)</b> and proxy settings for incognito windows <b>(I)</b>. |
178 </p> | 177 </p> |
179 | 178 |
180 <p> | 179 <p> |
181 <ul> | 180 <ul> |
182 <li>If only <b>(R)</b> is set, these settings are effective for both regular | 181 <li>If only <b>(R)</b> is set, these settings are effective for both regular |
183 and incognito windows.</li> | 182 and incognito windows.</li> |
184 <li>If only <b>(I)</b> is set, these settings are effective for only incognito | 183 <li>If only <b>(I)</b> is set, these settings are effective for only incognito |
185 windows. Regular windows use the proxy settings determined by the lower layers | 184 windows. Regular windows use the proxy settings determined by the lower layers |
186 (command-line options and system settings).</li> | 185 (command-line options and system settings).</li> |
187 <li>If both <b>(R)</b> and <b>(I)</b> are set, the respective settings are | 186 <li>If both <b>(R)</b> and <b>(I)</b> are set, the respective settings are |
188 used for regular and incognito windows.</li> | 187 used for regular and incognito windows.</li> |
189 </ul> | 188 </ul> |
190 </p> | 189 </p> |
191 | 190 |
192 <p> | 191 <p> |
193 If two extensions want to set proxy settings, the extension installed last takes | 192 If two extensions want to set proxy settings, the extension installed last takes |
194 precedence over the other extensions. If the extension installed last sets only | 193 precedence over the other extensions. If the extension installed last sets only |
195 <b>(I)</b>, the settings of regular windows can be defined by more recently | 194 <b>(I)</b>, the settings of regular windows can be defined by more recently |
196 installed extensions. | 195 installed extensions. |
197 </p> | 196 </p> |
197 --> | |
198 | 198 |
199 | 199 |
200 | 200 |
201 <h2 id="overview-examples">Examples</h2> | 201 <h2 id="overview-examples">Examples</h2> |
202 | 202 |
203 <p> | 203 <p> |
204 The following code sets a SOCKS 5 proxy for HTTP connections to all servers but | 204 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 | 205 foobar.com and uses direct connections for all other protocols. The settings |
206 apply to regular and incognito windows. | 206 apply to regular and incognito windows. |
207 </p> | 207 </p> |
208 | 208 |
209 <pre> | 209 <pre> |
210 var config = { | 210 var config = { |
211 mode: "fixed_servers", | 211 mode: "fixed_servers", |
212 rules: { | 212 rules: { |
213 httpProxy: { | 213 httpProxy: { |
214 scheme: "socks5", | 214 scheme: "socks5", |
215 host: "1.2.3.4" | 215 host: "1.2.3.4" |
216 }, | 216 }, |
217 bypassList: ["foobar.com"] | 217 bypassList: ["foobar.com"] |
218 } | 218 } |
219 }; | 219 }; |
220 chrome.experimental.proxy.settings.set( | 220 chrome.proxy.settings.set( |
221 {value: config, scope: 'regular'}, | 221 {value: config, scope: 'regular'}, |
222 function() {}); | 222 function() {}); |
223 </pre> | 223 </pre> |
224 | 224 |
225 <p> | 225 <p> |
226 The following code sets a custom pac script. | 226 The following code sets a custom pac script. |
227 </p> | 227 </p> |
228 | 228 |
229 <pre> | 229 <pre> |
230 var config = { | 230 var config = { |
231 mode: "pac_script", | 231 mode: "pac_script", |
232 pacScript: { | 232 pacScript: { |
233 data: "function FindProxyForURL(url, host) {\n" + | 233 data: "function FindProxyForURL(url, host) {\n" + |
234 " if (host == 'foobar.com')\n" + | 234 " if (host == 'foobar.com')\n" + |
235 " return 'PROXY blackhole:80';\n" + | 235 " return 'PROXY blackhole:80';\n" + |
236 " return 'DIRECT';\n" + | 236 " return 'DIRECT';\n" + |
237 "}" | 237 "}" |
238 } | 238 } |
239 }; | 239 }; |
240 chrome.experimental.proxy.settings.set( | 240 chrome.proxy.settings.set( |
241 {value: config, scope: 'regular'}, | 241 {value: config, scope: 'regular'}, |
242 function() {}); | 242 function() {}); |
243 </pre> | 243 </pre> |
244 | 244 |
245 <p> | 245 <p> |
246 The next snippet queries the current proxy settings. | 246 The next snippet queries the current proxy settings. |
247 </p> | 247 </p> |
248 | 248 |
249 <pre> | 249 <pre> |
250 chrome.experimental.proxy.settings.get( | 250 chrome.proxy.settings.getEffective( |
251 {'incognito': false}, | 251 {'incognito': false}, |
Matt Perry
2011/05/24 18:15:30
this sample code is out of date, right?
battre
2011/05/24 18:22:53
in my opinion, getEffective should continue to hav
| |
252 function(config) {console.log(JSON.stringify(config));}); | 252 function(config) {console.log(JSON.stringify(config));}); |
253 </pre> | 253 </pre> |
254 | 254 |
255 <p> | 255 <p> |
256 Note that the <code>value</code> object passed to <code>set()</code> is not | 256 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 | 257 identical to the <code>value</code> object passed to callback function of |
258 <code>get()</code>. The latter will contain a <code>rules.httpProxy.port</code> | 258 <code>getEffective()</code>. The latter will contain a |
259 element. | 259 <code>rules.httpProxy.port</code> element. |
260 </p> | 260 </p> |
261 | 261 |
262 <!-- END AUTHORED CONTENT --> | 262 <!-- END AUTHORED CONTENT --> |
OLD | NEW |