| 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 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/browser/history/history.h" | 21 #include "chrome/browser/history/history.h" |
| 22 #include "chrome/browser/instant/instant_controller.h" | 22 #include "chrome/browser/instant/instant_controller.h" |
| 23 #include "chrome/browser/net/url_fixer_upper.h" | 23 #include "chrome/browser/net/url_fixer_upper.h" |
| 24 #include "chrome/browser/prefs/pref_service.h" | 24 #include "chrome/browser/prefs/pref_service.h" |
| 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/content_url_request_user_data.h" |
| 31 #include "content/public/common/url_fetcher.h" | 32 #include "content/public/common/url_fetcher.h" |
| 32 #include "googleurl/src/url_util.h" | 33 #include "googleurl/src/url_util.h" |
| 33 #include "grit/generated_resources.h" | 34 #include "grit/generated_resources.h" |
| 34 #include "net/base/escape.h" | 35 #include "net/base/escape.h" |
| 35 #include "net/base/load_flags.h" | 36 #include "net/base/load_flags.h" |
| 36 #include "net/http/http_response_headers.h" | 37 #include "net/http/http_response_headers.h" |
| 37 #include "net/url_request/url_request_status.h" | 38 #include "net/url_request/url_request_status.h" |
| 38 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
| 39 | 40 |
| 40 using base::Time; | 41 using base::Time; |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 const TemplateURLRef* const suggestions_url = provider.suggestions_url(); | 441 const TemplateURLRef* const suggestions_url = provider.suggestions_url(); |
| 441 DCHECK(suggestions_url->SupportsReplacement()); | 442 DCHECK(suggestions_url->SupportsReplacement()); |
| 442 content::URLFetcher* fetcher = content::URLFetcher::Create( | 443 content::URLFetcher* fetcher = content::URLFetcher::Create( |
| 443 id, | 444 id, |
| 444 GURL(suggestions_url->ReplaceSearchTermsUsingProfile( | 445 GURL(suggestions_url->ReplaceSearchTermsUsingProfile( |
| 445 profile_, provider, text, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, | 446 profile_, provider, text, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, |
| 446 string16())), | 447 string16())), |
| 447 content::URLFetcher::GET, | 448 content::URLFetcher::GET, |
| 448 this); | 449 this); |
| 449 fetcher->SetRequestContext(profile_->GetRequestContext()); | 450 fetcher->SetRequestContext(profile_->GetRequestContext()); |
| 451 // TODO(jochen): Do cookie audit. |
| 452 fetcher->SetContentURLRequestUserData( |
| 453 new content::ContentURLRequestUserData()); |
| 450 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); | 454 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); |
| 451 fetcher->Start(); | 455 fetcher->Start(); |
| 452 return fetcher; | 456 return fetcher; |
| 453 } | 457 } |
| 454 | 458 |
| 455 bool SearchProvider::ParseSuggestResults(Value* root_val, | 459 bool SearchProvider::ParseSuggestResults(Value* root_val, |
| 456 bool is_keyword, | 460 bool is_keyword, |
| 457 const string16& input_text, | 461 const string16& input_text, |
| 458 SuggestResults* suggest_results) { | 462 SuggestResults* suggest_results) { |
| 459 if (!root_val->IsType(Value::TYPE_LIST)) | 463 if (!root_val->IsType(Value::TYPE_LIST)) |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 | 951 |
| 948 return match; | 952 return match; |
| 949 } | 953 } |
| 950 | 954 |
| 951 void SearchProvider::UpdateDone() { | 955 void SearchProvider::UpdateDone() { |
| 952 // We're done when there are no more suggest queries pending (this is set to 1 | 956 // We're done when there are no more suggest queries pending (this is set to 1 |
| 953 // when the timer is started) and we're not waiting on instant. | 957 // when the timer is started) and we're not waiting on instant. |
| 954 done_ = ((suggest_results_pending_ == 0) && | 958 done_ = ((suggest_results_pending_ == 0) && |
| 955 (instant_finalized_ || !InstantController::IsEnabled(profile_))); | 959 (instant_finalized_ || !InstantController::IsEnabled(profile_))); |
| 956 } | 960 } |
| OLD | NEW |