Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: chrome/browser/autocomplete/search_provider.cc

Issue 54203008: Store xsrf token received with psuggest results. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove match from matches_ when deletion is requested Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } 206 }
207 207
208 208
209 // SearchProvider::SuggestResult ---------------------------------------------- 209 // SearchProvider::SuggestResult ----------------------------------------------
210 210
211 SearchProvider::SuggestResult::SuggestResult( 211 SearchProvider::SuggestResult::SuggestResult(
212 const string16& suggestion, 212 const string16& suggestion,
213 const string16& match_contents, 213 const string16& match_contents,
214 const string16& annotation, 214 const string16& annotation,
215 const std::string& suggest_query_params, 215 const std::string& suggest_query_params,
216 const std::string& deletion_url,
216 bool from_keyword_provider, 217 bool from_keyword_provider,
217 int relevance, 218 int relevance,
218 bool relevance_from_server, 219 bool relevance_from_server,
219 bool should_prefetch) 220 bool should_prefetch)
220 : Result(from_keyword_provider, relevance, relevance_from_server), 221 : Result(from_keyword_provider, relevance, relevance_from_server),
221 suggestion_(suggestion), 222 suggestion_(suggestion),
222 match_contents_(match_contents), 223 match_contents_(match_contents),
223 annotation_(annotation), 224 annotation_(annotation),
224 suggest_query_params_(suggest_query_params), 225 suggest_query_params_(suggest_query_params),
226 deletion_url_(deletion_url),
225 should_prefetch_(should_prefetch) { 227 should_prefetch_(should_prefetch) {
226 } 228 }
227 229
228 SearchProvider::SuggestResult::~SuggestResult() { 230 SearchProvider::SuggestResult::~SuggestResult() {
229 } 231 }
230 232
231 bool SearchProvider::SuggestResult::IsInlineable(const string16& input) const { 233 bool SearchProvider::SuggestResult::IsInlineable(const string16& input) const {
232 return StartsWith(suggestion_, input, false); 234 return StartsWith(suggestion_, input, false);
233 } 235 }
234 236
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 for (NavigationResults::const_iterator i(navigation_results.begin()); 316 for (NavigationResults::const_iterator i(navigation_results.begin());
315 i != navigation_results.end(); ++i) { 317 i != navigation_results.end(); ++i) {
316 if (i->relevance_from_server()) 318 if (i->relevance_from_server())
317 return true; 319 return true;
318 } 320 }
319 321
320 return false; 322 return false;
321 } 323 }
322 324
323 325
326 // SearchProvider::SuggestionDeletionHandler ---------------------------------
327 SearchProvider::SuggestionDeletionHandler::SuggestionDeletionHandler() {
328 };
329
330 SearchProvider::SuggestionDeletionHandler::~SuggestionDeletionHandler() {
331 };
332
333 void SearchProvider::SuggestionDeletionHandler::StartRequest(
334 const std::string& deletion_url, Profile* profile,
335 const base::Callback<void(bool)>& callback) {
336 callback_ = callback;
337 GURL url = GURL(deletion_url);
338 if (url.is_valid()) {
339 deletion_fetcher_.reset(net::URLFetcher::Create(
340 SearchProvider::kDeletionURLFetcherID,
341 url,
342 net::URLFetcher::GET,
343 this));
344 deletion_fetcher_->SetRequestContext(profile->GetRequestContext());
345 deletion_fetcher_->Start();
346 } else {
347 callback_.Run(false);
348 }
349 };
350
351 void SearchProvider::SuggestionDeletionHandler::OnURLFetchComplete(
352 const net::URLFetcher* source) {
353 DCHECK(source == deletion_fetcher_.get());
354 const bool was_deletion_success = source->GetStatus().is_success() &&
355 source->GetResponseCode() == 200;
356 callback_.Run(was_deletion_success);
357 };
358
324 // SearchProvider ------------------------------------------------------------- 359 // SearchProvider -------------------------------------------------------------
325 360
326 // static 361 // static
327 const int SearchProvider::kDefaultProviderURLFetcherID = 1; 362 const int SearchProvider::kDefaultProviderURLFetcherID = 1;
328 const int SearchProvider::kKeywordProviderURLFetcherID = 2; 363 const int SearchProvider::kKeywordProviderURLFetcherID = 2;
364 const int SearchProvider::kDeletionURLFetcherID = 3;
329 int SearchProvider::kMinimumTimeBetweenSuggestQueriesMs = 100; 365 int SearchProvider::kMinimumTimeBetweenSuggestQueriesMs = 100;
330 const char SearchProvider::kRelevanceFromServerKey[] = "relevance_from_server"; 366 const char SearchProvider::kRelevanceFromServerKey[] = "relevance_from_server";
331 const char SearchProvider::kShouldPrefetchKey[] = "should_prefetch"; 367 const char SearchProvider::kShouldPrefetchKey[] = "should_prefetch";
332 const char SearchProvider::kSuggestMetadataKey[] = "suggest_metadata"; 368 const char SearchProvider::kSuggestMetadataKey[] = "suggest_metadata";
369 const char SearchProvider::kDeletionUrlKey[] = "deletion_url";
333 const char SearchProvider::kTrue[] = "true"; 370 const char SearchProvider::kTrue[] = "true";
334 const char SearchProvider::kFalse[] = "false"; 371 const char SearchProvider::kFalse[] = "false";
335 372
336 SearchProvider::SearchProvider(AutocompleteProviderListener* listener, 373 SearchProvider::SearchProvider(AutocompleteProviderListener* listener,
337 Profile* profile) 374 Profile* profile)
338 : AutocompleteProvider(listener, profile, 375 : AutocompleteProvider(listener, profile,
339 AutocompleteProvider::TYPE_SEARCH), 376 AutocompleteProvider::TYPE_SEARCH),
340 providers_(TemplateURLServiceFactory::GetForProfile(profile)), 377 providers_(TemplateURLServiceFactory::GetForProfile(profile)),
341 suggest_results_pending_(0), 378 suggest_results_pending_(0),
342 field_trial_triggered_(false), 379 field_trial_triggered_(false),
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 elapsed_time); 668 elapsed_time);
632 } 669 }
633 } 670 }
634 671
635 bool results_updated = false; 672 bool results_updated = false;
636 if (request_succeeded) { 673 if (request_succeeded) {
637 const net::HttpResponseHeaders* const response_headers = 674 const net::HttpResponseHeaders* const response_headers =
638 source->GetResponseHeaders(); 675 source->GetResponseHeaders();
639 std::string json_data; 676 std::string json_data;
640 source->GetResponseAsString(&json_data); 677 source->GetResponseAsString(&json_data);
678
641 // JSON is supposed to be UTF-8, but some suggest service providers send 679 // JSON is supposed to be UTF-8, but some suggest service providers send
642 // JSON files in non-UTF-8 encodings. The actual encoding is usually 680 // JSON files in non-UTF-8 encodings. The actual encoding is usually
643 // specified in the Content-Type header field. 681 // specified in the Content-Type header field.
644 if (response_headers) { 682 if (response_headers) {
645 std::string charset; 683 std::string charset;
646 if (response_headers->GetCharset(&charset)) { 684 if (response_headers->GetCharset(&charset)) {
647 string16 data_16; 685 string16 data_16;
648 // TODO(jungshik): Switch to CodePageToUTF8 after it's added. 686 // TODO(jungshik): Switch to CodePageToUTF8 after it's added.
649 if (base::CodepageToUTF16(json_data, charset.c_str(), 687 if (base::CodepageToUTF16(json_data, charset.c_str(),
650 base::OnStringConversionError::FAIL, 688 base::OnStringConversionError::FAIL,
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 results->navigation_results.push_back(NavigationResult( 1165 results->navigation_results.push_back(NavigationResult(
1128 *this, url, title, is_keyword, relevance, true)); 1166 *this, url, title, is_keyword, relevance, true));
1129 } 1167 }
1130 } else { 1168 } else {
1131 bool should_prefetch = static_cast<int>(index) == prefetch_index; 1169 bool should_prefetch = static_cast<int>(index) == prefetch_index;
1132 DictionaryValue* suggestion_detail = NULL; 1170 DictionaryValue* suggestion_detail = NULL;
1133 string16 match_contents = suggestion; 1171 string16 match_contents = suggestion;
1134 string16 disambiguating_query; 1172 string16 disambiguating_query;
1135 string16 annotation; 1173 string16 annotation;
1136 std::string suggest_query_params; 1174 std::string suggest_query_params;
1175 std::string deletion_url;
1137 if (suggestion_details && (type == "ENTITY") && 1176 if (suggestion_details && (type == "ENTITY") &&
1138 suggestion_details->GetDictionary(index, &suggestion_detail) && 1177 suggestion_details->GetDictionary(index, &suggestion_detail) &&
1139 suggestion_detail) { 1178 suggestion_detail) {
1140 suggestion_detail->GetString("a", &annotation); 1179 suggestion_detail->GetString("a", &annotation);
1141 if (suggestion_detail->GetString("dq", &disambiguating_query) && 1180 if (suggestion_detail->GetString("dq", &disambiguating_query) &&
1142 !disambiguating_query.empty()) 1181 !disambiguating_query.empty())
1143 suggestion = disambiguating_query; 1182 suggestion = disambiguating_query;
1144 suggestion_detail->GetString("q", &suggest_query_params); 1183 suggestion_detail->GetString("q", &suggest_query_params);
1184 } else if (suggestion_details && (type == "PERSONALIZED_QUERY") &&
1185 suggestion_details->GetDictionary(index, &suggestion_detail) &&
1186 suggestion_detail) {
1187 suggestion_detail->GetString("du", &deletion_url);
1145 } 1188 }
1146 // TODO(kochi): Improve calculator suggestion presentation. 1189 // TODO(kochi): Improve calculator suggestion presentation.
1147 results->suggest_results.push_back(SuggestResult( 1190 results->suggest_results.push_back(SuggestResult(
1148 suggestion, match_contents, annotation, suggest_query_params, 1191 suggestion, match_contents, annotation, suggest_query_params,
1149 is_keyword, relevance, true, should_prefetch)); 1192 deletion_url, is_keyword, relevance, true, should_prefetch));
1150 } 1193 }
1151 } 1194 }
1152 1195
1153 // Apply calculated relevance scores if a valid list was not provided. 1196 // Apply calculated relevance scores if a valid list was not provided.
1154 if (relevances == NULL) { 1197 if (relevances == NULL) {
1155 ApplyCalculatedSuggestRelevance(&results->suggest_results); 1198 ApplyCalculatedSuggestRelevance(&results->suggest_results);
1156 ApplyCalculatedNavigationRelevance(&results->navigation_results); 1199 ApplyCalculatedNavigationRelevance(&results->navigation_results);
1157 } 1200 }
1158 // Keep the result lists sorted. 1201 // Keep the result lists sorted.
1159 const CompareScoredResults comparator = CompareScoredResults(); 1202 const CompareScoredResults comparator = CompareScoredResults();
(...skipping 29 matching lines...) Expand all
1189 relevance_from_server, 1232 relevance_from_server,
1190 false, 1233 false,
1191 std::string(), 1234 std::string(),
1192 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, 1235 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED,
1193 false, 1236 false,
1194 input_.text(), 1237 input_.text(),
1195 string16(), 1238 string16(),
1196 input_.text(), 1239 input_.text(),
1197 did_not_accept_default_suggestion, 1240 did_not_accept_default_suggestion,
1198 std::string(), 1241 std::string(),
1242 std::string(),
1199 &map); 1243 &map);
1200 } 1244 }
1201 if (!keyword_input_.text().empty()) { 1245 if (!keyword_input_.text().empty()) {
1202 const TemplateURL* keyword_url = providers_.GetKeywordProviderURL(); 1246 const TemplateURL* keyword_url = providers_.GetKeywordProviderURL();
1203 // We only create the verbatim search query match for a keyword 1247 // We only create the verbatim search query match for a keyword
1204 // if it's not an extension keyword. Extension keywords are handled 1248 // if it's not an extension keyword. Extension keywords are handled
1205 // in KeywordProvider::Start(). (Extensions are complicated...) 1249 // in KeywordProvider::Start(). (Extensions are complicated...)
1206 // Note: in this provider, SEARCH_OTHER_ENGINE must correspond 1250 // Note: in this provider, SEARCH_OTHER_ENGINE must correspond
1207 // to the keyword verbatim search query. Do not create other matches 1251 // to the keyword verbatim search query. Do not create other matches
1208 // of type SEARCH_OTHER_ENGINE. 1252 // of type SEARCH_OTHER_ENGINE.
1209 if (keyword_url && 1253 if (keyword_url &&
1210 (keyword_url->GetType() != TemplateURL::OMNIBOX_API_EXTENSION)) { 1254 (keyword_url->GetType() != TemplateURL::OMNIBOX_API_EXTENSION)) {
1211 bool keyword_relevance_from_server; 1255 bool keyword_relevance_from_server;
1212 const int keyword_verbatim_relevance = 1256 const int keyword_verbatim_relevance =
1213 GetKeywordVerbatimRelevance(&keyword_relevance_from_server); 1257 GetKeywordVerbatimRelevance(&keyword_relevance_from_server);
1214 if (keyword_verbatim_relevance > 0) { 1258 if (keyword_verbatim_relevance > 0) {
1215 AddMatchToMap(keyword_input_.text(), 1259 AddMatchToMap(keyword_input_.text(),
1216 keyword_verbatim_relevance, 1260 keyword_verbatim_relevance,
1217 keyword_relevance_from_server, 1261 keyword_relevance_from_server,
1218 false, 1262 false,
1219 std::string(), 1263 std::string(),
1220 AutocompleteMatchType::SEARCH_OTHER_ENGINE, 1264 AutocompleteMatchType::SEARCH_OTHER_ENGINE,
1221 true, 1265 true,
1222 keyword_input_.text(), 1266 keyword_input_.text(),
1223 string16(), 1267 string16(),
1224 keyword_input_.text(), 1268 keyword_input_.text(),
1225 did_not_accept_keyword_suggestion, 1269 did_not_accept_keyword_suggestion,
1226 std::string(), 1270 std::string(),
1271 std::string(),
1227 &map); 1272 &map);
1228 } 1273 }
1229 } 1274 }
1230 } 1275 }
1231 AddHistoryResultsToMap(keyword_history_results_, true, 1276 AddHistoryResultsToMap(keyword_history_results_, true,
1232 did_not_accept_keyword_suggestion, &map); 1277 did_not_accept_keyword_suggestion, &map);
1233 AddHistoryResultsToMap(default_history_results_, false, 1278 AddHistoryResultsToMap(default_history_results_, false,
1234 did_not_accept_default_suggestion, &map); 1279 did_not_accept_default_suggestion, &map);
1235 1280
1236 AddSuggestResultsToMap(keyword_results_.suggest_results, 1281 AddSuggestResultsToMap(keyword_results_.suggest_results,
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 false, 1536 false,
1492 false, 1537 false,
1493 std::string(), 1538 std::string(),
1494 AutocompleteMatchType::SEARCH_HISTORY, 1539 AutocompleteMatchType::SEARCH_HISTORY,
1495 is_keyword, 1540 is_keyword,
1496 i->suggestion(), 1541 i->suggestion(),
1497 string16(), 1542 string16(),
1498 i->suggestion(), 1543 i->suggestion(),
1499 did_not_accept_suggestion, 1544 did_not_accept_suggestion,
1500 std::string(), 1545 std::string(),
1546 std::string(),
1501 map); 1547 map);
1502 } 1548 }
1503 UMA_HISTOGRAM_TIMES("Omnibox.SearchProvider.AddHistoryResultsTime", 1549 UMA_HISTOGRAM_TIMES("Omnibox.SearchProvider.AddHistoryResultsTime",
1504 base::TimeTicks::Now() - start_time); 1550 base::TimeTicks::Now() - start_time);
1505 } 1551 }
1506 1552
1507 SearchProvider::SuggestResults SearchProvider::ScoreHistoryResults( 1553 SearchProvider::SuggestResults SearchProvider::ScoreHistoryResults(
1508 const HistoryResults& results, 1554 const HistoryResults& results,
1509 bool base_prevent_inline_autocomplete, 1555 bool base_prevent_inline_autocomplete,
1510 bool input_multiple_words, 1556 bool input_multiple_words,
(...skipping 30 matching lines...) Expand all
1541 classifier->Classify(i->term, false, false, &match, NULL); 1587 classifier->Classify(i->term, false, false, &match, NULL);
1542 prevent_inline_autocomplete = 1588 prevent_inline_autocomplete =
1543 !AutocompleteMatch::IsSearchType(match.type); 1589 !AutocompleteMatch::IsSearchType(match.type);
1544 } 1590 }
1545 1591
1546 int relevance = CalculateRelevanceForHistory( 1592 int relevance = CalculateRelevanceForHistory(
1547 i->time, is_keyword, !prevent_inline_autocomplete, 1593 i->time, is_keyword, !prevent_inline_autocomplete,
1548 prevent_search_history_inlining); 1594 prevent_search_history_inlining);
1549 scored_results.push_back( 1595 scored_results.push_back(
1550 SuggestResult(i->term, string16(), string16(), std::string(), 1596 SuggestResult(i->term, string16(), string16(), std::string(),
1551 is_keyword, relevance, false, false)); 1597 std::string(), is_keyword, relevance, false, false));
1552 } 1598 }
1553 1599
1554 // History returns results sorted for us. However, we may have docked some 1600 // History returns results sorted for us. However, we may have docked some
1555 // results' scores, so things are no longer in order. Do a stable sort to get 1601 // results' scores, so things are no longer in order. Do a stable sort to get
1556 // things back in order without otherwise disturbing results with equal 1602 // things back in order without otherwise disturbing results with equal
1557 // scores, then force the scores to be unique, so that the order in which 1603 // scores, then force the scores to be unique, so that the order in which
1558 // they're shown is deterministic. 1604 // they're shown is deterministic.
1559 std::stable_sort(scored_results.begin(), scored_results.end(), 1605 std::stable_sort(scored_results.begin(), scored_results.end(),
1560 CompareScoredResults()); 1606 CompareScoredResults());
1561 int last_relevance = 0; 1607 int last_relevance = 0;
(...skipping 18 matching lines...) Expand all
1580 results[i].relevance_from_server(), 1626 results[i].relevance_from_server(),
1581 results[i].should_prefetch(), 1627 results[i].should_prefetch(),
1582 metadata, 1628 metadata,
1583 AutocompleteMatchType::SEARCH_SUGGEST, 1629 AutocompleteMatchType::SEARCH_SUGGEST,
1584 is_keyword, 1630 is_keyword,
1585 results[i].match_contents(), 1631 results[i].match_contents(),
1586 results[i].annotation(), 1632 results[i].annotation(),
1587 results[i].suggestion(), 1633 results[i].suggestion(),
1588 i, 1634 i,
1589 results[i].suggest_query_params(), 1635 results[i].suggest_query_params(),
1636 results[i].deletion_url(),
1590 map); 1637 map);
1591 } 1638 }
1592 } 1639 }
1593 1640
1594 int SearchProvider::GetVerbatimRelevance(bool* relevance_from_server) const { 1641 int SearchProvider::GetVerbatimRelevance(bool* relevance_from_server) const {
1595 // Use the suggested verbatim relevance score if it is non-negative (valid), 1642 // Use the suggested verbatim relevance score if it is non-negative (valid),
1596 // if inline autocomplete isn't prevented (always show verbatim on backspace), 1643 // if inline autocomplete isn't prevented (always show verbatim on backspace),
1597 // and if it won't suppress verbatim, leaving no default provider matches. 1644 // and if it won't suppress verbatim, leaving no default provider matches.
1598 // Otherwise, if the default provider returned no matches and was still able 1645 // Otherwise, if the default provider returned no matches and was still able
1599 // to suppress verbatim, the user would have no search/nav matches and may be 1646 // to suppress verbatim, the user would have no search/nav matches and may be
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1692 // Don't let scores go below 0. Negative relevance scores are meaningful in 1739 // Don't let scores go below 0. Negative relevance scores are meaningful in
1693 // a different way. 1740 // a different way.
1694 int base_score; 1741 int base_score;
1695 if (is_primary_provider) 1742 if (is_primary_provider)
1696 base_score = (input_.type() == AutocompleteInput::URL) ? 750 : 1050; 1743 base_score = (input_.type() == AutocompleteInput::URL) ? 750 : 1050;
1697 else 1744 else
1698 base_score = 200; 1745 base_score = 200;
1699 return std::max(0, base_score - score_discount); 1746 return std::max(0, base_score - score_discount);
1700 } 1747 }
1701 1748
1749 void SearchProvider::DeleteMatch(const AutocompleteMatch& match) {
1750 DCHECK(match.deletable);
Anuj 2013/11/21 17:27:52 This deletes only the server provided suggestions.
Maria 2013/11/21 19:38:31 Done.
1751
1752 std::string deletion_url = match.GetAdditionalInfo(
1753 SearchProvider::kDeletionUrlKey);
1754 deletion_handler_.reset(new SuggestionDeletionHandler());
1755 deletion_handler_.get()->StartRequest(deletion_url, profile_,
Anuj 2013/11/21 17:27:52 Use deletion_handler_->StartRequest. -> is pass-th
Maria 2013/11/21 19:38:31 Done.
1756 base::Bind(&SearchProvider::OnDeletionComplete, base::Unretained(this)));
1757 // Immediately updates the list of matches to show the match was deleted,
1758 // regardless of whether the server request actually succeeds.
1759 DeleteMatchFromMatches(match);
1760 }
1761
1762 void SearchProvider::OnDeletionComplete(bool success) {
1763 if (success) {
1764 UMA_HISTOGRAM_COUNTS("Omnibox.PsuggestDelete.Success", 1);
Anuj 2013/11/21 17:27:52 Not sure about mentioning this event as "PsuggestD
Maria 2013/11/21 19:38:31 Done.
1765 } else {
1766 UMA_HISTOGRAM_COUNTS("Omnibox.PsuggestDelete.Failure", 1);
1767 }
1768 deletion_handler_.reset(NULL);
Anuj 2013/11/21 17:27:52 Doesn't this create race? What if I try to delete
Maria 2013/11/21 19:38:31 I think you are right. Trying a new memory managem
1769 }
1770
1771 void SearchProvider::DeleteMatchFromMatches(const AutocompleteMatch& match) {
1772 bool found = false;
1773 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) {
1774 if (i->contents == match.contents && i->type == match.type) {
1775 found = true;
1776 matches_.erase(i);
1777 break;
1778 }
1779 }
1780 DCHECK(found) << "Asked to delete a search suggestion that isn't in our set "
1781 << "of matches";
1782 listener_->OnProviderUpdate(true);
1783 }
1784
1702 void SearchProvider::AddMatchToMap(const string16& input_text, 1785 void SearchProvider::AddMatchToMap(const string16& input_text,
1703 int relevance, 1786 int relevance,
1704 bool relevance_from_server, 1787 bool relevance_from_server,
1705 bool should_prefetch, 1788 bool should_prefetch,
1706 const std::string& metadata, 1789 const std::string& metadata,
1707 AutocompleteMatch::Type type, 1790 AutocompleteMatch::Type type,
1708 bool is_keyword, 1791 bool is_keyword,
1709 const string16& match_contents, 1792 const string16& match_contents,
1710 const string16& annotation, 1793 const string16& annotation,
1711 const string16& query_string, 1794 const string16& query_string,
1712 int accepted_suggestion, 1795 int accepted_suggestion,
1713 const std::string& suggest_query_params, 1796 const std::string& suggest_query_params,
1797 const std::string& deletion_url,
1714 MatchMap* map) { 1798 MatchMap* map) {
1715 // On non-mobile, ask the instant controller for the appropriate start margin. 1799 // On non-mobile, ask the instant controller for the appropriate start margin.
1716 // On mobile the start margin is unused, so leave the value as default there. 1800 // On mobile the start margin is unused, so leave the value as default there.
1717 int omnibox_start_margin = chrome::kDisableStartMargin; 1801 int omnibox_start_margin = chrome::kDisableStartMargin;
1718 #if !defined(OS_ANDROID) && !defined(IOS) 1802 #if !defined(OS_ANDROID) && !defined(IOS)
1719 if (chrome::IsInstantExtendedAPIEnabled()) { 1803 if (chrome::IsInstantExtendedAPIEnabled()) {
1720 Browser* browser = 1804 Browser* browser =
1721 chrome::FindBrowserWithProfile(profile_, chrome::GetActiveDesktop()); 1805 chrome::FindBrowserWithProfile(profile_, chrome::GetActiveDesktop());
1722 if (browser && browser->instant_controller() && 1806 if (browser && browser->instant_controller() &&
1723 browser->instant_controller()->instant()) { 1807 browser->instant_controller()->instant()) {
(...skipping 12 matching lines...) Expand all
1736 !is_keyword || providers_.default_provider().empty()); 1820 !is_keyword || providers_.default_provider().empty());
1737 if (!match.destination_url.is_valid()) 1821 if (!match.destination_url.is_valid())
1738 return; 1822 return;
1739 match.search_terms_args->bookmark_bar_pinned = 1823 match.search_terms_args->bookmark_bar_pinned =
1740 profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); 1824 profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar);
1741 match.RecordAdditionalInfo(kRelevanceFromServerKey, 1825 match.RecordAdditionalInfo(kRelevanceFromServerKey,
1742 relevance_from_server ? kTrue : kFalse); 1826 relevance_from_server ? kTrue : kFalse);
1743 match.RecordAdditionalInfo(kShouldPrefetchKey, 1827 match.RecordAdditionalInfo(kShouldPrefetchKey,
1744 should_prefetch ? kTrue : kFalse); 1828 should_prefetch ? kTrue : kFalse);
1745 1829
1830 if (!deletion_url.empty()) {
1831 match.RecordAdditionalInfo(kDeletionUrlKey, deletion_url);
1832 match.deletable = true;
Anuj 2013/11/21 17:27:52 Add a TODO about marking search-history suggestion
Maria 2013/11/21 19:38:31 I think when we implement it, we would have to do
1833 }
1834
1746 // Metadata is needed only for prefetching queries. 1835 // Metadata is needed only for prefetching queries.
1747 if (should_prefetch) 1836 if (should_prefetch)
1748 match.RecordAdditionalInfo(kSuggestMetadataKey, metadata); 1837 match.RecordAdditionalInfo(kSuggestMetadataKey, metadata);
1749 1838
1750 // Try to add |match| to |map|. If a match for |query_string| is already in 1839 // Try to add |match| to |map|. If a match for |query_string| is already in
1751 // |map|, replace it if |match| is more relevant. 1840 // |map|, replace it if |match| is more relevant.
1752 // NOTE: Keep this ToLower() call in sync with url_database.cc. 1841 // NOTE: Keep this ToLower() call in sync with url_database.cc.
1753 MatchKey match_key( 1842 MatchKey match_key(
1754 std::make_pair(base::i18n::ToLower(query_string), 1843 std::make_pair(base::i18n::ToLower(query_string),
1755 match.search_terms_args->suggest_query_params)); 1844 match.search_terms_args->suggest_query_params));
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 it->set_relevance(max_query_relevance); 1986 it->set_relevance(max_query_relevance);
1898 it->set_relevance_from_server(relevance_from_server); 1987 it->set_relevance_from_server(relevance_from_server);
1899 } 1988 }
1900 } 1989 }
1901 1990
1902 void SearchProvider::UpdateDone() { 1991 void SearchProvider::UpdateDone() {
1903 // We're done when the timer isn't running, there are no suggest queries 1992 // We're done when the timer isn't running, there are no suggest queries
1904 // pending, and we're not waiting on Instant. 1993 // pending, and we're not waiting on Instant.
1905 done_ = !timer_.IsRunning() && (suggest_results_pending_ == 0); 1994 done_ = !timer_.IsRunning() && (suggest_results_pending_ == 0);
1906 } 1995 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698