summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkerz@chromium.org <kerz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-31 00:40:53 +0000
committerkerz@chromium.org <kerz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-31 00:40:53 +0000
commit427cba8e96a39e381d26a3c36d1cfd7630f0e573 (patch)
tree45e0f7233de7516761ba459c120a21966c9f0ae3
parent6a0cc4aebc98d16d8f5a8eff936b6105169b9eee (diff)
downloadchromium_src-427cba8e96a39e381d26a3c36d1cfd7630f0e573.zip
chromium_src-427cba8e96a39e381d26a3c36d1cfd7630f0e573.tar.gz
chromium_src-427cba8e96a39e381d26a3c36d1cfd7630f0e573.tar.bz2
Merge 214446 "Fix Ctrl-shift-left to select words in the omnibox."
> Fix Ctrl-shift-left to select words in the omnibox. > > BUG=261176 > > Review URL: https://chromiumcodereview.appspot.com/19494006 TBR=hfung@chromium.org Review URL: https://codereview.chromium.org/21307005 git-svn-id: svn://svn.chromium.org/chrome/branches/1547/src@214491 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/omnibox/omnibox_edit_model.cc41
-rw-r--r--chrome/browser/ui/omnibox/omnibox_view_browsertest.cc32
2 files changed, 50 insertions, 23 deletions
diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
index b9fc0b8..b0715bf 100644
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
@@ -1051,40 +1051,35 @@ bool OmniboxEditModel::OnAfterPossibleChange(const string16& old_text,
text_differs || (selection_differs && !inline_autocomplete_text_.empty());
// If something has changed while the control key is down, prevent
- // "ctrl-enter" until the control key is released. When we do this, we need
- // to update the popup if it's open, since the desired_tld will have changed.
+ // "ctrl-enter" until the control key is released.
if ((text_differs || selection_differs) &&
- (control_key_state_ == DOWN_WITHOUT_CHANGE)) {
+ (control_key_state_ == DOWN_WITHOUT_CHANGE))
control_key_state_ = DOWN_WITH_CHANGE;
- if (!text_differs && !popup_model()->IsOpen())
- return false; // Don't open the popup for no reason.
- } else if (!user_text_changed) {
+
+ if (!user_text_changed)
return false;
- }
// If the user text has not changed, we do not want to change the model's
// state associated with the text. Otherwise, we can get surprising behavior
// where the autocompleted text unexpectedly reappears, e.g. crbug.com/55983
- if (user_text_changed) {
- InternalSetUserText(UserTextFromDisplayText(new_text));
- has_temporary_text_ = false;
+ InternalSetUserText(UserTextFromDisplayText(new_text));
+ has_temporary_text_ = false;
is_temporary_text_set_by_instant_ = false;
selected_instant_autocomplete_match_index_ = OmniboxPopupModel::kNoMatch;
is_instant_temporary_text_a_search_query_ = false;
- // Track when the user has deleted text so we won't allow inline
- // autocomplete.
- just_deleted_text_ = just_deleted_text;
-
- if (user_input_in_progress_ && user_text_.empty()) {
- // Log cases where the user started editing and then subsequently cleared
- // all the text. Note that this explicitly doesn't catch cases like
- // "hit ctrl-l to select whole edit contents, then hit backspace", because
- // in such cases, |user_input_in_progress| won't be true here.
- UMA_HISTOGRAM_ENUMERATION(kOmniboxUserTextClearedHistogram,
- OMNIBOX_USER_TEXT_CLEARED_BY_EDITING,
- OMNIBOX_USER_TEXT_CLEARED_NUM_OF_ITEMS);
- }
+ // Track when the user has deleted text so we won't allow inline
+ // autocomplete.
+ just_deleted_text_ = just_deleted_text;
+
+ if (user_input_in_progress_ && user_text_.empty()) {
+ // Log cases where the user started editing and then subsequently cleared
+ // all the text. Note that this explicitly doesn't catch cases like
+ // "hit ctrl-l to select whole edit contents, then hit backspace", because
+ // in such cases, |user_input_in_progress| won't be true here.
+ UMA_HISTOGRAM_ENUMERATION(kOmniboxUserTextClearedHistogram,
+ OMNIBOX_USER_TEXT_CLEARED_BY_EDITING,
+ OMNIBOX_USER_TEXT_CLEARED_NUM_OF_ITEMS);
}
const bool no_selection = selection_start == selection_end;
diff --git a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
index 9e3e8ee..c6c534f 100644
--- a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
+++ b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
@@ -1847,3 +1847,35 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewTest, BeginningShownAfterBlur) {
ASSERT_EQ(0U, end);
}
#endif // !defined(TOOLKIT_GTK)
+
+IN_PROC_BROWSER_TEST_F(OmniboxViewTest, CtrlArrowAfterArrowSuggestions) {
+ OmniboxView* omnibox_view = NULL;
+ ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
+ OmniboxPopupModel* popup_model = omnibox_view->model()->popup_model();
+ ASSERT_TRUE(popup_model);
+
+ // Input something to trigger results.
+ ASSERT_NO_FATAL_FAILURE(SendKeySequence(kDesiredTLDKeys));
+ ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
+ ASSERT_TRUE(popup_model->IsOpen());
+
+ ASSERT_EQ(ASCIIToUTF16("bar.com/1"), omnibox_view->GetText());
+
+ // Arrow down on a suggestion, and omnibox text should be the suggestion.
+ ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_DOWN, 0));
+ ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
+ ASSERT_EQ(ASCIIToUTF16("www.bar.com/2"), omnibox_view->GetText());
+
+ // Highlight the last 2 words and the omnibox text should not change.
+ // Simulating Ctrl-shift-left only once does not seem to highlight anything
+ // on Linux.
+#if defined(OS_MACOSX)
+ // Mac uses alt-left/right to select a word.
+ const int modifiers = ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN;
+#else
+ const int modifiers = ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN;
+#endif
+ ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, modifiers));
+ ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, modifiers));
+ ASSERT_EQ(ASCIIToUTF16("www.bar.com/2"), omnibox_view->GetText());
+}