diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-29 17:28:29 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-29 17:28:29 +0000 |
commit | 2de1e53f716e5fc1264a680be94f371d01002108 (patch) | |
tree | 291ebd906235776747b106ef83acb6d61224ce1e /chrome/browser/cocoa/bookmark_editor_controller.mm | |
parent | b51713b1d630e4ee893c5c7d037ec7a4213bc579 (diff) | |
download | chromium_src-2de1e53f716e5fc1264a680be94f371d01002108.zip chromium_src-2de1e53f716e5fc1264a680be94f371d01002108.tar.gz chromium_src-2de1e53f716e5fc1264a680be94f371d01002108.tar.bz2 |
Disable "OK" button in edit dialog of bookmark button when name is not valid
TEST=see bug
BUG=http://crbug.com/19558
Review URL: http://codereview.chromium.org/249030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27501 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bookmark_editor_controller.mm')
-rw-r--r-- | chrome/browser/cocoa/bookmark_editor_controller.mm | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/chrome/browser/cocoa/bookmark_editor_controller.mm b/chrome/browser/cocoa/bookmark_editor_controller.mm index 79cd1dc..bfa8156 100644 --- a/chrome/browser/cocoa/bookmark_editor_controller.mm +++ b/chrome/browser/cocoa/bookmark_editor_controller.mm @@ -67,8 +67,9 @@ void BookmarkEditor::Show(gfx::NativeView parent_hwnd, [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 @@ void BookmarkEditor::Show(gfx::NativeView parent_hwnd, // 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 @@ void BookmarkEditor::Show(gfx::NativeView parent_hwnd, // 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 BookmarkEditor::Show(gfx::NativeView parent_hwnd, - (void)setDisplayName:(NSString*)name { [nameField_ setStringValue:name]; + [self controlTextDidChange:nil]; } - (void)setDisplayURL:(NSString*)name { |