diff options
73 files changed, 422 insertions, 382 deletions
diff --git a/chrome/browser/accessibility/accessibility_extension_api.cc b/chrome/browser/accessibility/accessibility_extension_api.cc index 623f121..d33d482 100644 --- a/chrome/browser/accessibility/accessibility_extension_api.cc +++ b/chrome/browser/accessibility/accessibility_extension_api.cc @@ -209,7 +209,8 @@ bool GetAlertsForTabFunction::RunImpl() { ListValue* alerts_value = new ListValue; - InfoBarTabHelper* infobar_helper = contents->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(contents->web_contents()); for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); ++i) { // TODO(hashimoto): Make other kind of alerts available. crosbug.com/24281 InfoBarDelegate* infobar_delegate = infobar_helper->GetInfoBarDelegateAt(i); diff --git a/chrome/browser/accessibility/accessibility_extension_apitest.cc b/chrome/browser/accessibility/accessibility_extension_apitest.cc index 29cfb54..67c412b 100644 --- a/chrome/browser/accessibility/accessibility_extension_apitest.cc +++ b/chrome/browser/accessibility/accessibility_extension_apitest.cc @@ -8,13 +8,14 @@ #include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_tabstrip.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/common/chrome_switches.h" IN_PROC_BROWSER_TEST_F(ExtensionApiTest, GetAlertsForTab) { - TabContents* tab = chrome::GetActiveTabContents(browser()); - ASSERT_TRUE(tab); - InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); + content::WebContents* web_contents = chrome::GetActiveWebContents(browser()); + ASSERT_TRUE(web_contents); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents); + ASSERT_TRUE(infobar_helper); const char kAlertMessage[] = "Simple Alert Infobar."; infobar_helper->AddInfoBar( diff --git a/chrome/browser/alternate_nav_url_fetcher.cc b/chrome/browser/alternate_nav_url_fetcher.cc index 95ae598..35becab 100644 --- a/chrome/browser/alternate_nav_url_fetcher.cc +++ b/chrome/browser/alternate_nav_url_fetcher.cc @@ -222,8 +222,7 @@ void AlternateNavURLFetcher::SetStatusFromURLFetch( void AlternateNavURLFetcher::ShowInfobarIfPossible() { if (navigated_to_entry_ && (state_ == SUCCEEDED)) { InfoBarTabHelper* infobar_helper = - TabContents::FromWebContents(controller_->GetWebContents())-> - infobar_tab_helper(); + InfoBarTabHelper::FromWebContents(controller_->GetWebContents()); infobar_helper->AddInfoBar( new AlternateNavInfoBarDelegate(infobar_helper, alternate_nav_url_)); } else if (state_ != FAILED) { diff --git a/chrome/browser/api/infobars/infobar_service.h b/chrome/browser/api/infobars/infobar_service.h index 3e37eb1..32b792f 100644 --- a/chrome/browser/api/infobars/infobar_service.h +++ b/chrome/browser/api/infobars/infobar_service.h @@ -10,14 +10,13 @@ class WebContents; } class InfoBarDelegate; -class TabContents; // Provides access to creating, removing and enumerating info bars // attached to a tab. class InfoBarService { public: - // Retrieves the InfoBarService for a given tab. - static InfoBarService* FromTabContents(TabContents* tab_contents); + // Retrieves the InfoBarService for a given WebContents. + static InfoBarService* FromWebContents(content::WebContents* web_contents); virtual ~InfoBarService() {} diff --git a/chrome/browser/autofill/autofill_browsertest.cc b/chrome/browser/autofill/autofill_browsertest.cc index 605f7c1..59fff91 100644 --- a/chrome/browser/autofill/autofill_browsertest.cc +++ b/chrome/browser/autofill/autofill_browsertest.cc @@ -135,7 +135,7 @@ class WindowedPersonalDataManagerObserver const content::NotificationDetails& details) OVERRIDE { // Accept in the infobar. infobar_service_ = - InfoBarService::FromTabContents(chrome::GetActiveTabContents(browser_)); + InfoBarService::FromWebContents(chrome::GetActiveWebContents(browser_)); InfoBarDelegate* infobar = infobar_service_->GetInfoBarDelegateAt(0); ConfirmInfoBarDelegate* confirm_infobar = @@ -857,7 +857,7 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, DISABLED_AutofillAfterTranslate) { render_view_host(), ChromeViewHostMsg_TranslateLanguageDetermined(0, "ja", true)); TranslateInfoBarDelegate* infobar = - InfoBarService::FromTabContents(chrome::GetActiveTabContents(browser()))-> + InfoBarService::FromWebContents(chrome::GetActiveWebContents(browser()))-> GetInfoBarDelegateAt(0)->AsTranslateInfoBarDelegate(); ASSERT_TRUE(infobar != NULL); @@ -1031,8 +1031,8 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, InvalidCreditCardNumberIsNotAggregated) { ASSERT_FALSE(CreditCard::IsValidCreditCardNumber(ASCIIToUTF16(card))); SubmitCreditCard("Bob Smith", card.c_str(), "12", "2014"); ASSERT_EQ(0u, - InfoBarService::FromTabContents( - chrome::GetActiveTabContents(browser()))->GetInfoBarCount()); + InfoBarService::FromWebContents( + chrome::GetActiveWebContents(browser()))->GetInfoBarCount()); } // Test whitespaces and separator chars are stripped for valid CC numbers. @@ -1253,8 +1253,8 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, CCInfoNotStoredWhenAutocompleteOff) { FillFormAndSubmit("cc_autocomplete_off_test.html", data); ASSERT_EQ(0u, - InfoBarService::FromTabContents( - chrome::GetActiveTabContents(browser()))->GetInfoBarCount()); + InfoBarService::FromWebContents( + chrome::GetActiveWebContents(browser()))->GetInfoBarCount()); } // http://crbug.com/150084 diff --git a/chrome/browser/autofill/autofill_metrics_unittest.cc b/chrome/browser/autofill/autofill_metrics_unittest.cc index 3cadb33..678b5fb 100644 --- a/chrome/browser/autofill/autofill_metrics_unittest.cc +++ b/chrome/browser/autofill/autofill_metrics_unittest.cc @@ -320,7 +320,7 @@ AutofillCCInfoBarDelegate* AutofillMetricsTest::CreateDelegate( if (created_card) *created_card = credit_card; return new AutofillCCInfoBarDelegate( - InfoBarService::FromTabContents(tab_contents()), + InfoBarService::FromWebContents(web_contents()), credit_card, &personal_data_, metric_logger); diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index 1dc5000..a8b1fd6 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -1259,7 +1259,8 @@ InfoBarCountObserver::InfoBarCountObserver(AutomationProvider* automation, reply_message_(reply_message), tab_contents_(tab_contents), target_count_(target_count) { - content::Source<InfoBarTabHelper> source(tab_contents->infobar_tab_helper()); + content::Source<InfoBarTabHelper> source( + InfoBarTabHelper::FromWebContents(tab_contents->web_contents())); registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, source); registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, @@ -1279,7 +1280,9 @@ void InfoBarCountObserver::Observe( } void InfoBarCountObserver::CheckCount() { - if (tab_contents_->infobar_tab_helper()->GetInfoBarCount() != target_count_) + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(tab_contents_->web_contents()); + if (infobar_tab_helper->GetInfoBarCount() != target_count_) return; if (automation_) { diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 4417e35..ce185e9 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -2129,8 +2129,7 @@ void TestingAutomationProvider::SetWindowDimensions( ListValue* TestingAutomationProvider::GetInfobarsInfo(WebContents* wc) { // Each infobar may have different properties depending on the type. ListValue* infobars = new ListValue; - InfoBarTabHelper* infobar_helper = - TabContents::FromWebContents(wc)->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = InfoBarTabHelper::FromWebContents(wc); for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); ++i) { DictionaryValue* infobar_item = new DictionaryValue; InfoBarDelegate* infobar = infobar_helper->GetInfoBarDelegateAt(i); @@ -2206,12 +2205,13 @@ void TestingAutomationProvider::PerformActionOnInfobar( return; } - TabContents* tab_contents = chrome::GetTabContentsAt(browser, tab_index); - if (!tab_contents) { + WebContents* web_contents = chrome::GetWebContentsAt(browser, tab_index); + if (!web_contents) { reply.SendError(StringPrintf("No such tab at index %d", tab_index)); return; } - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents); InfoBarDelegate* infobar = NULL; size_t infobar_index = static_cast<size_t>(infobar_index_int); diff --git a/chrome/browser/chrome_quota_permission_context.cc b/chrome/browser/chrome_quota_permission_context.cc index bb583c6..5086a76 100644 --- a/chrome/browser/chrome_quota_permission_context.cc +++ b/chrome/browser/chrome_quota_permission_context.cc @@ -13,7 +13,6 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tab_contents/tab_util.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/common/pref_names.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_details.h" @@ -137,9 +136,8 @@ void ChromeQuotaPermissionContext::RequestQuotaPermission( return; } - TabContents* tab_contents = TabContents::FromWebContents(web_contents); InfoBarTabHelper* infobar_helper = - tab_contents ? tab_contents->infobar_tab_helper() : NULL; + InfoBarTabHelper::FromWebContents(web_contents); if (!infobar_helper) { // The tab has no infobar helper. LOG(WARNING) << "Attempt to request quota from a background page: " @@ -147,9 +145,11 @@ void ChromeQuotaPermissionContext::RequestQuotaPermission( DispatchCallbackOnIOThread(callback, QUOTA_PERMISSION_RESPONSE_CANCELLED); return; } + Profile* profile = + Profile::FromBrowserContext(web_contents->GetBrowserContext()); infobar_helper->AddInfoBar(new RequestQuotaInfoBarDelegate( infobar_helper, this, origin_url, requested_quota, - tab_contents->profile()->GetPrefs()->GetString(prefs::kAcceptLanguages), + profile->GetPrefs()->GetString(prefs::kAcceptLanguages), callback)); } diff --git a/chrome/browser/download/download_request_limiter.cc b/chrome/browser/download/download_request_limiter.cc index 4d78e4d..8efc09f 100644 --- a/chrome/browser/download/download_request_limiter.cc +++ b/chrome/browser/download/download_request_limiter.cc @@ -91,11 +91,13 @@ void DownloadRequestLimiter::TabDownloadState::PromptUserForDownload( NotifyCallbacks(DownloadRequestLimiter::delegate_->ShouldAllowDownload()); return; } - TabContents* tab_contents = TabContents::FromWebContents(web_contents); - if (!tab_contents) { - // If |web_contents| doesn't have a TabContents, then it isn't what a user - // thinks of as a tab, it's actually a "raw" WebContents like those used - // for extension popups/bubbles and hosted apps etc. + + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents); + if (!infobar_helper) { + // |web_contents| may not have a InfoBarTabHelper if it's actually a + // WebContents like those used for extension popups/bubbles and hosted apps + // etc. // TODO(benjhayden): If this is an automatic download from an extension, // it would be convenient for the extension author if we send a message to // the extension's DevTools console (as we do for CSP) about how @@ -104,7 +106,6 @@ void DownloadRequestLimiter::TabDownloadState::PromptUserForDownload( Cancel(); return; } - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); infobar_ = new DownloadRequestInfoBarDelegate(infobar_helper, this); infobar_helper->AddInfoBar(infobar_); } diff --git a/chrome/browser/extensions/api/debugger/debugger_api.cc b/chrome/browser/extensions/api/debugger/debugger_api.cc index 7ef6aad..8c06f5e 100644 --- a/chrome/browser/extensions/api/debugger/debugger_api.cc +++ b/chrome/browser/extensions/api/debugger/debugger_api.cc @@ -208,7 +208,7 @@ ExtensionDevToolsClientHost::ExtensionDevToolsClientHost( DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(agent, this); InfoBarTabHelper* infobar_helper = - TabContents::FromWebContents(web_contents_)->infobar_tab_helper(); + InfoBarTabHelper::FromWebContents(web_contents_); infobar_delegate_ = new ExtensionDevToolsInfoBarDelegate(infobar_helper, extension_name, this); @@ -227,10 +227,10 @@ ExtensionDevToolsClientHost::~ExtensionDevToolsClientHost() { if (infobar_delegate_) { infobar_delegate_->DiscardClientHost(); - TabContents* tab_contents = TabContents::FromWebContents(web_contents_); - InfoBarTabHelper* helper = tab_contents->infobar_tab_helper(); - if (helper) - helper->RemoveInfoBar(infobar_delegate_); + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(web_contents_); + if (infobar_tab_helper) + infobar_tab_helper->RemoveInfoBar(infobar_delegate_); } AttachedClientHosts::GetInstance()->Remove(this); } diff --git a/chrome/browser/extensions/app_notify_channel_ui_impl.cc b/chrome/browser/extensions/app_notify_channel_ui_impl.cc index 38b2b4b..a99940b 100644 --- a/chrome/browser/extensions/app_notify_channel_ui_impl.cc +++ b/chrome/browser/extensions/app_notify_channel_ui_impl.cc @@ -136,9 +136,10 @@ void AppNotifyChannelUIImpl::PromptSyncSetup( return; } - InfoBarTabHelper* helper = tab_contents_->infobar_tab_helper(); - helper->AddInfoBar(new AppNotifyChannelUIImpl::InfoBar( - this, helper, app_name_)); + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(tab_contents_->web_contents()); + infobar_tab_helper->AddInfoBar(new AppNotifyChannelUIImpl::InfoBar( + this, infobar_tab_helper, app_name_)); } void AppNotifyChannelUIImpl::OnInfoBarResult(bool accepted) { diff --git a/chrome/browser/extensions/extension_install_ui_browsertest.cc b/chrome/browser/extensions/extension_install_ui_browsertest.cc index 1179988..49f0eb4 100644 --- a/chrome/browser/extensions/extension_install_ui_browsertest.cc +++ b/chrome/browser/extensions/extension_install_ui_browsertest.cc @@ -17,7 +17,6 @@ #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" -#include "chrome/test/base/ui_test_utils.h" #include "content/public/browser/web_contents.h" using content::WebContents; @@ -28,9 +27,10 @@ class ExtensionInstallUIBrowserTest : public ExtensionBrowserTest { // Checks that a theme info bar is currently visible and issues an undo to // revert to the previous theme. void VerifyThemeInfoBarAndUndoInstall() { - TabContents* tab = chrome::GetActiveTabContents(browser()); - ASSERT_TRUE(tab); - InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); + WebContents* web_contents = chrome::GetActiveWebContents(browser()); + ASSERT_TRUE(web_contents); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents); ASSERT_EQ(1U, infobar_helper->GetInfoBarCount()); ConfirmInfoBarDelegate* delegate = infobar_helper-> GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); diff --git a/chrome/browser/extensions/extension_install_ui_default.cc b/chrome/browser/extensions/extension_install_ui_default.cc index 23c9ccd..700f6ee 100644 --- a/chrome/browser/extensions/extension_install_ui_default.cc +++ b/chrome/browser/extensions/extension_install_ui_default.cc @@ -151,10 +151,11 @@ void ExtensionInstallUIDefault::OnInstallFailure( return; Browser* browser = browser::FindLastActiveWithProfile(profile_); - TabContents* tab_contents = chrome::GetActiveTabContents(browser); - if (!tab_contents) + WebContents* web_contents = chrome::GetActiveWebContents(browser); + if (!web_contents) return; - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents); infobar_helper->AddInfoBar( new ErrorInfobarDelegate(infobar_helper, browser, error)); } @@ -179,10 +180,11 @@ void ExtensionInstallUIDefault::ShowThemeInfoBar( if (!browser) return; - TabContents* tab_contents = chrome::GetActiveTabContents(browser); - if (!tab_contents) + WebContents* web_contents = chrome::GetActiveWebContents(browser); + if (!web_contents) return; - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents); // First find any previous theme preview infobars. InfoBarDelegate* old_delegate = NULL; @@ -203,7 +205,7 @@ void ExtensionInstallUIDefault::ShowThemeInfoBar( // Then either replace that old one or add a new one. InfoBarDelegate* new_delegate = GetNewThemeInstalledInfoBarDelegate( - tab_contents, new_theme, previous_theme_id, previous_using_native_theme); + web_contents, new_theme, previous_theme_id, previous_using_native_theme); if (old_delegate) infobar_helper->ReplaceInfoBar(old_delegate, new_delegate); @@ -212,13 +214,14 @@ void ExtensionInstallUIDefault::ShowThemeInfoBar( } InfoBarDelegate* ExtensionInstallUIDefault::GetNewThemeInstalledInfoBarDelegate( - TabContents* tab_contents, + WebContents* web_contents, const Extension* new_theme, const std::string& previous_theme_id, bool previous_using_native_theme) { - Profile* profile = tab_contents->profile(); + Profile* profile = + Profile::FromBrowserContext(web_contents->GetBrowserContext()); return new ThemeInstalledInfoBarDelegate( - tab_contents->infobar_tab_helper(), + InfoBarTabHelper::FromWebContents(web_contents), profile->GetExtensionService(), ThemeServiceFactory::GetForProfile(profile), new_theme, diff --git a/chrome/browser/extensions/extension_install_ui_default.h b/chrome/browser/extensions/extension_install_ui_default.h index 95f3651..34069bc 100644 --- a/chrome/browser/extensions/extension_install_ui_default.h +++ b/chrome/browser/extensions/extension_install_ui_default.h @@ -9,7 +9,10 @@ class InfoBarDelegate; class Profile; -class TabContents; + +namespace content { +class WebContents; +} class ExtensionInstallUIDefault : public ExtensionInstallUI { public: @@ -35,7 +38,7 @@ class ExtensionInstallUIDefault : public ExtensionInstallUI { // Returns the delegate to control the browser's info bar. This is // within its own function due to its platform-specific nature. static InfoBarDelegate* GetNewThemeInstalledInfoBarDelegate( - TabContents* tab_contents, + content::WebContents* web_contents, const extensions::Extension* new_theme, const std::string& previous_theme_id, bool previous_using_native_theme); diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc index 29bfe1f..e7a8a79 100644 --- a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc +++ b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc @@ -18,6 +18,7 @@ #include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/browser/ui/tab_contents/test_tab_contents.h" +#include "chrome/browser/view_type_utils.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/test/base/testing_profile.h" #include "content/public/browser/navigation_details.h" @@ -106,16 +107,18 @@ class GeolocationPermissionContextTests : public TabContentsTestHarness { return contents()->GetRenderProcessHost()->GetID(); } int process_id_for_tab(int tab) { - return extra_tabs_[tab]->web_contents()->GetRenderProcessHost()->GetID(); + return extra_tabs_[tab]->GetRenderProcessHost()->GetID(); } int render_id() { return contents()->GetRenderViewHost()->GetRoutingID(); } int render_id_for_tab(int tab) { - return extra_tabs_[tab]->web_contents()-> - GetRenderViewHost()->GetRoutingID(); + return extra_tabs_[tab]->GetRenderViewHost()->GetRoutingID(); } int bridge_id() const { return 42; } // Not relevant at this level. InfoBarTabHelper* infobar_tab_helper() { - return tab_contents()->infobar_tab_helper(); + return InfoBarTabHelper::FromWebContents(web_contents()); + } + InfoBarTabHelper* infobar_tab_helper_for_tab(int tab) { + return InfoBarTabHelper::FromWebContents(extra_tabs_[tab]); } void RequestGeolocationPermission(int render_process_id, @@ -138,7 +141,7 @@ class GeolocationPermissionContextTests : public TabContentsTestHarness { scoped_refptr<ChromeGeolocationPermissionContext> geolocation_permission_context_; ClosedDelegateTracker closed_delegate_tracker_; - ScopedVector<TabContents> extra_tabs_; + ScopedVector<WebContents> extra_tabs_; private: // TabContentsTestHarness: @@ -195,7 +198,7 @@ void GeolocationPermissionContextTests::CheckPermissionMessageSentForTab( int bridge_id, bool allowed) { CheckPermissionMessageSentInternal(static_cast<MockRenderProcessHost*>( - extra_tabs_[tab]->web_contents()->GetRenderProcessHost()), + extra_tabs_[tab]->GetRenderProcessHost()), bridge_id, allowed); } @@ -216,7 +219,12 @@ void GeolocationPermissionContextTests::AddNewTab(const GURL& url) { url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); RenderViewHostTester::For(new_tab->GetRenderViewHost())-> SendNavigate(extra_tabs_.size() + 1, url); - extra_tabs_.push_back(TabContents::Factory::CreateTabContents(new_tab)); + + // Set up required helpers, and make this be as "tabby" as the code requires. + chrome::SetViewType(new_tab, chrome::VIEW_TYPE_TAB_CONTENTS); + InfoBarTabHelper::CreateForWebContents(new_tab); + + extra_tabs_.push_back(new_tab); } void GeolocationPermissionContextTests::CheckTabContentsState( @@ -472,14 +480,14 @@ TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) { RequestGeolocationPermission( process_id_for_tab(0), render_id_for_tab(0), bridge_id(), url_b); - EXPECT_EQ(1U, extra_tabs_[0]->infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(1U, infobar_tab_helper_for_tab(0)->GetInfoBarCount()); RequestGeolocationPermission( process_id_for_tab(1), render_id_for_tab(1), bridge_id(), url_a); - ASSERT_EQ(1U, extra_tabs_[1]->infobar_tab_helper()->GetInfoBarCount()); + ASSERT_EQ(1U, infobar_tab_helper_for_tab(1)->GetInfoBarCount()); - ConfirmInfoBarDelegate* removed_infobar = extra_tabs_[1]-> - infobar_tab_helper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); + ConfirmInfoBarDelegate* removed_infobar = infobar_tab_helper_for_tab(1)-> + GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); // Accept the first tab. ConfirmInfoBarDelegate* infobar_0 = infobar_tab_helper()-> @@ -492,7 +500,7 @@ TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) { EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0)); infobar_0->InfoBarClosed(); // Now the infobar for the tab with the same origin should have gone. - EXPECT_EQ(0U, extra_tabs_[1]->infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_tab_helper_for_tab(1)->GetInfoBarCount()); CheckPermissionMessageSentForTab(1, bridge_id(), true); EXPECT_TRUE(closed_delegate_tracker_.Contains(removed_infobar)); closed_delegate_tracker_.Clear(); @@ -500,11 +508,11 @@ TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) { removed_infobar->InfoBarClosed(); // But the other tab should still have the info bar... - ASSERT_EQ(1U, extra_tabs_[0]->infobar_tab_helper()->GetInfoBarCount()); - ConfirmInfoBarDelegate* infobar_1 = extra_tabs_[0]->infobar_tab_helper()-> + ASSERT_EQ(1U, infobar_tab_helper_for_tab(0)->GetInfoBarCount()); + ConfirmInfoBarDelegate* infobar_1 = infobar_tab_helper_for_tab(0)-> GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); infobar_1->Cancel(); - extra_tabs_[0]->infobar_tab_helper()->RemoveInfoBar(infobar_1); + infobar_tab_helper_for_tab(0)->RemoveInfoBar(infobar_1); EXPECT_EQ(1U, closed_delegate_tracker_.size()); EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_1)); infobar_1->InfoBarClosed(); @@ -523,22 +531,22 @@ TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) { RequestGeolocationPermission( process_id_for_tab(0), render_id_for_tab(0), bridge_id(), url_a); - EXPECT_EQ(1U, extra_tabs_[0]->infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(1U, infobar_tab_helper_for_tab(0)->GetInfoBarCount()); RequestGeolocationPermission( process_id_for_tab(0), render_id_for_tab(0), bridge_id() + 1, url_b); - ASSERT_EQ(1U, extra_tabs_[0]->infobar_tab_helper()->GetInfoBarCount()); + ASSERT_EQ(1U, infobar_tab_helper_for_tab(0)->GetInfoBarCount()); ConfirmInfoBarDelegate* removed_infobar = infobar_tab_helper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); // Accept the second tab. - ConfirmInfoBarDelegate* infobar_0 = extra_tabs_[0]->infobar_tab_helper()-> + ConfirmInfoBarDelegate* infobar_0 = infobar_tab_helper_for_tab(0)-> GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(infobar_0); infobar_0->Accept(); CheckPermissionMessageSentForTab(0, bridge_id(), true); - extra_tabs_[0]->infobar_tab_helper()->RemoveInfoBar(infobar_0); + infobar_tab_helper_for_tab(0)->RemoveInfoBar(infobar_0); EXPECT_EQ(2U, closed_delegate_tracker_.size()); EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0)); infobar_0->InfoBarClosed(); @@ -551,15 +559,15 @@ TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) { removed_infobar->InfoBarClosed(); // And we should have the queued infobar displayed now. - ASSERT_EQ(1U, extra_tabs_[0]->infobar_tab_helper()->GetInfoBarCount()); + ASSERT_EQ(1U, infobar_tab_helper_for_tab(0)->GetInfoBarCount()); // Accept the second infobar. - ConfirmInfoBarDelegate* infobar_1 = extra_tabs_[0]->infobar_tab_helper()-> + ConfirmInfoBarDelegate* infobar_1 = infobar_tab_helper_for_tab(0)-> GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(infobar_1); infobar_1->Accept(); CheckPermissionMessageSentForTab(0, bridge_id() + 1, true); - extra_tabs_[0]->infobar_tab_helper()->RemoveInfoBar(infobar_1); + infobar_tab_helper_for_tab(0)->RemoveInfoBar(infobar_1); EXPECT_EQ(1U, closed_delegate_tracker_.size()); EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_1)); infobar_1->InfoBarClosed(); diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc index 321dd60..af036f7 100644 --- a/chrome/browser/geolocation/geolocation_browsertest.cc +++ b/chrome/browser/geolocation/geolocation_browsertest.cc @@ -310,8 +310,7 @@ class GeolocationBrowserTest : public InProcessBrowserTest { observer.Wait(); } - TabContents* tab_contents = TabContents::FromWebContents(web_contents); - tab_contents->infobar_tab_helper()->RemoveInfoBar(infobar_); + InfoBarTabHelper::FromWebContents(web_contents)->RemoveInfoBar(infobar_); LOG(WARNING) << "infobar response set"; infobar_ = NULL; EXPECT_GT(settings_state.state_map().size(), state_map_size); @@ -567,8 +566,8 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, iframe_xpath_ = L"//iframe[@id='iframe_1']"; AddGeolocationWatch(true); - InfoBarTabHelper* infobar_helper = - chrome::GetActiveTabContents(current_browser_)->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = InfoBarTabHelper::FromWebContents( + chrome::GetActiveWebContents(current_browser_)); size_t num_infobars_before_cancel = infobar_helper->GetInfoBarCount(); // Change the iframe, and ensure the infobar is gone. IFrameLoader change_iframe_1(current_browser_, 1, current_url_); diff --git a/chrome/browser/geolocation/geolocation_infobar_queue_controller.cc b/chrome/browser/geolocation/geolocation_infobar_queue_controller.cc index ad8d49e..f991761 100644 --- a/chrome/browser/geolocation/geolocation_infobar_queue_controller.cc +++ b/chrome/browser/geolocation/geolocation_infobar_queue_controller.cc @@ -12,7 +12,6 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tab_contents/tab_util.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/content_settings.h" #include "chrome/common/pref_names.h" @@ -454,12 +453,7 @@ InfoBarTabHelper* GeolocationInfoBarQueueController::GetInfoBarHelper( int render_view_id) { WebContents* web_contents = tab_util::GetWebContentsByID(render_process_id, render_view_id); - if (!web_contents) - return NULL; - TabContents* tab_contents = TabContents::FromWebContents(web_contents); - if (!tab_contents) - return NULL; - return tab_contents->infobar_tab_helper(); + return web_contents ? InfoBarTabHelper::FromWebContents(web_contents) : NULL; } bool GeolocationInfoBarQueueController::AlreadyShowingInfoBar( diff --git a/chrome/browser/google/google_url_tracker.cc b/chrome/browser/google/google_url_tracker.cc index 00dde8c..bd1412a 100644 --- a/chrome/browser/google/google_url_tracker.cc +++ b/chrome/browser/google/google_url_tracker.cc @@ -217,14 +217,16 @@ void GoogleURLTracker::Observe(int type, case content::NOTIFICATION_NAV_ENTRY_PENDING: { content::NavigationController* controller = content::Source<content::NavigationController>(source).ptr(); - // Because we're listening to all sources, there may be no TabContents for - // some notifications, e.g. navigations in bubbles/balloons etc. See - // comments in tab_contents.h. + // Because we're listening to all sources, there may be no + // InfoBarTabHelper for some notifications, e.g. navigations in + // bubbles/balloons etc. TabContents* tab_contents = TabContents::FromWebContents(controller->GetWebContents()); if (tab_contents) { + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(tab_contents->web_contents()); OnNavigationPending(source, content::Source<TabContents>(tab_contents), - tab_contents->infobar_tab_helper(), + infobar_tab_helper, controller->GetPendingEntry()->GetUniqueID()); } break; @@ -234,28 +236,30 @@ void GoogleURLTracker::Observe(int type, content::NavigationController* controller = content::Source<content::NavigationController>(source).ptr(); // Here we're only listening to notifications where we already know - // there's an associated TabContents. - TabContents* tab_contents = - TabContents::FromWebContents(controller->GetWebContents()); - DCHECK(tab_contents); - OnNavigationCommittedOrTabClosed(tab_contents->infobar_tab_helper(), + // there's an associated InfoBarTabHelper. + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(controller->GetWebContents()); + DCHECK(infobar_tab_helper); + OnNavigationCommittedOrTabClosed(infobar_tab_helper, controller->GetActiveEntry()->GetURL()); break; } case chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED: { - OnNavigationCommittedOrTabClosed( - content::Source<TabContents>(source)->infobar_tab_helper(), GURL()); + InfoBarTabHelper* infobar_tab_helper = InfoBarTabHelper::FromWebContents( + content::Source<TabContents>(source)->web_contents()); + OnNavigationCommittedOrTabClosed(infobar_tab_helper, GURL()); break; } case chrome::NOTIFICATION_INSTANT_COMMITTED: { TabContents* tab_contents = content::Source<TabContents>(source).ptr(); content::WebContents* web_contents = tab_contents->web_contents(); - OnInstantCommitted( - content::Source<content::NavigationController>( - &web_contents->GetController()), - source, tab_contents->infobar_tab_helper(), web_contents->GetURL()); + OnInstantCommitted(content::Source<content::NavigationController>( + &web_contents->GetController()), + source, + InfoBarTabHelper::FromWebContents(web_contents), + web_contents->GetURL()); break; } diff --git a/chrome/browser/infobars/infobar_extension_api.cc b/chrome/browser/infobars/infobar_extension_api.cc index 4b7f26c..797cdb3 100644 --- a/chrome/browser/infobars/infobar_extension_api.cc +++ b/chrome/browser/infobars/infobar_extension_api.cc @@ -68,8 +68,10 @@ bool ShowInfoBarFunction::RunImpl() { return false; } - tab_contents->infobar_tab_helper()->AddInfoBar( - new ExtensionInfoBarDelegate(browser, tab_contents->infobar_tab_helper(), + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(tab_contents->web_contents()); + infobar_tab_helper->AddInfoBar( + new ExtensionInfoBarDelegate(browser, infobar_tab_helper, GetExtension(), url, height)); // TODO(finnur): Return the actual DOMWindow object. Bug 26463. diff --git a/chrome/browser/infobars/infobar_tab_helper.cc b/chrome/browser/infobars/infobar_tab_helper.cc index 7393a29d..f0ce1ac 100644 --- a/chrome/browser/infobars/infobar_tab_helper.cc +++ b/chrome/browser/infobars/infobar_tab_helper.cc @@ -7,7 +7,6 @@ #include "chrome/browser/api/infobars/infobar_delegate.h" #include "chrome/browser/infobars/infobar.h" #include "chrome/browser/infobars/insecure_content_infobar_delegate.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/render_messages.h" #include "content/public/browser/navigation_controller.h" @@ -17,14 +16,19 @@ using content::NavigationController; using content::WebContents; -InfoBarService* InfoBarService::FromTabContents(TabContents* tab) { - return tab->infobar_tab_helper(); +DEFINE_WEB_CONTENTS_USER_DATA_KEY(InfoBarTabHelper) + +InfoBarService* InfoBarService::FromWebContents(WebContents* web_contents) { + return InfoBarTabHelper::FromWebContents(web_contents); } InfoBarTabHelper::InfoBarTabHelper(WebContents* web_contents) : content::WebContentsObserver(web_contents), infobars_enabled_(true) { DCHECK(web_contents); + registrar_.Add(this, + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(web_contents)); } InfoBarTabHelper::~InfoBarTabHelper() { @@ -191,26 +195,32 @@ bool InfoBarTabHelper::OnMessageReceived(const IPC::Message& message) { void InfoBarTabHelper::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - switch (type) { - case content::NOTIFICATION_NAV_ENTRY_COMMITTED: { - DCHECK(&web_contents()->GetController() == - content::Source<NavigationController>(source).ptr()); - - content::LoadCommittedDetails& committed_details = - *(content::Details<content::LoadCommittedDetails>(details).ptr()); - - // NOTE: It is not safe to change the following code to count upwards or - // use iterators, as the RemoveInfoBar() call synchronously modifies our - // delegate list. - for (size_t i = infobars_.size(); i > 0; --i) { - InfoBarDelegate* delegate = GetInfoBarDelegateAt(i - 1); - if (delegate->ShouldExpire(committed_details)) - RemoveInfoBar(delegate); - } - - break; + if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { + DCHECK(&web_contents()->GetController() == + content::Source<NavigationController>(source).ptr()); + + content::LoadCommittedDetails& committed_details = + *(content::Details<content::LoadCommittedDetails>(details).ptr()); + + // NOTE: It is not safe to change the following code to count upwards or + // use iterators, as the RemoveInfoBar() call synchronously modifies our + // delegate list. + for (size_t i = infobars_.size(); i > 0; --i) { + InfoBarDelegate* delegate = GetInfoBarDelegateAt(i - 1); + if (delegate->ShouldExpire(committed_details)) + RemoveInfoBar(delegate); } - default: - NOTREACHED(); + + return; } + + DCHECK_EQ(type, content::NOTIFICATION_WEB_CONTENTS_DESTROYED); + // The WebContents is going away; be aggressively paranoid and delete + // ourselves lest other parts of the system attempt to add infobars or use + // us otherwise during the destruction. + DCHECK_EQ(web_contents(), content::Source<WebContents>(source).ptr()); + web_contents()->RemoveUserData(&kLocatorKey); + // That was the equivalent of "delete this". This object is now destroyed; + // returning from this function is the only safe thing to do. + return; } diff --git a/chrome/browser/infobars/infobar_tab_helper.h b/chrome/browser/infobars/infobar_tab_helper.h index 3e2c38d9..a0070f6 100644 --- a/chrome/browser/infobars/infobar_tab_helper.h +++ b/chrome/browser/infobars/infobar_tab_helper.h @@ -10,17 +10,20 @@ #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/web_contents_observer.h" +#include "content/public/browser/web_contents_user_data.h" class InfoBarDelegate; // Per-tab info bar manager. class InfoBarTabHelper : public InfoBarService, public content::WebContentsObserver, - public content::NotificationObserver { + public content::NotificationObserver, + public content::WebContentsUserData<InfoBarTabHelper> { public: - explicit InfoBarTabHelper(content::WebContents* web_contents); virtual ~InfoBarTabHelper(); + using content::WebContentsUserData<InfoBarTabHelper>::FromWebContents; + // InfoBarService implementation. virtual bool AddInfoBar(InfoBarDelegate* delegate) OVERRIDE; virtual void RemoveInfoBar(InfoBarDelegate* delegate) OVERRIDE; @@ -43,8 +46,12 @@ class InfoBarTabHelper : public InfoBarService, const content::NotificationDetails& details) OVERRIDE; private: + friend class content::WebContentsUserData<InfoBarTabHelper>; + typedef std::vector<InfoBarDelegate*> InfoBars; + explicit InfoBarTabHelper(content::WebContents* web_contents); + void RemoveInfoBarInternal(InfoBarDelegate* delegate, bool animate); void RemoveAllInfoBars(bool animate); diff --git a/chrome/browser/infobars/infobars_browsertest.cc b/chrome/browser/infobars/infobars_browsertest.cc index 968804b..2ff66be 100644 --- a/chrome/browser/infobars/infobars_browsertest.cc +++ b/chrome/browser/infobars/infobars_browsertest.cc @@ -75,8 +75,8 @@ IN_PROC_BROWSER_TEST_F(InfoBarsTest, TestInfoBarsCloseOnNewTheme) { infobar_added_2.Wait(); infobar_removed_1.Wait(); EXPECT_EQ(0u, - chrome::GetTabContentsAt(browser(), 0)->infobar_tab_helper()-> - GetInfoBarCount()); + InfoBarTabHelper::FromWebContents( + chrome::GetWebContentsAt(browser(), 0))->GetInfoBarCount()); content::WindowedNotificationObserver infobar_removed_2( chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, @@ -84,6 +84,6 @@ IN_PROC_BROWSER_TEST_F(InfoBarsTest, TestInfoBarsCloseOnNewTheme) { ThemeServiceFactory::GetForProfile(browser()->profile())->UseDefaultTheme(); infobar_removed_2.Wait(); EXPECT_EQ(0u, - chrome::GetActiveTabContents(browser())->infobar_tab_helper()-> - GetInfoBarCount()); + InfoBarTabHelper::FromWebContents( + chrome::GetActiveWebContents(browser()))->GetInfoBarCount()); } diff --git a/chrome/browser/intents/register_intent_handler_helper.cc b/chrome/browser/intents/register_intent_handler_helper.cc index 553971e..01c1e2c 100644 --- a/chrome/browser/intents/register_intent_handler_helper.cc +++ b/chrome/browser/intents/register_intent_handler_helper.cc @@ -6,6 +6,7 @@ #include "chrome/browser/favicon/favicon_service.h" #include "chrome/browser/favicon/favicon_service_factory.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" #include "chrome/browser/intents/web_intents_registry_factory.h" #include "chrome/browser/intents/web_intents_util.h" @@ -19,10 +20,10 @@ using content::WebContents; // static void Browser::RegisterIntentHandlerHelper( - WebContents* tab, + WebContents* web_contents, const webkit_glue::WebIntentServiceData& data, bool user_gesture) { - TabContents* tab_contents = TabContents::FromWebContents(tab); + TabContents* tab_contents = TabContents::FromWebContents(web_contents); if (!tab_contents || tab_contents->profile()->IsOffTheRecord()) return; @@ -33,9 +34,9 @@ void Browser::RegisterIntentHandlerHelper( tab_contents->profile(), Profile::EXPLICIT_ACCESS); RegisterIntentHandlerInfoBarDelegate::MaybeShowIntentInfoBar( - tab_contents->infobar_tab_helper(), + InfoBarTabHelper::FromWebContents(web_contents), WebIntentsRegistryFactory::GetForProfile(tab_contents->profile()), data, favicon_service, - tab->GetURL()); + web_contents->GetURL()); } 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 c39e2c0..ba57f46 100644 --- a/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc +++ b/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc @@ -4,6 +4,7 @@ #include "base/synchronization/waitable_event.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/infobars/infobar_tab_helper.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" @@ -70,7 +71,7 @@ TEST_F(RegisterIntentHandlerInfoBarDelegateTest, Accept) { service.action = ASCIIToUTF16("http://webintents.org/share"); service.type = ASCIIToUTF16("text/url"); RegisterIntentHandlerInfoBarDelegate delegate( - tab_contents()->infobar_tab_helper(), + InfoBarTabHelper::FromWebContents(web_contents()), WebIntentsRegistryFactory::GetForProfile(profile()), service, NULL, GURL()); diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc index 60096c5..bfac01a 100644 --- a/chrome/browser/notifications/desktop_notification_service.cc +++ b/chrome/browser/notifications/desktop_notification_service.cc @@ -401,16 +401,16 @@ void DesktopNotificationService::RequestPermission( ContentSetting setting = GetContentSetting(origin); if (setting == CONTENT_SETTING_ASK) { // Show an info bar requesting permission. - TabContents* tab_contents = TabContents::FromWebContents(contents); - // |tab_contents| may be NULL, e.g., if this request originated in a + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(contents); + // |infobar_tab_helper| may be NULL, e.g., if this request originated in a // browser action popup, extension background page, or any HTML that runs // outside of a tab. - if (tab_contents) { - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); - infobar_helper->AddInfoBar(new NotificationPermissionInfoBarDelegate( - infobar_helper, + if (infobar_tab_helper) { + infobar_tab_helper->AddInfoBar(new NotificationPermissionInfoBarDelegate( + infobar_tab_helper, DesktopNotificationServiceFactory::GetForProfile( - tab_contents->profile()), + Profile::FromBrowserContext(contents->GetBrowserContext())), origin, DisplayNameForOrigin(origin), process_id, diff --git a/chrome/browser/notifications/notification_browsertest.cc b/chrome/browser/notifications/notification_browsertest.cc index 21da5dd..3a693da 100644 --- a/chrome/browser/notifications/notification_browsertest.cc +++ b/chrome/browser/notifications/notification_browsertest.cc @@ -5,7 +5,6 @@ #include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_tabstrip.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "content/public/browser/web_contents.h" @@ -37,8 +36,8 @@ IN_PROC_BROWSER_TEST_F(NotificationsPermissionTest, TestUserGestureInfobar) { &result)); EXPECT_TRUE(result); - EXPECT_EQ(1U, chrome::GetTabContentsAt(browser(), 0)->infobar_tab_helper()-> - GetInfoBarCount()); + EXPECT_EQ(1U, InfoBarTabHelper::FromWebContents( + chrome::GetWebContentsAt(browser(), 0))->GetInfoBarCount()); } // If this flakes, use http://crbug.com/62311. @@ -52,6 +51,6 @@ IN_PROC_BROWSER_TEST_F(NotificationsPermissionTest, TestNoUserGestureInfobar) { test_server()->GetURL( "files/notifications/notifications_request_inline.html")); - EXPECT_EQ(0U, chrome::GetTabContentsAt(browser(), 0)->infobar_tab_helper()-> - GetInfoBarCount()); + EXPECT_EQ(0U, InfoBarTabHelper::FromWebContents( + chrome::GetWebContentsAt(browser(), 0))->GetInfoBarCount()); } diff --git a/chrome/browser/omnibox_search_hint.cc b/chrome/browser/omnibox_search_hint.cc index 60172f2..8f42aac 100644 --- a/chrome/browser/omnibox_search_hint.cc +++ b/chrome/browser/omnibox_search_hint.cc @@ -216,7 +216,7 @@ void OmniboxSearchHint::Observe(int type, void OmniboxSearchHint::ShowInfoBar() { InfoBarTabHelper* infobar_tab_helper = - TabContents::FromWebContents(web_contents_)->infobar_tab_helper(); + InfoBarTabHelper::FromWebContents(web_contents_); infobar_tab_helper->AddInfoBar(new HintInfoBar(this, infobar_tab_helper)); } diff --git a/chrome/browser/password_manager/password_manager_delegate_impl.cc b/chrome/browser/password_manager/password_manager_delegate_impl.cc index bba3f94..6548479 100644 --- a/chrome/browser/password_manager/password_manager_delegate_impl.cc +++ b/chrome/browser/password_manager/password_manager_delegate_impl.cc @@ -163,10 +163,10 @@ void PasswordManagerDelegateImpl::AddSavePasswordInfoBarIfPermitted( } #endif - TabContents* tab_contents = TabContents::FromWebContents(web_contents_); - tab_contents->infobar_tab_helper()->AddInfoBar( - new SavePasswordInfoBarDelegate( - tab_contents->infobar_tab_helper(), form_to_save)); + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(web_contents_); + infobar_tab_helper->AddInfoBar( + new SavePasswordInfoBarDelegate(infobar_tab_helper, form_to_save)); } Profile* PasswordManagerDelegateImpl::GetProfile() { diff --git a/chrome/browser/pepper_broker_observer.cc b/chrome/browser/pepper_broker_observer.cc index c78bf09..a84493b 100644 --- a/chrome/browser/pepper_broker_observer.cc +++ b/chrome/browser/pepper_broker_observer.cc @@ -12,7 +12,6 @@ #include "chrome/browser/plugins/plugin_metadata.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/common/pref_names.h" #include "content/public/browser/page_navigator.h" #include "content/public/browser/plugin_service.h" @@ -180,13 +179,8 @@ bool PepperBrokerObserver::RequestPpapiBrokerPermission( const GURL& url, const FilePath& plugin_path, const base::Callback<void(bool)>& callback) { - TabContents* tab = TabContents::FromWebContents(web_contents); - if (!tab) { - callback.Run(false); - return true; - } - - Profile* profile = tab->profile(); + Profile* profile = + Profile::FromBrowserContext(web_contents->GetBrowserContext()); // TODO(wad): Add ephemeral device ID support for broker in guest mode. if (Profile::IsGuestSession()) { callback.Run(false); @@ -216,7 +210,8 @@ bool PepperBrokerObserver::RequestPpapiBrokerPermission( content::RecordAction( content::UserMetricsAction("PPAPI.BrokerInfobarDisplayed")); - InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents); std::string languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); infobar_helper->AddInfoBar( diff --git a/chrome/browser/plugins/plugin_infobar_delegates.cc b/chrome/browser/plugins/plugin_infobar_delegates.cc index a037fe2..5da238c 100644 --- a/chrome/browser/plugins/plugin_infobar_delegates.cc +++ b/chrome/browser/plugins/plugin_infobar_delegates.cc @@ -178,8 +178,7 @@ OutdatedPluginInfoBarDelegate::OutdatedPluginInfoBarDelegate( scoped_ptr<PluginMetadata> plugin_metadata, const string16& message) : PluginInfoBarDelegate( - InfoBarService::FromTabContents( - TabContents::FromWebContents(web_contents)), + InfoBarService::FromWebContents(web_contents), plugin_metadata->name(), plugin_metadata->identifier()), WeakPluginInstallerObserver(installer), diff --git a/chrome/browser/plugins/plugin_observer.cc b/chrome/browser/plugins/plugin_observer.cc index 3bbc9ca..50a4ea5 100644 --- a/chrome/browser/plugins/plugin_observer.cc +++ b/chrome/browser/plugins/plugin_observer.cc @@ -190,8 +190,8 @@ void PluginObserver::PluginCrashed(const FilePath& plugin_path) { PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); gfx::Image* icon = &ResourceBundle::GetSharedInstance().GetNativeImageNamed( IDR_INFOBAR_PLUGIN_CRASHED); - TabContents* tab_contents = TabContents::FromWebContents(web_contents()); - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents()); infobar_helper->AddInfoBar( new SimpleAlertInfoBarDelegate( infobar_helper, @@ -226,12 +226,13 @@ bool PluginObserver::OnMessageReceived(const IPC::Message& message) { void PluginObserver::OnBlockedUnauthorizedPlugin( const string16& name, const std::string& identifier) { - TabContents* tab_contents = TabContents::FromWebContents(web_contents()); - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents()); infobar_helper->AddInfoBar( new UnauthorizedPluginInfoBarDelegate( infobar_helper, - tab_contents->profile()->GetHostContentSettingsMap(), + Profile::FromBrowserContext(web_contents()->GetBrowserContext())-> + GetHostContentSettingsMap(), name, identifier)); } @@ -250,8 +251,8 @@ void PluginObserver::OnBlockedOutdatedPlugin(int placeholder_id, plugin_placeholders_[placeholder_id] = new PluginPlaceholderHost(this, placeholder_id, plugin->name(), installer); - TabContents* tab_contents = TabContents::FromWebContents(web_contents()); - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents()); infobar_helper->AddInfoBar( OutdatedPluginInfoBarDelegate::Create(web_contents(), installer, plugin.Pass())); @@ -281,12 +282,12 @@ void PluginObserver::OnFindMissingPlugin(int placeholder_id, new PluginPlaceholderHost(this, placeholder_id, plugin_metadata->name(), installer); - TabContents* tab_contents = TabContents::FromWebContents(web_contents()); - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); base::Closure callback = base::Bind(&PluginObserver::InstallMissingPlugin, weak_ptr_factory_.GetWeakPtr(), installer, base::Passed(plugin_metadata->Clone())); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents()); InfoBarDelegate* delegate; #if !defined(OS_WIN) delegate = PluginInstallerInfoBarDelegate::Create( @@ -342,8 +343,8 @@ void PluginObserver::OnCouldNotLoadPlugin(const FilePath& plugin_path) { g_browser_process->metrics_service()->LogPluginLoadingError(plugin_path); string16 plugin_name = PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); - TabContents* tab_contents = TabContents::FromWebContents(web_contents()); - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents()); infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( infobar_helper, &ResourceBundle::GetSharedInstance().GetNativeImageNamed( diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc index 426c42c..70b5f84 100644 --- a/chrome/browser/policy/policy_browsertest.cc +++ b/chrome/browser/policy/policy_browsertest.cc @@ -973,9 +973,8 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, AlwaysAuthorizePlugins) { content::WebContents* contents = chrome::GetActiveWebContents(browser()); ASSERT_TRUE(contents); - TabContents* tab_contents = TabContents::FromWebContents(contents); - ASSERT_TRUE(tab_contents); - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(contents); ASSERT_TRUE(infobar_helper); EXPECT_EQ(0u, infobar_helper->GetInfoBarCount()); @@ -984,7 +983,8 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, AlwaysAuthorizePlugins) { ui_test_utils::NavigateToURL(browser(), url); // This should have triggered the dangerous plugin infobar. ASSERT_EQ(1u, infobar_helper->GetInfoBarCount()); - InfoBarDelegate* infobar_delegate = infobar_helper->GetInfoBarDelegateAt(0); + InfoBarDelegate* infobar_delegate = + infobar_helper->GetInfoBarDelegateAt(0); EXPECT_TRUE(infobar_delegate->AsConfirmInfoBarDelegate()); // And the plugin isn't running. EXPECT_EQ(0, CountPlugins()); @@ -1270,9 +1270,8 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, TranslateEnabled) { // Get the |infobar_helper|, and verify that there are no infobars on startup. content::WebContents* contents = chrome::GetActiveWebContents(browser()); ASSERT_TRUE(contents); - TabContents* tab_contents = TabContents::FromWebContents(contents); - ASSERT_TRUE(tab_contents); - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(contents); ASSERT_TRUE(infobar_helper); EXPECT_EQ(0u, infobar_helper->GetInfoBarCount()); @@ -1295,7 +1294,8 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, TranslateEnabled) { language_observer1.Wait(); // Verify that the translate infobar showed up. ASSERT_EQ(1u, infobar_helper->GetInfoBarCount()); - InfoBarDelegate* infobar_delegate = infobar_helper->GetInfoBarDelegateAt(0); + InfoBarDelegate* infobar_delegate = + infobar_helper->GetInfoBarDelegateAt(0); TranslateInfoBarDelegate* delegate = infobar_delegate->AsTranslateInfoBarDelegate(); ASSERT_TRUE(delegate); @@ -1303,7 +1303,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, TranslateEnabled) { EXPECT_EQ("fr", delegate->original_language_code()); // Now force disable translate. - ui_test_utils::CloseAllInfoBars(tab_contents); + infobar_helper->RemoveInfoBar(infobar_delegate); EXPECT_EQ(0u, infobar_helper->GetInfoBarCount()); policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false)); diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc index 33dd892..e7fba70 100644 --- a/chrome/browser/prerender/prerender_browsertest.cc +++ b/chrome/browser/prerender/prerender_browsertest.cc @@ -17,6 +17,7 @@ #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/favicon/favicon_tab_helper.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prerender/prerender_contents.h" #include "chrome/browser/prerender/prerender_handle.h" @@ -1790,8 +1791,6 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderWindowSize) { #else IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderWindowSize) { #endif - ui_test_utils::CloseAllInfoBars(chrome::GetActiveTabContents(browser())); - PrerenderTestURL("files/prerender/prerender_size.html", FINAL_STATUS_USED, 1); diff --git a/chrome/browser/ssl/ssl_tab_helper.cc b/chrome/browser/ssl/ssl_tab_helper.cc index 932be4b..ee587b9 100644 --- a/chrome/browser/ssl/ssl_tab_helper.cc +++ b/chrome/browser/ssl/ssl_tab_helper.cc @@ -139,8 +139,7 @@ class SSLTabHelper::SSLAddCertData }; SSLTabHelper::SSLAddCertData::SSLAddCertData(content::WebContents* contents) - : infobar_helper_( - TabContents::FromWebContents(contents)->infobar_tab_helper()), + : infobar_helper_(InfoBarTabHelper::FromWebContents(contents)), infobar_delegate_(NULL) { content::Source<InfoBarTabHelper> source(infobar_helper_); registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, @@ -218,9 +217,10 @@ void SSLTabHelper::OnAddClientCertificateSuccess( scoped_refptr<SSLAddCertHandler> handler) { SSLAddCertData* add_cert_data = GetAddCertData(handler); // Display an infobar to inform the user. - TabContents* tab_contents = TabContents::FromWebContents(web_contents_); + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(web_contents_); add_cert_data->ShowInfoBar(new SSLCertAddedInfoBarDelegate( - tab_contents->infobar_tab_helper(), handler->cert())); + infobar_tab_helper, handler->cert())); } void SSLTabHelper::OnAddClientCertificateError( diff --git a/chrome/browser/task_manager/task_manager_browsertest.cc b/chrome/browser/task_manager/task_manager_browsertest.cc index 01f5634..f699ee2 100644 --- a/chrome/browser/task_manager/task_manager_browsertest.cc +++ b/chrome/browser/task_manager/task_manager_browsertest.cc @@ -471,8 +471,8 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, // Reload the extension using the "crashed extension" infobar while the task // manager is still visible. Make sure we don't crash and the extension // gets reloaded and noticed in the task manager. - InfoBarTabHelper* infobar_helper = - chrome::GetActiveTabContents(browser())->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = InfoBarTabHelper::FromWebContents( + chrome::GetActiveWebContents(browser())); ASSERT_EQ(1U, infobar_helper->GetInfoBarCount()); ConfirmInfoBarDelegate* delegate = infobar_helper-> GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc index 277e86c..b3bdca7 100644 --- a/chrome/browser/translate/translate_manager.cc +++ b/chrome/browser/translate/translate_manager.cc @@ -28,7 +28,6 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_tabstrip.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_switches.h" @@ -473,14 +472,16 @@ void TranslateManager::OnURLFetchComplete(const net::URLFetcher* source) { } if (error) { - TabContents* tab_contents = TabContents::FromWebContents(web_contents); - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); + Profile* profile = + Profile::FromBrowserContext(web_contents->GetBrowserContext()); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents); ShowInfoBar( web_contents, TranslateInfoBarDelegate::CreateErrorDelegate( TranslateErrors::NETWORK, infobar_helper, - tab_contents->profile()->GetPrefs(), + profile->GetPrefs(), request.source_lang, request.target_lang)); } else { @@ -600,13 +601,13 @@ void TranslateManager::InitiateTranslation(WebContents* web_contents, return; } - TabContents* tab_contents = TabContents::FromWebContents(web_contents); - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents); // Prompts the user if he/she wants the page translated. infobar_helper->AddInfoBar( TranslateInfoBarDelegate::CreateDelegate( TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar_helper, - tab_contents->profile()->GetPrefs(), language_code, target_lang)); + profile->GetPrefs(), language_code, target_lang)); } void TranslateManager::InitiateTranslationPosted( @@ -634,11 +635,13 @@ void TranslateManager::TranslatePage(WebContents* web_contents, return; } - TabContents* tab_contents = TabContents::FromWebContents(web_contents); - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); + Profile* profile = + Profile::FromBrowserContext(web_contents->GetBrowserContext()); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents); ShowInfoBar(web_contents, TranslateInfoBarDelegate::CreateDelegate( TranslateInfoBarDelegate::TRANSLATING, infobar_helper, - tab_contents->profile()->GetPrefs(), source_lang, target_lang)); + profile->GetPrefs(), source_lang, target_lang)); if (!translate_script_.empty()) { DoTranslatePage(web_contents, translate_script_, source_lang, target_lang); @@ -727,9 +730,11 @@ void TranslateManager::DoTranslatePage(WebContents* web_contents, void TranslateManager::PageTranslated(WebContents* web_contents, PageTranslatedDetails* details) { - TabContents* tab_contents = TabContents::FromWebContents(web_contents); - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); - PrefService* prefs = tab_contents->profile()->GetPrefs(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents); + Profile* profile = + Profile::FromBrowserContext(web_contents->GetBrowserContext()); + PrefService* prefs = profile->GetPrefs(); // Create the new infobar to display. TranslateInfoBarDelegate* infobar; @@ -873,10 +878,10 @@ void TranslateManager::ShowInfoBar(content::WebContents* web_contents, TranslateInfoBarDelegate* old_infobar = GetTranslateInfoBarDelegate(web_contents); infobar->UpdateBackgroundAnimation(old_infobar); - TabContents* tab_contents = TabContents::FromWebContents(web_contents); - if (!tab_contents) + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents); + if (!infobar_helper) return; - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); if (old_infobar) { // There already is a translate infobar, simply replace it. infobar_helper->ReplaceInfoBar(old_infobar, infobar); @@ -913,14 +918,15 @@ std::string TranslateManager::GetTargetLanguage(PrefService* prefs) { // static TranslateInfoBarDelegate* TranslateManager::GetTranslateInfoBarDelegate( WebContents* web_contents) { - TabContents* tab_contents = TabContents::FromWebContents(web_contents); - if (!tab_contents) + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents); + if (!infobar_helper) return NULL; - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); ++i) { TranslateInfoBarDelegate* delegate = - infobar_helper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); + infobar_helper->GetInfoBarDelegateAt(i)-> + AsTranslateInfoBarDelegate(); if (delegate) return delegate; } diff --git a/chrome/browser/translate/translate_manager_browsertest.cc b/chrome/browser/translate/translate_manager_browsertest.cc index 477d4c2..9e96c3f 100644 --- a/chrome/browser/translate/translate_manager_browsertest.cc +++ b/chrome/browser/translate/translate_manager_browsertest.cc @@ -137,7 +137,7 @@ class TranslateManagerTest : public TabContentsTestHarness, } InfoBarTabHelper* infobar_tab_helper() { - return tab_contents()->infobar_tab_helper(); + return InfoBarTabHelper::FromWebContents(web_contents()); } // Returns the translate infobar if there is 1 infobar and it is a translate @@ -234,8 +234,7 @@ class TranslateManagerTest : public TabContentsTestHarness, notification_registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - content::Source<InfoBarTabHelper>( - tab_contents()->infobar_tab_helper())); + content::Source<InfoBarTabHelper>(infobar_tab_helper())); } virtual void TearDown() { @@ -243,8 +242,7 @@ class TranslateManagerTest : public TabContentsTestHarness, notification_registrar_.Remove(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - content::Source<InfoBarTabHelper>( - tab_contents()->infobar_tab_helper())); + content::Source<InfoBarTabHelper>(infobar_tab_helper())); TabContentsTestHarness::TearDown(); WebKit::shutdown(); diff --git a/chrome/browser/ui/auto_login_prompter.cc b/chrome/browser/ui/auto_login_prompter.cc index ad69cd7e..1efe7e1 100644 --- a/chrome/browser/ui/auto_login_prompter.cc +++ b/chrome/browser/ui/auto_login_prompter.cc @@ -20,7 +20,6 @@ #include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/tab_contents/tab_util.h" #include "chrome/browser/ui/auto_login_info_bar_delegate.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" @@ -176,10 +175,10 @@ void AutoLoginPrompter::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { if (type == content::NOTIFICATION_LOAD_STOP) { - TabContents* tab_contents = TabContents::FromWebContents(web_contents_); - // |tab_contents| is NULL for WebContents hosted in WebDialog. - if (tab_contents) { - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents_); + // |infobar_helper| is NULL for WebContents hosted in WebDialog. + if (infobar_helper) { infobar_helper->AddInfoBar( new AutoLoginInfoBarDelegate(infobar_helper, params_)); } diff --git a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc b/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc index 84b46df..1a2ec37 100644 --- a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc +++ b/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc @@ -44,7 +44,7 @@ Profile* TabAutofillManagerDelegate::GetOriginalProfile() const { } InfoBarService* TabAutofillManagerDelegate::GetInfoBarService() { - return TabContents::FromWebContents(web_contents_)->infobar_tab_helper(); + return InfoBarTabHelper::FromWebContents(web_contents_); } PrefServiceBase* TabAutofillManagerDelegate::GetPrefs() { diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index c28b515..78fc183 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -850,11 +850,11 @@ bool Browser::RunUnloadEventsHelper(WebContents* contents) { // static void Browser::JSOutOfMemoryHelper(WebContents* web_contents) { - TabContents* tab_contents = TabContents::FromWebContents(web_contents); - if (!tab_contents) + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents); + if (!infobar_helper) return; - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( infobar_helper, NULL, @@ -901,7 +901,8 @@ void Browser::RegisterProtocolHandlerHelper(WebContents* web_contents, content::RecordAction( UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown")); - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents); RegisterProtocolHandlerInfoBarDelegate* rph_delegate = new RegisterProtocolHandlerInfoBarDelegate(infobar_helper, @@ -953,7 +954,8 @@ void Browser::RequestMediaAccessPermissionHelper( request, callback)); if (!controller->DismissInfoBarAndTakeActionOnSettings()) { - InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents); InfoBarDelegate* old_infobar = NULL; for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); ++i) { old_infobar = infobar_helper->GetInfoBarDelegateAt(i)-> @@ -1559,8 +1561,8 @@ void Browser::RendererResponsive(WebContents* source) { } void Browser::WorkerCrashed(WebContents* source) { - TabContents* tab_contents = TabContents::FromWebContents(source); - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(source); infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( infobar_helper, NULL, diff --git a/chrome/browser/ui/chrome_select_file_policy.cc b/chrome/browser/ui/chrome_select_file_policy.cc index b41f060..d5399d9 100644 --- a/chrome/browser/ui/chrome_select_file_policy.cc +++ b/chrome/browser/ui/chrome_select_file_policy.cc @@ -11,7 +11,6 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/common/pref_names.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -30,9 +29,9 @@ bool ChromeSelectFilePolicy::CanOpenSelectFileDialog() { void ChromeSelectFilePolicy::SelectFileDenied() { // Show the InfoBar saying that file-selection dialogs are disabled. if (source_contents_) { - TabContents* tab_contents = TabContents::FromWebContents(source_contents_); - DCHECK(tab_contents); - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(source_contents_); + DCHECK(infobar_helper); infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( infobar_helper, NULL, diff --git a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm index d41d3c5..3415948 100644 --- a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm +++ b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm @@ -240,9 +240,10 @@ void CollectedCookiesMac::OnSheetDidEnd(NSWindow* sheet) { - (void)windowWillClose:(NSNotification*)notif { if (contentSettingsChanged_) { - InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); - infobar_helper->AddInfoBar( - new CollectedCookiesInfoBarDelegate(infobar_helper)); + InfoBarTabHelper* infobarTabHelper = + InfoBarTabHelper::FromWebContents(tab_contents_->web_contents()); + infobarTabHelper->AddInfoBar( + new CollectedCookiesInfoBarDelegate(infobarTabHelper)); } [allowedOutlineView_ setDelegate:nil]; [blockedOutlineView_ setDelegate:nil]; diff --git a/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm b/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm index fe1be7b..5c169e0 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm @@ -142,15 +142,15 @@ class InfoBarNotificationObserver : public content::NotificationObserver { currentTabContents_ = contents; if (currentTabContents_) { - InfoBarTabHelper* infobar_helper = - currentTabContents_->infobar_tab_helper(); - for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); ++i) { - InfoBar* infobar = infobar_helper-> - GetInfoBarDelegateAt(i)->CreateInfoBar(infobar_helper); + InfoBarTabHelper* infobarTabHelper = + InfoBarTabHelper::FromWebContents(currentTabContents_->web_contents()); + for (size_t i = 0; i < infobarTabHelper->GetInfoBarCount(); ++i) { + InfoBar* infobar = infobarTabHelper-> + GetInfoBarDelegateAt(i)->CreateInfoBar(infobarTabHelper); [self addInfoBar:infobar animate:NO]; } - content::Source<InfoBarTabHelper> source(infobar_helper); + content::Source<InfoBarTabHelper> source(infobarTabHelper); registrar_.Add(infoBarObserver_.get(), chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, source); registrar_.Add(infoBarObserver_.get(), diff --git a/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm b/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm index 59b8b52..1b26cfd 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm @@ -110,12 +110,13 @@ class LinkInfoBarControllerTest : public CocoaProfileTest, CocoaProfileTest::SetUp(); tab_contents_.reset(InfoBarControllerContentsCreator::CreateTabContents( WebContents::Create(profile(), NULL, MSG_ROUTING_NONE, NULL))); - tab_contents_->infobar_tab_helper()->set_infobars_enabled(false); + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(tab_contents_->web_contents()); + infobar_tab_helper->set_infobars_enabled(false); delegate_ = new MockLinkInfoBarDelegate(this); controller_.reset([[TestLinkInfoBarController alloc] - initWithDelegate:delegate_ - owner:tab_contents_.get()->infobar_tab_helper()]); + initWithDelegate:delegate_ owner:infobar_tab_helper]); container_.reset( [[InfoBarContainerTest alloc] initWithController:controller_]); [controller_ setContainerController:container_]; @@ -154,12 +155,13 @@ class ConfirmInfoBarControllerTest : public CocoaProfileTest, CocoaProfileTest::SetUp(); tab_contents_.reset(InfoBarControllerContentsCreator::CreateTabContents( WebContents::Create(profile(), NULL, MSG_ROUTING_NONE, NULL))); - tab_contents_->infobar_tab_helper()->set_infobars_enabled(false); + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(tab_contents_->web_contents()); + infobar_tab_helper->set_infobars_enabled(false); delegate_ = new MockConfirmInfoBarDelegate(this); controller_.reset([[TestConfirmInfoBarController alloc] - initWithDelegate:delegate_ - owner:tab_contents_.get()->infobar_tab_helper()]); + initWithDelegate:delegate_ owner:infobar_tab_helper]); container_.reset( [[InfoBarContainerTest alloc] initWithController:controller_]); [controller_ setContainerController:container_]; diff --git a/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm b/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm index 88fec711..8d08878 100644 --- a/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm +++ b/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm @@ -87,15 +87,17 @@ class TranslationInfoBarTest : public CocoaProfileTest { TranslateErrors::Type error = TranslateErrors::NONE; if (type == TranslateInfoBarDelegate::TRANSLATION_ERROR) error = TranslateErrors::NETWORK; + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(tab_contents_->web_contents()); infobar_delegate_.reset(new MockTranslateInfoBarDelegate( type, error, - tab_contents_->infobar_tab_helper(), + infobar_tab_helper, tab_contents_->profile()->GetPrefs())); [[infobar_controller_ view] removeFromSuperview]; scoped_ptr<InfoBar> infobar( static_cast<InfoBarDelegate*>(infobar_delegate_.get())-> - CreateInfoBar(tab_contents_->infobar_tab_helper())); + CreateInfoBar(infobar_tab_helper)); infobar_controller_.reset( reinterpret_cast<TranslateInfoBarControllerBase*>( infobar->controller())); diff --git a/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm b/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm index ba3ed49..c75eeb7 100644 --- a/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm +++ b/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm @@ -21,7 +21,6 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "content/public/browser/navigation_details.h" @@ -192,17 +191,19 @@ bool KeystonePromotionInfoBarDelegate::ShouldExpireInternal( [[KeystoneGlue defaultKeystoneGlue] needsPromotion]) { Browser* browser = browser::GetLastActiveBrowser(); if (browser) { - TabContents* tabContents = chrome::GetActiveTabContents(browser); + content::WebContents* webContents = chrome::GetActiveWebContents(browser); // Only show if no other info bars are showing, because that's how the // default browser info bar works. - if (tabContents) { - InfoBarTabHelper* infobar_helper = tabContents->infobar_tab_helper(); - if (infobar_helper->GetInfoBarCount() == 0) { - infobar_helper->AddInfoBar( + if (webContents) { + InfoBarTabHelper* infobarTabHelper = + InfoBarTabHelper::FromWebContents(webContents); + if (infobarTabHelper->GetInfoBarCount() == 0) { + infobarTabHelper->AddInfoBar( new KeystonePromotionInfoBarDelegate( - infobar_helper, - tabContents->profile()->GetPrefs())); + infobarTabHelper, + Profile::FromBrowserContext( + webContents->GetBrowserContext())->GetPrefs())); } } } diff --git a/chrome/browser/ui/cocoa/website_settings_bubble_controller.mm b/chrome/browser/ui/cocoa/website_settings_bubble_controller.mm index 1eba6c6..35b8b0d 100644 --- a/chrome/browser/ui/cocoa/website_settings_bubble_controller.mm +++ b/chrome/browser/ui/cocoa/website_settings_bubble_controller.mm @@ -11,6 +11,7 @@ #include "base/string_number_conversions.h" #include "base/sys_string_conversions.h" #import "chrome/browser/certificate_viewer.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #import "chrome/browser/ui/browser_dialogs.h" #import "chrome/browser/ui/cocoa/browser_window_controller.h" #import "chrome/browser/ui/cocoa/flipped_view.h" @@ -1149,7 +1150,7 @@ void WebsiteSettingsUIBridge::Show(gfx::NativeWindow parent, profile, TabSpecificContentSettings::FromWebContents( tab_contents->web_contents()), - tab_contents->infobar_tab_helper(), + InfoBarTabHelper::FromWebContents(tab_contents->web_contents()), url, ssl, content::CertStore::GetInstance()); diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc index 4da7a41..159d90b 100644 --- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc @@ -381,7 +381,8 @@ ContentSettingCookiesBubbleModel::ContentSettingCookiesBubbleModel( ContentSettingCookiesBubbleModel::~ContentSettingCookiesBubbleModel() { if (settings_changed()) { - InfoBarTabHelper* infobar_helper = tab_contents()->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(tab_contents()->web_contents()); infobar_helper->AddInfoBar( new CollectedCookiesInfoBarDelegate(infobar_helper)); } diff --git a/chrome/browser/ui/extensions/shell_window.cc b/chrome/browser/ui/extensions/shell_window.cc index 5851ec1..fa3e848 100644 --- a/chrome/browser/ui/extensions/shell_window.cc +++ b/chrome/browser/ui/extensions/shell_window.cc @@ -160,8 +160,8 @@ void ShellWindow::Init(const GURL& url, content::NotificationService::AllSources()); // Automatically dismiss all infobars. - TabContents* tab_contents = TabContents::FromWebContents(web_contents_); - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents_); infobar_helper->set_infobars_enabled(false); // Prevent the browser process from shutting down while this window is open. diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc index 8585c5f..86682ac 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.cc +++ b/chrome/browser/ui/gtk/browser_window_gtk.cc @@ -30,6 +30,7 @@ #include "chrome/browser/debugger/devtools_window.h" #include "chrome/browser/download/download_item_model.h" #include "chrome/browser/extensions/tab_helper.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/profiles/profile.h" @@ -1249,7 +1250,9 @@ void BrowserWindowGtk::ActiveTabChanged(TabContents* old_contents, // Update various elements that are interested in knowing the current // WebContents. UpdateDevToolsForContents(new_contents->web_contents()); - infobar_container_->ChangeTabContents(new_contents->infobar_tab_helper()); + InfoBarTabHelper* new_infobar_tab_helper = + InfoBarTabHelper::FromWebContents(new_contents->web_contents()); + infobar_container_->ChangeTabContents(new_infobar_tab_helper); contents_container_->SetTab(new_contents); // TODO(estade): after we manage browser activation, add a check to make sure diff --git a/chrome/browser/ui/gtk/collected_cookies_gtk.cc b/chrome/browser/ui/gtk/collected_cookies_gtk.cc index 3605479..8fc13c5 100644 --- a/chrome/browser/ui/gtk/collected_cookies_gtk.cc +++ b/chrome/browser/ui/gtk/collected_cookies_gtk.cc @@ -462,7 +462,8 @@ void CollectedCookiesGtk::Observe(int type, void CollectedCookiesGtk::OnClose(GtkWidget* close_button) { if (status_changed_) { - InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(tab_contents_->web_contents()); infobar_helper->AddInfoBar( new CollectedCookiesInfoBarDelegate(infobar_helper)); } diff --git a/chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.cc b/chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.cc index 551a147..f5fdf20 100644 --- a/chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.cc +++ b/chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.cc @@ -8,6 +8,7 @@ #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/browser/certificate_viewer.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" @@ -258,9 +259,11 @@ WebsiteSettingsPopupGtk::WebsiteSettingsPopupGtk( TabSpecificContentSettings* content_settings = TabSpecificContentSettings::FromWebContents(tab_contents->web_contents()); + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(tab_contents->web_contents()); presenter_.reset(new WebsiteSettings(this, profile, content_settings, - tab_contents->infobar_tab_helper(), + infobar_tab_helper, url, ssl, content::CertStore::GetInstance())); } diff --git a/chrome/browser/ui/hung_plugin_tab_helper.cc b/chrome/browser/ui/hung_plugin_tab_helper.cc index 8dd7257..c8ea7c5 100644 --- a/chrome/browser/ui/hung_plugin_tab_helper.cc +++ b/chrome/browser/ui/hung_plugin_tab_helper.cc @@ -217,7 +217,8 @@ void HungPluginTabHelper::PluginCrashed(const FilePath& plugin_path) { // TODO(brettw) ideally this would take the child process ID. When we do this // for NaCl plugins, we'll want to know exactly which process it was since // the path won't be useful. - InfoBarTabHelper* infobar_helper = GetInfoBarHelper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents()); if (!infobar_helper) return; @@ -237,7 +238,8 @@ void HungPluginTabHelper::PluginCrashed(const FilePath& plugin_path) { void HungPluginTabHelper::PluginHungStatusChanged(int plugin_child_id, const FilePath& plugin_path, bool is_hung) { - InfoBarTabHelper* infobar_helper = GetInfoBarHelper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents()); if (!infobar_helper) return; @@ -356,7 +358,8 @@ void HungPluginTabHelper::OnReshowTimer(int child_id) { } void HungPluginTabHelper::ShowBar(int child_id, PluginState* state) { - InfoBarTabHelper* infobar_helper = GetInfoBarHelper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents()); if (!infobar_helper) return; @@ -367,7 +370,8 @@ void HungPluginTabHelper::ShowBar(int child_id, PluginState* state) { } void HungPluginTabHelper::CloseBar(PluginState* state) { - InfoBarTabHelper* infobar_helper = GetInfoBarHelper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents()); if (!infobar_helper) return; @@ -376,10 +380,3 @@ void HungPluginTabHelper::CloseBar(PluginState* state) { state->info_bar = NULL; } } - -InfoBarTabHelper* HungPluginTabHelper::GetInfoBarHelper() { - TabContents* tab_contents = TabContents::FromWebContents(web_contents()); - if (!tab_contents) - return NULL; - return tab_contents->infobar_tab_helper(); -} diff --git a/chrome/browser/ui/hung_plugin_tab_helper.h b/chrome/browser/ui/hung_plugin_tab_helper.h index 9c7a0ee..91e546b 100644 --- a/chrome/browser/ui/hung_plugin_tab_helper.h +++ b/chrome/browser/ui/hung_plugin_tab_helper.h @@ -100,9 +100,6 @@ class HungPluginTabHelper // be called even if the bar is not opened, in which case it will do nothing. void CloseBar(PluginState* state); - // Possibly returns null. - InfoBarTabHelper* GetInfoBarHelper(); - content::NotificationRegistrar registrar_; // All currently hung plugins. diff --git a/chrome/browser/ui/startup/autolaunch_prompt_win.cc b/chrome/browser/ui/startup/autolaunch_prompt_win.cc index c39750d..a03cab8 100644 --- a/chrome/browser/ui/startup/autolaunch_prompt_win.cc +++ b/chrome/browser/ui/startup/autolaunch_prompt_win.cc @@ -16,7 +16,6 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_tabstrip.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" @@ -154,16 +153,17 @@ void CheckAutoLaunchCallback(Profile* profile) { // We must not use GetLastActive here because this is at Chrome startup and // no window might have been made active yet. We'll settle for any window. Browser* browser = browser::FindAnyBrowser(profile, true); - TabContents* tab = chrome::GetActiveTabContents(browser); + content::WebContents* web_contents = chrome::GetActiveWebContents(browser); // Don't show the info-bar if there are already info-bars showing. - InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents); if (infobar_helper->GetInfoBarCount() > 0) return; - infobar_helper->AddInfoBar( - new AutolaunchInfoBarDelegate(infobar_helper, - tab->profile()->GetPrefs(), tab->profile())); + profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); + infobar_helper->AddInfoBar(new AutolaunchInfoBarDelegate( + infobar_helper, profile->GetPrefs(), profile)); } } // namespace diff --git a/chrome/browser/ui/startup/bad_flags_prompt.cc b/chrome/browser/ui/startup/bad_flags_prompt.cc index 8057a60..3eca4a2 100644 --- a/chrome/browser/ui/startup/bad_flags_prompt.cc +++ b/chrome/browser/ui/startup/bad_flags_prompt.cc @@ -10,7 +10,6 @@ #include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_tabstrip.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/common/chrome_switches.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -41,12 +40,14 @@ void ShowBadFlagsPrompt(Browser* browser) { } if (bad_flag) { - TabContents* tab = chrome::GetActiveTabContents(browser); - if (!tab) + content::WebContents* web_contents = chrome::GetActiveWebContents(browser); + if (!web_contents) return; - tab->infobar_tab_helper()->AddInfoBar( + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(web_contents); + infobar_tab_helper->AddInfoBar( new SimpleAlertInfoBarDelegate( - tab->infobar_tab_helper(), NULL, + infobar_tab_helper, NULL, l10n_util::GetStringFUTF16( IDS_BAD_FLAGS_WARNING_MESSAGE, UTF8ToUTF16(std::string("--") + bad_flag)), diff --git a/chrome/browser/ui/startup/default_browser_prompt.cc b/chrome/browser/ui/startup/default_browser_prompt.cc index 6b92167..a25e211 100644 --- a/chrome/browser/ui/startup/default_browser_prompt.cc +++ b/chrome/browser/ui/startup/default_browser_prompt.cc @@ -17,7 +17,6 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_tabstrip.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/common/pref_names.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_details.h" @@ -216,20 +215,23 @@ void NotifyNotDefaultBrowserCallback() { // In ChromeBot tests, there might be a race. This line appears to get // called during shutdown and |tab| can be NULL. - TabContents* tab = chrome::GetActiveTabContents(browser); - if (!tab) + content::WebContents* web_contents = chrome::GetActiveWebContents(browser); + if (!web_contents) return; // Don't show the info-bar if there are already info-bars showing. - InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents); if (infobar_helper->GetInfoBarCount() > 0) return; bool interactive_flow = ShellIntegration::CanSetAsDefaultBrowser() == ShellIntegration::SET_DEFAULT_INTERACTIVE; + Profile* profile = + Profile::FromBrowserContext(web_contents->GetBrowserContext()); infobar_helper->AddInfoBar( new DefaultBrowserInfoBarDelegate(infobar_helper, - tab->profile()->GetPrefs(), + profile->GetPrefs(), interactive_flow)); } diff --git a/chrome/browser/ui/startup/obsolete_os_prompt_gtk.cc b/chrome/browser/ui/startup/obsolete_os_prompt_gtk.cc index d05ccca..4bb6f4e 100644 --- a/chrome/browser/ui/startup/obsolete_os_prompt_gtk.cc +++ b/chrome/browser/ui/startup/obsolete_os_prompt_gtk.cc @@ -10,7 +10,6 @@ #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/startup/obsolete_os_info_bar.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -31,13 +30,14 @@ void ShowObsoleteOSPrompt(Browser* browser) { // Link to an article in the help center on minimum system requirements. const char* kLearnMoreURL = "http://www.google.com/support/chrome/bin/answer.py?answer=95411"; - TabContents* tab = chrome::GetActiveTabContents(browser); - if (!tab) + content::WebContents* web_contents = chrome::GetActiveWebContents(browser); + if (!web_contents) return; - tab->infobar_tab_helper()->AddInfoBar( - new ObsoleteOSInfoBar(tab->infobar_tab_helper(), - message, - GURL(kLearnMoreURL))); + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(web_contents); + infobar_tab_helper->AddInfoBar(new ObsoleteOSInfoBar(infobar_tab_helper, + message, + GURL(kLearnMoreURL))); } } diff --git a/chrome/browser/ui/startup/session_crashed_prompt.cc b/chrome/browser/ui/startup/session_crashed_prompt.cc index ef6b95a..c28be5b 100644 --- a/chrome/browser/ui/startup/session_crashed_prompt.cc +++ b/chrome/browser/ui/startup/session_crashed_prompt.cc @@ -144,11 +144,13 @@ void ShowSessionCrashedPrompt(Browser* browser) { return; // Don't show the info-bar if there are already info-bars showing. - if (tab->infobar_tab_helper()->GetInfoBarCount() > 0) + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(tab->web_contents()); + if (infobar_tab_helper->GetInfoBarCount() > 0) return; - tab->infobar_tab_helper()->AddInfoBar( - new SessionCrashedInfoBarDelegate(tab->infobar_tab_helper())); + infobar_tab_helper->AddInfoBar( + new SessionCrashedInfoBarDelegate(infobar_tab_helper)); } } // namespace chrome diff --git a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc index bc83d32..86be442 100644 --- a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc +++ b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc @@ -651,9 +651,10 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) { new_browser = FindOneOtherBrowserForProfile(profile_home, NULL); ASSERT_TRUE(new_browser); ASSERT_EQ(1, new_browser->tab_count()); + content::WebContents* web_contents = chrome::GetWebContentsAt(new_browser, 0); EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), - chrome::GetWebContentsAt(new_browser, 0)->GetURL()); - EXPECT_EQ(1U, chrome::GetTabContentsAt(new_browser, 0)->infobar_tab_helper()-> + web_contents->GetURL()); + EXPECT_EQ(1U, InfoBarTabHelper::FromWebContents(web_contents)-> GetInfoBarCount()); // The profile which normally opens last open pages displays the new tab page. @@ -661,9 +662,10 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) { new_browser = FindOneOtherBrowserForProfile(profile_last, NULL); ASSERT_TRUE(new_browser); ASSERT_EQ(1, new_browser->tab_count()); + web_contents = chrome::GetWebContentsAt(new_browser, 0); EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), - chrome::GetWebContentsAt(new_browser, 0)->GetURL()); - EXPECT_EQ(1U, chrome::GetTabContentsAt(new_browser, 0)->infobar_tab_helper()-> + web_contents->GetURL()); + EXPECT_EQ(1U, InfoBarTabHelper::FromWebContents(web_contents)-> GetInfoBarCount()); // The profile which normally opens URLs displays the new tab page. @@ -671,9 +673,10 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) { new_browser = FindOneOtherBrowserForProfile(profile_urls, NULL); ASSERT_TRUE(new_browser); ASSERT_EQ(1, new_browser->tab_count()); + web_contents = chrome::GetWebContentsAt(new_browser, 0); EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), - chrome::GetWebContentsAt(new_browser, 0)->GetURL()); - EXPECT_EQ(1U, chrome::GetTabContentsAt(new_browser, 0)->infobar_tab_helper()-> + web_contents->GetURL()); + EXPECT_EQ(1U, InfoBarTabHelper::FromWebContents(web_contents)-> GetInfoBarCount()); } #endif // !OS_CHROMEOS diff --git a/chrome/browser/ui/sync/one_click_signin_helper.cc b/chrome/browser/ui/sync/one_click_signin_helper.cc index 50a2689..eab09e0 100644 --- a/chrome/browser/ui/sync/one_click_signin_helper.cc +++ b/chrome/browser/ui/sync/one_click_signin_helper.cc @@ -416,10 +416,11 @@ void OneClickSigninHelper::DidStopLoading( if (email_.empty() || password_.empty()) return; - TabContents* tab_contents = TabContents::FromWebContents(web_contents()); + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(web_contents()); - tab_contents->infobar_tab_helper()->AddInfoBar( - new OneClickInfoBarDelegateImpl(tab_contents->infobar_tab_helper(), + infobar_tab_helper->AddInfoBar( + new OneClickInfoBarDelegateImpl(infobar_tab_helper, session_index_, email_, password_)); email_.clear(); diff --git a/chrome/browser/ui/tab_contents/tab_contents.cc b/chrome/browser/ui/tab_contents/tab_contents.cc index e6c0a53..44142a7 100644 --- a/chrome/browser/ui/tab_contents/tab_contents.cc +++ b/chrome/browser/ui/tab_contents/tab_contents.cc @@ -138,7 +138,7 @@ TabContents::TabContents(WebContents* contents) FindTabHelper::CreateForWebContents(contents); HistoryTabHelper::CreateForWebContents(contents); HungPluginTabHelper::CreateForWebContents(contents); - infobar_tab_helper_.reset(new InfoBarTabHelper(contents)); + InfoBarTabHelper::CreateForWebContents(contents); MetroPinTabHelper::CreateForWebContents(contents); NavigationMetricsRecorder::CreateForWebContents(contents); PasswordManagerDelegateImpl::CreateForWebContents(contents); @@ -198,10 +198,6 @@ TabContents::~TabContents() { chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED, content::Source<TabContents>(this), content::NotificationService::NoDetails()); - - // Need to tear down infobars before the WebContents goes away. - // TODO(avi): Can we get this handled by the tab helper itself? - infobar_tab_helper_.reset(); } TabContents* TabContents::Clone() { diff --git a/chrome/browser/ui/tab_contents/tab_contents.h b/chrome/browser/ui/tab_contents/tab_contents.h index ba1bb1e..2f65da1 100644 --- a/chrome/browser/ui/tab_contents/tab_contents.h +++ b/chrome/browser/ui/tab_contents/tab_contents.h @@ -20,9 +20,7 @@ class ChromeWebContentsHandler; class ConstrainedWebDialogDelegateBase; class ExtensionTabUtil; class ExternalTabContainerWin; -class GeolocationPermissionContextTests; class InfoBarControllerContentsCreator; -class InfoBarTabHelper; class InstantLoader; class OffscreenTabContentsCreator; class PanelHost; @@ -87,7 +85,6 @@ class TabContents : public content::WebContentsObserver { friend class extensions::WebAuthFlow; friend class ExtensionTabUtil; friend class ExternalTabContainerWin; - friend class GeolocationPermissionContextTests; friend class InfoBarControllerContentsCreator; friend class InstantLoader; friend class OffscreenTabContentsCreator; @@ -133,10 +130,6 @@ class TabContents : public content::WebContentsObserver { // True if this TabContents is being torn down. bool in_destructor() const { return in_destructor_; } - // Tab Helpers --------------------------------------------------------------- - - InfoBarTabHelper* infobar_tab_helper() { return infobar_tab_helper_.get(); } - // Overrides ----------------------------------------------------------------- // content::WebContentsObserver overrides: @@ -153,12 +146,6 @@ class TabContents : public content::WebContentsObserver { // heap-allocated pointer is owned by the caller. TabContents* Clone(); - // Tab Helpers --------------------------------------------------------------- - // (These provide API for callers and have a getter function listed in the - // "Tab Helpers" section in the member functions area, above.) - - scoped_ptr<InfoBarTabHelper> infobar_tab_helper_; - // WebContents (MUST BE LAST) ------------------------------------------------ // If true, we're running the destructor. diff --git a/chrome/browser/ui/views/collected_cookies_views.cc b/chrome/browser/ui/views/collected_cookies_views.cc index 76d86ae..b0a025d 100644 --- a/chrome/browser/ui/views/collected_cookies_views.cc +++ b/chrome/browser/ui/views/collected_cookies_views.cc @@ -56,7 +56,7 @@ namespace chrome { // Declared in browser_dialogs.h so others don't have to depend on our header. void ShowCollectedCookiesDialog(TabContents* tab_contents) { // Deletes itself on close. - new CollectedCookiesViews(tab_contents); + new CollectedCookiesViews(tab_contents->web_contents()); } } // namespace chrome @@ -183,8 +183,8 @@ class InfobarView : public views::View { /////////////////////////////////////////////////////////////////////////////// // CollectedCookiesViews, public: -CollectedCookiesViews::CollectedCookiesViews(TabContents* tab_contents) - : tab_contents_(tab_contents), +CollectedCookiesViews::CollectedCookiesViews(content::WebContents* web_contents) + : web_contents_(web_contents), allowed_label_(NULL), blocked_label_(NULL), allowed_cookies_tree_(NULL), @@ -196,12 +196,10 @@ CollectedCookiesViews::CollectedCookiesViews(TabContents* tab_contents) infobar_(NULL), status_changed_(false) { TabSpecificContentSettings* content_settings = - TabSpecificContentSettings::FromWebContents(tab_contents->web_contents()); + TabSpecificContentSettings::FromWebContents(web_contents); registrar_.Add(this, chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, content::Source<TabSpecificContentSettings>(content_settings)); - window_ = new ConstrainedWindowViews(tab_contents->web_contents(), - this, - false); + window_ = new ConstrainedWindowViews(web_contents, this, false); } /////////////////////////////////////////////////////////////////////////////// @@ -226,7 +224,8 @@ void CollectedCookiesViews::DeleteDelegate() { bool CollectedCookiesViews::Cancel() { if (status_changed_) { - InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + InfoBarTabHelper::FromWebContents(web_contents_); infobar_helper->AddInfoBar( new CollectedCookiesInfoBarDelegate(infobar_helper)); } @@ -338,8 +337,7 @@ void CollectedCookiesViews::Init() { views::View* CollectedCookiesViews::CreateAllowedPane() { TabSpecificContentSettings* content_settings = - TabSpecificContentSettings::FromWebContents( - tab_contents_->web_contents()); + TabSpecificContentSettings::FromWebContents(web_contents_); // Create the controls that go into the pane. allowed_label_ = new views::Label(l10n_util::GetStringUTF16( @@ -391,10 +389,11 @@ views::View* CollectedCookiesViews::CreateAllowedPane() { views::View* CollectedCookiesViews::CreateBlockedPane() { TabSpecificContentSettings* content_settings = - TabSpecificContentSettings::FromWebContents( - tab_contents_->web_contents()); + TabSpecificContentSettings::FromWebContents(web_contents_); - PrefService* prefs = tab_contents_->profile()->GetPrefs(); + Profile* profile = + Profile::FromBrowserContext(web_contents_->GetBrowserContext()); + PrefService* prefs = profile->GetPrefs(); // Create the controls that go into the pane. blocked_label_ = new views::Label( @@ -510,7 +509,8 @@ void CollectedCookiesViews::AddContentException(views::TreeView* tree_view, ContentSetting setting) { CookieTreeHostNode* host_node = static_cast<CookieTreeHostNode*>(tree_view->GetSelectedNode()); - Profile* profile = tab_contents_->profile(); + Profile* profile = + Profile::FromBrowserContext(web_contents_->GetBrowserContext()); host_node->CreateContentException( CookieSettings::Factory::GetForProfile(profile), setting); infobar_->UpdateVisibility(true, setting, host_node->GetTitle()); diff --git a/chrome/browser/ui/views/collected_cookies_views.h b/chrome/browser/ui/views/collected_cookies_views.h index bcd5729a..97d8ec1 100644 --- a/chrome/browser/ui/views/collected_cookies_views.h +++ b/chrome/browser/ui/views/collected_cookies_views.h @@ -17,7 +17,10 @@ class ConstrainedWindow; class CookieInfoView; class CookiesTreeModel; class InfobarView; -class TabContents; + +namespace content { +class WebContents; +} namespace views { class Label; @@ -29,7 +32,7 @@ class TreeView; // // CollectedCookiesViews is a dialog that displays the allowed and blocked // cookies of the current tab contents. To display the dialog, invoke -// ShowCollectedCookiesDialog() on the delegate of the TabContents's +// ShowCollectedCookiesDialog() on the delegate of the WebContents's // content settings tab helper. class CollectedCookiesViews : public views::DialogDelegateView, public content::NotificationObserver, @@ -38,7 +41,7 @@ class CollectedCookiesViews : public views::DialogDelegateView, public views::TreeViewController { public: // Use BrowserWindow::ShowCollectedCookiesDialog to show. - explicit CollectedCookiesViews(TabContents* tab_contents); + explicit CollectedCookiesViews(content::WebContents* web_contents); // views::DialogDelegate: virtual string16 GetWindowTitle() const OVERRIDE; @@ -87,8 +90,8 @@ class CollectedCookiesViews : public views::DialogDelegateView, ConstrainedWindow* window_; - // The tab contents. - TabContents* tab_contents_; + // The web contents. + content::WebContents* web_contents_; // Assorted views. views::Label* allowed_label_; diff --git a/chrome/browser/ui/views/external_tab_container_win.cc b/chrome/browser/ui/views/external_tab_container_win.cc index af83daf..a75bc5a 100644 --- a/chrome/browser/ui/views/external_tab_container_win.cc +++ b/chrome/browser/ui/views/external_tab_container_win.cc @@ -199,8 +199,11 @@ bool ExternalTabContainerWin::Init(Profile* profile, tab_contents_.reset(TabContents::Factory::CreateTabContents(new_contents)); } - if (!infobars_enabled) - tab_contents_->infobar_tab_helper()->set_infobars_enabled(false); + if (!infobars_enabled) { + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(tab_contents_->web_contents()); + infobar_tab_helper->set_infobars_enabled(false); + } tab_contents_->web_contents()->SetDelegate(this); @@ -1198,7 +1201,9 @@ void ExternalTabContainerWin::SetupExternalTabView() { external_tab_view_ = new views::View(); InfoBarContainerView* info_bar_container = new InfoBarContainerView(this); - info_bar_container->ChangeTabContents(tab_contents_->infobar_tab_helper()); + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(tab_contents_->web_contents()); + info_bar_container->ChangeTabContents(infobar_tab_helper); views::GridLayout* layout = new views::GridLayout(external_tab_view_); // Give this column an identifier of 0. diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index ab803ea..dc478ac 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -2512,11 +2512,13 @@ void BrowserView::ProcessTabSelected(TabContents* new_contents) { // reparent the |contents_container_|. if (change_tab_contents) contents_container_->SetWebContents(NULL); + InfoBarTabHelper* new_infobar_tab_helper = + InfoBarTabHelper::FromWebContents(new_contents->web_contents()); // Hide infobars when showing Instant Extended suggestions. infobar_container_->ChangeTabContents( (chrome::search::IsInstantExtendedAPIEnabled(browser()->profile()) && browser()->search_model()->mode().is_search_suggestions()) ? - NULL : new_contents->infobar_tab_helper()); + NULL : new_infobar_tab_helper); if (bookmark_bar_view_.get()) { bookmark_bar_view_->SetBookmarkBarState( browser_->bookmark_bar_state(), @@ -2568,7 +2570,8 @@ void BrowserView::ModeChanged(const chrome::search::Mode& old_mode, bool hide_infobars = new_mode.is_search_suggestions() || (old_mode.is_search_suggestions() && new_mode.is_default()); infobar_container_->ChangeTabContents( - hide_infobars ? NULL : GetActiveTabContents()->infobar_tab_helper()); + hide_infobars + ? NULL : InfoBarTabHelper::FromWebContents(GetActiveWebContents())); } void BrowserView::CreateLauncherIcon() { diff --git a/chrome/browser/ui/views/toolbar_view.cc b/chrome/browser/ui/views/toolbar_view.cc index dc4a2b3..2e627b7 100644 --- a/chrome/browser/ui/views/toolbar_view.cc +++ b/chrome/browser/ui/views/toolbar_view.cc @@ -818,7 +818,9 @@ void ToolbarView::OnPaint(gfx::Canvas* canvas) { TabContents* tab_contents = GetTabContents(); if (tab_contents) { - int num_infobars = tab_contents->infobar_tab_helper()->GetInfoBarCount(); + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(tab_contents->web_contents()); + int num_infobars = infobar_tab_helper->GetInfoBarCount(); const chrome::search::Mode& mode(browser_->search_model()->mode()); if ((mode.is_ntp() || mode.is_search_results()) && num_infobars > 0) { canvas->FillRect(gfx::Rect(0, height() - 1, width(), 1), diff --git a/chrome/browser/ui/views/website_settings/website_settings_popup_view.cc b/chrome/browser/ui/views/website_settings/website_settings_popup_view.cc index ef5ca33..868cc39 100644 --- a/chrome/browser/ui/views/website_settings/website_settings_popup_view.cc +++ b/chrome/browser/ui/views/website_settings/website_settings_popup_view.cc @@ -7,6 +7,7 @@ #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/browser/certificate_viewer.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/tab_contents/tab_contents.h" @@ -340,9 +341,11 @@ WebsiteSettingsPopupView::WebsiteSettingsPopupView( TabSpecificContentSettings* content_settings = TabSpecificContentSettings::FromWebContents(tab_contents->web_contents()); + InfoBarTabHelper* infobar_tab_helper = + InfoBarTabHelper::FromWebContents(tab_contents->web_contents()); presenter_.reset(new WebsiteSettings(this, profile, content_settings, - tab_contents->infobar_tab_helper(), + infobar_tab_helper, url, ssl, content::CertStore::GetInstance())); @@ -372,7 +375,7 @@ void WebsiteSettingsPopupView::LinkClicked(views::Link* source, // Count how often the Collected Cookies dialog is opened. content::RecordAction( content::UserMetricsAction("WebsiteSettings_CookiesDialogOpened")); - new CollectedCookiesViews(tab_contents_); + new CollectedCookiesViews(tab_contents_->web_contents()); } else if (source == certificate_dialog_link_) { gfx::NativeWindow parent = anchor_view() ? anchor_view()->GetWidget()->GetNativeWindow() : NULL; diff --git a/chrome/browser/ui/website_settings/website_settings_unittest.cc b/chrome/browser/ui/website_settings/website_settings_unittest.cc index e51cb7f..b1b6977 100644 --- a/chrome/browser/ui/website_settings/website_settings_unittest.cc +++ b/chrome/browser/ui/website_settings/website_settings_unittest.cc @@ -75,7 +75,6 @@ class WebsiteSettingsTest : public ChromeRenderViewHostTestHarness { mock_ui_(NULL), cert_id_(0), browser_thread_(content::BrowserThread::UI, &message_loop_), - infobar_tab_helper_(NULL), url_("http://www.example.com") { } @@ -98,7 +97,7 @@ class WebsiteSettingsTest : public ChromeRenderViewHostTestHarness { expiration_date); TabSpecificContentSettings::CreateForWebContents(contents()); - infobar_tab_helper_.reset(new InfoBarTabHelper(contents())); + InfoBarTabHelper::CreateForWebContents(contents()); // Setup the mock cert store. EXPECT_CALL(cert_store_, RetrieveCert(cert_id_, _) ) @@ -132,13 +131,15 @@ class WebsiteSettingsTest : public ChromeRenderViewHostTestHarness { TabSpecificContentSettings* tab_specific_content_settings() { return TabSpecificContentSettings::FromWebContents(contents()); } - InfoBarTabHelper* infobar_tab_helper() { return infobar_tab_helper_.get(); } + InfoBarTabHelper* infobar_tab_helper() { + return InfoBarTabHelper::FromWebContents(contents()); + } WebsiteSettings* website_settings() { if (!website_settings_.get()) { website_settings_.reset(new WebsiteSettings( mock_ui(), profile(), tab_specific_content_settings(), - infobar_tab_helper_.get(), url(), ssl(), cert_store())); + infobar_tab_helper(), url(), ssl(), cert_store())); } return website_settings_.get(); } @@ -151,7 +152,6 @@ class WebsiteSettingsTest : public ChromeRenderViewHostTestHarness { int cert_id_; scoped_refptr<net::X509Certificate> cert_; content::TestBrowserThread browser_thread_; - scoped_ptr<InfoBarTabHelper> infobar_tab_helper_; MockCertStore cert_store_; GURL url_; }; diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc index 4626c81..e9e1f3c 100644 --- a/chrome/test/base/ui_test_utils.cc +++ b/chrome/test/base/ui_test_utils.cc @@ -26,7 +26,6 @@ #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/history/history_service_factory.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search_engines/template_url_service.h" @@ -392,12 +391,6 @@ int FindInPage(TabContents* tab_contents, const string16& search_string, return observer.number_of_matches(); } -void CloseAllInfoBars(TabContents* tab) { - InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); - while (infobar_helper->GetInfoBarCount() > 0) - infobar_helper->RemoveInfoBar(infobar_helper->GetInfoBarDelegateAt(0)); -} - void RegisterAndWait(content::NotificationObserver* observer, int type, const content::NotificationSource& source) { diff --git a/chrome/test/base/ui_test_utils.h b/chrome/test/base/ui_test_utils.h index b158e4c..a7797f9 100644 --- a/chrome/test/base/ui_test_utils.h +++ b/chrome/test/base/ui_test_utils.h @@ -145,10 +145,6 @@ int FindInPage(TabContents* tab, int* ordinal, gfx::Rect* selection_rect); -// Closes all infobars |tab| has open, if any. Tests that depend on there being -// no InfoBar open when the test starts may need to use this. -void CloseAllInfoBars(TabContents* tab); - // Returns true if the View is focused. bool IsViewFocused(const Browser* browser, ViewID vid); |