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 <stddef.h> | 7 #include <stddef.h> |
8 | |
9 #include <algorithm> | 8 #include <algorithm> |
10 #include <cmath> | 9 #include <cmath> |
| 10 #include <utility> |
11 | 11 |
12 #include "base/base64.h" | 12 #include "base/base64.h" |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/i18n/break_iterator.h" | 15 #include "base/i18n/break_iterator.h" |
16 #include "base/i18n/case_conversion.h" | 16 #include "base/i18n/case_conversion.h" |
17 #include "base/json/json_string_value_serializer.h" | 17 #include "base/json/json_string_value_serializer.h" |
18 #include "base/metrics/histogram_macros.h" | 18 #include "base/metrics/histogram_macros.h" |
19 #include "base/metrics/user_metrics.h" | 19 #include "base/metrics/user_metrics.h" |
20 #include "base/rand_util.h" | 20 #include "base/rand_util.h" |
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 answer_contents = it->answer_contents; | 934 answer_contents = it->answer_contents; |
935 answer_type = it->answer_type; | 935 answer_type = it->answer_type; |
936 answer = SuggestionAnswer::copy(it->answer.get()); | 936 answer = SuggestionAnswer::copy(it->answer.get()); |
937 break; | 937 break; |
938 } | 938 } |
939 } | 939 } |
940 | 940 |
941 SearchSuggestionParser::SuggestResult verbatim( | 941 SearchSuggestionParser::SuggestResult verbatim( |
942 trimmed_verbatim, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, | 942 trimmed_verbatim, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
943 trimmed_verbatim, base::string16(), base::string16(), answer_contents, | 943 trimmed_verbatim, base::string16(), base::string16(), answer_contents, |
944 answer_type, answer.Pass(), std::string(), std::string(), false, | 944 answer_type, std::move(answer), std::string(), std::string(), false, |
945 verbatim_relevance, relevance_from_server, false, trimmed_verbatim); | 945 verbatim_relevance, relevance_from_server, false, trimmed_verbatim); |
946 AddMatchToMap(verbatim, std::string(), did_not_accept_default_suggestion, | 946 AddMatchToMap(verbatim, std::string(), did_not_accept_default_suggestion, |
947 false, keyword_url != NULL, &map); | 947 false, keyword_url != NULL, &map); |
948 } | 948 } |
949 if (!keyword_input_.text().empty()) { | 949 if (!keyword_input_.text().empty()) { |
950 // We only create the verbatim search query match for a keyword | 950 // We only create the verbatim search query match for a keyword |
951 // if it's not an extension keyword. Extension keywords are handled | 951 // if it's not an extension keyword. Extension keywords are handled |
952 // in KeywordProvider::Start(). (Extensions are complicated...) | 952 // in KeywordProvider::Start(). (Extensions are complicated...) |
953 // Note: in this provider, SEARCH_OTHER_ENGINE must correspond | 953 // Note: in this provider, SEARCH_OTHER_ENGINE must correspond |
954 // to the keyword verbatim search query. Do not create other matches | 954 // to the keyword verbatim search query. Do not create other matches |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1505 for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i) | 1505 for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i) |
1506 matches.push_back(i->second); | 1506 matches.push_back(i->second); |
1507 std::sort(matches.begin(), matches.end(), &AutocompleteMatch::MoreRelevant); | 1507 std::sort(matches.begin(), matches.end(), &AutocompleteMatch::MoreRelevant); |
1508 | 1508 |
1509 // If there is a top scoring entry, find the corresponding answer. | 1509 // If there is a top scoring entry, find the corresponding answer. |
1510 if (!matches.empty()) | 1510 if (!matches.empty()) |
1511 return answers_cache_.GetTopAnswerEntry(matches[0].contents); | 1511 return answers_cache_.GetTopAnswerEntry(matches[0].contents); |
1512 | 1512 |
1513 return AnswersQueryData(); | 1513 return AnswersQueryData(); |
1514 } | 1514 } |
OLD | NEW |