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

Unified Diff: chrome/browser/autocomplete/extension_app_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/extension_app_provider.cc
===================================================================
--- chrome/browser/autocomplete/extension_app_provider.cc (revision 107110)
+++ chrome/browser/autocomplete/extension_app_provider.cc (working copy)
@@ -29,6 +29,40 @@
extension_apps_.push_back(std::make_pair(app_name, url));
}
+AutocompleteMatch ExtensionAppProvider::CreateAutocompleteMatch(
+ const AutocompleteInput& input,
Peter Kasting 2011/10/26 01:07:22 Nit: Indent all these 4.
+ const string16& name,
+ const string16& url,
+ size_t name_match_index,
+ size_t url_match_index) {
+ // We have a match, might be a partial match.
Peter Kasting 2011/10/26 01:07:22 Nit: This comment belongs in the caller.
+ // TODO(finnur): Figure out what type to return here, might want to have
+ // the extension icon/a generic icon show up in the Omnibox.
+ AutocompleteMatch match(this, 0, false,
+ AutocompleteMatch::EXTENSION_APP);
+ match.fill_into_edit = url;
+ match.destination_url = GURL(url);
+ match.inline_autocomplete_offset = string16::npos;
+ match.contents = AutocompleteMatch::SanitizeString(name);
+ AutocompleteMatch::ClassifyLocationInString(name_match_index,
+ input.text().length(),
+ name.length(),
+ ACMatchClassification::NONE,
+ &match.contents_class);
+ match.description = url;
+ AutocompleteMatch::ClassifyLocationInString(url_match_index,
+ input.text().length(),
+ url.length(),
+ ACMatchClassification::URL,
+ &match.description_class);
+ match.relevance = CalculateRelevance(input.type(),
+ input.text().length(),
+ name_match_index != string16::npos ?
+ name.length() : url.length(),
+ match.destination_url);
+ return match;
+}
+
void ExtensionAppProvider::Start(const AutocompleteInput& input,
bool minimal_changes) {
matches_.clear();
@@ -53,28 +87,13 @@
input.type() != AutocompleteInput::FORCED_QUERY;
if (matches_name || matches_url) {
- // We have a match, might be a partial match.
- // TODO(finnur): Figure out what type to return here, might want to have
- // the extension icon/a generic icon show up in the Omnibox.
- AutocompleteMatch match(this, 0, false,
- AutocompleteMatch::EXTENSION_APP);
- match.fill_into_edit = url;
- match.destination_url = GURL(url);
- match.inline_autocomplete_offset = string16::npos;
- match.contents = name;
- AutocompleteMatch::ClassifyLocationInString(matches_name ?
- static_cast<size_t>(name_iter - name.begin()) : string16::npos,
- input.text().length(), name.length(), ACMatchClassification::NONE,
- &match.contents_class);
- match.description = url;
- AutocompleteMatch::ClassifyLocationInString(matches_url ?
- static_cast<size_t>(url_iter - url.begin()) : string16::npos,
- input.text().length(), url.length(), ACMatchClassification::URL,
- &match.description_class);
- match.relevance = CalculateRelevance(input.type(),
- input.text().length(), matches_name ? name.length() : url.length(),
- match.destination_url);
- matches_.push_back(match);
+ size_t name_match_index = matches_name ?
+ static_cast<size_t>(name_iter - name.begin()) : string16::npos;
+ size_t url_match_index = matches_url ?
+ static_cast<size_t>(url_iter - url.begin()) : string16::npos;
+ matches_.push_back(
+ CreateAutocompleteMatch(input, name, url, name_match_index,
+ url_match_index));
}
}
}

Powered by Google App Engine
This is Rietveld 408576698