| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 | 358 |
| 359 // We'll have at least one pending fetch. Set it to 1 now, but the value is | 359 // We'll have at least one pending fetch. Set it to 1 now, but the value is |
| 360 // correctly set in Run. As Run isn't invoked immediately we need to set this | 360 // correctly set in Run. As Run isn't invoked immediately we need to set this |
| 361 // now, else we won't think we're waiting on results from the server when we | 361 // now, else we won't think we're waiting on results from the server when we |
| 362 // really are. | 362 // really are. |
| 363 suggest_results_pending_ = 1; | 363 suggest_results_pending_ = 1; |
| 364 | 364 |
| 365 // Kick off a timer that will start the URL fetch if it completes before | 365 // Kick off a timer that will start the URL fetch if it completes before |
| 366 // the user types another character. | 366 // the user types another character. |
| 367 int delay = query_suggest_immediately_ ? 0 : kQueryDelayMs; | 367 int delay = query_suggest_immediately_ ? 0 : kQueryDelayMs; |
| 368 timer_.Start(FROM_HERE, TimeDelta::FromMilliseconds(delay), this, | 368 timer_.Start(TimeDelta::FromMilliseconds(delay), this, &SearchProvider::Run); |
| 369 &SearchProvider::Run); | |
| 370 } | 369 } |
| 371 | 370 |
| 372 bool SearchProvider::IsQuerySuitableForSuggest() const { | 371 bool SearchProvider::IsQuerySuitableForSuggest() const { |
| 373 // Don't run Suggest in incognito mode, the engine doesn't support it, or | 372 // Don't run Suggest in incognito mode, the engine doesn't support it, or |
| 374 // the user has disabled it. | 373 // the user has disabled it. |
| 375 if (profile_->IsOffTheRecord() || | 374 if (profile_->IsOffTheRecord() || |
| 376 (!providers_.valid_suggest_for_keyword_provider() && | 375 (!providers_.valid_suggest_for_keyword_provider() && |
| 377 !providers_.valid_suggest_for_default_provider()) || | 376 !providers_.valid_suggest_for_default_provider()) || |
| 378 !profile_->GetPrefs()->GetBoolean(prefs::kSearchSuggestEnabled)) | 377 !profile_->GetPrefs()->GetBoolean(prefs::kSearchSuggestEnabled)) |
| 379 return false; | 378 return false; |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 | 940 |
| 942 return match; | 941 return match; |
| 943 } | 942 } |
| 944 | 943 |
| 945 void SearchProvider::UpdateDone() { | 944 void SearchProvider::UpdateDone() { |
| 946 // We're done when there are no more suggest queries pending (this is set to 1 | 945 // We're done when there are no more suggest queries pending (this is set to 1 |
| 947 // when the timer is started) and we're not waiting on instant. | 946 // when the timer is started) and we're not waiting on instant. |
| 948 done_ = ((suggest_results_pending_ == 0) && | 947 done_ = ((suggest_results_pending_ == 0) && |
| 949 (instant_finalized_ || !InstantController::IsEnabled(profile_))); | 948 (instant_finalized_ || !InstantController::IsEnabled(profile_))); |
| 950 } | 949 } |
| OLD | NEW |