summaryrefslogtreecommitdiffstats
path: root/chrome/browser/intents
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-30 15:07:08 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-30 15:07:08 +0000
commit95a33ed6cb8688573249f7cd7032d23518879c6d (patch)
tree77c2f8d28412caa3aeb6cdb94de420bb811113d6 /chrome/browser/intents
parent14ea9bf12826e740fd77fda742e67605df06ce4a (diff)
downloadchromium_src-95a33ed6cb8688573249f7cd7032d23518879c6d.zip
chromium_src-95a33ed6cb8688573249f7cd7032d23518879c6d.tar.gz
chromium_src-95a33ed6cb8688573249f7cd7032d23518879c6d.tar.bz2
Move infobar handling to a tab helper.
Part 2: - Removed TabContentsWrapper from core infobar classes - Made InfoBarTabHelper the owner of the infobar delegates - Removed all owner references from the delegate subclasses BUG=94741 TEST=no visible change Review URL: http://codereview.chromium.org/7862003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103463 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/intents')
-rw-r--r--chrome/browser/intents/register_intent_handler_infobar_delegate.cc14
-rw-r--r--chrome/browser/intents/register_intent_handler_infobar_delegate.h12
-rw-r--r--chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc22
3 files changed, 20 insertions, 28 deletions
diff --git a/chrome/browser/intents/register_intent_handler_infobar_delegate.cc b/chrome/browser/intents/register_intent_handler_infobar_delegate.cc
index 58206dc..4c711e4 100644
--- a/chrome/browser/intents/register_intent_handler_infobar_delegate.cc
+++ b/chrome/browser/intents/register_intent_handler_infobar_delegate.cc
@@ -9,15 +9,15 @@
#include "chrome/browser/intents/web_intents_registry.h"
#include "chrome/browser/intents/web_intents_registry_factory.h"
#include "chrome/browser/profiles/profile.h"
-#include "content/browser/tab_contents/tab_contents.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
RegisterIntentHandlerInfoBarDelegate::RegisterIntentHandlerInfoBarDelegate(
- TabContents* tab_contents, const WebIntentServiceData& service)
- : ConfirmInfoBarDelegate(tab_contents),
- tab_contents_(tab_contents),
- profile_(Profile::FromBrowserContext(tab_contents->browser_context())),
+ InfoBarTabHelper* infobar_helper,
+ WebIntentsRegistry* registry,
+ const WebIntentServiceData& service)
+ : ConfirmInfoBarDelegate(infobar_helper),
+ registry_(registry),
service_(service) {
}
@@ -45,9 +45,7 @@ string16 RegisterIntentHandlerInfoBarDelegate::GetButtonLabel(
}
bool RegisterIntentHandlerInfoBarDelegate::Accept() {
- WebIntentsRegistry* registry =
- WebIntentsRegistryFactory::GetForProfile(profile_);
- registry->RegisterIntentProvider(service_);
+ registry_->RegisterIntentProvider(service_);
return true;
}
diff --git a/chrome/browser/intents/register_intent_handler_infobar_delegate.h b/chrome/browser/intents/register_intent_handler_infobar_delegate.h
index cd887e1..83ae2fa 100644
--- a/chrome/browser/intents/register_intent_handler_infobar_delegate.h
+++ b/chrome/browser/intents/register_intent_handler_infobar_delegate.h
@@ -11,14 +11,15 @@
#include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
#include "webkit/glue/web_intent_service_data.h"
-class Profile;
class TabContents;
+class WebIntentsRegistry;
// The InfoBar used to request permission for a site to be registered as an
// Intent handler.
class RegisterIntentHandlerInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
- RegisterIntentHandlerInfoBarDelegate(TabContents* tab_contents,
+ RegisterIntentHandlerInfoBarDelegate(InfoBarTabHelper* infobar_helper,
+ WebIntentsRegistry* registry,
const WebIntentServiceData& service);
// ConfirmInfoBarDelegate implementation.
@@ -30,11 +31,8 @@ class RegisterIntentHandlerInfoBarDelegate : public ConfirmInfoBarDelegate {
virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
private:
- // The TabContents that contains this InfoBar. Weak pointer.
- TabContents* tab_contents_;
-
- // The profile associated with |tab_contents_|. Weak pointer.
- Profile* profile_;
+ // The web intents registry to use. Weak pointer.
+ WebIntentsRegistry* registry_;
// The cached intent data bundle passed up from the renderer.
WebIntentServiceData service_;
diff --git a/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc b/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc
index 56b08d5..32dcfac 100644
--- a/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc
+++ b/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc
@@ -2,15 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/memory/scoped_ptr.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/intents/register_intent_handler_infobar_delegate.h"
#include "chrome/browser/intents/web_intents_registry.h"
#include "chrome/browser/intents/web_intents_registry_factory.h"
-#include "chrome/test/base/chrome_render_view_host_test_harness.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
+#include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h"
#include "chrome/test/base/testing_profile.h"
#include "content/browser/browser_thread.h"
-#include "content/browser/site_instance.h"
#include "content/browser/tab_contents/test_tab_contents.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -34,30 +33,24 @@ MockWebIntentsRegistry* BuildForProfile(Profile* profile) {
}
class RegisterIntentHandlerInfoBarDelegateTest
- : public ChromeRenderViewHostTestHarness {
+ : public TabContentsWrapperTestHarness {
protected:
RegisterIntentHandlerInfoBarDelegateTest()
: ui_thread_(BrowserThread::UI, MessageLoopForUI::current()) {}
virtual void SetUp() {
- ChromeRenderViewHostTestHarness::SetUp();
+ TabContentsWrapperTestHarness::SetUp();
profile()->CreateWebDataService(false);
-
- SiteInstance* instance = SiteInstance::CreateSiteInstance(profile());
- tab_contents_.reset(new TestTabContents(profile(), instance));
-
web_intents_registry_ = BuildForProfile(profile());
}
virtual void TearDown() {
- tab_contents_.reset();
web_intents_registry_ = NULL;
- ChromeRenderViewHostTestHarness::TearDown();
+ TabContentsWrapperTestHarness::TearDown();
}
- scoped_ptr<TestTabContents> tab_contents_;
MockWebIntentsRegistry* web_intents_registry_;
private:
@@ -71,7 +64,10 @@ TEST_F(RegisterIntentHandlerInfoBarDelegateTest, Accept) {
service.service_url = GURL("google.com");
service.action = ASCIIToUTF16("http://webintents.org/share");
service.type = ASCIIToUTF16("text/url");
- RegisterIntentHandlerInfoBarDelegate delegate(tab_contents_.get(), service);
+ RegisterIntentHandlerInfoBarDelegate delegate(
+ contents_wrapper()->infobar_tab_helper(),
+ WebIntentsRegistryFactory::GetForProfile(profile()),
+ service);
EXPECT_CALL(*web_intents_registry_, RegisterIntentProvider(service));
delegate.Accept();