diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-01 16:24:09 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-01 16:24:09 +0000 |
commit | fdfb032b5ba7f106ee7e44580bbda1580af15dbb (patch) | |
tree | 835b3086386b5c5e0abde993e6f082496a105443 /chrome/browser/ui/tab_contents | |
parent | c80580c78a15a2436cce54088921d88540a962e1 (diff) | |
download | chromium_src-fdfb032b5ba7f106ee7e44580bbda1580af15dbb.zip chromium_src-fdfb032b5ba7f106ee7e44580bbda1580af15dbb.tar.gz chromium_src-fdfb032b5ba7f106ee7e44580bbda1580af15dbb.tar.bz2 |
Move find-in-page from TabContents to TabContentsWrapper.
BUG=71097
TEST=Hammer on find-in-page on all platforms. Nothing should crash, break, or have any user-visible change.
Review URL: http://codereview.chromium.org/6378014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73294 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/tab_contents')
4 files changed, 89 insertions, 0 deletions
diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc index 43f4c49..cb44d61 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc @@ -8,6 +8,7 @@ #include "chrome/browser/password_manager/password_manager.h" #include "chrome/browser/password_manager_delegate_impl.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/ui/find_bar/find_manager.h" static base::LazyInstance<PropertyAccessor<TabContentsWrapper*> > g_tab_contents_wrapper_property_accessor(base::LINKER_INITIALIZED); @@ -57,6 +58,15 @@ PasswordManager* TabContentsWrapper::GetPasswordManager() { return password_manager_.get(); } +FindManager* TabContentsWrapper::GetFindManager() { + if (!find_manager_.get()) { + find_manager_.reset(new FindManager(this)); + // Register the manager to receive navigation notifications. + tab_contents()->AddObserver(find_manager_.get()); + } + return find_manager_.get(); +} + //////////////////////////////////////////////////////////////////////////////// // TabContentsWrapper, TabContentsObserver implementation: diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h index 430008f..8172b9a 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h @@ -12,6 +12,7 @@ #include "chrome/browser/tab_contents/tab_contents_observer.h" class Extension; +class FindManager; class NavigationController; class PasswordManager; class PasswordManagerDelegate; @@ -62,6 +63,9 @@ class TabContentsWrapper : public TabContentsObserver { // Returns the PasswordManager, creating it if necessary. PasswordManager* GetPasswordManager(); + // Returns the FindManager, creating it if necessary. + FindManager* GetFindManager(); + // TabContentsObserver overrides: virtual void NavigateToPendingEntry() OVERRIDE; @@ -71,6 +75,9 @@ class TabContentsWrapper : public TabContentsObserver { scoped_ptr<PasswordManagerDelegate> password_manager_delegate_; scoped_ptr<PasswordManager> password_manager_; + // FindManager, lazily created. + scoped_ptr<FindManager> find_manager_; + // The supporting objects need to outlive the TabContents dtor (as they may // be called upon during its execution). As a result, this must come last // in the list. diff --git a/chrome/browser/ui/tab_contents/test_tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/test_tab_contents_wrapper.cc new file mode 100644 index 0000000..10b8a6b --- /dev/null +++ b/chrome/browser/ui/tab_contents/test_tab_contents_wrapper.cc @@ -0,0 +1,40 @@ +// Copyright (c) 2011 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. + +#include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" + +#include "chrome/browser/tab_contents/test_tab_contents.h" +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" +#include "chrome/test/testing_profile.h" + +TabContentsWrapperTestHarness::TabContentsWrapperTestHarness() + : RenderViewHostTestHarness() { +} + +TabContentsWrapperTestHarness::~TabContentsWrapperTestHarness() { +} + +TestTabContents* TabContentsWrapperTestHarness::contents() { + return static_cast<TestTabContents*>(contents_wrapper_.get()->tab_contents()); +} + +TabContentsWrapper* TabContentsWrapperTestHarness::contents_wrapper() { + return contents_wrapper_.get(); +} + +void TabContentsWrapperTestHarness::SetUp() { + contents_wrapper_.reset(new TabContentsWrapper(CreateTestTabContents())); +} + +void TabContentsWrapperTestHarness::TearDown() { + contents_wrapper_.reset(); + + // Make sure that we flush any messages related to TabContents destruction + // before we destroy the profile. + MessageLoop::current()->RunAllPending(); + + // Release the profile on the UI thread. + message_loop_.DeleteSoon(FROM_HERE, profile_.release()); + message_loop_.RunAllPending(); +} diff --git a/chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h b/chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h new file mode 100644 index 0000000..9c60c12 --- /dev/null +++ b/chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h @@ -0,0 +1,32 @@ +// Copyright (c) 2011 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. + +#ifndef CHROME_BROWSER_UI_TAB_CONTENTS_TEST_TAB_CONTENTS_WRAPPER_H_ +#define CHROME_BROWSER_UI_TAB_CONTENTS_TEST_TAB_CONTENTS_WRAPPER_H_ +#pragma once + +#include "base/compiler_specific.h" +#include "chrome/browser/renderer_host/test/test_render_view_host.h" + +class TabContentsWrapper; + +class TabContentsWrapperTestHarness : public RenderViewHostTestHarness { + public: + TabContentsWrapperTestHarness(); + virtual ~TabContentsWrapperTestHarness(); + + TestTabContents* contents(); + TabContentsWrapper* contents_wrapper(); + + protected: + // testing::Test + virtual void SetUp() OVERRIDE; + virtual void TearDown() OVERRIDE; + + scoped_ptr<TabContentsWrapper> contents_wrapper_; + + DISALLOW_COPY_AND_ASSIGN(TabContentsWrapperTestHarness); +}; + +#endif // CHROME_BROWSER_UI_TAB_CONTENTS_TEST_TAB_CONTENTS_WRAPPER_H_ |