Chromium Code Reviews| Index: chrome/browser/instant/instant_controller.cc |
| diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc |
| index 7b66a2f32305a55ec9226946a8842aed30ea458d..23c2ba7dcc4fe0608526f5c7f3388983298e9145 100644 |
| --- a/chrome/browser/instant/instant_controller.cc |
| +++ b/chrome/browser/instant/instant_controller.cc |
| @@ -144,6 +144,7 @@ bool InstantController::IsEnabled(Profile* profile) { |
| bool InstantController::Update(const AutocompleteMatch& match, |
| const string16& user_text, |
| + const string16& full_text, |
| bool verbatim, |
| string16* suggested_text, |
| InstantCompleteBehavior* complete_behavior) { |
| @@ -164,17 +165,11 @@ bool InstantController::Update(const AutocompleteMatch& match, |
| return false; |
| } |
| - string16 full_text = user_text + *suggested_text; |
| - |
| if (full_text.empty()) { |
| Hide(); |
| return false; |
| } |
| - // The presence of any suggested_text implies verbatim. |
| - DCHECK(suggested_text->empty() || verbatim) |
| - << user_text << "|" << *suggested_text; |
| - |
| ResetLoader(instant_url, active_tab); |
| last_active_tab_ = active_tab; |
| @@ -182,15 +177,17 @@ bool InstantController::Update(const AutocompleteMatch& match, |
| url_for_history_ = match.destination_url; |
| last_transition_type_ = match.transition; |
| + // In EXTENDED mode, we send only |user_text| as the query text. In all other |
| + // modes, we use the entire |full_text|. |
| + const string16& query_text = mode_ == EXTENDED ? user_text : full_text; |
| + string16 last_query_text = mode_ == EXTENDED ? last_user_text_ |
|
Peter Kasting
2012/08/24 22:27:19
Nit: Break after ==, not before :
sreeram
2012/08/24 23:09:55
Done.
|
| + : last_full_text_; |
| last_user_text_ = user_text; |
| + last_full_text_ = full_text; |
| // Don't send an update to the loader if the query text hasn't changed. |
| - if (full_text == last_full_text_ && verbatim == last_verbatim_) { |
| - // Since we are updating |suggested_text|, shouldn't we also update |
| - // |last_full_text_|? No. There's no guarantee that our suggestion will |
| - // actually be inline autocompleted. For example, it may get trumped by |
| - // a history suggestion. If our suggestion does make it, the omnibox will |
| - // call Update() again, at which time we'll update |last_full_text_|. |
| + if (query_text == last_query_text && verbatim == last_verbatim_) { |
| + // Reuse the last suggestion, as it's still valid. |
| *suggested_text = last_suggestion_.text; |
|
Peter Kasting
2012/08/24 22:27:19
This looks like a case where we set this outparam
sreeram
2012/08/24 23:09:55
For the current query (if it's not a duplicate of
|
| *complete_behavior = last_suggestion_.behavior; |
| @@ -207,17 +204,12 @@ bool InstantController::Update(const AutocompleteMatch& match, |
| return true; |
| } |
| - last_full_text_ = full_text; |
| last_verbatim_ = verbatim; |
| loader_processed_last_update_ = false; |
| - |
| - // Reset the last suggestion, as it's no longer valid. |
| - suggested_text->clear(); |
| last_suggestion_ = InstantSuggestion(); |
| - *complete_behavior = INSTANT_COMPLETE_NOW; |
| if (mode_ != SILENT) { |
| - loader_->Update(last_full_text_, last_verbatim_); |
| + loader_->Update(query_text, verbatim); |
| content::NotificationService::current()->Notify( |
| chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED, |