Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <div id="pageData-name" class="pageData">Privacy</div> | 1 <div id="pageData-name" class="pageData">Privacy</div> |
| 2 | 2 |
| 3 <!-- BEGIN AUTHORED CONTENT --> | 3 <!-- BEGIN AUTHORED CONTENT --> |
| 4 <p id="classSummary"> | 4 <p id="classSummary"> |
| 5 Use the <code>chrome.privacy</code> module to control usage of the features in | 5 Use the <code>chrome.privacy</code> module to control usage of the features in |
| 6 Chrome that can affect a user's privacy. This module relies on the | 6 Chrome that can affect a user's privacy. This module relies on the |
| 7 <a href="types.html#ChromeSetting">ChromeSetting prototype of the type API</a> | 7 <a href="types.html#ChromeSetting">ChromeSetting prototype of the type API</a> |
| 8 for getting and setting Chrome's configuration. | 8 for getting and setting Chrome's configuration. |
| 9 </p> | 9 </p> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 "privacy" | 26 "privacy" |
| 27 ]</b>, | 27 ]</b>, |
| 28 ... | 28 ... |
| 29 }</pre> | 29 }</pre> |
| 30 | 30 |
| 31 <h2 id="usage">Usage</h2> | 31 <h2 id="usage">Usage</h2> |
| 32 | 32 |
| 33 <p> | 33 <p> |
| 34 Reading the current value of a Chrome setting is straightforward. You'll first | 34 Reading the current value of a Chrome setting is straightforward. You'll first |
| 35 need to find the property you're interested in, then you'll call | 35 need to find the property you're interested in, then you'll call |
| 36 <code>get()</code> on that object in order to retrieve it's current value and | 36 <code>get()</code> on that object in order to retrieve its current value and |
| 37 your extension's level of control. For example, to determine if Chrome's | 37 your extension's level of control. For example, to determine if Chrome's |
| 38 Autofill feature is enabled, you'd write: | 38 Autofill feature is enabled, you'd write: |
| 39 </p> | 39 </p> |
| 40 | 40 |
| 41 <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) { | 41 <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) { |
| 42 if (details.value) | 42 if (details.value) |
| 43 console.log('Autofill is on!'); | 43 console.log('Autofill is on!'); |
| 44 else | 44 else |
| 45 console.log('Autofill is off!'); | 45 console.log('Autofill is off!'); |
| 46 });</pre> | 46 });</pre> |
| 47 | 47 |
| 48 <p> | 48 <p> |
| 49 Changing the value of a setting is a little bit more complex, simply because | 49 Changing the value of a setting is a little bit more complex, simply because |
| 50 you first must verify that your extension can control the setting. The user | 50 you first must verify that your extension can control the setting. The user |
| 51 won't see any change to her settings if you extension toggles a setting that | 51 won't see any change to her settings if your extension toggles a setting that |
| 52 is either locked to a specific value by enterprise policies | 52 is either locked to a specific value by enterprise policies |
| 53 (<code>levelOfControl</code> will be set to "not_controllable"), or if another | 53 (<code>levelOfControl</code> will be set to "not_controllable"), or if another |
| 54 extension is controlling the value (<code>levelOfControl</code> will be set to | 54 extension is controlling the value (<code>levelOfControl</code> will be set to |
| 55 "controlled_by_other_extensions"). The <code>set()</code> call will succeed, | 55 "controlled_by_other_extensions"). The <code>set()</code> call will succeed, |
| 56 but the setting will be immediately overridden. As this might be confusing, it | 56 but the setting will be immediately overridden. As this might be confusing, it |
| 57 is advisable to warn the user when the settings they've chosen aren't | 57 is advisable to warn the user when the settings they've chosen aren't |
| 58 practically applied. | 58 practically applied. |
| 59 </p> | 59 </p> |
| 60 | 60 |
| 61 <p class="note"> | 61 <p class="note"> |
| 62 Full details about extensions' ability to control <code>ChromeSetting</code>s | 62 Full details about extensions' ability to control <code>ChromeSetting</code>s |
| 63 can be found under | 63 can be found under |
| 64 <a href="types.html#ChromeSetting"> | 64 <a href="types.html#ChromeSetting"> |
| 65 <code>chrome.types.ChromeSetting</code></a>. | 65 <code>chrome.types.ChromeSetting</code></a>. |
| 66 </p> | 66 </p> |
| 67 | 67 |
| 68 <p> | 68 <p> |
| 69 This means that you ought to use the <code>get()</code> method to determine | 69 This means that you ought to use the <code>get()</code> method to determine |
| 70 your level of access, and then only call <code>set()</code> if your extension | 70 your level of access, and then only call <code>set()</code> if your extension |
| 71 can grab control over the setting (in fact if your extension can't control the | 71 can grab control over the setting (in fact if your extension can't control the |
| 72 setting it's probably a good idea to visibly disable the functionality to | 72 setting it's probably a good idea to visually disable the functionality to |
|
Mike West
2012/03/05 13:14:03
I don't think this is a typo, but I'm fine with th
| |
| 73 reduce user confusion): | 73 reduce user confusion): |
| 74 </p> | 74 </p> |
| 75 | 75 |
| 76 <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) { | 76 <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) { |
| 77 if (details.levelOfControl === 'controllable_by_this_extension') { | 77 if (details.levelOfControl === 'controllable_by_this_extension') { |
| 78 chrome.privacy.services.autofillEnabled.set({ value: true }, function() { | 78 chrome.privacy.services.autofillEnabled.set({ value: true }, function() { |
| 79 if (chrome.extension.lastError === undefined) | 79 if (chrome.extension.lastError === undefined) |
| 80 console.log("Hooray, it worked!"); | 80 console.log("Hooray, it worked!"); |
| 81 else | 81 else |
| 82 console.log("Sadness!", chrome.extension.lastError); | 82 console.log("Sadness!", chrome.extension.lastError); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 // in `details.levelOfControl`, and `details.incognitoSpecific` will be | 204 // in `details.levelOfControl`, and `details.incognitoSpecific` will be |
| 205 // `true` if the value is specific to Incognito mode. | 205 // `true` if the value is specific to Incognito mode. |
| 206 });</pre> | 206 });</pre> |
| 207 | 207 |
| 208 <h2 id="examples">Examples</h2> | 208 <h2 id="examples">Examples</h2> |
| 209 <p> | 209 <p> |
| 210 For example code, see the | 210 For example code, see the |
| 211 <a href="samples.html#privacy">Privacy API samples</a>. | 211 <a href="samples.html#privacy">Privacy API samples</a>. |
| 212 </p> | 212 </p> |
| 213 <!-- END AUTHORED CONTENT --> | 213 <!-- END AUTHORED CONTENT --> |
| OLD | NEW |