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

Side by Side Diff: chrome/common/extensions/docs/server2/templates/private/privacy_intro.html

Issue 10750017: Extensions Docs Server: Intro data source (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 8 years, 5 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
(Empty)
1 <!-- BEGIN AUTHORED CONTENT -->
2 <p id="classSummary">
3 Use the <code>chrome.privacy</code> module to control usage of the features in
4 Chrome that can affect a user's privacy. This module relies on the
5 <a href="types.html#ChromeSetting">ChromeSetting prototype of the type API</a>
6 for getting and setting Chrome's configuration.
7 </p>
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>
10 gives background detail regarding the features which this API can control.
11 </p>
12 <h2 id="manifest">Manifest</h2>
13 <p>
14 You must declare the "privacy" permission in your extension's
15 <a href="manifest.html">manifest</a> to use the API. For example:
16 </p>
17 <pre>{
18 "name": "My extension",
19 ...
20 <b>"permissions": [
21 "privacy"
22 ]</b>,
23 ...
24 }</pre>
25 <h2 id="usage">Usage</h2>
26 <p>
27 Reading the current value of a Chrome setting is straightforward. You'll first
28 need to find the property you're interested in, then you'll call
29 <code>get()</code> on that object in order to retrieve its current value and
30 your extension's level of control. For example, to determine if Chrome's
31 Autofill feature is enabled, you'd write:
32 </p>
33 <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) {
34 if (details.value)
35 console.log('Autofill is on!');
36 else
37 console.log('Autofill is off!');
38 });</pre>
39 <p>
40 Changing the value of a setting is a little bit more complex, simply because
41 you first must verify that your extension can control the setting. The user
42 won't see any change to her settings if your extension toggles a setting that
43 is either locked to a specific value by enterprise policies
44 (<code>levelOfControl</code> will be set to "not_controllable"), or if another
45 extension is controlling the value (<code>levelOfControl</code> will be set to
46 "controlled_by_other_extensions"). The <code>set()</code> call will succeed,
47 but the setting will be immediately overridden. As this might be confusing, it
48 is advisable to warn the user when the settings they've chosen aren't
49 practically applied.
50 </p>
51 <p class="note">
52 Full details about extensions' ability to control <code>ChromeSetting</code>s
53 can be found under
54 <a href="types.html#ChromeSetting">
55 <code>chrome.types.ChromeSetting</code></a>.
56 </p>
57 <p>
58 This means that you ought to use the <code>get()</code> method to determine
59 your level of access, and then only call <code>set()</code> if your extension
60 can grab control over the setting (in fact if your extension can't control the
61 setting it's probably a good idea to visually disable the functionality to
62 reduce user confusion):
63 </p>
64 <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) {
65 if (details.levelOfControl === 'controllable_by_this_extension') {
66 chrome.privacy.services.autofillEnabled.set({ value: true }, function() {
67 if (chrome.extension.lastError === undefined)
68 console.log("Hooray, it worked!");
69 else
70 console.log("Sadness!", chrome.extension.lastError);
71 }
72 }
73 });</pre>
74 <p>
75 If you're interested in changes to a setting's value, add a listener to its
76 <code>onChange</code> event. Among other uses, this will allow you to warn the
77 user if a more recently installed extension grabs control of a setting, or if
78 enterprise policy overrides your control. To listen for changes to Autofill's
79 status, for example, the following code would suffice:
80 </p>
81 <pre>chrome.privacy.services.autofillEnabled.onChange.addListener(
82 function (details) {
83 // The new value is stored in `details.value`, the new level of control
84 // in `details.levelOfControl`, and `details.incognitoSpecific` will be
85 // `true` if the value is specific to Incognito mode.
86 });</pre>
87 <h2 id="examples">Examples</h2>
88 <p>
89 For example code, see the
90 <a href="samples.html#privacy">Privacy API samples</a>.
91 </p>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698