Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / components / omnibox / browser / omnibox_client.h
blob77c90796ea8337f53f2a88c9d9ef3ce843ce8a91
1 // Copyright 2013 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_OMNIBOX_CLIENT_H_
6 #define COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_CLIENT_H_
8 #include "base/basictypes.h"
9 #include "components/omnibox/browser/autocomplete_provider_client.h"
10 #include "components/omnibox/browser/omnibox_navigation_observer.h"
11 #include "components/omnibox/common/omnibox_focus_state.h"
12 #include "ui/base/window_open_disposition.h"
14 class AutocompleteResult;
15 class GURL;
16 class SessionID;
17 class TemplateURL;
18 class TemplateURLService;
19 struct AutocompleteMatch;
20 struct OmniboxLog;
22 namespace bookmarks {
23 class BookmarkModel;
26 namespace gfx {
27 class Image;
30 typedef base::Callback<void(const SkBitmap& bitmap)> BitmapFetchedCallback;
32 // Interface that allows the omnibox component to interact with its embedder
33 // (e.g., getting information about the current page, retrieving objects
34 // associated with the current tab, or performing operations that rely on such
35 // objects under the hood).
36 class OmniboxClient {
37 public:
38 virtual ~OmniboxClient() {}
40 // Returns an AutocompleteProviderClient specific to the embedder context.
41 virtual scoped_ptr<AutocompleteProviderClient>
42 CreateAutocompleteProviderClient() = 0;
44 // Returns an OmniboxNavigationObserver specific to the embedder context. May
45 // return null if the embedder has no need to observe omnibox navigations.
46 virtual scoped_ptr<OmniboxNavigationObserver> CreateOmniboxNavigationObserver(
47 const base::string16& text,
48 const AutocompleteMatch& match,
49 const AutocompleteMatch& alternate_nav_match) = 0;
51 // Returns whether there is any associated current page. For example, during
52 // startup or shutdown, the omnibox may exist but have no attached page.
53 virtual bool CurrentPageExists() const = 0;
55 // Returns the URL of the current page.
56 virtual const GURL& GetURL() const = 0;
58 // Returns the title of the current page.
59 virtual const base::string16& GetTitle() const = 0;
61 // Returns the favicon of the current page.
62 virtual gfx::Image GetFavicon() const = 0;
64 // Returns true if the visible entry is a New Tab Page rendered by Instant.
65 virtual bool IsInstantNTP() const = 0;
67 // Returns true if the committed entry is a search results page.
68 virtual bool IsSearchResultsPage() const = 0;
70 // Returns whether the current page is loading.
71 virtual bool IsLoading() const = 0;
73 // Returns whether paste-and-go functionality is enabled.
74 virtual bool IsPasteAndGoEnabled() const = 0;
76 // Returns whether |url| corresponds to the new tab page.
77 virtual bool IsNewTabPage(const std::string& url) const = 0;
79 // Returns whether |url| corresponds to the user's home page.
80 virtual bool IsHomePage(const std::string& url) const = 0;
82 // Returns the session ID of the current page.
83 virtual const SessionID& GetSessionID() const = 0;
85 virtual bookmarks::BookmarkModel* GetBookmarkModel() = 0;
86 virtual TemplateURLService* GetTemplateURLService() = 0;
87 virtual const AutocompleteSchemeClassifier& GetSchemeClassifier() const = 0;
88 virtual AutocompleteClassifier* GetAutocompleteClassifier() = 0;
90 // Returns the icon corresponding to |match| if match is an extension match
91 // and an empty icon otherwise.
92 virtual gfx::Image GetIconIfExtensionMatch(
93 const AutocompleteMatch& match) const = 0;
95 // Checks whether |template_url| is an extension keyword; if so, asks the
96 // ExtensionOmniboxEventRouter to process |match| for it and returns true.
97 // Otherwise returns false. |observer| is the OmniboxNavigationObserver
98 // that was created by CreateOmniboxNavigationObserver() for |match|; in some
99 // embedding contexts, processing an extension keyword involves invoking
100 // action on this observer.
101 virtual bool ProcessExtensionKeyword(TemplateURL* template_url,
102 const AutocompleteMatch& match,
103 WindowOpenDisposition disposition,
104 OmniboxNavigationObserver* observer) = 0;
106 // Called to notify clients that the omnibox input state has changed.
107 virtual void OnInputStateChanged() = 0;
109 // Called to notify clients that the omnibox focus state has changed.
110 virtual void OnFocusChanged(OmniboxFocusState state,
111 OmniboxFocusChangeReason reason) = 0;
113 // Called when the autocomplete result has changed. If the embedder supports
114 // fetching of bitmaps for URLs (not all embedders do), |on_bitmap_fetched|
115 // will be called when the bitmap has been fetched.
116 virtual void OnResultChanged(
117 const AutocompleteResult& result,
118 bool default_match_changed,
119 const BitmapFetchedCallback& on_bitmap_fetched) = 0;
121 // Called when the current autocomplete match has changed.
122 virtual void OnCurrentMatchChanged(const AutocompleteMatch& match) = 0;
124 // Called when the text may have changed in the edit.
125 virtual void OnTextChanged(const AutocompleteMatch& current_match,
126 bool user_input_in_progress,
127 base::string16& user_text,
128 const AutocompleteResult& result,
129 bool is_popup_open,
130 bool has_focus) = 0;
132 // Called when input has been accepted.
133 virtual void OnInputAccepted(const AutocompleteMatch& match) = 0;
135 // Called when the edit model is being reverted back to its unedited state.
136 virtual void OnRevert() = 0;
138 // Called to notify clients that a URL was opened from the omnibox.
139 virtual void OnURLOpenedFromOmnibox(OmniboxLog* log) = 0;
141 // Called when a bookmark is launched from the omnibox.
142 virtual void OnBookmarkLaunched() = 0;
144 // Discards the state for all pending and transient navigations.
145 virtual void DiscardNonCommittedNavigations() = 0;
148 #endif // COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_CLIENT_H_