[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / omnibox / location_bar.h
blobef553127ac64dbda6886bde527b3469cf4c31f35
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.
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.
11 #ifndef CHROME_BROWSER_UI_OMNIBOX_LOCATION_BAR_H_
12 #define CHROME_BROWSER_UI_OMNIBOX_LOCATION_BAR_H_
14 #include <string>
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"
21 class ExtensionAction;
22 class LocationBarTesting;
23 class OmniboxView;
24 class Profile;
26 namespace content {
27 class WebContents;
30 class LocationBar {
31 public:
32 explicit LocationBar(Profile* profile);
34 // Shows the first run bubble anchored to the location bar.
35 virtual void ShowFirstRunBubble() = 0;
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 content::PageTransition GetPageTransition() const = 0;
42 // Accepts the current string of text entered in the location bar.
43 virtual void AcceptInput() = 0;
45 // Focuses the location bar. Optionally also selects its contents.
46 virtual void FocusLocation(bool select_all) = 0;
48 // Clears the location bar, inserts an annoying little "?" turd and sets
49 // focus to it.
50 virtual void FocusSearch() = 0;
52 // Updates the state of the images showing the content settings status.
53 virtual void UpdateContentSettingsIcons() = 0;
55 // Updates the password icon and pops up a bubble from the icon if needed.
56 virtual void UpdateManagePasswordsIconAndBubble() = 0;
58 // Updates the state of the page actions.
59 virtual void UpdatePageActions() = 0;
61 // Called when the page-action data needs to be refreshed, e.g. when an
62 // extension is unloaded or crashes.
63 virtual void InvalidatePageActions() = 0;
65 // Updates the state of the button to open a PDF in Adobe Reader.
66 virtual void UpdateOpenPDFInReaderPrompt() = 0;
68 // Updates the generated credit card view. This view serves as an anchor for
69 // the generated credit card bubble, which can show on successful generation
70 // of a new credit card number.
71 virtual void UpdateGeneratedCreditCardView() = 0;
73 // Saves the state of the location bar to the specified WebContents, so that
74 // it can be restored later. (Done when switching tabs).
75 virtual void SaveStateToContents(content::WebContents* contents) = 0;
77 // Reverts the location bar. The bar's permanent text will be shown.
78 virtual void Revert() = 0;
80 virtual const OmniboxView* GetOmniboxView() const = 0;
81 virtual OmniboxView* GetOmniboxView() = 0;
83 // Returns a pointer to the testing interface.
84 virtual LocationBarTesting* GetLocationBarForTesting() = 0;
86 Profile* profile() { return profile_; }
88 protected:
89 virtual ~LocationBar();
91 // Checks if any extension has requested that the bookmark star be hidden.
92 bool IsBookmarkStarHiddenByExtension() const;
94 private:
95 Profile* profile_;
97 DISALLOW_COPY_AND_ASSIGN(LocationBar);
100 class LocationBarTesting {
101 public:
102 // Returns the total number of page actions in the Omnibox.
103 virtual int PageActionCount() = 0;
105 // Returns the number of visible page actions in the Omnibox.
106 virtual int PageActionVisibleCount() = 0;
108 // Returns the ExtensionAction at |index|.
109 virtual ExtensionAction* GetPageAction(size_t index) = 0;
111 // Returns the visible ExtensionAction at |index|.
112 virtual ExtensionAction* GetVisiblePageAction(size_t index) = 0;
114 // Simulates a left mouse pressed on the visible page action at |index|.
115 virtual void TestPageActionPressed(size_t index) = 0;
117 // Returns whether or not the bookmark star decoration is visible.
118 virtual bool GetBookmarkStarVisibility() = 0;
120 protected:
121 virtual ~LocationBarTesting() {}
124 #endif // CHROME_BROWSER_UI_OMNIBOX_LOCATION_BAR_H_