diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-24 18:02:24 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-24 18:02:24 +0000 |
commit | f452e1aa97fbcd7e3d5560fc456819bf40e5c57c (patch) | |
tree | ea8a035b9c7d70934e8b1f8f5b749cc8c33b5800 | |
parent | 69b5f78973bcf5ee06c3b7a30a1e513615a2e2c5 (diff) | |
download | chromium_src-f452e1aa97fbcd7e3d5560fc456819bf40e5c57c.zip chromium_src-f452e1aa97fbcd7e3d5560fc456819bf40e5c57c.tar.gz chromium_src-f452e1aa97fbcd7e3d5560fc456819bf40e5c57c.tar.bz2 |
Misc. infobar stuff:
* Move the cross-platform parts of InfoBar and InfoBarContainer to chrome/browser/tab_contents (but place them under a TOOLKIT_VIEWS #ifdef until other platforms are ported).
* Plumb the "owning" TabContentsWrapper* through the infobar creation APIs. Ultimately the InfoBar will use this (when TabContents actually starts owning InfoBar*s), but for now it just stores it as an unused member.
* A few random other small changes.
BUG=62154
TEST=none
Review URL: http://codereview.chromium.org/6989001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86450 0039d316-1c4b-4281-b951-d872f2087c98
42 files changed, 205 insertions, 185 deletions
diff --git a/chrome/browser/autofill/autofill_metrics_unittest.cc b/chrome/browser/autofill/autofill_metrics_unittest.cc index c84d063..2616ce6 100644 --- a/chrome/browser/autofill/autofill_metrics_unittest.cc +++ b/chrome/browser/autofill/autofill_metrics_unittest.cc @@ -182,22 +182,15 @@ class TestFormStructure : public FormStructure { class AutofillMetricsTest : public TabContentsWrapperTestHarness { public: - AutofillMetricsTest() {} - virtual ~AutofillMetricsTest() { - // Order of destruction is important as AutofillManager relies on - // PersonalDataManager to be around when it gets destroyed. - autofill_manager_.reset(NULL); - test_personal_data_ = NULL; - } + AutofillMetricsTest(); + virtual ~AutofillMetricsTest(); - virtual void SetUp() { - TabContentsWrapperTestHarness::SetUp(); - test_personal_data_ = new TestPersonalDataManager(); - autofill_manager_.reset(new TestAutofillManager(contents_wrapper(), - test_personal_data_.get())); - } + virtual void SetUp(); protected: + AutofillCCInfoBarDelegate* CreateDelegate(MockAutofillMetrics* metric_logger, + CreditCard** created_card); + scoped_ptr<TestAutofillManager> autofill_manager_; scoped_refptr<TestPersonalDataManager> test_personal_data_; @@ -205,6 +198,36 @@ class AutofillMetricsTest : public TabContentsWrapperTestHarness { DISALLOW_COPY_AND_ASSIGN(AutofillMetricsTest); }; +AutofillMetricsTest::AutofillMetricsTest() { +} + +AutofillMetricsTest::~AutofillMetricsTest() { + // Order of destruction is important as AutofillManager relies on + // PersonalDataManager to be around when it gets destroyed. + autofill_manager_.reset(NULL); + test_personal_data_ = NULL; +} + +void AutofillMetricsTest::SetUp() { + TabContentsWrapperTestHarness::SetUp(); + test_personal_data_ = new TestPersonalDataManager(); + autofill_manager_.reset(new TestAutofillManager(contents_wrapper(), + test_personal_data_.get())); +} + +AutofillCCInfoBarDelegate* AutofillMetricsTest::CreateDelegate( + MockAutofillMetrics* metric_logger, + CreditCard** created_card) { + EXPECT_CALL(*metric_logger, + LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); + // The delegate created below will take ownership of this object. + CreditCard* credit_card = new CreditCard(); + if (created_card) + *created_card = credit_card; + return new AutofillCCInfoBarDelegate(contents(), credit_card, + test_personal_data_.get(), metric_logger); +} + // Test that we log quality metrics appropriately. TEST_F(AutofillMetricsTest, QualityMetrics) { // Set up our form data. @@ -893,76 +916,46 @@ TEST_F(AutofillMetricsTest, AutofillIsEnabledAtPageLoad) { // Test that credit card infobar metrics are logged correctly. TEST_F(AutofillMetricsTest, CreditCardInfoBar) { MockAutofillMetrics metric_logger; - CreditCard* credit_card; - AutofillCCInfoBarDelegate* infobar; ::testing::InSequence dummy; // Accept the infobar. - EXPECT_CALL(metric_logger, - LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); - credit_card = new CreditCard(); - infobar = new AutofillCCInfoBarDelegate(contents(), - credit_card, - test_personal_data_.get(), - &metric_logger); - - EXPECT_CALL(*test_personal_data_.get(), SaveImportedCreditCard(*credit_card)); - EXPECT_CALL(metric_logger, - LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_ACCEPTED)) - .Times(1); - EXPECT_CALL(metric_logger, - LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_IGNORED)) - .Times(0); - EXPECT_TRUE(infobar->Accept()); - infobar->InfoBarClosed(); + { + CreditCard* credit_card; + scoped_ptr<InfoBarDelegate> infobar(CreateDelegate(&metric_logger, + &credit_card)); + EXPECT_CALL(*test_personal_data_.get(), + SaveImportedCreditCard(*credit_card)); + EXPECT_CALL(metric_logger, + LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_ACCEPTED)).Times(1); + EXPECT_CALL(metric_logger, + LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_IGNORED)).Times(0); + EXPECT_TRUE(static_cast<ConfirmInfoBarDelegate*>(infobar.get())->Accept()); + } // Cancel the infobar. - EXPECT_CALL(metric_logger, - LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); - credit_card = new CreditCard(); - infobar = new AutofillCCInfoBarDelegate(contents(), - credit_card, - test_personal_data_.get(), - &metric_logger); - - EXPECT_CALL(metric_logger, - LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_DENIED)) - .Times(1); - EXPECT_CALL(metric_logger, - LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_IGNORED)) - .Times(0); - EXPECT_TRUE(infobar->Cancel()); - infobar->InfoBarClosed(); + { + scoped_ptr<InfoBarDelegate> infobar(CreateDelegate(&metric_logger, NULL)); + EXPECT_CALL(metric_logger, + LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_DENIED)).Times(1); + EXPECT_CALL(metric_logger, + LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_IGNORED)).Times(0); + EXPECT_TRUE(static_cast<ConfirmInfoBarDelegate*>(infobar.get())->Cancel()); + } // Dismiss the infobar. - EXPECT_CALL(metric_logger, - LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); - credit_card = new CreditCard(); - infobar = new AutofillCCInfoBarDelegate(contents(), - credit_card, - test_personal_data_.get(), - &metric_logger); - - EXPECT_CALL(metric_logger, - LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_DENIED)) - .Times(1); - EXPECT_CALL(metric_logger, - LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_IGNORED)) - .Times(0); - infobar->InfoBarDismissed(); - infobar->InfoBarClosed(); + { + scoped_ptr<InfoBarDelegate> infobar(CreateDelegate(&metric_logger, NULL)); + EXPECT_CALL(metric_logger, + LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_DENIED)).Times(1); + EXPECT_CALL(metric_logger, + LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_IGNORED)).Times(0); + infobar->InfoBarDismissed(); + } // Ignore the infobar. - EXPECT_CALL(metric_logger, - LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); - credit_card = new CreditCard(); - infobar = new AutofillCCInfoBarDelegate(contents(), - credit_card, - test_personal_data_.get(), - &metric_logger); - - EXPECT_CALL(metric_logger, - LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_IGNORED)) - .Times(1); - infobar->InfoBarClosed(); + { + scoped_ptr<InfoBarDelegate> infobar(CreateDelegate(&metric_logger, NULL)); + EXPECT_CALL(metric_logger, + LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_IGNORED)).Times(1); + } } diff --git a/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.h b/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.h index f71f6aa..855901b 100644 --- a/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.h +++ b/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.h @@ -10,7 +10,6 @@ #include "chrome/browser/custom_handlers/protocol_handler.h" #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" -class SkBitmap; class ProtocolHandlerRegistry; class TabContents; diff --git a/chrome/browser/extensions/extension_infobar_delegate.h b/chrome/browser/extensions/extension_infobar_delegate.h index 9a3385d..7f46e85 100644 --- a/chrome/browser/extensions/extension_infobar_delegate.h +++ b/chrome/browser/extensions/extension_infobar_delegate.h @@ -11,7 +11,7 @@ class Browser; class Extension; class ExtensionHost; -class TabContents; +class TabContentsWrapper; // The InfobarDelegate for creating and managing state for the ExtensionInfobar // plus monitor when the extension goes away. @@ -43,7 +43,7 @@ class ExtensionInfoBarDelegate : public InfoBarDelegate, virtual ~ExtensionInfoBarDelegate(); // InfoBarDelegate: - virtual InfoBar* CreateInfoBar() OVERRIDE; + virtual InfoBar* CreateInfoBar(TabContentsWrapper* owner) OVERRIDE; virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE; virtual void InfoBarDismissed() OVERRIDE; virtual Type GetInfoBarType() const OVERRIDE; diff --git a/chrome/browser/external_tab_container_win.h b/chrome/browser/external_tab_container_win.h index 163b1f1..55de8cb 100644 --- a/chrome/browser/external_tab_container_win.h +++ b/chrome/browser/external_tab_container_win.h @@ -14,9 +14,9 @@ #include "base/memory/scoped_ptr.h" #include "chrome/browser/automation/automation_resource_message_filter.h" #include "chrome/browser/net/chrome_url_request_context.h" +#include "chrome/browser/tab_contents/infobar_container.h" #include "chrome/browser/ui/download/download_tab_helper_delegate.h" #include "chrome/browser/ui/views/frame/browser_bubble_host.h" -#include "chrome/browser/ui/views/infobars/infobar_container.h" #include "chrome/browser/ui/views/unhandled_keyboard_event_handler.h" #include "content/browser/tab_contents/tab_contents_delegate.h" #include "content/browser/tab_contents/tab_contents_observer.h" diff --git a/chrome/browser/google/google_url_tracker_unittest.cc b/chrome/browser/google/google_url_tracker_unittest.cc index 04673fe..4c5ef9ac 100644 --- a/chrome/browser/google/google_url_tracker_unittest.cc +++ b/chrome/browser/google/google_url_tracker_unittest.cc @@ -67,7 +67,7 @@ class TestInfoBarDelegate : public InfoBarDelegate { virtual ~TestInfoBarDelegate(); // InfoBarDelegate: - virtual InfoBar* CreateInfoBar(); + virtual InfoBar* CreateInfoBar(TabContentsWrapper* owner); GoogleURLTracker* google_url_tracker_; GURL new_google_url_; @@ -83,7 +83,7 @@ TestInfoBarDelegate::TestInfoBarDelegate(GoogleURLTracker* google_url_tracker, TestInfoBarDelegate::~TestInfoBarDelegate() { } -InfoBar* TestInfoBarDelegate::CreateInfoBar() { +InfoBar* TestInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { return NULL; } diff --git a/chrome/browser/tab_contents/confirm_infobar_delegate.h b/chrome/browser/tab_contents/confirm_infobar_delegate.h index 07a9f3d..694ff28 100644 --- a/chrome/browser/tab_contents/confirm_infobar_delegate.h +++ b/chrome/browser/tab_contents/confirm_infobar_delegate.h @@ -35,11 +35,12 @@ class ConfirmInfoBarDelegate : public InfoBarDelegate { virtual bool NeedElevation(InfoBarButton button) const; // Called when the OK button is pressed. If the function returns true, the - // InfoBarDelegate should be removed from the associated TabContents. + // InfoBarDelegate should be removed from the associated TabContentsWrapper. virtual bool Accept(); // Called when the Cancel button is pressed. If the function returns true, - // the InfoBarDelegate should be removed from the associated TabContents. + // the InfoBarDelegate should be removed from the associated + // TabContentsWrapper. virtual bool Cancel(); // Returns the text of the link to be displayed, if any. Otherwise returns @@ -60,7 +61,7 @@ class ConfirmInfoBarDelegate : public InfoBarDelegate { private: // InfoBarDelegate: - virtual InfoBar* CreateInfoBar() OVERRIDE; + virtual InfoBar* CreateInfoBar(TabContentsWrapper* owner) OVERRIDE; virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE; virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate() OVERRIDE; diff --git a/chrome/browser/ui/views/infobars/infobar.cc b/chrome/browser/tab_contents/infobar.cc index e31b161..16d0fe7 100644 --- a/chrome/browser/ui/views/infobars/infobar.cc +++ b/chrome/browser/tab_contents/infobar.cc @@ -2,16 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/views/infobars/infobar.h" +#if defined(TOOLKIT_VIEWS) // TODO(pkasting): Port non-views to use this. + +#include "chrome/browser/tab_contents/infobar.h" #include <cmath> -#include "ui/base/animation/slide_animation.h" +#include "chrome/browser/tab_contents/infobar_container.h" #include "chrome/browser/tab_contents/infobar_delegate.h" -#include "chrome/browser/ui/views/infobars/infobar_container.h" +#include "ui/base/animation/slide_animation.h" -InfoBar::InfoBar(InfoBarDelegate* delegate) - : delegate_(delegate), +InfoBar::InfoBar(TabContentsWrapper* owner, InfoBarDelegate* delegate) + : owner_(owner), + delegate_(delegate), container_(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(animation_(new ui::SlideAnimation(this))), arrow_height_(0), @@ -19,6 +22,7 @@ InfoBar::InfoBar(InfoBarDelegate* delegate) arrow_half_width_(0), bar_height_(0), bar_target_height_(kDefaultBarTargetHeight) { + DCHECK(owner != NULL); DCHECK(delegate != NULL); animation_->SetTweenType(ui::Tween::LINEAR); } @@ -95,7 +99,7 @@ void InfoBar::RecalculateHeights(bool force_notify) { // scaling each of these with the square root of the animation value causes a // linear animation of the area, which matches the perception of the animation // of the bar portion. - double scale_factor = sqrt(animation()->GetCurrentValue()); + double scale_factor = sqrt(animation_->GetCurrentValue()); arrow_height_ = static_cast<int>(arrow_target_height_ * scale_factor); if (animation_->is_animating()) { arrow_half_width_ = static_cast<int>(std::min(arrow_target_height_, @@ -116,8 +120,7 @@ void InfoBar::RecalculateHeights(bool force_notify) { if (arrow_height_) arrow_height_ += kSeparatorLineHeight; - bar_height_ = - static_cast<int>(bar_target_height_ * animation()->GetCurrentValue()); + bar_height_ = animation_->CurrentValueBetween(0, bar_target_height_); // Don't re-layout if nothing has changed, e.g. because the animation step was // not large enough to actually change the heights by at least a pixel. @@ -141,3 +144,5 @@ void InfoBar::MaybeDelete() { delegate_ = NULL; } } + +#endif // TOOLKIT_VIEWS diff --git a/chrome/browser/ui/views/infobars/infobar.h b/chrome/browser/tab_contents/infobar.h index cb4aef7..35b5e09 100644 --- a/chrome/browser/ui/views/infobars/infobar.h +++ b/chrome/browser/tab_contents/infobar.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_H_ -#define CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_H_ +#ifndef CHROME_BROWSER_TAB_CONTENTS_INFOBAR_H_ +#define CHROME_BROWSER_TAB_CONTENTS_INFOBAR_H_ #pragma once #include "base/basictypes.h" @@ -13,6 +13,7 @@ class InfoBarContainer; class InfoBarDelegate; +class TabContentsWrapper; namespace ui { class SlideAnimation; @@ -20,7 +21,7 @@ class SlideAnimation; class InfoBar : public ui::AnimationDelegate { public: - explicit InfoBar(InfoBarDelegate* delegate); + InfoBar(TabContentsWrapper* owner, InfoBarDelegate* delegate); virtual ~InfoBar(); // Platforms must define these. @@ -96,6 +97,7 @@ class InfoBar : public ui::AnimationDelegate { // delete us) and closes the delegate. void MaybeDelete(); + TabContentsWrapper* owner_; // TODO(pkasting): Transition to using this. InfoBarDelegate* delegate_; InfoBarContainer* container_; scoped_ptr<ui::SlideAnimation> animation_; @@ -112,4 +114,4 @@ class InfoBar : public ui::AnimationDelegate { DISALLOW_COPY_AND_ASSIGN(InfoBar); }; -#endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_H_ +#endif // CHROME_BROWSER_TAB_CONTENTS_INFOBAR_H_ diff --git a/chrome/browser/ui/views/infobars/infobar_container.cc b/chrome/browser/tab_contents/infobar_container.cc index 4fe550c..ef2aac5 100644 --- a/chrome/browser/ui/views/infobars/infobar_container.cc +++ b/chrome/browser/tab_contents/infobar_container.cc @@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/views/infobars/infobar_container.h" +#if defined(TOOLKIT_VIEWS) // TODO(pkasting): Port non-views to use this. +#include "chrome/browser/tab_contents/infobar_container.h" + +#include "chrome/browser/tab_contents/infobar.h" #include "chrome/browser/tab_contents/infobar_delegate.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "chrome/browser/ui/views/infobars/infobar.h" #include "content/common/notification_details.h" #include "content/common/notification_source.h" #include "ui/base/animation/slide_animation.h" @@ -31,8 +33,8 @@ void InfoBarContainer::ChangeTabContents(TabContentsWrapper* contents) { while (!infobars_.empty()) { InfoBar* infobar = infobars_.front(); // NULL the container pointer first so that if the infobar is currently - // animating, OnInfoBarAnimated() won't get called; we'll manually trigger - // this once for the whole set of changes below. This also prevents + // animating, OnInfoBarStateChanged() won't get called; we'll manually + // trigger this once for the whole set of changes below. This also prevents // InfoBar::MaybeDelete() from calling RemoveInfoBar() a second time if the // infobar happens to be at zero height (dunno if this can actually happen). infobar->set_container(NULL); @@ -49,11 +51,12 @@ void InfoBarContainer::ChangeTabContents(TabContentsWrapper* contents) { registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REPLACED, tc_source); - for (size_t i = 0; i < contents->infobar_count(); ++i) { + for (size_t i = 0; i < tab_contents_->infobar_count(); ++i) { // As when we removed the infobars above, we prevent callbacks to // OnInfoBarAnimated() for each infobar. - AddInfoBar(tab_contents_->GetInfoBarDelegateAt(i)->CreateInfoBar(), false, - NO_CALLBACK); + AddInfoBar( + tab_contents_->GetInfoBarDelegateAt(i)->CreateInfoBar(tab_contents_), + false, NO_CALLBACK); } } @@ -120,8 +123,9 @@ void InfoBarContainer::Observe(NotificationType type, const NotificationDetails& details) { switch (type.value) { case NotificationType::TAB_CONTENTS_INFOBAR_ADDED: - AddInfoBar(Details<InfoBarDelegate>(details)->CreateInfoBar(), true, - WANT_CALLBACK); + AddInfoBar( + Details<InfoBarDelegate>(details)->CreateInfoBar(tab_contents_), true, + WANT_CALLBACK); break; case NotificationType::TAB_CONTENTS_INFOBAR_REMOVED: @@ -132,7 +136,8 @@ void InfoBarContainer::Observe(NotificationType type, typedef std::pair<InfoBarDelegate*, InfoBarDelegate*> InfoBarPair; InfoBarPair* infobar_pair = Details<InfoBarPair>(details).ptr(); RemoveInfoBar(infobar_pair->first, false); - AddInfoBar(infobar_pair->second->CreateInfoBar(), false, WANT_CALLBACK); + AddInfoBar(infobar_pair->second->CreateInfoBar(tab_contents_), false, + WANT_CALLBACK); break; } @@ -196,3 +201,5 @@ int InfoBarContainer::ArrowTargetHeightForInfoBar(size_t infobar_index) const { (InfoBar::kDefaultArrowTargetHeight - top_arrow_target_height_) * first_infobar_animation->GetCurrentValue()); } + +#endif // TOOLKIT_VIEWS diff --git a/chrome/browser/ui/views/infobars/infobar_container.h b/chrome/browser/tab_contents/infobar_container.h index 312140c..3b5bb0f 100644 --- a/chrome/browser/ui/views/infobars/infobar_container.h +++ b/chrome/browser/tab_contents/infobar_container.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_CONTAINER_H_ -#define CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_CONTAINER_H_ +#ifndef CHROME_BROWSER_TAB_CONTENTS_INFOBAR_CONTAINER_H_ +#define CHROME_BROWSER_TAB_CONTENTS_INFOBAR_CONTAINER_H_ #pragma once #include <vector> @@ -15,7 +15,6 @@ class InfoBar; class InfoBarDelegate; -class TabContents; class TabContentsWrapper; // InfoBarContainer is a cross-platform base class to handle the visibility- @@ -47,9 +46,9 @@ class InfoBarContainer : public NotificationObserver { explicit InfoBarContainer(Delegate* delegate); virtual ~InfoBarContainer(); - // Changes the TabContents for which this container is showing infobars. This - // will remove all current infobars from the container, add the infobars from - // |contents|, and show them all. |contents| may be NULL. + // Changes the TabContentsWrapper for which this container is showing + // infobars. This will remove all current infobars from the container, add + // the infobars from |contents|, and show them all. |contents| may be NULL. void ChangeTabContents(TabContentsWrapper* contents); // Returns the amount by which to overlap the toolbar above, and, when @@ -73,9 +72,9 @@ class InfoBarContainer : public NotificationObserver { // anything necessary to respond, e.g. re-layout. void OnInfoBarStateChanged(bool is_animating); - // Removes the specified InfoBarDelegate from the selected TabContents. This - // will notify us back and cause us to close the InfoBar. This is called from - // the InfoBar's close button handler. + // Removes the specified InfoBarDelegate from the selected TabContentsWrapper. + // This will notify us back and cause us to close the InfoBar. This is called + // from the InfoBar's close button handler. void RemoveDelegate(InfoBarDelegate* delegate); // Called by |infobar| to request that it be removed from the container, as it @@ -105,8 +104,8 @@ class InfoBarContainer : public NotificationObserver { const NotificationDetails& details) OVERRIDE; // Removes an InfoBar for the specified delegate, in response to a - // notification from the selected TabContents. The InfoBar's disappearance - // will be animated if |use_animation| is true. + // notification from the selected TabContentsWrapper. The InfoBar's + // disappearance will be animated if |use_animation| is true. void RemoveInfoBar(InfoBarDelegate* delegate, bool use_animation); // Adds |infobar| to this container and calls Show() on it. |animate| is @@ -133,4 +132,4 @@ class InfoBarContainer : public NotificationObserver { DISALLOW_COPY_AND_ASSIGN(InfoBarContainer); }; -#endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_CONTAINER_H_ +#endif // CHROME_BROWSER_TAB_CONTENTS_INFOBAR_CONTAINER_H_ diff --git a/chrome/browser/tab_contents/infobar_delegate.h b/chrome/browser/tab_contents/infobar_delegate.h index dd12472..88e183f3b 100644 --- a/chrome/browser/tab_contents/infobar_delegate.h +++ b/chrome/browser/tab_contents/infobar_delegate.h @@ -16,6 +16,8 @@ class ExtensionInfoBarDelegate; class InfoBar; class LinkInfoBarDelegate; class PluginInstallerInfoBarDelegate; +class TabContents; +class TabContentsWrapper; class ThemeInstalledInfoBarDelegate; class TranslateInfoBarDelegate; @@ -41,14 +43,14 @@ class InfoBarDelegate { // Called to create the InfoBar. Implementation of this method is // platform-specific. - virtual InfoBar* CreateInfoBar() = 0; + virtual InfoBar* CreateInfoBar(TabContentsWrapper* owner) = 0; // Returns true if the supplied |delegate| is equal to this one. Equality is // left to the implementation to define. This function is called by the - // TabContents when determining whether or not a delegate should be added - // because a matching one already exists. If this function returns true, the - // TabContents will not add the new delegate because it considers one to - // already be present. + // TabContentsWrapper when determining whether or not a delegate should be + // added because a matching one already exists. If this function returns true, + // the TabContentsWrapper will not add the new delegate because it considers + // one to already be present. virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; // Returns true if the InfoBar should be closed automatically after the page diff --git a/chrome/browser/tab_contents/link_infobar_delegate.h b/chrome/browser/tab_contents/link_infobar_delegate.h index 61bbcbb..8744a4f 100644 --- a/chrome/browser/tab_contents/link_infobar_delegate.h +++ b/chrome/browser/tab_contents/link_infobar_delegate.h @@ -12,6 +12,7 @@ #include "chrome/browser/tab_contents/infobar_delegate.h" class TabContents; +class TabContentsWrapper; // An interface derived from InfoBarDelegate implemented by objects wishing to // control a LinkInfoBar. @@ -37,7 +38,7 @@ class LinkInfoBarDelegate : public InfoBarDelegate { private: // InfoBarDelegate: - virtual InfoBar* CreateInfoBar() OVERRIDE; + virtual InfoBar* CreateInfoBar(TabContentsWrapper* owner) OVERRIDE; virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate() OVERRIDE; DISALLOW_COPY_AND_ASSIGN(LinkInfoBarDelegate); diff --git a/chrome/browser/translate/translate_infobar_delegate.h b/chrome/browser/translate/translate_infobar_delegate.h index 4ba31e6..ab63712 100644 --- a/chrome/browser/translate/translate_infobar_delegate.h +++ b/chrome/browser/translate/translate_infobar_delegate.h @@ -159,7 +159,7 @@ class TranslateInfoBarDelegate : public InfoBarDelegate { typedef std::pair<std::string, string16> LanguageNamePair; // InfoBarDelegate: - virtual InfoBar* CreateInfoBar() OVERRIDE; + virtual InfoBar* CreateInfoBar(TabContentsWrapper* owner) OVERRIDE; virtual void InfoBarDismissed() OVERRIDE; virtual gfx::Image* GetIcon() const OVERRIDE; virtual InfoBarDelegate::Type GetInfoBarType() const OVERRIDE; diff --git a/chrome/browser/ui/cocoa/extensions/extension_infobar_controller.mm b/chrome/browser/ui/cocoa/extensions/extension_infobar_controller.mm index 982b1d7..77a9afa 100644 --- a/chrome/browser/ui/cocoa/extensions/extension_infobar_controller.mm +++ b/chrome/browser/ui/cocoa/extensions/extension_infobar_controller.mm @@ -259,7 +259,7 @@ class InfobarBridge : public ExtensionInfoBarDelegate::DelegateObserver, @end -InfoBar* ExtensionInfoBarDelegate::CreateInfoBar() { +InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { NSWindow* window = [(NSView*)tab_contents_->GetContentNativeView() window]; ExtensionInfoBarController* controller = [[ExtensionInfoBarController alloc] initWithDelegate:this diff --git a/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm b/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm index 509b9b7..af68668 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm @@ -180,7 +180,7 @@ class InfoBarNotificationObserver : public NotificationObserver { } - (void)addInfoBar:(InfoBarDelegate*)delegate animate:(BOOL)animate { - scoped_ptr<InfoBar> infobar(delegate->CreateInfoBar()); + scoped_ptr<InfoBar> infobar(delegate->CreateInfoBar(currentTabContents_)); InfoBarController* controller = infobar->controller(); [controller setContainerController:self]; [[controller animatableView] setResizeDelegate:self]; diff --git a/chrome/browser/ui/cocoa/infobars/infobar_controller.mm b/chrome/browser/ui/cocoa/infobars/infobar_controller.mm index c2e6d50..7bfe220 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_controller.mm @@ -506,13 +506,13 @@ const float kAnimateCloseDuration = 0.12; ////////////////////////////////////////////////////////////////////////// // CreateInfoBar() implementations -InfoBar* LinkInfoBarDelegate::CreateInfoBar() { +InfoBar* LinkInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { LinkInfoBarController* controller = [[LinkInfoBarController alloc] initWithDelegate:this]; return new InfoBar(controller); } -InfoBar* ConfirmInfoBarDelegate::CreateInfoBar() { +InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { ConfirmInfoBarController* controller = [[ConfirmInfoBarController alloc] initWithDelegate:this]; return new InfoBar(controller); diff --git a/chrome/browser/ui/cocoa/translate/translate_infobar_base.mm b/chrome/browser/ui/cocoa/translate/translate_infobar_base.mm index a13174c..c5613a3 100644 --- a/chrome/browser/ui/cocoa/translate/translate_infobar_base.mm +++ b/chrome/browser/ui/cocoa/translate/translate_infobar_base.mm @@ -109,7 +109,7 @@ void AddMenuItem(NSMenu *menu, id target, SEL selector, NSString* title, } // namespace TranslateInfoBarUtilities // TranslateInfoBarDelegate views specific method: -InfoBar* TranslateInfoBarDelegate::CreateInfoBar() { +InfoBar* TranslateInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { TranslateInfoBarControllerBase* infobar_controller = NULL; switch (type_) { case BEFORE_TRANSLATE: diff --git a/chrome/browser/ui/cocoa/translate/translate_infobar_unittest.mm b/chrome/browser/ui/cocoa/translate/translate_infobar_unittest.mm index 09ad581..9e2aa6b 100644 --- a/chrome/browser/ui/cocoa/translate/translate_infobar_unittest.mm +++ b/chrome/browser/ui/cocoa/translate/translate_infobar_unittest.mm @@ -14,6 +14,7 @@ #import "chrome/browser/ui/cocoa/infobars/infobar.h" #import "chrome/browser/ui/cocoa/translate/translate_infobar_base.h" #import "chrome/browser/ui/cocoa/translate/before_translate_infobar_controller.h" +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #import "content/browser/site_instance.h" #import "content/browser/tab_contents/tab_contents.h" #import "testing/gmock/include/gmock/gmock.h" @@ -68,7 +69,7 @@ class MockTranslateInfoBarDelegate : public TranslateInfoBarDelegate { class TranslationInfoBarTest : public CocoaTest { public: BrowserTestHelper browser_helper_; - scoped_ptr<TabContents> tab_contents; + scoped_ptr<TabContentsWrapper> tab_contents; scoped_ptr<MockTranslateInfoBarDelegate> infobar_delegate; scoped_nsobject<TranslateInfoBarControllerBase> infobar_controller; @@ -77,12 +78,8 @@ class TranslationInfoBarTest : public CocoaTest { // the test. virtual void SetUp() { CocoaTest::SetUp(); - tab_contents.reset( - new TabContents(browser_helper_.profile(), - NULL, - MSG_ROUTING_NONE, - NULL, - NULL)); + tab_contents.reset(new TabContentsWrapper(new TabContents( + browser_helper_.profile(), NULL, MSG_ROUTING_NONE, NULL, NULL))); CreateInfoBar(); } @@ -94,11 +91,12 @@ class TranslationInfoBarTest : public CocoaTest { TranslateErrors::Type error = TranslateErrors::NONE; if (type == TranslateInfoBarDelegate::TRANSLATION_ERROR) error = TranslateErrors::NETWORK; - infobar_delegate.reset( - new MockTranslateInfoBarDelegate(type, error, tab_contents.get())); + infobar_delegate.reset(new MockTranslateInfoBarDelegate(type, error, + tab_contents->tab_contents())); [[infobar_controller view] removeFromSuperview]; scoped_ptr<InfoBar> infobar( - static_cast<InfoBarDelegate*>(infobar_delegate.get())->CreateInfoBar()); + static_cast<InfoBarDelegate*>(infobar_delegate.get())-> + CreateInfoBar(tab_contents.get())); infobar_controller.reset( reinterpret_cast<TranslateInfoBarControllerBase*>( infobar->controller())); diff --git a/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc index 76fe742..51fc25b 100644 --- a/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc @@ -13,7 +13,7 @@ // ConfirmInfoBarDelegate ------------------------------------------------------ -InfoBar* ConfirmInfoBarDelegate::CreateInfoBar() { +InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { return new ConfirmInfoBarGtk(this); } diff --git a/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc index 6e2bcd0..85e3597 100644 --- a/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc @@ -88,6 +88,6 @@ void ExtensionInfoBarGtk::OnExtensionPreferredSizeChanged( // of the content. } -InfoBar* ExtensionInfoBarDelegate::CreateInfoBar() { +InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { return new ExtensionInfoBarGtk(this); } diff --git a/chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc b/chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc index 57b1f71..5f1428e 100644 --- a/chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc @@ -176,7 +176,7 @@ void InfoBarContainerGtk::ShowArrowForDelegate(InfoBarDelegate* delegate, } void InfoBarContainerGtk::AddInfoBar(InfoBarDelegate* delegate, bool animate) { - InfoBar* infobar = delegate->CreateInfoBar(); + InfoBar* infobar = delegate->CreateInfoBar(tab_contents_); infobar->set_container(this); infobar->SetThemeProvider(GtkThemeService::GetFrom(profile_)); gtk_box_pack_start(GTK_BOX(widget()), infobar->widget(), diff --git a/chrome/browser/ui/gtk/infobars/link_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/link_infobar_gtk.cc index db4821b..10aa10b 100644 --- a/chrome/browser/ui/gtk/infobars/link_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/link_infobar_gtk.cc @@ -9,7 +9,7 @@ // LinkInfoBarDelegate --------------------------------------------------------- -InfoBar* LinkInfoBarDelegate::CreateInfoBar() { +InfoBar* LinkInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { return new LinkInfoBarGtk(this); } diff --git a/chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.cc b/chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.cc index 2579f16..0f53e03 100644 --- a/chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.cc @@ -218,7 +218,7 @@ void TranslateInfoBarBase::OnOptionsClicked(GtkWidget* sender) { } // TranslateInfoBarDelegate specific method: -InfoBar* TranslateInfoBarDelegate::CreateInfoBar() { +InfoBar* TranslateInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { TranslateInfoBarBase* infobar = NULL; switch (type_) { case BEFORE_TRANSLATE: diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h index 150739f..a2ef9fa 100644 --- a/chrome/browser/ui/views/frame/browser_view.h +++ b/chrome/browser/ui/views/frame/browser_view.h @@ -13,13 +13,13 @@ #include "base/memory/scoped_ptr.h" #include "base/timer.h" #include "build/build_config.h" +#include "chrome/browser/tab_contents/infobar_container.h" #include "chrome/browser/tabs/tab_strip_model_observer.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/views/compact_nav/compact_location_bar_view_host.h" #include "chrome/browser/ui/views/frame/browser_bubble_host.h" #include "chrome/browser/ui/views/frame/browser_frame.h" -#include "chrome/browser/ui/views/infobars/infobar_container.h" #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" #include "chrome/browser/ui/views/tabs/abstract_tab_strip_view.h" #include "chrome/browser/ui/views/unhandled_keyboard_event_handler.h" diff --git a/chrome/browser/ui/views/infobars/after_translate_infobar.cc b/chrome/browser/ui/views/infobars/after_translate_infobar.cc index 4bb557f..c7898c4 100644 --- a/chrome/browser/ui/views/infobars/after_translate_infobar.cc +++ b/chrome/browser/ui/views/infobars/after_translate_infobar.cc @@ -13,8 +13,9 @@ #include "views/controls/menu/menu_2.h" AfterTranslateInfoBar::AfterTranslateInfoBar( + TabContentsWrapper* owner, TranslateInfoBarDelegate* delegate) - : TranslateInfoBarBase(delegate), + : TranslateInfoBarBase(owner, delegate), label_1_(NULL), label_2_(NULL), label_3_(NULL), diff --git a/chrome/browser/ui/views/infobars/after_translate_infobar.h b/chrome/browser/ui/views/infobars/after_translate_infobar.h index c1cd254..794dc2f 100644 --- a/chrome/browser/ui/views/infobars/after_translate_infobar.h +++ b/chrome/browser/ui/views/infobars/after_translate_infobar.h @@ -20,7 +20,8 @@ class MenuButton; class AfterTranslateInfoBar : public TranslateInfoBarBase, public views::ViewMenuDelegate { public: - explicit AfterTranslateInfoBar(TranslateInfoBarDelegate* delegate); + AfterTranslateInfoBar(TabContentsWrapper* owner, + TranslateInfoBarDelegate* delegate); private: virtual ~AfterTranslateInfoBar(); diff --git a/chrome/browser/ui/views/infobars/before_translate_infobar.cc b/chrome/browser/ui/views/infobars/before_translate_infobar.cc index 308f064..644bc6e 100644 --- a/chrome/browser/ui/views/infobars/before_translate_infobar.cc +++ b/chrome/browser/ui/views/infobars/before_translate_infobar.cc @@ -13,8 +13,9 @@ #include "views/controls/menu/menu_2.h" BeforeTranslateInfoBar::BeforeTranslateInfoBar( + TabContentsWrapper* owner, TranslateInfoBarDelegate* delegate) - : TranslateInfoBarBase(delegate), + : TranslateInfoBarBase(owner, delegate), label_1_(NULL), label_2_(NULL), language_menu_button_(NULL), diff --git a/chrome/browser/ui/views/infobars/before_translate_infobar.h b/chrome/browser/ui/views/infobars/before_translate_infobar.h index 546b33f..651d715 100644 --- a/chrome/browser/ui/views/infobars/before_translate_infobar.h +++ b/chrome/browser/ui/views/infobars/before_translate_infobar.h @@ -20,7 +20,8 @@ class MenuButton; class BeforeTranslateInfoBar : public TranslateInfoBarBase, public views::ViewMenuDelegate { public: - explicit BeforeTranslateInfoBar(TranslateInfoBarDelegate* delegate); + BeforeTranslateInfoBar(TabContentsWrapper* owner, + TranslateInfoBarDelegate* delegate); private: virtual ~BeforeTranslateInfoBar(); diff --git a/chrome/browser/ui/views/infobars/confirm_infobar.cc b/chrome/browser/ui/views/infobars/confirm_infobar.cc index 8ed7132b..dc6ba1a 100644 --- a/chrome/browser/ui/views/infobars/confirm_infobar.cc +++ b/chrome/browser/ui/views/infobars/confirm_infobar.cc @@ -12,14 +12,15 @@ // ConfirmInfoBarDelegate ----------------------------------------------------- -InfoBar* ConfirmInfoBarDelegate::CreateInfoBar() { - return new ConfirmInfoBar(this); +InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { + return new ConfirmInfoBar(owner, this); } // ConfirmInfoBar ------------------------------------------------------------- -ConfirmInfoBar::ConfirmInfoBar(ConfirmInfoBarDelegate* delegate) - : InfoBarView(delegate), +ConfirmInfoBar::ConfirmInfoBar(TabContentsWrapper* owner, + ConfirmInfoBarDelegate* delegate) + : InfoBarView(owner, delegate), label_(NULL), ok_button_(NULL), cancel_button_(NULL), diff --git a/chrome/browser/ui/views/infobars/confirm_infobar.h b/chrome/browser/ui/views/infobars/confirm_infobar.h index ef2d37d..52dff90 100644 --- a/chrome/browser/ui/views/infobars/confirm_infobar.h +++ b/chrome/browser/ui/views/infobars/confirm_infobar.h @@ -24,7 +24,7 @@ class TextButton; class ConfirmInfoBar : public InfoBarView, public views::LinkListener { public: - explicit ConfirmInfoBar(ConfirmInfoBarDelegate* delegate); + ConfirmInfoBar(TabContentsWrapper* owner, ConfirmInfoBarDelegate* delegate); private: virtual ~ConfirmInfoBar(); diff --git a/chrome/browser/ui/views/infobars/extension_infobar.cc b/chrome/browser/ui/views/infobars/extension_infobar.cc index 6892509..05fe88a 100644 --- a/chrome/browser/ui/views/infobars/extension_infobar.cc +++ b/chrome/browser/ui/views/infobars/extension_infobar.cc @@ -23,8 +23,8 @@ // ExtensionInfoBarDelegate --------------------------------------------------- -InfoBar* ExtensionInfoBarDelegate::CreateInfoBar() { - return new ExtensionInfoBar(this); +InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { + return new ExtensionInfoBar(owner, this); } // ExtensionInfoBar ----------------------------------------------------------- @@ -34,8 +34,9 @@ namespace { static const int kMenuHorizontalMargin = 1; }; -ExtensionInfoBar::ExtensionInfoBar(ExtensionInfoBarDelegate* delegate) - : InfoBarView(delegate), +ExtensionInfoBar::ExtensionInfoBar(TabContentsWrapper* owner, + ExtensionInfoBarDelegate* delegate) + : InfoBarView(owner, delegate), delegate_(delegate), menu_(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) { diff --git a/chrome/browser/ui/views/infobars/extension_infobar.h b/chrome/browser/ui/views/infobars/extension_infobar.h index 67dc3dd..69d3c5c 100644 --- a/chrome/browser/ui/views/infobars/extension_infobar.h +++ b/chrome/browser/ui/views/infobars/extension_infobar.h @@ -13,6 +13,7 @@ #include "views/controls/menu/view_menu_delegate.h" class ExtensionContextMenuModel; +class TabContentsWrapper; namespace views { class MenuButton; class Menu2; @@ -24,7 +25,8 @@ class ExtensionInfoBar : public InfoBarView, public ExtensionInfoBarDelegate::DelegateObserver, public views::ViewMenuDelegate { public: - explicit ExtensionInfoBar(ExtensionInfoBarDelegate* delegate); + ExtensionInfoBar(TabContentsWrapper* owner, + ExtensionInfoBarDelegate* delegate); private: virtual ~ExtensionInfoBar(); diff --git a/chrome/browser/ui/views/infobars/infobar_container_view.h b/chrome/browser/ui/views/infobars/infobar_container_view.h index 1cac809..d6b937d 100644 --- a/chrome/browser/ui/views/infobars/infobar_container_view.h +++ b/chrome/browser/ui/views/infobars/infobar_container_view.h @@ -6,8 +6,8 @@ #define CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_CONTAINER_VIEW_H_ #pragma once +#include "chrome/browser/tab_contents/infobar_container.h" #include "chrome/browser/ui/views/accessible_pane_view.h" -#include "chrome/browser/ui/views/infobars/infobar_container.h" // The views-specific implementation of InfoBarContainer. class InfoBarContainerView : public AccessiblePaneView, diff --git a/chrome/browser/ui/views/infobars/infobar_view.cc b/chrome/browser/ui/views/infobars/infobar_view.cc index bb88b34..c947249 100644 --- a/chrome/browser/ui/views/infobars/infobar_view.cc +++ b/chrome/browser/ui/views/infobars/infobar_view.cc @@ -56,8 +56,8 @@ const int InfoBarView::kButtonButtonSpacing = 10; const int InfoBarView::kEndOfLabelSpacing = 16; const int InfoBarView::kHorizontalPadding = 6; -InfoBarView::InfoBarView(InfoBarDelegate* delegate) - : InfoBar(delegate), +InfoBarView::InfoBarView(TabContentsWrapper* owner, InfoBarDelegate* delegate) + : InfoBar(owner, delegate), icon_(NULL), close_button_(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(delete_factory_(this)), diff --git a/chrome/browser/ui/views/infobars/infobar_view.h b/chrome/browser/ui/views/infobars/infobar_view.h index 13596c5..82c0c8a 100644 --- a/chrome/browser/ui/views/infobars/infobar_view.h +++ b/chrome/browser/ui/views/infobars/infobar_view.h @@ -7,9 +7,9 @@ #pragma once #include "base/task.h" -#include "chrome/browser/ui/views/infobars/infobar.h" +#include "chrome/browser/tab_contents/infobar.h" +#include "chrome/browser/tab_contents/infobar_container.h" #include "chrome/browser/ui/views/infobars/infobar_background.h" -#include "chrome/browser/ui/views/infobars/infobar_container.h" #include "views/controls/button/button.h" #include "views/focus/focus_manager.h" @@ -32,7 +32,7 @@ class InfoBarView : public InfoBar, public views::ButtonListener, public views::FocusChangeListener { public: - explicit InfoBarView(InfoBarDelegate* delegate); + InfoBarView(TabContentsWrapper* owner, InfoBarDelegate* delegate); SkPath* fill_path() const { return fill_path_.get(); } SkPath* stroke_path() const { return stroke_path_.get(); } diff --git a/chrome/browser/ui/views/infobars/link_infobar.cc b/chrome/browser/ui/views/infobars/link_infobar.cc index accaeb6..a923648 100644 --- a/chrome/browser/ui/views/infobars/link_infobar.cc +++ b/chrome/browser/ui/views/infobars/link_infobar.cc @@ -11,14 +11,15 @@ // LinkInfoBarDelegate -------------------------------------------------------- -InfoBar* LinkInfoBarDelegate::CreateInfoBar() { - return new LinkInfoBar(this); +InfoBar* LinkInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { + return new LinkInfoBar(owner, this); } // LinkInfoBar ---------------------------------------------------------------- -LinkInfoBar::LinkInfoBar(LinkInfoBarDelegate* delegate) - : InfoBarView(delegate), +LinkInfoBar::LinkInfoBar(TabContentsWrapper* owner, + LinkInfoBarDelegate* delegate) + : InfoBarView(owner, delegate), label_1_(NULL), link_(NULL), label_2_(NULL) { diff --git a/chrome/browser/ui/views/infobars/link_infobar.h b/chrome/browser/ui/views/infobars/link_infobar.h index 99e5d9d..18e49f8 100644 --- a/chrome/browser/ui/views/infobars/link_infobar.h +++ b/chrome/browser/ui/views/infobars/link_infobar.h @@ -17,7 +17,7 @@ class LinkInfoBarDelegate; class LinkInfoBar : public InfoBarView, public views::LinkListener { public: - explicit LinkInfoBar(LinkInfoBarDelegate* delegate); + LinkInfoBar(TabContentsWrapper* owner, LinkInfoBarDelegate* delegate); private: virtual ~LinkInfoBar(); diff --git a/chrome/browser/ui/views/infobars/translate_infobar_base.cc b/chrome/browser/ui/views/infobars/translate_infobar_base.cc index f687e11..b20112a 100644 --- a/chrome/browser/ui/views/infobars/translate_infobar_base.cc +++ b/chrome/browser/ui/views/infobars/translate_infobar_base.cc @@ -19,18 +19,18 @@ // TranslateInfoBarDelegate --------------------------------------------------- -InfoBar* TranslateInfoBarDelegate::CreateInfoBar() { +InfoBar* TranslateInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { TranslateInfoBarBase* infobar = NULL; switch (type_) { case BEFORE_TRANSLATE: - infobar = new BeforeTranslateInfoBar(this); + infobar = new BeforeTranslateInfoBar(owner, this); break; case AFTER_TRANSLATE: - infobar = new AfterTranslateInfoBar(this); + infobar = new AfterTranslateInfoBar(owner, this); break; case TRANSLATING: case TRANSLATION_ERROR: - infobar = new TranslateMessageInfoBar(this); + infobar = new TranslateMessageInfoBar(owner, this); break; default: NOTREACHED(); @@ -44,8 +44,9 @@ InfoBar* TranslateInfoBarDelegate::CreateInfoBar() { // static const int TranslateInfoBarBase::kButtonInLabelSpacing = 5; -TranslateInfoBarBase::TranslateInfoBarBase(TranslateInfoBarDelegate* delegate) - : InfoBarView(delegate), +TranslateInfoBarBase::TranslateInfoBarBase(TabContentsWrapper* owner, + TranslateInfoBarDelegate* delegate) + : InfoBarView(owner, delegate), error_background_(InfoBarDelegate::WARNING_TYPE) { } diff --git a/chrome/browser/ui/views/infobars/translate_infobar_base.h b/chrome/browser/ui/views/infobars/translate_infobar_base.h index 4a6923d..30865e8 100644 --- a/chrome/browser/ui/views/infobars/translate_infobar_base.h +++ b/chrome/browser/ui/views/infobars/translate_infobar_base.h @@ -22,7 +22,8 @@ class MenuButton; class TranslateInfoBarBase : public TranslateInfoBarView, public InfoBarView { public: - explicit TranslateInfoBarBase(TranslateInfoBarDelegate* delegate); + TranslateInfoBarBase(TabContentsWrapper* owner, + TranslateInfoBarDelegate* delegate); virtual ~TranslateInfoBarBase(); protected: diff --git a/chrome/browser/ui/views/infobars/translate_message_infobar.cc b/chrome/browser/ui/views/infobars/translate_message_infobar.cc index f31e3b6..7a70485 100644 --- a/chrome/browser/ui/views/infobars/translate_message_infobar.cc +++ b/chrome/browser/ui/views/infobars/translate_message_infobar.cc @@ -9,8 +9,9 @@ #include "views/controls/label.h" TranslateMessageInfoBar::TranslateMessageInfoBar( + TabContentsWrapper* owner, TranslateInfoBarDelegate* delegate) - : TranslateInfoBarBase(delegate), + : TranslateInfoBarBase(owner, delegate), label_(NULL), button_(NULL) { } diff --git a/chrome/browser/ui/views/infobars/translate_message_infobar.h b/chrome/browser/ui/views/infobars/translate_message_infobar.h index c6a27fe..a70fd8d 100644 --- a/chrome/browser/ui/views/infobars/translate_message_infobar.h +++ b/chrome/browser/ui/views/infobars/translate_message_infobar.h @@ -10,7 +10,8 @@ class TranslateMessageInfoBar : public TranslateInfoBarBase { public: - explicit TranslateMessageInfoBar(TranslateInfoBarDelegate* delegate); + TranslateMessageInfoBar(TabContentsWrapper* owner, + TranslateInfoBarDelegate* delegate); private: virtual ~TranslateMessageInfoBar(); diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 65853b8..0965301 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2039,6 +2039,10 @@ 'browser/tab_contents/chrome_interstitial_page.h', 'browser/tab_contents/confirm_infobar_delegate.cc', 'browser/tab_contents/confirm_infobar_delegate.h', + 'browser/tab_contents/infobar.cc', + 'browser/tab_contents/infobar.h', + 'browser/tab_contents/infobar_container.cc', + 'browser/tab_contents/infobar_container.h', 'browser/tab_contents/infobar_delegate.cc', 'browser/tab_contents/infobar_delegate.h', 'browser/tab_contents/language_state.cc', @@ -3082,14 +3086,10 @@ 'browser/ui/views/infobars/confirm_infobar.h', 'browser/ui/views/infobars/extension_infobar.cc', 'browser/ui/views/infobars/extension_infobar.h', - 'browser/ui/views/infobars/infobar.cc', - 'browser/ui/views/infobars/infobar.h', 'browser/ui/views/infobars/infobar_background.cc', 'browser/ui/views/infobars/infobar_background.h', 'browser/ui/views/infobars/infobar_button_border.cc', 'browser/ui/views/infobars/infobar_button_border.h', - 'browser/ui/views/infobars/infobar_container.cc', - 'browser/ui/views/infobars/infobar_container.h', 'browser/ui/views/infobars/infobar_container_view.cc', 'browser/ui/views/infobars/infobar_container_view.h', 'browser/ui/views/infobars/infobar_view.cc', |