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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 // the providers again. | 271 // the providers again. |
272 UpdateResult(false); | 272 UpdateResult(false); |
273 } | 273 } |
274 | 274 |
275 void AutocompleteController::OnProviderUpdate(bool updated_matches) { | 275 void AutocompleteController::OnProviderUpdate(bool updated_matches) { |
276 if (in_zero_suggest_) { | 276 if (in_zero_suggest_) { |
277 // We got ZeroSuggest results before Start(). Show only those results, | 277 // We got ZeroSuggest results before Start(). Show only those results, |
278 // because results from other providers are stale. | 278 // because results from other providers are stale. |
279 result_.Reset(); | 279 result_.Reset(); |
280 result_.AppendMatches(zero_suggest_provider_->matches()); | 280 result_.AppendMatches(zero_suggest_provider_->matches()); |
281 result_.SortAndCull(input_); | 281 result_.SortAndCull(input_, profile_); |
282 NotifyChanged(true); | 282 NotifyChanged(true); |
283 } else { | 283 } else { |
284 CheckIfDone(); | 284 CheckIfDone(); |
285 // Multiple providers may provide synchronous results, so we only update the | 285 // Multiple providers may provide synchronous results, so we only update the |
286 // results if we're not in Start(). | 286 // results if we're not in Start(). |
287 if (!in_start_ && (updated_matches || done_)) | 287 if (!in_start_ && (updated_matches || done_)) |
288 UpdateResult(false); | 288 UpdateResult(false); |
289 } | 289 } |
290 } | 290 } |
291 | 291 |
(...skipping 12 matching lines...) Expand all Loading... |
304 | 304 |
305 void AutocompleteController::UpdateResult(bool is_synchronous_pass) { | 305 void AutocompleteController::UpdateResult(bool is_synchronous_pass) { |
306 AutocompleteResult last_result; | 306 AutocompleteResult last_result; |
307 last_result.Swap(&result_); | 307 last_result.Swap(&result_); |
308 | 308 |
309 for (ACProviders::const_iterator i(providers_.begin()); i != providers_.end(); | 309 for (ACProviders::const_iterator i(providers_.begin()); i != providers_.end(); |
310 ++i) | 310 ++i) |
311 result_.AppendMatches((*i)->matches()); | 311 result_.AppendMatches((*i)->matches()); |
312 | 312 |
313 // Sort the matches and trim to a small number of "best" matches. | 313 // Sort the matches and trim to a small number of "best" matches. |
314 result_.SortAndCull(input_); | 314 result_.SortAndCull(input_, profile_); |
315 | 315 |
316 // Need to validate before invoking CopyOldMatches as the old matches are not | 316 // Need to validate before invoking CopyOldMatches as the old matches are not |
317 // valid against the current input. | 317 // valid against the current input. |
318 #ifndef NDEBUG | 318 #ifndef NDEBUG |
319 result_.Validate(); | 319 result_.Validate(); |
320 #endif | 320 #endif |
321 | 321 |
322 if (!done_) { | 322 if (!done_) { |
323 // This conditional needs to match the conditional in Start that invokes | 323 // This conditional needs to match the conditional in Start that invokes |
324 // StartExpireTimer. | 324 // StartExpireTimer. |
325 result_.CopyOldMatches(input_, last_result); | 325 result_.CopyOldMatches(input_, last_result, profile_); |
326 } | 326 } |
327 | 327 |
328 UpdateKeywordDescriptions(&result_); | 328 UpdateKeywordDescriptions(&result_); |
329 UpdateAssociatedKeywords(&result_); | 329 UpdateAssociatedKeywords(&result_); |
330 UpdateAssistedQueryStats(&result_); | 330 UpdateAssistedQueryStats(&result_); |
331 | 331 |
332 bool notify_default_match = is_synchronous_pass; | 332 bool notify_default_match = is_synchronous_pass; |
333 if (!is_synchronous_pass) { | 333 if (!is_synchronous_pass) { |
334 const bool last_default_was_valid = | 334 const bool last_default_was_valid = |
335 last_result.default_match() != last_result.end(); | 335 last_result.default_match() != last_result.end(); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 } | 471 } |
472 done_ = true; | 472 done_ = true; |
473 } | 473 } |
474 | 474 |
475 void AutocompleteController::StartExpireTimer() { | 475 void AutocompleteController::StartExpireTimer() { |
476 if (result_.HasCopiedMatches()) | 476 if (result_.HasCopiedMatches()) |
477 expire_timer_.Start(FROM_HERE, | 477 expire_timer_.Start(FROM_HERE, |
478 base::TimeDelta::FromMilliseconds(kExpireTimeMS), | 478 base::TimeDelta::FromMilliseconds(kExpireTimeMS), |
479 this, &AutocompleteController::ExpireCopiedEntries); | 479 this, &AutocompleteController::ExpireCopiedEntries); |
480 } | 480 } |
OLD | NEW |