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 20 class ExtensionAction; 21 class LocationBarTesting; 22 class OmniboxView; 23 24 namespace content { 25 class WebContents; 26 } 27 28 class LocationBar { 29 public: 30 // Shows the first run bubble anchored to the location bar. 31 virtual void ShowFirstRunBubble() = 0; 32 33 // Returns the string of text entered in the location bar. 34 virtual string16 GetInputString() const = 0; 35 36 // Returns the WindowOpenDisposition that should be used to determine where 37 // to open a URL entered in the location bar. 38 virtual WindowOpenDisposition GetWindowOpenDisposition() const = 0; 39 40 // Returns the PageTransition that should be recorded in history when the URL 41 // entered in the location bar is loaded. 42 virtual content::PageTransition GetPageTransition() const = 0; 43 44 // Accepts the current string of text entered in the location bar. 45 virtual void AcceptInput() = 0; 46 47 // Focuses the location bar. Optionally also selects its contents. 48 virtual void FocusLocation(bool select_all) = 0; 49 50 // Clears the location bar, inserts an annoying little "?" turd and sets 51 // focus to it. 52 virtual void FocusSearch() = 0; 53 54 // Updates the state of the images showing the content settings status. 55 virtual void UpdateContentSettingsIcons() = 0; 56 57 // Updates the state of the page actions. 58 virtual void UpdatePageActions() = 0; 59 60 // Called when the page-action data needs to be refreshed, e.g. when an 61 // extension is unloaded or crashes. 62 virtual void InvalidatePageActions() = 0; 63 64 // Updates the state of the button to open a PDF in Adobe Reader. 65 virtual void UpdateOpenPDFInReaderPrompt() = 0; 66 67 // Updates the generated credit card view. This view serves as an anchor for 68 // the generated credit card bubble, which can show on successful generation 69 // of a new credit card number. 70 virtual void UpdateGeneratedCreditCardView() = 0; 71 72 // Saves the state of the location bar to the specified WebContents, so that 73 // it can be restored later. (Done when switching tabs). 74 virtual void SaveStateToContents(content::WebContents* contents) = 0; 75 76 // Reverts the location bar. The bar's permanent text will be shown. 77 virtual void Revert() = 0; 78 79 // Returns a pointer to the text entry view. 80 virtual const OmniboxView* GetLocationEntry() const = 0; 81 virtual OmniboxView* GetLocationEntry() = 0; 82 83 // Returns a pointer to the testing interface. 84 virtual LocationBarTesting* GetLocationBarForTesting() = 0; 85 86 protected: 87 virtual ~LocationBar() {} 88 }; 89 90 class LocationBarTesting { 91 public: 92 // Returns the total number of page actions in the Omnibox. 93 virtual int PageActionCount() = 0; 94 95 // Returns the number of visible page actions in the Omnibox. 96 virtual int PageActionVisibleCount() = 0; 97 98 // Returns the ExtensionAction at |index|. 99 virtual ExtensionAction* GetPageAction(size_t index) = 0; 100 101 // Returns the visible ExtensionAction at |index|. 102 virtual ExtensionAction* GetVisiblePageAction(size_t index) = 0; 103 104 // Simulates a left mouse pressed on the visible page action at |index|. 105 virtual void TestPageActionPressed(size_t index) = 0; 106 107 // Returns whether or not the bookmark star decoration is visible. 108 virtual bool GetBookmarkStarVisibility() = 0; 109 110 protected: 111 virtual ~LocationBarTesting() {} 112 }; 113 114 #endif // CHROME_BROWSER_UI_OMNIBOX_LOCATION_BAR_H_ 115