| 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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 void AutocompleteEditViewMac::OnDidResignKey() { | 542 void AutocompleteEditViewMac::OnDidResignKey() { |
| 543 ClosePopup(); | 543 ClosePopup(); |
| 544 } | 544 } |
| 545 | 545 |
| 546 void AutocompleteEditViewMac::AcceptInput( | 546 void AutocompleteEditViewMac::AcceptInput( |
| 547 WindowOpenDisposition disposition, bool for_drop) { | 547 WindowOpenDisposition disposition, bool for_drop) { |
| 548 model_->AcceptInput(disposition, for_drop); | 548 model_->AcceptInput(disposition, for_drop); |
| 549 } | 549 } |
| 550 | 550 |
| 551 void AutocompleteEditViewMac::FocusLocation() { | 551 void AutocompleteEditViewMac::FocusLocation() { |
| 552 [[field_ window] makeFirstResponder:field_]; | 552 // -makeFirstResponder: will select the entire field_. If we're |
| 553 DCHECK_EQ([field_ currentEditor], [[field_ window] firstResponder]); | 553 // already firstResponder, it's likely that we want to retain the |
| 554 // current selection. |
| 555 if (![field_ currentEditor]) { |
| 556 [[field_ window] makeFirstResponder:field_]; |
| 557 DCHECK_EQ([field_ currentEditor], [[field_ window] firstResponder]); |
| 558 } |
| 554 } | 559 } |
| 555 | 560 |
| 556 @implementation AutocompleteFieldDelegate | 561 @implementation AutocompleteFieldDelegate |
| 557 | 562 |
| 558 - initWithEditView:(AutocompleteEditViewMac*)view { | 563 - initWithEditView:(AutocompleteEditViewMac*)view { |
| 559 self = [super init]; | 564 self = [super init]; |
| 560 if (self) { | 565 if (self) { |
| 561 edit_view_ = view; | 566 edit_view_ = view; |
| 562 } | 567 } |
| 563 return self; | 568 return self; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 // TODO(shess): Figure out where the selection belongs. On GTK, | 627 // TODO(shess): Figure out where the selection belongs. On GTK, |
| 623 // it's set to the start of the text. | 628 // it's set to the start of the text. |
| 624 } | 629 } |
| 625 | 630 |
| 626 // Signal that we've lost focus when the window resigns key. | 631 // Signal that we've lost focus when the window resigns key. |
| 627 - (void)windowDidResignKey:(NSNotification*)notification { | 632 - (void)windowDidResignKey:(NSNotification*)notification { |
| 628 edit_view_->OnDidResignKey(); | 633 edit_view_->OnDidResignKey(); |
| 629 } | 634 } |
| 630 | 635 |
| 631 @end | 636 @end |
| OLD | NEW |