Chromium Code Reviews| 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 "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "chrome/browser/find_bar.h" | 8 #include "chrome/browser/find_bar.h" |
| 9 #include "chrome/browser/tab_contents/navigation_entry.h" | 9 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 10 #include "chrome/common/notification_service.h" | 10 #include "chrome/common/notification_service.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 } | 69 } |
| 70 | 70 |
| 71 if (web_contents_) { | 71 if (web_contents_) { |
| 72 NotificationService::current()->AddObserver( | 72 NotificationService::current()->AddObserver( |
| 73 this, NotificationType::FIND_RESULT_AVAILABLE, | 73 this, NotificationType::FIND_RESULT_AVAILABLE, |
| 74 Source<TabContents>(web_contents_)); | 74 Source<TabContents>(web_contents_)); |
| 75 NotificationService::current()->AddObserver( | 75 NotificationService::current()->AddObserver( |
| 76 this, NotificationType::NAV_ENTRY_COMMITTED, | 76 this, NotificationType::NAV_ENTRY_COMMITTED, |
| 77 Source<NavigationController>(web_contents_->controller())); | 77 Source<NavigationController>(web_contents_->controller())); |
| 78 | 78 |
| 79 // Find out what we should show in the find text box. Usually, this will be | |
| 80 // the last search in this tab, but if no search has been issued in this tab | |
| 81 // we use the last search string (from any tab). | |
| 82 string16 find_string = web_contents_->find_text(); | |
| 83 if (find_string.empty()) | |
| 84 find_string = web_contents_->find_prepopulate_text(); | |
|
Ben Goodger (Google)
2009/04/13 20:48:25
nit: indentation
| |
| 85 | |
| 79 // 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 |
| 80 // 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 |
| 81 // 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 |
| 82 // _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 |
| 83 // 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. |
| 84 find_bar_->SetFindText(web_contents_->find_text()); | 91 find_bar_->SetFindText(find_string); |
| 85 | 92 |
| 86 if (web_contents_->find_ui_active()) { | 93 if (web_contents_->find_ui_active()) { |
| 87 // A tab with a visible find bar just got selected and we need to show the | 94 // A tab with a visible find bar just got selected and we need to show the |
| 88 // find bar but without animation since it was already animated into its | 95 // find bar but without animation since it was already animated into its |
| 89 // visible state. We also want to reset the window location so that | 96 // visible state. We also want to reset the window location so that |
| 90 // we don't surprise the user by popping up to the left for no apparent | 97 // we don't surprise the user by popping up to the left for no apparent |
| 91 // reason. | 98 // reason. |
| 92 gfx::Rect new_pos = find_bar_->GetDialogPosition(gfx::Rect()); | 99 gfx::Rect new_pos = find_bar_->GetDialogPosition(gfx::Rect()); |
| 93 find_bar_->SetDialogPosition(new_pos, false); | 100 find_bar_->SetDialogPosition(new_pos, false); |
| 94 | 101 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 EndFindSession(); | 138 EndFindSession(); |
| 132 } else { | 139 } else { |
| 133 // On Reload we want to make sure FindNext is converted to a full Find | 140 // On Reload we want to make sure FindNext is converted to a full Find |
| 134 // to make sure highlights for inactive matches are repainted. | 141 // to make sure highlights for inactive matches are repainted. |
| 135 web_contents_->set_find_op_aborted(true); | 142 web_contents_->set_find_op_aborted(true); |
| 136 } | 143 } |
| 137 } | 144 } |
| 138 } | 145 } |
| 139 } | 146 } |
| 140 } | 147 } |
| OLD | NEW |