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

Side by Side Diff: components/omnibox/browser/search_provider.cc

Issue 1841653003: Drop |languages| from {Format,Elide}Url* and IDNToUnicode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo in elide_url.cc Created 4 years, 8 months 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
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 "components/omnibox/browser/search_provider.h" 5 #include "components/omnibox/browser/search_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <cmath> 9 #include <cmath>
10 #include <utility> 10 #include <utility>
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 } 439 }
440 440
441 void SearchProvider::UpdateMatchContentsClass( 441 void SearchProvider::UpdateMatchContentsClass(
442 const base::string16& input_text, 442 const base::string16& input_text,
443 SearchSuggestionParser::Results* results) { 443 SearchSuggestionParser::Results* results) {
444 for (SearchSuggestionParser::SuggestResults::iterator sug_it = 444 for (SearchSuggestionParser::SuggestResults::iterator sug_it =
445 results->suggest_results.begin(); 445 results->suggest_results.begin();
446 sug_it != results->suggest_results.end(); ++sug_it) { 446 sug_it != results->suggest_results.end(); ++sug_it) {
447 sug_it->ClassifyMatchContents(false, input_text); 447 sug_it->ClassifyMatchContents(false, input_text);
448 } 448 }
449 const std::string languages(client()->GetAcceptLanguages());
450 for (SearchSuggestionParser::NavigationResults::iterator nav_it = 449 for (SearchSuggestionParser::NavigationResults::iterator nav_it =
451 results->navigation_results.begin(); 450 results->navigation_results.begin();
452 nav_it != results->navigation_results.end(); ++nav_it) { 451 nav_it != results->navigation_results.end(); ++nav_it) {
453 nav_it->CalculateAndClassifyMatchContents(false, input_text, languages); 452 nav_it->CalculateAndClassifyMatchContents(false, input_text);
454 } 453 }
455 } 454 }
456 455
457 void SearchProvider::SortResults(bool is_keyword, 456 void SearchProvider::SortResults(bool is_keyword,
458 SearchSuggestionParser::Results* results) { 457 SearchSuggestionParser::Results* results) {
459 // Ignore suggested scores for non-keyword matches in keyword mode; if the 458 // Ignore suggested scores for non-keyword matches in keyword mode; if the
460 // server is allowed to score these, it could interfere with the user's 459 // server is allowed to score these, it could interfere with the user's
461 // ability to get good keyword results. 460 // ability to get good keyword results.
462 const bool abandon_suggested_scores = 461 const bool abandon_suggested_scores =
463 !is_keyword && !providers_.keyword_provider().empty(); 462 !is_keyword && !providers_.keyword_provider().empty();
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 const URLPrefix* prefix = 1409 const URLPrefix* prefix =
1411 URLPrefix::BestURLPrefix(navigation.formatted_url(), input); 1410 URLPrefix::BestURLPrefix(navigation.formatted_url(), input);
1412 size_t match_start = (prefix == NULL) ? 1411 size_t match_start = (prefix == NULL) ?
1413 navigation.formatted_url().find(input) : prefix->prefix.length(); 1412 navigation.formatted_url().find(input) : prefix->prefix.length();
1414 bool trim_http = !AutocompleteInput::HasHTTPScheme(input) && 1413 bool trim_http = !AutocompleteInput::HasHTTPScheme(input) &&
1415 (!prefix || (match_start != 0)); 1414 (!prefix || (match_start != 0));
1416 const url_formatter::FormatUrlTypes format_types = 1415 const url_formatter::FormatUrlTypes format_types =
1417 url_formatter::kFormatUrlOmitAll & 1416 url_formatter::kFormatUrlOmitAll &
1418 ~(trim_http ? 0 : url_formatter::kFormatUrlOmitHTTP); 1417 ~(trim_http ? 0 : url_formatter::kFormatUrlOmitHTTP);
1419 1418
1420 const std::string languages(client()->GetAcceptLanguages());
1421 size_t inline_autocomplete_offset = (prefix == NULL) ? 1419 size_t inline_autocomplete_offset = (prefix == NULL) ?
1422 base::string16::npos : (match_start + input.length()); 1420 base::string16::npos : (match_start + input.length());
1423 match.fill_into_edit += 1421 match.fill_into_edit +=
1424 AutocompleteInput::FormattedStringWithEquivalentMeaning( 1422 AutocompleteInput::FormattedStringWithEquivalentMeaning(
1425 navigation.url(), 1423 navigation.url(),
1426 url_formatter::FormatUrl(navigation.url(), languages, format_types, 1424 url_formatter::FormatUrl(navigation.url(), format_types,
1427 net::UnescapeRule::SPACES, nullptr, nullptr, 1425 net::UnescapeRule::SPACES, nullptr, nullptr,
1428 &inline_autocomplete_offset), 1426 &inline_autocomplete_offset),
1429 client()->GetSchemeClassifier()); 1427 client()->GetSchemeClassifier());
1430 // Preserve the forced query '?' prefix in |match.fill_into_edit|. 1428 // Preserve the forced query '?' prefix in |match.fill_into_edit|.
1431 // Otherwise, user edits to a suggestion would show non-Search results. 1429 // Otherwise, user edits to a suggestion would show non-Search results.
1432 if (input_.type() == metrics::OmniboxInputType::FORCED_QUERY) { 1430 if (input_.type() == metrics::OmniboxInputType::FORCED_QUERY) {
1433 match.fill_into_edit.insert(0, base::ASCIIToUTF16("?")); 1431 match.fill_into_edit.insert(0, base::ASCIIToUTF16("?"));
1434 if (inline_autocomplete_offset != base::string16::npos) 1432 if (inline_autocomplete_offset != base::string16::npos)
1435 ++inline_autocomplete_offset; 1433 ++inline_autocomplete_offset;
1436 } 1434 }
(...skipping 11 matching lines...) Expand all
1448 // Finally, if we have an inlineable navsuggestion with an inline completion 1446 // Finally, if we have an inlineable navsuggestion with an inline completion
1449 // that we're not preventing, make sure we didn't trim any whitespace. 1447 // that we're not preventing, make sure we didn't trim any whitespace.
1450 // We don't want to claim http://foo.com/bar is inlineable against the 1448 // We don't want to claim http://foo.com/bar is inlineable against the
1451 // input "foo.com/b ". 1449 // input "foo.com/b ".
1452 match.allowed_to_be_default_match = 1450 match.allowed_to_be_default_match =
1453 (prefix != NULL) && 1451 (prefix != NULL) &&
1454 (providers_.GetKeywordProviderURL() == NULL) && 1452 (providers_.GetKeywordProviderURL() == NULL) &&
1455 !navigation.received_after_last_keystroke() && 1453 !navigation.received_after_last_keystroke() &&
1456 (match.inline_autocompletion.empty() || 1454 (match.inline_autocompletion.empty() ||
1457 (!input_.prevent_inline_autocomplete() && !trimmed_whitespace)); 1455 (!input_.prevent_inline_autocomplete() && !trimmed_whitespace));
1458 match.EnsureUWYTIsAllowedToBeDefault(input_, client()->GetAcceptLanguages(), 1456 match.EnsureUWYTIsAllowedToBeDefault(input_,
1459 client()->GetTemplateURLService()); 1457 client()->GetTemplateURLService());
1460 1458
1461 match.contents = navigation.match_contents(); 1459 match.contents = navigation.match_contents();
1462 match.contents_class = navigation.match_contents_class(); 1460 match.contents_class = navigation.match_contents_class();
1463 match.description = navigation.description(); 1461 match.description = navigation.description();
1464 AutocompleteMatch::ClassifyMatchInString(input, match.description, 1462 AutocompleteMatch::ClassifyMatchInString(input, match.description,
1465 ACMatchClassification::NONE, &match.description_class); 1463 ACMatchClassification::NONE, &match.description_class);
1466 1464
1467 match.RecordAdditionalInfo( 1465 match.RecordAdditionalInfo(
1468 kRelevanceFromServerKey, 1466 kRelevanceFromServerKey,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1512 for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i) 1510 for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i)
1513 matches.push_back(i->second); 1511 matches.push_back(i->second);
1514 std::sort(matches.begin(), matches.end(), &AutocompleteMatch::MoreRelevant); 1512 std::sort(matches.begin(), matches.end(), &AutocompleteMatch::MoreRelevant);
1515 1513
1516 // If there is a top scoring entry, find the corresponding answer. 1514 // If there is a top scoring entry, find the corresponding answer.
1517 if (!matches.empty()) 1515 if (!matches.empty())
1518 return answers_cache_.GetTopAnswerEntry(matches[0].contents); 1516 return answers_cache_.GetTopAnswerEntry(matches[0].contents);
1519 1517
1520 return AnswersQueryData(); 1518 return AnswersQueryData();
1521 } 1519 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/scored_history_match_unittest.cc ('k') | components/omnibox/browser/search_suggestion_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698