Avoid DCHECK failure for chrome:// URLs in autocomplete suggestions
If the URL in the omnibox input field was not entered by the user, then
avoid checking that the scheme of the default autocomplete suggestion
is equivalent to the scheme of the input URL.
This check causes a failure in the typical case for the Physical Web
provider, which only offers suggestions when the user has not entered
text in the omnibox and can suggest chrome://physical-web as the default
suggestion.
BUG=
Review-Url: https://codereview.chromium.org/2266083002
Cr-Commit-Position: refs/heads/master@{#416302}
diff --git a/components/omnibox/browser/physical_web_provider.h b/components/omnibox/browser/physical_web_provider.h
index 86c1f5c..d4e7486 100644
--- a/components/omnibox/browser/physical_web_provider.h
+++ b/components/omnibox/browser/physical_web_provider.h
@@ -5,25 +5,29 @@
#ifndef COMPONENTS_OMNIBOX_BROWSER_PHYSICAL_WEB_PROVIDER_H_
#define COMPONENTS_OMNIBOX_BROWSER_PHYSICAL_WEB_PROVIDER_H_
+#include "base/macros.h"
#include "components/omnibox/browser/autocomplete_input.h"
#include "components/omnibox/browser/autocomplete_provider.h"
class AutocompleteProviderClient;
+class HistoryURLProvider;
namespace base {
class ListValue;
}
class PhysicalWebProvider : public AutocompleteProvider {
-public:
- static PhysicalWebProvider* Create(AutocompleteProviderClient* client);
+ public:
+ static PhysicalWebProvider* Create(AutocompleteProviderClient* client,
+ HistoryURLProvider* history_url_provider);
// AutocompleteProvider:
void Start(const AutocompleteInput& input, bool minimal_changes) override;
void Stop(bool clear_cached_results, bool due_to_user_inactivity) override;
-private:
- PhysicalWebProvider(AutocompleteProviderClient* client);
+ private:
+ PhysicalWebProvider(AutocompleteProviderClient* client,
+ HistoryURLProvider* history_url_provider);
~PhysicalWebProvider() override;
// Adds a separate match item to |matches_| for each nearby URL in
@@ -39,6 +43,11 @@
void AppendOverflowItem(int additional_url_count, int relevance);
AutocompleteProviderClient* client_;
+
+ // Used for efficiency when creating the verbatim match. Can be null.
+ HistoryURLProvider* history_url_provider_;
+
+ DISALLOW_COPY_AND_ASSIGN(PhysicalWebProvider);
};
#endif // COMPONENTS_OMNIBOX_BROWSER_PHYSICAL_WEB_PROVIDER_H_