Home | History | Annotate | Download | only in find_bar
      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 // 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.
      8 
      9 #ifndef CHROME_BROWSER_UI_FIND_BAR_FIND_BAR_H_
     10 #define CHROME_BROWSER_UI_FIND_BAR_FIND_BAR_H_
     11 #pragma once
     12 
     13 #include "base/string16.h"
     14 #include "ui/gfx/rect.h"
     15 
     16 class FindBarController;
     17 class FindBarTesting;
     18 class FindNotificationDetails;
     19 
     20 class FindBar {
     21  public:
     22   virtual ~FindBar() { }
     23 
     24   // Accessor and setter for the FindBarController.
     25   virtual FindBarController* GetFindBarController() const = 0;
     26   virtual void SetFindBarController(
     27       FindBarController* find_bar_controller) = 0;
     28 
     29   // Shows the find bar. Any previous search string will again be visible.
     30   // If |animate| is true, we try to slide the find bar in.
     31   virtual void Show(bool animate) = 0;
     32 
     33   // Hide the find bar.  If |animate| is true, we try to slide the find bar
     34   // away.
     35   virtual void Hide(bool animate) = 0;
     36 
     37   // Restore the selected text in the find box and focus it.
     38   virtual void SetFocusAndSelection() = 0;
     39 
     40   // Clear the text in the find box.
     41   virtual void ClearResults(const FindNotificationDetails& results) = 0;
     42 
     43   // Stop the animation.
     44   virtual void StopAnimation() = 0;
     45 
     46   // If the find bar obscures the search results we need to move the window. To
     47   // do that we need to know what is selected on the page. We simply calculate
     48   // where it would be if we place it on the left of the selection and if it
     49   // doesn't fit on the screen we try the right side. The parameter
     50   // |selection_rect| is expected to have coordinates relative to the top of
     51   // the web page area. If |no_redraw| is true, the window will be moved without
     52   // redrawing siblings.
     53   virtual void MoveWindowIfNecessary(const gfx::Rect& selection_rect,
     54                                      bool no_redraw) = 0;
     55 
     56   // Set the text in the find box.
     57   virtual void SetFindText(const string16& find_text) = 0;
     58 
     59   // Updates the FindBar with the find result details contained within the
     60   // specified |result|.
     61   virtual void UpdateUIForFindResult(const FindNotificationDetails& result,
     62                                      const string16& find_text) = 0;
     63 
     64   // No match was found; play an audible alert.
     65   virtual void AudibleAlert() = 0;
     66 
     67   virtual bool IsFindBarVisible() = 0;
     68 
     69   // Upon dismissing the window, restore focus to the last focused view which is
     70   // not FindBarView or any of its children.
     71   virtual void RestoreSavedFocus() = 0;
     72 
     73   // Returns a pointer to the testing interface to the FindBar, or NULL
     74   // if there is none.
     75   virtual FindBarTesting* GetFindBarTesting() = 0;
     76 };
     77 
     78 class FindBarTesting {
     79  public:
     80   virtual ~FindBarTesting() { }
     81 
     82   // Computes the location of the find bar and whether it is fully visible in
     83   // its parent window. The return value indicates if the window is visible at
     84   // all. Both out arguments are optional.
     85   //
     86   // This is used for UI tests of the find bar. If the find bar is not currently
     87   // shown (return value of false), the out params will be {(0, 0), false}.
     88   virtual bool GetFindBarWindowInfo(gfx::Point* position,
     89                                     bool* fully_visible) = 0;
     90 
     91   // Gets the search string currently visible in the Find box.
     92   virtual string16 GetFindText() = 0;
     93 
     94   // Gets the search string currently selected in the Find box.
     95   virtual string16 GetFindSelectedText() = 0;
     96 
     97   // Gets the match count text (ie. 1 of 3) visible in the Find box.
     98   virtual string16 GetMatchCountText() = 0;
     99 };
    100 
    101 #endif  // CHROME_BROWSER_UI_FIND_BAR_FIND_BAR_H_
    102