Chromium Code Reviews| Index: chrome/browser/ui/views/omnibox/omnibox_view_views.cc |
| diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc |
| index bda1e48da0c8e4ddd594b08a7ef90de6b80b935c..9272c6a1a55168cb012b210486efe9a0af9d3c00 100644 |
| --- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc |
| +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc |
| @@ -366,13 +366,17 @@ bool OmniboxViewViews::HandleKeyReleaseEvent(const ui::KeyEvent& event) { |
| } |
| void OmniboxViewViews::HandleMousePressEvent(const ui::MouseEvent& event) { |
| - select_all_on_mouse_release_ = |
| - (event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) && |
| + const bool is_left_or_right_click = |
| + (event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()); |
| + select_all_on_mouse_release_ = is_left_or_right_click && |
| !textfield_->HasFocus(); |
| - // Restore caret visibility whenever the user clicks in the the omnibox. This |
| - // is not always covered by OnSetFocus() because when clicking while the |
| - // omnibox has invisible focus does not trigger a new OnSetFocus() call. |
| - model()->SetCaretVisibility(true); |
| + // Restore caret visibility whenever the user left or right clicks in the the |
| + // omnibox. This is not always covered by OnSetFocus() because when clicking |
| + // while the omnibox has invisible focus does not trigger a new OnSetFocus() |
| + // call. |
| + if (is_left_or_right_click && |
| + (!textfield_->HasFocus() || !model()->is_caret_visible())) |
|
Peter Kasting
2012/12/06 06:02:30
This isn't right... select_all_on_mouse_release_ s
samarth
2012/12/06 16:15:50
Ah ok, makes sense. Done.
|
| + model()->SetCaretVisibility(true); |
| } |
| void OmniboxViewViews::HandleMouseDragEvent(const ui::MouseEvent& event) { |
| @@ -579,14 +583,14 @@ void OmniboxViewViews::UpdatePopup() { |
| } |
| void OmniboxViewViews::SetFocus() { |
| + // In views-implementation, the focus is on textfield rather than OmniboxView. |
| + textfield_->RequestFocus(); |
| // Restore caret visibility if focused explicitly. We need to do this here |
| // because if we already have invisible focus, the RequestFocus() call below |
| // will short-circuit, preventing us from reaching |
| // OmniboxEditModel::OnSetFocus(), which handles restoring visibility when we |
| // didn't previously have focus. |
| model()->SetCaretVisibility(true); |
| - // In views-implementation, the focus is on textfield rather than OmniboxView. |
| - textfield_->RequestFocus(); |
| } |
| void OmniboxViewViews::ApplyCaretVisibility() { |