blob: e431b9d58c88ae58234982f177f433e82189ba78 [file] [log] [blame]
hashimoto663b9f42014-08-26 04:29:201// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Ryo Hashimoto884ad192014-08-28 05:54:305#ifndef CHROME_BROWSER_AUTOCOMPLETE_CHROME_AUTOCOMPLETE_PROVIDER_CLIENT_H_
6#define CHROME_BROWSER_AUTOCOMPLETE_CHROME_AUTOCOMPLETE_PROVIDER_CLIENT_H_
hashimoto663b9f42014-08-26 04:29:207
Gang Wua52721ce2020-06-13 04:03:248#include <memory>
9#include <string>
10#include <vector>
11
avie4d7b6f2015-12-26 00:59:1812#include "base/macros.h"
Gang Wua4a85312020-06-20 05:14:1313#include "build/build_config.h"
hashimoto663b9f42014-08-26 04:29:2014#include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
blundell2102f7c2015-07-09 10:00:5315#include "components/omnibox/browser/autocomplete_provider_client.h"
hashimoto663b9f42014-08-26 04:29:2016
Gang Wua4a85312020-06-20 05:14:1317#if defined(OS_ANDROID)
18class TabAndroid;
19#endif // defined(OS_ANDROID)
20
hashimoto663b9f42014-08-26 04:29:2021class Profile;
22
Justin Donnellya7a6fec852017-08-01 14:59:2223namespace content {
24class StoragePartition;
Kevin Bailey6099f61f2019-11-06 17:42:4925class WebContents;
Justin Donnellya7a6fec852017-08-01 14:59:2226}
27
Mark Pearsoncb618ec2018-07-28 16:13:4228namespace unified_consent {
29class UrlKeyedDataCollectionConsentHelper;
30}
31
Ryo Hashimoto884ad192014-08-28 05:54:3032class ChromeAutocompleteProviderClient : public AutocompleteProviderClient {
hashimoto663b9f42014-08-26 04:29:2033 public:
Ryo Hashimoto884ad192014-08-28 05:54:3034 explicit ChromeAutocompleteProviderClient(Profile* profile);
Daniel Chenga542fca2014-10-21 09:51:2935 ~ChromeAutocompleteProviderClient() override;
hashimoto663b9f42014-08-26 04:29:2036
Ryo Hashimoto884ad192014-08-28 05:54:3037 // AutocompleteProviderClient:
Maks Orlovich1b208512018-06-13 21:08:1738 scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override;
blundelld130d592015-06-21 19:29:1339 PrefService* GetPrefs() override;
Travis Skare4d46fb812020-11-04 14:18:3840 PrefService* GetLocalState() override;
blundelld130d592015-06-21 19:29:1341 const AutocompleteSchemeClassifier& GetSchemeClassifier() const override;
42 AutocompleteClassifier* GetAutocompleteClassifier() override;
paulmeyerb5824262015-06-17 18:08:4443 history::HistoryService* GetHistoryService() override;
blundelld130d592015-06-21 19:29:1344 scoped_refptr<history::TopSites> GetTopSites() override;
paulmeyerb5824262015-06-17 18:08:4445 bookmarks::BookmarkModel* GetBookmarkModel() override;
46 history::URLDatabase* GetInMemoryDatabase() override;
blundellb11c2787e2015-06-22 10:05:1047 InMemoryURLIndex* GetInMemoryURLIndex() override;
blundell0c5bb2532015-06-16 14:23:1448 TemplateURLService* GetTemplateURLService() override;
blundelld130d592015-06-21 19:29:1349 const TemplateURLService* GetTemplateURLService() const override;
Tommy C. Li06ec26a2019-06-10 18:01:4250 RemoteSuggestionsService* GetRemoteSuggestionsService(
Gheorghe Comanici86bbdf62017-08-28 17:20:3351 bool create_if_necessary) const override;
Travis Skare13393cb2018-07-19 02:47:5652 DocumentSuggestionsService* GetDocumentSuggestionsService(
53 bool create_if_necessary) const override;
Orin Jaworski76893bb2018-10-08 18:12:5454 OmniboxPedalProvider* GetPedalProvider() const override;
blundellfb1215ee2015-06-19 20:18:1255 scoped_refptr<ShortcutsBackend> GetShortcutsBackend() override;
56 scoped_refptr<ShortcutsBackend> GetShortcutsBackendIfExists() override;
dcheng4af48582016-04-19 00:29:3557 std::unique_ptr<KeywordExtensionsDelegate> GetKeywordExtensionsDelegate(
blundellb11c2787e2015-06-22 10:05:1058 KeywordProvider* keyword_provider) override;
blundelld130d592015-06-21 19:29:1359 std::string GetAcceptLanguages() const override;
Mark Pearson3fb0e3162018-08-27 21:53:5760 std::string GetEmbedderRepresentationOfAboutScheme() const override;
blundellff1502c2015-06-22 11:34:3761 std::vector<base::string16> GetBuiltinURLs() override;
62 std::vector<base::string16> GetBuiltinsToProvideAsUserTypes() override;
Ce Chen704a23162019-06-17 22:39:1463 component_updater::ComponentUpdateService* GetComponentUpdateService()
64 override;
Xing Liu6d873212020-05-13 22:33:4965 query_tiles::TileService* GetQueryTileService() const override;
manukhdf6487ff2020-11-03 20:16:2466 OmniboxTriggeredFeatureService* GetOmniboxTriggeredFeatureService()
67 const override;
Ce Chen704a23162019-06-17 22:39:1468
blundelld130d592015-06-21 19:29:1369 bool IsOffTheRecord() const override;
70 bool SearchSuggestEnabled() const override;
Mark Pearsoncb618ec2018-07-28 16:13:4271 bool IsPersonalizedUrlDataCollectionActive() const override;
Gheorghe Comanici682504102017-11-30 17:47:2572 bool IsAuthenticated() const override;
Travis Skare6e7d80142018-09-11 23:51:0573 bool IsSyncActive() const override;
manukda8584b2019-07-19 19:42:0674 std::string ProfileUserName() const override;
Daniel Chenga542fca2014-10-21 09:51:2975 void Classify(
hashimoto663b9f42014-08-26 04:29:2076 const base::string16& text,
77 bool prefer_keyword,
78 bool allow_exact_keyword_match,
79 metrics::OmniboxEventProto::PageClassification page_classification,
80 AutocompleteMatch* match,
mostynb01d8b10e2014-10-13 09:44:4481 GURL* alternate_nav_url) override;
Daniel Chenga542fca2014-10-21 09:51:2982 void DeleteMatchingURLsForKeywordFromHistory(
hashimoto663b9f42014-08-26 04:29:2083 history::KeywordID keyword_id,
mostynb01d8b10e2014-10-13 09:44:4484 const base::string16& term) override;
Daniel Chenga542fca2014-10-21 09:51:2985 void PrefetchImage(const GURL& url) override;
Justin Donnelly4e448cb2017-07-07 21:32:1386 void StartServiceWorker(const GURL& destination_url) override;
Kevin Bailey55841fa72018-03-12 22:52:0587 bool IsTabOpenWithURL(const GURL& url,
88 const AutocompleteInput* input) override;
Orin Jaworskiabf577a2018-11-09 02:23:2489 bool IsBrowserUpdateAvailable() const override;
Ryan Sturm10bcb5d2020-10-23 20:43:2590 void OnAutocompleteControllerResultReady(
91 AutocompleteController* controller) override;
hashimoto663b9f42014-08-26 04:29:2092
Justin Donnellya7a6fec852017-08-01 14:59:2293 // For testing.
94 void set_storage_partition(content::StoragePartition* storage_partition) {
95 storage_partition_ = storage_partition;
96 }
97
Kevin Bailey55841fa72018-03-12 22:52:0598 bool StrippedURLsAreEqual(const GURL& url1,
99 const GURL& url2,
Kevin Bailey499298a2018-03-16 14:54:43100 const AutocompleteInput* input) const;
Kevin Bailey55841fa72018-03-12 22:52:05101
Kevin Bailey6099f61f2019-11-06 17:42:49102 // Performs a comparison of |stripped_url| to the stripped last committed
103 // URL of |web_contents|, using the internal cache to avoid repeatedly
104 // re-stripping the URL.
105 bool IsStrippedURLEqualToWebContentsURL(const GURL& stripped_url,
106 content::WebContents* web_contents);
Kevin Baileyd9ece312019-07-25 21:04:40107
Gang Wua4a85312020-06-20 05:14:13108#if defined(OS_ANDROID)
109 // Returns a TabAndroid has opened same URL as |url|.
110 TabAndroid* GetTabOpenWithURL(const GURL& url,
111 const AutocompleteInput* input);
112#endif // defined(OS_ANDROID)
113
Kevin Bailey6099f61f2019-11-06 17:42:49114 private:
hashimoto663b9f42014-08-26 04:29:20115 Profile* profile_;
116 ChromeAutocompleteSchemeClassifier scheme_classifier_;
Orin Jaworski76893bb2018-10-08 18:12:54117 std::unique_ptr<OmniboxPedalProvider> pedal_provider_;
Mark Pearsoncb618ec2018-07-28 16:13:42118 std::unique_ptr<unified_consent::UrlKeyedDataCollectionConsentHelper>
119 url_consent_helper_;
hashimoto663b9f42014-08-26 04:29:20120
Justin Donnellya7a6fec852017-08-01 14:59:22121 // Injectable storage partitiion, used for testing.
122 content::StoragePartition* storage_partition_;
123
manukhdf6487ff2020-11-03 20:16:24124 std::unique_ptr<OmniboxTriggeredFeatureService>
125 omnibox_triggered_feature_service_;
126
Ryo Hashimoto884ad192014-08-28 05:54:30127 DISALLOW_COPY_AND_ASSIGN(ChromeAutocompleteProviderClient);
hashimoto663b9f42014-08-26 04:29:20128};
129
Ryo Hashimoto884ad192014-08-28 05:54:30130#endif // CHROME_BROWSER_AUTOCOMPLETE_CHROME_AUTOCOMPLETE_PROVIDER_CLIENT_H_