diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-13 22:16:03 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-13 22:16:03 +0000 |
commit | 732286a0ef1cb3a91b691c59343bf809d3486299 (patch) | |
tree | e2530581e98a1fcf476677a21efd3fed29941a6c /chrome/browser/find_bar_controller.cc | |
parent | 9665fa68fd7f65d34ee1796641649466e74f6cd7 (diff) | |
download | chromium_src-732286a0ef1cb3a91b691c59343bf809d3486299.zip chromium_src-732286a0ef1cb3a91b691c59343bf809d3486299.tar.gz chromium_src-732286a0ef1cb3a91b691c59343bf809d3486299.tar.bz2 |
Once you search for something in a tab, you are very likely to search for the same thing in another tab. Therefore, if you haven't searched for anything within that tab then Chrome should prepopulate the Find box with the last string you searched for (in any tab).
BUG=876
TEST=Open google.com, Ctrl+F, search for 'e'. Open a new tab/new window/open a link in a new window. In all of those new tabs the Find box should be prepopulated with 'e' that is selected (for easy overwriting).
Review URL: http://codereview.chromium.org/67066
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13613 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/find_bar_controller.cc')
-rw-r--r-- | chrome/browser/find_bar_controller.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/chrome/browser/find_bar_controller.cc b/chrome/browser/find_bar_controller.cc index adb7c067..bdcb94b 100644 --- a/chrome/browser/find_bar_controller.cc +++ b/chrome/browser/find_bar_controller.cc @@ -76,12 +76,19 @@ void FindBarController::ChangeWebContents(WebContents* contents) { this, NotificationType::NAV_ENTRY_COMMITTED, Source<NavigationController>(web_contents_->controller())); + // Find out what we should show in the find text box. Usually, this will be + // the last search in this tab, but if no search has been issued in this tab + // we use the last search string (from any tab). + string16 find_string = web_contents_->find_text(); + if (find_string.empty()) + find_string = web_contents_->find_prepopulate_text(); + // Update the find bar with existing results and search text, regardless of // whether or not the find bar is visible, so that if it's subsequently // shown it is showing the right state for this tab. We update the find text // _first_ since the FindBarView checks its emptiness to see if it should // clear the result count display when there's nothing in the box. - find_bar_->SetFindText(web_contents_->find_text()); + find_bar_->SetFindText(find_string); if (web_contents_->find_ui_active()) { // A tab with a visible find bar just got selected and we need to show the |