Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(923)

Unified Diff: chrome/browser/ui/find_bar/find_bar_controller.cc

Issue 2839713002: Fix extraneous beeps on empty page search. (Closed)
Patch Set: Un-reverse the conditional I broke last patch. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/find_bar/find_bar_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/find_bar/find_bar_controller.cc
diff --git a/chrome/browser/ui/find_bar/find_bar_controller.cc b/chrome/browser/ui/find_bar/find_bar_controller.cc
index db9cfcefd123182f20140dccf9165747410969e3..cfacd76e9ea65ff0a1a627f5b1e1d8aae00b432f 100644
--- a/chrome/browser/ui/find_bar/find_bar_controller.cc
+++ b/chrome/browser/ui/find_bar/find_bar_controller.cc
@@ -58,6 +58,10 @@ void FindBarController::EndFindSession(SelectionAction selection_action,
ResultAction result_action) {
find_bar_->Hide(true);
+ // If the user searches again for this string, it should notify if the result
+ // comes back empty again.
+ alerted_search_.clear();
+
// |web_contents_| can be NULL for a number of reasons, for example when the
// tab is closing. We must guard against that case. See issue 8030.
if (web_contents_) {
@@ -139,14 +143,24 @@ void FindBarController::Observe(int type,
// are actively tracking.
if (content::Source<WebContents>(source).ptr() == web_contents_) {
UpdateFindBarForCurrentResult();
+
+ // A final update can occur multiple times if the document changes.
if (find_tab_helper->find_result().final_update() &&
find_tab_helper->find_result().number_of_matches() == 0) {
const base::string16& last_search =
find_tab_helper->previous_find_text();
const base::string16& current_search = find_tab_helper->find_text();
- if (!base::StartsWith(last_search, current_search,
- base::CompareCase::SENSITIVE)) {
- find_bar_->AudibleAlert();
+
+ // Alert the user once per unique search, if they aren't backspacing.
+ if (current_search != alerted_search_) {
+ // Keep track of the last notified search string, even if the
+ // notification itself is elided.
+ if (!base::StartsWith(last_search, current_search,
+ base::CompareCase::SENSITIVE)) {
+ find_bar_->AudibleAlert();
+ }
+
+ alerted_search_ = current_search;
}
}
}
« no previous file with comments | « chrome/browser/ui/find_bar/find_bar_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698