OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 cr.define('options', function() { | 5 cr.define('options', function() { |
6 var OptionsPage = options.OptionsPage; | 6 var OptionsPage = options.OptionsPage; |
7 | 7 |
8 /** | 8 /** |
9 * ManagedUserCreateConfirm class. | 9 * SupervisedUserCreateConfirm class. |
10 * Encapsulated handling of the confirmation overlay page when creating a | 10 * Encapsulated handling of the confirmation overlay page when creating a |
11 * managed user. | 11 * supervised user. |
12 * @constructor | 12 * @constructor |
13 * @class | 13 * @class |
14 */ | 14 */ |
15 function ManagedUserCreateConfirmOverlay() { | 15 function SupervisedUserCreateConfirmOverlay() { |
16 OptionsPage.call(this, 'managedUserCreateConfirm', | 16 OptionsPage.call(this, 'supervisedUserCreateConfirm', |
17 '', // The title will be based on the new profile name. | 17 '', // The title will be based on the new profile name. |
18 'managed-user-created'); | 18 'supervised-user-created'); |
19 }; | 19 }; |
20 | 20 |
21 cr.addSingletonGetter(ManagedUserCreateConfirmOverlay); | 21 cr.addSingletonGetter(SupervisedUserCreateConfirmOverlay); |
22 | 22 |
23 ManagedUserCreateConfirmOverlay.prototype = { | 23 SupervisedUserCreateConfirmOverlay.prototype = { |
24 // Inherit from OptionsPage. | 24 // Inherit from OptionsPage. |
25 __proto__: OptionsPage.prototype, | 25 __proto__: OptionsPage.prototype, |
26 | 26 |
27 // Info about the newly created profile. | 27 // Info about the newly created profile. |
28 profileInfo_: null, | 28 profileInfo_: null, |
29 | 29 |
30 /** @override */ | 30 /** @override */ |
31 initializePage: function() { | 31 initializePage: function() { |
32 OptionsPage.prototype.initializePage.call(this); | 32 OptionsPage.prototype.initializePage.call(this); |
33 | 33 |
34 $('managed-user-created-done').onclick = function(event) { | 34 $('supervised-user-created-done').onclick = function(event) { |
35 OptionsPage.closeOverlay(); | 35 OptionsPage.closeOverlay(); |
36 }; | 36 }; |
37 | 37 |
38 var self = this; | 38 var self = this; |
39 | 39 |
40 $('managed-user-created-switch').onclick = function(event) { | 40 $('supervised-user-created-switch').onclick = function(event) { |
41 OptionsPage.closeOverlay(); | 41 OptionsPage.closeOverlay(); |
42 chrome.send('switchToProfile', [self.profileInfo_.filePath]); | 42 chrome.send('switchToProfile', [self.profileInfo_.filePath]); |
43 }; | 43 }; |
44 }, | 44 }, |
45 | 45 |
46 /** @override */ | 46 /** @override */ |
47 didShowPage: function() { | 47 didShowPage: function() { |
48 $('managed-user-created-switch').focus(); | 48 $('supervised-user-created-switch').focus(); |
49 }, | 49 }, |
50 | 50 |
51 /** | 51 /** |
52 * Sets the profile info used in the dialog and updates the profile name | 52 * Sets the profile info used in the dialog and updates the profile name |
53 * displayed. Called by the profile creation overlay when this overlay is | 53 * displayed. Called by the profile creation overlay when this overlay is |
54 * opened. | 54 * opened. |
55 * @param {Object} info An object of the form: | 55 * @param {Object} info An object of the form: |
56 * info = { | 56 * info = { |
57 * name: "Profile Name", | 57 * name: "Profile Name", |
58 * filePath: "/path/to/profile/data/on/disk", | 58 * filePath: "/path/to/profile/data/on/disk", |
59 * isManaged: (true|false) | 59 * isSupervised: (true|false) |
60 * custodianEmail: "example@gmail.com" | 60 * custodianEmail: "example@gmail.com" |
61 * }; | 61 * }; |
62 * @private | 62 * @private |
63 */ | 63 */ |
64 setProfileInfo_: function(info) { | 64 setProfileInfo_: function(info) { |
65 this.profileInfo_ = info; | 65 this.profileInfo_ = info; |
66 var MAX_LENGTH = 50; | 66 var MAX_LENGTH = 50; |
67 var elidedName = elide(info.name, MAX_LENGTH); | 67 var elidedName = elide(info.name, MAX_LENGTH); |
68 $('managed-user-created-title').textContent = | 68 $('supervised-user-created-title').textContent = |
69 loadTimeData.getStringF('managedUserCreatedTitle', elidedName); | 69 loadTimeData.getStringF('supervisedUserCreatedTitle', elidedName); |
70 $('managed-user-created-switch').textContent = | 70 $('supervised-user-created-switch').textContent = |
71 loadTimeData.getStringF('managedUserCreatedSwitch', elidedName); | 71 loadTimeData.getStringF('supervisedUserCreatedSwitch', elidedName); |
72 | 72 |
73 // HTML-escape the user-supplied strings before putting them into | 73 // HTML-escape the user-supplied strings before putting them into |
74 // innerHTML. This is probably excessive for the email address, but | 74 // innerHTML. This is probably excessive for the email address, but |
75 // belt-and-suspenders is cheap here. | 75 // belt-and-suspenders is cheap here. |
76 $('managed-user-created-text').innerHTML = | 76 $('supervised-user-created-text').innerHTML = |
77 loadTimeData.getStringF('managedUserCreatedText', | 77 loadTimeData.getStringF('supervisedUserCreatedText', |
78 HTMLEscape(elidedName), | 78 HTMLEscape(elidedName), |
79 HTMLEscape(elide(info.custodianEmail, | 79 HTMLEscape(elide(info.custodianEmail, |
80 MAX_LENGTH))); | 80 MAX_LENGTH))); |
81 }, | 81 }, |
82 | 82 |
83 /** @override */ | 83 /** @override */ |
84 canShowPage: function() { | 84 canShowPage: function() { |
85 return this.profileInfo_ != null; | 85 return this.profileInfo_ != null; |
86 }, | 86 }, |
87 }; | 87 }; |
88 | 88 |
89 // Forward public APIs to private implementations. | 89 // Forward public APIs to private implementations. |
90 [ | 90 [ |
91 'setProfileInfo', | 91 'setProfileInfo', |
92 ].forEach(function(name) { | 92 ].forEach(function(name) { |
93 ManagedUserCreateConfirmOverlay[name] = function() { | 93 SupervisedUserCreateConfirmOverlay[name] = function() { |
94 var instance = ManagedUserCreateConfirmOverlay.getInstance(); | 94 var instance = SupervisedUserCreateConfirmOverlay.getInstance(); |
95 return instance[name + '_'].apply(instance, arguments); | 95 return instance[name + '_'].apply(instance, arguments); |
96 }; | 96 }; |
97 }); | 97 }); |
98 | 98 |
99 // Export | 99 // Export |
100 return { | 100 return { |
101 ManagedUserCreateConfirmOverlay: ManagedUserCreateConfirmOverlay, | 101 SupervisedUserCreateConfirmOverlay: SupervisedUserCreateConfirmOverlay, |
102 }; | 102 }; |
103 }); | 103 }); |
OLD | NEW |