OLD | NEW |
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 "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" |
6 | 6 |
7 #include <Carbon/Carbon.h> // kVK_Return | 7 #include <Carbon/Carbon.h> // kVK_Return |
8 #include "app/gfx/font.h" | 8 #include "app/gfx/font.h" |
9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
10 #include "base/clipboard.h" | 10 #include "base/clipboard.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 177 |
178 // Destroy popup view before this object in case it tries to call us | 178 // Destroy popup view before this object in case it tries to call us |
179 // back in the destructor. Likewise for destroying the model before | 179 // back in the destructor. Likewise for destroying the model before |
180 // this object. | 180 // this object. |
181 popup_view_.reset(); | 181 popup_view_.reset(); |
182 model_.reset(); | 182 model_.reset(); |
183 | 183 |
184 // Disconnect field_ from edit_helper_ so that we don't get calls | 184 // Disconnect field_ from edit_helper_ so that we don't get calls |
185 // after destruction. | 185 // after destruction. |
186 [field_ setDelegate:nil]; | 186 [field_ setDelegate:nil]; |
187 | |
188 // Disconnect notifications so they don't signal a dead object. | |
189 [[NSNotificationCenter defaultCenter] removeObserver:edit_helper_]; | |
190 } | 187 } |
191 | 188 |
192 void AutocompleteEditViewMac::SaveStateToTab(TabContents* tab) { | 189 void AutocompleteEditViewMac::SaveStateToTab(TabContents* tab) { |
193 DCHECK(tab); | 190 DCHECK(tab); |
194 | 191 |
195 const bool hasFocus = [field_ currentEditor] ? true : false; | 192 const bool hasFocus = [field_ currentEditor] ? true : false; |
196 | 193 |
197 NSRange range; | 194 NSRange range; |
198 if (hasFocus) { | 195 if (hasFocus) { |
199 range = GetSelectedRange(); | 196 range = GetSelectedRange(); |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 @implementation AutocompleteFieldDelegate | 707 @implementation AutocompleteFieldDelegate |
711 | 708 |
712 - initWithEditView:(AutocompleteEditViewMac*)view { | 709 - initWithEditView:(AutocompleteEditViewMac*)view { |
713 self = [super init]; | 710 self = [super init]; |
714 if (self) { | 711 if (self) { |
715 edit_view_ = view; | 712 edit_view_ = view; |
716 } | 713 } |
717 return self; | 714 return self; |
718 } | 715 } |
719 | 716 |
| 717 - (void)dealloc { |
| 718 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 719 [super dealloc]; |
| 720 } |
| 721 |
720 - (BOOL)control:(NSControl*)control | 722 - (BOOL)control:(NSControl*)control |
721 textView:(NSTextView*)textView doCommandBySelector:(SEL)cmd { | 723 textView:(NSTextView*)textView doCommandBySelector:(SEL)cmd { |
722 // Don't intercept up/down-arrow if the popup isn't open. | 724 // Don't intercept up/down-arrow if the popup isn't open. |
723 if (edit_view_->IsPopupOpen()) { | 725 if (edit_view_->IsPopupOpen()) { |
724 if (cmd == @selector(moveDown:)) { | 726 if (cmd == @selector(moveDown:)) { |
725 edit_view_->OnUpOrDownKeyPressed(false, false); | 727 edit_view_->OnUpOrDownKeyPressed(false, false); |
726 return YES; | 728 return YES; |
727 } | 729 } |
728 | 730 |
729 if (cmd == @selector(moveUp:)) { | 731 if (cmd == @selector(moveUp:)) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 // prepended and ".com" appended. This calls down to | 833 // prepended and ".com" appended. This calls down to |
832 // AutocompleteEditModel::OnControlKeyChanged() so that it can change | 834 // AutocompleteEditModel::OnControlKeyChanged() so that it can change |
833 // the popup to reflect this. See autocomplete_edit.cc | 835 // the popup to reflect this. See autocomplete_edit.cc |
834 // OnControlKeyChanged() and OnAfterPossibleChange(). | 836 // OnControlKeyChanged() and OnAfterPossibleChange(). |
835 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent { | 837 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent { |
836 BOOL controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0; | 838 BOOL controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0; |
837 edit_view_->OnControlKeyChanged(controlFlag); | 839 edit_view_->OnControlKeyChanged(controlFlag); |
838 } | 840 } |
839 | 841 |
840 @end | 842 @end |
OLD | NEW |