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 /** | 30 /** |
31 * Initialize the page. | 31 * Initialize the page. |
32 */ | 32 */ |
33 initializePage: function() { | 33 initializePage: function() { |
34 OptionsPage.prototype.initializePage.call(this); | 34 OptionsPage.prototype.initializePage.call(this); |
35 | 35 |
36 $('managed-user-created-done').onclick = function(event) { | 36 $('supervised-user-created-done').onclick = function(event) { |
37 OptionsPage.closeOverlay(); | 37 OptionsPage.closeOverlay(); |
38 }; | 38 }; |
39 | 39 |
40 var self = this; | 40 var self = this; |
41 | 41 |
42 $('managed-user-created-switch').onclick = function(event) { | 42 $('supervised-user-created-switch').onclick = function(event) { |
43 OptionsPage.closeOverlay(); | 43 OptionsPage.closeOverlay(); |
44 chrome.send('switchToProfile', [self.profileInfo_.filePath]); | 44 chrome.send('switchToProfile', [self.profileInfo_.filePath]); |
45 }; | 45 }; |
46 }, | 46 }, |
47 | 47 |
48 /** @override */ | 48 /** @override */ |
49 didShowPage: function() { | 49 didShowPage: function() { |
50 $('managed-user-created-switch').focus(); | 50 $('supervised-user-created-switch').focus(); |
51 }, | 51 }, |
52 | 52 |
53 /** | 53 /** |
54 * Sets the profile info used in the dialog and updates the profile name | 54 * Sets the profile info used in the dialog and updates the profile name |
55 * displayed. Called by the profile creation overlay when this overlay is | 55 * displayed. Called by the profile creation overlay when this overlay is |
56 * opened. | 56 * opened. |
57 * @param {Object} info An object of the form: | 57 * @param {Object} info An object of the form: |
58 * info = { | 58 * info = { |
59 * name: "Profile Name", | 59 * name: "Profile Name", |
60 * filePath: "/path/to/profile/data/on/disk", | 60 * filePath: "/path/to/profile/data/on/disk", |
61 * isManaged: (true|false) | 61 * isSupervised: (true|false) |
62 * custodianEmail: "example@gmail.com" | 62 * custodianEmail: "example@gmail.com" |
63 * }; | 63 * }; |
64 * @private | 64 * @private |
65 */ | 65 */ |
66 setProfileInfo_: function(info) { | 66 setProfileInfo_: function(info) { |
67 this.profileInfo_ = info; | 67 this.profileInfo_ = info; |
68 var MAX_LENGTH = 50; | 68 var MAX_LENGTH = 50; |
69 var elidedName = elide(info.name, MAX_LENGTH); | 69 var elidedName = elide(info.name, MAX_LENGTH); |
70 $('managed-user-created-title').textContent = | 70 $('supervised-user-created-title').textContent = |
71 loadTimeData.getStringF('managedUserCreatedTitle', elidedName); | 71 loadTimeData.getStringF('supervisedUserCreatedTitle', elidedName); |
72 $('managed-user-created-switch').textContent = | 72 $('supervised-user-created-switch').textContent = |
73 loadTimeData.getStringF('managedUserCreatedSwitch', elidedName); | 73 loadTimeData.getStringF('supervisedUserCreatedSwitch', elidedName); |
74 | 74 |
75 // HTML-escape the user-supplied strings before putting them into | 75 // HTML-escape the user-supplied strings before putting them into |
76 // innerHTML. This is probably excessive for the email address, but | 76 // innerHTML. This is probably excessive for the email address, but |
77 // belt-and-suspenders is cheap here. | 77 // belt-and-suspenders is cheap here. |
78 $('managed-user-created-text').innerHTML = | 78 $('supervised-user-created-text').innerHTML = |
79 loadTimeData.getStringF('managedUserCreatedText', | 79 loadTimeData.getStringF('supervisedUserCreatedText', |
80 HTMLEscape(elidedName), | 80 HTMLEscape(elidedName), |
81 HTMLEscape(elide(info.custodianEmail, | 81 HTMLEscape(elide(info.custodianEmail, |
82 MAX_LENGTH))); | 82 MAX_LENGTH))); |
83 }, | 83 }, |
84 | 84 |
85 /** @override */ | 85 /** @override */ |
86 canShowPage: function() { | 86 canShowPage: function() { |
87 return this.profileInfo_ != null; | 87 return this.profileInfo_ != null; |
88 }, | 88 }, |
89 }; | 89 }; |
90 | 90 |
91 // Forward public APIs to private implementations. | 91 // Forward public APIs to private implementations. |
92 [ | 92 [ |
93 'setProfileInfo', | 93 'setProfileInfo', |
94 ].forEach(function(name) { | 94 ].forEach(function(name) { |
95 ManagedUserCreateConfirmOverlay[name] = function() { | 95 SupervisedUserCreateConfirmOverlay[name] = function() { |
96 var instance = ManagedUserCreateConfirmOverlay.getInstance(); | 96 var instance = SupervisedUserCreateConfirmOverlay.getInstance(); |
97 return instance[name + '_'].apply(instance, arguments); | 97 return instance[name + '_'].apply(instance, arguments); |
98 }; | 98 }; |
99 }); | 99 }); |
100 | 100 |
101 // Export | 101 // Export |
102 return { | 102 return { |
103 ManagedUserCreateConfirmOverlay: ManagedUserCreateConfirmOverlay, | 103 SupervisedUserCreateConfirmOverlay: SupervisedUserCreateConfirmOverlay, |
104 }; | 104 }; |
105 }); | 105 }); |
OLD | NEW |