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
3 // found in the LICENSE file.
5 cr.define('options', function() {
6 var OptionsPage = options.OptionsPage;
9 * ManagedUserCreateConfirm class.
10 * Encapsulated handling of the confirmation overlay page when creating a
15 function ManagedUserCreateConfirmOverlay() {
16 OptionsPage.call(this, 'managedUserCreateConfirm',
17 '', // The title will be based on the new profile name.
18 'managed-user-created');
21 cr.addSingletonGetter(ManagedUserCreateConfirmOverlay);
23 ManagedUserCreateConfirmOverlay.prototype = {
24 // Inherit from OptionsPage.
25 __proto__: OptionsPage.prototype,
27 // Info about the newly created profile.
31 * Initialize the page.
33 initializePage: function() {
34 OptionsPage.prototype.initializePage.call(this);
36 $('managed-user-created-done').onclick = function(event) {
37 OptionsPage.closeOverlay();
42 $('managed-user-created-switch').onclick = function(event) {
43 OptionsPage.closeOverlay();
44 chrome.send('switchToProfile', [self.profileInfo_.filePath]);
49 didShowPage: function() {
50 $('managed-user-created-switch').focus();
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
57 * @param {Object} info An object of the form:
59 * name: "Profile Name",
60 * filePath: "/path/to/profile/data/on/disk",
61 * isManaged: (true|false)
62 * custodianEmail: "example@gmail.com"
66 setProfileInfo_: function(info) {
67 this.profileInfo_ = info;
69 var elidedName = elide(info.name, MAX_LENGTH);
70 $('managed-user-created-title').textContent =
71 loadTimeData.getStringF('managedUserCreatedTitle', elidedName);
72 $('managed-user-created-switch').textContent =
73 loadTimeData.getStringF('managedUserCreatedSwitch', elidedName);
75 // HTML-escape the user-supplied strings before putting them into
76 // innerHTML. This is probably excessive for the email address, but
77 // belt-and-suspenders is cheap here.
78 $('managed-user-created-text').innerHTML =
79 loadTimeData.getStringF('managedUserCreatedText',
80 HTMLEscape(elidedName),
81 HTMLEscape(elide(info.custodianEmail,
86 canShowPage: function() {
87 return this.profileInfo_ != null;
91 // Forward public APIs to private implementations.
94 ].forEach(function(name) {
95 ManagedUserCreateConfirmOverlay[name] = function() {
96 var instance = ManagedUserCreateConfirmOverlay.getInstance();
97 return instance[name + '_'].apply(instance, arguments);
103 ManagedUserCreateConfirmOverlay: ManagedUserCreateConfirmOverlay,