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

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

Issue 361011: Clean up bookmark_editor_controller to so that is closes consistently as both... (Closed) Base URL: svn://svn.chromium.org/chrome/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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/cocoa/bookmark_editor_controller.mm
===================================================================
--- chrome/browser/cocoa/bookmark_editor_controller.mm (revision 30825)
+++ chrome/browser/cocoa/bookmark_editor_controller.mm (working copy)
@@ -172,6 +172,19 @@
}
}
+- (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 @@
[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 @@
BookmarkModel* model = profile_->GetBookmarkModel();
NSString* newTitle = [cell title];
model->SetTitle(bookmarkNode, base::SysNSStringToWide(newTitle));
- currentEditCell_.reset();
}
- (void)browserDoubleClicked:(id)sender {
@@ -368,24 +379,7 @@
- (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
« no previous file with comments | « chrome/browser/cocoa/bookmark_editor_controller.h ('k') | chrome/browser/cocoa/bookmark_editor_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698