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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 }; | 45 }; |
46 }, | 46 }, |
47 | 47 |
48 /** | 48 /** |
49 * Sets the profile info used in the dialog and updates the profile name | 49 * Sets the profile info used in the dialog and updates the profile name |
50 * displayed. Called by the profile creation overlay when this overlay is | 50 * displayed. Called by the profile creation overlay when this overlay is |
51 * opened. | 51 * opened. |
52 * @param {Object} info An object of the form: | 52 * @param {Object} info An object of the form: |
53 * info = { | 53 * info = { |
54 * name: "Profile Name", | 54 * name: "Profile Name", |
55 * filePath: "/path/to/profile/data/on/disk" | 55 * filePath: "/path/to/profile/data/on/disk", |
56 * isManaged: (true|false) | 56 * isManaged: (true|false) |
| 57 * custodianEmail: "example@gmail.com" |
57 * }; | 58 * }; |
58 * @private | 59 * @private |
59 */ | 60 */ |
60 setProfileInfo_: function(info) { | 61 setProfileInfo_: function(info) { |
| 62 function HTMLEscape(original) { |
| 63 return original.replace(/&/g, '&') |
| 64 .replace(/</g, '<') |
| 65 .replace(/>/g, '>') |
| 66 .replace(/"/g, '"') |
| 67 .replace(/'/g, '''); |
| 68 } |
| 69 |
61 this.profileInfo_ = info; | 70 this.profileInfo_ = info; |
62 $('managed-user-created-title').textContent = | 71 $('managed-user-created-title').textContent = |
63 loadTimeData.getStringF('managedUserCreatedTitle', info.name); | 72 loadTimeData.getStringF('managedUserCreatedTitle', info.name); |
64 $('managed-user-created-text').textContent = | |
65 loadTimeData.getStringF('managedUserCreatedText', | |
66 info.name, | |
67 loadTimeData.getString('custodianEmail')); | |
68 $('managed-user-created-switch').textContent = | 73 $('managed-user-created-switch').textContent = |
69 loadTimeData.getStringF('managedUserCreatedSwitch', info.name); | 74 loadTimeData.getStringF('managedUserCreatedSwitch', info.name); |
| 75 |
| 76 // HTML-escape the user-supplied strings before putting them into |
| 77 // innerHTML. This is probably excessive for the email address, but |
| 78 // belt-and-suspenders is cheap here. |
| 79 $('managed-user-created-text').innerHTML = |
| 80 loadTimeData.getStringF('managedUserCreatedText', |
| 81 HTMLEscape(info.name), |
| 82 HTMLEscape(info.custodianEmail)); |
70 }, | 83 }, |
71 }; | 84 }; |
72 | 85 |
73 // Forward public APIs to private implementations. | 86 // Forward public APIs to private implementations. |
74 [ | 87 [ |
75 'setProfileInfo', | 88 'setProfileInfo', |
76 ].forEach(function(name) { | 89 ].forEach(function(name) { |
77 ManagedUserCreateConfirmOverlay[name] = function() { | 90 ManagedUserCreateConfirmOverlay[name] = function() { |
78 var instance = ManagedUserCreateConfirmOverlay.getInstance(); | 91 var instance = ManagedUserCreateConfirmOverlay.getInstance(); |
79 return instance[name + '_'].apply(instance, arguments); | 92 return instance[name + '_'].apply(instance, arguments); |
80 }; | 93 }; |
81 }); | 94 }); |
82 | 95 |
83 // Export | 96 // Export |
84 return { | 97 return { |
85 ManagedUserCreateConfirmOverlay: ManagedUserCreateConfirmOverlay, | 98 ManagedUserCreateConfirmOverlay: ManagedUserCreateConfirmOverlay, |
86 }; | 99 }; |
87 }); | 100 }); |
OLD | NEW |