| OLD | NEW |
| 1 <p id="classSummary"> | 1 <p id="classSummary"> |
| 2 Use the <code>chrome.privacy</code> module to control usage of the features in | 2 Use the <code>chrome.privacy</code> module to control usage of the features in |
| 3 Chrome that can affect a user's privacy. This module relies on the | 3 Chrome that can affect a user's privacy. This module relies on the |
| 4 <a href="types.html#ChromeSetting">ChromeSetting prototype of the type API</a> | 4 <a href="types.html#ChromeSetting">ChromeSetting prototype of the type API</a> |
| 5 for getting and setting Chrome's configuration. | 5 for getting and setting Chrome's configuration. |
| 6 </p> | 6 </p> |
| 7 | 7 |
| 8 <p class="note"> | 8 <p class="note"> |
| 9 The <a href="http://www.google.com/intl/en/landing/chrome/google-chrome-privac
y-whitepaper.pdf">Chrome Privacy Whitepaper</a> | 9 The <a href="http://www.google.com/intl/en/landing/chrome/google-chrome-privac
y-whitepaper.pdf">Chrome Privacy Whitepaper</a> |
| 10 gives background detail regarding the features which this API can control. | 10 gives background detail regarding the features which this API can control. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 This means that you ought to use the <code>get()</code> method to determine | 66 This means that you ought to use the <code>get()</code> method to determine |
| 67 your level of access, and then only call <code>set()</code> if your extension | 67 your level of access, and then only call <code>set()</code> if your extension |
| 68 can grab control over the setting (in fact if your extension can't control the | 68 can grab control over the setting (in fact if your extension can't control the |
| 69 setting it's probably a good idea to visually disable the functionality to | 69 setting it's probably a good idea to visually disable the functionality to |
| 70 reduce user confusion): | 70 reduce user confusion): |
| 71 </p> | 71 </p> |
| 72 | 72 |
| 73 <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) { | 73 <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) { |
| 74 if (details.levelOfControl === 'controllable_by_this_extension') { | 74 if (details.levelOfControl === 'controllable_by_this_extension') { |
| 75 chrome.privacy.services.autofillEnabled.set({ value: true }, function() { | 75 chrome.privacy.services.autofillEnabled.set({ value: true }, function() { |
| 76 if (chrome.extension.lastError === undefined) | 76 if (chrome.runtime.lastError === undefined) |
| 77 console.log("Hooray, it worked!"); | 77 console.log("Hooray, it worked!"); |
| 78 else | 78 else |
| 79 console.log("Sadness!", chrome.extension.lastError); | 79 console.log("Sadness!", chrome.runtime.lastError); |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 });</pre> | 82 });</pre> |
| 83 | 83 |
| 84 <p> | 84 <p> |
| 85 If you're interested in changes to a setting's value, add a listener to its | 85 If you're interested in changes to a setting's value, add a listener to its |
| 86 <code>onChange</code> event. Among other uses, this will allow you to warn the | 86 <code>onChange</code> event. Among other uses, this will allow you to warn the |
| 87 user if a more recently installed extension grabs control of a setting, or if | 87 user if a more recently installed extension grabs control of a setting, or if |
| 88 enterprise policy overrides your control. To listen for changes to Autofill's | 88 enterprise policy overrides your control. To listen for changes to Autofill's |
| 89 status, for example, the following code would suffice: | 89 status, for example, the following code would suffice: |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 This means that you ought to use the <code>get()</code> method to determine | 172 This means that you ought to use the <code>get()</code> method to determine |
| 173 your level of access, and then only call <code>set()</code> if your extension | 173 your level of access, and then only call <code>set()</code> if your extension |
| 174 can grab control over the setting (in fact if your extension can't control the | 174 can grab control over the setting (in fact if your extension can't control the |
| 175 setting it's probably a good idea to visibly disable the functionality to | 175 setting it's probably a good idea to visibly disable the functionality to |
| 176 reduce user confusion): | 176 reduce user confusion): |
| 177 </p> | 177 </p> |
| 178 | 178 |
| 179 <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) { | 179 <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) { |
| 180 if (details.levelOfControl === 'controllable_by_this_extension') { | 180 if (details.levelOfControl === 'controllable_by_this_extension') { |
| 181 chrome.privacy.services.autofillEnabled.set({ value: true }, function() { | 181 chrome.privacy.services.autofillEnabled.set({ value: true }, function() { |
| 182 if (chrome.extension.lastError === undefined) | 182 if (chrome.runtime.lastError === undefined) |
| 183 console.log("Hooray, it worked!"); | 183 console.log("Hooray, it worked!"); |
| 184 else | 184 else |
| 185 console.log("Sadness!", chrome.extension.lastError); | 185 console.log("Sadness!", chrome.runtime.lastError); |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 });</pre> | 188 });</pre> |
| 189 | 189 |
| 190 <p> | 190 <p> |
| 191 If you're interested in changes to a setting's value, add a listener to its | 191 If you're interested in changes to a setting's value, add a listener to its |
| 192 <code>onChange</code> event. Among other uses, this will allow you to warn the | 192 <code>onChange</code> event. Among other uses, this will allow you to warn the |
| 193 user if a more recently installed extension grabs control of a setting, or if | 193 user if a more recently installed extension grabs control of a setting, or if |
| 194 enterprise policy overrides your control. To listen for changes to Autofill's | 194 enterprise policy overrides your control. To listen for changes to Autofill's |
| 195 status, for example, the following code would suffice: | 195 status, for example, the following code would suffice: |
| 196 </p> | 196 </p> |
| 197 | 197 |
| 198 <pre>chrome.privacy.services.autofillEnabled.onChange.addListener( | 198 <pre>chrome.privacy.services.autofillEnabled.onChange.addListener( |
| 199 function (details) { | 199 function (details) { |
| 200 // The new value is stored in `details.value`, the new level of control | 200 // The new value is stored in `details.value`, the new level of control |
| 201 // in `details.levelOfControl`, and `details.incognitoSpecific` will be | 201 // in `details.levelOfControl`, and `details.incognitoSpecific` will be |
| 202 // `true` if the value is specific to Incognito mode. | 202 // `true` if the value is specific to Incognito mode. |
| 203 });</pre> | 203 });</pre> |
| 204 | 204 |
| 205 <h2 id="examples">Examples</h2> | 205 <h2 id="examples">Examples</h2> |
| 206 <p> | 206 <p> |
| 207 For example code, see the | 207 For example code, see the |
| 208 <a href="samples.html#privacy">Privacy API samples</a>. | 208 <a href="samples.html#privacy">Privacy API samples</a>. |
| 209 </p> | 209 </p> |
| OLD | NEW |