Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / find_bar / find_bar_bridge.h
blob80299a6fa3ada76fd4fdbb378015cfd069a02176
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.
5 #ifndef CHROME_BROWSER_UI_COCOA_FIND_BAR_FIND_BAR_BRIDGE_H_
6 #define CHROME_BROWSER_UI_COCOA_FIND_BAR_FIND_BAR_BRIDGE_H_
8 #include "base/compiler_specific.h"
9 #include "base/logging.h"
10 #include "chrome/browser/ui/find_bar/find_bar.h"
12 class Browser;
13 class FindBarController;
15 // This class is included by find_bar_host_browsertest.cc, so it has to be
16 // objc-free.
17 #ifdef __OBJC__
18 @class FindBarCocoaController;
19 #else
20 class FindBarCocoaController;
21 #endif
23 // Implementation of FindBar for the Mac. This class simply passes
24 // each message along to |cocoa_controller_|.
26 // The initialization here is a bit complicated. FindBarBridge is
27 // created by a static method in BrowserWindow. The FindBarBridge
28 // constructor creates a FindBarCocoaController, which in turn loads a
29 // FindBarView from a nib file. All of this is happening outside of
30 // the main view hierarchy, so the static method also calls
31 // BrowserWindowCocoa::AddFindBar() in order to add its FindBarView to
32 // the cocoa views hierarchy.
34 // Memory ownership is relatively straightforward. The FindBarBridge
35 // object is owned by the Browser. FindBarCocoaController is retained
36 // by bother FindBarBridge and BrowserWindowController, since both use it.
38 class FindBarBridge : public FindBar,
39 public FindBarTesting {
40 public:
41 FindBarBridge(Browser* browser);
42 ~FindBarBridge() override;
44 FindBarCocoaController* find_bar_cocoa_controller() {
45 return cocoa_controller_;
48 void SetFindBarController(FindBarController* find_bar_controller) override;
50 FindBarController* GetFindBarController() const override;
52 FindBarTesting* GetFindBarTesting() override;
54 // Methods from FindBar.
55 void Show(bool animate) override;
56 void Hide(bool animate) override;
57 void SetFocusAndSelection() override;
58 void ClearResults(const FindNotificationDetails& results) override;
59 void StopAnimation() override;
60 void SetFindTextAndSelectedRange(const base::string16& find_text,
61 const gfx::Range& selected_range) override;
62 base::string16 GetFindText() override;
63 gfx::Range GetSelectedRange() override;
64 void UpdateUIForFindResult(const FindNotificationDetails& result,
65 const base::string16& find_text) override;
66 void AudibleAlert() override;
67 bool IsFindBarVisible() override;
68 void RestoreSavedFocus() override;
69 bool HasGlobalFindPasteboard() override;
70 void UpdateFindBarForChangedWebContents() override;
71 void MoveWindowIfNecessary(const gfx::Rect& selection_rect) override;
73 // Methods from FindBarTesting.
74 bool GetFindBarWindowInfo(gfx::Point* position, bool* fully_visible) override;
75 base::string16 GetFindSelectedText() override;
76 base::string16 GetMatchCountText() override;
77 int GetWidth() override;
79 // Used to disable find bar animations when testing.
80 static bool disable_animations_during_testing_;
82 private:
83 // Pointer to the cocoa controller which manages the cocoa view. Is
84 // never nil.
85 FindBarCocoaController* cocoa_controller_;
87 // Pointer back to the owning controller.
88 FindBarController* find_bar_controller_; // weak, owns us
90 DISALLOW_COPY_AND_ASSIGN(FindBarBridge);
93 #endif // CHROME_BROWSER_UI_COCOA_FIND_BAR_FIND_BAR_BRIDGE_H_