Home | History | Annotate | Download | only in omnibox
      1 // Copyright (c) 2012 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_EDIT_CONTROLLER_H_
      6 #define CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_CONTROLLER_H_
      7 
      8 #include "base/strings/string16.h"
      9 #include "content/public/common/page_transition_types.h"
     10 #include "ui/base/window_open_disposition.h"
     11 
     12 class GURL;
     13 class InstantController;
     14 
     15 namespace content {
     16 class WebContents;
     17 }
     18 
     19 namespace gfx {
     20 class Image;
     21 }
     22 
     23 // I am in hack-and-slash mode right now.
     24 // http://code.google.com/p/chromium/issues/detail?id=6772
     25 
     26 // Embedders of an AutocompleteEdit widget must implement this class.
     27 class OmniboxEditController {
     28  public:
     29   // When the user presses enter or selects a line with the mouse, this
     30   // function will get called synchronously with the url to open and
     31   // disposition and transition to use when opening it.
     32   //
     33   // |alternate_nav_url|, if non-empty, contains the alternate navigation URL
     34   // for |url|, which the controller can check for existence.  See comments on
     35   // AutocompleteResult::GetAlternateNavURL().
     36   virtual void OnAutocompleteAccept(const GURL& url,
     37                                     WindowOpenDisposition disposition,
     38                                     content::PageTransition transition,
     39                                     const GURL& alternate_nav_url) = 0;
     40 
     41   // Called when anything has changed that might affect the layout or contents
     42   // of the views around the edit, including the text of the edit and the
     43   // status of any keyword- or hint-related state.
     44   virtual void OnChanged() = 0;
     45 
     46   // Called when the selection of the OmniboxView changes.
     47   virtual void OnSelectionBoundsChanged() = 0;
     48 
     49   // Called whenever the user starts or stops an input session (typing,
     50   // interacting with the edit, etc.).  When user input is not in progress,
     51   // the edit is guaranteed to be showing the permanent text.
     52   virtual void OnInputInProgress(bool in_progress) = 0;
     53 
     54   // Called whenever the autocomplete edit is losing focus.
     55   virtual void OnKillFocus() = 0;
     56 
     57   // Called whenever the autocomplete edit gets focused.
     58   virtual void OnSetFocus() = 0;
     59 
     60   // Returns the favicon of the current page.
     61   virtual gfx::Image GetFavicon() const = 0;
     62 
     63   // Returns the title of the current page.
     64   virtual string16 GetTitle() const = 0;
     65 
     66   // Returns the InstantController, or NULL if instant is not enabled.
     67   virtual InstantController* GetInstant() = 0;
     68 
     69   // Returns the WebContents of the currently active tab.
     70   virtual content::WebContents* GetWebContents() const = 0;
     71 
     72  protected:
     73   virtual ~OmniboxEditController() {}
     74 };
     75 
     76 #endif  // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_CONTROLLER_H_
     77