| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 /** | 5 /** |
| 6 * @fileoverview 'supervised-user-create-confirm' is a page that is displayed | 6 * @fileoverview 'supervised-user-create-confirm' is a page that is displayed |
| 7 * upon successful creation of a supervised user. It contains information for | 7 * upon successful creation of a supervised user. It contains information for |
| 8 * the custodian on where to configure browsing restrictions as well as how to | 8 * the custodian on where to configure browsing restrictions as well as how to |
| 9 * exit and childlock their profile. | 9 * exit and childlock their profile. |
| 10 */ | 10 */ |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 * @param {?ProfileInfo} profileInfo | 91 * @param {?ProfileInfo} profileInfo |
| 92 * @return {string} | 92 * @return {string} |
| 93 * @private | 93 * @private |
| 94 */ | 94 */ |
| 95 titleText_: function(profileInfo) { | 95 titleText_: function(profileInfo) { |
| 96 return this.i18n('supervisedUserCreatedTitle', | 96 return this.i18n('supervisedUserCreatedTitle', |
| 97 this.elideProfileName_(profileInfo)); | 97 this.elideProfileName_(profileInfo)); |
| 98 }, | 98 }, |
| 99 | 99 |
| 100 /** | 100 /** |
| 101 * Sanitizes HTML so that insecure HTML/Javascript won't be set as innerHTML. | |
| 102 * @param {string} html | |
| 103 * @return {string} | |
| 104 * @private | |
| 105 */ | |
| 106 sanitizeHtml_: function(html) { | |
| 107 return parseHtmlSubset('<div>' + html + '<div>', ['A', 'DIV']) | |
| 108 .firstChild.innerHTML; | |
| 109 }, | |
| 110 | |
| 111 /** | |
| 112 * Computed binding returning the part 1 of the confirmation message. Returns | 101 * Computed binding returning the part 1 of the confirmation message. Returns |
| 113 * sanitized HTML that is safe to set as innerHTML. | 102 * sanitized HTML that is safe to set as innerHTML. |
| 114 * @param {?ProfileInfo} profileInfo | 103 * @param {?ProfileInfo} profileInfo |
| 115 * @return {string} | 104 * @return {string} |
| 116 * @private | 105 * @private |
| 117 */ | 106 */ |
| 118 htmlMessage1_: function(profileInfo) { | 107 htmlMessage1_: function(profileInfo) { |
| 119 return this.sanitizeHtml_( | 108 return this.i18n('supervisedUserCreatedTextPart1', |
| 120 this.i18n('supervisedUserCreatedTextPart1', | 109 HTMLEscape(this.elideProfileName_(profileInfo))); |
| 121 HTMLEscape(this.elideProfileName_(profileInfo)))); | |
| 122 }, | 110 }, |
| 123 | 111 |
| 124 /** | 112 /** |
| 125 * Computed binding returning the part 2 of the confirmation message. Returns | 113 * Computed binding returning the part 2 of the confirmation message. Returns |
| 126 * sanitized HTML that is safe to set as innerHTML. | 114 * sanitized HTML that is safe to set as innerHTML. |
| 127 * @param {?ProfileInfo} profileInfo | 115 * @param {?ProfileInfo} profileInfo |
| 128 * @return {string} | 116 * @return {string} |
| 129 * @private | 117 * @private |
| 130 */ | 118 */ |
| 131 htmlMessage2_: function(profileInfo) { | 119 htmlMessage2_: function(profileInfo) { |
| 132 return this.sanitizeHtml_( | 120 return this.i18n('supervisedUserCreatedTextPart2', |
| 133 this.i18n('supervisedUserCreatedTextPart2', | 121 this.elideProfileName_(profileInfo), |
| 134 this.elideProfileName_(profileInfo), | 122 this.elideCustodianUsername_(profileInfo)); |
| 135 this.elideCustodianUsername_(profileInfo))); | |
| 136 }, | 123 }, |
| 137 | 124 |
| 138 /** | 125 /** |
| 139 * Computed binding returning the text of the 'Switch To User' button. | 126 * Computed binding returning the text of the 'Switch To User' button. |
| 140 * @param {?ProfileInfo} profileInfo | 127 * @param {?ProfileInfo} profileInfo |
| 141 * @return {string} | 128 * @return {string} |
| 142 * @private | 129 * @private |
| 143 */ | 130 */ |
| 144 switchUserText_: function(profileInfo) { | 131 switchUserText_: function(profileInfo) { |
| 145 return this.i18n('supervisedUserCreatedSwitch', | 132 return this.i18n('supervisedUserCreatedSwitch', |
| (...skipping 15 matching lines...) Expand all Loading... |
| 161 * @param {!Event} event | 148 * @param {!Event} event |
| 162 * @private | 149 * @private |
| 163 */ | 150 */ |
| 164 onSwitchUserTap_: function(event) { | 151 onSwitchUserTap_: function(event) { |
| 165 this.browserProxy_.switchToProfile(this.profileInfo.filePath); | 152 this.browserProxy_.switchToProfile(this.profileInfo.filePath); |
| 166 // Event is caught by user-manager-pages. | 153 // Event is caught by user-manager-pages. |
| 167 this.fire('change-page', {page: 'user-pods-page'}); | 154 this.fire('change-page', {page: 'user-pods-page'}); |
| 168 } | 155 } |
| 169 }); | 156 }); |
| 170 })(); | 157 })(); |
| OLD | NEW |