1 // Copyright (c) 2011 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 // This is an interface for the platform specific FindBar. It is responsible 6 // for drawing the FindBar bar on the platform and is owned by the 7 // FindBarController. 8 9 #ifndef CHROME_BROWSER_UI_FIND_BAR_FIND_BAR_H_ 10 #define CHROME_BROWSER_UI_FIND_BAR_FIND_BAR_H_ 11 12 #include "base/strings/string16.h" 13 #include "ui/gfx/rect.h" 14 15 class FindBarController; 16 class FindBarTesting; 17 class FindNotificationDetails; 18 19 class FindBar { 20 public: 21 virtual ~FindBar() { } 22 23 // Accessor and setter for the FindBarController. 24 virtual FindBarController* GetFindBarController() const = 0; 25 virtual void SetFindBarController( 26 FindBarController* find_bar_controller) = 0; 27 28 // Shows the find bar. Any previous search string will again be visible. 29 // If |animate| is true, we try to slide the find bar in. 30 virtual void Show(bool animate) = 0; 31 32 // Hide the find bar. If |animate| is true, we try to slide the find bar 33 // away. 34 virtual void Hide(bool animate) = 0; 35 36 // Restore the selected text in the find box and focus it. 37 virtual void SetFocusAndSelection() = 0; 38 39 // Clear the text in the find box. 40 virtual void ClearResults(const FindNotificationDetails& results) = 0; 41 42 // Stop the animation. 43 virtual void StopAnimation() = 0; 44 45 // If the find bar obscures the search results we need to move the window. To 46 // do that we need to know what is selected on the page. We simply calculate 47 // where it would be if we place it on the left of the selection and if it 48 // doesn't fit on the screen we try the right side. The parameter 49 // |selection_rect| is expected to have coordinates relative to the top of 50 // the web page area. If |no_redraw| is true, the window will be moved without 51 // redrawing siblings. 52 virtual void MoveWindowIfNecessary(const gfx::Rect& selection_rect, 53 bool no_redraw) = 0; 54 55 // Set the text in the find box. 56 virtual void SetFindText(const string16& find_text) = 0; 57 58 // Updates the FindBar with the find result details contained within the 59 // specified |result|. 60 virtual void UpdateUIForFindResult(const FindNotificationDetails& result, 61 const string16& find_text) = 0; 62 63 // No match was found; play an audible alert. 64 virtual void AudibleAlert() = 0; 65 66 virtual bool IsFindBarVisible() = 0; 67 68 // Upon dismissing the window, restore focus to the last focused view which is 69 // not FindBarView or any of its children. 70 virtual void RestoreSavedFocus() = 0; 71 72 // Returns true if all tabs use a single find pasteboard. 73 virtual bool HasGlobalFindPasteboard() = 0; 74 75 // Called when the web contents associated with the find bar changes. 76 virtual void UpdateFindBarForChangedWebContents() = 0; 77 78 // Returns a pointer to the testing interface to the FindBar, or NULL 79 // if there is none. 80 virtual FindBarTesting* GetFindBarTesting() = 0; 81 }; 82 83 class FindBarTesting { 84 public: 85 virtual ~FindBarTesting() { } 86 87 // Computes the location of the find bar and whether it is fully visible in 88 // its parent window. The return value indicates if the window is visible at 89 // all. Both out arguments are optional. 90 // 91 // This is used for UI tests of the find bar. If the find bar is not currently 92 // shown (return value of false), the out params will be {(0, 0), false}. 93 virtual bool GetFindBarWindowInfo(gfx::Point* position, 94 bool* fully_visible) = 0; 95 96 // Gets the search string currently visible in the Find box. 97 virtual string16 GetFindText() = 0; 98 99 // Gets the search string currently selected in the Find box. 100 virtual string16 GetFindSelectedText() = 0; 101 102 // Gets the match count text (ie. 1 of 3) visible in the Find box. 103 virtual string16 GetMatchCountText() = 0; 104 105 // Gets the pixel width of the FindBar. 106 virtual int GetWidth() = 0; 107 }; 108 109 #endif // CHROME_BROWSER_UI_FIND_BAR_FIND_BAR_H_ 110