| 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(TimeDelta::FromMilliseconds(delay), this, &SearchProvider::Run); | 368 timer_.Start(TimeDelta::FromMilliseconds(delay), this, &SearchProvider::Run, |
| 369 FROM_HERE); |
| 369 } | 370 } |
| 370 | 371 |
| 371 bool SearchProvider::IsQuerySuitableForSuggest() const { | 372 bool SearchProvider::IsQuerySuitableForSuggest() const { |
| 372 // Don't run Suggest in incognito mode, the engine doesn't support it, or | 373 // Don't run Suggest in incognito mode, the engine doesn't support it, or |
| 373 // the user has disabled it. | 374 // the user has disabled it. |
| 374 if (profile_->IsOffTheRecord() || | 375 if (profile_->IsOffTheRecord() || |
| 375 (!providers_.valid_suggest_for_keyword_provider() && | 376 (!providers_.valid_suggest_for_keyword_provider() && |
| 376 !providers_.valid_suggest_for_default_provider()) || | 377 !providers_.valid_suggest_for_default_provider()) || |
| 377 !profile_->GetPrefs()->GetBoolean(prefs::kSearchSuggestEnabled)) | 378 !profile_->GetPrefs()->GetBoolean(prefs::kSearchSuggestEnabled)) |
| 378 return false; | 379 return false; |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 | 945 |
| 945 return match; | 946 return match; |
| 946 } | 947 } |
| 947 | 948 |
| 948 void SearchProvider::UpdateDone() { | 949 void SearchProvider::UpdateDone() { |
| 949 // We're done when there are no more suggest queries pending (this is set to 1 | 950 // We're done when there are no more suggest queries pending (this is set to 1 |
| 950 // when the timer is started) and we're not waiting on instant. | 951 // when the timer is started) and we're not waiting on instant. |
| 951 done_ = ((suggest_results_pending_ == 0) && | 952 done_ = ((suggest_results_pending_ == 0) && |
| 952 (instant_finalized_ || !InstantController::IsEnabled(profile_))); | 953 (instant_finalized_ || !InstantController::IsEnabled(profile_))); |
| 953 } | 954 } |
| OLD | NEW |