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

Unified Diff: chrome/browser/ui/views/omnibox/omnibox_view_win.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
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.cc ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/omnibox/omnibox_view_win.cc
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
index 32dda4bd89fbc87d5f25d4d155b8fe4c76e6ff15..5059591c35e695c5575c43bf31cb0a2fac0d42df 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
@@ -33,6 +33,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.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/views/location_bar/location_bar_view.h"
@@ -761,10 +762,11 @@ void OmniboxViewWin::UpdatePopup() {
void OmniboxViewWin::SetFocus() {
::SetFocus(m_hWnd);
- // Restore caret visibility if focused explicitly. We need to do this here
- // because if we already have invisible focus, the ::SetFocus call above will
- // short-circuit, preventing us from reaching OmniboxEditModel::OnSetFocus(),
- // which handles restoring visibility when we didn't previously have focus.
+ // Restore caret visibility if focus is explicitly requested. This is
+ // necessary because if we already have invisible focus, the ::SetFocus()
+ // 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);
}
@@ -1772,7 +1774,8 @@ LRESULT OmniboxViewWin::OnMouseActivate(HWND window,
// reached before OnXButtonDown(), preventing us from detecting this properly
// there. Also in those cases, we need to already know in OnSetFocus() that
// we should not restore the saved selection.
- if ((!model()->has_focus() || !model()->is_caret_visible()) &&
+ if ((!model()->has_focus() ||
+ (model()->focus_state() == OMNIBOX_FOCUS_INVISIBLE)) &&
((mouse_message == WM_LBUTTONDOWN || mouse_message == WM_RBUTTONDOWN)) &&
(result == MA_ACTIVATE)) {
if (gaining_focus_) {
@@ -1783,8 +1786,10 @@ LRESULT OmniboxViewWin::OnMouseActivate(HWND window,
}
gaining_focus_.reset(new ScopedFreeze(this, GetTextObjectModel()));
- // Explicitely set focus visibility in the case of clicking on the omnibox,
- // which will remove invisible focus if present.
+ // 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().
model()->SetCaretVisibility(true);
// NOTE: Despite |mouse_message| being WM_XBUTTONDOWN here, we're not
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.cc ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698