Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1098)

Side by Side Diff: chrome/browser/resources/md_user_manager/create_profile.js

Issue 1920253002: Refactors parse_html_subset() into i18n_behavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 'create-profile' is a page that contains controls for creating 6 * @fileoverview 'create-profile' is a page that contains controls for creating
7 * a (optionally supervised) profile, including choosing a name, and an avatar. 7 * a (optionally supervised) profile, including choosing a name, and an avatar.
8 */ 8 */
9 (function() { 9 (function() {
10 /** 10 /**
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 // creating SUs with the same name (https://crbug.com/557445). 275 // creating SUs with the same name (https://crbug.com/557445).
276 var allOnCurrentDevice = supervisedUsers[i].onCurrentDevice; 276 var allOnCurrentDevice = supervisedUsers[i].onCurrentDevice;
277 for (var j = i + 1; j < supervisedUsers.length; ++j) { 277 for (var j = i + 1; j < supervisedUsers.length; ++j) {
278 if (supervisedUsers[j].name == this.profileName_) { 278 if (supervisedUsers[j].name == this.profileName_) {
279 nameIsUnique = false; 279 nameIsUnique = false;
280 allOnCurrentDevice = allOnCurrentDevice && 280 allOnCurrentDevice = allOnCurrentDevice &&
281 supervisedUsers[j].onCurrentDevice; 281 supervisedUsers[j].onCurrentDevice;
282 } 282 }
283 } 283 }
284 284
285 var opts = {
286 'substitutions':
287 [HTMLEscape(elide(this.profileName_, /* maxLength */ 50))],
288 'attrs': {
289 'id': function(node, value) {
290 return node.tagName == 'A' && value != '';
291 },
292 'is': function(node, value) {
293 return node.tagName == 'A' && value == 'action-link';
294 },
295 'role': function(node, value) {
296 return node.tagName == 'A' && value == 'link';
297 },
298 'tabindex': function(node, value) {
299 return node.tagName == 'A';
300 }
301 }
302 };
303
285 this.handleMessage_(allOnCurrentDevice ? 304 this.handleMessage_(allOnCurrentDevice ?
286 this.i18n('managedProfilesExistingLocalSupervisedUser') : 305 this.i18n('managedProfilesExistingLocalSupervisedUser') :
287 this.i18n('manageProfilesExistingSupervisedUser', 306 this.i18nAdvanced('manageProfilesExistingSupervisedUser', opts));
288 HTMLEscape(elide(this.profileName_, /* maxLength */ 50))));
289 return; 307 return;
290 } 308 }
291 // No existing supervised user's name matches the entered profile name. 309 // No existing supervised user's name matches the entered profile name.
292 // Continue with creating the new supervised profile. 310 // Continue with creating the new supervised profile.
293 this.createProfile_(); 311 this.createProfile_();
294 }, 312 },
295 313
296 /** 314 /**
297 * Creates the new profile. 315 * Creates the new profile.
298 * @private 316 * @private
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 * Handles profile create/import warning/error message pushed by the browser. 394 * Handles profile create/import warning/error message pushed by the browser.
377 * @param {*} message An HTML warning/error message. 395 * @param {*} message An HTML warning/error message.
378 * @private 396 * @private
379 */ 397 */
380 handleMessage_: function(message) { 398 handleMessage_: function(message) {
381 this.createInProgress_ = false; 399 this.createInProgress_ = false;
382 this.message_ = '' + message; 400 this.message_ = '' + message;
383 }, 401 },
384 402
385 /** 403 /**
404 * Returns a translated message that contains link elements with 'id'
405 * attribute.
406 * @param {string} id The ID of the string to translate.
407 * @private
408 */
409 i18nAllowIDAttr_: function(id) {
410 var opts = {
411 'attrs': {
412 'id' : function(node, value) {
413 return node.tagName == 'A' && value != '';
Dan Beam 2016/05/05 16:43:36 i suppose checking for tagName == 'A' isn't bad, b
Moe 2016/05/06 14:24:59 It's not needed. removed.
414 }
415 }
416 };
417
418 return this.i18nAdvanced(id, opts);
Dan Beam 2016/05/05 16:43:36 this would be so much prettier return this.i18n
Moe 2016/05/06 14:24:59 I agree. When can we start using ES6 in chromium?
419 },
420
421 /**
386 * Computed binding determining which profile icon button is toggled on. 422 * Computed binding determining which profile icon button is toggled on.
387 * @param {string} iconUrl icon URL of a given icon button. 423 * @param {string} iconUrl icon URL of a given icon button.
388 * @param {string} profileIconUrl Currently selected icon URL. 424 * @param {string} profileIconUrl Currently selected icon URL.
389 * @return {boolean} 425 * @return {boolean}
390 * @private 426 * @private
391 */ 427 */
392 isActiveIcon_: function(iconUrl, profileIconUrl) { 428 isActiveIcon_: function(iconUrl, profileIconUrl) {
393 return iconUrl == profileIconUrl; 429 return iconUrl == profileIconUrl;
394 }, 430 },
395 431
(...skipping 27 matching lines...) Expand all
423 * Computed binding that returns True if there are any signed-in users. 459 * Computed binding that returns True if there are any signed-in users.
424 * @param {!Array<!SignedInUser>} signedInUsers signed-in users. 460 * @param {!Array<!SignedInUser>} signedInUsers signed-in users.
425 * @return {boolean} 461 * @return {boolean}
426 * @private 462 * @private
427 */ 463 */
428 isSignedIn_: function(signedInUsers) { 464 isSignedIn_: function(signedInUsers) {
429 return signedInUsers.length > 0; 465 return signedInUsers.length > 0;
430 } 466 }
431 }); 467 });
432 }()); 468 }());
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698