blob: a2bb1638e93668bc351d8936bd72530368c9db25 [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
avie4d7b6f2015-12-26 00:59:188#include "base/macros.h"
hashimoto663b9f42014-08-26 04:29:209#include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
blundell0c5bb2532015-06-16 14:23:1410#include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
blundell2102f7c2015-07-09 10:00:5311#include "components/omnibox/browser/autocomplete_provider_client.h"
hashimoto663b9f42014-08-26 04:29:2012
13class Profile;
14
Justin Donnellya7a6fec852017-08-01 14:59:2215namespace content {
16class StoragePartition;
17}
18
Mark Pearsoncb618ec2018-07-28 16:13:4219namespace unified_consent {
20class UrlKeyedDataCollectionConsentHelper;
21}
22
Ryo Hashimoto884ad192014-08-28 05:54:3023class ChromeAutocompleteProviderClient : public AutocompleteProviderClient {
hashimoto663b9f42014-08-26 04:29:2024 public:
Ryo Hashimoto884ad192014-08-28 05:54:3025 explicit ChromeAutocompleteProviderClient(Profile* profile);
Daniel Chenga542fca2014-10-21 09:51:2926 ~ChromeAutocompleteProviderClient() override;
hashimoto663b9f42014-08-26 04:29:2027
Ryo Hashimoto884ad192014-08-28 05:54:3028 // AutocompleteProviderClient:
Maks Orlovich1b208512018-06-13 21:08:1729 scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override;
blundelld130d592015-06-21 19:29:1330 PrefService* GetPrefs() override;
31 const AutocompleteSchemeClassifier& GetSchemeClassifier() const override;
32 AutocompleteClassifier* GetAutocompleteClassifier() override;
paulmeyerb5824262015-06-17 18:08:4433 history::HistoryService* GetHistoryService() override;
blundelld130d592015-06-21 19:29:1334 scoped_refptr<history::TopSites> GetTopSites() override;
paulmeyerb5824262015-06-17 18:08:4435 bookmarks::BookmarkModel* GetBookmarkModel() override;
36 history::URLDatabase* GetInMemoryDatabase() override;
blundellb11c2787e2015-06-22 10:05:1037 InMemoryURLIndex* GetInMemoryURLIndex() override;
blundell0c5bb2532015-06-16 14:23:1438 TemplateURLService* GetTemplateURLService() override;
blundelld130d592015-06-21 19:29:1339 const TemplateURLService* GetTemplateURLService() const override;
Gheorghe Comanici86bbdf62017-08-28 17:20:3340 ContextualSuggestionsService* GetContextualSuggestionsService(
41 bool create_if_necessary) const override;
Travis Skare13393cb2018-07-19 02:47:5642 DocumentSuggestionsService* GetDocumentSuggestionsService(
43 bool create_if_necessary) const override;
blundelld130d592015-06-21 19:29:1344 const SearchTermsData& GetSearchTermsData() const override;
blundellfb1215ee2015-06-19 20:18:1245 scoped_refptr<ShortcutsBackend> GetShortcutsBackend() override;
46 scoped_refptr<ShortcutsBackend> GetShortcutsBackendIfExists() override;
dcheng4af48582016-04-19 00:29:3547 std::unique_ptr<KeywordExtensionsDelegate> GetKeywordExtensionsDelegate(
blundellb11c2787e2015-06-22 10:05:1048 KeywordProvider* keyword_provider) override;
blundelld130d592015-06-21 19:29:1349 std::string GetAcceptLanguages() const override;
blundellff1502c2015-06-22 11:34:3750 std::string GetEmbedderRepresentationOfAboutScheme() override;
51 std::vector<base::string16> GetBuiltinURLs() override;
52 std::vector<base::string16> GetBuiltinsToProvideAsUserTypes() override;
Gheorghe Comanici034cff62018-01-27 03:34:0053 // GetCurrentVisitTimestamp is only implemented for desktop users. For mobile
54 // users, the function returns base::Time().
55 base::Time GetCurrentVisitTimestamp() const override;
blundelld130d592015-06-21 19:29:1356 bool IsOffTheRecord() const override;
57 bool SearchSuggestEnabled() const override;
Mark Pearsoncb618ec2018-07-28 16:13:4258 bool IsPersonalizedUrlDataCollectionActive() const override;
Gheorghe Comanici682504102017-11-30 17:47:2559 bool IsAuthenticated() const override;
Daniel Chenga542fca2014-10-21 09:51:2960 void Classify(
hashimoto663b9f42014-08-26 04:29:2061 const base::string16& text,
62 bool prefer_keyword,
63 bool allow_exact_keyword_match,
64 metrics::OmniboxEventProto::PageClassification page_classification,
65 AutocompleteMatch* match,
mostynb01d8b10e2014-10-13 09:44:4466 GURL* alternate_nav_url) override;
Daniel Chenga542fca2014-10-21 09:51:2967 void DeleteMatchingURLsForKeywordFromHistory(
hashimoto663b9f42014-08-26 04:29:2068 history::KeywordID keyword_id,
mostynb01d8b10e2014-10-13 09:44:4469 const base::string16& term) override;
Daniel Chenga542fca2014-10-21 09:51:2970 void PrefetchImage(const GURL& url) override;
Justin Donnelly4e448cb2017-07-07 21:32:1371 void StartServiceWorker(const GURL& destination_url) override;
blundell62bf65f2015-06-19 08:30:4672 void OnAutocompleteControllerResultReady(
73 AutocompleteController* controller) override;
Kevin Bailey55841fa72018-03-12 22:52:0574 bool IsTabOpenWithURL(const GURL& url,
75 const AutocompleteInput* input) override;
hashimoto663b9f42014-08-26 04:29:2076
Justin Donnellya7a6fec852017-08-01 14:59:2277 // For testing.
78 void set_storage_partition(content::StoragePartition* storage_partition) {
79 storage_partition_ = storage_partition;
80 }
81
Kevin Bailey55841fa72018-03-12 22:52:0582 bool StrippedURLsAreEqual(const GURL& url1,
83 const GURL& url2,
Kevin Bailey499298a2018-03-16 14:54:4384 const AutocompleteInput* input) const;
Kevin Bailey55841fa72018-03-12 22:52:0585
hashimoto663b9f42014-08-26 04:29:2086 private:
87 Profile* profile_;
88 ChromeAutocompleteSchemeClassifier scheme_classifier_;
blundell0c5bb2532015-06-16 14:23:1489 UIThreadSearchTermsData search_terms_data_;
Mark Pearsoncb618ec2018-07-28 16:13:4290 std::unique_ptr<unified_consent::UrlKeyedDataCollectionConsentHelper>
91 url_consent_helper_;
hashimoto663b9f42014-08-26 04:29:2092
Justin Donnellya7a6fec852017-08-01 14:59:2293 // Injectable storage partitiion, used for testing.
94 content::StoragePartition* storage_partition_;
95
Ryo Hashimoto884ad192014-08-28 05:54:3096 DISALLOW_COPY_AND_ASSIGN(ChromeAutocompleteProviderClient);
hashimoto663b9f42014-08-26 04:29:2097};
98
Ryo Hashimoto884ad192014-08-28 05:54:3099#endif // CHROME_BROWSER_AUTOCOMPLETE_CHROME_AUTOCOMPLETE_PROVIDER_CLIENT_H_