summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser.cc
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-05 04:52:58 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-05 04:52:58 +0000
commit4801ecc5ce684ec8556769cb173506b4645c618b (patch)
tree526495f64269f04390ff3ef7f313513495fc36e9 /chrome/browser/browser.cc
parent19e7dbd299d4b4281ade12550870b0cb15f0193d (diff)
downloadchromium_src-4801ecc5ce684ec8556769cb173506b4645c618b.zip
chromium_src-4801ecc5ce684ec8556769cb173506b4645c618b.tar.gz
chromium_src-4801ecc5ce684ec8556769cb173506b4645c618b.tar.bz2
Moving the Find bar ownership to the Browser object for portability and testability purposes.BUG=None.TEST=No new functionality, just moving stuff around and as such it is covered by pre-existing tests.
Review URL: http://codereview.chromium.org/60105 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13134 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser.cc')
-rw-r--r--chrome/browser/browser.cc25
1 files changed, 23 insertions, 2 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 16544fd..119c5aa 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-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.
@@ -16,6 +16,8 @@
#include "chrome/browser/browser_window.h"
#include "chrome/browser/character_encoding.h"
#include "chrome/browser/debugger/devtools_manager.h"
+#include "chrome/browser/find_bar.h"
+#include "chrome/browser/find_bar_controller.h"
#include "chrome/browser/location_bar.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/net/url_fixer_upper.h"
@@ -279,6 +281,12 @@ void Browser::CreateBrowserWindow() {
local_state->ClearPref(prefs::kShouldShowFirstRunBubble);
window_->GetLocationBar()->ShowFirstRunBubble();
}
+
+#if defined(OS_WIN)
+ FindBar* find_bar = BrowserWindow::CreateFindBar(this);
+ find_bar_controller_.reset(new FindBarController(find_bar));
+ find_bar->SetFindBarController(find_bar_controller_.get());
+#endif
}
///////////////////////////////////////////////////////////////////////////////
@@ -779,6 +787,10 @@ void Browser::ViewSource() {
}
}
+void Browser::ShowFindBar() {
+ find_bar_controller_->Show();
+}
+
bool Browser::SupportsWindowFeature(WindowFeature feature) const {
unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF;
if (type() == TYPE_NORMAL)
@@ -1495,6 +1507,9 @@ void Browser::TabDetachedAt(TabContents* contents, int index) {
RemoveScheduledUpdatesFor(contents);
+ if (find_bar_controller_.get() && index == tabstrip_model_.selected_index())
+ find_bar_controller_->ChangeWebContents(NULL);
+
NotificationService::current()->RemoveObserver(
this,
NotificationType::WEB_CONTENTS_DISCONNECTED,
@@ -1539,6 +1554,12 @@ void Browser::TabSelectedAt(TabContents* old_contents,
status_bubble->SetStatus(GetSelectedTabContents()->GetStatusText());
}
+ if (find_bar_controller_.get()) {
+ find_bar_controller_->ChangeWebContents(new_contents->AsWebContents());
+ find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(),
+ true);
+ }
+
// Update sessions. Don't force creation of sessions. If sessions doesn't
// exist, the change will be picked up by sessions when created.
if (profile_->HasSessionService()) {
@@ -2487,7 +2508,7 @@ GURL Browser::GetHomePage() const {
}
void Browser::FindInPage(bool find_next, bool forward_direction) {
- window_->ShowFindBar();
+ ShowFindBar();
if (find_next) {
GetSelectedTabContents()->AsWebContents()->StartFinding(
string16(),