summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-08 18:35:54 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-08 18:35:54 +0000
commitfb6de399a7eead8338e4f49920feed47d122fec3 (patch)
treece27a7a6d26e6e71709f5a58a4b5f00d39f80df9 /chrome/browser
parentf2f0a0b643f0edac8b346d2d53957d2a239699d0 (diff)
downloadchromium_src-fb6de399a7eead8338e4f49920feed47d122fec3.zip
chromium_src-fb6de399a7eead8338e4f49920feed47d122fec3.tar.gz
chromium_src-fb6de399a7eead8338e4f49920feed47d122fec3.tar.bz2
Simplified the api by replacing them with single Show(false) call and cleaned up linux/mac code.
BUG=22036 TEST=None Review URL: http://codereview.chromium.org/523125 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35803 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/cocoa/find_bar_bridge.h4
-rw-r--r--chrome/browser/cocoa/find_bar_bridge.mm17
-rw-r--r--chrome/browser/find_bar.h23
-rw-r--r--chrome/browser/find_bar_controller.cc5
-rw-r--r--chrome/browser/gtk/find_bar_gtk.cc20
-rw-r--r--chrome/browser/gtk/find_bar_gtk.h19
-rw-r--r--chrome/browser/views/dropdown_bar_host.cc4
-rw-r--r--chrome/browser/views/dropdown_bar_host.h2
-rw-r--r--chrome/browser/views/find_bar_host.cc4
-rw-r--r--chrome/browser/views/find_bar_host.h24
10 files changed, 58 insertions, 64 deletions
diff --git a/chrome/browser/cocoa/find_bar_bridge.h b/chrome/browser/cocoa/find_bar_bridge.h
index 970679c..ca9e27f 100644
--- a/chrome/browser/cocoa/find_bar_bridge.h
+++ b/chrome/browser/cocoa/find_bar_bridge.h
@@ -54,7 +54,7 @@ class FindBarBridge : public FindBar {
}
// Methods from FindBar.
- virtual void Show();
+ virtual void Show(bool animate);
virtual void Hide(bool animate);
virtual void SetFocusAndSelection();
virtual void ClearResults(const FindNotificationDetails& results);
@@ -63,8 +63,6 @@ class FindBarBridge : public FindBar {
virtual void UpdateUIForFindResult(const FindNotificationDetails& result,
const string16& find_text);
virtual void AudibleAlert();
- 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();
virtual void MoveWindowIfNecessary(const gfx::Rect& selection_rect,
diff --git a/chrome/browser/cocoa/find_bar_bridge.mm b/chrome/browser/cocoa/find_bar_bridge.mm
index c12a830..9b73254 100644
--- a/chrome/browser/cocoa/find_bar_bridge.mm
+++ b/chrome/browser/cocoa/find_bar_bridge.mm
@@ -16,8 +16,8 @@ FindBarBridge::FindBarBridge()
FindBarBridge::~FindBarBridge() {
}
-void FindBarBridge::Show() {
- [cocoa_controller_ showFindBar:YES]; // with animation.
+void FindBarBridge::Show(bool animate) {
+ [cocoa_controller_ showFindBar:(animate ? YES : NO)];
}
void FindBarBridge::Hide(bool animate) {
@@ -52,24 +52,13 @@ bool FindBarBridge::IsFindBarVisible() {
void FindBarBridge::MoveWindowIfNecessary(const gfx::Rect& selection_rect,
bool no_redraw) {
// http://crbug.com/11084
+ // http://crbug.com/22036
}
void FindBarBridge::StopAnimation() {
[cocoa_controller_ stopAnimation];
}
-gfx::Rect FindBarBridge::GetDialogPosition(gfx::Rect avoid_overlapping_rect) {
- // http://crbug.com/22036
- return gfx::Rect();
-}
-
-void FindBarBridge::SetDialogPosition(const gfx::Rect& new_pos,
- bool no_redraw) {
- // TODO(rohitrao): Do something useful here. For now, just show the findbar.
- // http://crbug.com/22036
- [cocoa_controller_ showFindBar:NO]; // Do not animate.
-}
-
void FindBarBridge::RestoreSavedFocus() {
[cocoa_controller_ restoreSavedFocus];
}
diff --git a/chrome/browser/find_bar.h b/chrome/browser/find_bar.h
index 6fcd5d1..a593e71 100644
--- a/chrome/browser/find_bar.h
+++ b/chrome/browser/find_bar.h
@@ -27,7 +27,8 @@ class FindBar {
FindBarController* find_bar_controller) = 0;
// Shows the find bar. Any previous search string will again be visible.
- virtual void Show() = 0;
+ // If |animate| is true, we try to slide the find bar in.
+ virtual void Show(bool animate) = 0;
// Hide the find bar. If |animate| is true, we try to slide the find bar
// away.
@@ -63,26 +64,6 @@ class FindBar {
// No match was found; play an audible alert.
virtual void AudibleAlert() = 0;
- // 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.
- virtual gfx::Rect GetDialogPosition(gfx::Rect avoid_overlapping_rect) = 0;
-
- // 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.
- virtual void SetDialogPosition(const gfx::Rect& new_pos, bool no_redraw) = 0;
-
virtual bool IsFindBarVisible() = 0;
// Upon dismissing the window, restore focus to the last focused view which is
diff --git a/chrome/browser/find_bar_controller.cc b/chrome/browser/find_bar_controller.cc
index 5dca125..9b5bc7d 100644
--- a/chrome/browser/find_bar_controller.cc
+++ b/chrome/browser/find_bar_controller.cc
@@ -29,7 +29,7 @@ void FindBarController::Show() {
// selected TabContents.
if (!tab_contents_->find_ui_active()) {
tab_contents_->set_find_ui_active(true);
- find_bar_->Show();
+ find_bar_->Show(true);
}
find_bar_->SetFocusAndSelection();
}
@@ -101,8 +101,7 @@ void FindBarController::ChangeTabContents(TabContents* contents) {
// visible state. We also want to reset the window location so that
// we don't surprise the user by popping up to the left for no apparent
// reason.
- gfx::Rect new_pos = find_bar_->GetDialogPosition(gfx::Rect());
- find_bar_->SetDialogPosition(new_pos, false);
+ find_bar_->Show(false);
}
UpdateFindBarForCurrentResult();
diff --git a/chrome/browser/gtk/find_bar_gtk.cc b/chrome/browser/gtk/find_bar_gtk.cc
index e3ddeb8..a26b0cf 100644
--- a/chrome/browser/gtk/find_bar_gtk.cc
+++ b/chrome/browser/gtk/find_bar_gtk.cc
@@ -298,12 +298,16 @@ void FindBarGtk::InitWidgets() {
gtk_widget_show(widget());
}
-void FindBarGtk::Show() {
- slide_widget_->Open();
- selection_rect = gfx::Rect();
- Reposition();
- if (container_->window)
- gdk_window_raise(container_->window);
+void FindBarGtk::Show(bool animate) {
+ if (animate) {
+ slide_widget_->Open();
+ selection_rect = gfx::Rect();
+ Reposition();
+ if (container_->window)
+ gdk_window_raise(container_->window);
+ } else {
+ slide_widget_->OpenWithoutAnimation();
+ }
}
void FindBarGtk::Hide(bool animate) {
@@ -408,10 +412,6 @@ gfx::Rect FindBarGtk::GetDialogPosition(gfx::Rect avoid_overlapping_rect) {
return new_pos;
}
-void FindBarGtk::SetDialogPosition(const gfx::Rect& new_pos, bool no_redraw) {
- slide_widget_->OpenWithoutAnimation();
-}
-
bool FindBarGtk::IsFindBarVisible() {
return GTK_WIDGET_VISIBLE(widget());
}
diff --git a/chrome/browser/gtk/find_bar_gtk.h b/chrome/browser/gtk/find_bar_gtk.h
index 137b2c3..bad7122 100644
--- a/chrome/browser/gtk/find_bar_gtk.h
+++ b/chrome/browser/gtk/find_bar_gtk.h
@@ -1,5 +1,5 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use
+// of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_GTK_FIND_BAR_GTK_H_
@@ -45,7 +45,7 @@ class FindBarGtk : public FindBar,
virtual void SetFindBarController(FindBarController* find_bar_controller) {
find_bar_controller_ = find_bar_controller;
}
- virtual void Show();
+ virtual void Show(bool animate);
virtual void Hide(bool animate);
virtual void SetFocusAndSelection();
virtual void ClearResults(const FindNotificationDetails& results);
@@ -56,8 +56,6 @@ class FindBarGtk : public FindBar,
virtual void UpdateUIForFindResult(const FindNotificationDetails& result,
const string16& find_text);
virtual void AudibleAlert();
- 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();
virtual FindBarTesting* GetFindBarTesting();
@@ -93,6 +91,17 @@ class FindBarGtk : public FindBar,
// Asynchronously repositions the dialog.
void Reposition();
+ // Returns the rectangle representing where to position the find bar. 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);
+
static void OnParentSet(GtkWidget* widget, GtkObject* old_parent,
FindBarGtk* find_bar);
diff --git a/chrome/browser/views/dropdown_bar_host.cc b/chrome/browser/views/dropdown_bar_host.cc
index ee647d25..a921b95 100644
--- a/chrome/browser/views/dropdown_bar_host.cc
+++ b/chrome/browser/views/dropdown_bar_host.cc
@@ -58,12 +58,12 @@ DropdownBarHost::~DropdownBarHost() {
focus_tracker_.reset(NULL);
}
-void DropdownBarHost::Show() {
+void DropdownBarHost::Show(bool animate) {
// Stores the currently focused view, and tracks focus changes so that we can
// restore focus when the dropdown widget is closed.
focus_tracker_.reset(new views::ExternalFocusTracker(view_, focus_manager_));
- if (disable_animations_during_testing_) {
+ if (!animate || disable_animations_during_testing_) {
animation_->Reset(1);
AnimationProgressed(animation_.get());
} else {
diff --git a/chrome/browser/views/dropdown_bar_host.h b/chrome/browser/views/dropdown_bar_host.h
index 635ee18..c15585f 100644
--- a/chrome/browser/views/dropdown_bar_host.h
+++ b/chrome/browser/views/dropdown_bar_host.h
@@ -49,7 +49,7 @@ class DropdownBarHost : public views::AcceleratorTarget,
// Returns true if the dropdown bar view is visible, or false otherwise.
bool IsVisible() const;
// Shows the dropdown bar.
- void Show();
+ void Show(bool animate);
// Hides the dropdown bar.
void Hide(bool animate);
// Selects text in the entry field and set focus.
diff --git a/chrome/browser/views/find_bar_host.cc b/chrome/browser/views/find_bar_host.cc
index 1e7cca7..991b7497 100644
--- a/chrome/browser/views/find_bar_host.cc
+++ b/chrome/browser/views/find_bar_host.cc
@@ -50,8 +50,8 @@ FindBarHost::FindBarHost(BrowserView* browser_view)
FindBarHost::~FindBarHost() {
}
-void FindBarHost::Show() {
- DropdownBarHost::Show();
+void FindBarHost::Show(bool animate) {
+ DropdownBarHost::Show(animate);
}
void FindBarHost::SetFocusAndSelection() {
diff --git a/chrome/browser/views/find_bar_host.h b/chrome/browser/views/find_bar_host.h
index d42ff26..51771c9 100644
--- a/chrome/browser/views/find_bar_host.h
+++ b/chrome/browser/views/find_bar_host.h
@@ -54,7 +54,7 @@ class FindBarHost : public DropdownBarHost,
virtual void SetFindBarController(FindBarController* find_bar_controller) {
find_bar_controller_ = find_bar_controller;
}
- virtual void Show();
+ virtual void Show(bool animate);
virtual void Hide(bool animate);
virtual void SetFocusAndSelection();
virtual void ClearResults(const FindNotificationDetails& results);
@@ -65,8 +65,6 @@ class FindBarHost : public DropdownBarHost,
virtual void UpdateUIForFindResult(const FindNotificationDetails& result,
const string16& find_text);
virtual void AudibleAlert();
- 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();
virtual FindBarTesting* GetFindBarTesting();
@@ -78,6 +76,26 @@ class FindBarHost : public DropdownBarHost,
virtual bool GetFindBarWindowInfo(gfx::Point* position,
bool* fully_visible);
+ // Overridden from DropdownBarHost:
+ // 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.
+ virtual 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.
+ virtual void SetDialogPosition(const gfx::Rect& new_pos, bool no_redraw);
+
private:
// The find bar widget needs rounded edges, so we create a polygon
// that corresponds to the background images for this window (and