OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "components/omnibox/browser/search_provider.h" | 5 #include "components/omnibox/browser/search_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "components/omnibox/browser/autocomplete_provider_listener.h" | 26 #include "components/omnibox/browser/autocomplete_provider_listener.h" |
27 #include "components/omnibox/browser/autocomplete_result.h" | 27 #include "components/omnibox/browser/autocomplete_result.h" |
28 #include "components/omnibox/browser/keyword_provider.h" | 28 #include "components/omnibox/browser/keyword_provider.h" |
29 #include "components/omnibox/browser/omnibox_field_trial.h" | 29 #include "components/omnibox/browser/omnibox_field_trial.h" |
30 #include "components/omnibox/browser/suggestion_answer.h" | 30 #include "components/omnibox/browser/suggestion_answer.h" |
31 #include "components/omnibox/browser/url_prefix.h" | 31 #include "components/omnibox/browser/url_prefix.h" |
32 #include "components/search/search.h" | 32 #include "components/search/search.h" |
33 #include "components/search_engines/template_url_prepopulate_data.h" | 33 #include "components/search_engines/template_url_prepopulate_data.h" |
34 #include "components/search_engines/template_url_service.h" | 34 #include "components/search_engines/template_url_service.h" |
35 #include "components/url_formatter/url_formatter.h" | 35 #include "components/url_formatter/url_formatter.h" |
36 #include "components/variations/net/variations_http_header_provider.h" | 36 #include "components/variations/net/variations_http_headers.h" |
37 #include "grit/components_strings.h" | 37 #include "grit/components_strings.h" |
38 #include "net/base/escape.h" | 38 #include "net/base/escape.h" |
39 #include "net/base/load_flags.h" | 39 #include "net/base/load_flags.h" |
40 #include "net/http/http_request_headers.h" | 40 #include "net/http/http_request_headers.h" |
41 #include "net/url_request/url_fetcher.h" | 41 #include "net/url_request/url_fetcher.h" |
42 #include "net/url_request/url_request_status.h" | 42 #include "net/url_request/url_request_status.h" |
43 #include "ui/base/l10n/l10n_util.h" | 43 #include "ui/base/l10n/l10n_util.h" |
44 #include "url/url_constants.h" | 44 #include "url/url_constants.h" |
45 #include "url/url_util.h" | 45 #include "url/url_util.h" |
46 | 46 |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 LogOmniboxSuggestRequest(REQUEST_SENT); | 884 LogOmniboxSuggestRequest(REQUEST_SENT); |
885 | 885 |
886 scoped_ptr<net::URLFetcher> fetcher = | 886 scoped_ptr<net::URLFetcher> fetcher = |
887 net::URLFetcher::Create(id, suggest_url, net::URLFetcher::GET, this); | 887 net::URLFetcher::Create(id, suggest_url, net::URLFetcher::GET, this); |
888 data_use_measurement::DataUseUserData::AttachToFetcher( | 888 data_use_measurement::DataUseUserData::AttachToFetcher( |
889 fetcher.get(), data_use_measurement::DataUseUserData::OMNIBOX); | 889 fetcher.get(), data_use_measurement::DataUseUserData::OMNIBOX); |
890 fetcher->SetRequestContext(client()->GetRequestContext()); | 890 fetcher->SetRequestContext(client()->GetRequestContext()); |
891 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); | 891 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); |
892 // Add Chrome experiment state to the request headers. | 892 // Add Chrome experiment state to the request headers. |
893 net::HttpRequestHeaders headers; | 893 net::HttpRequestHeaders headers; |
894 variations::VariationsHttpHeaderProvider::GetInstance()->AppendHeaders( | 894 variations::AppendVariationHeaders( |
895 fetcher->GetOriginalURL(), client()->IsOffTheRecord(), false, &headers); | 895 fetcher->GetOriginalURL(), client()->IsOffTheRecord(), false, &headers); |
896 fetcher->SetExtraRequestHeaders(headers.ToString()); | 896 fetcher->SetExtraRequestHeaders(headers.ToString()); |
897 fetcher->Start(); | 897 fetcher->Start(); |
898 return fetcher; | 898 return fetcher; |
899 } | 899 } |
900 | 900 |
901 void SearchProvider::ConvertResultsToAutocompleteMatches() { | 901 void SearchProvider::ConvertResultsToAutocompleteMatches() { |
902 // Convert all the results to matches and add them to a map, so we can keep | 902 // Convert all the results to matches and add them to a map, so we can keep |
903 // the most relevant match for each result. | 903 // the most relevant match for each result. |
904 base::TimeTicks start_time(base::TimeTicks::Now()); | 904 base::TimeTicks start_time(base::TimeTicks::Now()); |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1503 for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i) | 1503 for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i) |
1504 matches.push_back(i->second); | 1504 matches.push_back(i->second); |
1505 std::sort(matches.begin(), matches.end(), &AutocompleteMatch::MoreRelevant); | 1505 std::sort(matches.begin(), matches.end(), &AutocompleteMatch::MoreRelevant); |
1506 | 1506 |
1507 // If there is a top scoring entry, find the corresponding answer. | 1507 // If there is a top scoring entry, find the corresponding answer. |
1508 if (!matches.empty()) | 1508 if (!matches.empty()) |
1509 return answers_cache_.GetTopAnswerEntry(matches[0].contents); | 1509 return answers_cache_.GetTopAnswerEntry(matches[0].contents); |
1510 | 1510 |
1511 return AnswersQueryData(); | 1511 return AnswersQueryData(); |
1512 } | 1512 } |
OLD | NEW |