Commit aaa1418e authored by tby's avatar tby Committed by Commit Bot

[Duplicate files] Filter file results from omnibox provider.

We want all file results to be returned by the launcher search provider,
so let's stop the omnibox provider from doubling up. Cases to handle:

 - docs.google.com/... urls - drive files
 - drive.google.com/... urls - drive folders and misc
 - file://... urls - local files opened in chrome

Bug: 1053637
Change-Id: Ia71174969f14f3d34638c611376d6460dee61105
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2377326
Commit-Queue: Tony Yeoman <tby@chromium.org>
Reviewed-by: default avatarRachel Wong <wrong@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802451}
parent a37811d1
......@@ -20,6 +20,15 @@
#include "url/gurl.h"
namespace app_list {
namespace {
bool IsDriveUrl(const GURL& url) {
// Returns true if the |url| points to a Drive Web host.
const std::string& host = url.host();
return host == "drive.google.com" || host == "docs.google.com";
}
} // namespace
OmniboxProvider::OmniboxProvider(Profile* profile,
AppListControllerDelegate* list_controller)
......@@ -72,12 +81,22 @@ void OmniboxProvider::PopulateFromACResult(const AutocompleteResult& result) {
SearchProvider::Results new_results;
new_results.reserve(result.size());
for (const AutocompleteMatch& match : result) {
if (!match.destination_url.is_valid())
// Do not return a match in any of these cases:
// - The URL is invalid.
// - The URL points to Drive Web. The LauncherSearchProvider surfaces Drive
// results.
// - The URL points to a local file. The LauncherSearchProvider also handles
// files results, even if they've been opened in the browser.
if (!match.destination_url.is_valid() ||
IsDriveUrl(match.destination_url) ||
match.destination_url.SchemeIsFile()) {
continue;
}
new_results.emplace_back(std::make_unique<OmniboxResult>(
profile_, list_controller_, controller_.get(), match,
is_zero_state_input_));
}
SwapResults(&new_results);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment