| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/find_bar/find_bar_controller.h" | 5 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/strings/string_util.h" |
| 11 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 12 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/find_bar/find_bar.h" | 15 #include "chrome/browser/ui/find_bar/find_bar.h" |
| 15 #include "chrome/browser/ui/find_bar/find_bar_state.h" | 16 #include "chrome/browser/ui/find_bar/find_bar_state.h" |
| 16 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h" | 17 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h" |
| 17 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 18 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
| 18 #include "content/public/browser/navigation_details.h" | 19 #include "content/public/browser/navigation_details.h" |
| 19 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
| 20 #include "content/public/browser/notification_details.h" | 21 #include "content/public/browser/notification_details.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 if (type == chrome::NOTIFICATION_FIND_RESULT_AVAILABLE) { | 137 if (type == chrome::NOTIFICATION_FIND_RESULT_AVAILABLE) { |
| 137 // Don't update for notifications from WebContentses other than the one we | 138 // Don't update for notifications from WebContentses other than the one we |
| 138 // are actively tracking. | 139 // are actively tracking. |
| 139 if (content::Source<WebContents>(source).ptr() == web_contents_) { | 140 if (content::Source<WebContents>(source).ptr() == web_contents_) { |
| 140 UpdateFindBarForCurrentResult(); | 141 UpdateFindBarForCurrentResult(); |
| 141 if (find_tab_helper->find_result().final_update() && | 142 if (find_tab_helper->find_result().final_update() && |
| 142 find_tab_helper->find_result().number_of_matches() == 0) { | 143 find_tab_helper->find_result().number_of_matches() == 0) { |
| 143 const base::string16& last_search = | 144 const base::string16& last_search = |
| 144 find_tab_helper->previous_find_text(); | 145 find_tab_helper->previous_find_text(); |
| 145 const base::string16& current_search = find_tab_helper->find_text(); | 146 const base::string16& current_search = find_tab_helper->find_text(); |
| 146 if (last_search.find(current_search) != 0) | 147 if (base::StartsWith(last_search, current_search, |
| 148 base::CompareCase::SENSITIVE)) { |
| 147 find_bar_->AudibleAlert(); | 149 find_bar_->AudibleAlert(); |
| 150 } |
| 148 } | 151 } |
| 149 } | 152 } |
| 150 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { | 153 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { |
| 151 NavigationController* source_controller = | 154 NavigationController* source_controller = |
| 152 content::Source<NavigationController>(source).ptr(); | 155 content::Source<NavigationController>(source).ptr(); |
| 153 if (source_controller == &web_contents_->GetController()) { | 156 if (source_controller == &web_contents_->GetController()) { |
| 154 content::LoadCommittedDetails* commit_details = | 157 content::LoadCommittedDetails* commit_details = |
| 155 content::Details<content::LoadCommittedDetails>(details).ptr(); | 158 content::Details<content::LoadCommittedDetails>(details).ptr(); |
| 156 ui::PageTransition transition_type = | 159 ui::PageTransition transition_type = |
| 157 commit_details->entry->GetTransitionType(); | 160 commit_details->entry->GetTransitionType(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 } | 253 } |
| 251 | 254 |
| 252 // Update the find bar with existing results and search text, regardless of | 255 // Update the find bar with existing results and search text, regardless of |
| 253 // whether or not the find bar is visible, so that if it's subsequently | 256 // whether or not the find bar is visible, so that if it's subsequently |
| 254 // shown it is showing the right state for this tab. We update the find text | 257 // shown it is showing the right state for this tab. We update the find text |
| 255 // _first_ since the FindBarView checks its emptiness to see if it should | 258 // _first_ since the FindBarView checks its emptiness to see if it should |
| 256 // clear the result count display when there's nothing in the box. | 259 // clear the result count display when there's nothing in the box. |
| 257 find_bar_->SetFindTextAndSelectedRange(find_string, | 260 find_bar_->SetFindTextAndSelectedRange(find_string, |
| 258 find_tab_helper->selected_range()); | 261 find_tab_helper->selected_range()); |
| 259 } | 262 } |
| OLD | NEW |