OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/find_bar_controller.h" | 5 #include "chrome/browser/find_bar_controller.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "chrome/browser/find_bar.h" | 9 #include "chrome/browser/find_bar.h" |
10 #include "chrome/browser/tab_contents/navigation_entry.h" | 10 #include "chrome/browser/tab_contents/navigation_entry.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 void FindBarController::Observe(NotificationType type, | 114 void FindBarController::Observe(NotificationType type, |
115 const NotificationSource& source, | 115 const NotificationSource& source, |
116 const NotificationDetails& details) { | 116 const NotificationDetails& details) { |
117 if (type == NotificationType::FIND_RESULT_AVAILABLE) { | 117 if (type == NotificationType::FIND_RESULT_AVAILABLE) { |
118 // Don't update for notifications from TabContentses other than the one we | 118 // Don't update for notifications from TabContentses other than the one we |
119 // are actively tracking. | 119 // are actively tracking. |
120 if (Source<TabContents>(source).ptr() == tab_contents_) { | 120 if (Source<TabContents>(source).ptr() == tab_contents_) { |
121 UpdateFindBarForCurrentResult(); | 121 UpdateFindBarForCurrentResult(); |
122 if (tab_contents_->find_result().final_update() && | 122 if (tab_contents_->find_result().final_update() && |
123 tab_contents_->find_result().number_of_matches() == 0) { | 123 tab_contents_->find_result().number_of_matches() == 0) { |
124 find_bar_->AudibleAlert(); | 124 const string16& last_search = tab_contents_->previous_find_text(); |
125 const string16& current_search = tab_contents_->find_text(); | |
126 if (last_search.find(current_search) != 0) | |
Peter Kasting
2009/10/26 21:04:33
Nit: If you want, you can inline those temps into
| |
127 find_bar_->AudibleAlert(); | |
125 } | 128 } |
126 } | 129 } |
127 } else if (type == NotificationType::NAV_ENTRY_COMMITTED) { | 130 } else if (type == NotificationType::NAV_ENTRY_COMMITTED) { |
128 NavigationController* source_controller = | 131 NavigationController* source_controller = |
129 Source<NavigationController>(source).ptr(); | 132 Source<NavigationController>(source).ptr(); |
130 if (source_controller == &tab_contents_->controller()) { | 133 if (source_controller == &tab_contents_->controller()) { |
131 NavigationController::LoadCommittedDetails* commit_details = | 134 NavigationController::LoadCommittedDetails* commit_details = |
132 Details<NavigationController::LoadCommittedDetails>(details).ptr(); | 135 Details<NavigationController::LoadCommittedDetails>(details).ptr(); |
133 PageTransition::Type transition_type = | 136 PageTransition::Type transition_type = |
134 commit_details->entry->transition_type(); | 137 commit_details->entry->transition_type(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 if (find_result.number_of_matches() > -1) { | 204 if (find_result.number_of_matches() > -1) { |
202 if (last_reported_matchcount_ > 0 && | 205 if (last_reported_matchcount_ > 0 && |
203 find_result.number_of_matches() == 1 && | 206 find_result.number_of_matches() == 1 && |
204 !find_result.final_update()) | 207 !find_result.final_update()) |
205 return; // Don't let interim result override match count. | 208 return; // Don't let interim result override match count. |
206 last_reported_matchcount_ = find_result.number_of_matches(); | 209 last_reported_matchcount_ = find_result.number_of_matches(); |
207 } | 210 } |
208 | 211 |
209 find_bar_->UpdateUIForFindResult(find_result, tab_contents_->find_text()); | 212 find_bar_->UpdateUIForFindResult(find_result, tab_contents_->find_text()); |
210 } | 213 } |
OLD | NEW |