OLD | NEW |
| (Empty) |
1 <div id="pageData-name" class="pageData">Managed Mode API</div> | |
2 | |
3 <!-- BEGIN AUTHORED CONTENT --> | |
4 <p id="classSummary"> | |
5 The <code>chrome.experimental.managedMode</code> module allows extensions to | |
6 request that the browser enter managed mode, as well as to query whether it | |
7 is currently in managed mode. | |
8 </p> | |
9 | |
10 <p class="note"> | |
11 <b>Note: </b>Extensions cannot request that the browser leave managed mode. | |
12 This must be done by the user from within the browser itself. | |
13 </p> | |
14 | |
15 <h2 id="manifest">Manifest</h2> | |
16 <p> | |
17 You must declare the "managedMode" and "experimental" permissions in your | |
18 extension's <a href="manifest.html">manifest</a> to use the API. For example: | |
19 </p> | |
20 | |
21 <pre>{ | |
22 "name": "My extension", | |
23 ... | |
24 <b>"permissions": [ | |
25 "experimental", | |
26 "managedMode" | |
27 ]</b>, | |
28 ... | |
29 }</pre> | |
30 | |
31 <h2 id="about">About Managed Mode</h2> | |
32 | |
33 <p> | |
34 Managed mode allows one person to manage the Chrome experience for another | |
35 person by pre-configuring and then locking a managed User profile. | |
36 | |
37 <span class="todo">For more information about Chrome's managed mode, see | |
38 <b>[TBD]</b>.</span> | |
39 </p> | |
40 | |
41 <h2 id="usage">Usage</h2> | |
42 | |
43 <p> | |
44 Querying managed mode is straightforward. Simply call <code>get()</code>, | |
45 providing a callback function to receive the result. For example: | |
46 </p> | |
47 | |
48 <pre>chrome.experimental.managedMode.get(function(details) { | |
49 if (details.value) | |
50 console.log('Managed mode is on.'); | |
51 else | |
52 console.log('Managed mode is off.'); | |
53 });</pre> | |
54 | |
55 <p> | |
56 Entering managed mode is a little bit more complex, because if the browser is | |
57 already in managed mode, trying to enter it again will have no effect. To | |
58 avoid confusing users, it's advisable to check whether your extension can | |
59 enter managed mode (i.e., if it is not already in effect), and visually | |
60 disable the functionality in your extension if not. You can optionally | |
61 provide a callback function to <code>enter()</code> to receive the result. | |
62 For example: | |
63 </p> | |
64 | |
65 <pre>chrome.experimental.managedMode.get(function(details) { | |
66 if (details.value) { | |
67 console.log("Managed mode is already in effect."); | |
68 } else { | |
69 chrome.experimental.managedMode.enter(function(result) { | |
70 if (chrome.extension.lastError === undefined) { | |
71 if (result.success) | |
72 console.log("Hooray, it worked!"); | |
73 else | |
74 console.log("Oops, the user changed her mind."); | |
75 } else { | |
76 console.log("Aw, snap!", chrome.extension.lastError); | |
77 } | |
78 }); | |
79 } | |
80 });</pre> | |
81 <!-- END AUTHORED CONTENT --> | |
OLD | NEW |