1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 cr
.define('options', function() {
6 var Page
= cr
.ui
.pageManager
.Page
;
7 var PageManager
= cr
.ui
.pageManager
.PageManager
;
10 * SupervisedUserCreateConfirm class.
11 * Encapsulated handling of the confirmation overlay page when creating a
14 * @extends {cr.ui.pageManager.Page}
16 function SupervisedUserCreateConfirmOverlay() {
17 Page
.call(this, 'supervisedUserCreateConfirm',
18 '', // The title will be based on the new profile name.
19 'supervised-user-created');
22 cr
.addSingletonGetter(SupervisedUserCreateConfirmOverlay
);
24 SupervisedUserCreateConfirmOverlay
.prototype = {
26 __proto__
: Page
.prototype,
28 // Info about the newly created profile.
32 initializePage: function() {
33 Page
.prototype.initializePage
.call(this);
35 $('supervised-user-created-done').onclick = function(event
) {
36 PageManager
.closeOverlay();
41 $('supervised-user-created-switch').onclick = function(event
) {
42 PageManager
.closeOverlay();
43 chrome
.send('switchToProfile', [self
.profileInfo_
.filePath
]);
48 didShowPage: function() {
49 $('supervised-user-created-switch').focus();
53 * Sets the profile info used in the dialog and updates the profile name
54 * displayed. Called by the profile creation overlay when this overlay is
56 * @param {Object} info An object of the form:
58 * name: "Profile Name",
59 * filePath: "/path/to/profile/data/on/disk",
60 * isSupervised: (true|false)
61 * custodianEmail: "example@gmail.com"
65 setProfileInfo_: function(info
) {
66 this.profileInfo_
= info
;
68 var elidedName
= elide(info
.name
, MAX_LENGTH
);
69 $('supervised-user-created-title').textContent
=
70 loadTimeData
.getStringF('supervisedUserCreatedTitle', elidedName
);
71 $('supervised-user-created-switch').textContent
=
72 loadTimeData
.getStringF('supervisedUserCreatedSwitch', elidedName
);
74 // HTML-escape the user-supplied strings before putting them into
75 // innerHTML. This is probably excessive for the email address, but
76 // belt-and-suspenders is cheap here.
77 $('supervised-user-created-text').innerHTML
=
78 loadTimeData
.getStringF('supervisedUserCreatedText',
79 HTMLEscape(elidedName
),
80 HTMLEscape(elide(info
.custodianEmail
,
85 canShowPage: function() {
86 return this.profileInfo_
!= null;
90 // Forward public APIs to private implementations.
91 cr
.makePublic(SupervisedUserCreateConfirmOverlay
, [
97 SupervisedUserCreateConfirmOverlay
: SupervisedUserCreateConfirmOverlay
,