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