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

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

Issue 108643003: Omnibox: Bug Fixes for Shortcuts Inlining (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove comment Created 7 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/shortcuts_provider.cc
diff --git a/chrome/browser/autocomplete/shortcuts_provider.cc b/chrome/browser/autocomplete/shortcuts_provider.cc
index b476f0fe2c96ea2d15624c8d0921df9148d94fee..b467d583b1d48f79ec4365cd96d9b45685576620 100644
--- a/chrome/browser/autocomplete/shortcuts_provider.cc
+++ b/chrome/browser/autocomplete/shortcuts_provider.cc
@@ -28,6 +28,7 @@
#include "chrome/browser/history/shortcuts_backend_factory.h"
#include "chrome/browser/omnibox/omnibox_field_trial.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/net/url_fixer_upper.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "url/url_parse.h"
@@ -228,6 +229,32 @@ AutocompleteMatch ShortcutsProvider::ShortcutToACMatch(
best_prefix->prefix.length() + term_string.length());
match.allowed_to_be_default_match =
!prevent_inline_autocomplete || match.inline_autocompletion.empty();
+ } else {
+ // Special case to allow URL-like inputs that need to be fixed up to
+ // inline against URL shortcuts. This is especially userful to get
Peter Kasting 2013/12/17 19:56:49 Nit: userful -> useful
Mark P 2013/12/17 20:36:18 Done.
+ // about: URLs to inline against chrome:// shortcuts. (about: URLs
+ // are fixed up to the chrome:// scheme.)
Peter Kasting 2013/12/17 19:56:49 What about if the fill_into_edit is about:foo and
Mark P 2013/12/17 20:36:18 This will not happen. There's no way to select a
+ GURL url =
+ URLFixerUpper::FixupURL(UTF16ToUTF8(term_string), std::string());
+ if (url.is_valid()) {
Mark P 2013/12/17 19:29:02 Alternatively, do I want to skip is_valid() and si
Peter Kasting 2013/12/17 19:56:49 I think so. "about:" might get fixed to "chrome:/
Mark P 2013/12/17 20:36:18 Done. I thought I tested this case but apparently
+ base::string16 url_spec_utf16 = ASCIIToUTF16(url.spec());
+ if ((term_string[term_string.length() - 1] != char16('/')) &&
+ (url_spec_utf16[url_spec_utf16.length() - 1] == char16('/'))) {
+ // If the url.spec() added a trailing '/' that wasn't in the input
+ // (e.g., at the end of a hostname in a URL such as chrome://version),
+ // remove it for the purposes of calculating whether this can be
+ // the default match. (Fill_into_edit may be missing the trailing
Peter Kasting 2013/12/17 19:56:49 Nit: Fill -> fill
Mark P 2013/12/17 20:36:18 Done.
+ // slash in some cases.)
+ url_spec_utf16 =
+ url_spec_utf16.substr(0, url_spec_utf16.length() - 1);
+ }
+ if (StartsWith(match.fill_into_edit, url_spec_utf16, false)) {
+ match.inline_autocompletion = match.fill_into_edit.substr(
+ url_spec_utf16.length());
+ match.allowed_to_be_default_match = !prevent_inline_autocomplete ||
+ match.inline_autocompletion.empty();
+ }
+ }
Mark P 2013/12/17 19:29:02 I think this strategy works but I'm not positive.
Peter Kasting 2013/12/17 19:56:49 Check i18n domain names and escaped versus unescap
Mark P 2013/12/17 20:36:18 Seems to work. I can only manage to get shortcut'
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698