File: autocomplete_provider_client.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (256 lines) | stat: -rw-r--r-- 10,748 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_PROVIDER_CLIENT_H_
#define COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_PROVIDER_CLIENT_H_

#include <memory>
#include <string>
#include <vector>

#include "base/callback_list.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "components/history/core/browser/keyword_id.h"
#include "components/omnibox/browser/actions/omnibox_action.h"
#include "components/omnibox/browser/lens_suggest_inputs_utils.h"
#include "third_party/metrics_proto/omnibox_event.pb.h"

class AutocompleteClassifier;
class AutocompleteSchemeClassifier;
class AutocompleteScoringModelService;
class DocumentSuggestionsService;
class UnscopedExtensionProvider;
class UnscopedExtensionProviderDelegate;
class GURL;
class InMemoryURLIndex;
class KeywordExtensionsDelegate;
class KeywordProvider;
class OmniboxPedalProvider;
class OmniboxTriggeredFeatureService;
class OnDeviceTailModelService;
class PrefService;
class RemoteSuggestionsService;
class ShortcutsBackend;
class TabMatcher;
class ZeroSuggestCacheService;
struct AutocompleteMatch;
struct ProviderStateService;

namespace bookmarks {
class BookmarkModel;
}

namespace history {
class HistoryService;
class TopSites;
class URLDatabase;
}  // namespace history

namespace history_clusters {
class HistoryClustersService;
}

namespace history_embeddings {
class HistoryEmbeddingsService;
}

namespace network {
class SharedURLLoaderFactory;
}

namespace component_updater {
class ComponentUpdateService;
}

namespace signin {
class IdentityManager;
}

namespace tab_groups {
class TabGroupSyncService;
}

class TemplateURLService;

class AutocompleteProviderClient : public OmniboxAction::Client {
 public:
  virtual ~AutocompleteProviderClient() = default;

  virtual scoped_refptr<network::SharedURLLoaderFactory>
  GetURLLoaderFactory() = 0;
  virtual PrefService* GetPrefs() const = 0;
  virtual PrefService* GetLocalState() = 0;
  virtual std::string GetApplicationLocale() const = 0;
  virtual const AutocompleteSchemeClassifier& GetSchemeClassifier() const = 0;
  virtual AutocompleteClassifier* GetAutocompleteClassifier() = 0;
  virtual history::HistoryService* GetHistoryService() = 0;
  virtual history_clusters::HistoryClustersService* GetHistoryClustersService();
  virtual history_embeddings::HistoryEmbeddingsService*
  GetHistoryEmbeddingsService();
  virtual scoped_refptr<history::TopSites> GetTopSites() = 0;
  virtual bookmarks::BookmarkModel* GetBookmarkModel() = 0;
  virtual history::URLDatabase* GetInMemoryDatabase() = 0;
  virtual InMemoryURLIndex* GetInMemoryURLIndex() = 0;
  virtual TemplateURLService* GetTemplateURLService() = 0;
  virtual const TemplateURLService* GetTemplateURLService() const = 0;
  virtual DocumentSuggestionsService* GetDocumentSuggestionsService() const;
  virtual RemoteSuggestionsService* GetRemoteSuggestionsService(
      bool create_if_necessary) const = 0;
  virtual ZeroSuggestCacheService* GetZeroSuggestCacheService() = 0;
  virtual const ZeroSuggestCacheService* GetZeroSuggestCacheService() const = 0;
  virtual OmniboxPedalProvider* GetPedalProvider() const = 0;
  virtual scoped_refptr<ShortcutsBackend> GetShortcutsBackend() = 0;
  virtual scoped_refptr<ShortcutsBackend> GetShortcutsBackendIfExists() = 0;
  virtual std::unique_ptr<KeywordExtensionsDelegate>
  GetKeywordExtensionsDelegate(KeywordProvider* keyword_provider) = 0;
  virtual std::unique_ptr<UnscopedExtensionProviderDelegate>
  GetUnscopedExtensionProviderDelegate(UnscopedExtensionProvider* provider) = 0;
  virtual OmniboxTriggeredFeatureService* GetOmniboxTriggeredFeatureService()
      const = 0;
  virtual AutocompleteScoringModelService* GetAutocompleteScoringModelService()
      const = 0;
  virtual OnDeviceTailModelService* GetOnDeviceTailModelService() const = 0;
  virtual ProviderStateService* GetProviderStateService() const = 0;
  virtual base::CallbackListSubscription GetLensSuggestInputsWhenReady(
      LensOverlaySuggestInputsCallback callback) const = 0;
  virtual tab_groups::TabGroupSyncService* GetTabGroupSyncService() const = 0;

  // The value to use for Accept-Languages HTTP header when making an HTTP
  // request.
  virtual std::string GetAcceptLanguages() const = 0;

  // The embedder's representation of the |about| URL scheme for builtin URLs
  // (e.g., |chrome| for Chrome).
  virtual std::string GetEmbedderRepresentationOfAboutScheme() const = 0;

  // The set of built-in URLs considered worth suggesting as autocomplete
  // suggestions to the user.  Some built-in URLs, e.g. hidden URLs that
  // intentionally crash the product for testing purposes, may be omitted from
  // this list if suggesting them is undesirable.
  virtual std::vector<std::u16string> GetBuiltinURLs() = 0;

  // The set of URLs to provide as autocomplete suggestions as the user types a
  // prefix of the |about| scheme or the embedder's representation of that
  // scheme. Note that this may be a subset of GetBuiltinURLs(), e.g., only the
  // most commonly-used URLs from that set.
  virtual std::vector<std::u16string> GetBuiltinsToProvideAsUserTypes() = 0;

  // TODO(crbug.com/40610979): clean up component update service if it's
  // confirmed it's not needed for on device head provider. The component update
  // service instance which will be used by on device suggestion provider to
  // observe the model update event.
  virtual component_updater::ComponentUpdateService*
  GetComponentUpdateService() = 0;

  // Returns the signin::IdentityManager associated with the current profile.
  virtual signin::IdentityManager* GetIdentityManager() const = 0;
  // In desktop platforms, this returns true for both guest and Incognito mode.
  // In mobile platforms, we don't have a guest mode and therefore, it returns
  // true only for Incognito mode.
  virtual bool IsOffTheRecord() const = 0;
  virtual bool IsIncognitoProfile() const = 0;
  virtual bool IsGuestSession() const = 0;

  virtual bool SearchSuggestEnabled() const = 0;

  // True for almost all users except ones with a specific enterprise policy.
  virtual bool AllowDeletingBrowserHistory() const;

  // Returns whether *anonymized* data collection is enabled.
  // This is used by the client to check whether the user has granted consent
  // for *anonymized* URL-keyed data collection. This currently governs
  // whether we send Suggest requests that include information about the
  // current page URL (when the user has enabled the MSBB opt-in).
  virtual bool IsUrlDataCollectionActive() const = 0;

  // Returns whether *personalized* data collection is enabled.
  // This is used by the client to check whether the user has granted consent
  // for *personalized* URL-keyed data collection keyed by their Google account.
  // This currently governs whether we send Suggest requests that include
  // information about the current page title (when the user has enabled the
  // History Sync opt-in).
  virtual bool IsPersonalizedUrlDataCollectionActive() const = 0;

  // This function returns true if the user is signed in.
  virtual bool IsAuthenticated() const = 0;

  // Determines whether sync is enabled.
  virtual bool IsSyncActive() const = 0;

  virtual std::string ProfileUserName() const;

  // Given some string |text| that the user wants to use for navigation,
  // determines how it should be interpreted.
  virtual void Classify(
      const std::u16string& text,
      bool prefer_keyword,
      bool allow_exact_keyword_match,
      metrics::OmniboxEventProto::PageClassification page_classification,
      AutocompleteMatch* match,
      GURL* alternate_nav_url) = 0;

  // Deletes all URL and search term entries matching the given |term| and
  // |keyword_id| from history.
  virtual void DeleteMatchingURLsForKeywordFromHistory(
      history::KeywordID keyword_id,
      const std::u16string& term) = 0;

  virtual void PrefetchImage(const GURL& url) = 0;

  // Sends a hint to the service worker context that navigation to
  // |destination_url| is likely, unless the current profile is in incognito
  // mode. On platforms where this is supported, the service worker lookup can
  // be expensive so this method should only be called once per input session.
  virtual void StartServiceWorker(const GURL& destination_url) {}

  // Called after creation of |keyword_provider| to allow the client to
  // configure the provider if desired.
  virtual void ConfigureKeywordProvider(KeywordProvider* keyword_provider) {}

  // Called to acquire the instance of TabMatcher, used to identify open tabs
  // for a given set of AutocompleteMatches within the current profile.
  virtual const TabMatcher& GetTabMatcher() const = 0;

  // Returns whether user is currently allowed to enter incognito mode.
  virtual bool IsIncognitoModeAvailable() const;

  // Returns true if the sharing hub command is enabled.
  virtual bool IsSharingHubAvailable() const;

  // Returns true if history embeddings is enabled and user has opted in.
  virtual bool IsHistoryEmbeddingsEnabled() const;

  // Returns true if history embeddings is enabled and user can opt in/out.
  virtual bool IsHistoryEmbeddingsSettingVisible() const;

  // Returns true if the current profile is eligible for Lens. This is used to
  // control whether Lens entrypoints can be shown during this browsing session.
  // Can be changed on demand via enterprise policy.
  virtual bool IsLensEnabled() const;

  // Returns true if the Lens entrypoints can be shown to the user at this
  // instant in time. This is false if Lens is already active, and therefore the
  // entrypoint shouldn't be shown as it will cause nothing to happen if
  // clicked. This is per tab dependent.
  virtual bool AreLensEntrypointsVisible() const;

  // Returns true if the page contains the paywall hint in the HTML. Returns
  // false if the page does not contain the paywall hint. Returns std::nullopt
  // if the page content wasn't extracted and therefore the signal could not be
  // calculated. This is used to control whether contextual suggestions can be
  // shown to the user.
  virtual std::optional<bool> IsPagePaywalled() const;

  // Returns whether the app is currently in the background state (Mobile only).
  virtual bool in_background_state() const;

  virtual void set_in_background_state(bool in_background_state) {}

  // Gets a weak pointer to the client. Used when providers need to use the
  // client when the client may no longer be around.
  virtual base::WeakPtr<AutocompleteProviderClient> GetWeakPtr();
};

#endif  // COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_PROVIDER_CLIENT_H_