summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/find_bar_host.h
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-09 22:06:19 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-09 22:06:19 +0000
commit44f773c63bbe33388c71bac110e097a0bf106664 (patch)
tree1996d8ceee903a7061c4dddd8fbba43c3570ff03 /chrome/browser/views/find_bar_host.h
parent22a3daa444d2ef3efd1e11fdcd6216c0f5b474a5 (diff)
downloadchromium_src-44f773c63bbe33388c71bac110e097a0bf106664.zip
chromium_src-44f773c63bbe33388c71bac110e097a0bf106664.tar.gz
chromium_src-44f773c63bbe33388c71bac110e097a0bf106664.tar.bz2
Refactored FindBarHost/View to create DropdownBarHostView, which I'm plannig to use this
for CompactLocationBar. BUG=None TEST=enabled find_bar_host_browsertest.cc for linux view build. Review URL: http://codereview.chromium.org/360044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31486 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/find_bar_host.h')
-rw-r--r--chrome/browser/views/find_bar_host.h119
1 files changed, 17 insertions, 102 deletions
diff --git a/chrome/browser/views/find_bar_host.h b/chrome/browser/views/find_bar_host.h
index 4ccc57a..d42ff26 100644
--- a/chrome/browser/views/find_bar_host.h
+++ b/chrome/browser/views/find_bar_host.h
@@ -8,33 +8,23 @@
#include "app/animation.h"
#include "app/gfx/native_widget_types.h"
#include "base/gfx/rect.h"
-#include "base/scoped_ptr.h"
#include "chrome/browser/find_bar.h"
#include "chrome/browser/renderer_host/render_view_host_delegate.h"
+#include "chrome/browser/views/dropdown_bar_host.h"
#include "views/controls/textfield/textfield.h"
-#include "views/focus/focus_manager.h"
-#include "views/widget/widget.h"
class BrowserView;
class FindBarController;
class FindBarView;
class FindNotificationDetails;
-class RenderViewHost;
-class SlideAnimation;
-
-namespace views {
-class ExternalFocusTracker;
-class View;
-}
-
////////////////////////////////////////////////////////////////////////////////
//
-// The FindBarHost implements the container window for the
+// The FindBarHost implements the container widget for the
// find-in-page functionality. It uses the appropriate implementation from
// find_bar_host_win.cc or find_bar_host_gtk.cc to draw its content and is
-// responsible for showing, hiding, closing, and moving the window if needed,
-// for example if the window is obscuring the selection results. It also
+// responsible for showing, hiding, closing, and moving the widget if needed,
+// for example if the widget is obscuring the selection results. It also
// receives notifications about the search results and communicates that to
// the view.
//
@@ -43,18 +33,13 @@ class View;
// the BrowserView is attached to the frame's Widget for the first time.
//
////////////////////////////////////////////////////////////////////////////////
-class FindBarHost : public views::AcceleratorTarget,
- public views::FocusChangeListener,
- public AnimationDelegate,
+class FindBarHost : public DropdownBarHost,
public FindBar,
public FindBarTesting {
public:
explicit FindBarHost(BrowserView* browser_view);
virtual ~FindBarHost();
- // Whether we are animating the position of the Find window.
- bool IsAnimating();
-
// Forwards selected keystrokes to the renderer. This is useful to make sure
// that arrow keys and PageUp and PageDown result in scrolling, instead of
// being eaten because the FindBar has focus. Returns true if the keystroke
@@ -62,8 +47,6 @@ class FindBarHost : public views::AcceleratorTarget,
bool MaybeForwardKeystrokeToWebpage(
const views::Textfield::Keystroke& key_stroke);
- bool IsVisible();
-
// FindBar implementation:
virtual FindBarController* GetFindBarController() const {
return find_bar_controller_;
@@ -88,104 +71,36 @@ class FindBarHost : public views::AcceleratorTarget,
virtual void RestoreSavedFocus();
virtual FindBarTesting* GetFindBarTesting();
- // Overridden from views::FocusChangeListener:
- virtual void FocusWillChange(views::View* focused_before,
- views::View* focused_now);
-
- // Overridden from views::AcceleratorTarget:
+ // Overridden from views::AcceleratorTarget in DropdownBarHost class:
virtual bool AcceleratorPressed(const views::Accelerator& accelerator);
- // AnimationDelegate implementation:
- virtual void AnimationProgressed(const Animation* animation);
- virtual void AnimationEnded(const Animation* animation);
-
// FindBarTesting implementation:
virtual bool GetFindBarWindowInfo(gfx::Point* position,
bool* fully_visible);
- // Get the offset with which to paint the theme image.
- void GetThemePosition(gfx::Rect* bounds);
-
- // During testing we can disable animations by setting this flag to true,
- // so that opening and closing the Find box happens instantly, instead of
- // having to poll it while it animates to open/closed status.
- static bool disable_animations_during_testing_;
-
private:
- // Retrieves the boundaries that the find bar has to work with within the
- // Chrome frame window. The resulting rectangle will be a rectangle that
- // overlaps the bottom of the Chrome toolbar by one pixel (so we can create
- // the illusion that the find bar is part of the toolbar) and covers the page
- // area, except that we deflate the rect width by subtracting (from both
- // sides) the width of the toolbar and some extra pixels to account for the
- // width of the Chrome window borders. |bounds| is relative to the browser
- // window. If the function fails to determine the browser window/client area
- // rectangle or the rectangle for the page area then |bounds| will
- // be an empty rectangle.
- void GetDialogBounds(gfx::Rect* bounds);
-
- // The dialog needs rounded edges, so we create a polygon that corresponds to
- // the background images for this window (and make the polygon only contain
- // the pixels that we want to draw). The polygon is then given to SetWindowRgn
- // which changes the window from being a rectangle in shape, to being a rect
- // with curved edges. We also check to see if the region should be truncated
- // to prevent from drawing onto Chrome's window border.
+ // The find bar widget needs rounded edges, so we create a polygon
+ // that corresponds to the background images for this window (and
+ // make the polygon only contain the pixels that we want to
+ // draw). The polygon is then given to SetWindowRgn which changes
+ // the window from being a rectangle in shape, to being a rect with
+ // curved edges. We also check to see if the region should be
+ // truncated to prevent from drawing onto Chrome's window border.
void UpdateWindowEdges(const gfx::Rect& new_pos);
- // Registers this class as the handler for when Escape is pressed. We will
- // unregister once we loose focus. See also: SetFocusChangeListener().
- void RegisterEscAccelerator();
+ // Allows implementation to tweak widget position.
+ void GetWidgetPositionNative(gfx::Rect* avoid_overlapping_rect);
- // When we loose focus, we unregister the handler for Escape. See
- // also: SetFocusChangeListener().
- void UnregisterEscAccelerator();
-
- // Creates and returns the native Widget.
- views::Widget* CreateHost();
- // Allows implementation to tweak dialog position.
- void SetDialogPositionNative(const gfx::Rect& new_pos, bool no_redraw);
- // Allows implementation to tweak dialog position.
- void GetDialogPositionNative(gfx::Rect* avoid_overlapping_rect);
- // Returns the native view (is a child of the window widget in gtk).
- gfx::NativeView GetNativeView(BrowserView* browser_view);
- // Returns a keyboard event suitable for fowarding.
- NativeWebKeyboardEvent GetKeyboardEvent(
- const TabContents* contents,
- const views::Textfield::Keystroke& key_stroke);
// Allows native implementation to prevent keystrokes from being forwarded.
bool ShouldForwardKeystrokeToWebpageNative(
const views::Textfield::Keystroke& key_stroke);
- // The BrowserView that created us.
- BrowserView* browser_view_;
-
- // Our view, which is responsible for drawing the UI.
- FindBarView* view_;
-
- // The y position pixel offset of the window while animating the Find dialog.
- int find_dialog_animation_offset_;
-
- // The animation class to use when opening the Find window.
- scoped_ptr<SlideAnimation> animation_;
-
- // The focus manager we register with to keep track of focus changes.
- views::FocusManager* focus_manager_;
-
- // True if the accelerator target for Esc key is registered.
- bool esc_accel_target_registered_;
-
- // Tracks and stores the last focused view which is not the FindBarView
- // or any of its children. Used to restore focus once the FindBarView is
- // closed.
- scoped_ptr<views::ExternalFocusTracker> focus_tracker_;
+ // Returns the FindBarView.
+ FindBarView* find_bar_view();
// A pointer back to the owning controller.
FindBarController* find_bar_controller_;
- // Host is the Widget implementation that is created and maintained by the
- // find bar. It contains the FindBarView.
- scoped_ptr<views::Widget> host_;
-
DISALLOW_COPY_AND_ASSIGN(FindBarHost);
};