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.
5 #ifndef COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_PROVIDER_CLIENT_H_
6 #define COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_PROVIDER_CLIENT_H_
10 #include "base/memory/ref_counted.h"
11 #include "base/strings/string16.h"
12 #include "components/history/core/browser/keyword_id.h"
13 #include "components/history/core/browser/top_sites.h"
14 #include "components/metrics/proto/omnibox_event.pb.h"
15 #include "components/omnibox/browser/keyword_extensions_delegate.h"
16 #include "components/omnibox/browser/shortcuts_backend.h"
18 class AutocompleteController
;
19 struct AutocompleteMatch
;
20 class AutocompleteClassifier
;
21 class AutocompleteSchemeClassifier
;
23 class InMemoryURLIndex
;
24 class KeywordProvider
;
26 class ShortcutsBackend
;
38 class URLRequestContextGetter
;
41 class SearchTermsData
;
42 class TemplateURLService
;
44 class AutocompleteProviderClient
{
46 virtual ~AutocompleteProviderClient() {}
48 virtual net::URLRequestContextGetter
* GetRequestContext() = 0;
49 virtual PrefService
* GetPrefs() = 0;
50 virtual const AutocompleteSchemeClassifier
& GetSchemeClassifier() const = 0;
51 virtual AutocompleteClassifier
* GetAutocompleteClassifier() = 0;
52 virtual history::HistoryService
* GetHistoryService() = 0;
53 virtual scoped_refptr
<history::TopSites
> GetTopSites() = 0;
54 virtual bookmarks::BookmarkModel
* GetBookmarkModel() = 0;
55 virtual history::URLDatabase
* GetInMemoryDatabase() = 0;
56 virtual InMemoryURLIndex
* GetInMemoryURLIndex() = 0;
57 virtual TemplateURLService
* GetTemplateURLService() = 0;
58 virtual const TemplateURLService
* GetTemplateURLService() const = 0;
59 virtual const SearchTermsData
& GetSearchTermsData() const = 0;
60 virtual scoped_refptr
<ShortcutsBackend
> GetShortcutsBackend() = 0;
61 virtual scoped_refptr
<ShortcutsBackend
> GetShortcutsBackendIfExists() = 0;
62 virtual scoped_ptr
<KeywordExtensionsDelegate
> GetKeywordExtensionsDelegate(
63 KeywordProvider
* keyword_provider
) = 0;
65 // The value to use for Accept-Languages HTTP header when making an HTTP
67 virtual std::string
GetAcceptLanguages() const = 0;
69 // The embedder's representation of the |about| URL scheme for builtin URLs
70 // (e.g., |chrome| for Chrome).
71 virtual std::string
GetEmbedderRepresentationOfAboutScheme() = 0;
73 // The set of built-in URLs considered worth suggesting as autocomplete
74 // suggestions to the user. Some built-in URLs, e.g. hidden URLs that
75 // intentionally crash the product for testing purposes, may be omitted from
76 // this list if suggesting them is undesirable.
77 virtual std::vector
<base::string16
> GetBuiltinURLs() = 0;
79 // The set of URLs to provide as autocomplete suggestions as the user types a
80 // prefix of the |about| scheme or the embedder's representation of that
81 // scheme. Note that this may be a subset of GetBuiltinURLs(), e.g., only the
82 // most commonly-used URLs from that set.
83 virtual std::vector
<base::string16
> GetBuiltinsToProvideAsUserTypes() = 0;
85 virtual bool IsOffTheRecord() const = 0;
86 virtual bool SearchSuggestEnabled() const = 0;
88 // Returns whether the bookmark bar is visible on all tabs.
89 virtual bool BookmarkBarIsVisible() const = 0;
91 virtual bool TabSyncEnabledAndUnencrypted() const = 0;
93 // Given some string |text| that the user wants to use for navigation,
94 // determines how it should be interpreted.
95 virtual void Classify(
96 const base::string16
& text
,
98 bool allow_exact_keyword_match
,
99 metrics::OmniboxEventProto::PageClassification page_classification
,
100 AutocompleteMatch
* match
,
101 GURL
* alternate_nav_url
) = 0;
103 // Deletes all URL and search term entries matching the given |term| and
104 // |keyword_id| from history.
105 virtual void DeleteMatchingURLsForKeywordFromHistory(
106 history::KeywordID keyword_id
,
107 const base::string16
& term
) = 0;
109 virtual void PrefetchImage(const GURL
& url
) = 0;
111 // Called by |controller| when its results have changed and all providers are
112 // done processing the autocomplete request. At the //chrome level, this
113 // callback results in firing the
114 // NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY notification.
115 // TODO(blundell): Remove the //chrome-level notification entirely in favor of
116 // having AutocompleteController expose a CallbackList that //chrome-level
117 // listeners add themselves to, and then kill this method.
118 virtual void OnAutocompleteControllerResultReady(
119 AutocompleteController
* controller
) {}
121 // Called after creation of |keyword_provider| to allow the client to
122 // configure the provider if desired.
123 virtual void ConfigureKeywordProvider(KeywordProvider
* keyword_provider
) {}
126 #endif // COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_PROVIDER_CLIENT_H_