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/search_provider.h" | 5 #include "components/omnibox/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 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 base::UTF16ToUTF8(prefetch_data_.query_type); | 841 base::UTF16ToUTF8(prefetch_data_.query_type); |
842 } | 842 } |
843 } | 843 } |
844 GURL suggest_url(template_url->suggestions_url_ref().ReplaceSearchTerms( | 844 GURL suggest_url(template_url->suggestions_url_ref().ReplaceSearchTerms( |
845 search_term_args, | 845 search_term_args, |
846 providers_.template_url_service()->search_terms_data())); | 846 providers_.template_url_service()->search_terms_data())); |
847 if (!suggest_url.is_valid()) | 847 if (!suggest_url.is_valid()) |
848 return NULL; | 848 return NULL; |
849 // Send the current page URL if user setting and URL requirements are met and | 849 // Send the current page URL if user setting and URL requirements are met and |
850 // the user is in the field trial. | 850 // the user is in the field trial. |
851 if (CanSendURL(current_page_url_, suggest_url, template_url, | 851 if (CanSendURL(input.current_url(), suggest_url, template_url, |
852 input.current_page_classification(), | 852 input.current_page_classification(), |
853 template_url_service_->search_terms_data(), client_.get()) && | 853 template_url_service_->search_terms_data(), client_.get()) && |
854 OmniboxFieldTrial::InZeroSuggestAfterTypingFieldTrial()) { | 854 OmniboxFieldTrial::InZeroSuggestAfterTypingFieldTrial()) { |
855 search_term_args.current_page_url = current_page_url_.spec(); | 855 search_term_args.current_page_url = input.current_url().spec(); |
856 // Create the suggest URL again with the current page URL. | 856 // Create the suggest URL again with the current page URL. |
857 suggest_url = GURL(template_url->suggestions_url_ref().ReplaceSearchTerms( | 857 suggest_url = GURL(template_url->suggestions_url_ref().ReplaceSearchTerms( |
858 search_term_args, | 858 search_term_args, |
859 providers_.template_url_service()->search_terms_data())); | 859 providers_.template_url_service()->search_terms_data())); |
860 } | 860 } |
861 | 861 |
862 LogOmniboxSuggestRequest(REQUEST_SENT); | 862 LogOmniboxSuggestRequest(REQUEST_SENT); |
863 | 863 |
864 scoped_ptr<net::URLFetcher> fetcher = | 864 scoped_ptr<net::URLFetcher> fetcher = |
865 net::URLFetcher::Create(id, suggest_url, net::URLFetcher::GET, this); | 865 net::URLFetcher::Create(id, suggest_url, net::URLFetcher::GET, this); |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i) | 1512 for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i) |
1513 matches.push_back(i->second); | 1513 matches.push_back(i->second); |
1514 std::sort(matches.begin(), matches.end(), &AutocompleteMatch::MoreRelevant); | 1514 std::sort(matches.begin(), matches.end(), &AutocompleteMatch::MoreRelevant); |
1515 | 1515 |
1516 // If there is a top scoring entry, find the corresponding answer. | 1516 // If there is a top scoring entry, find the corresponding answer. |
1517 if (!matches.empty()) | 1517 if (!matches.empty()) |
1518 return answers_cache_.GetTopAnswerEntry(matches[0].contents); | 1518 return answers_cache_.GetTopAnswerEntry(matches[0].contents); |
1519 | 1519 |
1520 return AnswersQueryData(); | 1520 return AnswersQueryData(); |
1521 } | 1521 } |
OLD | NEW |