[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / find_bar / find_bar.h
blob9fd85ef4581fc1ae10604e7d740c08c23b52c5db
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/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. If |no_redraw| is true, the window will be moved without
55 // redrawing siblings.
56 virtual void MoveWindowIfNecessary(const gfx::Rect& selection_rect,
57 bool no_redraw) = 0;
59 // Set the text in the find box.
60 virtual void SetFindTextAndSelectedRange(
61 const base::string16& find_text,
62 const gfx::Range& selected_range) = 0;
64 // Gets the search string currently visible in the find box.
65 virtual base::string16 GetFindText() = 0;
67 // Gets the selection.
68 virtual gfx::Range GetSelectedRange() = 0;
70 // Updates the FindBar with the find result details contained within the
71 // specified |result|.
72 virtual void UpdateUIForFindResult(const FindNotificationDetails& result,
73 const base::string16& find_text) = 0;
75 // No match was found; play an audible alert.
76 virtual void AudibleAlert() = 0;
78 virtual bool IsFindBarVisible() = 0;
80 // Upon dismissing the window, restore focus to the last focused view which is
81 // not FindBarView or any of its children.
82 virtual void RestoreSavedFocus() = 0;
84 // Returns true if all tabs use a single find pasteboard.
85 virtual bool HasGlobalFindPasteboard() = 0;
87 // Called when the web contents associated with the find bar changes.
88 virtual void UpdateFindBarForChangedWebContents() = 0;
90 // Returns a pointer to the testing interface to the FindBar, or NULL
91 // if there is none.
92 virtual FindBarTesting* GetFindBarTesting() = 0;
95 class FindBarTesting {
96 public:
97 virtual ~FindBarTesting() { }
99 // Computes the location of the find bar and whether it is fully visible in
100 // its parent window. The return value indicates if the window is visible at
101 // all. Both out arguments are optional.
103 // This is used for UI tests of the find bar. If the find bar is not currently
104 // shown (return value of false), the out params will be {(0, 0), false}.
105 virtual bool GetFindBarWindowInfo(gfx::Point* position,
106 bool* fully_visible) = 0;
108 // Gets the search string currently selected in the Find box.
109 virtual base::string16 GetFindSelectedText() = 0;
111 // Gets the match count text (ie. 1 of 3) visible in the Find box.
112 virtual base::string16 GetMatchCountText() = 0;
114 // Gets the pixel width of the FindBar.
115 virtual int GetWidth() = 0;
118 #endif // CHROME_BROWSER_UI_FIND_BAR_FIND_BAR_H_