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

Side by Side Diff: chrome/browser/cocoa/bookmark_editor_controller.mm

Issue 353024: Mac: Enable OK Button when editing a bookmark text to be blank... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "app/l10n_util.h" 5 #include "app/l10n_util.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/mac_util.h" 7 #include "base/mac_util.h"
8 #include "base/sys_string_conversions.h" 8 #include "base/sys_string_conversions.h"
9 #include "chrome/browser/bookmarks/bookmark_editor.h" 9 #include "chrome/browser/bookmarks/bookmark_editor.h"
10 #include "chrome/browser/bookmarks/bookmark_model.h" 10 #include "chrome/browser/bookmarks/bookmark_model.h"
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 newURL = GURL([[NSString stringWithFormat:@"http://%@", url] UTF8String]); 321 newURL = GURL([[NSString stringWithFormat:@"http://%@", url] UTF8String]);
322 } 322 }
323 return newURL; 323 return newURL;
324 } 324 }
325 325
326 // Enable the OK button if there is a bookmark name and there is a valid URL. 326 // Enable the OK button if there is a bookmark name and there is a valid URL.
327 // We set ourselves as the delegate of urlField_ so this gets called. 327 // We set ourselves as the delegate of urlField_ so this gets called.
328 // (Yes, setting ourself as a delegate automatically registers us for 328 // (Yes, setting ourself as a delegate automatically registers us for
329 // the notification.) 329 // the notification.)
330 - (void)controlTextDidChange:(NSNotification*)aNotification { 330 - (void)controlTextDidChange:(NSNotification*)aNotification {
331 // Name must not be empty, but it can be whitespace.
332 NSString* name = [nameField_ stringValue];
333 GURL newURL = [self GURLFromUrlField]; 331 GURL newURL = [self GURLFromUrlField];
334 [okButton_ setEnabled:([name length] != 0 && newURL.is_valid()) ? YES : NO]; 332 [okButton_ setEnabled:(newURL.is_valid()) ? YES : NO];
335 } 333 }
336 334
337 // The ok: action is connected to the OK button in the Edit Bookmark window 335 // The ok: action is connected to the OK button in the Edit Bookmark window
338 // of the BookmarkEditor.xib. The the bookmark's name and URL are assumed 336 // of the BookmarkEditor.xib. The the bookmark's name and URL are assumed
339 // to be valid (otherwise the OK button should not be enabled). If the 337 // to be valid (otherwise the OK button should not be enabled). If the
340 // bookmark previously existed then it is removed from its old folder. 338 // bookmark previously existed then it is removed from its old folder.
341 // The bookmark is then added to its new folder. If the folder has not 339 // The bookmark is then added to its new folder. If the folder has not
342 // changed then the bookmark stays in its original position (index) otherwise 340 // changed then the bookmark stays in its original position (index) otherwise
343 // it is added to the end of the new folder. 341 // it is added to the end of the new folder.
344 - (IBAction)ok:(id)sender { 342 - (IBAction)ok:(id)sender {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 DCHECK(childNode); 455 DCHECK(childNode);
458 BookmarkTreeBrowserCell* browserCell = 456 BookmarkTreeBrowserCell* browserCell =
459 static_cast<BookmarkTreeBrowserCell*>(cell); 457 static_cast<BookmarkTreeBrowserCell*>(cell);
460 [browserCell setTitle:base::SysWideToNSString(childNode->GetTitle())]; 458 [browserCell setTitle:base::SysWideToNSString(childNode->GetTitle())];
461 [browserCell setBookmarkNode:childNode]; 459 [browserCell setBookmarkNode:childNode];
462 [browserCell setMatrix:[folderBrowser_ matrixInColumn:column]]; 460 [browserCell setMatrix:[folderBrowser_ matrixInColumn:column]];
463 } 461 }
464 462
465 @end // BookmarkEditorController 463 @end // BookmarkEditorController
466 464
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698