blob: b55a96130c718240fc92c9e47ef2352252ac1ffb [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_AUTOCOMPLETE_CHROME_AUTOCOMPLETE_PROVIDER_CLIENT_H_
#define CHROME_BROWSER_AUTOCOMPLETE_CHROME_AUTOCOMPLETE_PROVIDER_CLIENT_H_
#include "base/macros.h"
#include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
#include "components/omnibox/browser/autocomplete_provider_client.h"
class Profile;
namespace content {
class StoragePartition;
class WebContents;
}
namespace unified_consent {
class UrlKeyedDataCollectionConsentHelper;
}
class ChromeAutocompleteProviderClient : public AutocompleteProviderClient {
public:
explicit ChromeAutocompleteProviderClient(Profile* profile);
~ChromeAutocompleteProviderClient() override;
// AutocompleteProviderClient:
scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override;
PrefService* GetPrefs() override;
const AutocompleteSchemeClassifier& GetSchemeClassifier() const override;
AutocompleteClassifier* GetAutocompleteClassifier() override;
history::HistoryService* GetHistoryService() override;
scoped_refptr<history::TopSites> GetTopSites() override;
bookmarks::BookmarkModel* GetBookmarkModel() override;
history::URLDatabase* GetInMemoryDatabase() override;
InMemoryURLIndex* GetInMemoryURLIndex() override;
TemplateURLService* GetTemplateURLService() override;
const TemplateURLService* GetTemplateURLService() const override;
RemoteSuggestionsService* GetRemoteSuggestionsService(
bool create_if_necessary) const override;
DocumentSuggestionsService* GetDocumentSuggestionsService(
bool create_if_necessary) const override;
OmniboxPedalProvider* GetPedalProvider() const override;
scoped_refptr<ShortcutsBackend> GetShortcutsBackend() override;
scoped_refptr<ShortcutsBackend> GetShortcutsBackendIfExists() override;
std::unique_ptr<KeywordExtensionsDelegate> GetKeywordExtensionsDelegate(
KeywordProvider* keyword_provider) override;
std::string GetAcceptLanguages() const override;
std::string GetEmbedderRepresentationOfAboutScheme() const override;
std::vector<base::string16> GetBuiltinURLs() override;
std::vector<base::string16> GetBuiltinsToProvideAsUserTypes() override;
component_updater::ComponentUpdateService* GetComponentUpdateService()
override;
bool IsOffTheRecord() const override;
bool SearchSuggestEnabled() const override;
bool IsPersonalizedUrlDataCollectionActive() const override;
bool IsAuthenticated() const override;
bool IsSyncActive() const override;
std::string ProfileUserName() const override;
void Classify(
const base::string16& text,
bool prefer_keyword,
bool allow_exact_keyword_match,
metrics::OmniboxEventProto::PageClassification page_classification,
AutocompleteMatch* match,
GURL* alternate_nav_url) override;
void DeleteMatchingURLsForKeywordFromHistory(
history::KeywordID keyword_id,
const base::string16& term) override;
void PrefetchImage(const GURL& url) override;
void StartServiceWorker(const GURL& destination_url) override;
bool IsTabOpenWithURL(const GURL& url,
const AutocompleteInput* input) override;
bool IsBrowserUpdateAvailable() const override;
// For testing.
void set_storage_partition(content::StoragePartition* storage_partition) {
storage_partition_ = storage_partition;
}
bool StrippedURLsAreEqual(const GURL& url1,
const GURL& url2,
const AutocompleteInput* input) const;
// Performs a comparison of |stripped_url| to the stripped last committed
// URL of |web_contents|, using the internal cache to avoid repeatedly
// re-stripping the URL.
bool IsStrippedURLEqualToWebContentsURL(const GURL& stripped_url,
content::WebContents* web_contents);
private:
Profile* profile_;
ChromeAutocompleteSchemeClassifier scheme_classifier_;
std::unique_ptr<OmniboxPedalProvider> pedal_provider_;
std::unique_ptr<unified_consent::UrlKeyedDataCollectionConsentHelper>
url_consent_helper_;
// Injectable storage partitiion, used for testing.
content::StoragePartition* storage_partition_;
DISALLOW_COPY_AND_ASSIGN(ChromeAutocompleteProviderClient);
};
#endif // CHROME_BROWSER_AUTOCOMPLETE_CHROME_AUTOCOMPLETE_PROVIDER_CLIENT_H_