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