2a05187a6af28ffa93aafbdd2f80f52aef3e9c43
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / location_bar / location_bar.h
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.
4
5 #ifndef CHROME_BROWSER_UI_LOCATION_BAR_LOCATION_BAR_H_
6 #define CHROME_BROWSER_UI_LOCATION_BAR_LOCATION_BAR_H_
7
8 #include "ui/base/page_transition_types.h"
9 #include "ui/base/window_open_disposition.h"
10 #include "url/gurl.h"
11
12 class ExtensionAction;
13 class LocationBarTesting;
14 class OmniboxView;
15 class Profile;
16
17 namespace content {
18 class WebContents;
19 }
20
21 namespace extensions {
22 class Extension;
23 }
24
25 // The LocationBar class is a virtual interface, defining access to the
26 // window's location bar component.  This class exists so that cross-platform
27 // components like the browser command system can talk to the platform
28 // specific implementations of the location bar control.  It also allows the
29 // location bar to be mocked for testing.
30 class LocationBar {
31  public:
32   explicit LocationBar(Profile* profile);
33
34   // Shows the first run bubble anchored to the location bar.
35   virtual void ShowFirstRunBubble() = 0;
36
37   // The details necessary to open the user's desired omnibox match.
38   virtual GURL GetDestinationURL() const = 0;
39   virtual WindowOpenDisposition GetWindowOpenDisposition() const = 0;
40   virtual ui::PageTransition GetPageTransition() const = 0;
41
42   // Accepts the current string of text entered in the location bar.
43   virtual void AcceptInput() = 0;
44
45   // Focuses the location bar.  Optionally also selects its contents.
46   virtual void FocusLocation(bool select_all) = 0;
47
48   // Clears the location bar, inserts an annoying little "?" turd and sets
49   // focus to it.
50   virtual void FocusSearch() = 0;
51
52   // Updates the state of the images showing the content settings status.
53   virtual void UpdateContentSettingsIcons() = 0;
54
55   // Updates the password icon and pops up a bubble from the icon if needed.
56   virtual void UpdateManagePasswordsIconAndBubble() = 0;
57
58   // Updates the state of the page actions.
59   virtual void UpdatePageActions() = 0;
60
61   // Updates the visibility of the bookmark star.
62   virtual void UpdateBookmarkStarVisibility() = 0;
63
64   // Called when the page-action data needs to be refreshed, e.g. when an
65   // extension is unloaded or crashes.
66   virtual void InvalidatePageActions() = 0;
67
68   // Shows the popup for the given |extension| and, if |grant_active_tab| is
69   // true, grants the extension active tab permissions.
70   // Returns true if a popup was shown.
71   virtual bool ShowPageActionPopup(const extensions::Extension* extension,
72                                    bool grant_active_tab) = 0;
73
74   // Updates the state of the button to open a PDF in Adobe Reader.
75   virtual void UpdateOpenPDFInReaderPrompt() = 0;
76
77   // Updates the generated credit card view. This view serves as an anchor for
78   // the generated credit card bubble, which can show on successful generation
79   // of a new credit card number.
80   virtual void UpdateGeneratedCreditCardView() = 0;
81
82   // Saves the state of the location bar to the specified WebContents, so that
83   // it can be restored later. (Done when switching tabs).
84   virtual void SaveStateToContents(content::WebContents* contents) = 0;
85
86   // Reverts the location bar.  The bar's permanent text will be shown.
87   virtual void Revert() = 0;
88
89   virtual const OmniboxView* GetOmniboxView() const = 0;
90   virtual OmniboxView* GetOmniboxView() = 0;
91
92   // Returns a pointer to the testing interface.
93   virtual LocationBarTesting* GetLocationBarForTesting() = 0;
94
95   Profile* profile() { return profile_; }
96
97  protected:
98   virtual ~LocationBar();
99
100   // Checks if any extension has requested that the bookmark star be hidden.
101   bool IsBookmarkStarHiddenByExtension() const;
102
103  private:
104   Profile* profile_;
105
106   DISALLOW_COPY_AND_ASSIGN(LocationBar);
107 };
108
109 class LocationBarTesting {
110  public:
111   // Returns the total number of page actions in the Omnibox.
112   virtual int PageActionCount() = 0;
113
114   // Returns the number of visible page actions in the Omnibox.
115   virtual int PageActionVisibleCount() = 0;
116
117   // Returns the ExtensionAction at |index|.
118   virtual ExtensionAction* GetPageAction(size_t index) = 0;
119
120   // Returns the visible ExtensionAction at |index|.
121   virtual ExtensionAction* GetVisiblePageAction(size_t index) = 0;
122
123   // Simulates a left mouse pressed on the visible page action at |index|.
124   virtual void TestPageActionPressed(size_t index) = 0;
125
126   // Returns whether or not the bookmark star decoration is visible.
127   virtual bool GetBookmarkStarVisibility() = 0;
128
129  protected:
130   virtual ~LocationBarTesting() {}
131 };
132
133 #endif  // CHROME_BROWSER_UI_LOCATION_BAR_LOCATION_BAR_H_