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

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

Issue 8364001: Strip special characters in extension omnibox suggestions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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/keyword_provider.cc
===================================================================
--- chrome/browser/autocomplete/keyword_provider.cc (revision 107110)
+++ chrome/browser/autocomplete/keyword_provider.cc (working copy)
@@ -440,6 +440,22 @@
return result;
}
+AutocompleteMatch KeywordProvider::CreateAutocompleteMatchFromSuggestion(
+ TemplateURLService* model,
+ const string16& keyword,
+ const AutocompleteInput& input,
+ const ExtensionOmniboxSuggestion& suggestion,
+ int relevance) {
+ AutocompleteMatch match = CreateAutocompleteMatch(
+ model, keyword, input, keyword.length(),
+ suggestion.content, relevance);
+ match.contents = AutocompleteMatch::SanitizeString(suggestion.description);
+ match.contents_class = suggestion.description_styles;
+ match.description.clear();
+ match.description_class.clear();
+ return match;
+}
+
void KeywordProvider::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
@@ -488,8 +504,6 @@
// TODO(mpcomplete): consider clamping the number of suggestions to
// AutocompleteProvider::kMaxMatches.
for (size_t i = 0; i < suggestions.suggestions.size(); ++i) {
- const ExtensionOmniboxSuggestion& suggestion =
- suggestions.suggestions[i];
// We want to order these suggestions in descending order, so start with
// the relevance of the first result (added synchronously in Start()),
// and subtract 1 for each subsequent suggestion from the extension.
@@ -497,15 +511,13 @@
// the extension unless the full keyword had been typed.
int first_relevance = CalculateRelevance(input.type(), true, true,
input.prefer_keyword(), input.allow_exact_keyword_match());
- extension_suggest_matches_.push_back(CreateAutocompleteMatch(
- model, keyword, input, keyword.length(),
- suggestion.content, first_relevance - (i + 1)));
-
- AutocompleteMatch* match = &extension_suggest_matches_.back();
- match->contents.assign(suggestion.description);
- match->contents_class = suggestion.description_styles;
- match->description.clear();
- match->description_class.clear();
+ int relevance = first_relevance - (i + 1);
+ extension_suggest_matches_.push_back(
+ CreateAutocompleteMatchFromSuggestion(model,
+ keyword,
+ input,
+ suggestions.suggestions[i],
+ relevance));
}
done_ = true;

Powered by Google App Engine
This is Rietveld 408576698