Commit 101c90eb authored by finnur@chromium.org's avatar finnur@chromium.org

Find-in-page should not ding while deleting characters.

BUG=18120
TEST=Open google.com, type Ctrl+F, type in garbage. Erase one letter at a time and there should be no beeping while you erase. Try it again, but this time use shift-delete to cut a few letters off the end. It should not ding. Now Copy the whole find string, press Esc, open Find again and on Paste it should not ding.

Review URL: http://codereview.chromium.org/338005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30092 0039d316-1c4b-4281-b951-d872f2087c98
parent 7c40973a
...@@ -121,7 +121,10 @@ void FindBarController::Observe(NotificationType type, ...@@ -121,7 +121,10 @@ void FindBarController::Observe(NotificationType type,
UpdateFindBarForCurrentResult(); UpdateFindBarForCurrentResult();
if (tab_contents_->find_result().final_update() && if (tab_contents_->find_result().final_update() &&
tab_contents_->find_result().number_of_matches() == 0) { tab_contents_->find_result().number_of_matches() == 0) {
find_bar_->AudibleAlert(); const string16& last_search = tab_contents_->previous_find_text();
const string16& current_search = tab_contents_->find_text();
if (last_search.find(current_search) != 0)
find_bar_->AudibleAlert();
} }
} }
} else if (type == NotificationType::NAV_ENTRY_COMMITTED) { } else if (type == NotificationType::NAV_ENTRY_COMMITTED) {
......
...@@ -1084,6 +1084,9 @@ void TabContents::StartFinding(string16 find_text, ...@@ -1084,6 +1084,9 @@ void TabContents::StartFinding(string16 find_text,
find_text = *last_search_prepopulate_text_; find_text = *last_search_prepopulate_text_;
} }
// Keep track of the previous search.
previous_find_text_ = find_text_;
// This is a FindNext operation if we are searching for the same text again, // This is a FindNext operation if we are searching for the same text again,
// or if the passed in search text is empty (FindNext keyboard shortcut). The // or if the passed in search text is empty (FindNext keyboard shortcut). The
// exception to this is if the Find was aborted (then we don't want FindNext // exception to this is if the Find was aborted (then we don't want FindNext
...@@ -1117,6 +1120,7 @@ void TabContents::StopFinding(bool clear_selection) { ...@@ -1117,6 +1120,7 @@ void TabContents::StopFinding(bool clear_selection) {
// by the user, but the UI has not been dismissed. // by the user, but the UI has not been dismissed.
if (!clear_selection) if (!clear_selection)
find_ui_active_ = false; find_ui_active_ = false;
find_text_.clear();
find_op_aborted_ = true; find_op_aborted_ = true;
last_search_result_ = FindNotificationDetails(); last_search_result_ = FindNotificationDetails();
render_view_host()->StopFinding(clear_selection); render_view_host()->StopFinding(clear_selection);
......
...@@ -530,6 +530,9 @@ class TabContents : public PageNavigator, ...@@ -530,6 +530,9 @@ class TabContents : public PageNavigator,
// active searches. // active searches.
string16 find_text() const { return find_text_; } string16 find_text() const { return find_text_; }
// Accessor for the previous search we issued.
string16 previous_find_text() const { return previous_find_text_; }
// Accessor for last_search_prepopulate_text_. Used to access the last search // Accessor for last_search_prepopulate_text_. Used to access the last search
// string entered, whatever tab that search was performed in. // string entered, whatever tab that search was performed in.
string16 find_prepopulate_text() const { string16 find_prepopulate_text() const {
...@@ -1105,10 +1108,14 @@ class TabContents : public PageNavigator, ...@@ -1105,10 +1108,14 @@ class TabContents : public PageNavigator,
// This variable keeps track of what the most recent request id is. // This variable keeps track of what the most recent request id is.
int current_find_request_id_; int current_find_request_id_;
// The last string we searched for. This is used to figure out if this is a // The current string we are/just finished searching for. This is used to
// Find or a FindNext operation (FindNext should not increase the request id). // figure out if this is a Find or a FindNext operation (FindNext should not
// increase the request id).
string16 find_text_; string16 find_text_;
// The string we searched for before |find_text_|.
string16 previous_find_text_;
// Whether the last search was case sensitive or not. // Whether the last search was case sensitive or not.
bool last_search_case_sensitive_; bool last_search_case_sensitive_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment