Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: chrome/common/extensions/docs/templates/intros/privacy.html

Issue 12223068: Fix some typos, broken links and other issues in extension docs (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // in `details.levelOfControl`, and `details.incognitoSpecific` will be 95 // in `details.levelOfControl`, and `details.incognitoSpecific` will be
96 // `true` if the value is specific to Incognito mode. 96 // `true` if the value is specific to Incognito mode.
97 });</pre> 97 });</pre>
98 98
99 <h2 id="examples">Examples</h2> 99 <h2 id="examples">Examples</h2>
100 <p> 100 <p>
101 For example code, see the 101 For example code, see the
102 <a href="samples.html#privacy">Privacy API samples</a>. 102 <a href="samples.html#privacy">Privacy API samples</a>.
103 </p> 103 </p>
104 104
105
106
107 <p id="classSummary">
108 Use the <code>chrome.privacy</code> module to control usage of the features in
109 Chrome that can affect a user's privacy. This module relies on the
110 <a href="types.html#ChromeSetting">ChromeSetting prototype of the type API</a>
111 for getting and setting Chrome's configuration.
112 </p>
113
114 <p class="note">
115 The <a href="http://www.google.com/intl/en/landing/chrome/google-chrome-privac y-whitepaper.pdf">Chrome Privacy Whitepaper</a>
116 gives background detail regarding the features which this API can control.
117 </p>
118
119 <h2 id="manifest">Manifest</h2>
120 <p>
121 You must declare the "privacy" permission in your extension's
122 <a href="manifest.html">manifest</a> to use the API. For example:
123 </p>
124
125 <pre>{
126 "name": "My extension",
127 ...
128 <b>"permissions": [
129 "privacy"
130 ]</b>,
131 ...
132 }</pre>
133
134 <h2 id="usage">Usage</h2>
135
136 <p>
137 Reading the current value of a Chrome setting is straightforward. You'll first
138 need to find the property you're interested in, then you'll call
139 <code>get()</code> on that object in order to retrieve its current value and
140 your extension's level of control. For example, to determine if Chrome's
141 Autofill feature is enabled, you'd write:
142 </p>
143
144 <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) {
145 if (details.value)
146 console.log('Autofill is on!');
147 else
148 console.log('Autofill is off!');
149 });</pre>
150
151 <p>
152 Changing the value of a setting is a little bit more complex, simply because
153 you first must verify that your extension can control the setting. The user
154 won't see any change to her settings if you extension toggles a setting that
155 is either locked to a specific value by enterprise policies
156 (<code>levelOfControl</code> will be set to "not_controllable"), or if another
157 extension is controlling the value (<code>levelOfControl</code> will be set to
158 "controlled_by_other_extensions"). The <code>set()</code> call will succeed,
159 but the setting will be immediately overridden. As this might be confusing, it
160 is advisable to warn the user when the settings they've chosen aren't
161 practically applied.
162 </p>
163
164 <p class="note">
165 Full details about extensions' ability to control <code>ChromeSetting</code>s
166 can be found under
167 <a href="types.html#ChromeSetting">
168 <code>chrome.types.ChromeSetting</code></a>.
169 </p>
170
171 <p>
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
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
176 reduce user confusion):
177 </p>
178
179 <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) {
180 if (details.levelOfControl === 'controllable_by_this_extension') {
181 chrome.privacy.services.autofillEnabled.set({ value: true }, function() {
182 if (chrome.runtime.lastError === undefined)
183 console.log("Hooray, it worked!");
184 else
185 console.log("Sadness!", chrome.runtime.lastError);
186 }
187 }
188 });</pre>
189
190 <p>
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
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
195 status, for example, the following code would suffice:
196 </p>
197
198 <pre>chrome.privacy.services.autofillEnabled.onChange.addListener(
199 function (details) {
200 // The new value is stored in `details.value`, the new level of control
201 // in `details.levelOfControl`, and `details.incognitoSpecific` will be
202 // `true` if the value is specific to Incognito mode.
203 });</pre>
204
205 <h2 id="examples">Examples</h2>
206 <p>
207 For example code, see the
208 <a href="samples.html#privacy">Privacy API samples</a>.
209 </p>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698