OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 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_LOCATION_BAR_H_ | |
12 #define CHROME_BROWSER_LOCATION_BAR_H_ | |
13 #pragma once | |
14 | |
15 #include <string> | |
16 | |
17 #include "base/string16.h" | |
18 #include "chrome/browser/first_run/first_run.h" | |
19 #include "chrome/common/page_transition_types.h" | |
20 #include "webkit/glue/window_open_disposition.h" | |
21 | |
22 class AutocompleteEditView; | |
23 class ExtensionAction; | |
24 class LocationBarTesting; | |
25 class TabContents; | |
26 | |
27 class LocationBar { | |
28 public: | |
29 // Shows the first run information bubble anchored to the location bar. | |
30 virtual void ShowFirstRunBubble(FirstRun::BubbleType bubble_type) = 0; | |
31 | |
32 // Sets the suggested text to show in the omnibox. This is shown in addition | |
33 // to the current text of the omnibox. | |
34 virtual void SetSuggestedText(const string16& text) = 0; | |
35 | |
36 // Returns the string of text entered in the location bar. | |
37 virtual std::wstring GetInputString() const = 0; | |
38 | |
39 // Returns the WindowOpenDisposition that should be used to determine where | |
40 // to open a URL entered in the location bar. | |
41 virtual WindowOpenDisposition GetWindowOpenDisposition() const = 0; | |
42 | |
43 // Returns the PageTransition that should be recorded in history when the URL | |
44 // entered in the location bar is loaded. | |
45 virtual PageTransition::Type GetPageTransition() const = 0; | |
46 | |
47 // Accepts the current string of text entered in the location bar. | |
48 virtual void AcceptInput() = 0; | |
49 | |
50 // Focuses the location bar. Optionally also selects its contents. | |
51 virtual void FocusLocation(bool select_all) = 0; | |
52 | |
53 // Clears the location bar, inserts an annoying little "?" turd and sets | |
54 // focus to it. | |
55 virtual void FocusSearch() = 0; | |
56 | |
57 // Updates the state of the images showing the content settings status. | |
58 virtual void UpdateContentSettingsIcons() = 0; | |
59 | |
60 // Updates the state of the page actions. | |
61 virtual void UpdatePageActions() = 0; | |
62 | |
63 // Called when the page-action data needs to be refreshed, e.g. when an | |
64 // extension is unloaded or crashes. | |
65 virtual void InvalidatePageActions() = 0; | |
66 | |
67 // Saves the state of the location bar to the specified TabContents, so that | |
68 // it can be restored later. (Done when switching tabs). | |
69 virtual void SaveStateToContents(TabContents* 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 AutocompleteEditView* location_entry() const = 0; | |
76 virtual AutocompleteEditView* location_entry() = 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 protected: | |
103 virtual ~LocationBarTesting() {} | |
104 }; | |
105 | |
106 #endif // CHROME_BROWSER_LOCATION_BAR_H_ | |
OLD | NEW |