Allow Zero Suggest (on Android) on chrome: and about: Pages
In effect, this fixes this TODO in zero_suggest_provider.cc
// Only show zero suggest for HTTP[S] pages.
// TODO(mariakhomenko): We may be able to expand this set to include pages
// with other schemes (e.g. chrome://). That may require improvements to
// the formatting of the verbatim result returned by MatchForCurrentURL().
As such, the main part of this change is in
components/omnibox/browser/zero_suggest_provider.cc
Everything else in this changelist is simply to get that change working.
I audited all the schemes in the URL constants files.
* Some schemes such as ftp are never used on Android; they're not
supported.
* Some schemes such as chrome-native are used on Android, but they're
never displayed in a context that has an omnibox.
The only ones I found I could get displayed in the omnibox were
about: and chrome:.
For identifying what schemes to investigate, the histogram
Navigation.MainFrameScheme was useful.
This changelist allows zero suggest to appear on those contexts.
Zero suggest still not appear on the new tab page or incognito,
both by product decision. This change does not alter that.
To make this work, I had to make the AutocompleteClient function
GetEmbedderRepresentationOfAboutScheme() const. Most of this
changelist is fixes declarations due to that.
Tested interactively.
TBR=rohitrao
for mechanical changes to ios/c/b/autocomplete
Bug: 704406
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I65be6327d29bd7616e44999304c85317406b67cc
Reviewed-on: https://chromium-review.googlesource.com/1172080
Commit-Queue: Mark Pearson <[email protected]>
Reviewed-by: Justin Donnelly <[email protected]>
Cr-Commit-Position: refs/heads/master@{#586429}
diff --git a/components/omnibox/browser/zero_suggest_provider.cc b/components/omnibox/browser/zero_suggest_provider.cc
index 15ef66d..86c73893 100644
--- a/components/omnibox/browser/zero_suggest_provider.cc
+++ b/components/omnibox/browser/zero_suggest_provider.cc
@@ -473,10 +473,7 @@
if (num_results == 0)
return;
- // TODO(jered): Rip this out once the first match is decoupled from the
- // current typing in the omnibox.
matches_.push_back(current_url_match_);
-
for (MatchMap::const_iterator it(map.begin()); it != map.end(); ++it)
matches_.push_back(it->second);
@@ -516,13 +513,19 @@
if (client()->IsOffTheRecord())
return false;
- // Only show zero suggest for HTTP[S] pages.
- // TODO(mariakhomenko): We may be able to expand this set to include pages
- // with other schemes (e.g. chrome://). That may require improvements to
- // the formatting of the verbatim result returned by MatchForCurrentURL().
+ // Only show zero suggest for pages with URLs the user will recognize.
+ // This list intentionally does not include items such as ftp: and file:
+ // because (a) these do not work on Android and iOS, where non-contextual
+ // zero suggest is launched and (b) on desktop, where contextual zero suggest
+ // is running, these types of schemes aren't eligible to be sent to the
+ // server to ask for suggestions (and thus in practice we won't display zero
+ // suggest for them).
if (!current_page_url.is_valid() ||
((current_page_url.scheme() != url::kHttpScheme) &&
- (current_page_url.scheme() != url::kHttpsScheme)))
+ (current_page_url.scheme() != url::kHttpsScheme) &&
+ (current_page_url.scheme() != url::kAboutScheme) &&
+ (current_page_url.scheme() !=
+ client()->GetEmbedderRepresentationOfAboutScheme())))
return false;
return true;