Home | History | Annotate | Download | only in omnibox
      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.
      4 
      5 #ifndef CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_CURRENT_PAGE_DELEGATE_H_
      6 #define CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_CURRENT_PAGE_DELEGATE_H_
      7 
      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"
     12 
     13 class GURL;
     14 class SessionID;
     15 class TemplateURL;
     16 struct AutocompleteMatch;
     17 
     18 namespace content {
     19 class NavigationController;
     20 }
     21 
     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 {
     27  public:
     28   virtual ~OmniboxCurrentPageDelegate() {}
     29 
     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;
     33 
     34   // Returns the URL of the current page.
     35   virtual const GURL& GetURL() const = 0;
     36 
     37   // Returns true if the visible entry is a New Tab Page rendered by Instant.
     38   virtual bool IsInstantNTP() const = 0;
     39 
     40   // Returns true if the committed entry is a search results page.
     41   virtual bool IsSearchResultsPage() const = 0;
     42 
     43   // Returns whether the current page is loading.
     44   virtual bool IsLoading() const = 0;
     45 
     46   // Returns the NavigationController for the current page.
     47   virtual content::NavigationController& GetNavigationController() const = 0;
     48 
     49   // Returns the session ID of the current page.
     50   virtual const SessionID& GetSessionID() const = 0;
     51 
     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;
     58 
     59   // Called to notify clients that the omnibox input state has changed.
     60   virtual void OnInputStateChanged() = 0;
     61 
     62   // Called to notify clients that the omnibox focus state has changed.
     63   virtual void OnFocusChanged(OmniboxFocusState state,
     64                               OmniboxFocusChangeReason reason) = 0;
     65 
     66   // Performs prerendering for |match|.
     67   virtual void DoPrerender(const AutocompleteMatch& match) = 0;
     68 
     69   // Sends the current SearchProvider suggestion to the Instant page if any.
     70   virtual void SetSuggestionToPrefetch(const InstantSuggestion& suggestion) = 0;
     71 };
     72 
     73 #endif  // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_CURRENT_PAGE_DELEGATE_H_
     74