OLD | NEW |
1 <!DOCTYPE html><!-- This page is a placeholder for generated extensions api doc.
Note: | 1 <!DOCTYPE html><!-- This page is a placeholder for generated extensions api doc.
Note: |
2 1) The <head> information in this page is significant, should be uniform | 2 1) The <head> information in this page is significant, should be uniform |
3 across api docs and should be edited only with knowledge of the | 3 across api docs and should be edited only with knowledge of the |
4 templating mechanism. | 4 templating mechanism. |
5 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a | 5 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a |
6 browser, it will be re-generated from the template, json schema and | 6 browser, it will be re-generated from the template, json schema and |
7 authored overview content. | 7 authored overview content. |
8 4) The <body>.innerHTML is also generated by an offline step so that this | 8 4) The <body>.innerHTML is also generated by an offline step so that this |
9 page may easily be indexed by search engines. | 9 page may easily be indexed by search engines. |
10 --><html xmlns="http://www.w3.org/1999/xhtml"><head> | 10 --><html xmlns="http://www.w3.org/1999/xhtml"><head> |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 ... | 258 ... |
259 <b>"permissions": [ | 259 <b>"permissions": [ |
260 "privacy" | 260 "privacy" |
261 ]</b>, | 261 ]</b>, |
262 ... | 262 ... |
263 }</pre> | 263 }</pre> |
264 <h2 id="usage">Usage</h2> | 264 <h2 id="usage">Usage</h2> |
265 <p> | 265 <p> |
266 Reading the current value of a Chrome setting is straightforward. You'll first | 266 Reading the current value of a Chrome setting is straightforward. You'll first |
267 need to find the property you're interested in, then you'll call | 267 need to find the property you're interested in, then you'll call |
268 <code>get()</code> on that object in order to retrieve it's current value and | 268 <code>get()</code> on that object in order to retrieve its current value and |
269 your extension's level of control. For example, to determine if Chrome's | 269 your extension's level of control. For example, to determine if Chrome's |
270 Autofill feature is enabled, you'd write: | 270 Autofill feature is enabled, you'd write: |
271 </p> | 271 </p> |
272 <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) { | 272 <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) { |
273 if (details.value) | 273 if (details.value) |
274 console.log('Autofill is on!'); | 274 console.log('Autofill is on!'); |
275 else | 275 else |
276 console.log('Autofill is off!'); | 276 console.log('Autofill is off!'); |
277 });</pre> | 277 });</pre> |
278 <p> | 278 <p> |
279 Changing the value of a setting is a little bit more complex, simply because | 279 Changing the value of a setting is a little bit more complex, simply because |
280 you first must verify that your extension can control the setting. The user | 280 you first must verify that your extension can control the setting. The user |
281 won't see any change to her settings if you extension toggles a setting that | 281 won't see any change to her settings if your extension toggles a setting that |
282 is either locked to a specific value by enterprise policies | 282 is either locked to a specific value by enterprise policies |
283 (<code>levelOfControl</code> will be set to "not_controllable"), or if another | 283 (<code>levelOfControl</code> will be set to "not_controllable"), or if another |
284 extension is controlling the value (<code>levelOfControl</code> will be set to | 284 extension is controlling the value (<code>levelOfControl</code> will be set to |
285 "controlled_by_other_extensions"). The <code>set()</code> call will succeed, | 285 "controlled_by_other_extensions"). The <code>set()</code> call will succeed, |
286 but the setting will be immediately overridden. As this might be confusing, it | 286 but the setting will be immediately overridden. As this might be confusing, it |
287 is advisable to warn the user when the settings they've chosen aren't | 287 is advisable to warn the user when the settings they've chosen aren't |
288 practically applied. | 288 practically applied. |
289 </p> | 289 </p> |
290 <p class="note"> | 290 <p class="note"> |
291 Full details about extensions' ability to control <code>ChromeSetting</code>s | 291 Full details about extensions' ability to control <code>ChromeSetting</code>s |
292 can be found under | 292 can be found under |
293 <a href="types.html#ChromeSetting"> | 293 <a href="types.html#ChromeSetting"> |
294 <code>chrome.types.ChromeSetting</code></a>. | 294 <code>chrome.types.ChromeSetting</code></a>. |
295 </p> | 295 </p> |
296 <p> | 296 <p> |
297 This means that you ought to use the <code>get()</code> method to determine | 297 This means that you ought to use the <code>get()</code> method to determine |
298 your level of access, and then only call <code>set()</code> if your extension | 298 your level of access, and then only call <code>set()</code> if your extension |
299 can grab control over the setting (in fact if your extension can't control the | 299 can grab control over the setting (in fact if your extension can't control the |
300 setting it's probably a good idea to visibly disable the functionality to | 300 setting it's probably a good idea to visually disable the functionality to |
301 reduce user confusion): | 301 reduce user confusion): |
302 </p> | 302 </p> |
303 <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) { | 303 <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) { |
304 if (details.levelOfControl === 'controllable_by_this_extension') { | 304 if (details.levelOfControl === 'controllable_by_this_extension') { |
305 chrome.privacy.services.autofillEnabled.set({ value: true }, function() { | 305 chrome.privacy.services.autofillEnabled.set({ value: true }, function() { |
306 if (chrome.extension.lastError === undefined) | 306 if (chrome.extension.lastError === undefined) |
307 console.log("Hooray, it worked!"); | 307 console.log("Hooray, it worked!"); |
308 else | 308 else |
309 console.log("Sadness!", chrome.extension.lastError); | 309 console.log("Sadness!", chrome.extension.lastError); |
310 } | 310 } |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 _uff=0; | 801 _uff=0; |
802 urchinTracker(); | 802 urchinTracker(); |
803 } | 803 } |
804 catch(e) {/* urchinTracker not available. */} | 804 catch(e) {/* urchinTracker not available. */} |
805 </script> | 805 </script> |
806 <!-- end analytics --> | 806 <!-- end analytics --> |
807 </div> | 807 </div> |
808 </div> <!-- /gc-footer --> | 808 </div> <!-- /gc-footer --> |
809 </div> <!-- /gc-container --> | 809 </div> <!-- /gc-container --> |
810 </body></html> | 810 </body></html> |
OLD | NEW |