Commit 90ea187c authored by samarth@chromium.org's avatar samarth@chromium.org

Omnibox: don't assume omnibox has focus in OnAfterPossibleChange().

On Linux, right clicking in the omnibox does not give it focus, so
right-clicking and pasting can change the contents without focus in
the omnibox. Take out the DCHECK that assumes this cannot happen.

Also, change the focus_source_ to assume the source was OMNIBOX in these cases.

BUG=271462
R=pkasting@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217062 0039d316-1c4b-4281-b951-d872f2087c98
parent a02a0c90
...@@ -1032,10 +1032,15 @@ bool OmniboxEditModel::OnAfterPossibleChange(const string16& old_text, ...@@ -1032,10 +1032,15 @@ bool OmniboxEditModel::OnAfterPossibleChange(const string16& old_text,
if (text_differs || selection_differs) { if (text_differs || selection_differs) {
// Record current focus state for this input if we haven't already. // Record current focus state for this input if we haven't already.
DCHECK_NE(OMNIBOX_FOCUS_NONE, focus_state_);
if (focus_source_ == INVALID) { if (focus_source_ == INVALID) {
focus_source_ = (focus_state_ == OMNIBOX_FOCUS_VISIBLE) ? // We should generally expect the omnibox to have focus at this point, but
OMNIBOX : FAKEBOX; // it doesn't always on Linux. This is because, unlike other platforms,
// right clicking in the omnibox on Linux doesn't focus it. So pasting via
// right-click can change the contents without focusing the omnibox.
// TODO(samarth): fix Linux focus behavior and add a DCHECK here to
// check that the omnibox does have focus.
focus_source_ = (focus_state_ == OMNIBOX_FOCUS_INVISIBLE) ?
FAKEBOX : OMNIBOX;
} }
// Restore caret visibility whenever the user changes text or selection in // Restore caret visibility whenever the user changes text or selection in
......
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