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 CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_CURRENT_PAGE_DELEGATE_H_
6 #define CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_CURRENT_PAGE_DELEGATE_H_
8 #include "base/basictypes.h"
9 #include "chrome/common/instant_types.h"
10 #include "chrome/common/omnibox_focus_state.h"
11 #include "ui/base/window_open_disposition.h"
16 struct AutocompleteMatch
;
19 class NavigationController
;
22 // A class that abstracts omnibox functionality that depends on the current
23 // tab/page (e.g., getting information about the current page, retrieving
24 // objects associated with the current tab, or performing operations that rely
25 // on such objects under the hood).
26 class OmniboxCurrentPageDelegate
{
28 virtual ~OmniboxCurrentPageDelegate() {}
30 // Returns whether there is any associated current page. For example, during
31 // startup or shutdown, the omnibox may exist but have no attached page.
32 virtual bool CurrentPageExists() const = 0;
34 // Returns the URL of the current page.
35 virtual const GURL
& GetURL() const = 0;
37 // Returns true if the visible entry is a New Tab Page rendered by Instant.
38 virtual bool IsInstantNTP() const = 0;
40 // Returns true if the committed entry is a search results page.
41 virtual bool IsSearchResultsPage() const = 0;
43 // Returns whether the current page is loading.
44 virtual bool IsLoading() const = 0;
46 // Returns the NavigationController for the current page.
47 virtual content::NavigationController
& GetNavigationController() const = 0;
49 // Returns the session ID of the current page.
50 virtual const SessionID
& GetSessionID() const = 0;
52 // Checks whether |template_url| is an extension keyword; if so, asks the
53 // ExtensionOmniboxEventRouter to process |match| for it and returns true.
54 // Otherwise returns false.
55 virtual bool ProcessExtensionKeyword(TemplateURL
* template_url
,
56 const AutocompleteMatch
& match
,
57 WindowOpenDisposition disposition
) = 0;
59 // Called to notify clients that the omnibox input state has changed.
60 virtual void OnInputStateChanged() = 0;
62 // Called to notify clients that the omnibox focus state has changed.
63 virtual void OnFocusChanged(OmniboxFocusState state
,
64 OmniboxFocusChangeReason reason
) = 0;
66 // Performs prerendering for |match|.
67 virtual void DoPrerender(const AutocompleteMatch
& match
) = 0;
69 // Sends the current SearchProvider suggestion to the Instant page if any.
70 virtual void SetSuggestionToPrefetch(const InstantSuggestion
& suggestion
) = 0;
73 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_CURRENT_PAGE_DELEGATE_H_