| 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 "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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 if (i.IsWord()) { | 95 if (i.IsWord()) { |
| 96 if (found_word) | 96 if (found_word) |
| 97 return true; | 97 return true; |
| 98 found_word = true; | 98 found_word = true; |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 return false; | 102 return false; |
| 103 } | 103 } |
| 104 | 104 |
| 105 // Builds the match contents and classification for the contents, and updates | |
| 106 // the given |AutocompleteMatch|. | |
| 107 void SetAndClassifyMatchContents(const base::string16& query_string, | |
| 108 const base::string16& input_text, | |
| 109 const base::string16& match_contents, | |
| 110 AutocompleteMatch* match) { | |
| 111 match->contents = match_contents.empty() ? query_string : match_contents; | |
| 112 | |
| 113 // We do intra-string highlighting for suggestions - the suggested segment | |
| 114 // will be highlighted, e.g. for input_text = "you" the suggestion may be | |
| 115 // "youtube", so we'll bold the "tube" section: you*tube*. | |
| 116 if (input_text != match_contents) { | |
| 117 size_t input_position = match->contents.find(input_text); | |
| 118 if (input_position == base::string16::npos) { | |
| 119 // The input text is not a substring of the query string, e.g. input | |
| 120 // text is "slasdot" and the query string is "slashdot", so we bold the | |
| 121 // whole thing. | |
| 122 match->contents_class.push_back(ACMatchClassification( | |
| 123 0, ACMatchClassification::MATCH)); | |
| 124 } else { | |
| 125 // TODO(beng): ACMatchClassification::MATCH now seems to just mean | |
| 126 // "bold" this. Consider modifying the terminology. | |
| 127 // We don't iterate over the string here annotating all matches because | |
| 128 // it looks odd to have every occurrence of a substring that may be as | |
| 129 // short as a single character highlighted in a query suggestion result, | |
| 130 // e.g. for input text "s" and query string "southwest airlines", it | |
| 131 // looks odd if both the first and last s are highlighted. | |
| 132 if (input_position != 0) { | |
| 133 match->contents_class.push_back(ACMatchClassification( | |
| 134 0, ACMatchClassification::MATCH)); | |
| 135 } | |
| 136 match->contents_class.push_back( | |
| 137 ACMatchClassification(input_position, ACMatchClassification::NONE)); | |
| 138 size_t next_fragment_position = input_position + input_text.length(); | |
| 139 if (next_fragment_position < query_string.length()) { | |
| 140 match->contents_class.push_back(ACMatchClassification( | |
| 141 next_fragment_position, ACMatchClassification::MATCH)); | |
| 142 } | |
| 143 } | |
| 144 } else { | |
| 145 // Otherwise, |match| is a verbatim (what-you-typed) match, either for the | |
| 146 // default provider or a keyword search provider. | |
| 147 match->contents_class.push_back(ACMatchClassification( | |
| 148 0, ACMatchClassification::NONE)); | |
| 149 } | |
| 150 } | |
| 151 | |
| 152 AutocompleteMatchType::Type GetAutocompleteMatchType(const std::string& type) { | 105 AutocompleteMatchType::Type GetAutocompleteMatchType(const std::string& type) { |
| 153 if (type == "ENTITY") | 106 if (type == "ENTITY") |
| 154 return AutocompleteMatchType::SEARCH_SUGGEST_ENTITY; | 107 return AutocompleteMatchType::SEARCH_SUGGEST_ENTITY; |
| 155 if (type == "INFINITE") | 108 if (type == "INFINITE") |
| 156 return AutocompleteMatchType::SEARCH_SUGGEST_INFINITE; | 109 return AutocompleteMatchType::SEARCH_SUGGEST_INFINITE; |
| 157 if (type == "PERSONALIZED") | 110 if (type == "PERSONALIZED") |
| 158 return AutocompleteMatchType::SEARCH_SUGGEST_PERSONALIZED; | 111 return AutocompleteMatchType::SEARCH_SUGGEST_PERSONALIZED; |
| 159 if (type == "PROFILE") | 112 if (type == "PROFILE") |
| 160 return AutocompleteMatchType::SEARCH_SUGGEST_PROFILE; | 113 return AutocompleteMatchType::SEARCH_SUGGEST_PROFILE; |
| 161 return AutocompleteMatchType::SEARCH_SUGGEST; | 114 return AutocompleteMatchType::SEARCH_SUGGEST; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 SearchProvider::SuggestResult::SuggestResult( | 208 SearchProvider::SuggestResult::SuggestResult( |
| 256 const base::string16& suggestion, | 209 const base::string16& suggestion, |
| 257 AutocompleteMatchType::Type type, | 210 AutocompleteMatchType::Type type, |
| 258 const base::string16& match_contents, | 211 const base::string16& match_contents, |
| 259 const base::string16& annotation, | 212 const base::string16& annotation, |
| 260 const std::string& suggest_query_params, | 213 const std::string& suggest_query_params, |
| 261 const std::string& deletion_url, | 214 const std::string& deletion_url, |
| 262 bool from_keyword_provider, | 215 bool from_keyword_provider, |
| 263 int relevance, | 216 int relevance, |
| 264 bool relevance_from_server, | 217 bool relevance_from_server, |
| 265 bool should_prefetch) | 218 bool should_prefetch, |
| 219 const base::string16& input_text) |
| 266 : Result(from_keyword_provider, relevance, relevance_from_server), | 220 : Result(from_keyword_provider, relevance, relevance_from_server), |
| 267 suggestion_(suggestion), | 221 suggestion_(suggestion), |
| 268 type_(type), | 222 type_(type), |
| 269 match_contents_(match_contents), | 223 match_contents_(match_contents), |
| 270 annotation_(annotation), | 224 annotation_(annotation), |
| 271 suggest_query_params_(suggest_query_params), | 225 suggest_query_params_(suggest_query_params), |
| 272 deletion_url_(deletion_url), | 226 deletion_url_(deletion_url), |
| 273 should_prefetch_(should_prefetch) { | 227 should_prefetch_(should_prefetch) { |
| 228 DCHECK(!match_contents_.empty()); |
| 229 ClassifyMatchContents(true, input_text); |
| 274 } | 230 } |
| 275 | 231 |
| 276 SearchProvider::SuggestResult::~SuggestResult() { | 232 SearchProvider::SuggestResult::~SuggestResult() { |
| 277 } | 233 } |
| 278 | 234 |
| 235 void SearchProvider::SuggestResult::ClassifyMatchContents( |
| 236 const bool allow_bolding_all, |
| 237 const base::string16& input_text) { |
| 238 size_t input_position = match_contents_.find(input_text); |
| 239 if (!allow_bolding_all && (input_position == base::string16::npos)) { |
| 240 // Bail if the code below to update the bolding would bold the whole |
| 241 // string. Note that the string may already be entirely bolded; if |
| 242 // so, leave it as is. |
| 243 return; |
| 244 } |
| 245 match_contents_class_.clear(); |
| 246 // We do intra-string highlighting for suggestions - the suggested segment |
| 247 // will be highlighted, e.g. for input_text = "you" the suggestion may be |
| 248 // "youtube", so we'll bold the "tube" section: you*tube*. |
| 249 if (input_text != match_contents_) { |
| 250 if (input_position == base::string16::npos) { |
| 251 // The input text is not a substring of the query string, e.g. input |
| 252 // text is "slasdot" and the query string is "slashdot", so we bold the |
| 253 // whole thing. |
| 254 match_contents_class_.push_back(ACMatchClassification( |
| 255 0, ACMatchClassification::MATCH)); |
| 256 } else { |
| 257 // We don't iterate over the string here annotating all matches because |
| 258 // it looks odd to have every occurrence of a substring that may be as |
| 259 // short as a single character highlighted in a query suggestion result, |
| 260 // e.g. for input text "s" and query string "southwest airlines", it |
| 261 // looks odd if both the first and last s are highlighted. |
| 262 if (input_position != 0) { |
| 263 match_contents_class_.push_back(ACMatchClassification( |
| 264 0, ACMatchClassification::MATCH)); |
| 265 } |
| 266 match_contents_class_.push_back( |
| 267 ACMatchClassification(input_position, ACMatchClassification::NONE)); |
| 268 size_t next_fragment_position = input_position + input_text.length(); |
| 269 if (next_fragment_position < match_contents_.length()) { |
| 270 match_contents_class_.push_back(ACMatchClassification( |
| 271 next_fragment_position, ACMatchClassification::MATCH)); |
| 272 } |
| 273 } |
| 274 } else { |
| 275 // Otherwise, match_contents_ is a verbatim (what-you-typed) match, either |
| 276 // for the default provider or a keyword search provider. |
| 277 match_contents_class_.push_back(ACMatchClassification( |
| 278 0, ACMatchClassification::NONE)); |
| 279 } |
| 280 } |
| 281 |
| 279 bool SearchProvider::SuggestResult::IsInlineable( | 282 bool SearchProvider::SuggestResult::IsInlineable( |
| 280 const base::string16& input) const { | 283 const base::string16& input) const { |
| 281 return StartsWith(suggestion_, input, false); | 284 return StartsWith(suggestion_, input, false); |
| 282 } | 285 } |
| 283 | 286 |
| 284 int SearchProvider::SuggestResult::CalculateRelevance( | 287 int SearchProvider::SuggestResult::CalculateRelevance( |
| 285 const AutocompleteInput& input, | 288 const AutocompleteInput& input, |
| 286 bool keyword_provider_requested) const { | 289 bool keyword_provider_requested) const { |
| 287 if (!from_keyword_provider_ && keyword_provider_requested) | 290 if (!from_keyword_provider_ && keyword_provider_requested) |
| 288 return 100; | 291 return 100; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 const TemplateURL* template_url, | 406 const TemplateURL* template_url, |
| 404 int accepted_suggestion, | 407 int accepted_suggestion, |
| 405 int omnibox_start_margin, | 408 int omnibox_start_margin, |
| 406 bool append_extra_query_params) { | 409 bool append_extra_query_params) { |
| 407 AutocompleteMatch match(autocomplete_provider, suggestion.relevance(), false, | 410 AutocompleteMatch match(autocomplete_provider, suggestion.relevance(), false, |
| 408 suggestion.type()); | 411 suggestion.type()); |
| 409 | 412 |
| 410 if (!template_url) | 413 if (!template_url) |
| 411 return match; | 414 return match; |
| 412 match.keyword = template_url->keyword(); | 415 match.keyword = template_url->keyword(); |
| 413 | 416 match.contents = suggestion.match_contents(); |
| 414 SetAndClassifyMatchContents(suggestion.suggestion(), input_text, | 417 match.contents_class = suggestion.match_contents_class(); |
| 415 suggestion.match_contents(), &match); | |
| 416 | 418 |
| 417 if (!suggestion.annotation().empty()) | 419 if (!suggestion.annotation().empty()) |
| 418 match.description = suggestion.annotation(); | 420 match.description = suggestion.annotation(); |
| 419 | 421 |
| 420 match.allowed_to_be_default_match = | 422 match.allowed_to_be_default_match = |
| 421 (input_text == suggestion.match_contents()); | 423 (input_text == suggestion.match_contents()); |
| 422 | 424 |
| 423 // When the user forced a query, we need to make sure all the fill_into_edit | 425 // When the user forced a query, we need to make sure all the fill_into_edit |
| 424 // values preserve that property. Otherwise, if the user starts editing a | 426 // values preserve that property. Otherwise, if the user starts editing a |
| 425 // suggestion, non-Search results will suddenly appear. | 427 // suggestion, non-Search results will suddenly appear. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 } else { | 565 } else { |
| 564 // The current top result is a navigational suggestion. | 566 // The current top result is a navigational suggestion. |
| 565 if (nav_it->IsInlineable(input)) | 567 if (nav_it->IsInlineable(input)) |
| 566 break; | 568 break; |
| 567 nav_it = navigation_results->erase(nav_it); | 569 nav_it = navigation_results->erase(nav_it); |
| 568 } | 570 } |
| 569 } | 571 } |
| 570 } | 572 } |
| 571 | 573 |
| 572 // static | 574 // static |
| 575 void SearchProvider::UpdateMatchContentsClass(const base::string16& input_text, |
| 576 SuggestResults* suggest_results) { |
| 577 for (SuggestResults::iterator sug_it = suggest_results->begin(); |
| 578 sug_it != suggest_results->end(); ++sug_it) { |
| 579 sug_it->ClassifyMatchContents(false, input_text); |
| 580 } |
| 581 } |
| 582 |
| 583 // static |
| 573 int SearchProvider::CalculateRelevanceForKeywordVerbatim( | 584 int SearchProvider::CalculateRelevanceForKeywordVerbatim( |
| 574 AutocompleteInput::Type type, | 585 AutocompleteInput::Type type, |
| 575 bool prefer_keyword) { | 586 bool prefer_keyword) { |
| 576 // This function is responsible for scoring verbatim query matches | 587 // This function is responsible for scoring verbatim query matches |
| 577 // for non-extension keywords. KeywordProvider::CalculateRelevance() | 588 // for non-extension keywords. KeywordProvider::CalculateRelevance() |
| 578 // scores verbatim query matches for extension keywords, as well as | 589 // scores verbatim query matches for extension keywords, as well as |
| 579 // for keyword matches (i.e., suggestions of a keyword itself, not a | 590 // for keyword matches (i.e., suggestions of a keyword itself, not a |
| 580 // suggestion of a query on a keyword search engine). These two | 591 // suggestion of a query on a keyword search engine). These two |
| 581 // functions are currently in sync, but there's no reason we | 592 // functions are currently in sync, but there's no reason we |
| 582 // couldn't decide in the future to score verbatim matches | 593 // couldn't decide in the future to score verbatim matches |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 (!done_ && | 879 (!done_ && |
| 869 input_.matches_requested() == AutocompleteInput::ALL_MATCHES))) | 880 input_.matches_requested() == AutocompleteInput::ALL_MATCHES))) |
| 870 return; | 881 return; |
| 871 | 882 |
| 872 // We can't keep running any previous query, so halt it. | 883 // We can't keep running any previous query, so halt it. |
| 873 StopSuggest(); | 884 StopSuggest(); |
| 874 | 885 |
| 875 // Remove existing results that cannot inline autocomplete the new input. | 886 // Remove existing results that cannot inline autocomplete the new input. |
| 876 RemoveAllStaleResults(); | 887 RemoveAllStaleResults(); |
| 877 | 888 |
| 889 // Update the content classifications of remaining results so they look good |
| 890 // against the current input. |
| 891 UpdateMatchContentsClass(input_.text(), &default_results_.suggest_results); |
| 892 if (!keyword_input_.text().empty()) { |
| 893 UpdateMatchContentsClass(keyword_input_.text(), |
| 894 &keyword_results_.suggest_results); |
| 895 } |
| 896 |
| 878 // We can't start a new query if we're only allowed synchronous results. | 897 // We can't start a new query if we're only allowed synchronous results. |
| 879 if (input_.matches_requested() != AutocompleteInput::ALL_MATCHES) | 898 if (input_.matches_requested() != AutocompleteInput::ALL_MATCHES) |
| 880 return; | 899 return; |
| 881 | 900 |
| 882 // To avoid flooding the suggest server, don't send a query until at | 901 // To avoid flooding the suggest server, don't send a query until at |
| 883 // least 100 ms since the last query. | 902 // least 100 ms since the last query. |
| 884 base::TimeTicks next_suggest_time(time_suggest_request_sent_ + | 903 base::TimeTicks next_suggest_time(time_suggest_request_sent_ + |
| 885 base::TimeDelta::FromMilliseconds(kMinimumTimeBetweenSuggestQueriesMs)); | 904 base::TimeDelta::FromMilliseconds(kMinimumTimeBetweenSuggestQueriesMs)); |
| 886 base::TimeTicks now(base::TimeTicks::Now()); | 905 base::TimeTicks now(base::TimeTicks::Now()); |
| 887 if (now >= next_suggest_time) { | 906 if (now >= next_suggest_time) { |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 base::string16 annotation; | 1208 base::string16 annotation; |
| 1190 std::string suggest_query_params; | 1209 std::string suggest_query_params; |
| 1191 std::string deletion_url; | 1210 std::string deletion_url; |
| 1192 | 1211 |
| 1193 if (suggestion_details) { | 1212 if (suggestion_details) { |
| 1194 suggestion_details->GetDictionary(index, &suggestion_detail); | 1213 suggestion_details->GetDictionary(index, &suggestion_detail); |
| 1195 if (suggestion_detail) { | 1214 if (suggestion_detail) { |
| 1196 suggestion_detail->GetString("du", &deletion_url); | 1215 suggestion_detail->GetString("du", &deletion_url); |
| 1197 suggestion_detail->GetString("title", &match_contents) || | 1216 suggestion_detail->GetString("title", &match_contents) || |
| 1198 suggestion_detail->GetString("t", &match_contents); | 1217 suggestion_detail->GetString("t", &match_contents); |
| 1218 // Error correction for bad data from server. |
| 1219 if (match_contents.empty()) |
| 1220 match_contents = suggestion; |
| 1199 suggestion_detail->GetString("annotation", &annotation) || | 1221 suggestion_detail->GetString("annotation", &annotation) || |
| 1200 suggestion_detail->GetString("a", &annotation); | 1222 suggestion_detail->GetString("a", &annotation); |
| 1201 suggestion_detail->GetString("query_params", &suggest_query_params) || | 1223 suggestion_detail->GetString("query_params", &suggest_query_params) || |
| 1202 suggestion_detail->GetString("q", &suggest_query_params); | 1224 suggestion_detail->GetString("q", &suggest_query_params); |
| 1203 } | 1225 } |
| 1204 } | 1226 } |
| 1205 | 1227 |
| 1206 // TODO(kochi): Improve calculator suggestion presentation. | 1228 // TODO(kochi): Improve calculator suggestion presentation. |
| 1207 results->suggest_results.push_back(SuggestResult( | 1229 results->suggest_results.push_back(SuggestResult( |
| 1208 suggestion, match_type, match_contents, annotation, | 1230 suggestion, match_type, match_contents, annotation, |
| 1209 suggest_query_params, deletion_url, is_keyword, relevance, true, | 1231 suggest_query_params, deletion_url, is_keyword, relevance, true, |
| 1210 should_prefetch)); | 1232 should_prefetch, input_text)); |
| 1211 } | 1233 } |
| 1212 } | 1234 } |
| 1213 | 1235 |
| 1214 // Ignore suggested scores for non-keyword matches in keyword mode; if the | 1236 // Ignore suggested scores for non-keyword matches in keyword mode; if the |
| 1215 // server is allowed to score these, it could interfere with the user's | 1237 // server is allowed to score these, it could interfere with the user's |
| 1216 // ability to get good keyword results. | 1238 // ability to get good keyword results. |
| 1217 const bool abandon_suggested_scores = | 1239 const bool abandon_suggested_scores = |
| 1218 !is_keyword && !providers_.keyword_provider().empty(); | 1240 !is_keyword && !providers_.keyword_provider().empty(); |
| 1219 // Apply calculated relevance scores to suggestions if a valid list was | 1241 // Apply calculated relevance scores to suggestions if a valid list was |
| 1220 // not provided or we're abandoning suggested scores entirely. | 1242 // not provided or we're abandoning suggested scores entirely. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1250 | 1272 |
| 1251 bool relevance_from_server; | 1273 bool relevance_from_server; |
| 1252 int verbatim_relevance = GetVerbatimRelevance(&relevance_from_server); | 1274 int verbatim_relevance = GetVerbatimRelevance(&relevance_from_server); |
| 1253 int did_not_accept_default_suggestion = | 1275 int did_not_accept_default_suggestion = |
| 1254 default_results_.suggest_results.empty() ? | 1276 default_results_.suggest_results.empty() ? |
| 1255 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE : | 1277 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE : |
| 1256 TemplateURLRef::NO_SUGGESTION_CHOSEN; | 1278 TemplateURLRef::NO_SUGGESTION_CHOSEN; |
| 1257 if (verbatim_relevance > 0) { | 1279 if (verbatim_relevance > 0) { |
| 1258 SuggestResult verbatim( | 1280 SuggestResult verbatim( |
| 1259 input_.text(), AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, | 1281 input_.text(), AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
| 1260 input_.text(), base::string16(), std::string(), std::string(), | 1282 input_.text(), base::string16(), std::string(), std::string(), false, |
| 1261 false, verbatim_relevance, relevance_from_server, false); | 1283 verbatim_relevance, relevance_from_server, false, input_.text()); |
| 1262 AddMatchToMap(verbatim, input_.text(), std::string(), | 1284 AddMatchToMap(verbatim, input_.text(), std::string(), |
| 1263 did_not_accept_default_suggestion, &map); | 1285 did_not_accept_default_suggestion, &map); |
| 1264 } | 1286 } |
| 1265 if (!keyword_input_.text().empty()) { | 1287 if (!keyword_input_.text().empty()) { |
| 1266 const TemplateURL* keyword_url = providers_.GetKeywordProviderURL(); | 1288 const TemplateURL* keyword_url = providers_.GetKeywordProviderURL(); |
| 1267 // We only create the verbatim search query match for a keyword | 1289 // We only create the verbatim search query match for a keyword |
| 1268 // if it's not an extension keyword. Extension keywords are handled | 1290 // if it's not an extension keyword. Extension keywords are handled |
| 1269 // in KeywordProvider::Start(). (Extensions are complicated...) | 1291 // in KeywordProvider::Start(). (Extensions are complicated...) |
| 1270 // Note: in this provider, SEARCH_OTHER_ENGINE must correspond | 1292 // Note: in this provider, SEARCH_OTHER_ENGINE must correspond |
| 1271 // to the keyword verbatim search query. Do not create other matches | 1293 // to the keyword verbatim search query. Do not create other matches |
| 1272 // of type SEARCH_OTHER_ENGINE. | 1294 // of type SEARCH_OTHER_ENGINE. |
| 1273 if (keyword_url && | 1295 if (keyword_url && |
| 1274 (keyword_url->GetType() != TemplateURL::OMNIBOX_API_EXTENSION)) { | 1296 (keyword_url->GetType() != TemplateURL::OMNIBOX_API_EXTENSION)) { |
| 1275 bool keyword_relevance_from_server; | 1297 bool keyword_relevance_from_server; |
| 1276 const int keyword_verbatim_relevance = | 1298 const int keyword_verbatim_relevance = |
| 1277 GetKeywordVerbatimRelevance(&keyword_relevance_from_server); | 1299 GetKeywordVerbatimRelevance(&keyword_relevance_from_server); |
| 1278 if (keyword_verbatim_relevance > 0) { | 1300 if (keyword_verbatim_relevance > 0) { |
| 1279 SuggestResult verbatim( | 1301 SuggestResult verbatim( |
| 1280 keyword_input_.text(), AutocompleteMatchType::SEARCH_OTHER_ENGINE, | 1302 keyword_input_.text(), AutocompleteMatchType::SEARCH_OTHER_ENGINE, |
| 1281 keyword_input_.text(), base::string16(), std::string(), | 1303 keyword_input_.text(), base::string16(), std::string(), |
| 1282 std::string(), true, keyword_verbatim_relevance, | 1304 std::string(), true, keyword_verbatim_relevance, |
| 1283 keyword_relevance_from_server, false); | 1305 keyword_relevance_from_server, false, keyword_input_.text()); |
| 1284 AddMatchToMap(verbatim, keyword_input_.text(), std::string(), | 1306 AddMatchToMap(verbatim, keyword_input_.text(), std::string(), |
| 1285 did_not_accept_keyword_suggestion, &map); | 1307 did_not_accept_keyword_suggestion, &map); |
| 1286 } | 1308 } |
| 1287 } | 1309 } |
| 1288 } | 1310 } |
| 1289 AddHistoryResultsToMap(keyword_history_results_, true, | 1311 AddHistoryResultsToMap(keyword_history_results_, true, |
| 1290 did_not_accept_keyword_suggestion, &map); | 1312 did_not_accept_keyword_suggestion, &map); |
| 1291 AddHistoryResultsToMap(default_history_results_, false, | 1313 AddHistoryResultsToMap(default_history_results_, false, |
| 1292 did_not_accept_default_suggestion, &map); | 1314 did_not_accept_default_suggestion, &map); |
| 1293 | 1315 |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1623 prevent_inline_autocomplete = | 1645 prevent_inline_autocomplete = |
| 1624 !AutocompleteMatch::IsSearchType(match.type); | 1646 !AutocompleteMatch::IsSearchType(match.type); |
| 1625 } | 1647 } |
| 1626 | 1648 |
| 1627 int relevance = CalculateRelevanceForHistory( | 1649 int relevance = CalculateRelevanceForHistory( |
| 1628 i->time, is_keyword, !prevent_inline_autocomplete, | 1650 i->time, is_keyword, !prevent_inline_autocomplete, |
| 1629 prevent_search_history_inlining); | 1651 prevent_search_history_inlining); |
| 1630 scored_results.push_back(SuggestResult( | 1652 scored_results.push_back(SuggestResult( |
| 1631 i->term, AutocompleteMatchType::SEARCH_HISTORY, i->term, | 1653 i->term, AutocompleteMatchType::SEARCH_HISTORY, i->term, |
| 1632 base::string16(), std::string(), std::string(), is_keyword, relevance, | 1654 base::string16(), std::string(), std::string(), is_keyword, relevance, |
| 1633 false, false)); | 1655 false, false, input_text)); |
| 1634 } | 1656 } |
| 1635 | 1657 |
| 1636 // History returns results sorted for us. However, we may have docked some | 1658 // History returns results sorted for us. However, we may have docked some |
| 1637 // results' scores, so things are no longer in order. Do a stable sort to get | 1659 // results' scores, so things are no longer in order. Do a stable sort to get |
| 1638 // things back in order without otherwise disturbing results with equal | 1660 // things back in order without otherwise disturbing results with equal |
| 1639 // scores, then force the scores to be unique, so that the order in which | 1661 // scores, then force the scores to be unique, so that the order in which |
| 1640 // they're shown is deterministic. | 1662 // they're shown is deterministic. |
| 1641 std::stable_sort(scored_results.begin(), scored_results.end(), | 1663 std::stable_sort(scored_results.begin(), scored_results.end(), |
| 1642 CompareScoredResults()); | 1664 CompareScoredResults()); |
| 1643 int last_relevance = 0; | 1665 int last_relevance = 0; |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2035 if (!OmniboxFieldTrial::InZeroSuggestFieldTrial() || | 2057 if (!OmniboxFieldTrial::InZeroSuggestFieldTrial() || |
| 2036 service == NULL || | 2058 service == NULL || |
| 2037 !service->IsSyncEnabledAndLoggedIn() || | 2059 !service->IsSyncEnabledAndLoggedIn() || |
| 2038 !sync_prefs.GetPreferredDataTypes(syncer::UserTypes()).Has( | 2060 !sync_prefs.GetPreferredDataTypes(syncer::UserTypes()).Has( |
| 2039 syncer::PROXY_TABS) || | 2061 syncer::PROXY_TABS) || |
| 2040 service->GetEncryptedDataTypes().Has(syncer::SESSIONS)) | 2062 service->GetEncryptedDataTypes().Has(syncer::SESSIONS)) |
| 2041 return false; | 2063 return false; |
| 2042 | 2064 |
| 2043 return true; | 2065 return true; |
| 2044 } | 2066 } |
| OLD | NEW |