| OLD | NEW |
| (Empty) | |
| 1 <div id="pageData-name" class="pageData">Privacy</div> |
| 2 |
| 3 <!-- BEGIN AUTHORED CONTENT --> |
| 4 <p id="classSummary"> |
| 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 |
| 7 <a href="types.html#ChromeSetting">ChromeSetting prototype of the type API</a> |
| 8 for getting and setting Chrome's configuration. |
| 9 </p> |
| 10 |
| 11 <p class="note"> |
| 12 The <a href="http://www.google.com/intl/en/landing/chrome/google-chrome-privac
y-whitepaper.pdf">Chrome Privacy Whitepaper</a> |
| 13 gives background detail regarding the features which this API can control. |
| 14 </p> |
| 15 |
| 16 <h2 id="manifest">Manifest</h2> |
| 17 <p> |
| 18 You must declare the "privacy" permission in your extension's |
| 19 <a href="manifest.html">manifest</a> to use the API. For example: |
| 20 </p> |
| 21 |
| 22 <pre>{ |
| 23 "name": "My extension", |
| 24 ... |
| 25 <b>"permissions": [ |
| 26 "privacy" |
| 27 ]</b>, |
| 28 ... |
| 29 }</pre> |
| 30 |
| 31 <h2 id="usage">Usage</h2> |
| 32 |
| 33 <p> |
| 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 |
| 36 <code>get()</code> on that object in order to retrieve it's current value and |
| 37 your extension's level of control. For example, to determine if Chrome's |
| 38 Autofill feature is enabled, you'd write: |
| 39 </p> |
| 40 |
| 41 <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) { |
| 42 if (details.value) |
| 43 console.log('Autofill is on!'); |
| 44 else |
| 45 console.log('Autofill is off!'); |
| 46 });</pre> |
| 47 |
| 48 <p> |
| 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 |
| 51 won't see any change to her settings if you extension toggles a setting that |
| 52 is either locked to a specific value by enterprise policies |
| 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 |
| 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 |
| 57 is advisable to warn the user when the settings they've chosen aren't |
| 58 practically applied. |
| 59 </p> |
| 60 |
| 61 <p class="note"> |
| 62 Full details about extensions' ability to control <code>ChromeSetting</code>s |
| 63 can be found under |
| 64 <a href="types.html#ChromeSetting"> |
| 65 <code>chrome.types.ChromeSetting</code></a>. |
| 66 </p> |
| 67 |
| 68 <p> |
| 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 |
| 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 |
| 73 reduce user confusion): |
| 74 </p> |
| 75 |
| 76 <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) { |
| 77 if (details.levelOfControl === 'controllable_by_this_extension') { |
| 78 chrome.privacy.services.autofillEnabled.set({ value: true }, function() { |
| 79 if (chrome.extension.lastError === undefined) |
| 80 console.log("Hooray, it worked!"); |
| 81 else |
| 82 console.log("Sadness!", chrome.extension.lastError); |
| 83 } |
| 84 } |
| 85 });</pre> |
| 86 |
| 87 <p> |
| 88 If you're interested in changes to a setting's value, add a listener to its |
| 89 <code>onChange</code> event. Among other uses, this will allow you to warn the |
| 90 user if a more recently installed extension grabs control of a setting, or if |
| 91 enterprise policy overrides your control. To listen for changes to Autofill's |
| 92 status, for example, the following code would suffice: |
| 93 </p> |
| 94 |
| 95 <pre>chrome.privacy.services.autofillEnabled.onChange.addListener( |
| 96 function (details) { |
| 97 // The new value is stored in `details.value`, the new level of control |
| 98 // in `details.levelOfControl`, and `details.incognitoSpecific` will be |
| 99 // `true` if the value is specific to Incognito mode. |
| 100 });</pre> |
| 101 |
| 102 <h2 id="examples">Examples</h2> |
| 103 <p> |
| 104 For example code, see the |
| 105 <a href="samples.html#privacy">Privacy API samples</a>. |
| 106 </p> |
| 107 <!-- END AUTHORED CONTENT --><div id="pageData-name" class="pageData">Privacy</d
iv> |
| 108 |
| 109 <!-- BEGIN AUTHORED CONTENT --> |
| 110 <p id="classSummary"> |
| 111 Use the <code>chrome.privacy</code> module to control usage of the features in |
| 112 Chrome that can affect a user's privacy. This module relies on the |
| 113 <a href="types.html#ChromeSetting">ChromeSetting prototype of the type API</a> |
| 114 for getting and setting Chrome's configuration. |
| 115 </p> |
| 116 |
| 117 <p class="note"> |
| 118 The <a href="http://www.google.com/intl/en/landing/chrome/google-chrome-privac
y-whitepaper.pdf">Chrome Privacy Whitepaper</a> |
| 119 gives background detail regarding the features which this API can control. |
| 120 </p> |
| 121 |
| 122 <h2 id="manifest">Manifest</h2> |
| 123 <p> |
| 124 You must declare the "privacy" permission in your extension's |
| 125 <a href="manifest.html">manifest</a> to use the API. For example: |
| 126 </p> |
| 127 |
| 128 <pre>{ |
| 129 "name": "My extension", |
| 130 ... |
| 131 <b>"permissions": [ |
| 132 "privacy" |
| 133 ]</b>, |
| 134 ... |
| 135 }</pre> |
| 136 |
| 137 <h2 id="usage">Usage</h2> |
| 138 |
| 139 <p> |
| 140 Reading the current value of a Chrome setting is straightforward. You'll first |
| 141 need to find the property you're interested in, then you'll call |
| 142 <code>get()</code> on that object in order to retrieve it's current value and |
| 143 your extension's level of control. For example, to determine if Chrome's |
| 144 Autofill feature is enabled, you'd write: |
| 145 </p> |
| 146 |
| 147 <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) { |
| 148 if (details.value) |
| 149 console.log('Autofill is on!'); |
| 150 else |
| 151 console.log('Autofill is off!'); |
| 152 });</pre> |
| 153 |
| 154 <p> |
| 155 Changing the value of a setting is a little bit more complex, simply because |
| 156 you first must verify that your extension can control the setting. The user |
| 157 won't see any change to her settings if you extension toggles a setting that |
| 158 is either locked to a specific value by enterprise policies |
| 159 (<code>levelOfControl</code> will be set to "not_controllable"), or if another |
| 160 extension is controlling the value (<code>levelOfControl</code> will be set to |
| 161 "controlled_by_other_extensions"). The <code>set()</code> call will succeed, |
| 162 but the setting will be immediately overridden. As this might be confusing, it |
| 163 is advisable to warn the user when the settings they've chosen aren't |
| 164 practically applied. |
| 165 </p> |
| 166 |
| 167 <p class="note"> |
| 168 Full details about extensions' ability to control <code>ChromeSetting</code>s |
| 169 can be found under |
| 170 <a href="types.html#ChromeSetting"> |
| 171 <code>chrome.types.ChromeSetting</code></a>. |
| 172 </p> |
| 173 |
| 174 <p> |
| 175 This means that you ought to use the <code>get()</code> method to determine |
| 176 your level of access, and then only call <code>set()</code> if your extension |
| 177 can grab control over the setting (in fact if your extension can't control the |
| 178 setting it's probably a good idea to visibly disable the functionality to |
| 179 reduce user confusion): |
| 180 </p> |
| 181 |
| 182 <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) { |
| 183 if (details.levelOfControl === 'controllable_by_this_extension') { |
| 184 chrome.privacy.services.autofillEnabled.set({ value: true }, function() { |
| 185 if (chrome.extension.lastError === undefined) |
| 186 console.log("Hooray, it worked!"); |
| 187 else |
| 188 console.log("Sadness!", chrome.extension.lastError); |
| 189 } |
| 190 } |
| 191 });</pre> |
| 192 |
| 193 <p> |
| 194 If you're interested in changes to a setting's value, add a listener to its |
| 195 <code>onChange</code> event. Among other uses, this will allow you to warn the |
| 196 user if a more recently installed extension grabs control of a setting, or if |
| 197 enterprise policy overrides your control. To listen for changes to Autofill's |
| 198 status, for example, the following code would suffice: |
| 199 </p> |
| 200 |
| 201 <pre>chrome.privacy.services.autofillEnabled.onChange.addListener( |
| 202 function (details) { |
| 203 // The new value is stored in `details.value`, the new level of control |
| 204 // in `details.levelOfControl`, and `details.incognitoSpecific` will be |
| 205 // `true` if the value is specific to Incognito mode. |
| 206 });</pre> |
| 207 |
| 208 <h2 id="examples">Examples</h2> |
| 209 <p> |
| 210 For example code, see the |
| 211 <a href="samples.html#privacy">Privacy API samples</a>. |
| 212 </p> |
| 213 <!-- END AUTHORED CONTENT --> |
| OLD | NEW |