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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 | 469 |
486 scoped_ptr<base::Value> data(DeserializeJsonData(json_data)); | 470 scoped_ptr<base::Value> data(DeserializeJsonData(json_data)); |
487 results_updated = data.get() && ParseSuggestResults(data.get(), is_keyword); | 471 results_updated = data.get() && ParseSuggestResults(data.get(), is_keyword); |
488 } | 472 } |
489 | 473 |
490 UpdateMatches(); | 474 UpdateMatches(); |
491 if (done_ || results_updated) | 475 if (done_ || results_updated) |
492 listener_->OnProviderUpdate(results_updated); | 476 listener_->OnProviderUpdate(results_updated); |
493 } | 477 } |
494 | 478 |
| 479 const TemplateURL* SearchProvider::GetTemplateURL( |
| 480 const SuggestResult& result) const { |
| 481 return result.from_keyword_provider() ? providers_.GetKeywordProviderURL() |
| 482 : providers_.GetDefaultProviderURL(); |
| 483 } |
| 484 |
| 485 const AutocompleteInput SearchProvider::GetInput( |
| 486 const SuggestResult& result) const { |
| 487 return result.from_keyword_provider() ? keyword_input_ : input_; |
| 488 } |
| 489 |
| 490 bool SearchProvider::ShouldAppendExtraParams( |
| 491 const SuggestResult& result) const { |
| 492 return !result.from_keyword_provider() || |
| 493 providers_.default_provider().empty(); |
| 494 } |
| 495 |
495 void SearchProvider::OnDeletionComplete(bool success, | 496 void SearchProvider::OnDeletionComplete(bool success, |
496 SuggestionDeletionHandler* handler) { | 497 SuggestionDeletionHandler* handler) { |
497 RecordDeletionResult(success); | 498 RecordDeletionResult(success); |
498 SuggestionDeletionHandlers::iterator it = std::find( | 499 SuggestionDeletionHandlers::iterator it = std::find( |
499 deletion_handlers_.begin(), deletion_handlers_.end(), handler); | 500 deletion_handlers_.begin(), deletion_handlers_.end(), handler); |
500 DCHECK(it != deletion_handlers_.end()); | 501 DCHECK(it != deletion_handlers_.end()); |
501 deletion_handlers_.erase(it); | 502 deletion_handlers_.erase(it); |
502 } | 503 } |
503 | 504 |
504 | 505 |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 int verbatim_relevance = GetVerbatimRelevance(&relevance_from_server); | 999 int verbatim_relevance = GetVerbatimRelevance(&relevance_from_server); |
999 int did_not_accept_default_suggestion = | 1000 int did_not_accept_default_suggestion = |
1000 default_results_.suggest_results.empty() ? | 1001 default_results_.suggest_results.empty() ? |
1001 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE : | 1002 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE : |
1002 TemplateURLRef::NO_SUGGESTION_CHOSEN; | 1003 TemplateURLRef::NO_SUGGESTION_CHOSEN; |
1003 if (verbatim_relevance > 0) { | 1004 if (verbatim_relevance > 0) { |
1004 SuggestResult verbatim( | 1005 SuggestResult verbatim( |
1005 input_.text(), AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, | 1006 input_.text(), AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
1006 input_.text(), base::string16(), std::string(), std::string(), false, | 1007 input_.text(), base::string16(), std::string(), std::string(), false, |
1007 verbatim_relevance, relevance_from_server, false, input_.text()); | 1008 verbatim_relevance, relevance_from_server, false, input_.text()); |
1008 AddMatchToMap(verbatim, input_.text(), std::string(), | 1009 AddMatchToMap( |
1009 did_not_accept_default_suggestion, &map); | 1010 verbatim, std::string(), did_not_accept_default_suggestion, &map); |
1010 } | 1011 } |
1011 if (!keyword_input_.text().empty()) { | 1012 if (!keyword_input_.text().empty()) { |
1012 const TemplateURL* keyword_url = providers_.GetKeywordProviderURL(); | 1013 const TemplateURL* keyword_url = providers_.GetKeywordProviderURL(); |
1013 // We only create the verbatim search query match for a keyword | 1014 // We only create the verbatim search query match for a keyword |
1014 // if it's not an extension keyword. Extension keywords are handled | 1015 // if it's not an extension keyword. Extension keywords are handled |
1015 // in KeywordProvider::Start(). (Extensions are complicated...) | 1016 // in KeywordProvider::Start(). (Extensions are complicated...) |
1016 // Note: in this provider, SEARCH_OTHER_ENGINE must correspond | 1017 // Note: in this provider, SEARCH_OTHER_ENGINE must correspond |
1017 // to the keyword verbatim search query. Do not create other matches | 1018 // to the keyword verbatim search query. Do not create other matches |
1018 // of type SEARCH_OTHER_ENGINE. | 1019 // of type SEARCH_OTHER_ENGINE. |
1019 if (keyword_url && | 1020 if (keyword_url && |
1020 (keyword_url->GetType() != TemplateURL::OMNIBOX_API_EXTENSION)) { | 1021 (keyword_url->GetType() != TemplateURL::OMNIBOX_API_EXTENSION)) { |
1021 bool keyword_relevance_from_server; | 1022 bool keyword_relevance_from_server; |
1022 const int keyword_verbatim_relevance = | 1023 const int keyword_verbatim_relevance = |
1023 GetKeywordVerbatimRelevance(&keyword_relevance_from_server); | 1024 GetKeywordVerbatimRelevance(&keyword_relevance_from_server); |
1024 if (keyword_verbatim_relevance > 0) { | 1025 if (keyword_verbatim_relevance > 0) { |
1025 SuggestResult verbatim( | 1026 SuggestResult verbatim( |
1026 keyword_input_.text(), AutocompleteMatchType::SEARCH_OTHER_ENGINE, | 1027 keyword_input_.text(), AutocompleteMatchType::SEARCH_OTHER_ENGINE, |
1027 keyword_input_.text(), base::string16(), std::string(), | 1028 keyword_input_.text(), base::string16(), std::string(), |
1028 std::string(), true, keyword_verbatim_relevance, | 1029 std::string(), true, keyword_verbatim_relevance, |
1029 keyword_relevance_from_server, false, keyword_input_.text()); | 1030 keyword_relevance_from_server, false, keyword_input_.text()); |
1030 AddMatchToMap(verbatim, keyword_input_.text(), std::string(), | 1031 AddMatchToMap( |
1031 did_not_accept_keyword_suggestion, &map); | 1032 verbatim, std::string(), did_not_accept_keyword_suggestion, &map); |
1032 } | 1033 } |
1033 } | 1034 } |
1034 } | 1035 } |
1035 AddHistoryResultsToMap(keyword_history_results_, true, | 1036 AddHistoryResultsToMap(keyword_history_results_, true, |
1036 did_not_accept_keyword_suggestion, &map); | 1037 did_not_accept_keyword_suggestion, &map); |
1037 AddHistoryResultsToMap(default_history_results_, false, | 1038 AddHistoryResultsToMap(default_history_results_, false, |
1038 did_not_accept_default_suggestion, &map); | 1039 did_not_accept_default_suggestion, &map); |
1039 | 1040 |
1040 AddSuggestResultsToMap(keyword_results_.suggest_results, | 1041 AddSuggestResultsToMap(keyword_results_.suggest_results, |
1041 keyword_results_.metadata, &map); | 1042 keyword_results_.metadata, &map); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 AutocompleteResult::kLowestDefaultScore) || | 1320 AutocompleteResult::kLowestDefaultScore) || |
1320 !HasMultipleWords(scored_results.front().suggestion())) | 1321 !HasMultipleWords(scored_results.front().suggestion())) |
1321 scored_results.clear(); // Didn't detect the case above, score normally. | 1322 scored_results.clear(); // Didn't detect the case above, score normally. |
1322 } | 1323 } |
1323 if (scored_results.empty()) | 1324 if (scored_results.empty()) |
1324 scored_results = ScoreHistoryResults(results, prevent_inline_autocomplete, | 1325 scored_results = ScoreHistoryResults(results, prevent_inline_autocomplete, |
1325 input_multiple_words, input_text, | 1326 input_multiple_words, input_text, |
1326 is_keyword); | 1327 is_keyword); |
1327 for (SuggestResults::const_iterator i(scored_results.begin()); | 1328 for (SuggestResults::const_iterator i(scored_results.begin()); |
1328 i != scored_results.end(); ++i) { | 1329 i != scored_results.end(); ++i) { |
1329 AddMatchToMap(*i, input_text, std::string(), | 1330 AddMatchToMap(*i, std::string(), did_not_accept_suggestion, map); |
1330 did_not_accept_suggestion, map); | |
1331 } | 1331 } |
1332 UMA_HISTOGRAM_TIMES("Omnibox.SearchProvider.AddHistoryResultsTime", | 1332 UMA_HISTOGRAM_TIMES("Omnibox.SearchProvider.AddHistoryResultsTime", |
1333 base::TimeTicks::Now() - start_time); | 1333 base::TimeTicks::Now() - start_time); |
1334 } | 1334 } |
1335 | 1335 |
1336 SearchProvider::SuggestResults SearchProvider::ScoreHistoryResults( | 1336 SearchProvider::SuggestResults SearchProvider::ScoreHistoryResults( |
1337 const HistoryResults& results, | 1337 const HistoryResults& results, |
1338 bool base_prevent_inline_autocomplete, | 1338 bool base_prevent_inline_autocomplete, |
1339 bool input_multiple_words, | 1339 bool input_multiple_words, |
1340 const base::string16& input_text, | 1340 const base::string16& input_text, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1396 i->set_relevance(last_relevance - 1); | 1396 i->set_relevance(last_relevance - 1); |
1397 last_relevance = i->relevance(); | 1397 last_relevance = i->relevance(); |
1398 } | 1398 } |
1399 | 1399 |
1400 return scored_results; | 1400 return scored_results; |
1401 } | 1401 } |
1402 | 1402 |
1403 void SearchProvider::AddSuggestResultsToMap(const SuggestResults& results, | 1403 void SearchProvider::AddSuggestResultsToMap(const SuggestResults& results, |
1404 const std::string& metadata, | 1404 const std::string& metadata, |
1405 MatchMap* map) { | 1405 MatchMap* map) { |
1406 for (size_t i = 0; i < results.size(); ++i) { | 1406 for (size_t i = 0; i < results.size(); ++i) |
1407 const bool is_keyword = results[i].from_keyword_provider(); | 1407 AddMatchToMap(results[i], metadata, i, map); |
1408 const base::string16& input = is_keyword ? keyword_input_.text() | |
1409 : input_.text(); | |
1410 AddMatchToMap(results[i], input, metadata, i, map); | |
1411 } | |
1412 } | 1408 } |
1413 | 1409 |
1414 int SearchProvider::GetVerbatimRelevance(bool* relevance_from_server) const { | 1410 int SearchProvider::GetVerbatimRelevance(bool* relevance_from_server) const { |
1415 // Use the suggested verbatim relevance score if it is non-negative (valid), | 1411 // Use the suggested verbatim relevance score if it is non-negative (valid), |
1416 // if inline autocomplete isn't prevented (always show verbatim on backspace), | 1412 // if inline autocomplete isn't prevented (always show verbatim on backspace), |
1417 // and if it won't suppress verbatim, leaving no default provider matches. | 1413 // 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 | 1414 // 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 | 1415 // 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. | 1416 // left unable to search using their default provider from the omnibox. |
1421 // Check for results on each verbatim calculation, as results from older | 1417 // Check for results on each verbatim calculation, as results from older |
(...skipping 90 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 | 1508 // Don't let scores go below 0. Negative relevance scores are meaningful in |
1513 // a different way. | 1509 // a different way. |
1514 int base_score; | 1510 int base_score; |
1515 if (is_primary_provider) | 1511 if (is_primary_provider) |
1516 base_score = (input_.type() == AutocompleteInput::URL) ? 750 : 1050; | 1512 base_score = (input_.type() == AutocompleteInput::URL) ? 750 : 1050; |
1517 else | 1513 else |
1518 base_score = 200; | 1514 base_score = 200; |
1519 return std::max(0, base_score - score_discount); | 1515 return std::max(0, base_score - score_discount); |
1520 } | 1516 } |
1521 | 1517 |
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( | 1518 AutocompleteMatch SearchProvider::NavigationToMatch( |
1604 const NavigationResult& navigation) { | 1519 const NavigationResult& navigation) { |
1605 const base::string16& input = navigation.from_keyword_provider() ? | 1520 const base::string16& input = navigation.from_keyword_provider() ? |
1606 keyword_input_.text() : input_.text(); | 1521 keyword_input_.text() : input_.text(); |
1607 AutocompleteMatch match(this, navigation.relevance(), false, | 1522 AutocompleteMatch match(this, navigation.relevance(), false, |
1608 AutocompleteMatchType::NAVSUGGEST); | 1523 AutocompleteMatchType::NAVSUGGEST); |
1609 match.destination_url = navigation.url(); | 1524 match.destination_url = navigation.url(); |
1610 | 1525 |
1611 // First look for the user's input inside the formatted url as it would be | 1526 // 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 | 1527 // 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); | 1616 it->set_relevance(max_query_relevance); |
1702 it->set_relevance_from_server(relevance_from_server); | 1617 it->set_relevance_from_server(relevance_from_server); |
1703 } | 1618 } |
1704 } | 1619 } |
1705 | 1620 |
1706 void SearchProvider::UpdateDone() { | 1621 void SearchProvider::UpdateDone() { |
1707 // We're done when the timer isn't running, there are no suggest queries | 1622 // We're done when the timer isn't running, there are no suggest queries |
1708 // pending, and we're not waiting on Instant. | 1623 // pending, and we're not waiting on Instant. |
1709 done_ = !timer_.IsRunning() && (suggest_results_pending_ == 0); | 1624 done_ = !timer_.IsRunning() && (suggest_results_pending_ == 0); |
1710 } | 1625 } |
OLD | NEW |