| OLD | NEW | 
 | (Empty) | 
|   1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_UI_COCOA_FIND_BAR_BRIDGE_H_ |  | 
|   6 #define CHROME_BROWSER_UI_COCOA_FIND_BAR_BRIDGE_H_ |  | 
|   7 #pragma once |  | 
|   8  |  | 
|   9 #include "base/logging.h" |  | 
|  10 #include "chrome/browser/ui/find_bar/find_bar.h" |  | 
|  11  |  | 
|  12 class BrowserWindowCocoa; |  | 
|  13 class FindBarController; |  | 
|  14  |  | 
|  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 |  | 
|  22  |  | 
|  23 // Implementation of FindBar for the Mac.  This class simply passes |  | 
|  24 // each message along to |cocoa_controller_|. |  | 
|  25 // |  | 
|  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. |  | 
|  33 // |  | 
|  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. |  | 
|  37  |  | 
|  38 class FindBarBridge : public FindBar, |  | 
|  39                       public FindBarTesting { |  | 
|  40  public: |  | 
|  41   FindBarBridge(); |  | 
|  42   virtual ~FindBarBridge(); |  | 
|  43  |  | 
|  44   FindBarCocoaController* find_bar_cocoa_controller() { |  | 
|  45     return cocoa_controller_; |  | 
|  46   } |  | 
|  47  |  | 
|  48   virtual void SetFindBarController(FindBarController* find_bar_controller) { |  | 
|  49     find_bar_controller_ = find_bar_controller; |  | 
|  50   } |  | 
|  51  |  | 
|  52   virtual FindBarController* GetFindBarController() const { |  | 
|  53     DCHECK(find_bar_controller_); |  | 
|  54     return find_bar_controller_; |  | 
|  55   } |  | 
|  56  |  | 
|  57   virtual FindBarTesting* GetFindBarTesting() { |  | 
|  58     return this; |  | 
|  59   } |  | 
|  60  |  | 
|  61   // Methods from FindBar. |  | 
|  62   virtual void Show(bool animate); |  | 
|  63   virtual void Hide(bool animate); |  | 
|  64   virtual void SetFocusAndSelection(); |  | 
|  65   virtual void ClearResults(const FindNotificationDetails& results); |  | 
|  66   virtual void StopAnimation(); |  | 
|  67   virtual void SetFindText(const string16& find_text); |  | 
|  68   virtual void UpdateUIForFindResult(const FindNotificationDetails& result, |  | 
|  69                                      const string16& find_text); |  | 
|  70   virtual void AudibleAlert(); |  | 
|  71   virtual bool IsFindBarVisible(); |  | 
|  72   virtual void RestoreSavedFocus(); |  | 
|  73   virtual void MoveWindowIfNecessary(const gfx::Rect& selection_rect, |  | 
|  74                                      bool no_redraw); |  | 
|  75  |  | 
|  76   // Methods from FindBarTesting. |  | 
|  77   virtual bool GetFindBarWindowInfo(gfx::Point* position, |  | 
|  78                                     bool* fully_visible); |  | 
|  79   virtual string16 GetFindText(); |  | 
|  80   virtual string16 GetFindSelectedText(); |  | 
|  81   virtual string16 GetMatchCountText(); |  | 
|  82  |  | 
|  83   // Used to disable find bar animations when testing. |  | 
|  84   static bool disable_animations_during_testing_; |  | 
|  85  |  | 
|  86  private: |  | 
|  87   // Pointer to the cocoa controller which manages the cocoa view.  Is |  | 
|  88   // never nil. |  | 
|  89   FindBarCocoaController* cocoa_controller_; |  | 
|  90  |  | 
|  91   // Pointer back to the owning controller. |  | 
|  92   FindBarController* find_bar_controller_;  // weak, owns us |  | 
|  93  |  | 
|  94   DISALLOW_COPY_AND_ASSIGN(FindBarBridge); |  | 
|  95 }; |  | 
|  96  |  | 
|  97 #endif  // CHROME_BROWSER_UI_COCOA_FIND_BAR_BRIDGE_H_ |  | 
| OLD | NEW |