| 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 11 matching lines...) Expand all Loading... |
| 22 #include "chrome/browser/autocomplete/autocomplete_result.h" | 22 #include "chrome/browser/autocomplete/autocomplete_result.h" |
| 23 #include "chrome/browser/autocomplete/keyword_provider.h" | 23 #include "chrome/browser/autocomplete/keyword_provider.h" |
| 24 #include "chrome/browser/autocomplete/url_prefix.h" | 24 #include "chrome/browser/autocomplete/url_prefix.h" |
| 25 #include "chrome/browser/google/google_util.h" | 25 #include "chrome/browser/google/google_util.h" |
| 26 #include "chrome/browser/history/history_service.h" | 26 #include "chrome/browser/history/history_service.h" |
| 27 #include "chrome/browser/history/history_service_factory.h" | 27 #include "chrome/browser/history/history_service_factory.h" |
| 28 #include "chrome/browser/history/in_memory_database.h" | 28 #include "chrome/browser/history/in_memory_database.h" |
| 29 #include "chrome/browser/metrics/variations/variations_http_header_provider.h" | 29 #include "chrome/browser/metrics/variations/variations_http_header_provider.h" |
| 30 #include "chrome/browser/omnibox/omnibox_field_trial.h" | 30 #include "chrome/browser/omnibox/omnibox_field_trial.h" |
| 31 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
| 32 #include "chrome/browser/search/instant_service.h" | |
| 33 #include "chrome/browser/search/instant_service_factory.h" | |
| 34 #include "chrome/browser/search/search.h" | 32 #include "chrome/browser/search/search.h" |
| 35 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 33 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
| 36 #include "chrome/browser/search_engines/template_url_service.h" | 34 #include "chrome/browser/search_engines/template_url_service.h" |
| 37 #include "chrome/browser/search_engines/template_url_service_factory.h" | 35 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 38 #include "chrome/browser/ui/browser.h" | |
| 39 #include "chrome/browser/ui/browser_finder.h" | |
| 40 #include "chrome/browser/ui/browser_instant_controller.h" | |
| 41 #include "chrome/browser/ui/search/instant_controller.h" | 36 #include "chrome/browser/ui/search/instant_controller.h" |
| 42 #include "chrome/common/net/url_fixer_upper.h" | 37 #include "chrome/common/net/url_fixer_upper.h" |
| 43 #include "chrome/common/pref_names.h" | 38 #include "chrome/common/pref_names.h" |
| 44 #include "chrome/common/url_constants.h" | 39 #include "chrome/common/url_constants.h" |
| 45 #include "content/public/browser/user_metrics.h" | 40 #include "content/public/browser/user_metrics.h" |
| 46 #include "grit/generated_resources.h" | 41 #include "grit/generated_resources.h" |
| 47 #include "net/base/escape.h" | 42 #include "net/base/escape.h" |
| 48 #include "net/base/load_flags.h" | 43 #include "net/base/load_flags.h" |
| 49 #include "net/base/net_util.h" | 44 #include "net/base/net_util.h" |
| 50 #include "net/http/http_request_headers.h" | 45 #include "net/http/http_request_headers.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 }; | 190 }; |
| 196 | 191 |
| 197 | 192 |
| 198 // SearchProvider ------------------------------------------------------------- | 193 // SearchProvider ------------------------------------------------------------- |
| 199 | 194 |
| 200 // static | 195 // static |
| 201 const int SearchProvider::kDefaultProviderURLFetcherID = 1; | 196 const int SearchProvider::kDefaultProviderURLFetcherID = 1; |
| 202 const int SearchProvider::kKeywordProviderURLFetcherID = 2; | 197 const int SearchProvider::kKeywordProviderURLFetcherID = 2; |
| 203 const int SearchProvider::kDeletionURLFetcherID = 3; | 198 const int SearchProvider::kDeletionURLFetcherID = 3; |
| 204 int SearchProvider::kMinimumTimeBetweenSuggestQueriesMs = 100; | 199 int SearchProvider::kMinimumTimeBetweenSuggestQueriesMs = 100; |
| 205 const char SearchProvider::kRelevanceFromServerKey[] = "relevance_from_server"; | |
| 206 const char SearchProvider::kShouldPrefetchKey[] = "should_prefetch"; | |
| 207 const char SearchProvider::kSuggestMetadataKey[] = "suggest_metadata"; | |
| 208 const char SearchProvider::kDeletionUrlKey[] = "deletion_url"; | |
| 209 const char SearchProvider::kTrue[] = "true"; | |
| 210 const char SearchProvider::kFalse[] = "false"; | |
| 211 | 200 |
| 212 SearchProvider::SearchProvider(AutocompleteProviderListener* listener, | 201 SearchProvider::SearchProvider(AutocompleteProviderListener* listener, |
| 213 Profile* profile) | 202 Profile* profile) |
| 214 : BaseSearchProvider(listener, profile, AutocompleteProvider::TYPE_SEARCH), | 203 : BaseSearchProvider(listener, profile, AutocompleteProvider::TYPE_SEARCH), |
| 215 providers_(TemplateURLServiceFactory::GetForProfile(profile)), | 204 providers_(TemplateURLServiceFactory::GetForProfile(profile)), |
| 216 suggest_results_pending_(0) { | 205 suggest_results_pending_(0) { |
| 217 } | 206 } |
| 218 | 207 |
| 219 // static | 208 // static |
| 220 bool SearchProvider::ShouldPrefetch(const AutocompleteMatch& match) { | |
| 221 return match.GetAdditionalInfo(kShouldPrefetchKey) == kTrue; | |
| 222 } | |
| 223 | |
| 224 // static | |
| 225 std::string SearchProvider::GetSuggestMetadata(const AutocompleteMatch& match) { | 209 std::string SearchProvider::GetSuggestMetadata(const AutocompleteMatch& match) { |
| 226 return match.GetAdditionalInfo(kSuggestMetadataKey); | 210 return match.GetAdditionalInfo(kSuggestMetadataKey); |
| 227 } | 211 } |
| 228 | 212 |
| 229 void SearchProvider::DeleteMatch(const AutocompleteMatch& match) { | 213 void SearchProvider::DeleteMatch(const AutocompleteMatch& match) { |
| 230 DCHECK(match.deletable); | 214 DCHECK(match.deletable); |
| 231 | 215 |
| 232 deletion_handlers_.push_back(new SuggestionDeletionHandler( | 216 deletion_handlers_.push_back(new SuggestionDeletionHandler( |
| 233 match.GetAdditionalInfo(SearchProvider::kDeletionUrlKey), | 217 match.GetAdditionalInfo(SearchProvider::kDeletionUrlKey), |
| 234 profile_, | 218 profile_, |
| (...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 int verbatim_relevance = GetVerbatimRelevance(&relevance_from_server); | 982 int verbatim_relevance = GetVerbatimRelevance(&relevance_from_server); |
| 999 int did_not_accept_default_suggestion = | 983 int did_not_accept_default_suggestion = |
| 1000 default_results_.suggest_results.empty() ? | 984 default_results_.suggest_results.empty() ? |
| 1001 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE : | 985 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE : |
| 1002 TemplateURLRef::NO_SUGGESTION_CHOSEN; | 986 TemplateURLRef::NO_SUGGESTION_CHOSEN; |
| 1003 if (verbatim_relevance > 0) { | 987 if (verbatim_relevance > 0) { |
| 1004 SuggestResult verbatim( | 988 SuggestResult verbatim( |
| 1005 input_.text(), AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, | 989 input_.text(), AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
| 1006 input_.text(), base::string16(), std::string(), std::string(), false, | 990 input_.text(), base::string16(), std::string(), std::string(), false, |
| 1007 verbatim_relevance, relevance_from_server, false, input_.text()); | 991 verbatim_relevance, relevance_from_server, false, input_.text()); |
| 1008 AddMatchToMap(verbatim, input_.text(), std::string(), | 992 AddMatchToMap(verbatim, input_, input_.text(), GetTemplateURL(verbatim), |
| 1009 did_not_accept_default_suggestion, &map); | 993 std::string() /* metadata */, did_not_accept_default_suggestion, |
| 994 IsDefaultSearchProviderResult(verbatim), &map); |
| 1010 } | 995 } |
| 1011 if (!keyword_input_.text().empty()) { | 996 if (!keyword_input_.text().empty()) { |
| 1012 const TemplateURL* keyword_url = providers_.GetKeywordProviderURL(); | 997 const TemplateURL* keyword_url = providers_.GetKeywordProviderURL(); |
| 1013 // We only create the verbatim search query match for a keyword | 998 // We only create the verbatim search query match for a keyword |
| 1014 // if it's not an extension keyword. Extension keywords are handled | 999 // if it's not an extension keyword. Extension keywords are handled |
| 1015 // in KeywordProvider::Start(). (Extensions are complicated...) | 1000 // in KeywordProvider::Start(). (Extensions are complicated...) |
| 1016 // Note: in this provider, SEARCH_OTHER_ENGINE must correspond | 1001 // Note: in this provider, SEARCH_OTHER_ENGINE must correspond |
| 1017 // to the keyword verbatim search query. Do not create other matches | 1002 // to the keyword verbatim search query. Do not create other matches |
| 1018 // of type SEARCH_OTHER_ENGINE. | 1003 // of type SEARCH_OTHER_ENGINE. |
| 1019 if (keyword_url && | 1004 if (keyword_url && |
| 1020 (keyword_url->GetType() != TemplateURL::OMNIBOX_API_EXTENSION)) { | 1005 (keyword_url->GetType() != TemplateURL::OMNIBOX_API_EXTENSION)) { |
| 1021 bool keyword_relevance_from_server; | 1006 bool keyword_relevance_from_server; |
| 1022 const int keyword_verbatim_relevance = | 1007 const int keyword_verbatim_relevance = |
| 1023 GetKeywordVerbatimRelevance(&keyword_relevance_from_server); | 1008 GetKeywordVerbatimRelevance(&keyword_relevance_from_server); |
| 1024 if (keyword_verbatim_relevance > 0) { | 1009 if (keyword_verbatim_relevance > 0) { |
| 1025 SuggestResult verbatim( | 1010 SuggestResult verbatim( |
| 1026 keyword_input_.text(), AutocompleteMatchType::SEARCH_OTHER_ENGINE, | 1011 keyword_input_.text(), AutocompleteMatchType::SEARCH_OTHER_ENGINE, |
| 1027 keyword_input_.text(), base::string16(), std::string(), | 1012 keyword_input_.text(), base::string16(), std::string(), |
| 1028 std::string(), true, keyword_verbatim_relevance, | 1013 std::string(), true, keyword_verbatim_relevance, |
| 1029 keyword_relevance_from_server, false, keyword_input_.text()); | 1014 keyword_relevance_from_server, false, keyword_input_.text()); |
| 1030 AddMatchToMap(verbatim, keyword_input_.text(), std::string(), | 1015 AddMatchToMap(verbatim, keyword_input_, keyword_input_.text(), |
| 1031 did_not_accept_keyword_suggestion, &map); | 1016 GetTemplateURL(verbatim), std::string() /* metadata */, |
| 1017 did_not_accept_keyword_suggestion, |
| 1018 IsDefaultSearchProviderResult(verbatim), &map); |
| 1032 } | 1019 } |
| 1033 } | 1020 } |
| 1034 } | 1021 } |
| 1035 AddHistoryResultsToMap(keyword_history_results_, true, | 1022 AddHistoryResultsToMap(keyword_history_results_, true, |
| 1036 did_not_accept_keyword_suggestion, &map); | 1023 did_not_accept_keyword_suggestion, &map); |
| 1037 AddHistoryResultsToMap(default_history_results_, false, | 1024 AddHistoryResultsToMap(default_history_results_, false, |
| 1038 did_not_accept_default_suggestion, &map); | 1025 did_not_accept_default_suggestion, &map); |
| 1039 | 1026 |
| 1040 AddSuggestResultsToMap(keyword_results_.suggest_results, | 1027 AddSuggestResultsToMap(keyword_results_.suggest_results, |
| 1041 keyword_results_.metadata, &map); | 1028 keyword_results_.metadata, &map); |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 AutocompleteResult::kLowestDefaultScore) || | 1306 AutocompleteResult::kLowestDefaultScore) || |
| 1320 !HasMultipleWords(scored_results.front().suggestion())) | 1307 !HasMultipleWords(scored_results.front().suggestion())) |
| 1321 scored_results.clear(); // Didn't detect the case above, score normally. | 1308 scored_results.clear(); // Didn't detect the case above, score normally. |
| 1322 } | 1309 } |
| 1323 if (scored_results.empty()) | 1310 if (scored_results.empty()) |
| 1324 scored_results = ScoreHistoryResults(results, prevent_inline_autocomplete, | 1311 scored_results = ScoreHistoryResults(results, prevent_inline_autocomplete, |
| 1325 input_multiple_words, input_text, | 1312 input_multiple_words, input_text, |
| 1326 is_keyword); | 1313 is_keyword); |
| 1327 for (SuggestResults::const_iterator i(scored_results.begin()); | 1314 for (SuggestResults::const_iterator i(scored_results.begin()); |
| 1328 i != scored_results.end(); ++i) { | 1315 i != scored_results.end(); ++i) { |
| 1329 AddMatchToMap(*i, input_text, std::string(), | 1316 AddMatchToMap(*i, GetInput(*i), input_text, GetTemplateURL(*i), |
| 1330 did_not_accept_suggestion, map); | 1317 std::string() /* metadata */, did_not_accept_suggestion, |
| 1318 IsDefaultSearchProviderResult(*i), map); |
| 1331 } | 1319 } |
| 1332 UMA_HISTOGRAM_TIMES("Omnibox.SearchProvider.AddHistoryResultsTime", | 1320 UMA_HISTOGRAM_TIMES("Omnibox.SearchProvider.AddHistoryResultsTime", |
| 1333 base::TimeTicks::Now() - start_time); | 1321 base::TimeTicks::Now() - start_time); |
| 1334 } | 1322 } |
| 1335 | 1323 |
| 1336 SearchProvider::SuggestResults SearchProvider::ScoreHistoryResults( | 1324 SearchProvider::SuggestResults SearchProvider::ScoreHistoryResults( |
| 1337 const HistoryResults& results, | 1325 const HistoryResults& results, |
| 1338 bool base_prevent_inline_autocomplete, | 1326 bool base_prevent_inline_autocomplete, |
| 1339 bool input_multiple_words, | 1327 bool input_multiple_words, |
| 1340 const base::string16& input_text, | 1328 const base::string16& input_text, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1397 last_relevance = i->relevance(); | 1385 last_relevance = i->relevance(); |
| 1398 } | 1386 } |
| 1399 | 1387 |
| 1400 return scored_results; | 1388 return scored_results; |
| 1401 } | 1389 } |
| 1402 | 1390 |
| 1403 void SearchProvider::AddSuggestResultsToMap(const SuggestResults& results, | 1391 void SearchProvider::AddSuggestResultsToMap(const SuggestResults& results, |
| 1404 const std::string& metadata, | 1392 const std::string& metadata, |
| 1405 MatchMap* map) { | 1393 MatchMap* map) { |
| 1406 for (size_t i = 0; i < results.size(); ++i) { | 1394 for (size_t i = 0; i < results.size(); ++i) { |
| 1407 const bool is_keyword = results[i].from_keyword_provider(); | 1395 const SuggestResult& result = results[i]; |
| 1408 const base::string16& input = is_keyword ? keyword_input_.text() | 1396 const AutocompleteInput input = GetInput(result); |
| 1409 : input_.text(); | 1397 AddMatchToMap(result, input, input.text(), GetTemplateURL(result), |
| 1410 AddMatchToMap(results[i], input, metadata, i, map); | 1398 metadata, i, IsDefaultSearchProviderResult(result), map); |
| 1411 } | 1399 } |
| 1412 } | 1400 } |
| 1413 | 1401 |
| 1402 const AutocompleteInput SearchProvider::GetInput( |
| 1403 const SuggestResult& result) const { |
| 1404 return result.from_keyword_provider() ? keyword_input_ : input_; |
| 1405 } |
| 1406 |
| 1407 const TemplateURL* SearchProvider::GetTemplateURL( |
| 1408 const SuggestResult& result) const { |
| 1409 return result.from_keyword_provider() ? providers_.GetKeywordProviderURL() |
| 1410 : providers_.GetDefaultProviderURL(); |
| 1411 } |
| 1412 |
| 1413 bool SearchProvider::IsDefaultSearchProviderResult( |
| 1414 const SuggestResult& result) const { |
| 1415 return !result.from_keyword_provider() || |
| 1416 providers_.default_provider().empty(); |
| 1417 } |
| 1418 |
| 1414 int SearchProvider::GetVerbatimRelevance(bool* relevance_from_server) const { | 1419 int SearchProvider::GetVerbatimRelevance(bool* relevance_from_server) const { |
| 1415 // Use the suggested verbatim relevance score if it is non-negative (valid), | 1420 // Use the suggested verbatim relevance score if it is non-negative (valid), |
| 1416 // if inline autocomplete isn't prevented (always show verbatim on backspace), | 1421 // if inline autocomplete isn't prevented (always show verbatim on backspace), |
| 1417 // and if it won't suppress verbatim, leaving no default provider matches. | 1422 // and if it won't suppress verbatim, leaving no default provider matches. |
| 1418 // Otherwise, if the default provider returned no matches and was still able | 1423 // Otherwise, if the default provider returned no matches and was still able |
| 1419 // to suppress verbatim, the user would have no search/nav matches and may be | 1424 // to suppress verbatim, the user would have no search/nav matches and may be |
| 1420 // left unable to search using their default provider from the omnibox. | 1425 // left unable to search using their default provider from the omnibox. |
| 1421 // Check for results on each verbatim calculation, as results from older | 1426 // Check for results on each verbatim calculation, as results from older |
| 1422 // queries (on previous input) may be trimmed for failing to inline new input. | 1427 // queries (on previous input) may be trimmed for failing to inline new input. |
| 1423 bool use_server_relevance = | 1428 bool use_server_relevance = |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1512 // Don't let scores go below 0. Negative relevance scores are meaningful in | 1517 // Don't let scores go below 0. Negative relevance scores are meaningful in |
| 1513 // a different way. | 1518 // a different way. |
| 1514 int base_score; | 1519 int base_score; |
| 1515 if (is_primary_provider) | 1520 if (is_primary_provider) |
| 1516 base_score = (input_.type() == AutocompleteInput::URL) ? 750 : 1050; | 1521 base_score = (input_.type() == AutocompleteInput::URL) ? 750 : 1050; |
| 1517 else | 1522 else |
| 1518 base_score = 200; | 1523 base_score = 200; |
| 1519 return std::max(0, base_score - score_discount); | 1524 return std::max(0, base_score - score_discount); |
| 1520 } | 1525 } |
| 1521 | 1526 |
| 1522 void SearchProvider::AddMatchToMap(const SuggestResult& result, | |
| 1523 const base::string16& input_text, | |
| 1524 const std::string& metadata, | |
| 1525 int accepted_suggestion, | |
| 1526 MatchMap* map) { | |
| 1527 InstantService* instant_service = | |
| 1528 InstantServiceFactory::GetForProfile(profile_); | |
| 1529 // Android and iOS have no InstantService. | |
| 1530 const int omnibox_start_margin = instant_service ? | |
| 1531 instant_service->omnibox_start_margin() : chrome::kDisableStartMargin; | |
| 1532 | |
| 1533 const TemplateURL* template_url = result.from_keyword_provider() ? | |
| 1534 providers_.GetKeywordProviderURL() : providers_.GetDefaultProviderURL(); | |
| 1535 AutocompleteMatch match = CreateSearchSuggestion( | |
| 1536 this, input_, input_text, result, template_url, accepted_suggestion, | |
| 1537 omnibox_start_margin, | |
| 1538 !result.from_keyword_provider() || providers_.default_provider().empty()); | |
| 1539 if (!match.destination_url.is_valid()) | |
| 1540 return; | |
| 1541 match.search_terms_args->bookmark_bar_pinned = | |
| 1542 profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); | |
| 1543 match.RecordAdditionalInfo(kRelevanceFromServerKey, | |
| 1544 result.relevance_from_server() ? kTrue : kFalse); | |
| 1545 match.RecordAdditionalInfo(kShouldPrefetchKey, | |
| 1546 result.should_prefetch() ? kTrue : kFalse); | |
| 1547 | |
| 1548 if (!result.deletion_url().empty()) { | |
| 1549 GURL url(match.destination_url.GetOrigin().Resolve(result.deletion_url())); | |
| 1550 if (url.is_valid()) { | |
| 1551 match.RecordAdditionalInfo(kDeletionUrlKey, url.spec()); | |
| 1552 match.deletable = true; | |
| 1553 } | |
| 1554 } | |
| 1555 | |
| 1556 // Metadata is needed only for prefetching queries. | |
| 1557 if (result.should_prefetch()) | |
| 1558 match.RecordAdditionalInfo(kSuggestMetadataKey, metadata); | |
| 1559 | |
| 1560 // Try to add |match| to |map|. If a match for |query_string| is already in | |
| 1561 // |map|, replace it if |match| is more relevant. | |
| 1562 // NOTE: Keep this ToLower() call in sync with url_database.cc. | |
| 1563 MatchKey match_key( | |
| 1564 std::make_pair(base::i18n::ToLower(result.suggestion()), | |
| 1565 match.search_terms_args->suggest_query_params)); | |
| 1566 const std::pair<MatchMap::iterator, bool> i( | |
| 1567 map->insert(std::make_pair(match_key, match))); | |
| 1568 | |
| 1569 bool should_prefetch = result.should_prefetch(); | |
| 1570 if (!i.second) { | |
| 1571 // NOTE: We purposefully do a direct relevance comparison here instead of | |
| 1572 // using AutocompleteMatch::MoreRelevant(), so that we'll prefer "items | |
| 1573 // added first" rather than "items alphabetically first" when the scores are | |
| 1574 // equal. The only case this matters is when a user has results with the | |
| 1575 // same score that differ only by capitalization; because the history system | |
| 1576 // returns results sorted by recency, this means we'll pick the most | |
| 1577 // recent such result even if the precision of our relevance score is too | |
| 1578 // low to distinguish the two. | |
| 1579 if (match.relevance > i.first->second.relevance) { | |
| 1580 i.first->second = match; | |
| 1581 } else if (match.keyword == i.first->second.keyword) { | |
| 1582 // Old and new matches are from the same search provider. It is okay to | |
| 1583 // record one match's prefetch data onto a different match (for the same | |
| 1584 // query string) for the following reasons: | |
| 1585 // 1. Because the suggest server only sends down a query string from which | |
| 1586 // we construct a URL, rather than sending a full URL, and because we | |
| 1587 // construct URLs from query strings in the same way every time, the URLs | |
| 1588 // for the two matches will be the same. Therefore, we won't end up | |
| 1589 // prefetching something the server didn't intend. | |
| 1590 // 2. Presumably the server sets the prefetch bit on a match it things is | |
| 1591 // sufficiently relevant that the user is likely to choose it. Surely | |
| 1592 // setting the prefetch bit on a match of even higher relevance won't | |
| 1593 // violate this assumption. | |
| 1594 should_prefetch |= ShouldPrefetch(i.first->second); | |
| 1595 i.first->second.RecordAdditionalInfo(kShouldPrefetchKey, | |
| 1596 should_prefetch ? kTrue : kFalse); | |
| 1597 if (should_prefetch) | |
| 1598 i.first->second.RecordAdditionalInfo(kSuggestMetadataKey, metadata); | |
| 1599 } | |
| 1600 } | |
| 1601 } | |
| 1602 | |
| 1603 AutocompleteMatch SearchProvider::NavigationToMatch( | 1527 AutocompleteMatch SearchProvider::NavigationToMatch( |
| 1604 const NavigationResult& navigation) { | 1528 const NavigationResult& navigation) { |
| 1605 const base::string16& input = navigation.from_keyword_provider() ? | 1529 const base::string16& input = navigation.from_keyword_provider() ? |
| 1606 keyword_input_.text() : input_.text(); | 1530 keyword_input_.text() : input_.text(); |
| 1607 AutocompleteMatch match(this, navigation.relevance(), false, | 1531 AutocompleteMatch match(this, navigation.relevance(), false, |
| 1608 AutocompleteMatchType::NAVSUGGEST); | 1532 AutocompleteMatchType::NAVSUGGEST); |
| 1609 match.destination_url = navigation.url(); | 1533 match.destination_url = navigation.url(); |
| 1610 | 1534 |
| 1611 // First look for the user's input inside the formatted url as it would be | 1535 // First look for the user's input inside the formatted url as it would be |
| 1612 // without trimming the scheme, so we can find matches at the beginning of the | 1536 // without trimming the scheme, so we can find matches at the beginning of the |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1701 it->set_relevance(max_query_relevance); | 1625 it->set_relevance(max_query_relevance); |
| 1702 it->set_relevance_from_server(relevance_from_server); | 1626 it->set_relevance_from_server(relevance_from_server); |
| 1703 } | 1627 } |
| 1704 } | 1628 } |
| 1705 | 1629 |
| 1706 void SearchProvider::UpdateDone() { | 1630 void SearchProvider::UpdateDone() { |
| 1707 // We're done when the timer isn't running, there are no suggest queries | 1631 // We're done when the timer isn't running, there are no suggest queries |
| 1708 // pending, and we're not waiting on Instant. | 1632 // pending, and we're not waiting on Instant. |
| 1709 done_ = !timer_.IsRunning() && (suggest_results_pending_ == 0); | 1633 done_ = !timer_.IsRunning() && (suggest_results_pending_ == 0); |
| 1710 } | 1634 } |
| OLD | NEW |