hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 1 | // 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 Hashimoto | 884ad19 | 2014-08-28 05:54:30 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_AUTOCOMPLETE_CHROME_AUTOCOMPLETE_PROVIDER_CLIENT_H_ |
| 6 | #define CHROME_BROWSER_AUTOCOMPLETE_CHROME_AUTOCOMPLETE_PROVIDER_CLIENT_H_ |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 7 | |
avi | e4d7b6f | 2015-12-26 00:59:18 | [diff] [blame] | 8 | #include "base/macros.h" |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 9 | #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
blundell | 0c5bb253 | 2015-06-16 14:23:14 | [diff] [blame] | 10 | #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
blundell | 2102f7c | 2015-07-09 10:00:53 | [diff] [blame] | 11 | #include "components/omnibox/browser/autocomplete_provider_client.h" |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 12 | |
| 13 | class Profile; |
| 14 | |
Justin Donnelly | a7a6fec85 | 2017-08-01 14:59:22 | [diff] [blame] | 15 | namespace content { |
| 16 | class StoragePartition; |
| 17 | } |
| 18 | |
Ryo Hashimoto | 884ad19 | 2014-08-28 05:54:30 | [diff] [blame] | 19 | class ChromeAutocompleteProviderClient : public AutocompleteProviderClient { |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 20 | public: |
Ryo Hashimoto | 884ad19 | 2014-08-28 05:54:30 | [diff] [blame] | 21 | explicit ChromeAutocompleteProviderClient(Profile* profile); |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 22 | ~ChromeAutocompleteProviderClient() override; |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 23 | |
Ryo Hashimoto | 884ad19 | 2014-08-28 05:54:30 | [diff] [blame] | 24 | // AutocompleteProviderClient: |
Maks Orlovich | 1b20851 | 2018-06-13 21:08:17 | [diff] [blame] | 25 | scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override; |
blundell | d130d59 | 2015-06-21 19:29:13 | [diff] [blame] | 26 | PrefService* GetPrefs() override; |
| 27 | const AutocompleteSchemeClassifier& GetSchemeClassifier() const override; |
| 28 | AutocompleteClassifier* GetAutocompleteClassifier() override; |
paulmeyer | b582426 | 2015-06-17 18:08:44 | [diff] [blame] | 29 | history::HistoryService* GetHistoryService() override; |
blundell | d130d59 | 2015-06-21 19:29:13 | [diff] [blame] | 30 | scoped_refptr<history::TopSites> GetTopSites() override; |
paulmeyer | b582426 | 2015-06-17 18:08:44 | [diff] [blame] | 31 | bookmarks::BookmarkModel* GetBookmarkModel() override; |
| 32 | history::URLDatabase* GetInMemoryDatabase() override; |
blundell | b11c2787e | 2015-06-22 10:05:10 | [diff] [blame] | 33 | InMemoryURLIndex* GetInMemoryURLIndex() override; |
blundell | 0c5bb253 | 2015-06-16 14:23:14 | [diff] [blame] | 34 | TemplateURLService* GetTemplateURLService() override; |
blundell | d130d59 | 2015-06-21 19:29:13 | [diff] [blame] | 35 | const TemplateURLService* GetTemplateURLService() const override; |
Gheorghe Comanici | 86bbdf6 | 2017-08-28 17:20:33 | [diff] [blame] | 36 | ContextualSuggestionsService* GetContextualSuggestionsService( |
| 37 | bool create_if_necessary) const override; |
Travis Skare | 13393cb | 2018-07-19 02:47:56 | [diff] [blame] | 38 | DocumentSuggestionsService* GetDocumentSuggestionsService( |
| 39 | bool create_if_necessary) const override; |
blundell | d130d59 | 2015-06-21 19:29:13 | [diff] [blame] | 40 | const SearchTermsData& GetSearchTermsData() const override; |
blundell | fb1215ee | 2015-06-19 20:18:12 | [diff] [blame] | 41 | scoped_refptr<ShortcutsBackend> GetShortcutsBackend() override; |
| 42 | scoped_refptr<ShortcutsBackend> GetShortcutsBackendIfExists() override; |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 43 | std::unique_ptr<KeywordExtensionsDelegate> GetKeywordExtensionsDelegate( |
blundell | b11c2787e | 2015-06-22 10:05:10 | [diff] [blame] | 44 | KeywordProvider* keyword_provider) override; |
blundell | d130d59 | 2015-06-21 19:29:13 | [diff] [blame] | 45 | std::string GetAcceptLanguages() const override; |
blundell | ff1502c | 2015-06-22 11:34:37 | [diff] [blame] | 46 | std::string GetEmbedderRepresentationOfAboutScheme() override; |
| 47 | std::vector<base::string16> GetBuiltinURLs() override; |
| 48 | std::vector<base::string16> GetBuiltinsToProvideAsUserTypes() override; |
Gheorghe Comanici | 034cff6 | 2018-01-27 03:34:00 | [diff] [blame] | 49 | // GetCurrentVisitTimestamp is only implemented for desktop users. For mobile |
| 50 | // users, the function returns base::Time(). |
| 51 | base::Time GetCurrentVisitTimestamp() const override; |
blundell | d130d59 | 2015-06-21 19:29:13 | [diff] [blame] | 52 | bool IsOffTheRecord() const override; |
| 53 | bool SearchSuggestEnabled() const override; |
Justin Donnelly | 904e7cb | 2018-04-10 14:56:05 | [diff] [blame] | 54 | bool IsTabUploadToGoogleActive() const override; |
Gheorghe Comanici | 68250410 | 2017-11-30 17:47:25 | [diff] [blame] | 55 | bool IsAuthenticated() const override; |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 56 | void Classify( |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 57 | const base::string16& text, |
| 58 | bool prefer_keyword, |
| 59 | bool allow_exact_keyword_match, |
| 60 | metrics::OmniboxEventProto::PageClassification page_classification, |
| 61 | AutocompleteMatch* match, |
mostynb | 01d8b10e | 2014-10-13 09:44:44 | [diff] [blame] | 62 | GURL* alternate_nav_url) override; |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 63 | void DeleteMatchingURLsForKeywordFromHistory( |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 64 | history::KeywordID keyword_id, |
mostynb | 01d8b10e | 2014-10-13 09:44:44 | [diff] [blame] | 65 | const base::string16& term) override; |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 66 | void PrefetchImage(const GURL& url) override; |
Justin Donnelly | 4e448cb | 2017-07-07 21:32:13 | [diff] [blame] | 67 | void StartServiceWorker(const GURL& destination_url) override; |
blundell | 62bf65f | 2015-06-19 08:30:46 | [diff] [blame] | 68 | void OnAutocompleteControllerResultReady( |
| 69 | AutocompleteController* controller) override; |
Kevin Bailey | 55841fa7 | 2018-03-12 22:52:05 | [diff] [blame] | 70 | bool IsTabOpenWithURL(const GURL& url, |
| 71 | const AutocompleteInput* input) override; |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 72 | |
Justin Donnelly | a7a6fec85 | 2017-08-01 14:59:22 | [diff] [blame] | 73 | // For testing. |
| 74 | void set_storage_partition(content::StoragePartition* storage_partition) { |
| 75 | storage_partition_ = storage_partition; |
| 76 | } |
| 77 | |
Kevin Bailey | 55841fa7 | 2018-03-12 22:52:05 | [diff] [blame] | 78 | bool StrippedURLsAreEqual(const GURL& url1, |
| 79 | const GURL& url2, |
Kevin Bailey | 499298a | 2018-03-16 14:54:43 | [diff] [blame] | 80 | const AutocompleteInput* input) const; |
Kevin Bailey | 55841fa7 | 2018-03-12 22:52:05 | [diff] [blame] | 81 | |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 82 | private: |
| 83 | Profile* profile_; |
| 84 | ChromeAutocompleteSchemeClassifier scheme_classifier_; |
blundell | 0c5bb253 | 2015-06-16 14:23:14 | [diff] [blame] | 85 | UIThreadSearchTermsData search_terms_data_; |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 86 | |
Justin Donnelly | a7a6fec85 | 2017-08-01 14:59:22 | [diff] [blame] | 87 | // Injectable storage partitiion, used for testing. |
| 88 | content::StoragePartition* storage_partition_; |
| 89 | |
Ryo Hashimoto | 884ad19 | 2014-08-28 05:54:30 | [diff] [blame] | 90 | DISALLOW_COPY_AND_ASSIGN(ChromeAutocompleteProviderClient); |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 91 | }; |
| 92 | |
Ryo Hashimoto | 884ad19 | 2014-08-28 05:54:30 | [diff] [blame] | 93 | #endif // CHROME_BROWSER_AUTOCOMPLETE_CHROME_AUTOCOMPLETE_PROVIDER_CLIENT_H_ |