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 | |
Gang Wu | a52721ce | 2020-06-13 04:03:24 | [diff] [blame] | 8 | #include <memory> |
| 9 | #include <string> |
| 10 | #include <vector> |
| 11 | |
avi | e4d7b6f | 2015-12-26 00:59:18 | [diff] [blame] | 12 | #include "base/macros.h" |
Gang Wu | a4a8531 | 2020-06-20 05:14:13 | [diff] [blame] | 13 | #include "build/build_config.h" |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 14 | #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
blundell | 2102f7c | 2015-07-09 10:00:53 | [diff] [blame] | 15 | #include "components/omnibox/browser/autocomplete_provider_client.h" |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 16 | |
Gang Wu | a4a8531 | 2020-06-20 05:14:13 | [diff] [blame] | 17 | #if defined(OS_ANDROID) |
| 18 | class TabAndroid; |
| 19 | #endif // defined(OS_ANDROID) |
| 20 | |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 21 | class Profile; |
| 22 | |
Justin Donnelly | a7a6fec85 | 2017-08-01 14:59:22 | [diff] [blame] | 23 | namespace content { |
| 24 | class StoragePartition; |
Kevin Bailey | 6099f61f | 2019-11-06 17:42:49 | [diff] [blame] | 25 | class WebContents; |
Justin Donnelly | a7a6fec85 | 2017-08-01 14:59:22 | [diff] [blame] | 26 | } |
| 27 | |
Mark Pearson | cb618ec | 2018-07-28 16:13:42 | [diff] [blame] | 28 | namespace unified_consent { |
| 29 | class UrlKeyedDataCollectionConsentHelper; |
| 30 | } |
| 31 | |
Ryo Hashimoto | 884ad19 | 2014-08-28 05:54:30 | [diff] [blame] | 32 | class ChromeAutocompleteProviderClient : public AutocompleteProviderClient { |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 33 | public: |
Ryo Hashimoto | 884ad19 | 2014-08-28 05:54:30 | [diff] [blame] | 34 | explicit ChromeAutocompleteProviderClient(Profile* profile); |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 35 | ~ChromeAutocompleteProviderClient() override; |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 36 | |
Ryo Hashimoto | 884ad19 | 2014-08-28 05:54:30 | [diff] [blame] | 37 | // AutocompleteProviderClient: |
Maks Orlovich | 1b20851 | 2018-06-13 21:08:17 | [diff] [blame] | 38 | scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override; |
blundell | d130d59 | 2015-06-21 19:29:13 | [diff] [blame] | 39 | PrefService* GetPrefs() override; |
Travis Skare | 4d46fb81 | 2020-11-04 14:18:38 | [diff] [blame] | 40 | PrefService* GetLocalState() override; |
blundell | d130d59 | 2015-06-21 19:29:13 | [diff] [blame] | 41 | const AutocompleteSchemeClassifier& GetSchemeClassifier() const override; |
| 42 | AutocompleteClassifier* GetAutocompleteClassifier() override; |
paulmeyer | b582426 | 2015-06-17 18:08:44 | [diff] [blame] | 43 | history::HistoryService* GetHistoryService() override; |
blundell | d130d59 | 2015-06-21 19:29:13 | [diff] [blame] | 44 | scoped_refptr<history::TopSites> GetTopSites() override; |
paulmeyer | b582426 | 2015-06-17 18:08:44 | [diff] [blame] | 45 | bookmarks::BookmarkModel* GetBookmarkModel() override; |
| 46 | history::URLDatabase* GetInMemoryDatabase() override; |
blundell | b11c2787e | 2015-06-22 10:05:10 | [diff] [blame] | 47 | InMemoryURLIndex* GetInMemoryURLIndex() override; |
blundell | 0c5bb253 | 2015-06-16 14:23:14 | [diff] [blame] | 48 | TemplateURLService* GetTemplateURLService() override; |
blundell | d130d59 | 2015-06-21 19:29:13 | [diff] [blame] | 49 | const TemplateURLService* GetTemplateURLService() const override; |
Tommy C. Li | 06ec26a | 2019-06-10 18:01:42 | [diff] [blame] | 50 | RemoteSuggestionsService* GetRemoteSuggestionsService( |
Gheorghe Comanici | 86bbdf6 | 2017-08-28 17:20:33 | [diff] [blame] | 51 | bool create_if_necessary) const override; |
Travis Skare | 13393cb | 2018-07-19 02:47:56 | [diff] [blame] | 52 | DocumentSuggestionsService* GetDocumentSuggestionsService( |
| 53 | bool create_if_necessary) const override; |
Orin Jaworski | 76893bb | 2018-10-08 18:12:54 | [diff] [blame] | 54 | OmniboxPedalProvider* GetPedalProvider() const override; |
blundell | fb1215ee | 2015-06-19 20:18:12 | [diff] [blame] | 55 | scoped_refptr<ShortcutsBackend> GetShortcutsBackend() override; |
| 56 | scoped_refptr<ShortcutsBackend> GetShortcutsBackendIfExists() override; |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 57 | std::unique_ptr<KeywordExtensionsDelegate> GetKeywordExtensionsDelegate( |
blundell | b11c2787e | 2015-06-22 10:05:10 | [diff] [blame] | 58 | KeywordProvider* keyword_provider) override; |
blundell | d130d59 | 2015-06-21 19:29:13 | [diff] [blame] | 59 | std::string GetAcceptLanguages() const override; |
Mark Pearson | 3fb0e316 | 2018-08-27 21:53:57 | [diff] [blame] | 60 | std::string GetEmbedderRepresentationOfAboutScheme() const override; |
blundell | ff1502c | 2015-06-22 11:34:37 | [diff] [blame] | 61 | std::vector<base::string16> GetBuiltinURLs() override; |
| 62 | std::vector<base::string16> GetBuiltinsToProvideAsUserTypes() override; |
Ce Chen | 704a2316 | 2019-06-17 22:39:14 | [diff] [blame] | 63 | component_updater::ComponentUpdateService* GetComponentUpdateService() |
| 64 | override; |
Xing Liu | 6d87321 | 2020-05-13 22:33:49 | [diff] [blame] | 65 | query_tiles::TileService* GetQueryTileService() const override; |
manukh | df6487ff | 2020-11-03 20:16:24 | [diff] [blame] | 66 | OmniboxTriggeredFeatureService* GetOmniboxTriggeredFeatureService() |
| 67 | const override; |
Ce Chen | 704a2316 | 2019-06-17 22:39:14 | [diff] [blame] | 68 | |
blundell | d130d59 | 2015-06-21 19:29:13 | [diff] [blame] | 69 | bool IsOffTheRecord() const override; |
| 70 | bool SearchSuggestEnabled() const override; |
Mark Pearson | cb618ec | 2018-07-28 16:13:42 | [diff] [blame] | 71 | bool IsPersonalizedUrlDataCollectionActive() const override; |
Gheorghe Comanici | 68250410 | 2017-11-30 17:47:25 | [diff] [blame] | 72 | bool IsAuthenticated() const override; |
Travis Skare | 6e7d8014 | 2018-09-11 23:51:05 | [diff] [blame] | 73 | bool IsSyncActive() const override; |
manuk | da8584b | 2019-07-19 19:42:06 | [diff] [blame] | 74 | std::string ProfileUserName() const override; |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 75 | void Classify( |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 76 | const base::string16& text, |
| 77 | bool prefer_keyword, |
| 78 | bool allow_exact_keyword_match, |
| 79 | metrics::OmniboxEventProto::PageClassification page_classification, |
| 80 | AutocompleteMatch* match, |
mostynb | 01d8b10e | 2014-10-13 09:44:44 | [diff] [blame] | 81 | GURL* alternate_nav_url) override; |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 82 | void DeleteMatchingURLsForKeywordFromHistory( |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 83 | history::KeywordID keyword_id, |
mostynb | 01d8b10e | 2014-10-13 09:44:44 | [diff] [blame] | 84 | const base::string16& term) override; |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 85 | void PrefetchImage(const GURL& url) override; |
Justin Donnelly | 4e448cb | 2017-07-07 21:32:13 | [diff] [blame] | 86 | void StartServiceWorker(const GURL& destination_url) override; |
Kevin Bailey | 55841fa7 | 2018-03-12 22:52:05 | [diff] [blame] | 87 | bool IsTabOpenWithURL(const GURL& url, |
| 88 | const AutocompleteInput* input) override; |
Orin Jaworski | abf577a | 2018-11-09 02:23:24 | [diff] [blame] | 89 | bool IsBrowserUpdateAvailable() const override; |
Ryan Sturm | 10bcb5d | 2020-10-23 20:43:25 | [diff] [blame] | 90 | void OnAutocompleteControllerResultReady( |
| 91 | AutocompleteController* controller) override; |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 92 | |
Justin Donnelly | a7a6fec85 | 2017-08-01 14:59:22 | [diff] [blame] | 93 | // For testing. |
| 94 | void set_storage_partition(content::StoragePartition* storage_partition) { |
| 95 | storage_partition_ = storage_partition; |
| 96 | } |
| 97 | |
Kevin Bailey | 55841fa7 | 2018-03-12 22:52:05 | [diff] [blame] | 98 | bool StrippedURLsAreEqual(const GURL& url1, |
| 99 | const GURL& url2, |
Kevin Bailey | 499298a | 2018-03-16 14:54:43 | [diff] [blame] | 100 | const AutocompleteInput* input) const; |
Kevin Bailey | 55841fa7 | 2018-03-12 22:52:05 | [diff] [blame] | 101 | |
Kevin Bailey | 6099f61f | 2019-11-06 17:42:49 | [diff] [blame] | 102 | // 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 Bailey | d9ece31 | 2019-07-25 21:04:40 | [diff] [blame] | 107 | |
Gang Wu | a4a8531 | 2020-06-20 05:14:13 | [diff] [blame] | 108 | #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 Bailey | 6099f61f | 2019-11-06 17:42:49 | [diff] [blame] | 114 | private: |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 115 | Profile* profile_; |
| 116 | ChromeAutocompleteSchemeClassifier scheme_classifier_; |
Orin Jaworski | 76893bb | 2018-10-08 18:12:54 | [diff] [blame] | 117 | std::unique_ptr<OmniboxPedalProvider> pedal_provider_; |
Mark Pearson | cb618ec | 2018-07-28 16:13:42 | [diff] [blame] | 118 | std::unique_ptr<unified_consent::UrlKeyedDataCollectionConsentHelper> |
| 119 | url_consent_helper_; |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 120 | |
Justin Donnelly | a7a6fec85 | 2017-08-01 14:59:22 | [diff] [blame] | 121 | // Injectable storage partitiion, used for testing. |
| 122 | content::StoragePartition* storage_partition_; |
| 123 | |
manukh | df6487ff | 2020-11-03 20:16:24 | [diff] [blame] | 124 | std::unique_ptr<OmniboxTriggeredFeatureService> |
| 125 | omnibox_triggered_feature_service_; |
| 126 | |
Ryo Hashimoto | 884ad19 | 2014-08-28 05:54:30 | [diff] [blame] | 127 | DISALLOW_COPY_AND_ASSIGN(ChromeAutocompleteProviderClient); |
hashimoto | 663b9f4 | 2014-08-26 04:29:20 | [diff] [blame] | 128 | }; |
| 129 | |
Ryo Hashimoto | 884ad19 | 2014-08-28 05:54:30 | [diff] [blame] | 130 | #endif // CHROME_BROWSER_AUTOCOMPLETE_CHROME_AUTOCOMPLETE_PROVIDER_CLIENT_H_ |