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 "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
8 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 8 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
10 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" | 10 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 | 554 |
555 void AutocompleteEditViewMac::AcceptInput( | 555 void AutocompleteEditViewMac::AcceptInput( |
556 WindowOpenDisposition disposition, bool for_drop) { | 556 WindowOpenDisposition disposition, bool for_drop) { |
557 // We should only arrive here when the field is focussed. | 557 // We should only arrive here when the field is focussed. |
558 DCHECK([field_ currentEditor]); | 558 DCHECK([field_ currentEditor]); |
559 | 559 |
560 model_->AcceptInput(disposition, for_drop); | 560 model_->AcceptInput(disposition, for_drop); |
561 } | 561 } |
562 | 562 |
563 void AutocompleteEditViewMac::FocusLocation() { | 563 void AutocompleteEditViewMac::FocusLocation() { |
564 // -makeFirstResponder: will select the entire field_. If we're | 564 [[field_ window] makeFirstResponder:field_]; |
565 // already firstResponder, it's likely that we want to retain the | 565 DCHECK_EQ([field_ currentEditor], [[field_ window] firstResponder]); |
566 // current selection. | |
567 if (![field_ currentEditor]) { | |
568 [[field_ window] makeFirstResponder:field_]; | |
569 DCHECK_EQ([field_ currentEditor], [[field_ window] firstResponder]); | |
570 } | |
571 } | 566 } |
572 | 567 |
573 @implementation AutocompleteFieldDelegate | 568 @implementation AutocompleteFieldDelegate |
574 | 569 |
575 - initWithEditView:(AutocompleteEditViewMac*)view { | 570 - initWithEditView:(AutocompleteEditViewMac*)view { |
576 self = [super init]; | 571 self = [super init]; |
577 if (self) { | 572 if (self) { |
578 edit_view_ = view; | 573 edit_view_ = view; |
579 } | 574 } |
580 return self; | 575 return self; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 // TODO(shess): Figure out where the selection belongs. On GTK, | 634 // TODO(shess): Figure out where the selection belongs. On GTK, |
640 // it's set to the start of the text. | 635 // it's set to the start of the text. |
641 } | 636 } |
642 | 637 |
643 // Signal that we've lost focus when the window resigns key. | 638 // Signal that we've lost focus when the window resigns key. |
644 - (void)windowDidResignKey:(NSNotification*)notification { | 639 - (void)windowDidResignKey:(NSNotification*)notification { |
645 edit_view_->OnDidResignKey(); | 640 edit_view_->OnDidResignKey(); |
646 } | 641 } |
647 | 642 |
648 @end | 643 @end |
OLD | NEW |