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

Unified Diff: chrome/browser/resources/options/manage_profile_overlay.js

Issue 7845004: [Multi Profile] Don't allow the user to choose an empty profile name. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: merge + fix nit Created 9 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/options/manage_profile_overlay.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/options/manage_profile_overlay.js
diff --git a/chrome/browser/resources/options/manage_profile_overlay.js b/chrome/browser/resources/options/manage_profile_overlay.js
index ae97f12f87c3da19e4da92d6a4f7db5d84bf5d01..16bf5c8ca250460eae2552af173756f0d39c48dc 100644
--- a/chrome/browser/resources/options/manage_profile_overlay.js
+++ b/chrome/browser/resources/options/manage_profile_overlay.js
@@ -108,34 +108,25 @@ cr.define('options', function() {
},
/**
- * Determine whether |name| is valid; i.e. not equal to any other profile
- * name.
- * @param {string} name The profile name to validate.
- * @return true if the name is not equal to any other profile name.
+ * Display the error bubble, with |errorText| in the bubble.
+ * @param {string} errorText The localized string id to display as an error.
* @private
*/
- isNameValid_: function(name) {
- // if the name hasn't changed, assume it is valid.
- if (name == this.profileInfo_.name)
- return true;
+ showErrorBubble_: function(errorText) {
+ var nameErrorEl = $('manage-profile-error-bubble');
+ nameErrorEl.hidden = false;
+ nameErrorEl.textContent = localStrings.getString(errorText);
- return this.profileNames_[name] == undefined;
+ $('manage-profile-ok').disabled = true;
},
/**
- * Update the UI elements accordingly if the profile name is valid/invalid.
- * @param {boolean} isValid True if the UI should be updated as if the name
- * were valid.
+ * Hide the error bubble.
* @private
*/
- setNameIsValid_: function(isValid) {
- var dupeNameErrorEl = $('manage-profile-duplicate-name-error');
- if (isValid)
- dupeNameErrorEl.classList.add('hiding');
- else
- dupeNameErrorEl.classList.remove('hiding');
-
- $('manage-profile-ok').disabled = !isValid;
+ hideErrorBubble_: function() {
+ $('manage-profile-error-bubble').hidden = true;
+ $('manage-profile-ok').disabled = false;
},
/**
@@ -144,7 +135,19 @@ cr.define('options', function() {
* @private
*/
onNameChanged_: function(event) {
- this.setNameIsValid_(this.isNameValid_(event.target.value));
+ var newName = event.target.value;
+ var oldName = this.profileInfo_.name;
+
+ if (newName == oldName) {
+ this.hideErrorBubble_();
+ } else if (this.profileNames_[newName] != undefined) {
+ this.showErrorBubble_('manageProfilesDuplicateNameError');
+ } else {
+ this.hideErrorBubble_();
+
+ var nameIsValid = $('manage-profile-name').validity.valid;
+ $('manage-profile-ok').disabled = !nameIsValid;
+ }
},
/**
@@ -167,7 +170,7 @@ cr.define('options', function() {
ManageProfileOverlay.setProfileInfo(profileInfo);
$('manage-profile-overlay-manage').hidden = false;
$('manage-profile-overlay-delete').hidden = true;
- ManageProfileOverlay.getInstance().setNameIsValid_(true);
+ ManageProfileOverlay.getInstance().hideErrorBubble_();
// Intentionally don't show the URL in the location bar as we don't want
// people trying to navigate here by hand.
« no previous file with comments | « chrome/browser/resources/options/manage_profile_overlay.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698