summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
diff options
context:
space:
mode:
authorsamarth@chromium.org <samarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-12 04:18:16 +0000
committersamarth@chromium.org <samarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-12 04:18:16 +0000
commit6a6811ae25d84530cfdcb5b73cffddb8f4497a04 (patch)
tree59baed7c1d2ef0066872b5ec109991d220f97ba6 /chrome/browser/ui/views/omnibox/omnibox_view_views.cc
parentb358c951e427a6c5a6e14a8c84440f8631cae40a (diff)
downloadchromium_src-6a6811ae25d84530cfdcb5b73cffddb8f4497a04.zip
chromium_src-6a6811ae25d84530cfdcb5b73cffddb8f4497a04.tar.gz
chromium_src-6a6811ae25d84530cfdcb5b73cffddb8f4497a04.tar.bz2
Instant API: tell page whether the browser is capturing key strokes.
TESTED=manual, per bug BUG=164782 Review URL: https://chromiumcodereview.appspot.com/11413217 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172524 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/views/omnibox/omnibox_view_views.cc')
-rw-r--r--chrome/browser/ui/views/omnibox/omnibox_view_views.cc26
1 files changed, 15 insertions, 11 deletions
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
index fce7818..07b7c56 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/chromeos/input_method/input_method_configuration.h"
#include "chrome/browser/command_updater.h"
#include "chrome/browser/ui/omnibox/omnibox_edit_controller.h"
+#include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
#include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
#include "chrome/browser/ui/search/search.h"
#include "chrome/browser/ui/view_ids.h"
@@ -361,11 +362,14 @@ bool OmniboxViewViews::HandleKeyReleaseEvent(const ui::KeyEvent& event) {
void OmniboxViewViews::HandleMousePressEvent(const ui::MouseEvent& event) {
select_all_on_mouse_release_ =
(event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) &&
- !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);
+ (!textfield_->HasFocus() ||
+ (model()->focus_state() == OMNIBOX_FOCUS_INVISIBLE));
+ // Restore caret visibility whenever the user clicks in the omnibox in a way
+ // that would give it focus. We must handle this case separately here because
+ // if the omnibox currently has invisible focus, the mouse event won't trigger
+ // either SetFocus() or OmniboxEditModel::OnSetFocus().
+ if (select_all_on_mouse_release_)
+ model()->SetCaretVisibility(true);
}
void OmniboxViewViews::HandleMouseDragEvent(const ui::MouseEvent& event) {
@@ -572,14 +576,14 @@ void OmniboxViewViews::UpdatePopup() {
}
void OmniboxViewViews::SetFocus() {
- // 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();
+ // Restore caret visibility if focus is explicitly requested. This is
+ // necessary because if we already have invisible focus, the RequestFocus()
+ // call above will short-circuit, preventing us from reaching
+ // OmniboxEditModel::OnSetFocus(), which handles restoring visibility when the
+ // omnibox regains focus after losing focus.
+ model()->SetCaretVisibility(true);
}
void OmniboxViewViews::ApplyCaretVisibility() {