1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
// Copyright 2011 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// This is an interface for the platform specific FindBar. It is responsible
// for drawing the FindBar bar on the platform and is owned by the
// FindBarController.
#ifndef CHROME_BROWSER_UI_FIND_BAR_FIND_BAR_H_
#define CHROME_BROWSER_UI_FIND_BAR_FIND_BAR_H_
#include <string>
#include "build/build_config.h"
class FindBarController;
class FindBarTesting;
namespace find_in_page {
class FindNotificationDetails;
}
namespace gfx {
class Point;
class Range;
} // namespace gfx
#if BUILDFLAG(IS_MAC)
namespace views {
class Widget;
}
#endif
class FindBar {
public:
virtual ~FindBar() {}
// Accessor and setter for the FindBarController.
virtual FindBarController* GetFindBarController() const = 0;
virtual void SetFindBarController(FindBarController* find_bar_controller) = 0;
// Shows the find bar. Any previous search string will again be visible.
// If `animate` is true, we try to slide the find bar in.
// If `focus` is true, the find bar takes focus and accepts keyboard input.
virtual void Show(bool animate, bool focus) = 0;
// Hide the find bar. If |animate| is true, we try to slide the find bar
// away.
virtual void Hide(bool animate) = 0;
// Restore the selected text in the find box and focus it.
virtual void SetFocusAndSelection() = 0;
// Clear the text in the find box.
virtual void ClearResults(
const find_in_page::FindNotificationDetails& results) = 0;
// Stop the animation.
virtual void StopAnimation() = 0;
// Repaints and lays out the find bar window relative to the view layout state
// of the current browser window.
virtual void MoveWindowIfNecessary() = 0;
// Set the text in the find box.
virtual void SetFindTextAndSelectedRange(
const std::u16string& find_text,
const gfx::Range& selected_range) = 0;
// Gets the search string currently visible in the find box.
virtual std::u16string_view GetFindText() const = 0;
// Gets the selection.
virtual gfx::Range GetSelectedRange() const = 0;
// Updates the FindBar with the find result details contained within the
// specified |result|.
virtual void UpdateUIForFindResult(
const find_in_page::FindNotificationDetails& result,
const std::u16string& find_text) = 0;
// No match was found; play an audible alert.
virtual void AudibleAlert() = 0;
virtual bool IsFindBarVisible() const = 0;
// Upon dismissing the window, restore focus to the last focused view which is
// not FindBarView or any of its children.
virtual void RestoreSavedFocus() = 0;
// Returns true if all tabs use a single find pasteboard.
virtual bool HasGlobalFindPasteboard() const = 0;
// Called when the web contents associated with the find bar changes.
virtual void UpdateFindBarForChangedWebContents() = 0;
// Returns a pointer to the testing interface to the FindBar, or NULL
// if there is none.
virtual const FindBarTesting* GetFindBarTesting() const = 0;
// Return |true| if find bar has focus.
virtual bool HasFocus() const = 0;
#if BUILDFLAG(IS_MAC)
// Get the host widget. Used by immersive fullscreen to detect the find bar
// widget and reparent as necessary.
virtual views::Widget* GetHostWidget() = 0;
#endif
};
class FindBarTesting {
public:
virtual ~FindBarTesting() {}
// Computes the location of the find bar and whether it is fully visible in
// its parent window. The return value indicates if the window is visible at
// all. Both out arguments are optional.
//
// This is used for UI tests of the find bar. If the find bar is not currently
// shown (return value of false), the out params will be {(0, 0), false}.
virtual bool GetFindBarWindowInfo(gfx::Point* position,
bool* fully_visible) const = 0;
// Gets the search string currently selected in the Find box.
virtual std::u16string_view GetFindSelectedText() const = 0;
// Gets the match count text (ie. 1 of 3) visible in the Find box.
virtual std::u16string_view GetMatchCountText() const = 0;
// Gets the pixel width of the FindBar contents.
virtual int GetContentsWidth() const = 0;
// Gets the number of audible alerts that have been issued by this bar.
virtual size_t GetAudibleAlertCount() const = 0;
};
#endif // CHROME_BROWSER_UI_FIND_BAR_FIND_BAR_H_
|