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