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

Unified Diff: chrome/browser/autocomplete/search_provider.cc

Issue 171753002: Omnibox: SearchProvider: Fix Navsuggestions in Prevent-Inlining Mode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autocomplete/search_provider.cc
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index 331a498f53666329f59a7096842933c0306eec03..389938df0072ae35678a7339f33253920625131a 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -1509,8 +1509,11 @@ int SearchProvider::CalculateRelevanceForHistory(
AutocompleteMatch SearchProvider::NavigationToMatch(
const NavigationResult& navigation) {
- const base::string16& input = navigation.from_keyword_provider() ?
+ const base::string16& full_input = navigation.from_keyword_provider() ?
keyword_input_.text() : input_.text();
+ // Actual input to use when matching, discarding trailing slash if any.
Mark P 2014/02/19 00:26:19 This helps handle cases like input doodle.com/ wit
Peter Kasting 2014/02/19 20:39:32 What about e.g. matches where the "www." is only p
Mark P 2014/02/19 23:23:01 The code (below) uses BestUrlPrefix, exactly like
+ const base::string16 input = (*(full_input.rbegin()) == '/') ?
+ full_input.substr(0, full_input.length() - 1) : full_input;
AutocompleteMatch match(this, navigation.relevance(), false,
AutocompleteMatchType::NAVSUGGEST);
match.destination_url = navigation.url();
@@ -1543,16 +1546,19 @@ AutocompleteMatch SearchProvider::NavigationToMatch(
if (inline_autocomplete_offset != base::string16::npos)
++inline_autocomplete_offset;
}
- if (!input_.prevent_inline_autocomplete() &&
- (inline_autocomplete_offset != base::string16::npos)) {
+ if (inline_autocomplete_offset != base::string16::npos) {
Mark P 2014/02/19 00:26:19 The restructuring in this block allows handling si
DCHECK(inline_autocomplete_offset <= match.fill_into_edit.length());
+ match.inline_autocompletion =
+ match.fill_into_edit.substr(inline_autocomplete_offset);
// A navsuggestion can only be the default match when there is no
// keyword provider active, lest it appear first and break the user
- // out of keyword mode.
+ // out of keyword mode. It can also only be default when we're not
+ // preventing inline autocompletion (unless the inline autocompletion
+ // would be empty).
match.allowed_to_be_default_match =
- (providers_.GetKeywordProviderURL() == NULL);
- match.inline_autocompletion =
- match.fill_into_edit.substr(inline_autocomplete_offset);
+ (providers_.GetKeywordProviderURL() == NULL) &&
+ (!input_.prevent_inline_autocomplete() ||
+ match.inline_autocompletion.empty());
Peter Kasting 2014/02/19 20:39:32 Does this mean that an input of "doodle.com" won't
Mark P 2014/02/19 23:23:01 There's some subtlety here. Technically, you're ri
}
match.contents = navigation.match_contents();

Powered by Google App Engine
This is Rietveld 408576698