| 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 14 matching lines...) Expand all Loading... |
| 25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/history/in_memory_database.h" | 26 #include "chrome/browser/history/in_memory_database.h" |
| 27 #include "chrome/browser/search_engines/template_url_service.h" | 27 #include "chrome/browser/search_engines/template_url_service.h" |
| 28 #include "chrome/browser/search_engines/template_url_service_factory.h" | 28 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 30 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 31 #include "content/public/common/url_fetcher.h" | 31 #include "content/public/common/url_fetcher.h" |
| 32 #include "googleurl/src/url_util.h" | 32 #include "googleurl/src/url_util.h" |
| 33 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
| 34 #include "net/base/escape.h" | 34 #include "net/base/escape.h" |
| 35 #include "net/base/load_flags.h" |
| 35 #include "net/http/http_response_headers.h" | 36 #include "net/http/http_response_headers.h" |
| 36 #include "net/url_request/url_request_status.h" | 37 #include "net/url_request/url_request_status.h" |
| 37 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
| 38 | 39 |
| 39 using base::Time; | 40 using base::Time; |
| 40 using base::TimeDelta; | 41 using base::TimeDelta; |
| 41 | 42 |
| 42 namespace { | 43 namespace { |
| 43 | 44 |
| 44 bool HasMultipleWords(const string16& text) { | 45 bool HasMultipleWords(const string16& text) { |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 const TemplateURLRef* const suggestions_url = provider.suggestions_url(); | 440 const TemplateURLRef* const suggestions_url = provider.suggestions_url(); |
| 440 DCHECK(suggestions_url->SupportsReplacement()); | 441 DCHECK(suggestions_url->SupportsReplacement()); |
| 441 content::URLFetcher* fetcher = content::URLFetcher::Create( | 442 content::URLFetcher* fetcher = content::URLFetcher::Create( |
| 442 id, | 443 id, |
| 443 GURL(suggestions_url->ReplaceSearchTermsUsingProfile( | 444 GURL(suggestions_url->ReplaceSearchTermsUsingProfile( |
| 444 profile_, provider, text, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, | 445 profile_, provider, text, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, |
| 445 string16())), | 446 string16())), |
| 446 content::URLFetcher::GET, | 447 content::URLFetcher::GET, |
| 447 this); | 448 this); |
| 448 fetcher->SetRequestContext(profile_->GetRequestContext()); | 449 fetcher->SetRequestContext(profile_->GetRequestContext()); |
| 450 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); |
| 449 fetcher->Start(); | 451 fetcher->Start(); |
| 450 return fetcher; | 452 return fetcher; |
| 451 } | 453 } |
| 452 | 454 |
| 453 bool SearchProvider::ParseSuggestResults(Value* root_val, | 455 bool SearchProvider::ParseSuggestResults(Value* root_val, |
| 454 bool is_keyword, | 456 bool is_keyword, |
| 455 const string16& input_text, | 457 const string16& input_text, |
| 456 SuggestResults* suggest_results) { | 458 SuggestResults* suggest_results) { |
| 457 if (!root_val->IsType(Value::TYPE_LIST)) | 459 if (!root_val->IsType(Value::TYPE_LIST)) |
| 458 return false; | 460 return false; |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 | 945 |
| 944 return match; | 946 return match; |
| 945 } | 947 } |
| 946 | 948 |
| 947 void SearchProvider::UpdateDone() { | 949 void SearchProvider::UpdateDone() { |
| 948 // 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 |
| 949 // 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. |
| 950 done_ = ((suggest_results_pending_ == 0) && | 952 done_ = ((suggest_results_pending_ == 0) && |
| 951 (instant_finalized_ || !InstantController::IsEnabled(profile_))); | 953 (instant_finalized_ || !InstantController::IsEnabled(profile_))); |
| 952 } | 954 } |
| OLD | NEW |