| Index: chrome/browser/ui/omnibox/omnibox_edit_model.cc
|
| diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
|
| index 668d9a820ea8ff5b715b1dba83d0cf0d3f6ab002..9997a9870902da9e5119c3ae53062964d4114df8 100644
|
| --- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc
|
| +++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
|
| @@ -136,7 +136,7 @@ const OmniboxEditModel::State OmniboxEditModel::GetStateForTabSwitch() {
|
| }
|
|
|
| void OmniboxEditModel::RestoreState(const State& state) {
|
| - SetCaretVisibility(state.is_caret_visible);
|
| + SetCaretVisibilityInternal(state.is_caret_visible, FOCUS_CHANGE_TAB_SWITCH);
|
| // Restore any user editing.
|
| if (state.user_input_in_progress) {
|
| // NOTE: Be sure and set keyword-related state BEFORE invoking
|
| @@ -715,11 +715,18 @@ const AutocompleteResult& OmniboxEditModel::result() const {
|
| void OmniboxEditModel::OnSetFocus(bool control_down) {
|
| has_focus_ = true;
|
| control_key_state_ = control_down ? DOWN_WITHOUT_CHANGE : UP;
|
| - // Restore caret visibility whenever the user focuses back into the omnibox.
|
| + // If the omnibox lost focus while the caret was hidden and then regained
|
| + // focus, OnSetFocus() is called and should restore visibility. Note that
|
| + // focus can be regained without an accompanying call to
|
| + // OmniboxView::SetFocus(), e.g. by tabbing in.
|
| SetCaretVisibility(true);
|
|
|
| - if (InstantController* instant = controller_->GetInstant())
|
| - instant->OmniboxGotFocus();
|
| + // The SetCaretVisibility call above will already send an update to the
|
| + // InstantController in some cases but we still need this here since it won't
|
| + // send an update if the caret was already visible.
|
| + InstantController* instant = controller_->GetInstant();
|
| + if (instant)
|
| + instant->OmniboxFocusChanged(FOCUS_VISIBLE, FOCUS_CHANGE_EXPLICIT, NULL);
|
|
|
| content::WebContents* web_contents = controller_->GetWebContents();
|
| if (web_contents) {
|
| @@ -736,17 +743,17 @@ void OmniboxEditModel::OnSetFocus(bool control_down) {
|
| }
|
|
|
| void OmniboxEditModel::SetCaretVisibility(bool visible) {
|
| - if (has_focus_ && visible != is_caret_visible_) {
|
| - is_caret_visible_ = visible;
|
| - view_->ApplyCaretVisibility();
|
| - }
|
| + SetCaretVisibilityInternal(visible, FOCUS_CHANGE_EXPLICIT);
|
| }
|
|
|
| void OmniboxEditModel::OnWillKillFocus(gfx::NativeView view_gaining_focus) {
|
| SetInstantSuggestion(InstantSuggestion());
|
|
|
| - if (InstantController* instant = controller_->GetInstant())
|
| - instant->OmniboxLostFocus(view_gaining_focus);
|
| + InstantController* instant = controller_->GetInstant();
|
| + if (instant) {
|
| + instant->OmniboxFocusChanged(FOCUS_NONE, FOCUS_CHANGE_EXPLICIT,
|
| + view_gaining_focus);
|
| + }
|
|
|
| // TODO(jered): Rip this out along with StartZeroSuggest.
|
| autocomplete_controller_->StopZeroSuggest();
|
| @@ -952,7 +959,7 @@ bool OmniboxEditModel::OnAfterPossibleChange(const string16& old_text,
|
| // Restore caret visibility whenever the user changes text or selection in the
|
| // omnibox.
|
| if (text_differs || selection_differs)
|
| - SetCaretVisibility(true);
|
| + SetCaretVisibilityInternal(true, FOCUS_CHANGE_TYPING);
|
|
|
| // Modifying the selection counts as accepting the autocompleted text.
|
| const bool user_text_changed =
|
| @@ -1014,7 +1021,8 @@ bool OmniboxEditModel::OnAfterPossibleChange(const string16& old_text,
|
| }
|
|
|
| void OmniboxEditModel::PopupBoundsChangedTo(const gfx::Rect& bounds) {
|
| - if (InstantController* instant = controller_->GetInstant())
|
| + InstantController* instant = controller_->GetInstant();
|
| + if (instant)
|
| instant->SetOmniboxBounds(bounds);
|
| }
|
|
|
| @@ -1063,7 +1071,8 @@ void OmniboxEditModel::OnResultChanged(bool default_match_changed) {
|
| NotifySearchTabHelper();
|
| }
|
|
|
| - if (InstantController* instant = controller_->GetInstant())
|
| + InstantController* instant = controller_->GetInstant();
|
| + if (instant)
|
| instant->HandleAutocompleteResults(*autocomplete_controller_->providers());
|
| }
|
|
|
| @@ -1288,3 +1297,17 @@ void OmniboxEditModel::ClassifyStringForPasteAndGo(
|
| AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text,
|
| string16(), false, false, match, alternate_nav_url);
|
| }
|
| +
|
| +void OmniboxEditModel::SetCaretVisibilityInternal(
|
| + bool visible,
|
| + OmniboxFocusChangeReason reason) {
|
| + if (has_focus_ && visible != is_caret_visible_) {
|
| + InstantController* instant = controller_->GetInstant();
|
| + if (instant) {
|
| + instant->OmniboxFocusChanged(visible ? FOCUS_VISIBLE : FOCUS_INVISIBLE,
|
| + reason, NULL);
|
| + }
|
| + is_caret_visible_ = visible;
|
| + view_->ApplyCaretVisibility();
|
| + }
|
| +}
|
|
|