| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" |
| 6 | 6 |
| 7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 10 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 if (url.is_valid()) | 75 if (url.is_valid()) |
| 76 initialUrl_.reset([[NSString stringWithUTF8String:url.spec().c_str()] | 76 initialUrl_.reset([[NSString stringWithUTF8String:url.spec().c_str()] |
| 77 retain]); | 77 retain]); |
| 78 } | 78 } |
| 79 [self setDisplayURL:initialUrl_]; | 79 [self setDisplayURL:initialUrl_]; |
| 80 [super awakeFromNib]; | 80 [super awakeFromNib]; |
| 81 [self expandNodes: | 81 [self expandNodes: |
| 82 [self bookmarkModel]->expanded_state_tracker()->GetExpandedNodes()]; | 82 [self bookmarkModel]->expanded_state_tracker()->GetExpandedNodes()]; |
| 83 } | 83 } |
| 84 | 84 |
| 85 - (void)windowWillClose:(NSNotification*)notification { |
| 86 // Force the field editors to resign the first responder so that they'll |
| 87 // be removed from the view hierarchy and its delegate be set to nil. |
| 88 [[self window] endEditingFor:urlField_]; |
| 89 [[self window] endEditingFor:nameTextField_]; |
| 90 |
| 91 [super windowWillClose:notification]; |
| 92 } |
| 93 |
| 85 - (id)windowWillReturnFieldEditor:(NSWindow*)sender toObject:(id)obj { | 94 - (id)windowWillReturnFieldEditor:(NSWindow*)sender toObject:(id)obj { |
| 86 if (obj == urlField_) { | 95 if (obj == urlField_) { |
| 87 if (!urlFieldEditor_) | 96 if (!urlFieldEditor_) |
| 88 urlFieldEditor_.reset([[DialogTextFieldEditor alloc] init]); | 97 urlFieldEditor_.reset([[DialogTextFieldEditor alloc] init]); |
| 89 | 98 return urlFieldEditor_.get(); |
| 90 return urlFieldEditor_.autorelease(); | |
| 91 } else if (obj == nameTextField_) { | 99 } else if (obj == nameTextField_) { |
| 92 if (!nameFieldEditor_) | 100 if (!nameFieldEditor_) |
| 93 nameFieldEditor_.reset([[DialogTextFieldEditor alloc] init]); | 101 nameFieldEditor_.reset([[DialogTextFieldEditor alloc] init]); |
| 94 | 102 |
| 95 return nameFieldEditor_.autorelease(); | 103 return nameFieldEditor_.get(); |
| 96 } | 104 } |
| 97 | 105 |
| 98 return nil; | 106 return nil; |
| 99 } | 107 } |
| 100 | 108 |
| 101 - (void)nodeRemoved:(const BookmarkNode*)node | 109 - (void)nodeRemoved:(const BookmarkNode*)node |
| 102 fromParent:(const BookmarkNode*)parent | 110 fromParent:(const BookmarkNode*)parent |
| 103 { | 111 { |
| 104 // Be conservative; it is needed (e.g. "Add Page...") | 112 // Be conservative; it is needed (e.g. "Add Page...") |
| 105 node_ = NULL; | 113 node_ = NULL; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 SetExpandedNodes(expanded_nodes); | 180 SetExpandedNodes(expanded_nodes); |
| 173 return [NSNumber numberWithBool:YES]; | 181 return [NSNumber numberWithBool:YES]; |
| 174 } | 182 } |
| 175 | 183 |
| 176 - (NSColor *)urlFieldColor { | 184 - (NSColor *)urlFieldColor { |
| 177 return [urlField_ backgroundColor]; | 185 return [urlField_ backgroundColor]; |
| 178 } | 186 } |
| 179 | 187 |
| 180 @end // BookmarkEditorController | 188 @end // BookmarkEditorController |
| 181 | 189 |
| OLD | NEW |