| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 } | 68 } |
| 69 | 69 |
| 70 if (!tab_contents_) | 70 if (!tab_contents_) |
| 71 return; | 71 return; |
| 72 | 72 |
| 73 registrar_.Add(this, NotificationType::FIND_RESULT_AVAILABLE, | 73 registrar_.Add(this, NotificationType::FIND_RESULT_AVAILABLE, |
| 74 Source<TabContents>(tab_contents_)); | 74 Source<TabContents>(tab_contents_)); |
| 75 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, | 75 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, |
| 76 Source<NavigationController>(&tab_contents_->controller())); | 76 Source<NavigationController>(&tab_contents_->controller())); |
| 77 | 77 |
| 78 #if !defined(OS_MACOSX) |
| 78 // Find out what we should show in the find text box. Usually, this will be | 79 // Find out what we should show in the find text box. Usually, this will be |
| 79 // the last search in this tab, but if no search has been issued in this tab | 80 // the last search in this tab, but if no search has been issued in this tab |
| 80 // we use the last search string (from any tab). | 81 // we use the last search string (from any tab). |
| 81 string16 find_string = tab_contents_->find_text(); | 82 string16 find_string = tab_contents_->find_text(); |
| 82 if (find_string.empty()) | 83 if (find_string.empty()) |
| 83 find_string = tab_contents_->find_prepopulate_text(); | 84 find_string = tab_contents_->find_prepopulate_text(); |
| 84 | 85 |
| 85 // Update the find bar with existing results and search text, regardless of | 86 // Update the find bar with existing results and search text, regardless of |
| 86 // whether or not the find bar is visible, so that if it's subsequently | 87 // whether or not the find bar is visible, so that if it's subsequently |
| 87 // shown it is showing the right state for this tab. We update the find text | 88 // shown it is showing the right state for this tab. We update the find text |
| 88 // _first_ since the FindBarView checks its emptiness to see if it should | 89 // _first_ since the FindBarView checks its emptiness to see if it should |
| 89 // clear the result count display when there's nothing in the box. | 90 // clear the result count display when there's nothing in the box. |
| 90 find_bar_->SetFindText(find_string); | 91 find_bar_->SetFindText(find_string); |
| 92 #else |
| 93 // Having a per-tab find_string is not compatible with OS X's find pasteboard, |
| 94 // so we always have the same find text in all find bars. This is done through |
| 95 // the find pasteboard mechanism, so don't set the text here. |
| 96 #endif |
| 91 | 97 |
| 92 if (tab_contents_->find_ui_active()) { | 98 if (tab_contents_->find_ui_active()) { |
| 93 // A tab with a visible find bar just got selected and we need to show the | 99 // A tab with a visible find bar just got selected and we need to show the |
| 94 // find bar but without animation since it was already animated into its | 100 // find bar but without animation since it was already animated into its |
| 95 // visible state. We also want to reset the window location so that | 101 // visible state. We also want to reset the window location so that |
| 96 // we don't surprise the user by popping up to the left for no apparent | 102 // we don't surprise the user by popping up to the left for no apparent |
| 97 // reason. | 103 // reason. |
| 98 gfx::Rect new_pos = find_bar_->GetDialogPosition(gfx::Rect()); | 104 gfx::Rect new_pos = find_bar_->GetDialogPosition(gfx::Rect()); |
| 99 find_bar_->SetDialogPosition(new_pos, false); | 105 find_bar_->SetDialogPosition(new_pos, false); |
| 100 } | 106 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 if (find_result.number_of_matches() > -1) { | 201 if (find_result.number_of_matches() > -1) { |
| 196 if (last_reported_matchcount_ > 0 && | 202 if (last_reported_matchcount_ > 0 && |
| 197 find_result.number_of_matches() == 1 && | 203 find_result.number_of_matches() == 1 && |
| 198 !find_result.final_update()) | 204 !find_result.final_update()) |
| 199 return; // Don't let interim result override match count. | 205 return; // Don't let interim result override match count. |
| 200 last_reported_matchcount_ = find_result.number_of_matches(); | 206 last_reported_matchcount_ = find_result.number_of_matches(); |
| 201 } | 207 } |
| 202 | 208 |
| 203 find_bar_->UpdateUIForFindResult(find_result, tab_contents_->find_text()); | 209 find_bar_->UpdateUIForFindResult(find_result, tab_contents_->find_text()); |
| 204 } | 210 } |
| OLD | NEW |