Commit 70964960 authored by lenny.khazan's avatar lenny.khazan Committed by Commit bot

Allow users to perform queries in the omnibox which begin with a search

shortcut.

Previously, if a user had (for example) configured a search shortcut of 'cs' which
went to cs.chromium.org, they would be unable to (easily) start a query in the
omnibox starting with 'cs'. Now, backspacing the keyword leaves the space after
the keyword, allowing the user to continue typing without reenabling keyword
mode.

BUG=393371
NOTRY=true
R=pkasting@chromium.org
TEST=type 'google.com ' into the omnibar and it should enter keyword mode.
Press backspace and 'google.com ' will be left in the omnibar, rather than
'google.com'.

Review URL: https://codereview.chromium.org/477873002

Cr-Commit-Position: refs/heads/master@{#322429}
parent 044f3ca9
...@@ -291,6 +291,7 @@ Laszlo Radanyi <bekkra@gmail.com> ...@@ -291,6 +291,7 @@ Laszlo Radanyi <bekkra@gmail.com>
Lauren Yeun Kim <lauren.yeun.kim@gmail.com> Lauren Yeun Kim <lauren.yeun.kim@gmail.com>
Lauri Oherd <lauri.oherd@gmail.com> Lauri Oherd <lauri.oherd@gmail.com>
Leith Bade <leith@leithalweapon.geek.nz> Leith Bade <leith@leithalweapon.geek.nz>
Lenny Khazan <lenny.khazan@gmail.com>
Li Yin <li.yin@intel.com> Li Yin <li.yin@intel.com>
Lidwine Genevet <lgenevet@cisco.com> Lidwine Genevet <lgenevet@cisco.com>
Lionel Landwerlin <lionel.g.landwerlin@intel.com> Lionel Landwerlin <lionel.g.landwerlin@intel.com>
......
...@@ -880,14 +880,17 @@ void OmniboxEditModel::ClearKeyword(const base::string16& visible_text) { ...@@ -880,14 +880,17 @@ void OmniboxEditModel::ClearKeyword(const base::string16& visible_text) {
autocomplete_controller()->Stop(false); autocomplete_controller()->Stop(false);
omnibox_controller_->ClearPopupKeywordMode(); omnibox_controller_->ClearPopupKeywordMode();
const base::string16 window_text(keyword_ + visible_text); // Add a space after the keyword to allow the user to continue typing without
// re-enabling keyword mode.
const base::string16 window_text =
keyword_ + base::ASCIIToUTF16(" ") + visible_text;
// Only reset the result if the edit text has changed since the // Only reset the result if the edit text has changed since the
// keyword was accepted, or if the popup is closed. // keyword was accepted, or if the popup is closed.
if (just_deleted_text_ || !visible_text.empty() || if (just_deleted_text_ || !visible_text.empty() ||
!(popup_model() && popup_model()->IsOpen())) { !(popup_model() && popup_model()->IsOpen())) {
view_->OnBeforePossibleChange(); view_->OnBeforePossibleChange();
view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(), view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length() + 1,
false, false); false, false);
keyword_.clear(); keyword_.clear();
is_keyword_hint_ = false; is_keyword_hint_ = false;
...@@ -897,7 +900,7 @@ void OmniboxEditModel::ClearKeyword(const base::string16& visible_text) { ...@@ -897,7 +900,7 @@ void OmniboxEditModel::ClearKeyword(const base::string16& visible_text) {
// longer. // longer.
} else { } else {
is_keyword_hint_ = true; is_keyword_hint_ = true;
view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(), view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length() + 1,
false, true); false, true);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment