Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_edit_model.cc

Issue 13141002: Use Instant suggested match type for Instant temporary text. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: const string16& Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 OmniboxEditController* controller, 115 OmniboxEditController* controller,
116 Profile* profile) 116 Profile* profile)
117 : view_(view), 117 : view_(view),
118 popup_(NULL), 118 popup_(NULL),
119 controller_(controller), 119 controller_(controller),
120 focus_state_(OMNIBOX_FOCUS_NONE), 120 focus_state_(OMNIBOX_FOCUS_NONE),
121 user_input_in_progress_(false), 121 user_input_in_progress_(false),
122 just_deleted_text_(false), 122 just_deleted_text_(false),
123 has_temporary_text_(false), 123 has_temporary_text_(false),
124 is_temporary_text_set_by_instant_(false), 124 is_temporary_text_set_by_instant_(false),
125 is_instant_temporary_text_a_search_query_(false),
125 paste_state_(NONE), 126 paste_state_(NONE),
126 control_key_state_(UP), 127 control_key_state_(UP),
127 is_keyword_hint_(false), 128 is_keyword_hint_(false),
128 profile_(profile), 129 profile_(profile),
129 in_revert_(false), 130 in_revert_(false),
130 in_escape_handler_(false), 131 in_escape_handler_(false),
131 allow_exact_keyword_match_(false) { 132 allow_exact_keyword_match_(false) {
132 // Use a restricted subset of the autocomplete providers if we're using the 133 // Use a restricted subset of the autocomplete providers if we're using the
133 // Instant Extended API, as it doesn't support them all. 134 // Instant Extended API, as it doesn't support them all.
134 autocomplete_controller_.reset(new AutocompleteController(profile, this, 135 autocomplete_controller_.reset(new AutocompleteController(profile, this,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 GURL OmniboxEditModel::PermanentURL() { 213 GURL OmniboxEditModel::PermanentURL() {
213 return URLFixerUpper::FixupURL(UTF16ToUTF8(permanent_text_), std::string()); 214 return URLFixerUpper::FixupURL(UTF16ToUTF8(permanent_text_), std::string());
214 } 215 }
215 216
216 void OmniboxEditModel::SetUserText(const string16& text) { 217 void OmniboxEditModel::SetUserText(const string16& text) {
217 SetInputInProgress(true); 218 SetInputInProgress(true);
218 InternalSetUserText(text); 219 InternalSetUserText(text);
219 paste_state_ = NONE; 220 paste_state_ = NONE;
220 has_temporary_text_ = false; 221 has_temporary_text_ = false;
221 is_temporary_text_set_by_instant_ = false; 222 is_temporary_text_set_by_instant_ = false;
223 is_instant_temporary_text_a_search_query_ = false;
222 } 224 }
223 225
224 void OmniboxEditModel::FinalizeInstantQuery(const string16& input_text, 226 void OmniboxEditModel::FinalizeInstantQuery(const string16& input_text,
225 const InstantSuggestion& suggestion, 227 const InstantSuggestion& suggestion,
226 bool skip_inline_autocomplete) { 228 bool skip_inline_autocomplete) {
227 if (skip_inline_autocomplete) { 229 if (skip_inline_autocomplete) {
228 const string16 final_text = input_text + suggestion.text; 230 const string16 final_text = input_text + suggestion.text;
229 view_->OnBeforePossibleChange(); 231 view_->OnBeforePossibleChange();
230 view_->SetWindowTextAndCaretPos(final_text, final_text.length(), false, 232 view_->SetWindowTextAndCaretPos(final_text, final_text.length(), false,
231 false); 233 false);
(...skipping 12 matching lines...) Expand all
244 switch (suggestion.behavior) { 246 switch (suggestion.behavior) {
245 case INSTANT_COMPLETE_NOW: 247 case INSTANT_COMPLETE_NOW:
246 view_->SetInstantSuggestion(string16()); 248 view_->SetInstantSuggestion(string16());
247 if (!suggestion.text.empty()) 249 if (!suggestion.text.empty())
248 FinalizeInstantQuery(view_->GetText(), suggestion, false); 250 FinalizeInstantQuery(view_->GetText(), suggestion, false);
249 break; 251 break;
250 252
251 case INSTANT_COMPLETE_NEVER: { 253 case INSTANT_COMPLETE_NEVER: {
252 DCHECK_EQ(INSTANT_SUGGESTION_SEARCH, suggestion.type); 254 DCHECK_EQ(INSTANT_SUGGESTION_SEARCH, suggestion.type);
253 view_->SetInstantSuggestion(suggestion.text); 255 view_->SetInstantSuggestion(suggestion.text);
254 SearchProvider* search_provider = 256 autocomplete_controller_->search_provider()->ClearInstantSuggestion();
255 autocomplete_controller_->search_provider();
256 if (search_provider)
Mark P 2013/04/09 23:59:11 I know this shouldn't happen in normal use. Never
sreeram 2013/04/11 20:37:54 It shouldn't happen at all, whether in normal use
257 search_provider->ClearInstantSuggestion();
258 break; 257 break;
259 } 258 }
260 259
261 case INSTANT_COMPLETE_REPLACE: { 260 case INSTANT_COMPLETE_REPLACE: {
262 const bool save_original_selection = !has_temporary_text_; 261 const bool save_original_selection = !has_temporary_text_;
263 view_->SetInstantSuggestion(string16()); 262 view_->SetInstantSuggestion(string16());
264 has_temporary_text_ = true; 263 has_temporary_text_ = true;
265 is_temporary_text_set_by_instant_ = true; 264 is_temporary_text_set_by_instant_ = true;
265 is_instant_temporary_text_a_search_query_ =
266 suggestion.type == INSTANT_SUGGESTION_SEARCH;
266 // Instant suggestions are never a keyword. 267 // Instant suggestions are never a keyword.
267 keyword_ = string16(); 268 keyword_ = string16();
268 is_keyword_hint_ = false; 269 is_keyword_hint_ = false;
269 view_->OnTemporaryTextMaybeChanged(suggestion.text, 270 view_->OnTemporaryTextMaybeChanged(suggestion.text,
270 save_original_selection, true); 271 save_original_selection, true);
271 break; 272 break;
272 } 273 }
273 } 274 }
274 } 275 }
275 276
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 471 }
471 472
472 void OmniboxEditModel::Revert() { 473 void OmniboxEditModel::Revert() {
473 SetInputInProgress(false); 474 SetInputInProgress(false);
474 paste_state_ = NONE; 475 paste_state_ = NONE;
475 InternalSetUserText(string16()); 476 InternalSetUserText(string16());
476 keyword_.clear(); 477 keyword_.clear();
477 is_keyword_hint_ = false; 478 is_keyword_hint_ = false;
478 has_temporary_text_ = false; 479 has_temporary_text_ = false;
479 is_temporary_text_set_by_instant_ = false; 480 is_temporary_text_set_by_instant_ = false;
481 is_instant_temporary_text_a_search_query_ = false;
480 view_->SetWindowTextAndCaretPos(permanent_text_, 482 view_->SetWindowTextAndCaretPos(permanent_text_,
481 has_focus() ? permanent_text_.length() : 0, 483 has_focus() ? permanent_text_.length() : 0,
482 false, true); 484 false, true);
483 AutocompleteActionPredictor* action_predictor = 485 AutocompleteActionPredictor* action_predictor =
484 AutocompleteActionPredictorFactory::GetForProfile(profile_); 486 AutocompleteActionPredictorFactory::GetForProfile(profile_);
485 if (action_predictor) 487 if (action_predictor)
486 action_predictor->ClearTransitionalMatches(); 488 action_predictor->ClearTransitionalMatches();
487 } 489 }
488 490
489 void OmniboxEditModel::StartAutocomplete( 491 void OmniboxEditModel::StartAutocomplete(
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 popup_->SetSelectedLineState(OmniboxPopupModel::KEYWORD); 752 popup_->SetSelectedLineState(OmniboxPopupModel::KEYWORD);
751 else 753 else
752 StartAutocomplete(false, true); 754 StartAutocomplete(false, true);
753 755
754 // Ensure the current selection is saved before showing keyword mode 756 // Ensure the current selection is saved before showing keyword mode
755 // so that moving to another line and then reverting the text will restore 757 // so that moving to another line and then reverting the text will restore
756 // the current state properly. 758 // the current state properly.
757 bool save_original_selection = !has_temporary_text_; 759 bool save_original_selection = !has_temporary_text_;
758 has_temporary_text_ = true; 760 has_temporary_text_ = true;
759 is_temporary_text_set_by_instant_ = false; 761 is_temporary_text_set_by_instant_ = false;
762 is_instant_temporary_text_a_search_query_ = false;
760 view_->OnTemporaryTextMaybeChanged( 763 view_->OnTemporaryTextMaybeChanged(
761 DisplayTextFromUserText(CurrentMatch().fill_into_edit), 764 DisplayTextFromUserText(CurrentMatch().fill_into_edit),
762 save_original_selection, true); 765 save_original_selection, true);
763 766
764 content::RecordAction(UserMetricsAction("AcceptedKeywordHint")); 767 content::RecordAction(UserMetricsAction("AcceptedKeywordHint"));
765 return true; 768 return true;
766 } 769 }
767 770
768 void OmniboxEditModel::ClearKeyword(const string16& visible_text) { 771 void OmniboxEditModel::ClearKeyword(const string16& visible_text) {
769 autocomplete_controller_->Stop(false); 772 autocomplete_controller_->Stop(false);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 // Don't change anything unless the key state is actually toggling. 889 // Don't change anything unless the key state is actually toggling.
887 if (pressed == (control_key_state_ == UP)) { 890 if (pressed == (control_key_state_ == UP)) {
888 ControlKeyState old_state = control_key_state_; 891 ControlKeyState old_state = control_key_state_;
889 control_key_state_ = pressed ? DOWN_WITHOUT_CHANGE : UP; 892 control_key_state_ = pressed ? DOWN_WITHOUT_CHANGE : UP;
890 if ((control_key_state_ == DOWN_WITHOUT_CHANGE) && has_temporary_text_) { 893 if ((control_key_state_ == DOWN_WITHOUT_CHANGE) && has_temporary_text_) {
891 // Arrowing down and then hitting control accepts the temporary text as 894 // Arrowing down and then hitting control accepts the temporary text as
892 // the input text. 895 // the input text.
893 InternalSetUserText(UserTextFromDisplayText(view_->GetText())); 896 InternalSetUserText(UserTextFromDisplayText(view_->GetText()));
894 has_temporary_text_ = false; 897 has_temporary_text_ = false;
895 is_temporary_text_set_by_instant_ = false; 898 is_temporary_text_set_by_instant_ = false;
899 is_instant_temporary_text_a_search_query_ = false;
896 } 900 }
897 if ((old_state != DOWN_WITH_CHANGE) && popup_->IsOpen()) { 901 if ((old_state != DOWN_WITH_CHANGE) && popup_->IsOpen()) {
898 // Autocomplete history provider results may change, so refresh the 902 // Autocomplete history provider results may change, so refresh the
899 // popup. This will force user_input_in_progress_ to true, but if the 903 // popup. This will force user_input_in_progress_ to true, but if the
900 // popup is open, that should have already been the case. 904 // popup is open, that should have already been the case.
901 view_->UpdatePopup(); 905 view_->UpdatePopup();
902 } 906 }
903 } 907 }
904 } 908 }
905 909
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 DCHECK(!keyword_.empty() || !is_keyword_hint_); 958 DCHECK(!keyword_.empty() || !is_keyword_hint_);
955 } 959 }
956 960
957 // Handle changes to temporary text. 961 // Handle changes to temporary text.
958 if (destination_for_temporary_text_change != NULL) { 962 if (destination_for_temporary_text_change != NULL) {
959 const bool save_original_selection = !has_temporary_text_; 963 const bool save_original_selection = !has_temporary_text_;
960 if (save_original_selection) { 964 if (save_original_selection) {
961 // Save the original selection and URL so it can be reverted later. 965 // Save the original selection and URL so it can be reverted later.
962 has_temporary_text_ = true; 966 has_temporary_text_ = true;
963 is_temporary_text_set_by_instant_ = false; 967 is_temporary_text_set_by_instant_ = false;
968 is_instant_temporary_text_a_search_query_ = false;
964 original_url_ = *destination_for_temporary_text_change; 969 original_url_ = *destination_for_temporary_text_change;
965 inline_autocomplete_text_.clear(); 970 inline_autocomplete_text_.clear();
966 } 971 }
967 if (control_key_state_ == DOWN_WITHOUT_CHANGE) { 972 if (control_key_state_ == DOWN_WITHOUT_CHANGE) {
968 // Arrowing around the popup cancels control-enter. 973 // Arrowing around the popup cancels control-enter.
969 control_key_state_ = DOWN_WITH_CHANGE; 974 control_key_state_ = DOWN_WITH_CHANGE;
970 // Now things are a bit screwy: the desired_tld has changed, but if we 975 // Now things are a bit screwy: the desired_tld has changed, but if we
971 // update the popup, the new order of entries won't match the old, so the 976 // update the popup, the new order of entries won't match the old, so the
972 // user's selection gets screwy; and if we don't update the popup, and the 977 // user's selection gets screwy; and if we don't update the popup, and the
973 // user reverts, then the selected item will be as if control is still 978 // 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
1059 return false; 1064 return false;
1060 } 1065 }
1061 1066
1062 // If the user text has not changed, we do not want to change the model's 1067 // If the user text has not changed, we do not want to change the model's
1063 // state associated with the text. Otherwise, we can get surprising behavior 1068 // state associated with the text. Otherwise, we can get surprising behavior
1064 // where the autocompleted text unexpectedly reappears, e.g. crbug.com/55983 1069 // where the autocompleted text unexpectedly reappears, e.g. crbug.com/55983
1065 if (user_text_changed) { 1070 if (user_text_changed) {
1066 InternalSetUserText(UserTextFromDisplayText(new_text)); 1071 InternalSetUserText(UserTextFromDisplayText(new_text));
1067 has_temporary_text_ = false; 1072 has_temporary_text_ = false;
1068 is_temporary_text_set_by_instant_ = false; 1073 is_temporary_text_set_by_instant_ = false;
1074 is_instant_temporary_text_a_search_query_ = false;
1069 1075
1070 // Track when the user has deleted text so we won't allow inline 1076 // Track when the user has deleted text so we won't allow inline
1071 // autocomplete. 1077 // autocomplete.
1072 just_deleted_text_ = just_deleted_text; 1078 just_deleted_text_ = just_deleted_text;
1073 1079
1074 if (user_input_in_progress_ && user_text_.empty()) { 1080 if (user_input_in_progress_ && user_text_.empty()) {
1075 // Log cases where the user started editing and then subsequently cleared 1081 // Log cases where the user started editing and then subsequently cleared
1076 // all the text. Note that this explicitly doesn't catch cases like 1082 // all the text. Note that this explicitly doesn't catch cases like
1077 // "hit ctrl-l to select whole edit contents, then hit backspace", because 1083 // "hit ctrl-l to select whole edit contents, then hit backspace", because
1078 // in such cases, |user_input_in_progress| won't be true here. 1084 // in such cases, |user_input_in_progress| won't be true here.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 } 1158 }
1153 1159
1154 if (popup_->IsOpen()) { 1160 if (popup_->IsOpen()) {
1155 OnPopupBoundsChanged(popup_->view()->GetTargetBounds()); 1161 OnPopupBoundsChanged(popup_->view()->GetTargetBounds());
1156 } else if (was_open) { 1162 } else if (was_open) {
1157 // Accepts the temporary text as the user text, because it makes little 1163 // Accepts the temporary text as the user text, because it makes little
1158 // sense to have temporary text when the popup is closed. 1164 // sense to have temporary text when the popup is closed.
1159 InternalSetUserText(UserTextFromDisplayText(view_->GetText())); 1165 InternalSetUserText(UserTextFromDisplayText(view_->GetText()));
1160 has_temporary_text_ = false; 1166 has_temporary_text_ = false;
1161 is_temporary_text_set_by_instant_ = false; 1167 is_temporary_text_set_by_instant_ = false;
1168 is_instant_temporary_text_a_search_query_ = false;
1162 OnPopupBoundsChanged(gfx::Rect()); 1169 OnPopupBoundsChanged(gfx::Rect());
1163 delegate_->NotifySearchTabHelper(user_input_in_progress_, !in_revert_); 1170 delegate_->NotifySearchTabHelper(user_input_in_progress_, !in_revert_);
1164 } 1171 }
1165 1172
1166 InstantController* instant = controller_->GetInstant(); 1173 InstantController* instant = controller_->GetInstant();
1167 if (instant && !in_revert_) 1174 if (instant && !in_revert_)
1168 instant->HandleAutocompleteResults(*autocomplete_controller_->providers()); 1175 instant->HandleAutocompleteResults(*autocomplete_controller_->providers());
1169 } 1176 }
1170 1177
1171 bool OmniboxEditModel::query_in_progress() const { 1178 bool OmniboxEditModel::query_in_progress() const {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 CHECK(popup_->selected_line() < result.size()); 1226 CHECK(popup_->selected_line() < result.size());
1220 *match = result.match_at(popup_->selected_line()); 1227 *match = result.match_at(popup_->selected_line());
1221 } 1228 }
1222 if (alternate_nav_url && popup_->manually_selected_match().empty()) 1229 if (alternate_nav_url && popup_->manually_selected_match().empty())
1223 *alternate_nav_url = result.alternate_nav_url(); 1230 *alternate_nav_url = result.alternate_nav_url();
1224 } 1231 }
1225 1232
1226 void OmniboxEditModel::GetInfoForCurrentText(AutocompleteMatch* match, 1233 void OmniboxEditModel::GetInfoForCurrentText(AutocompleteMatch* match,
1227 GURL* alternate_nav_url) const { 1234 GURL* alternate_nav_url) const {
1228 // If there's temporary text and it has been set by Instant, we won't find it 1235 // If there's temporary text and it has been set by Instant, we won't find it
1229 // in the popup model, so classify the text anew. 1236 // in the popup model, so create the match based on the type Instant told us
1230 if ((popup_->IsOpen() || query_in_progress()) && 1237 // (SWYT for queries and UWYT for URLs). We do this instead of classifying the
1231 !is_temporary_text_set_by_instant_) { 1238 // text ourselves because the text may look like a URL, but Instant may expect
1239 // it to be a search (e.g.: a query for "amazon.com").
1240 if (is_temporary_text_set_by_instant_) {
1241 const string16& text = view_->GetText();
1242 if (is_instant_temporary_text_a_search_query_) {
1243 autocomplete_controller_->search_provider()->GetSearchWhatYouTypedMatch(
1244 text, text, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, false, match);
Mark P 2013/04/09 23:59:11 Are there cases when the match you want to provide
Mark P 2013/04/09 23:59:11 Isn't using TemplateURLRef::NO_SUGGESTIONS_AVAILAB
sreeram 2013/04/11 20:37:54 Not needed. Even if you type a query starting with
sreeram 2013/04/11 20:48:58 You're right. Good catch. When we are using the l
1245 } else {
1246 AutocompleteInput input(text, string16::npos, string16(), GURL(), false,
Mark P 2013/04/09 23:59:11 what's wrong with passing the actual current URL h
Mark P 2013/04/09 23:59:11 I'm pretty sure it's not used, but I think you mig
sreeram 2013/04/11 20:37:54 Nothing wrong. I've added a comment. Please see if
sreeram 2013/04/11 20:37:54 As above, I've added a comment as to why I'm mostl
1247 false, false, AutocompleteInput::BEST_MATCH);
1248 *match = HistoryURLProvider::SuggestExactInput(
1249 autocomplete_controller_->history_url_provider(), input, false);
Mark P 2013/04/09 23:59:11 Is it correct to always trim the http? Maybe it s
sreeram 2013/04/11 20:37:54 The false indicates to NOT trim the http. The trim
1250 }
1251 } else if (popup_->IsOpen() || query_in_progress()) {
1232 InfoForCurrentSelection(match, alternate_nav_url); 1252 InfoForCurrentSelection(match, alternate_nav_url);
1233 } else { 1253 } else {
1234 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify( 1254 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(
1235 UserTextFromDisplayText(view_->GetText()), KeywordIsSelected(), true, 1255 UserTextFromDisplayText(view_->GetText()), KeywordIsSelected(), true,
1236 match, alternate_nav_url); 1256 match, alternate_nav_url);
1237 } 1257 }
1238 } 1258 }
1239 1259
1240 void OmniboxEditModel::RevertTemporaryText(bool revert_popup) { 1260 void OmniboxEditModel::RevertTemporaryText(bool revert_popup) {
1241 // The user typed something, then selected a different item. Restore the 1261 // The user typed something, then selected a different item. Restore the
1242 // text they typed and change back to the default item. 1262 // text they typed and change back to the default item.
1243 // NOTE: This purposefully does not reset paste_state_. 1263 // NOTE: This purposefully does not reset paste_state_.
1244 bool notify_instant = is_temporary_text_set_by_instant_; 1264 bool notify_instant = is_temporary_text_set_by_instant_;
1245 just_deleted_text_ = false; 1265 just_deleted_text_ = false;
1246 has_temporary_text_ = false; 1266 has_temporary_text_ = false;
1247 is_temporary_text_set_by_instant_ = false; 1267 is_temporary_text_set_by_instant_ = false;
1268 is_instant_temporary_text_a_search_query_ = false;
1248 1269
1249 InstantController* instant = controller_->GetInstant(); 1270 InstantController* instant = controller_->GetInstant();
1250 if (instant && notify_instant) { 1271 if (instant && notify_instant) {
1251 // Normally, popup_->ResetToDefaultMatch() will cause the view text to be 1272 // Normally, popup_->ResetToDefaultMatch() will cause the view text to be
1252 // updated. In Instant Extended mode however, the popup_ is not used, so it 1273 // updated. In Instant Extended mode however, the popup_ is not used, so it
1253 // won't do anything. So, update the view ourselves. Even if Instant is not 1274 // won't do anything. So, update the view ourselves. Even if Instant is not
1254 // in extended mode (i.e., it's enabled in non-extended mode, or disabled 1275 // in extended mode (i.e., it's enabled in non-extended mode, or disabled
1255 // altogether), this is okay to do, since the call to 1276 // altogether), this is okay to do, since the call to
1256 // popup_->ResetToDefaultMatch() will just override whatever we do here. 1277 // popup_->ResetToDefaultMatch() will just override whatever we do here.
1257 // 1278 //
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 return !keyword.empty() && autocomplete_controller_->keyword_provider() && 1329 return !keyword.empty() && autocomplete_controller_->keyword_provider() &&
1309 !autocomplete_controller_->keyword_provider()-> 1330 !autocomplete_controller_->keyword_provider()->
1310 GetKeywordForText(keyword).empty(); 1331 GetKeywordForText(keyword).empty();
1311 } 1332 }
1312 1333
1313 bool OmniboxEditModel::DoInstant(const AutocompleteMatch& match) { 1334 bool OmniboxEditModel::DoInstant(const AutocompleteMatch& match) {
1314 InstantController* instant = controller_->GetInstant(); 1335 InstantController* instant = controller_->GetInstant();
1315 if (!instant || in_revert_) 1336 if (!instant || in_revert_)
1316 return false; 1337 return false;
1317 1338
1318 // Don't call Update() if the change is a result of a 1339 // Don't call Update() if the change is the result of an
1319 // INSTANT_COMPLETE_REPLACE instant suggestion. 1340 // INSTANT_COMPLETE_REPLACE instant suggestion.
1320 if (has_temporary_text_ && is_temporary_text_set_by_instant_) 1341 if (is_temporary_text_set_by_instant_)
1321 return false; 1342 return false;
1322 1343
1323 // The two pieces of text we want to send Instant, viz., what the user has 1344 // The two pieces of text we want to send Instant, viz., what the user has
1324 // typed, and the full omnibox text including any inline autocompletion. 1345 // typed, and the full omnibox text including any inline autocompletion.
1325 string16 user_text = has_temporary_text_ ? 1346 string16 user_text = has_temporary_text_ ?
1326 match.fill_into_edit : DisplayTextFromUserText(user_text_); 1347 match.fill_into_edit : DisplayTextFromUserText(user_text_);
1327 string16 full_text = view_->GetText(); 1348 string16 full_text = view_->GetText();
1328 1349
1329 // Remove "?" if we're in forced query mode. 1350 // Remove "?" if we're in forced query mode.
1330 AutocompleteInput::RemoveForcedQueryStringIfNecessary( 1351 AutocompleteInput::RemoveForcedQueryStringIfNecessary(
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 instant->OmniboxFocusChanged(state, reason, NULL); 1421 instant->OmniboxFocusChanged(state, reason, NULL);
1401 1422
1402 // Update state and notify view if the omnibox has focus and the caret 1423 // Update state and notify view if the omnibox has focus and the caret
1403 // visibility changed. 1424 // visibility changed.
1404 const bool was_caret_visible = is_caret_visible(); 1425 const bool was_caret_visible = is_caret_visible();
1405 focus_state_ = state; 1426 focus_state_ = state;
1406 if (focus_state_ != OMNIBOX_FOCUS_NONE && 1427 if (focus_state_ != OMNIBOX_FOCUS_NONE &&
1407 is_caret_visible() != was_caret_visible) 1428 is_caret_visible() != was_caret_visible)
1408 view_->ApplyCaretVisibility(); 1429 view_->ApplyCaretVisibility();
1409 } 1430 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698