| 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 * ManagedUserCreateConfirm class. |
| 10 * Encapsulated handling of the confirmation overlay page when creating a | 10 * Encapsulated handling of the confirmation overlay page when creating a |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 * isManaged: (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 function HTMLEscape(original) { | 67 this.profileInfo_ = info; |
| 68 return original.replace(/&/g, '&') | |
| 69 .replace(/</g, '<') | |
| 70 .replace(/>/g, '>') | |
| 71 .replace(/"/g, '"') | |
| 72 .replace(/'/g, '''); | |
| 73 } | |
| 74 | |
| 75 var MAX_LENGTH = 50; | 68 var MAX_LENGTH = 50; |
| 76 function elide(original) { | 69 var elidedName = elide(info.name, MAX_LENGTH); |
| 77 if (original.length <= MAX_LENGTH) | |
| 78 return original; | |
| 79 return original.substring(0, MAX_LENGTH - 3) + '...'; | |
| 80 } | |
| 81 | |
| 82 this.profileInfo_ = info; | |
| 83 var elidedName = elide(info.name); | |
| 84 $('managed-user-created-title').textContent = | 70 $('managed-user-created-title').textContent = |
| 85 loadTimeData.getStringF('managedUserCreatedTitle', elidedName); | 71 loadTimeData.getStringF('managedUserCreatedTitle', elidedName); |
| 86 $('managed-user-created-switch').textContent = | 72 $('managed-user-created-switch').textContent = |
| 87 loadTimeData.getStringF('managedUserCreatedSwitch', elidedName); | 73 loadTimeData.getStringF('managedUserCreatedSwitch', elidedName); |
| 88 | 74 |
| 89 // HTML-escape the user-supplied strings before putting them into | 75 // HTML-escape the user-supplied strings before putting them into |
| 90 // innerHTML. This is probably excessive for the email address, but | 76 // innerHTML. This is probably excessive for the email address, but |
| 91 // belt-and-suspenders is cheap here. | 77 // belt-and-suspenders is cheap here. |
| 92 $('managed-user-created-text').innerHTML = | 78 $('managed-user-created-text').innerHTML = |
| 93 loadTimeData.getStringF('managedUserCreatedText', | 79 loadTimeData.getStringF('managedUserCreatedText', |
| 94 HTMLEscape(elidedName), | 80 HTMLEscape(elidedName), |
| 95 HTMLEscape(elide(info.custodianEmail))); | 81 HTMLEscape(elide(info.custodianEmail, |
| 82 MAX_LENGTH))); |
| 96 }, | 83 }, |
| 97 | 84 |
| 98 /** @override */ | 85 /** @override */ |
| 99 canShowPage: function() { | 86 canShowPage: function() { |
| 100 return this.profileInfo_ != null; | 87 return this.profileInfo_ != null; |
| 101 }, | 88 }, |
| 102 }; | 89 }; |
| 103 | 90 |
| 104 // Forward public APIs to private implementations. | 91 // Forward public APIs to private implementations. |
| 105 [ | 92 [ |
| 106 'setProfileInfo', | 93 'setProfileInfo', |
| 107 ].forEach(function(name) { | 94 ].forEach(function(name) { |
| 108 ManagedUserCreateConfirmOverlay[name] = function() { | 95 ManagedUserCreateConfirmOverlay[name] = function() { |
| 109 var instance = ManagedUserCreateConfirmOverlay.getInstance(); | 96 var instance = ManagedUserCreateConfirmOverlay.getInstance(); |
| 110 return instance[name + '_'].apply(instance, arguments); | 97 return instance[name + '_'].apply(instance, arguments); |
| 111 }; | 98 }; |
| 112 }); | 99 }); |
| 113 | 100 |
| 114 // Export | 101 // Export |
| 115 return { | 102 return { |
| 116 ManagedUserCreateConfirmOverlay: ManagedUserCreateConfirmOverlay, | 103 ManagedUserCreateConfirmOverlay: ManagedUserCreateConfirmOverlay, |
| 117 }; | 104 }; |
| 118 }); | 105 }); |
| OLD | NEW |