summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-05 02:40:07 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-05 02:40:07 +0000
commit126f4120902008da93759d7256c87e1e6d3ae70b (patch)
treeba664f25a7d09be02fc6c05802b938fba53683be /chrome/browser
parent627f02642ffe7075b567ee85e77044d64d72e24d (diff)
downloadchromium_src-126f4120902008da93759d7256c87e1e6d3ae70b.zip
chromium_src-126f4120902008da93759d7256c87e1e6d3ae70b.tar.gz
chromium_src-126f4120902008da93759d7256c87e1e6d3ae70b.tar.bz2
FindBarView::UpdateForResult is not a good place to
beep if nothing was found on the page. The reason is that it is gets called when you switch from one tab to the other. I've added a function to FindBar that the controller can call and each platform can implement whatever sound they want to use. BUG=10823 TEST=Open google.com, search for z0, it should beep (no matches). Open new tab, switch back to the old tab and it should not beep. Review URL: http://codereview.chromium.org/99372 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15269 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/cocoa/find_bar_bridge.h1
-rw-r--r--chrome/browser/cocoa/find_bar_bridge.mm5
-rw-r--r--chrome/browser/find_bar.h4
-rw-r--r--chrome/browser/find_bar_controller.cc1
-rw-r--r--chrome/browser/gtk/find_bar_gtk.cc4
-rw-r--r--chrome/browser/gtk/find_bar_gtk.h1
-rw-r--r--chrome/browser/views/find_bar_view.cc1
-rw-r--r--chrome/browser/views/find_bar_win.cc6
-rw-r--r--chrome/browser/views/find_bar_win.h1
9 files changed, 23 insertions, 1 deletions
diff --git a/chrome/browser/cocoa/find_bar_bridge.h b/chrome/browser/cocoa/find_bar_bridge.h
index 2388733..d54d57a 100644
--- a/chrome/browser/cocoa/find_bar_bridge.h
+++ b/chrome/browser/cocoa/find_bar_bridge.h
@@ -62,6 +62,7 @@ class FindBarBridge : public FindBar {
virtual void SetFindText(const string16& find_text);
virtual void UpdateUIForFindResult(const FindNotificationDetails& result,
const string16& find_text);
+ virtual void AudibleAlertIfNotFound(const FindNotificationDetails& result);
virtual gfx::Rect GetDialogPosition(gfx::Rect avoid_overlapping_rect);
virtual void SetDialogPosition(const gfx::Rect& new_pos, bool no_redraw);
virtual bool IsFindBarVisible();
diff --git a/chrome/browser/cocoa/find_bar_bridge.mm b/chrome/browser/cocoa/find_bar_bridge.mm
index 8cb37e4..e7c2f9b 100644
--- a/chrome/browser/cocoa/find_bar_bridge.mm
+++ b/chrome/browser/cocoa/find_bar_bridge.mm
@@ -38,6 +38,11 @@ void FindBarBridge::UpdateUIForFindResult(const FindNotificationDetails& result,
[cocoa_controller_ updateUIForFindResult:result withText:find_text];
}
+void FindBarBridge::AudibleAlertIfNotFound(
+ const FindNotificationDetails& result) {
+ // TODO(rohitrao): Beep beep, beep beep, Yeah!
+}
+
bool FindBarBridge::IsFindBarVisible() {
return [cocoa_controller_ isFindBarVisible] ? true : false;
}
diff --git a/chrome/browser/find_bar.h b/chrome/browser/find_bar.h
index 7321113..c912b81 100644
--- a/chrome/browser/find_bar.h
+++ b/chrome/browser/find_bar.h
@@ -60,6 +60,10 @@ class FindBar {
virtual void UpdateUIForFindResult(const FindNotificationDetails& result,
const string16& find_text) = 0;
+ // Play an audible alert if no match was found.
+ virtual void AudibleAlertIfNotFound(
+ const FindNotificationDetails& result) = 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
diff --git a/chrome/browser/find_bar_controller.cc b/chrome/browser/find_bar_controller.cc
index 07cd5e6..2d273f1 100644
--- a/chrome/browser/find_bar_controller.cc
+++ b/chrome/browser/find_bar_controller.cc
@@ -121,6 +121,7 @@ void FindBarController::Observe(NotificationType type,
if (Source<TabContents>(source).ptr() == tab_contents_) {
find_bar_->UpdateUIForFindResult(tab_contents_->find_result(),
tab_contents_->find_text());
+ find_bar_->AudibleAlertIfNotFound(tab_contents_->find_result());
}
} else if (type == NotificationType::NAV_ENTRY_COMMITTED) {
NavigationController* source_controller =
diff --git a/chrome/browser/gtk/find_bar_gtk.cc b/chrome/browser/gtk/find_bar_gtk.cc
index f3e0b05..8fd0dbe 100644
--- a/chrome/browser/gtk/find_bar_gtk.cc
+++ b/chrome/browser/gtk/find_bar_gtk.cc
@@ -210,6 +210,10 @@ void FindBarGtk::UpdateUIForFindResult(const FindNotificationDetails& result,
const string16& find_text) {
}
+void FindBarGtk::AudibleAlertIfNotFound(const FindNotificationDetails& result) {
+ // TODO(estade): Beep beep, beep beep, Yeah!
+}
+
gfx::Rect FindBarGtk::GetDialogPosition(gfx::Rect avoid_overlapping_rect) {
// TODO(estade): Logic for the positioning of the find bar should be factored
// out of here and browser/views/* and into FindBarController.
diff --git a/chrome/browser/gtk/find_bar_gtk.h b/chrome/browser/gtk/find_bar_gtk.h
index 721df0a..592b50c 100644
--- a/chrome/browser/gtk/find_bar_gtk.h
+++ b/chrome/browser/gtk/find_bar_gtk.h
@@ -45,6 +45,7 @@ class FindBarGtk : public FindBar,
virtual void SetFindText(const string16& find_text);
virtual void UpdateUIForFindResult(const FindNotificationDetails& result,
const string16& find_text);
+ virtual void AudibleAlertIfNotFound(const FindNotificationDetails& result);
virtual gfx::Rect GetDialogPosition(gfx::Rect avoid_overlapping_rect);
virtual void SetDialogPosition(const gfx::Rect& new_pos, bool no_redraw);
virtual bool IsFindBarVisible();
diff --git a/chrome/browser/views/find_bar_view.cc b/chrome/browser/views/find_bar_view.cc
index 4aaccee..2869cff1 100644
--- a/chrome/browser/views/find_bar_view.cc
+++ b/chrome/browser/views/find_bar_view.cc
@@ -231,7 +231,6 @@ void FindBarView::UpdateForResult(const FindNotificationDetails& result,
match_count_text_->set_background(
views::Background::CreateSolidBackground(kBackgroundColorNoMatch));
match_count_text_->SetColor(kTextColorNoMatch);
- MessageBeep(MB_OK);
}
// Make sure Find Next and Find Previous are enabled if we found any matches.
diff --git a/chrome/browser/views/find_bar_win.cc b/chrome/browser/views/find_bar_win.cc
index 5c4d7e75..a579130 100644
--- a/chrome/browser/views/find_bar_win.cc
+++ b/chrome/browser/views/find_bar_win.cc
@@ -549,3 +549,9 @@ void FindBarWin::UpdateUIForFindResult(const FindNotificationDetails& result,
if (result.number_of_matches() > 0)
focus_tracker_.reset(NULL);
}
+
+void FindBarWin::AudibleAlertIfNotFound(
+ const FindNotificationDetails& result) {
+ if (result.final_update() && result.number_of_matches() == 0)
+ MessageBeep(MB_OK);
+}
diff --git a/chrome/browser/views/find_bar_win.h b/chrome/browser/views/find_bar_win.h
index 81e9176..4f6cf31 100644
--- a/chrome/browser/views/find_bar_win.h
+++ b/chrome/browser/views/find_bar_win.h
@@ -82,6 +82,7 @@ class FindBarWin : public views::FocusChangeListener,
virtual void SetFindText(const string16& find_text);
virtual void UpdateUIForFindResult(const FindNotificationDetails& result,
const string16& find_text);
+ virtual void AudibleAlertIfNotFound(const FindNotificationDetails& result);
virtual gfx::Rect GetDialogPosition(gfx::Rect avoid_overlapping_rect);
virtual void SetDialogPosition(const gfx::Rect& new_pos, bool no_redraw);
virtual bool IsFindBarVisible();