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

Unified Diff: chrome/browser/cocoa/bookmark_editor_controller.mm

Issue 249030: Disable "OK" button in edit dialog of bookmark button when name is not valid... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | « no previous file | chrome/browser/cocoa/bookmark_editor_controller_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/bookmark_editor_controller.mm
===================================================================
--- chrome/browser/cocoa/bookmark_editor_controller.mm (revision 27404)
+++ chrome/browser/cocoa/bookmark_editor_controller.mm (working copy)
@@ -67,8 +67,9 @@
[nameField_ setStringValue:initialName_];
[urlField_ setStringValue:initialUrl_];
- // Get a ping when the URL text changes;
+ // Get a ping when the URL or name text fields change;
// trigger an initial ping to set things up.
+ [nameField_ setDelegate:self];
[urlField_ setDelegate:self];
[self controlTextDidChange:nil];
@@ -136,7 +137,17 @@
// the notification.)
- (void)controlTextDidChange:(NSNotification *)aNotification {
GURL newURL = [self GURLFromUrlField];
- if (newURL.is_valid()) {
+ NSString* name = [nameField_ stringValue];
+
+ // if empty or only whitespace, name is not valid.
+ bool name_valid = true;
+ if (([name length] == 0) ||
+ ([[name stringByTrimmingCharactersInSet:[NSCharacterSet
+ whitespaceAndNewlineCharacterSet]] length] == 0)) {
+ name_valid = false;
+ }
+
+ if (newURL.is_valid() && name_valid) {
[okButton_ setEnabled:YES];
} else {
[okButton_ setEnabled:NO];
@@ -182,6 +193,7 @@
// This is probably unnecessary but it feels cleaner since the
// delegate of a text field can be automatically registered for
// notifications.
+ [nameField_ setDelegate:nil];
[urlField_ setDelegate:nil];
[[self window] orderOut:self];
@@ -202,6 +214,7 @@
- (void)setDisplayName:(NSString*)name {
[nameField_ setStringValue:name];
+ [self controlTextDidChange:nil];
}
- (void)setDisplayURL:(NSString*)name {
« no previous file with comments | « no previous file | chrome/browser/cocoa/bookmark_editor_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698