diff options
author | suzhe@google.com <suzhe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-28 02:36:49 +0000 |
---|---|---|
committer | suzhe@google.com <suzhe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-28 02:36:49 +0000 |
commit | 911696b92b1b5a666e59433b8b64303a2f4eae62 (patch) | |
tree | a47bab7021b5a34a532b1dae4140b8651558efd5 /chrome/browser/ui/views/location_bar | |
parent | b7d6c22f8092a652d6b4572d4800e8a6aac6ccbe (diff) | |
download | chromium_src-911696b92b1b5a666e59433b8b64303a2f4eae62.zip chromium_src-911696b92b1b5a666e59433b8b64303a2f4eae62.tar.gz chromium_src-911696b92b1b5a666e59433b8b64303a2f4eae62.tar.bz2 |
Hitting Tab should always move cursor to end of omnibox text.
BUG=66850
TEST=AutocompleteEditViewTest.TabMoveCursorToEnd and InstantTest.TabKey
Review URL: http://codereview.chromium.org/5966006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72920 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/views/location_bar')
3 files changed, 26 insertions, 29 deletions
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc index d66b51a..8dc3a25 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc @@ -399,15 +399,6 @@ gfx::Point LocationBarView::GetLocationEntryOrigin() const { return origin; } -#if defined(OS_WIN) -void LocationBarView::OnCommitSuggestedText() { - InstantController* instant = delegate_->GetInstant(); - DCHECK(instant); - DCHECK(suggested_text_view_); - OnCommitSuggestedText(location_entry_->GetText()); -} -#endif - gfx::Size LocationBarView::GetPreferredSize() { return gfx::Size(0, GetThemeProvider()->GetBitmapNamed(mode_ == POPUP ? IDR_LOCATIONBG_POPUPMODE_CENTER : IDR_LOCATIONBG_C)->height()); @@ -768,17 +759,24 @@ void LocationBarView::OnAutocompleteWillAccept() { update_instant_ = false; } -bool LocationBarView::OnCommitSuggestedText(const string16& typed_text) { - InstantController* instant = delegate_->GetInstant(); - if (!instant) +bool LocationBarView::OnCommitSuggestedText(bool skip_inline_autocomplete) { + if (!delegate_->GetInstant()) return false; + string16 suggestion; #if defined(OS_WIN) - if (!HasValidSuggestText()) - return false; - suggestion = suggested_text_view_->GetText(); + if (HasValidSuggestText()) + suggestion = suggested_text_view_->GetText(); +#else + suggestion = location_entry_->GetInstantSuggestion(); #endif - return location_entry_->CommitInstantSuggestion(typed_text, suggestion); + + if (suggestion.empty()) + return false; + + location_entry_->model()->FinalizeInstantQuery( + location_entry_->GetText(), suggestion, skip_inline_autocomplete); + return true; } bool LocationBarView::AcceptCurrentInstantPreview() { @@ -852,13 +850,13 @@ void LocationBarView::OnChanged() { location_entry_->model()->UseVerbatimInstant(), &suggested_text); if (!instant->MightSupportInstant()) { - location_entry_->model()->FinalizeInstantQuery(string16(), - string16()); + location_entry_->model()->FinalizeInstantQuery( + string16(), string16(), false); } } else { instant->DestroyPreviewContents(); - location_entry_->model()->FinalizeInstantQuery(string16(), - string16()); + location_entry_->model()->FinalizeInstantQuery( + string16(), string16(), false); } } @@ -1058,6 +1056,10 @@ bool LocationBarView::SkipDefaultKeyEventProcessing(const views::KeyEvent& e) { return true; } + // If the caret is not at the end, then tab moves the caret to the end. + if (!location_entry_->IsCaretAtEnd()) + return true; + // Tab while showing instant commits instant immediately. // Return true so that focus traversal isn't attempted. The edit ends // up doing nothing in this case. @@ -1128,8 +1130,8 @@ void LocationBarView::SetSuggestedText(const string16& input) { // TODO: if we keep autocomplete, make it so this isn't invoked with empty // text. if (!input.empty()) { - location_entry_->model()->FinalizeInstantQuery(location_entry_->GetText(), - input); + location_entry_->model()->FinalizeInstantQuery( + location_entry_->GetText(), input, false); } return; } diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.h b/chrome/browser/ui/views/location_bar/location_bar_view.h index 90273e9..d149aba 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.h +++ b/chrome/browser/ui/views/location_bar/location_bar_view.h @@ -155,11 +155,6 @@ class LocationBarView : public LocationBar, // appears, not where the icons are shown). gfx::Point GetLocationEntryOrigin() const; -#if defined(OS_WIN) - // Invoked from SuggestedTextView when the suggested text should be committed. - void OnCommitSuggestedText(); -#endif - // Sizing functions virtual gfx::Size GetPreferredSize(); @@ -194,7 +189,7 @@ class LocationBarView : public LocationBar, virtual void OnAutocompleteWillClosePopup(); virtual void OnAutocompleteLosingFocus(gfx::NativeView view_gaining_focus); virtual void OnAutocompleteWillAccept(); - virtual bool OnCommitSuggestedText(const string16& typed_text); + virtual bool OnCommitSuggestedText(bool skip_inline_autocomplete); virtual bool AcceptCurrentInstantPreview(); virtual void OnPopupBoundsChanged(const gfx::Rect& bounds); virtual void OnAutocompleteAccept(const GURL& url, diff --git a/chrome/browser/ui/views/location_bar/suggested_text_view.cc b/chrome/browser/ui/views/location_bar/suggested_text_view.cc index 22b9e9f..6fa19c0 100644 --- a/chrome/browser/ui/views/location_bar/suggested_text_view.cc +++ b/chrome/browser/ui/views/location_bar/suggested_text_view.cc @@ -46,7 +46,7 @@ void SuggestedTextView::PaintBackground(gfx::Canvas* canvas) { } void SuggestedTextView::AnimationEnded(const ui::Animation* animation) { - location_bar_->OnCommitSuggestedText(); + location_bar_->OnCommitSuggestedText(false); } void SuggestedTextView::AnimationProgressed(const ui::Animation* animation) { |