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 76c7453d52281e7fb2c4f4c2b2c1d68aca638a8b..44f1fef67baab2f4114ae97535b137ac2e694475 100644 |
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc |
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc |
@@ -444,7 +444,7 @@ void OmniboxViewViews::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
} |
//////////////////////////////////////////////////////////////////////////////// |
-// OmniboxViewViews, AutocopmleteEditView implementation: |
+// OmniboxViewViews, AutocompleteEditView implementation: |
void OmniboxViewViews::SaveStateToTab(WebContents* tab) { |
DCHECK(tab); |
@@ -484,6 +484,7 @@ void OmniboxViewViews::Update(const WebContents* contents) { |
contents->GetUserData(&kAutocompleteEditStateKey)); |
if (state) { |
model()->RestoreState(state->model_state); |
+ ApplyFocusVisibility(); |
// Move the marks for the cursor and the other end of the selection to |
// the previously-saved offsets (but preserve PRIMARY). |
@@ -573,6 +574,16 @@ void OmniboxViewViews::UpdatePopup() { |
} |
void OmniboxViewViews::SetFocus() { |
+ model()->set_is_focus_visible(true); |
+ ApplyFocusVisibility(); |
+ // In views-implementation, the focus is on textfield rather than OmniboxView. |
+ textfield_->RequestFocus(); |
+} |
+ |
+void OmniboxViewViews::SetInvisibleFocus() { |
+ DLOG(0) << "SetInvisibleFocus"; |
+ model()->set_is_focus_visible(false); |
+ ApplyFocusVisibility(); |
// In views-implementation, the focus is on textfield rather than OmniboxView. |
textfield_->RequestFocus(); |
} |
@@ -603,6 +614,10 @@ void OmniboxViewViews::OnRevertTemporaryText() { |
} |
void OmniboxViewViews::OnBeforePossibleChange() { |
+ // Since this is called when the user directly clicks on the omnibox |
+ // regardless of its focus state, we reset the focus to visible. |
+ model()->set_is_focus_visible(true); |
+ ApplyFocusVisibility(); |
// Record our state. |
text_before_change_ = GetText(); |
textfield_->GetSelectedRange(&sel_before_change_); |
@@ -940,3 +955,9 @@ void OmniboxViewViews::OnPaste() { |
textfield_->ReplaceSelection(text); |
} |
} |
+ |
+void OmniboxViewViews::ApplyFocusVisibility() { |
+ textfield_->SetCursorColor(model()->is_focus_visible() ? |
+ SK_ColorBLACK : textfield_->background_color()); |
samarth
2012/11/28 17:43:54
Is BLACK always correct? If not, we may need to s
Mathieu
2012/11/28 21:03:06
Thanks for the comment. I've changed the logic so
|
+} |
+ |