summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/find_bar_controller.cc9
-rw-r--r--chrome/browser/tab_contents/web_contents.cc12
-rw-r--r--chrome/browser/tab_contents/web_contents.h7
3 files changed, 25 insertions, 3 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
diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc
index b91c693..81c3e7a 100644
--- a/chrome/browser/tab_contents/web_contents.cc
+++ b/chrome/browser/tab_contents/web_contents.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -208,7 +208,8 @@ WebContents::WebContents(Profile* profile,
load_state_(net::LOAD_STATE_IDLE),
find_ui_active_(false),
find_op_aborted_(false),
- current_find_request_id_(find_request_id_counter_++) {
+ current_find_request_id_(find_request_id_counter_++),
+ find_prepopulate_text_(NULL) {
pending_install_.page_id = 0;
pending_install_.callback_functor = NULL;
@@ -232,6 +233,10 @@ WebContents::WebContents(Profile* profile,
NotificationService::current()->AddObserver(
this, NotificationType::RENDER_WIDGET_HOST_DESTROYED,
NotificationService::AllSources());
+
+ // Keep a global copy of the previous search string (if any).
+ static string16 global_last_search = string16();
+ find_prepopulate_text_ = &global_last_search;
}
WebContents::~WebContents() {
@@ -625,6 +630,9 @@ void WebContents::StartFinding(const string16& find_text,
find_op_aborted_ = false;
+ // Keep track of what the last search was across the tabs.
+ *find_prepopulate_text_ = find_text;
+
render_view_host()->StartFinding(current_find_request_id_,
find_text_,
forward_direction,
diff --git a/chrome/browser/tab_contents/web_contents.h b/chrome/browser/tab_contents/web_contents.h
index 6164ddb..0e62e8d 100644
--- a/chrome/browser/tab_contents/web_contents.h
+++ b/chrome/browser/tab_contents/web_contents.h
@@ -225,6 +225,10 @@ class WebContents : public TabContents,
// active searches.
string16 find_text() const { return find_text_; }
+ // Accessor for find_prepopulate_text_. Used to access the last search
+ // string entered, whatever tab that search was performed in.
+ string16 find_prepopulate_text() const { return *find_prepopulate_text_; }
+
// Accessor for find_result_.
const FindNotificationDetails& find_result() const { return find_result_; }
@@ -696,6 +700,9 @@ class WebContents : public TabContents,
// Find or a FindNext operation (FindNext should not increase the request id).
string16 find_text_;
+ // Keeps track of the last search string that was used to search in any tab.
+ string16* find_prepopulate_text_;
+
// The last find result. This object contains details about the number of
// matches, the find selection rectangle, etc. The UI can access this
// information to build its presentation.