| 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 // If DeleteMatch resulted in a callback to OnProviderUpdate and we're | 272 // If DeleteMatch resulted in a callback to OnProviderUpdate and we're |
| 273 // not done, we might attempt to redisplay the deleted match. Make sure | 273 // not done, we might attempt to redisplay the deleted match. Make sure |
| 274 // we aren't displaying it by removing any old entries. | 274 // we aren't displaying it by removing any old entries. |
| 275 ExpireCopiedEntries(); | 275 ExpireCopiedEntries(); |
| 276 } | 276 } |
| 277 | 277 |
| 278 void AutocompleteController::ExpireCopiedEntries() { | 278 void AutocompleteController::ExpireCopiedEntries() { |
| 279 // The first true makes UpdateResult() clear out the results and | 279 // The first true makes UpdateResult() clear out the results and |
| 280 // regenerate them, thus ensuring that no results from the previous | 280 // regenerate them, thus ensuring that no results from the previous |
| 281 // result set remain. | 281 // result set remain. |
| 282 // The second true says to pretend the default match changed (even | 282 UpdateResult(true, false); |
| 283 // if it did not). This may not be necessary but the code has been | |
| 284 // like this for a long time and there's probably no great benefit in | |
| 285 // changing it. Classically we have erred on the side of notifying | |
| 286 // too often because it hasn't had any major side effects. | |
| 287 UpdateResult(true, true); | |
| 288 } | 283 } |
| 289 | 284 |
| 290 void AutocompleteController::OnProviderUpdate(bool updated_matches) { | 285 void AutocompleteController::OnProviderUpdate(bool updated_matches) { |
| 291 if (in_zero_suggest_) { | 286 if (in_zero_suggest_) { |
| 292 // We got ZeroSuggest results before Start(). Show only those results, | 287 // We got ZeroSuggest results before Start(). Show only those results, |
| 293 // because results from other providers are stale. | 288 // because results from other providers are stale. |
| 294 result_.Reset(); | 289 result_.Reset(); |
| 295 result_.AppendMatches(zero_suggest_provider_->matches()); | 290 result_.AppendMatches(zero_suggest_provider_->matches()); |
| 296 result_.SortAndCull(input_, profile_); | 291 result_.SortAndCull(input_, profile_); |
| 297 NotifyChanged(true); | 292 NotifyChanged(true); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 } | 499 } |
| 505 done_ = true; | 500 done_ = true; |
| 506 } | 501 } |
| 507 | 502 |
| 508 void AutocompleteController::StartExpireTimer() { | 503 void AutocompleteController::StartExpireTimer() { |
| 509 if (result_.HasCopiedMatches()) | 504 if (result_.HasCopiedMatches()) |
| 510 expire_timer_.Start(FROM_HERE, | 505 expire_timer_.Start(FROM_HERE, |
| 511 base::TimeDelta::FromMilliseconds(kExpireTimeMS), | 506 base::TimeDelta::FromMilliseconds(kExpireTimeMS), |
| 512 this, &AutocompleteController::ExpireCopiedEntries); | 507 this, &AutocompleteController::ExpireCopiedEntries); |
| 513 } | 508 } |
| OLD | NEW |