| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/autocomplete/autocomplete_controller.h" | 5 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 // the providers again. | 262 // the providers again. |
| 263 UpdateResult(false); | 263 UpdateResult(false); |
| 264 } | 264 } |
| 265 | 265 |
| 266 void AutocompleteController::OnProviderUpdate(bool updated_matches) { | 266 void AutocompleteController::OnProviderUpdate(bool updated_matches) { |
| 267 if (in_zero_suggest_) { | 267 if (in_zero_suggest_) { |
| 268 // We got ZeroSuggest results before Start(). Show only those results, | 268 // We got ZeroSuggest results before Start(). Show only those results, |
| 269 // because results from other providers are stale. | 269 // because results from other providers are stale. |
| 270 result_.Reset(); | 270 result_.Reset(); |
| 271 result_.AppendMatches(zero_suggest_provider_->matches()); | 271 result_.AppendMatches(zero_suggest_provider_->matches()); |
| 272 result_.SortAndCull(input_); | 272 result_.SortAndCull(input_, profile_); |
| 273 NotifyChanged(true); | 273 NotifyChanged(true); |
| 274 } else { | 274 } else { |
| 275 CheckIfDone(); | 275 CheckIfDone(); |
| 276 // Multiple providers may provide synchronous results, so we only update the | 276 // Multiple providers may provide synchronous results, so we only update the |
| 277 // results if we're not in Start(). | 277 // results if we're not in Start(). |
| 278 if (!in_start_ && (updated_matches || done_)) | 278 if (!in_start_ && (updated_matches || done_)) |
| 279 UpdateResult(false); | 279 UpdateResult(false); |
| 280 } | 280 } |
| 281 } | 281 } |
| 282 | 282 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 295 | 295 |
| 296 void AutocompleteController::UpdateResult(bool is_synchronous_pass) { | 296 void AutocompleteController::UpdateResult(bool is_synchronous_pass) { |
| 297 AutocompleteResult last_result; | 297 AutocompleteResult last_result; |
| 298 last_result.Swap(&result_); | 298 last_result.Swap(&result_); |
| 299 | 299 |
| 300 for (ACProviders::const_iterator i(providers_.begin()); i != providers_.end(); | 300 for (ACProviders::const_iterator i(providers_.begin()); i != providers_.end(); |
| 301 ++i) | 301 ++i) |
| 302 result_.AppendMatches((*i)->matches()); | 302 result_.AppendMatches((*i)->matches()); |
| 303 | 303 |
| 304 // Sort the matches and trim to a small number of "best" matches. | 304 // Sort the matches and trim to a small number of "best" matches. |
| 305 result_.SortAndCull(input_); | 305 result_.SortAndCull(input_, profile_); |
| 306 | 306 |
| 307 // Need to validate before invoking CopyOldMatches as the old matches are not | 307 // Need to validate before invoking CopyOldMatches as the old matches are not |
| 308 // valid against the current input. | 308 // valid against the current input. |
| 309 #ifndef NDEBUG | 309 #ifndef NDEBUG |
| 310 result_.Validate(); | 310 result_.Validate(); |
| 311 #endif | 311 #endif |
| 312 | 312 |
| 313 if (!done_) { | 313 if (!done_) { |
| 314 // This conditional needs to match the conditional in Start that invokes | 314 // This conditional needs to match the conditional in Start that invokes |
| 315 // StartExpireTimer. | 315 // StartExpireTimer. |
| 316 result_.CopyOldMatches(input_, last_result); | 316 result_.CopyOldMatches(input_, last_result, profile_); |
| 317 } | 317 } |
| 318 | 318 |
| 319 UpdateKeywordDescriptions(&result_); | 319 UpdateKeywordDescriptions(&result_); |
| 320 UpdateAssociatedKeywords(&result_); | 320 UpdateAssociatedKeywords(&result_); |
| 321 UpdateAssistedQueryStats(&result_); | 321 UpdateAssistedQueryStats(&result_); |
| 322 | 322 |
| 323 bool notify_default_match = is_synchronous_pass; | 323 bool notify_default_match = is_synchronous_pass; |
| 324 if (!is_synchronous_pass) { | 324 if (!is_synchronous_pass) { |
| 325 const bool last_default_was_valid = | 325 const bool last_default_was_valid = |
| 326 last_result.default_match() != last_result.end(); | 326 last_result.default_match() != last_result.end(); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 } | 462 } |
| 463 done_ = true; | 463 done_ = true; |
| 464 } | 464 } |
| 465 | 465 |
| 466 void AutocompleteController::StartExpireTimer() { | 466 void AutocompleteController::StartExpireTimer() { |
| 467 if (result_.HasCopiedMatches()) | 467 if (result_.HasCopiedMatches()) |
| 468 expire_timer_.Start(FROM_HERE, | 468 expire_timer_.Start(FROM_HERE, |
| 469 base::TimeDelta::FromMilliseconds(kExpireTimeMS), | 469 base::TimeDelta::FromMilliseconds(kExpireTimeMS), |
| 470 this, &AutocompleteController::ExpireCopiedEntries); | 470 this, &AutocompleteController::ExpireCopiedEntries); |
| 471 } | 471 } |
| OLD | NEW |