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 94a93c12ce9687e8fb8519dc54b6f1b606317b60..157d748f064457d5166dc82d9811ec7dab9e30fa 100644 |
| --- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc |
| +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc |
| @@ -224,7 +224,8 @@ OmniboxViewViews::OmniboxViewViews(OmniboxEditController* controller, |
| delete_at_end_pressed_(false), |
| location_bar_view_(location_bar), |
| ime_candidate_window_open_(false), |
| - select_all_on_mouse_release_(false) { |
| + select_all_on_mouse_release_(false), |
| + visible_caret_color_(SK_ColorBLACK) { |
| } |
| OmniboxViewViews::~OmniboxViewViews() { |
| @@ -368,6 +369,10 @@ 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); |
| } |
| void OmniboxViewViews::HandleMouseDragEvent(const ui::MouseEvent& event) { |
| @@ -445,7 +450,7 @@ void OmniboxViewViews::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| -// OmniboxViewViews, AutocopmleteEditView implementation: |
| +// OmniboxViewViews, OmniboxView implementation: |
| void OmniboxViewViews::SaveStateToTab(WebContents* tab) { |
| DCHECK(tab); |
| @@ -574,10 +579,21 @@ void OmniboxViewViews::UpdatePopup() { |
| } |
| void OmniboxViewViews::SetFocus() { |
| + // Restore caret visibility if focused explicitly. |
|
Peter Kasting
2012/12/05 00:52:53
Nit: Add: "We need to do this here because if we a
samarth
2012/12/05 01:15:51
Yes, exactly; updated comment.
|
| + model()->SetCaretVisibility(true); |
| // In views-implementation, the focus is on textfield rather than OmniboxView. |
| textfield_->RequestFocus(); |
| } |
| +void OmniboxViewViews::ApplyCaretVisibility() { |
| + if (textfield_->cursor_color() != textfield_->background_color()) |
| + visible_caret_color_ = textfield_->cursor_color(); |
| + // Setting the color of the text cursor (caret) to the background color |
| + // effectively hides it. |
| + textfield_->SetCursorColor(model()->is_caret_visible() ? |
| + visible_caret_color_ : textfield_->background_color()); |
| +} |
| + |
| void OmniboxViewViews::OnTemporaryTextMaybeChanged( |
| const string16& display_text, |
| bool save_original_selection) { |