Chromium Code Reviews| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 OmniboxEditController* controller, | 113 OmniboxEditController* controller, |
| 114 Profile* profile) | 114 Profile* profile) |
| 115 : view_(view), | 115 : view_(view), |
| 116 popup_(NULL), | 116 popup_(NULL), |
| 117 controller_(controller), | 117 controller_(controller), |
| 118 focus_state_(OMNIBOX_FOCUS_NONE), | 118 focus_state_(OMNIBOX_FOCUS_NONE), |
| 119 user_input_in_progress_(false), | 119 user_input_in_progress_(false), |
| 120 just_deleted_text_(false), | 120 just_deleted_text_(false), |
| 121 has_temporary_text_(false), | 121 has_temporary_text_(false), |
| 122 is_temporary_text_set_by_instant_(false), | 122 is_temporary_text_set_by_instant_(false), |
| 123 is_instant_temporary_text_a_search_query_(false), | |
| 123 paste_state_(NONE), | 124 paste_state_(NONE), |
| 124 control_key_state_(UP), | 125 control_key_state_(UP), |
| 125 is_keyword_hint_(false), | 126 is_keyword_hint_(false), |
| 126 profile_(profile), | 127 profile_(profile), |
| 127 in_revert_(false), | 128 in_revert_(false), |
| 128 in_escape_handler_(false), | 129 in_escape_handler_(false), |
| 129 allow_exact_keyword_match_(false) { | 130 allow_exact_keyword_match_(false) { |
| 130 // Use a restricted subset of the autocomplete providers if we're using the | 131 // Use a restricted subset of the autocomplete providers if we're using the |
| 131 // Instant Extended API, as it doesn't support them all. | 132 // Instant Extended API, as it doesn't support them all. |
| 132 autocomplete_controller_.reset(new AutocompleteController(profile, this, | 133 autocomplete_controller_.reset(new AutocompleteController(profile, this, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 GURL OmniboxEditModel::PermanentURL() { | 196 GURL OmniboxEditModel::PermanentURL() { |
| 196 return URLFixerUpper::FixupURL(UTF16ToUTF8(permanent_text_), std::string()); | 197 return URLFixerUpper::FixupURL(UTF16ToUTF8(permanent_text_), std::string()); |
| 197 } | 198 } |
| 198 | 199 |
| 199 void OmniboxEditModel::SetUserText(const string16& text) { | 200 void OmniboxEditModel::SetUserText(const string16& text) { |
| 200 SetInputInProgress(true); | 201 SetInputInProgress(true); |
| 201 InternalSetUserText(text); | 202 InternalSetUserText(text); |
| 202 paste_state_ = NONE; | 203 paste_state_ = NONE; |
| 203 has_temporary_text_ = false; | 204 has_temporary_text_ = false; |
| 204 is_temporary_text_set_by_instant_ = false; | 205 is_temporary_text_set_by_instant_ = false; |
| 206 is_instant_temporary_text_a_search_query_ = false; | |
| 205 } | 207 } |
| 206 | 208 |
| 207 void OmniboxEditModel::FinalizeInstantQuery(const string16& input_text, | 209 void OmniboxEditModel::FinalizeInstantQuery(const string16& input_text, |
| 208 const InstantSuggestion& suggestion, | 210 const InstantSuggestion& suggestion, |
| 209 bool skip_inline_autocomplete) { | 211 bool skip_inline_autocomplete) { |
| 210 if (skip_inline_autocomplete) { | 212 if (skip_inline_autocomplete) { |
| 211 const string16 final_text = input_text + suggestion.text; | 213 const string16 final_text = input_text + suggestion.text; |
| 212 view_->OnBeforePossibleChange(); | 214 view_->OnBeforePossibleChange(); |
| 213 view_->SetWindowTextAndCaretPos(final_text, final_text.length(), false, | 215 view_->SetWindowTextAndCaretPos(final_text, final_text.length(), false, |
| 214 false); | 216 false); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 239 if (search_provider) | 241 if (search_provider) |
| 240 search_provider->ClearInstantSuggestion(); | 242 search_provider->ClearInstantSuggestion(); |
| 241 break; | 243 break; |
| 242 } | 244 } |
| 243 | 245 |
| 244 case INSTANT_COMPLETE_REPLACE: { | 246 case INSTANT_COMPLETE_REPLACE: { |
| 245 const bool save_original_selection = !has_temporary_text_; | 247 const bool save_original_selection = !has_temporary_text_; |
| 246 view_->SetInstantSuggestion(string16()); | 248 view_->SetInstantSuggestion(string16()); |
| 247 has_temporary_text_ = true; | 249 has_temporary_text_ = true; |
| 248 is_temporary_text_set_by_instant_ = true; | 250 is_temporary_text_set_by_instant_ = true; |
| 251 is_instant_temporary_text_a_search_query_ = | |
| 252 suggestion.type == INSTANT_SUGGESTION_SEARCH; | |
| 249 // Instant suggestions are never a keyword. | 253 // Instant suggestions are never a keyword. |
| 250 keyword_ = string16(); | 254 keyword_ = string16(); |
| 251 is_keyword_hint_ = false; | 255 is_keyword_hint_ = false; |
| 252 view_->OnTemporaryTextMaybeChanged(suggestion.text, | 256 view_->OnTemporaryTextMaybeChanged(suggestion.text, |
| 253 save_original_selection, true); | 257 save_original_selection, true); |
| 254 break; | 258 break; |
| 255 } | 259 } |
| 256 } | 260 } |
| 257 } | 261 } |
| 258 | 262 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 453 } | 457 } |
| 454 | 458 |
| 455 void OmniboxEditModel::Revert() { | 459 void OmniboxEditModel::Revert() { |
| 456 SetInputInProgress(false); | 460 SetInputInProgress(false); |
| 457 paste_state_ = NONE; | 461 paste_state_ = NONE; |
| 458 InternalSetUserText(string16()); | 462 InternalSetUserText(string16()); |
| 459 keyword_.clear(); | 463 keyword_.clear(); |
| 460 is_keyword_hint_ = false; | 464 is_keyword_hint_ = false; |
| 461 has_temporary_text_ = false; | 465 has_temporary_text_ = false; |
| 462 is_temporary_text_set_by_instant_ = false; | 466 is_temporary_text_set_by_instant_ = false; |
| 467 is_instant_temporary_text_a_search_query_ = false; | |
| 463 view_->SetWindowTextAndCaretPos(permanent_text_, | 468 view_->SetWindowTextAndCaretPos(permanent_text_, |
| 464 has_focus() ? permanent_text_.length() : 0, | 469 has_focus() ? permanent_text_.length() : 0, |
| 465 false, true); | 470 false, true); |
| 466 AutocompleteActionPredictor* action_predictor = | 471 AutocompleteActionPredictor* action_predictor = |
| 467 AutocompleteActionPredictorFactory::GetForProfile(profile_); | 472 AutocompleteActionPredictorFactory::GetForProfile(profile_); |
| 468 if (action_predictor) | 473 if (action_predictor) |
| 469 action_predictor->ClearTransitionalMatches(); | 474 action_predictor->ClearTransitionalMatches(); |
| 470 } | 475 } |
| 471 | 476 |
| 472 void OmniboxEditModel::StartAutocomplete( | 477 void OmniboxEditModel::StartAutocomplete( |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 733 popup_->SetSelectedLineState(OmniboxPopupModel::KEYWORD); | 738 popup_->SetSelectedLineState(OmniboxPopupModel::KEYWORD); |
| 734 else | 739 else |
| 735 StartAutocomplete(false, true); | 740 StartAutocomplete(false, true); |
| 736 | 741 |
| 737 // Ensure the current selection is saved before showing keyword mode | 742 // Ensure the current selection is saved before showing keyword mode |
| 738 // so that moving to another line and then reverting the text will restore | 743 // so that moving to another line and then reverting the text will restore |
| 739 // the current state properly. | 744 // the current state properly. |
| 740 bool save_original_selection = !has_temporary_text_; | 745 bool save_original_selection = !has_temporary_text_; |
| 741 has_temporary_text_ = true; | 746 has_temporary_text_ = true; |
| 742 is_temporary_text_set_by_instant_ = false; | 747 is_temporary_text_set_by_instant_ = false; |
| 748 is_instant_temporary_text_a_search_query_ = false; | |
| 743 view_->OnTemporaryTextMaybeChanged( | 749 view_->OnTemporaryTextMaybeChanged( |
| 744 DisplayTextFromUserText(CurrentMatch().fill_into_edit), | 750 DisplayTextFromUserText(CurrentMatch().fill_into_edit), |
| 745 save_original_selection, true); | 751 save_original_selection, true); |
| 746 | 752 |
| 747 content::RecordAction(UserMetricsAction("AcceptedKeywordHint")); | 753 content::RecordAction(UserMetricsAction("AcceptedKeywordHint")); |
| 748 return true; | 754 return true; |
| 749 } | 755 } |
| 750 | 756 |
| 751 void OmniboxEditModel::ClearKeyword(const string16& visible_text) { | 757 void OmniboxEditModel::ClearKeyword(const string16& visible_text) { |
| 752 autocomplete_controller_->Stop(false); | 758 autocomplete_controller_->Stop(false); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 871 // Don't change anything unless the key state is actually toggling. | 877 // Don't change anything unless the key state is actually toggling. |
| 872 if (pressed == (control_key_state_ == UP)) { | 878 if (pressed == (control_key_state_ == UP)) { |
| 873 ControlKeyState old_state = control_key_state_; | 879 ControlKeyState old_state = control_key_state_; |
| 874 control_key_state_ = pressed ? DOWN_WITHOUT_CHANGE : UP; | 880 control_key_state_ = pressed ? DOWN_WITHOUT_CHANGE : UP; |
| 875 if ((control_key_state_ == DOWN_WITHOUT_CHANGE) && has_temporary_text_) { | 881 if ((control_key_state_ == DOWN_WITHOUT_CHANGE) && has_temporary_text_) { |
| 876 // Arrowing down and then hitting control accepts the temporary text as | 882 // Arrowing down and then hitting control accepts the temporary text as |
| 877 // the input text. | 883 // the input text. |
| 878 InternalSetUserText(UserTextFromDisplayText(view_->GetText())); | 884 InternalSetUserText(UserTextFromDisplayText(view_->GetText())); |
| 879 has_temporary_text_ = false; | 885 has_temporary_text_ = false; |
| 880 is_temporary_text_set_by_instant_ = false; | 886 is_temporary_text_set_by_instant_ = false; |
| 887 is_instant_temporary_text_a_search_query_ = false; | |
| 881 } | 888 } |
| 882 if ((old_state != DOWN_WITH_CHANGE) && popup_->IsOpen()) { | 889 if ((old_state != DOWN_WITH_CHANGE) && popup_->IsOpen()) { |
| 883 // Autocomplete history provider results may change, so refresh the | 890 // Autocomplete history provider results may change, so refresh the |
| 884 // popup. This will force user_input_in_progress_ to true, but if the | 891 // popup. This will force user_input_in_progress_ to true, but if the |
| 885 // popup is open, that should have already been the case. | 892 // popup is open, that should have already been the case. |
| 886 view_->UpdatePopup(); | 893 view_->UpdatePopup(); |
| 887 } | 894 } |
| 888 } | 895 } |
| 889 } | 896 } |
| 890 | 897 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 939 DCHECK(!keyword_.empty() || !is_keyword_hint_); | 946 DCHECK(!keyword_.empty() || !is_keyword_hint_); |
| 940 } | 947 } |
| 941 | 948 |
| 942 // Handle changes to temporary text. | 949 // Handle changes to temporary text. |
| 943 if (destination_for_temporary_text_change != NULL) { | 950 if (destination_for_temporary_text_change != NULL) { |
| 944 const bool save_original_selection = !has_temporary_text_; | 951 const bool save_original_selection = !has_temporary_text_; |
| 945 if (save_original_selection) { | 952 if (save_original_selection) { |
| 946 // Save the original selection and URL so it can be reverted later. | 953 // Save the original selection and URL so it can be reverted later. |
| 947 has_temporary_text_ = true; | 954 has_temporary_text_ = true; |
| 948 is_temporary_text_set_by_instant_ = false; | 955 is_temporary_text_set_by_instant_ = false; |
| 956 is_instant_temporary_text_a_search_query_ = false; | |
| 949 original_url_ = *destination_for_temporary_text_change; | 957 original_url_ = *destination_for_temporary_text_change; |
| 950 inline_autocomplete_text_.clear(); | 958 inline_autocomplete_text_.clear(); |
| 951 } | 959 } |
| 952 if (control_key_state_ == DOWN_WITHOUT_CHANGE) { | 960 if (control_key_state_ == DOWN_WITHOUT_CHANGE) { |
| 953 // Arrowing around the popup cancels control-enter. | 961 // Arrowing around the popup cancels control-enter. |
| 954 control_key_state_ = DOWN_WITH_CHANGE; | 962 control_key_state_ = DOWN_WITH_CHANGE; |
| 955 // Now things are a bit screwy: the desired_tld has changed, but if we | 963 // Now things are a bit screwy: the desired_tld has changed, but if we |
| 956 // update the popup, the new order of entries won't match the old, so the | 964 // update the popup, the new order of entries won't match the old, so the |
| 957 // user's selection gets screwy; and if we don't update the popup, and the | 965 // user's selection gets screwy; and if we don't update the popup, and the |
| 958 // user reverts, then the selected item will be as if control is still | 966 // user reverts, then the selected item will be as if control is still |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1044 return false; | 1052 return false; |
| 1045 } | 1053 } |
| 1046 | 1054 |
| 1047 // If the user text has not changed, we do not want to change the model's | 1055 // If the user text has not changed, we do not want to change the model's |
| 1048 // state associated with the text. Otherwise, we can get surprising behavior | 1056 // state associated with the text. Otherwise, we can get surprising behavior |
| 1049 // where the autocompleted text unexpectedly reappears, e.g. crbug.com/55983 | 1057 // where the autocompleted text unexpectedly reappears, e.g. crbug.com/55983 |
| 1050 if (user_text_changed) { | 1058 if (user_text_changed) { |
| 1051 InternalSetUserText(UserTextFromDisplayText(new_text)); | 1059 InternalSetUserText(UserTextFromDisplayText(new_text)); |
| 1052 has_temporary_text_ = false; | 1060 has_temporary_text_ = false; |
| 1053 is_temporary_text_set_by_instant_ = false; | 1061 is_temporary_text_set_by_instant_ = false; |
| 1062 is_instant_temporary_text_a_search_query_ = false; | |
| 1054 | 1063 |
| 1055 // Track when the user has deleted text so we won't allow inline | 1064 // Track when the user has deleted text so we won't allow inline |
| 1056 // autocomplete. | 1065 // autocomplete. |
| 1057 just_deleted_text_ = just_deleted_text; | 1066 just_deleted_text_ = just_deleted_text; |
| 1058 | 1067 |
| 1059 if (user_input_in_progress_ && user_text_.empty()) { | 1068 if (user_input_in_progress_ && user_text_.empty()) { |
| 1060 // Log cases where the user started editing and then subsequently cleared | 1069 // Log cases where the user started editing and then subsequently cleared |
| 1061 // all the text. Note that this explicitly doesn't catch cases like | 1070 // all the text. Note that this explicitly doesn't catch cases like |
| 1062 // "hit ctrl-l to select whole edit contents, then hit backspace", because | 1071 // "hit ctrl-l to select whole edit contents, then hit backspace", because |
| 1063 // in such cases, |user_input_in_progress| won't be true here. | 1072 // in such cases, |user_input_in_progress| won't be true here. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1137 } | 1146 } |
| 1138 | 1147 |
| 1139 if (popup_->IsOpen()) { | 1148 if (popup_->IsOpen()) { |
| 1140 OnPopupBoundsChanged(popup_->view()->GetTargetBounds()); | 1149 OnPopupBoundsChanged(popup_->view()->GetTargetBounds()); |
| 1141 } else if (was_open) { | 1150 } else if (was_open) { |
| 1142 // Accepts the temporary text as the user text, because it makes little | 1151 // Accepts the temporary text as the user text, because it makes little |
| 1143 // sense to have temporary text when the popup is closed. | 1152 // sense to have temporary text when the popup is closed. |
| 1144 InternalSetUserText(UserTextFromDisplayText(view_->GetText())); | 1153 InternalSetUserText(UserTextFromDisplayText(view_->GetText())); |
| 1145 has_temporary_text_ = false; | 1154 has_temporary_text_ = false; |
| 1146 is_temporary_text_set_by_instant_ = false; | 1155 is_temporary_text_set_by_instant_ = false; |
| 1156 is_instant_temporary_text_a_search_query_ = false; | |
| 1147 OnPopupBoundsChanged(gfx::Rect()); | 1157 OnPopupBoundsChanged(gfx::Rect()); |
| 1148 delegate_->NotifySearchTabHelper(user_input_in_progress_, !in_revert_); | 1158 delegate_->NotifySearchTabHelper(user_input_in_progress_, !in_revert_); |
| 1149 } | 1159 } |
| 1150 | 1160 |
| 1151 InstantController* instant = controller_->GetInstant(); | 1161 InstantController* instant = controller_->GetInstant(); |
| 1152 if (instant && !in_revert_) | 1162 if (instant && !in_revert_) |
| 1153 instant->HandleAutocompleteResults(*autocomplete_controller_->providers()); | 1163 instant->HandleAutocompleteResults(*autocomplete_controller_->providers()); |
| 1154 } | 1164 } |
| 1155 | 1165 |
| 1156 bool OmniboxEditModel::query_in_progress() const { | 1166 bool OmniboxEditModel::query_in_progress() const { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1205 *match = result.match_at(popup_->selected_line()); | 1215 *match = result.match_at(popup_->selected_line()); |
| 1206 } | 1216 } |
| 1207 if (alternate_nav_url && popup_->manually_selected_match().empty()) | 1217 if (alternate_nav_url && popup_->manually_selected_match().empty()) |
| 1208 *alternate_nav_url = result.alternate_nav_url(); | 1218 *alternate_nav_url = result.alternate_nav_url(); |
| 1209 } | 1219 } |
| 1210 | 1220 |
| 1211 void OmniboxEditModel::GetInfoForCurrentText(AutocompleteMatch* match, | 1221 void OmniboxEditModel::GetInfoForCurrentText(AutocompleteMatch* match, |
| 1212 GURL* alternate_nav_url) const { | 1222 GURL* alternate_nav_url) const { |
| 1213 // If there's temporary text and it has been set by Instant, we won't find it | 1223 // If there's temporary text and it has been set by Instant, we won't find it |
| 1214 // in the popup model, so classify the text anew. | 1224 // in the popup model, so classify the text anew. |
| 1215 if ((popup_->IsOpen() || query_in_progress()) && | 1225 if (is_temporary_text_set_by_instant_) { |
| 1216 !is_temporary_text_set_by_instant_) { | 1226 // TODO XXX |
|
sreeram
2013/04/08 16:07:28
Here, I want to return either a UWYT match or a SW
Peter Kasting
2013/04/08 20:13:50
So to be clear, the reason that running through th
sreeram
2013/04/08 20:20:48
Exactly.
Peter Kasting
2013/04/08 20:34:06
K, make sure to make that clear in the comments he
| |
| 1227 } else if (popup_->IsOpen() || query_in_progress()) { | |
| 1217 InfoForCurrentSelection(match, alternate_nav_url); | 1228 InfoForCurrentSelection(match, alternate_nav_url); |
| 1218 } else { | 1229 } else { |
| 1219 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify( | 1230 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify( |
| 1220 UserTextFromDisplayText(view_->GetText()), KeywordIsSelected(), true, | 1231 UserTextFromDisplayText(view_->GetText()), KeywordIsSelected(), true, |
| 1221 match, alternate_nav_url); | 1232 match, alternate_nav_url); |
| 1222 } | 1233 } |
| 1223 } | 1234 } |
| 1224 | 1235 |
| 1225 void OmniboxEditModel::RevertTemporaryText(bool revert_popup) { | 1236 void OmniboxEditModel::RevertTemporaryText(bool revert_popup) { |
| 1226 // The user typed something, then selected a different item. Restore the | 1237 // The user typed something, then selected a different item. Restore the |
| 1227 // text they typed and change back to the default item. | 1238 // text they typed and change back to the default item. |
| 1228 // NOTE: This purposefully does not reset paste_state_. | 1239 // NOTE: This purposefully does not reset paste_state_. |
| 1229 bool notify_instant = is_temporary_text_set_by_instant_; | 1240 bool notify_instant = is_temporary_text_set_by_instant_; |
| 1230 just_deleted_text_ = false; | 1241 just_deleted_text_ = false; |
| 1231 has_temporary_text_ = false; | 1242 has_temporary_text_ = false; |
| 1232 is_temporary_text_set_by_instant_ = false; | 1243 is_temporary_text_set_by_instant_ = false; |
| 1244 is_instant_temporary_text_a_search_query_ = false; | |
| 1233 | 1245 |
| 1234 InstantController* instant = controller_->GetInstant(); | 1246 InstantController* instant = controller_->GetInstant(); |
| 1235 if (instant && notify_instant) { | 1247 if (instant && notify_instant) { |
| 1236 // Normally, popup_->ResetToDefaultMatch() will cause the view text to be | 1248 // Normally, popup_->ResetToDefaultMatch() will cause the view text to be |
| 1237 // updated. In Instant Extended mode however, the popup_ is not used, so it | 1249 // updated. In Instant Extended mode however, the popup_ is not used, so it |
| 1238 // won't do anything. So, update the view ourselves. Even if Instant is not | 1250 // won't do anything. So, update the view ourselves. Even if Instant is not |
| 1239 // in extended mode (i.e., it's enabled in non-extended mode, or disabled | 1251 // in extended mode (i.e., it's enabled in non-extended mode, or disabled |
| 1240 // altogether), this is okay to do, since the call to | 1252 // altogether), this is okay to do, since the call to |
| 1241 // popup_->ResetToDefaultMatch() will just override whatever we do here. | 1253 // popup_->ResetToDefaultMatch() will just override whatever we do here. |
| 1242 // | 1254 // |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1293 return !keyword.empty() && autocomplete_controller_->keyword_provider() && | 1305 return !keyword.empty() && autocomplete_controller_->keyword_provider() && |
| 1294 !autocomplete_controller_->keyword_provider()-> | 1306 !autocomplete_controller_->keyword_provider()-> |
| 1295 GetKeywordForText(keyword).empty(); | 1307 GetKeywordForText(keyword).empty(); |
| 1296 } | 1308 } |
| 1297 | 1309 |
| 1298 bool OmniboxEditModel::DoInstant(const AutocompleteMatch& match) { | 1310 bool OmniboxEditModel::DoInstant(const AutocompleteMatch& match) { |
| 1299 InstantController* instant = controller_->GetInstant(); | 1311 InstantController* instant = controller_->GetInstant(); |
| 1300 if (!instant || in_revert_) | 1312 if (!instant || in_revert_) |
| 1301 return false; | 1313 return false; |
| 1302 | 1314 |
| 1303 // Don't call Update() if the change is a result of a | 1315 // Don't call Update() if the change is the result of an |
| 1304 // INSTANT_COMPLETE_REPLACE instant suggestion. | 1316 // INSTANT_COMPLETE_REPLACE instant suggestion. |
| 1305 if (has_temporary_text_ && is_temporary_text_set_by_instant_) | 1317 if (is_temporary_text_set_by_instant_) |
| 1306 return false; | 1318 return false; |
| 1307 | 1319 |
| 1308 // The two pieces of text we want to send Instant, viz., what the user has | 1320 // The two pieces of text we want to send Instant, viz., what the user has |
| 1309 // typed, and the full omnibox text including any inline autocompletion. | 1321 // typed, and the full omnibox text including any inline autocompletion. |
| 1310 string16 user_text = has_temporary_text_ ? | 1322 string16 user_text = has_temporary_text_ ? |
| 1311 match.fill_into_edit : DisplayTextFromUserText(user_text_); | 1323 match.fill_into_edit : DisplayTextFromUserText(user_text_); |
| 1312 string16 full_text = view_->GetText(); | 1324 string16 full_text = view_->GetText(); |
| 1313 | 1325 |
| 1314 // Remove "?" if we're in forced query mode. | 1326 // Remove "?" if we're in forced query mode. |
| 1315 AutocompleteInput::RemoveForcedQueryStringIfNecessary( | 1327 AutocompleteInput::RemoveForcedQueryStringIfNecessary( |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1385 instant->OmniboxFocusChanged(state, reason, NULL); | 1397 instant->OmniboxFocusChanged(state, reason, NULL); |
| 1386 | 1398 |
| 1387 // Update state and notify view if the omnibox has focus and the caret | 1399 // Update state and notify view if the omnibox has focus and the caret |
| 1388 // visibility changed. | 1400 // visibility changed. |
| 1389 const bool was_caret_visible = is_caret_visible(); | 1401 const bool was_caret_visible = is_caret_visible(); |
| 1390 focus_state_ = state; | 1402 focus_state_ = state; |
| 1391 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1403 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
| 1392 is_caret_visible() != was_caret_visible) | 1404 is_caret_visible() != was_caret_visible) |
| 1393 view_->ApplyCaretVisibility(); | 1405 view_->ApplyCaretVisibility(); |
| 1394 } | 1406 } |
| OLD | NEW |