summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/find_bar_win.h
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-12 17:03:37 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-12 17:03:37 +0000
commit92e175a8152b4a7226cf8715aed8501ed7d83187 (patch)
tree67ca4faf8de98eef08cbc592f4b16b8d08d739be /chrome/browser/views/find_bar_win.h
parent7985f9159ec6ba70fcdc4c76b6bc8787c074cb50 (diff)
downloadchromium_src-92e175a8152b4a7226cf8715aed8501ed7d83187.zip
chromium_src-92e175a8152b4a7226cf8715aed8501ed7d83187.tar.gz
chromium_src-92e175a8152b4a7226cf8715aed8501ed7d83187.tar.bz2
Some work in refactoring FindBarWin/FindBarView so
we can share code across platforms. See http://code.google.com/p/chromium/wiki/FindBarRefactoring for more information about the design. Review URL: http://codereview.chromium.org/42057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11544 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/find_bar_win.h')
-rw-r--r--chrome/browser/views/find_bar_win.h78
1 files changed, 28 insertions, 50 deletions
diff --git a/chrome/browser/views/find_bar_win.h b/chrome/browser/views/find_bar_win.h
index c226ea9..b06a033 100644
--- a/chrome/browser/views/find_bar_win.h
+++ b/chrome/browser/views/find_bar_win.h
@@ -6,14 +6,15 @@
#define CHROME_BROWSER_VIEWS_FIND_BAR_WIN_H_
#include "base/gfx/rect.h"
-#include "chrome/browser/find_notification_details.h"
+#include "chrome/browser/find_bar.h"
#include "chrome/browser/renderer_host/render_view_host_delegate.h"
#include "chrome/common/animation.h"
-#include "chrome/common/notification_service.h"
#include "chrome/views/widget_win.h"
class BrowserView;
+class FindBarController;
class FindBarView;
+class FindNotificationDetails;
class RenderViewHost;
class SlideAnimation;
@@ -39,23 +40,19 @@ class View;
class FindBarWin : public views::FocusChangeListener,
public views::WidgetWin,
public AnimationDelegate,
- public NotificationObserver {
+ public FindBar {
public:
explicit FindBarWin(BrowserView* browser_view);
virtual ~FindBarWin();
- // Accessor for the attached WebContents.
- WebContents* web_contents() const { return web_contents_; }
-
- // Shows the find bar. Any previous search string will again be visible.
- void Show();
-
- // Ends the current session.
- void EndFindSession();
-
- // Changes the WebContents that this FindBar is attached to. This occurs when
- // the user switches tabs in the Browser window. |contents| can be NULL.
- void ChangeWebContents(WebContents* contents);
+ // Accessor for find_bar_controller so FindBarView can get back to
+ // FindBarController.
+ FindBarController* find_bar_controller() const {
+ return find_bar_controller_;
+ }
+ void set_find_bar_controller(FindBarController* find_bar_controller) {
+ find_bar_controller_ = find_bar_controller;
+ }
// If the find bar obscures the search results we need to move the window. To
// do that we need to know what is selected on the page. We simply calculate
@@ -79,10 +76,19 @@ class FindBarWin : public views::FocusChangeListener,
// new |parent_hwnd|.
void SetFocusChangeListener(HWND parent_hwnd);
- // Overridden from NotificationObserver:
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
+ // FindBar implementation:
+ virtual void Show();
+ virtual void Hide(bool animate);
+ virtual void SetFocusAndSelection();
+ virtual void ClearResults(const FindNotificationDetails& results);
+ virtual void StopAnimation();
+ virtual void SetFindText(const std::wstring& find_text);
+ virtual void UpdateUIForFindResult(const FindNotificationDetails& result,
+ const std::wstring& find_text);
+ virtual gfx::Rect GetDialogPosition(gfx::Rect avoid_overlapping_rect);
+ virtual void SetDialogPosition(const gfx::Rect& new_pos, bool no_redraw);
+ virtual bool IsFindBarVisible();
+ virtual void RestoreSavedFocus();
// Overridden from views::WidgetWin:
virtual void OnFinalMessage(HWND window);
@@ -111,26 +117,6 @@ class FindBarWin : public views::FocusChangeListener,
// be an empty rectangle.
void GetDialogBounds(gfx::Rect* bounds);
- // Returns the rectangle representing where to position the find bar. It uses
- // GetDialogBounds and positions itself within that, either to the left (if an
- // InfoBar is present) or to the right (no InfoBar). If
- // |avoid_overlapping_rect| is specified, the return value will be a rectangle
- // located immediately to the left of |avoid_overlapping_rect|, as long as
- // there is enough room for the dialog to draw within the bounds. If not, the
- // dialog position returned will overlap |avoid_overlapping_rect|.
- // Note: |avoid_overlapping_rect| is expected to use coordinates relative to
- // the top of the page area, (it will be converted to coordinates relative to
- // the top of the browser window, when comparing against the dialog
- // coordinates). The returned value is relative to the browser window.
- gfx::Rect GetDialogPosition(gfx::Rect avoid_overlapping_rect);
-
- // Moves the dialog window to the provided location, moves it to top in the
- // z-order (HWND_TOP, not HWND_TOPMOST) and shows the window (if hidden).
- // It then calls UpdateWindowEdges to make sure we don't overwrite the Chrome
- // window border. If |no_redraw| is set, the window is getting moved but not
- // sized, and should not be redrawn to reduce update flicker.
- void SetDialogPosition(const gfx::Rect& new_pos, bool no_redraw);
-
// 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
@@ -139,9 +125,6 @@ class FindBarWin : public views::FocusChangeListener,
// to prevent from drawing onto Chrome's window border.
void UpdateWindowEdges(const gfx::Rect& new_pos);
- // Upon dismissing the window, restore focus to the last focused view which is
- // not FindBarView or any of its children.
- void RestoreSavedFocus();
// Registers this class as the handler for when Escape is pressed. We will
// unregister once we loose focus. See also: SetFocusChangeListener().
@@ -151,14 +134,6 @@ class FindBarWin : public views::FocusChangeListener,
// also: SetFocusChangeListener().
void UnregisterEscAccelerator();
- // Updates the FindBarView with the find result details contained within the
- // specified |result|.
- void UpdateUIForFindResult(const FindNotificationDetails& result,
- const std::wstring& find_text);
-
- // The WebContents we are currently associated with.
- WebContents* web_contents_;
-
// The BrowserView that created us.
BrowserView* browser_view_;
@@ -183,6 +158,9 @@ class FindBarWin : public views::FocusChangeListener,
// closed.
scoped_ptr<views::ExternalFocusTracker> focus_tracker_;
+ // A pointer back to the owning controller.
+ FindBarController* find_bar_controller_;
+
DISALLOW_COPY_AND_ASSIGN(FindBarWin);
};