diff options
author | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-04 21:12:44 +0000 |
---|---|---|
committer | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-04 21:12:44 +0000 |
commit | f283d2cb1d259518850b0249e4bbc4d224552d24 (patch) | |
tree | 4950727331ae1451d69bcd4d5412d5a838ba14fe /chrome/browser/cocoa/bookmark_editor_controller.mm | |
parent | 5370a4dd9c56a780eccbe57f27c61ffa7d94efe2 (diff) | |
download | chromium_src-f283d2cb1d259518850b0249e4bbc4d224552d24.zip chromium_src-f283d2cb1d259518850b0249e4bbc4d224552d24.tar.gz chromium_src-f283d2cb1d259518850b0249e4bbc4d224552d24.tar.bz2 |
Clean up bookmark_editor_controller to so that is closes consistently as both a standard window and as a sheet.
Get rid of an unneeded member variable.
Clean up unittest to use new CocoaTest, and to clean up its windows properly.
BUG=none
TEST=Open the bookmark editing window and edit bookmarks. Make sure to test with both OK and Cancel.
Review URL: http://codereview.chromium.org/361011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31000 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 | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/chrome/browser/cocoa/bookmark_editor_controller.mm b/chrome/browser/cocoa/bookmark_editor_controller.mm index 93ea8e3..f675fc3 100644 --- a/chrome/browser/cocoa/bookmark_editor_controller.mm +++ b/chrome/browser/cocoa/bookmark_editor_controller.mm @@ -172,6 +172,19 @@ int IndexOfFolderChild(const BookmarkNode* child_node) { } } +- (void)windowWillClose:(NSNotification *)notification { + // If a folder name cell is being edited then force it to end editing + // so that any changes are recorded. + [[self window] makeFirstResponder:nil]; + + // 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 autorelease]; +} + /* TODO(jrg): // Implementing this informal protocol allows us to open the sheet // somewhere other than at the top of the window. NOTE: this means @@ -248,7 +261,6 @@ int IndexOfFolderChild(const BookmarkNode* child_node) { [cell setTarget:self]; [cell setAction:@selector(cellEditingCompleted:)]; [cell setSendsActionOnEndEditing:YES]; - currentEditCell_.reset([cell retain]); NSMatrix* matrix = [cell matrix]; // Set the delegate so that we get called when editing wants to complete. [matrix setDelegate:self]; @@ -277,7 +289,6 @@ int IndexOfFolderChild(const BookmarkNode* child_node) { BookmarkModel* model = profile_->GetBookmarkModel(); NSString* newTitle = [cell title]; model->SetTitle(bookmarkNode, base::SysNSStringToWide(newTitle)); - currentEditCell_.reset(); } - (void)browserDoubleClicked:(id)sender { @@ -368,24 +379,7 @@ int IndexOfFolderChild(const BookmarkNode* child_node) { - (void)didEndSheet:(NSWindow*)sheet returnCode:(int)returnCode contextInfo:(void*)contextInfo { - // If a folder name cell is being edited then force it to end editing - // so that any changes are recorded. - BookmarkTreeBrowserCell* currentEditCell = currentEditCell_.get(); - if (currentEditCell) { - [self saveFolderNameForCell:currentEditCell]; - currentEditCell_.reset(); - } - // 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]; - - // BookmarkEditor::Show() will create us then run away. Unusually - // for a controller, we are responsible for deallocating ourself. - [self autorelease]; + [sheet close]; } #pragma mark For Unit Test Use Only |