OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 5 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 // determine what keyword, if any, is applicable. | 1020 // determine what keyword, if any, is applicable. |
1021 // | 1021 // |
1022 // If MaybeAcceptKeywordBySpace() accepts the keyword and returns true, that | 1022 // If MaybeAcceptKeywordBySpace() accepts the keyword and returns true, that |
1023 // will have updated our state already, so in that case we don't also return | 1023 // will have updated our state already, so in that case we don't also return |
1024 // true from this function. | 1024 // true from this function. |
1025 return !(text_differs && allow_keyword_ui_change && !just_deleted_text && | 1025 return !(text_differs && allow_keyword_ui_change && !just_deleted_text && |
1026 no_selection && (selection_start == user_text_.length()) && | 1026 no_selection && (selection_start == user_text_.length()) && |
1027 MaybeAcceptKeywordBySpace(user_text_)); | 1027 MaybeAcceptKeywordBySpace(user_text_)); |
1028 } | 1028 } |
1029 | 1029 |
1030 void OmniboxEditModel::PopupBoundsChangedTo(const gfx::Rect& bounds) { | 1030 void OmniboxEditModel::OnPopupBoundsChanged(const gfx::Rect& bounds) { |
1031 InstantController* instant = controller_->GetInstant(); | 1031 InstantController* instant = controller_->GetInstant(); |
1032 if (instant) | 1032 if (instant) |
1033 instant->SetOmniboxBounds(bounds); | 1033 instant->SetPopupBounds(bounds); |
1034 } | 1034 } |
1035 | 1035 |
1036 void OmniboxEditModel::OnResultChanged(bool default_match_changed) { | 1036 void OmniboxEditModel::OnResultChanged(bool default_match_changed) { |
1037 const bool was_open = popup_->IsOpen(); | 1037 const bool was_open = popup_->IsOpen(); |
1038 if (default_match_changed) { | 1038 if (default_match_changed) { |
1039 string16 inline_autocomplete_text; | 1039 string16 inline_autocomplete_text; |
1040 string16 keyword; | 1040 string16 keyword; |
1041 bool is_keyword_hint = false; | 1041 bool is_keyword_hint = false; |
1042 const AutocompleteResult& result = this->result(); | 1042 const AutocompleteResult& result = this->result(); |
1043 const AutocompleteResult::const_iterator match(result.default_match()); | 1043 const AutocompleteResult::const_iterator match(result.default_match()); |
(...skipping 16 matching lines...) Expand all Loading... |
1060 } | 1060 } |
1061 | 1061 |
1062 popup_->OnResultChanged(); | 1062 popup_->OnResultChanged(); |
1063 OnPopupDataChanged(inline_autocomplete_text, NULL, keyword, | 1063 OnPopupDataChanged(inline_autocomplete_text, NULL, keyword, |
1064 is_keyword_hint); | 1064 is_keyword_hint); |
1065 } else { | 1065 } else { |
1066 popup_->OnResultChanged(); | 1066 popup_->OnResultChanged(); |
1067 } | 1067 } |
1068 | 1068 |
1069 if (popup_->IsOpen()) { | 1069 if (popup_->IsOpen()) { |
1070 PopupBoundsChangedTo(popup_->view()->GetTargetBounds()); | 1070 OnPopupBoundsChanged(popup_->view()->GetTargetBounds()); |
1071 } else if (was_open) { | 1071 } else if (was_open) { |
1072 // Accepts the temporary text as the user text, because it makes little | 1072 // Accepts the temporary text as the user text, because it makes little |
1073 // sense to have temporary text when the popup is closed. | 1073 // sense to have temporary text when the popup is closed. |
1074 InternalSetUserText(UserTextFromDisplayText(view_->GetText())); | 1074 InternalSetUserText(UserTextFromDisplayText(view_->GetText())); |
1075 has_temporary_text_ = false; | 1075 has_temporary_text_ = false; |
1076 is_temporary_text_set_by_instant_ = false; | 1076 is_temporary_text_set_by_instant_ = false; |
1077 PopupBoundsChangedTo(gfx::Rect()); | 1077 OnPopupBoundsChanged(gfx::Rect()); |
1078 NotifySearchTabHelper(); | 1078 NotifySearchTabHelper(); |
1079 } | 1079 } |
1080 | 1080 |
1081 InstantController* instant = controller_->GetInstant(); | 1081 InstantController* instant = controller_->GetInstant(); |
1082 if (instant) | 1082 if (instant) |
1083 instant->HandleAutocompleteResults(*autocomplete_controller_->providers()); | 1083 instant->HandleAutocompleteResults(*autocomplete_controller_->providers()); |
1084 } | 1084 } |
1085 | 1085 |
1086 bool OmniboxEditModel::query_in_progress() const { | 1086 bool OmniboxEditModel::query_in_progress() const { |
1087 return !autocomplete_controller_->done(); | 1087 return !autocomplete_controller_->done(); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 instant->OmniboxFocusChanged(state, reason, NULL); | 1316 instant->OmniboxFocusChanged(state, reason, NULL); |
1317 | 1317 |
1318 // Update state and notify view if the omnibox has focus and the caret | 1318 // Update state and notify view if the omnibox has focus and the caret |
1319 // visibility changed. | 1319 // visibility changed. |
1320 const bool was_caret_visible = is_caret_visible(); | 1320 const bool was_caret_visible = is_caret_visible(); |
1321 focus_state_ = state; | 1321 focus_state_ = state; |
1322 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1322 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1323 is_caret_visible() != was_caret_visible) | 1323 is_caret_visible() != was_caret_visible) |
1324 view_->ApplyCaretVisibility(); | 1324 view_->ApplyCaretVisibility(); |
1325 } | 1325 } |
OLD | NEW |