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 18 matching lines...) Expand all Loading... |
29 #include "chrome/browser/history/in_memory_database.h" | 29 #include "chrome/browser/history/in_memory_database.h" |
30 #include "chrome/browser/instant/instant_controller.h" | 30 #include "chrome/browser/instant/instant_controller.h" |
31 #include "chrome/browser/net/url_fixer_upper.h" | 31 #include "chrome/browser/net/url_fixer_upper.h" |
32 #include "chrome/browser/prefs/pref_service.h" | 32 #include "chrome/browser/prefs/pref_service.h" |
33 #include "chrome/browser/profiles/profile.h" | 33 #include "chrome/browser/profiles/profile.h" |
34 #include "chrome/browser/search_engines/search_engine_type.h" | 34 #include "chrome/browser/search_engines/search_engine_type.h" |
35 #include "chrome/browser/search_engines/template_url_service.h" | 35 #include "chrome/browser/search_engines/template_url_service.h" |
36 #include "chrome/browser/search_engines/template_url_service_factory.h" | 36 #include "chrome/browser/search_engines/template_url_service_factory.h" |
37 #include "chrome/common/pref_names.h" | 37 #include "chrome/common/pref_names.h" |
38 #include "chrome/common/url_constants.h" | 38 #include "chrome/common/url_constants.h" |
39 #include "content/public/common/url_fetcher.h" | |
40 #include "googleurl/src/url_util.h" | 39 #include "googleurl/src/url_util.h" |
41 #include "grit/generated_resources.h" | 40 #include "grit/generated_resources.h" |
42 #include "net/base/escape.h" | 41 #include "net/base/escape.h" |
43 #include "net/base/load_flags.h" | 42 #include "net/base/load_flags.h" |
44 #include "net/base/net_util.h" | 43 #include "net/base/net_util.h" |
45 #include "net/http/http_response_headers.h" | 44 #include "net/http/http_response_headers.h" |
| 45 #include "net/url_request/url_fetcher.h" |
46 #include "net/url_request/url_request_status.h" | 46 #include "net/url_request/url_request_status.h" |
47 #include "ui/base/l10n/l10n_util.h" | 47 #include "ui/base/l10n/l10n_util.h" |
48 | 48 |
49 using base::Time; | 49 using base::Time; |
50 using base::TimeDelta; | 50 using base::TimeDelta; |
51 | 51 |
52 namespace { | 52 namespace { |
53 | 53 |
54 bool HasMultipleWords(const string16& text) { | 54 bool HasMultipleWords(const string16& text) { |
55 base::i18n::BreakIterator i(text, base::i18n::BreakIterator::BREAK_WORD); | 55 base::i18n::BreakIterator i(text, base::i18n::BreakIterator::BREAK_WORD); |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 (*list)[i].set_relevance(CalculateRelevanceForNavigation(is_keyword) + | 585 (*list)[i].set_relevance(CalculateRelevanceForNavigation(is_keyword) + |
586 (list->size() - i - 1)); | 586 (list->size() - i - 1)); |
587 } | 587 } |
588 } | 588 } |
589 | 589 |
590 net::URLFetcher* SearchProvider::CreateSuggestFetcher( | 590 net::URLFetcher* SearchProvider::CreateSuggestFetcher( |
591 int id, | 591 int id, |
592 const TemplateURLRef& suggestions_url, | 592 const TemplateURLRef& suggestions_url, |
593 const string16& text) { | 593 const string16& text) { |
594 DCHECK(suggestions_url.SupportsReplacement()); | 594 DCHECK(suggestions_url.SupportsReplacement()); |
595 net::URLFetcher* fetcher = content::URLFetcher::Create(id, | 595 net::URLFetcher* fetcher = net::URLFetcher::Create(id, |
596 GURL(suggestions_url.ReplaceSearchTerms(text, | 596 GURL(suggestions_url.ReplaceSearchTerms(text, |
597 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())), | 597 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())), |
598 net::URLFetcher::GET, this); | 598 net::URLFetcher::GET, this); |
599 fetcher->SetRequestContext(profile_->GetRequestContext()); | 599 fetcher->SetRequestContext(profile_->GetRequestContext()); |
600 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); | 600 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); |
601 fetcher->Start(); | 601 fetcher->Start(); |
602 return fetcher; | 602 return fetcher; |
603 } | 603 } |
604 | 604 |
605 bool SearchProvider::ParseSuggestResults(Value* root_val, bool is_keyword) { | 605 bool SearchProvider::ParseSuggestResults(Value* root_val, bool is_keyword) { |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1165 ACMatchClassification::NONE, &match.description_class); | 1165 ACMatchClassification::NONE, &match.description_class); |
1166 return match; | 1166 return match; |
1167 } | 1167 } |
1168 | 1168 |
1169 void SearchProvider::UpdateDone() { | 1169 void SearchProvider::UpdateDone() { |
1170 // We're done when there are no more suggest queries pending (this is set to 1 | 1170 // We're done when there are no more suggest queries pending (this is set to 1 |
1171 // when the timer is started) and we're not waiting on instant. | 1171 // when the timer is started) and we're not waiting on instant. |
1172 done_ = ((suggest_results_pending_ == 0) && | 1172 done_ = ((suggest_results_pending_ == 0) && |
1173 (instant_finalized_ || !InstantController::IsEnabled(profile_))); | 1173 (instant_finalized_ || !InstantController::IsEnabled(profile_))); |
1174 } | 1174 } |
OLD | NEW |