summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-23 03:29:11 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-23 03:29:11 +0000
commite80a42b2517ee31d28db08f60ff9322c3d704806 (patch)
tree349c86c71db465f322cac0dda6580fbe593cfa55 /chrome/browser
parent33551efc75fe523dfaa1f9a6d36696e431324fd0 (diff)
downloadchromium_src-e80a42b2517ee31d28db08f60ff9322c3d704806.zip
chromium_src-e80a42b2517ee31d28db08f60ff9322c3d704806.tar.gz
chromium_src-e80a42b2517ee31d28db08f60ff9322c3d704806.tar.bz2
Makes right arrow in omnibox commit suggest results.
BUG=54833 TEST=none Review URL: http://codereview.chromium.org/3493002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60255 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit.h4
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_unittest.cc3
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_win.cc16
-rw-r--r--chrome/browser/views/location_bar/location_bar_view.cc13
-rw-r--r--chrome/browser/views/location_bar/location_bar_view.h1
5 files changed, 35 insertions, 2 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit.h b/chrome/browser/autocomplete/autocomplete_edit.h
index caca730..33420dd 100644
--- a/chrome/browser/autocomplete/autocomplete_edit.h
+++ b/chrome/browser/autocomplete/autocomplete_edit.h
@@ -45,6 +45,10 @@ class AutocompleteEditController {
// Sent prior to OnAutoCompleteAccept and before the model has been reverted.
virtual void OnAutocompleteWillAccept() = 0;
+ // Commits the suggested text. |typed_text| is the current text showing in the
+ // autocomplete. Returns true if the text was committed.
+ virtual bool OnCommitSuggestedText(const std::wstring& typed_text) = 0;
+
// Invoked when the popup is going to change its bounds to |bounds|.
virtual void OnPopupBoundsChanged(const gfx::Rect& bounds) = 0;
#else
diff --git a/chrome/browser/autocomplete/autocomplete_edit_unittest.cc b/chrome/browser/autocomplete/autocomplete_edit_unittest.cc
index bca3c54..6451fa6 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_unittest.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_unittest.cc
@@ -64,6 +64,9 @@ class TestingAutocompleteEditController : public AutocompleteEditController {
virtual void OnAutocompleteWillClosePopup() {}
virtual void OnAutocompleteLosingFocus(gfx::NativeView view_gaining_focus) {}
virtual void OnAutocompleteWillAccept() {}
+ virtual bool OnCommitSuggestedText(const std::wstring& typed_text) {
+ return false;
+ }
virtual void OnPopupBoundsChanged(const gfx::Rect& bounds) {}
virtual void OnAutocompleteAccept(const GURL& url,
WindowOpenDisposition disposition,
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
index 2238584..37419d1 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
@@ -1825,10 +1825,22 @@ bool AutocompleteEditViewWin::OnKeyDownOnlyWritable(TCHAR key,
// WM_SYSKEYDOWN, so we need to check (flags & KF_ALTDOWN) in various places
// in this function even with a WM_SYSKEYDOWN handler.
- // Update LocationBarView::SkipDefaultKeyEventProcessing() as well when you
- // add some key combinations here.
+ // If adding a new key that could possibly be an accelerator then you'll need
+ // to update LocationBarView::SkipDefaultKeyEventProcessing() as well.
int count = repeat_count;
switch (key) {
+ case VK_RIGHT:
+ // TODO(sky): figure out RTL.
+ if (base::i18n::IsRTL())
+ return false;
+ {
+ CHARRANGE selection;
+ GetSel(selection);
+ return (selection.cpMin == selection.cpMax) &&
+ (selection.cpMin == GetTextLength()) &&
+ controller_->OnCommitSuggestedText(GetText());
+ }
+
case VK_RETURN:
model_->AcceptInput((flags & KF_ALTDOWN) ?
NEW_FOREGROUND_TAB : CURRENT_TAB, false);
diff --git a/chrome/browser/views/location_bar/location_bar_view.cc b/chrome/browser/views/location_bar/location_bar_view.cc
index 193408a..d6730ca 100644
--- a/chrome/browser/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/views/location_bar/location_bar_view.cc
@@ -746,6 +746,19 @@ void LocationBarView::OnAutocompleteWillAccept() {
update_match_preview_ = false;
}
+bool LocationBarView::OnCommitSuggestedText(const std::wstring& typed_text) {
+ MatchPreview* match_preview = delegate_->GetMatchPreview();
+ if (!match_preview || !suggested_text_view_ ||
+ suggested_text_view_->size().IsEmpty() ||
+ suggested_text_view_->GetText().empty()) {
+ return false;
+ }
+ // TODO(sky): I may need to route this through MatchPreview so that we don't
+ // fetch suggestions for the new combined text.
+ location_entry_->SetUserText(typed_text + suggested_text_view_->GetText());
+ return true;
+}
+
void LocationBarView::OnPopupBoundsChanged(const gfx::Rect& bounds) {
MatchPreview* match_preview = delegate_->GetMatchPreview();
if (match_preview)
diff --git a/chrome/browser/views/location_bar/location_bar_view.h b/chrome/browser/views/location_bar/location_bar_view.h
index dd01100..1daf264 100644
--- a/chrome/browser/views/location_bar/location_bar_view.h
+++ b/chrome/browser/views/location_bar/location_bar_view.h
@@ -178,6 +178,7 @@ class LocationBarView : public LocationBar,
virtual void OnAutocompleteWillClosePopup();
virtual void OnAutocompleteLosingFocus(gfx::NativeView view_gaining_focus);
virtual void OnAutocompleteWillAccept();
+ virtual bool OnCommitSuggestedText(const std::wstring& typed_text);
virtual void OnPopupBoundsChanged(const gfx::Rect& bounds);
virtual void OnAutocompleteAccept(const GURL& url,
WindowOpenDisposition disposition,