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'
|
} |
} |