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/search_provider.h" | 5 #include "chrome/browser/autocomplete/search_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
497 // We can't keep running any previous query, so halt it. | 497 // We can't keep running any previous query, so halt it. |
498 StopSuggest(); | 498 StopSuggest(); |
499 | 499 |
500 // Remove existing results that cannot inline autocomplete the new input. | 500 // Remove existing results that cannot inline autocomplete the new input. |
501 RemoveStaleResults(); | 501 RemoveStaleResults(); |
502 | 502 |
503 // We can't start a new query if we're only allowed synchronous results. | 503 // We can't start a new query if we're only allowed synchronous results. |
504 if (input_.matches_requested() != AutocompleteInput::ALL_MATCHES) | 504 if (input_.matches_requested() != AutocompleteInput::ALL_MATCHES) |
505 return; | 505 return; |
506 | 506 |
507 // We'll have at least one pending fetch. Set it to 1 now, but the value is | |
508 // correctly set in Run. As Run isn't invoked immediately we need to set this | |
509 // now, else we won't think we're waiting on results from the server when we | |
510 // really are. | |
511 suggest_results_pending_ = 1; | |
512 | |
513 // Kick off a timer that will start the URL fetch if it completes before | 507 // Kick off a timer that will start the URL fetch if it completes before |
514 // the user types another character. Requests may be delayed to avoid | 508 // the user types another character. Requests may be delayed to avoid |
515 // flooding the server with requests that are likely to be thrown away later | 509 // flooding the server with requests that are likely to be thrown away later |
516 // anyway. | 510 // anyway. |
517 timer_.Start(FROM_HERE, GetSuggestQueryDelay(), this, &SearchProvider::Run); | 511 timer_.Start(FROM_HERE, GetSuggestQueryDelay(), this, &SearchProvider::Run); |
518 } | 512 } |
519 | 513 |
520 bool SearchProvider::IsQuerySuitableForSuggest() const { | 514 bool SearchProvider::IsQuerySuitableForSuggest() const { |
521 // Don't run Suggest in incognito mode, if the engine doesn't support it, or | 515 // Don't run Suggest in incognito mode, if the engine doesn't support it, or |
522 // if the user has disabled it. | 516 // if the user has disabled it. |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1235 match.contents.length(), ACMatchClassification::URL, | 1229 match.contents.length(), ACMatchClassification::URL, |
1236 &match.contents_class); | 1230 &match.contents_class); |
1237 | 1231 |
1238 match.description = navigation.description(); | 1232 match.description = navigation.description(); |
1239 AutocompleteMatch::ClassifyMatchInString(input, match.description, | 1233 AutocompleteMatch::ClassifyMatchInString(input, match.description, |
1240 ACMatchClassification::NONE, &match.description_class); | 1234 ACMatchClassification::NONE, &match.description_class); |
1241 return match; | 1235 return match; |
1242 } | 1236 } |
1243 | 1237 |
1244 void SearchProvider::UpdateDone() { | 1238 void SearchProvider::UpdateDone() { |
1245 // We're done when there are no more suggest queries pending (this is set to 1 | 1239 // We're done when the timer isn't running and there are no suggest queries |
msw
2012/08/21 18:30:27
grammar nit: lists of 3+ clauses use comma(s) and
Mark P
2012/08/21 19:13:41
Done.
| |
1246 // when the timer is started) and we're not waiting on instant. | 1240 // pending and we're not waiting on instant. |
1247 done_ = ((suggest_results_pending_ == 0) && | 1241 done_ = (!timer_.IsRunning() && (suggest_results_pending_ == 0) && |
1248 (instant_finalized_ || !InstantController::IsEnabled(profile_))); | 1242 (instant_finalized_ || !InstantController::IsEnabled(profile_))); |
1249 } | 1243 } |
OLD | NEW |