Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: chrome/browser/ui/views/omnibox/omnibox_view_views.cc

Issue 11413217: Instant API: tell page whether the browser is capturing key strokes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@focus
Patch Set: Fix tests. Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 cd5a16f8a4cf16c73a878db61bc805fe445b381f..3389d9ba682472e44ae87634834dafd7a0470826 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/tab_contents/tab_contents.h"
@@ -362,11 +363,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) {
@@ -573,14 +577,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() {
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_edit_model.cc ('k') | chrome/browser/ui/views/omnibox/omnibox_view_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698