diff options
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_mac.h | 7 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_mac.mm | 17 |
2 files changed, 15 insertions, 9 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h index aac879b..0c0cb2b 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h +++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h @@ -112,10 +112,11 @@ class AutocompleteEditViewMac : public AutocompleteEditView { // Called when the user attempts to paste into |field_|. void OnPaste(); - void AcceptInput(WindowOpenDisposition disposition, bool for_drop); + // Checks if a keyword search is possible and forwards to |model_| + // if so. Returns true if the tab should be eaten. + bool OnTabPressed(); - // Forwards to |model_| when user hits Tab. - void AcceptKeyword(); + void AcceptInput(WindowOpenDisposition disposition, bool for_drop); // Helper for LocationBarViewMac. Selects all in |field_|. void FocusLocation(); diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm index d115c88..9ca8a6b 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm +++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm @@ -622,6 +622,14 @@ void AutocompleteEditViewMac::OnPaste() { OnAfterPossibleChange(); } +bool AutocompleteEditViewMac::OnTabPressed() { + if (model_->is_keyword_hint() && !model_->keyword().empty()) { + model_->AcceptKeyword(); + return true; + } + return false; +} + bool AutocompleteEditViewMac::IsPopupOpen() const { return popup_view_->IsOpen(); } @@ -635,10 +643,6 @@ void AutocompleteEditViewMac::AcceptInput( model_->AcceptInput(disposition, for_drop); } -void AutocompleteEditViewMac::AcceptKeyword() { - model_->AcceptKeyword(); -} - void AutocompleteEditViewMac::FocusLocation() { [[field_ window] makeFirstResponder:field_]; DCHECK_EQ([field_ currentEditor], [[field_ window] firstResponder]); @@ -725,8 +729,9 @@ std::wstring AutocompleteEditViewMac::GetClipboardText(Clipboard* clipboard) { } if (cmd == @selector(insertTab:)) { - edit_view_->AcceptKeyword(); - return YES; + if (edit_view_->OnTabPressed()) { + return YES; + } } // |-noop:| is sent when the user presses Cmd+Return. Override the no-op |