diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-20 16:34:13 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-20 16:34:13 +0000 |
commit | d715fb8034a11d163481f93d9473d968f9f2203e (patch) | |
tree | 0c162fd3de1c8b99ed887a326629cda105dfe685 | |
parent | 97826c1ca1812f98ff4a0a03be27b932e867b22c (diff) | |
download | chromium_src-d715fb8034a11d163481f93d9473d968f9f2203e.zip chromium_src-d715fb8034a11d163481f93d9473d968f9f2203e.tar.gz chromium_src-d715fb8034a11d163481f93d9473d968f9f2203e.tar.bz2 |
Introduce InfoBarTabService API.
The new interface extracts the API bits from InfoBarTabHelper. This
change switches files under chrome/browser/autofill and
chrome/browser/api to use the API and remove the temporarily-allowed
dependency on InfoBarTabHelper.
TBRing other owners as the changes are just to match the updated API and include paths.
TBR=ben@chromium.org
BUG=140037
Review URL: https://chromiumcodereview.appspot.com/10830353
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152338 0039d316-1c4b-4281-b951-d872f2087c98
93 files changed, 391 insertions, 297 deletions
diff --git a/chrome/browser/accessibility/accessibility_extension_api.cc b/chrome/browser/accessibility/accessibility_extension_api.cc index 35cf188..623f121 100644 --- a/chrome/browser/accessibility/accessibility_extension_api.cc +++ b/chrome/browser/accessibility/accessibility_extension_api.cc @@ -210,7 +210,7 @@ bool GetAlertsForTabFunction::RunImpl() { ListValue* alerts_value = new ListValue; InfoBarTabHelper* infobar_helper = contents->infobar_tab_helper(); - for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { + 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); ConfirmInfoBarDelegate* confirm_infobar_delegate = diff --git a/chrome/browser/alternate_nav_url_fetcher.cc b/chrome/browser/alternate_nav_url_fetcher.cc index 9ad01af..e45e8c6 100644 --- a/chrome/browser/alternate_nav_url_fetcher.cc +++ b/chrome/browser/alternate_nav_url_fetcher.cc @@ -89,7 +89,7 @@ bool AlternateNavInfoBarDelegate::LinkClicked( // the future. content::PAGE_TRANSITION_TYPED, false); - owner()->web_contents()->OpenURL(params); + owner()->GetWebContents()->OpenURL(params); // We should always close, even if the navigation did not occur within this // WebContents. diff --git a/chrome/browser/api/infobars/DEPS b/chrome/browser/api/infobars/DEPS deleted file mode 100644 index 25e95cc..0000000 --- a/chrome/browser/api/infobars/DEPS +++ /dev/null @@ -1,6 +0,0 @@ -# TODO(joi): Reduce this list to zero exceptions. -specific_include_rules = { - "infobar_delegate\.cc": [ - "!chrome/browser/infobars/infobar_tab_helper.h", - ] -} diff --git a/chrome/browser/api/infobars/confirm_infobar_delegate.cc b/chrome/browser/api/infobars/confirm_infobar_delegate.cc index 2944466..963687d 100644 --- a/chrome/browser/api/infobars/confirm_infobar_delegate.cc +++ b/chrome/browser/api/infobars/confirm_infobar_delegate.cc @@ -41,8 +41,9 @@ bool ConfirmInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { return true; } -ConfirmInfoBarDelegate::ConfirmInfoBarDelegate(InfoBarTabHelper* infobar_helper) - : InfoBarDelegate(infobar_helper) { +ConfirmInfoBarDelegate::ConfirmInfoBarDelegate( + InfoBarTabService* infobar_service) + : InfoBarDelegate(infobar_service) { } ConfirmInfoBarDelegate::~ConfirmInfoBarDelegate() { diff --git a/chrome/browser/api/infobars/confirm_infobar_delegate.h b/chrome/browser/api/infobars/confirm_infobar_delegate.h index e793bd7..ec71000 100644 --- a/chrome/browser/api/infobars/confirm_infobar_delegate.h +++ b/chrome/browser/api/infobars/confirm_infobar_delegate.h @@ -58,7 +58,7 @@ class ConfirmInfoBarDelegate : public InfoBarDelegate { virtual bool LinkClicked(WindowOpenDisposition disposition); protected: - explicit ConfirmInfoBarDelegate(InfoBarTabHelper* infobar_helper); + explicit ConfirmInfoBarDelegate(InfoBarTabService* infobar_service); virtual ~ConfirmInfoBarDelegate(); virtual bool ShouldExpireInternal( @@ -66,7 +66,7 @@ class ConfirmInfoBarDelegate : public InfoBarDelegate { private: // InfoBarDelegate: - virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) OVERRIDE; + virtual InfoBar* CreateInfoBar(InfoBarTabService* owner) OVERRIDE; virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE; virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate() OVERRIDE; diff --git a/chrome/browser/api/infobars/infobar_delegate.cc b/chrome/browser/api/infobars/infobar_delegate.cc index 69f6625..fa401ac 100644 --- a/chrome/browser/api/infobars/infobar_delegate.cc +++ b/chrome/browser/api/infobars/infobar_delegate.cc @@ -6,7 +6,7 @@ #include "base/logging.h" #include "build/build_config.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" +#include "chrome/browser/api/infobars/infobar_tab_service.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_details.h" #include "content/public/browser/navigation_entry.h" @@ -90,17 +90,17 @@ TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() { return NULL; } -InfoBarDelegate::InfoBarDelegate(InfoBarTabHelper* infobar_helper) +InfoBarDelegate::InfoBarDelegate(InfoBarTabService* infobar_service) : contents_unique_id_(0), - owner_(infobar_helper) { - if (infobar_helper) - StoreActiveEntryUniqueID(infobar_helper); + owner_(infobar_service) { + if (infobar_service) + StoreActiveEntryUniqueID(infobar_service); } void InfoBarDelegate::StoreActiveEntryUniqueID( - InfoBarTabHelper* infobar_helper) { + InfoBarTabService* infobar_service) { NavigationEntry* active_entry = - infobar_helper->web_contents()->GetController().GetActiveEntry(); + infobar_service->GetWebContents()->GetController().GetActiveEntry(); contents_unique_id_ = active_entry ? active_entry->GetUniqueID() : 0; } diff --git a/chrome/browser/api/infobars/infobar_delegate.h b/chrome/browser/api/infobars/infobar_delegate.h index 26b2438..cc092a0 100644 --- a/chrome/browser/api/infobars/infobar_delegate.h +++ b/chrome/browser/api/infobars/infobar_delegate.h @@ -13,7 +13,7 @@ class AutoLoginInfoBarDelegate; class ConfirmInfoBarDelegate; class ExtensionInfoBarDelegate; class InfoBar; -class InfoBarTabHelper; +class InfoBarTabService; class InsecureContentInfoBarDelegate; class LinkInfoBarDelegate; class MediaStreamInfoBarDelegate; @@ -58,19 +58,18 @@ class InfoBarDelegate { // Called to create the InfoBar. Implementation of this method is // platform-specific. - virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) = 0; - - // Called by the InfoBarTabHelper when it removes us. - void clear_owner() { owner_ = NULL; } + virtual InfoBar* CreateInfoBar(InfoBarTabService* owner) = 0; // TODO(pkasting): Move to InfoBar once InfoBars own their delegates. - InfoBarTabHelper* owner() { return owner_; } + InfoBarTabService* owner() { return owner_; } + + void clear_owner() { owner_ = NULL; } // Returns true if the supplied |delegate| is equal to this one. Equality is // left to the implementation to define. This function is called by the - // InfoBarTabHelper when determining whether or not a delegate should be + // InfoBarTabService when determining whether or not a delegate should be // added because a matching one already exists. If this function returns true, - // the InfoBarTabHelper will not add the new delegate because it considers + // the InfoBarTabService will not add the new delegate because it considers // one to already be present. virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; @@ -111,12 +110,12 @@ class InfoBarDelegate { protected: // If |contents| is non-NULL, its active entry's unique ID will be stored // using StoreActiveEntryUniqueID automatically. - explicit InfoBarDelegate(InfoBarTabHelper* infobar_helper); + explicit InfoBarDelegate(InfoBarTabService* infobar_service); // Store the unique id for the active entry in the specified WebContents, to // be used later upon navigation to determine if this InfoBarDelegate should // be expired from |contents_|. - void StoreActiveEntryUniqueID(InfoBarTabHelper* infobar_helper); + void StoreActiveEntryUniqueID(InfoBarTabService* infobar_service); // Direct accessors for subclasses that need to do something special. int contents_unique_id() const { return contents_unique_id_; } @@ -138,7 +137,7 @@ class InfoBarDelegate { int contents_unique_id_; // TODO(pkasting): Remove. - InfoBarTabHelper* owner_; + InfoBarTabService* owner_; DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); }; diff --git a/chrome/browser/api/infobars/infobar_tab_service.h b/chrome/browser/api/infobars/infobar_tab_service.h new file mode 100644 index 0000000..c99cb81 --- /dev/null +++ b/chrome/browser/api/infobars/infobar_tab_service.h @@ -0,0 +1,63 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_API_INFOBARS_INFOBAR_TAB_SERVICE_H_ +#define CHROME_BROWSER_API_INFOBARS_INFOBAR_TAB_SERVICE_H_ + +namespace content { +class WebContents; +} + +class InfoBarDelegate; +class TabContents; + +// Provides access to creating, removing and enumerating info bars +// attached to a tab. +class InfoBarTabService { + public: + // Retrieves the InfoBarTabService for a given tab. + static InfoBarTabService* ForTab(TabContents* tab_contents); + + virtual ~InfoBarTabService() {} + + // Adds an InfoBar for the specified |delegate|. + // + // If infobars are disabled for this tab or the tab already has a delegate + // which returns true for InfoBarDelegate::EqualsDelegate(delegate), + // |delegate| is closed immediately without being added. + // + // Returns whether |delegate| was successfully added. + virtual bool AddInfoBar(InfoBarDelegate* delegate) = 0; + + // Removes the InfoBar for the specified |delegate|. + // + // If infobars are disabled for this tab, this will do nothing, on the + // assumption that the matching AddInfoBar() call will have already closed the + // delegate (see above). + virtual void RemoveInfoBar(InfoBarDelegate* delegate) = 0; + + // Replaces one infobar with another, without any animation in between. + // + // If infobars are disabled for this tab, |new_delegate| is closed immediately + // without being added, and nothing else happens. + // + // Returns whether |new_delegate| was successfully added. + // + // NOTE: This does not perform any EqualsDelegate() checks like AddInfoBar(). + virtual bool ReplaceInfoBar(InfoBarDelegate* old_delegate, + InfoBarDelegate* new_delegate) = 0; + + // Returns the number of infobars for this tab. + virtual size_t GetInfoBarCount() const = 0; + + // Returns the infobar at the given |index|. + // + // Warning: Does not sanity check |index|. + virtual InfoBarDelegate* GetInfoBarDelegateAt(size_t index) = 0; + + // Retrieve the WebContents for the tab this service is associated with. + virtual content::WebContents* GetWebContents() = 0; +}; + +#endif // CHROME_BROWSER_API_INFOBARS_INFOBAR_TAB_SERVICE_H_ diff --git a/chrome/browser/api/infobars/link_infobar_delegate.cc b/chrome/browser/api/infobars/link_infobar_delegate.cc index 340945c..29f78ab 100644 --- a/chrome/browser/api/infobars/link_infobar_delegate.cc +++ b/chrome/browser/api/infobars/link_infobar_delegate.cc @@ -8,8 +8,8 @@ bool LinkInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { return true; } -LinkInfoBarDelegate::LinkInfoBarDelegate(InfoBarTabHelper* infobar_helper) - : InfoBarDelegate(infobar_helper) { +LinkInfoBarDelegate::LinkInfoBarDelegate(InfoBarTabService* infobar_service) + : InfoBarDelegate(infobar_service) { } LinkInfoBarDelegate::~LinkInfoBarDelegate() { diff --git a/chrome/browser/api/infobars/link_infobar_delegate.h b/chrome/browser/api/infobars/link_infobar_delegate.h index 0856115..96a1941 100644 --- a/chrome/browser/api/infobars/link_infobar_delegate.h +++ b/chrome/browser/api/infobars/link_infobar_delegate.h @@ -31,12 +31,12 @@ class LinkInfoBarDelegate : public InfoBarDelegate { virtual bool LinkClicked(WindowOpenDisposition disposition); protected: - explicit LinkInfoBarDelegate(InfoBarTabHelper* infobar_helper); + explicit LinkInfoBarDelegate(InfoBarTabService* infobar_service); virtual ~LinkInfoBarDelegate(); private: // InfoBarDelegate: - virtual InfoBar* CreateInfoBar(InfoBarTabHelper* infobar_helper) OVERRIDE; + virtual InfoBar* CreateInfoBar(InfoBarTabService* infobar_service) OVERRIDE; virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate() OVERRIDE; DISALLOW_COPY_AND_ASSIGN(LinkInfoBarDelegate); diff --git a/chrome/browser/api/infobars/simple_alert_infobar_delegate.cc b/chrome/browser/api/infobars/simple_alert_infobar_delegate.cc index 69c18ba..c5208f5 100644 --- a/chrome/browser/api/infobars/simple_alert_infobar_delegate.cc +++ b/chrome/browser/api/infobars/simple_alert_infobar_delegate.cc @@ -7,11 +7,11 @@ #include "third_party/skia/include/core/SkBitmap.h" SimpleAlertInfoBarDelegate::SimpleAlertInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarTabService* infobar_service, gfx::Image* icon, const string16& message, bool auto_expire) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), icon_(icon), message_(message), auto_expire_(auto_expire) { diff --git a/chrome/browser/api/infobars/simple_alert_infobar_delegate.h b/chrome/browser/api/infobars/simple_alert_infobar_delegate.h index c1f8fc3..98ce3f2 100644 --- a/chrome/browser/api/infobars/simple_alert_infobar_delegate.h +++ b/chrome/browser/api/infobars/simple_alert_infobar_delegate.h @@ -12,7 +12,7 @@ class SimpleAlertInfoBarDelegate : public ConfirmInfoBarDelegate { public: - SimpleAlertInfoBarDelegate(InfoBarTabHelper* infobar_helper, + SimpleAlertInfoBarDelegate(InfoBarTabService* infobar_service, gfx::Image* icon, // May be NULL. const string16& message, bool auto_expire); diff --git a/chrome/browser/autofill/DEPS b/chrome/browser/autofill/DEPS index 02881c6..2ea5636 100644 --- a/chrome/browser/autofill/DEPS +++ b/chrome/browser/autofill/DEPS @@ -14,7 +14,6 @@ include_rules = [ # # Do not add to the list of temporarily-allowed dependencies below, # and please do not introduce more #includes of these files. - "!chrome/browser/infobars/infobar_tab_helper.h", "!chrome/browser/password_manager/password_manager.h", "!chrome/browser/prefs/pref_change_registrar.h", "!chrome/browser/prefs/pref_member.h", diff --git a/chrome/browser/autofill/autofill_browsertest.cc b/chrome/browser/autofill/autofill_browsertest.cc index 0edb8b1..421debe 100644 --- a/chrome/browser/autofill/autofill_browsertest.cc +++ b/chrome/browser/autofill/autofill_browsertest.cc @@ -9,12 +9,12 @@ #include "base/memory/scoped_ptr.h" #include "base/string16.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/api/infobars/infobar_tab_service.h" #include "chrome/browser/autofill/autofill_common_test.h" #include "chrome/browser/autofill/autofill_profile.h" #include "chrome/browser/autofill/personal_data_manager.h" #include "chrome/browser/autofill/personal_data_manager_factory.h" #include "chrome/browser/autofill/personal_data_manager_observer.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/translate/translate_infobar_delegate.h" #include "chrome/browser/translate/translate_manager.h" @@ -678,7 +678,7 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, AutofillAfterTranslate) { render_view_host(), ChromeViewHostMsg_TranslateLanguageDetermined(0, "ja", true)); TranslateInfoBarDelegate* infobar = - chrome::GetActiveTabContents(browser())->infobar_tab_helper()-> + InfoBarTabService::ForTab(chrome::GetActiveTabContents(browser()))-> GetInfoBarDelegateAt(0)->AsTranslateInfoBarDelegate(); ASSERT_TRUE(infobar != NULL); diff --git a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc b/chrome/browser/autofill/autofill_cc_infobar_delegate.cc index cff0cae..2b58724 100644 --- a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc +++ b/chrome/browser/autofill/autofill_cc_infobar_delegate.cc @@ -5,9 +5,9 @@ #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" #include "base/logging.h" +#include "chrome/browser/api/infobars/infobar_tab_service.h" #include "chrome/browser/autofill/credit_card.h" #include "chrome/browser/autofill/personal_data_manager.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/common/url_constants.h" #include "content/public/browser/page_navigator.h" #include "content/public/browser/web_contents.h" @@ -18,11 +18,11 @@ #include "ui/base/resource/resource_bundle.h" AutofillCCInfoBarDelegate::AutofillCCInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarTabService* infobar_service, const CreditCard* credit_card, PersonalDataManager* personal_data, const AutofillMetrics* metric_logger) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), credit_card_(credit_card), personal_data_(personal_data), metric_logger_(metric_logger), @@ -89,8 +89,8 @@ string16 AutofillCCInfoBarDelegate::GetLinkText() const { } bool AutofillCCInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { - owner()->web_contents()->GetDelegate()->OpenURLFromTab( - owner()->web_contents(), + owner()->GetWebContents()->GetDelegate()->OpenURLFromTab( + owner()->GetWebContents(), content::OpenURLParams(GURL(chrome::kAutofillHelpURL), content::Referrer(), NEW_FOREGROUND_TAB, diff --git a/chrome/browser/autofill/autofill_cc_infobar_delegate.h b/chrome/browser/autofill/autofill_cc_infobar_delegate.h index aa4500f..7b0c82a 100644 --- a/chrome/browser/autofill/autofill_cc_infobar_delegate.h +++ b/chrome/browser/autofill/autofill_cc_infobar_delegate.h @@ -24,7 +24,7 @@ struct LoadCommittedDetails; // card information gathered from a form submission. class AutofillCCInfoBarDelegate : public ConfirmInfoBarDelegate { public: - AutofillCCInfoBarDelegate(InfoBarTabHelper* infobar_helper, + AutofillCCInfoBarDelegate(InfoBarTabService* infobar_service, const CreditCard* credit_card, PersonalDataManager* personal_data, const AutofillMetrics* metric_logger); diff --git a/chrome/browser/autofill/autofill_feedback_infobar_delegate.cc b/chrome/browser/autofill/autofill_feedback_infobar_delegate.cc index cfc7a60..540100a 100644 --- a/chrome/browser/autofill/autofill_feedback_infobar_delegate.cc +++ b/chrome/browser/autofill/autofill_feedback_infobar_delegate.cc @@ -5,7 +5,7 @@ #include "chrome/browser/autofill/autofill_feedback_infobar_delegate.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" +#include "chrome/browser/api/infobars/infobar_tab_service.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/chrome_pages.h" @@ -17,11 +17,11 @@ const char kCategoryTagAutofill[] = "Autofill"; AutofillFeedbackInfoBarDelegate::AutofillFeedbackInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarTabService* infobar_service, const string16& message, const string16& link_text, const std::string& feedback_message) - : LinkInfoBarDelegate(infobar_helper), + : LinkInfoBarDelegate(infobar_service), message_(message), link_text_(link_text), feedback_message_(feedback_message), @@ -45,7 +45,7 @@ string16 AutofillFeedbackInfoBarDelegate::GetLinkText() const { bool AutofillFeedbackInfoBarDelegate::LinkClicked( WindowOpenDisposition disposition) { chrome::ShowFeedbackPage( - browser::FindBrowserWithWebContents(owner()->web_contents()), + browser::FindBrowserWithWebContents(owner()->GetWebContents()), feedback_message_, std::string(kCategoryTagAutofill)); return true; diff --git a/chrome/browser/autofill/autofill_feedback_infobar_delegate.h b/chrome/browser/autofill/autofill_feedback_infobar_delegate.h index 53a0e9c..f09181f 100644 --- a/chrome/browser/autofill/autofill_feedback_infobar_delegate.h +++ b/chrome/browser/autofill/autofill_feedback_infobar_delegate.h @@ -16,7 +16,7 @@ // the Autofill developers. class AutofillFeedbackInfoBarDelegate : public LinkInfoBarDelegate { public: - AutofillFeedbackInfoBarDelegate(InfoBarTabHelper* infobar_helper, + AutofillFeedbackInfoBarDelegate(InfoBarTabService* infobar_service, const string16& message, const string16& link_text, const std::string& feedback_message); diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc index d6f62d9..d609038 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -19,6 +19,7 @@ #include "base/string_util.h" #include "base/threading/sequenced_worker_pool.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/api/infobars/infobar_tab_service.h" #include "chrome/browser/autofill/autocomplete_history_manager.h" #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" #include "chrome/browser/autofill/autofill_external_delegate.h" @@ -35,7 +36,6 @@ #include "chrome/browser/autofill/phone_number.h" #include "chrome/browser/autofill/phone_number_i18n.h" #include "chrome/browser/autofill/select_control_handler.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/password_manager/password_manager.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" @@ -844,9 +844,10 @@ void AutofillManager::ImportFormData(const FormStructure& submitted_form) { // it. scoped_ptr<const CreditCard> scoped_credit_card(imported_credit_card); if (imported_credit_card && web_contents()) { - InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); - infobar_helper->AddInfoBar( - new AutofillCCInfoBarDelegate(infobar_helper, + InfoBarTabService* infobar_service = + InfoBarTabService::ForTab(tab_contents_); + infobar_service->AddInfoBar( + new AutofillCCInfoBarDelegate(infobar_service, scoped_credit_card.release(), personal_data_, metric_logger_.get())); diff --git a/chrome/browser/autofill/autofill_metrics_unittest.cc b/chrome/browser/autofill/autofill_metrics_unittest.cc index ce9c530..1037c68 100644 --- a/chrome/browser/autofill/autofill_metrics_unittest.cc +++ b/chrome/browser/autofill/autofill_metrics_unittest.cc @@ -8,6 +8,7 @@ #include "base/string16.h" #include "base/time.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/api/infobars/infobar_tab_service.h" #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" #include "chrome/browser/autofill/autofill_common_test.h" #include "chrome/browser/autofill/autofill_manager.h" @@ -314,10 +315,11 @@ AutofillCCInfoBarDelegate* AutofillMetricsTest::CreateDelegate( CreditCard* credit_card = new CreditCard(); if (created_card) *created_card = credit_card; - return new AutofillCCInfoBarDelegate(tab_contents()->infobar_tab_helper(), - credit_card, - &personal_data_, - metric_logger); + return new AutofillCCInfoBarDelegate( + InfoBarTabService::ForTab(tab_contents()), + credit_card, + &personal_data_, + metric_logger); } // Test that we log quality metrics appropriately. diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index 3f7aa86..71ca9de 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -1387,7 +1387,7 @@ void InfoBarCountObserver::Observe( } void InfoBarCountObserver::CheckCount() { - if (tab_contents_->infobar_tab_helper()->infobar_count() != target_count_) + if (tab_contents_->infobar_tab_helper()->GetInfoBarCount() != target_count_) return; if (automation_) { @@ -2360,7 +2360,7 @@ AutofillFormSubmittedObserver::~AutofillFormSubmittedObserver() { if (infobar_helper_) { InfoBarDelegate* infobar = NULL; - if (infobar_helper_->infobar_count() > 0 && + if (infobar_helper_->GetInfoBarCount() > 0 && (infobar = infobar_helper_->GetInfoBarDelegateAt(0))) { infobar_helper_->RemoveInfoBar(infobar); } diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 6216b1b..361c9a9 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -2175,7 +2175,7 @@ ListValue* TestingAutomationProvider::GetInfobarsInfo(WebContents* wc) { ListValue* infobars = new ListValue; InfoBarTabHelper* infobar_helper = TabContents::FromWebContents(wc)->infobar_tab_helper(); - for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { + for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); ++i) { DictionaryValue* infobar_item = new DictionaryValue; InfoBarDelegate* infobar = infobar_helper->GetInfoBarDelegateAt(i); switch (infobar->GetInfoBarAutomationType()) { @@ -2267,7 +2267,7 @@ void TestingAutomationProvider::PerformActionOnInfobar( InfoBarDelegate* infobar = NULL; size_t infobar_index = static_cast<size_t>(infobar_index_int); - if (infobar_index >= infobar_helper->infobar_count()) { + if (infobar_index >= infobar_helper->GetInfoBarCount()) { reply.SendError(StringPrintf("No such infobar at index %" PRIuS, infobar_index)); return; @@ -3786,7 +3786,7 @@ TranslateInfoBarDelegate* GetTranslateInfoBarDelegate( WebContents* web_contents) { InfoBarTabHelper* infobar_helper = TabContents::FromWebContents(web_contents)->infobar_tab_helper(); - for (size_t i = 0; i < infobar_helper->infobar_count(); i++) { + for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); i++) { InfoBarDelegate* infobar = infobar_helper->GetInfoBarDelegateAt(i); if (infobar->AsTranslateInfoBarDelegate()) return infobar->AsTranslateInfoBarDelegate(); diff --git a/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc b/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc index 4c30d0c..d3cbca0 100644 --- a/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc +++ b/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc @@ -5,8 +5,8 @@ #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/api/infobars/infobar_tab_service.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/common/url_constants.h" #include "content/public/browser/user_metrics.h" #include "content/public/browser/web_contents.h" @@ -18,10 +18,10 @@ using content::Referrer; using content::UserMetricsAction; RegisterProtocolHandlerInfoBarDelegate::RegisterProtocolHandlerInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarTabService* infobar_service, ProtocolHandlerRegistry* registry, const ProtocolHandler& handler) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), registry_(registry), handler_(handler) { } @@ -97,7 +97,7 @@ bool RegisterProtocolHandlerInfoBarDelegate::LinkClicked( (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, content::PAGE_TRANSITION_LINK, false); - owner()->web_contents()->OpenURL(params); + owner()->GetWebContents()->OpenURL(params); return false; } diff --git a/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.h b/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.h index 24c4c28..cedecd0 100644 --- a/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.h +++ b/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.h @@ -9,13 +9,14 @@ #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" #include "chrome/common/custom_handlers/protocol_handler.h" +class InfoBarTabService; class ProtocolHandlerRegistry; // An InfoBar delegate that enables the user to allow or deny storing credit // card information gathered from a form submission. class RegisterProtocolHandlerInfoBarDelegate : public ConfirmInfoBarDelegate { public: - RegisterProtocolHandlerInfoBarDelegate(InfoBarTabHelper* infobar_helper, + RegisterProtocolHandlerInfoBarDelegate(InfoBarTabService* infobar_service, ProtocolHandlerRegistry* registry, const ProtocolHandler& handler); diff --git a/chrome/browser/download/download_request_infobar_delegate.cc b/chrome/browser/download/download_request_infobar_delegate.cc index 9c96fab..fee0bfd 100644 --- a/chrome/browser/download/download_request_infobar_delegate.cc +++ b/chrome/browser/download/download_request_infobar_delegate.cc @@ -4,15 +4,16 @@ #include "chrome/browser/download/download_request_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_tab_service.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" DownloadRequestInfoBarDelegate::DownloadRequestInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarTabService* infobar_service, DownloadRequestLimiter::TabDownloadState* host) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), host_(host) { } diff --git a/chrome/browser/download/download_request_infobar_delegate.h b/chrome/browser/download/download_request_infobar_delegate.h index 0e8f2fe..071fbcb 100644 --- a/chrome/browser/download/download_request_infobar_delegate.h +++ b/chrome/browser/download/download_request_infobar_delegate.h @@ -9,6 +9,8 @@ #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" #include "chrome/browser/download/download_request_limiter.h" +class InfoBarTabService; + // An infobar delegate that presents the user with a choice to allow or deny // multiple downloads from the same site. This confirmation step protects // against "carpet-bombing", where a malicious site forces multiple downloads @@ -16,7 +18,7 @@ class DownloadRequestInfoBarDelegate : public ConfirmInfoBarDelegate { public: DownloadRequestInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarTabService* infobar_service, DownloadRequestLimiter::TabDownloadState* host); void set_host(DownloadRequestLimiter::TabDownloadState* host) { diff --git a/chrome/browser/extensions/extension_infobar_delegate.cc b/chrome/browser/extensions/extension_infobar_delegate.cc index cf4dfcb..afef514 100644 --- a/chrome/browser/extensions/extension_infobar_delegate.cc +++ b/chrome/browser/extensions/extension_infobar_delegate.cc @@ -4,10 +4,10 @@ #include "chrome/browser/extensions/extension_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_tab_service.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/infobars/infobar.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_notification_types.h" @@ -17,11 +17,11 @@ ExtensionInfoBarDelegate::ExtensionInfoBarDelegate( Browser* browser, - InfoBarTabHelper* infobar_helper, + InfoBarTabService* infobar_service, const extensions::Extension* extension, const GURL& url, int height) - : InfoBarDelegate(infobar_helper), + : InfoBarDelegate(infobar_service), browser_(browser), observer_(NULL), extension_(extension), @@ -29,7 +29,7 @@ ExtensionInfoBarDelegate::ExtensionInfoBarDelegate( ExtensionProcessManager* manager = browser->profile()->GetExtensionProcessManager(); extension_host_.reset(manager->CreateInfobarHost(url, browser)); - extension_host_->SetAssociatedWebContents(infobar_helper->web_contents()); + extension_host_->SetAssociatedWebContents(infobar_service->GetWebContents()); registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, content::Source<Profile>(browser->profile())); diff --git a/chrome/browser/extensions/extension_infobar_delegate.h b/chrome/browser/extensions/extension_infobar_delegate.h index c843623..9dd0c6a 100644 --- a/chrome/browser/extensions/extension_infobar_delegate.h +++ b/chrome/browser/extensions/extension_infobar_delegate.h @@ -12,6 +12,7 @@ class Browser; class GURL; +class InfoBarTabService; namespace extensions { class Extension; @@ -33,7 +34,7 @@ class ExtensionInfoBarDelegate : public InfoBarDelegate, }; ExtensionInfoBarDelegate(Browser* browser, - InfoBarTabHelper* infobar_helper, + InfoBarTabService* infobar_service, const extensions::Extension* extension, const GURL& url, int height); @@ -50,7 +51,7 @@ class ExtensionInfoBarDelegate : public InfoBarDelegate, virtual ~ExtensionInfoBarDelegate(); // InfoBarDelegate: - virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) OVERRIDE; + virtual InfoBar* CreateInfoBar(InfoBarTabService* owner) OVERRIDE; virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE; virtual void InfoBarDismissed() OVERRIDE; virtual Type GetInfoBarType() const OVERRIDE; diff --git a/chrome/browser/extensions/extension_install_ui_browsertest.cc b/chrome/browser/extensions/extension_install_ui_browsertest.cc index 0e50725..ff388d3 100644 --- a/chrome/browser/extensions/extension_install_ui_browsertest.cc +++ b/chrome/browser/extensions/extension_install_ui_browsertest.cc @@ -28,12 +28,12 @@ class ExtensionInstallUIBrowserTest : public ExtensionBrowserTest { TabContents* tab = chrome::GetActiveTabContents(browser()); ASSERT_TRUE(tab); InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); - ASSERT_EQ(1U, infobar_helper->infobar_count()); + ASSERT_EQ(1U, infobar_helper->GetInfoBarCount()); ConfirmInfoBarDelegate* delegate = infobar_helper-> GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(delegate); delegate->Cancel(); - ASSERT_EQ(0U, infobar_helper->infobar_count()); + ASSERT_EQ(0U, infobar_helper->GetInfoBarCount()); } const Extension* GetTheme() const { diff --git a/chrome/browser/extensions/extension_install_ui_default.cc b/chrome/browser/extensions/extension_install_ui_default.cc index d4b940a..23c9ccd 100644 --- a/chrome/browser/extensions/extension_install_ui_default.cc +++ b/chrome/browser/extensions/extension_install_ui_default.cc @@ -186,7 +186,7 @@ void ExtensionInstallUIDefault::ShowThemeInfoBar( // First find any previous theme preview infobars. InfoBarDelegate* old_delegate = NULL; - for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { + for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); ++i) { InfoBarDelegate* delegate = infobar_helper->GetInfoBarDelegateAt(i); ThemeInstalledInfoBarDelegate* theme_infobar = delegate->AsThemePreviewInfobarDelegate(); diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.cc b/chrome/browser/extensions/theme_installed_infobar_delegate.cc index a767c35..33c9876c 100644 --- a/chrome/browser/extensions/theme_installed_infobar_delegate.cc +++ b/chrome/browser/extensions/theme_installed_infobar_delegate.cc @@ -8,6 +8,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.h b/chrome/browser/extensions/theme_installed_infobar_delegate.h index a3abb17..a527709 100644 --- a/chrome/browser/extensions/theme_installed_infobar_delegate.h +++ b/chrome/browser/extensions/theme_installed_infobar_delegate.h @@ -13,6 +13,7 @@ #include "content/public/browser/notification_registrar.h" class ExtensionService; +class InfoBarTabHelper; class ThemeService; namespace extensions { diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context.cc index 5d84bef..b00bb7d 100644 --- a/chrome/browser/geolocation/chrome_geolocation_permission_context.cc +++ b/chrome/browser/geolocation/chrome_geolocation_permission_context.cc @@ -178,7 +178,7 @@ GeolocationConfirmInfoBarDelegate::GeolocationConfirmInfoBarDelegate( requesting_frame_url_(requesting_frame_url), display_languages_(display_languages) { const NavigationEntry* committed_entry = - infobar_helper->web_contents()->GetController().GetLastCommittedEntry(); + infobar_helper->GetWebContents()->GetController().GetLastCommittedEntry(); set_contents_unique_id(committed_entry ? committed_entry->GetUniqueID() : 0); } @@ -205,13 +205,13 @@ string16 GeolocationConfirmInfoBarDelegate::GetButtonLabel( bool GeolocationConfirmInfoBarDelegate::Accept() { controller_->OnPermissionSet(render_process_id_, render_view_id_, bridge_id_, - requesting_frame_url_, owner()->web_contents()->GetURL(), true); + requesting_frame_url_, owner()->GetWebContents()->GetURL(), true); return true; } bool GeolocationConfirmInfoBarDelegate::Cancel() { controller_->OnPermissionSet(render_process_id_, render_view_id_, bridge_id_, - requesting_frame_url_, owner()->web_contents()->GetURL(), + requesting_frame_url_, owner()->GetWebContents()->GetURL(), false); return true; } @@ -234,7 +234,7 @@ bool GeolocationConfirmInfoBarDelegate::LinkClicked( Referrer(), (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, content::PAGE_TRANSITION_LINK, false); - owner()->web_contents()->OpenURL(params); + owner()->GetWebContents()->OpenURL(params); return false; // Do not dismiss the info bar. } diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc index 0782b87..4de4787 100644 --- a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc +++ b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc @@ -260,10 +260,10 @@ void GeolocationPermissionContextTests::TearDown() { TEST_F(GeolocationPermissionContextTests, SinglePermission) { GURL requesting_frame("http://www.example.com/geolocation"); NavigateAndCommit(requesting_frame); - EXPECT_EQ(0U, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); RequestGeolocationPermission( process_id(), render_id(), bridge_id(), requesting_frame); - ASSERT_EQ(1U, infobar_tab_helper()->infobar_count()); + ASSERT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); ConfirmInfoBarDelegate* infobar_0 = infobar_tab_helper()-> GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); infobar_0->Cancel(); @@ -283,18 +283,18 @@ TEST_F(GeolocationPermissionContextTests, GeolocationEnabledDisabled) { // even though the default policy allows it. GURL requesting_frame("http://www.example.com/geolocation"); NavigateAndCommit(requesting_frame); - EXPECT_EQ(0U, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); profile()->GetPrefs()->SetBoolean(prefs::kGeolocationEnabled, false); RequestGeolocationPermission( process_id(), render_id(), bridge_id(), requesting_frame); - ASSERT_EQ(0U, infobar_tab_helper()->infobar_count()); + ASSERT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); CheckPermissionMessageSent(bridge_id(), false); // Reenable the preference and check that the request now goes though. profile()->GetPrefs()->SetBoolean(prefs::kGeolocationEnabled, true); RequestGeolocationPermission( process_id(), render_id(), bridge_id() + 1, requesting_frame); - ASSERT_EQ(0U, infobar_tab_helper()->infobar_count()); + ASSERT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); CheckPermissionMessageSent(bridge_id() + 1, true); } #endif @@ -317,14 +317,14 @@ TEST_F(GeolocationPermissionContextTests, QueuedPermission) { NavigateAndCommit(requesting_frame_0); - EXPECT_EQ(0U, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); // Request permission for two frames. RequestGeolocationPermission( process_id(), render_id(), bridge_id(), requesting_frame_0); RequestGeolocationPermission( process_id(), render_id(), bridge_id() + 1, requesting_frame_1); // Ensure only one infobar is created. - ASSERT_EQ(1U, infobar_tab_helper()->infobar_count()); + ASSERT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); ConfirmInfoBarDelegate* infobar_0 = infobar_tab_helper()-> GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(infobar_0); @@ -341,7 +341,7 @@ TEST_F(GeolocationPermissionContextTests, QueuedPermission) { closed_delegate_tracker_.Clear(); infobar_0->InfoBarClosed(); // Now we should have a new infobar for the second frame. - ASSERT_EQ(1U, infobar_tab_helper()->infobar_count()); + ASSERT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); ConfirmInfoBarDelegate* infobar_1 = infobar_tab_helper()-> GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); @@ -357,7 +357,7 @@ TEST_F(GeolocationPermissionContextTests, QueuedPermission) { EXPECT_EQ(1U, closed_delegate_tracker_.size()); EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_1)); infobar_1->InfoBarClosed(); - EXPECT_EQ(0U, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); // Ensure the persisted permissions are ok. EXPECT_EQ(CONTENT_SETTING_ALLOW, profile()->GetHostContentSettingsMap()->GetContentSetting( @@ -393,13 +393,13 @@ TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) { NavigateAndCommit(requesting_frame_0); - EXPECT_EQ(0U, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); // Request permission for two frames. RequestGeolocationPermission( process_id(), render_id(), bridge_id(), requesting_frame_0); RequestGeolocationPermission( process_id(), render_id(), bridge_id() + 1, requesting_frame_1); - ASSERT_EQ(1U, infobar_tab_helper()->infobar_count()); + ASSERT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); ConfirmInfoBarDelegate* infobar_0 = infobar_tab_helper()-> GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); @@ -414,7 +414,7 @@ TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) { EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0)); closed_delegate_tracker_.Clear(); infobar_0->InfoBarClosed(); - ASSERT_EQ(1U, infobar_tab_helper()->infobar_count()); + ASSERT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); ConfirmInfoBarDelegate* infobar_1 = infobar_tab_helper()-> GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); @@ -430,7 +430,7 @@ TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) { EXPECT_EQ(1U, closed_delegate_tracker_.size()); EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_1)); infobar_1->InfoBarClosed(); - EXPECT_EQ(0U, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); // Ensure the persisted permissions are ok. EXPECT_EQ(CONTENT_SETTING_ASK, profile()->GetHostContentSettingsMap()->GetContentSetting( @@ -451,10 +451,10 @@ TEST_F(GeolocationPermissionContextTests, InvalidURL) { GURL invalid_embedder("about:blank"); GURL requesting_frame; NavigateAndCommit(invalid_embedder); - EXPECT_EQ(0U, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); RequestGeolocationPermission( process_id(), render_id(), bridge_id(), requesting_frame); - EXPECT_EQ(0U, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); CheckPermissionMessageSent(bridge_id(), false); } @@ -465,18 +465,18 @@ TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) { AddNewTab(url_b); AddNewTab(url_a); - EXPECT_EQ(0U, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); RequestGeolocationPermission( process_id(), render_id(), bridge_id(), url_a); - ASSERT_EQ(1U, infobar_tab_helper()->infobar_count()); + ASSERT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); RequestGeolocationPermission( process_id_for_tab(0), render_id_for_tab(0), bridge_id(), url_b); - EXPECT_EQ(1U, extra_tabs_[0]->infobar_tab_helper()->infobar_count()); + EXPECT_EQ(1U, extra_tabs_[0]->infobar_tab_helper()->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()->infobar_count()); + ASSERT_EQ(1U, extra_tabs_[1]->infobar_tab_helper()->GetInfoBarCount()); ConfirmInfoBarDelegate* removed_infobar = extra_tabs_[1]-> infobar_tab_helper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); @@ -492,7 +492,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()->infobar_count()); + EXPECT_EQ(0U, extra_tabs_[1]->infobar_tab_helper()->GetInfoBarCount()); CheckPermissionMessageSentForTab(1, bridge_id(), true); EXPECT_TRUE(closed_delegate_tracker_.Contains(removed_infobar)); closed_delegate_tracker_.Clear(); @@ -500,7 +500,7 @@ 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()->infobar_count()); + ASSERT_EQ(1U, extra_tabs_[0]->infobar_tab_helper()->GetInfoBarCount()); ConfirmInfoBarDelegate* infobar_1 = extra_tabs_[0]->infobar_tab_helper()-> GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); infobar_1->Cancel(); @@ -516,18 +516,18 @@ TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) { NavigateAndCommit(url_a); AddNewTab(url_a); - EXPECT_EQ(0U, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); RequestGeolocationPermission( process_id(), render_id(), bridge_id(), url_a); - ASSERT_EQ(1U, infobar_tab_helper()->infobar_count()); + ASSERT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); RequestGeolocationPermission( process_id_for_tab(0), render_id_for_tab(0), bridge_id(), url_a); - EXPECT_EQ(1U, extra_tabs_[0]->infobar_tab_helper()->infobar_count()); + EXPECT_EQ(1U, extra_tabs_[0]->infobar_tab_helper()->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()->infobar_count()); + ASSERT_EQ(1U, extra_tabs_[0]->infobar_tab_helper()->GetInfoBarCount()); ConfirmInfoBarDelegate* removed_infobar = infobar_tab_helper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); @@ -543,7 +543,7 @@ TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) { 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, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); CheckPermissionMessageSent(bridge_id(), true); EXPECT_TRUE(closed_delegate_tracker_.Contains(removed_infobar)); closed_delegate_tracker_.Clear(); @@ -551,7 +551,7 @@ 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()->infobar_count()); + ASSERT_EQ(1U, extra_tabs_[0]->infobar_tab_helper()->GetInfoBarCount()); // Accept the second infobar. ConfirmInfoBarDelegate* infobar_1 = extra_tabs_[0]->infobar_tab_helper()-> @@ -585,14 +585,14 @@ TEST_F(GeolocationPermissionContextTests, TabDestroyed) { std::string())); NavigateAndCommit(requesting_frame_0); - EXPECT_EQ(0U, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); // Request permission for two frames. RequestGeolocationPermission( process_id(), render_id(), bridge_id(), requesting_frame_0); RequestGeolocationPermission( process_id(), render_id(), bridge_id() + 1, requesting_frame_1); // Ensure only one infobar is created. - ASSERT_EQ(1U, infobar_tab_helper()->infobar_count()); + ASSERT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); ConfirmInfoBarDelegate* infobar_0 = infobar_tab_helper()-> GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(infobar_0); @@ -617,7 +617,7 @@ TEST_F(GeolocationPermissionContextTests, InfoBarUsesCommittedEntry) { GURL requesting_frame_1("http://www.example-2.com/geolocation"); NavigateAndCommit(requesting_frame_0); NavigateAndCommit(requesting_frame_1); - EXPECT_EQ(0U, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); // Go back: navigate to a pending entry before requesting geolocation // permission. contents()->GetController().GoBack(); @@ -625,7 +625,7 @@ TEST_F(GeolocationPermissionContextTests, InfoBarUsesCommittedEntry) { RequestGeolocationPermission( process_id(), render_id(), bridge_id(), requesting_frame_1); // Ensure the infobar is created. - ASSERT_EQ(1U, infobar_tab_helper()->infobar_count()); + ASSERT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); InfoBarDelegate* infobar_0 = infobar_tab_helper()->GetInfoBarDelegateAt(0); ASSERT_TRUE(infobar_0); // Ensure the infobar is not yet expired. diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc index 7edf812..8022e64 100644 --- a/chrome/browser/geolocation/geolocation_browsertest.cc +++ b/chrome/browser/geolocation/geolocation_browsertest.cc @@ -568,10 +568,10 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, InfoBarTabHelper* infobar_helper = chrome::GetActiveTabContents(current_browser_)->infobar_tab_helper(); - size_t num_infobars_before_cancel = infobar_helper->infobar_count(); + 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_); - size_t num_infobars_after_cancel = infobar_helper->infobar_count(); + size_t num_infobars_after_cancel = infobar_helper->GetInfoBarCount(); EXPECT_EQ(num_infobars_before_cancel, num_infobars_after_cancel + 1); } diff --git a/chrome/browser/google/google_url_tracker.cc b/chrome/browser/google/google_url_tracker.cc index dfb1be7..baa8365 100644 --- a/chrome/browser/google/google_url_tracker.cc +++ b/chrome/browser/google/google_url_tracker.cc @@ -87,7 +87,7 @@ bool GoogleURLTrackerInfoBarDelegate::LinkClicked( content::Referrer(), (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, content::PAGE_TRANSITION_LINK, false); - owner()->web_contents()->OpenURL(params); + owner()->GetWebContents()->OpenURL(params); return false; } @@ -148,7 +148,7 @@ void GoogleURLTrackerInfoBarDelegate::Close(bool redo_search) { if (new_search_url.is_valid()) { content::OpenURLParams params(new_search_url, content::Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_GENERATED, false); - owner()->web_contents()->OpenURL(params); + owner()->GetWebContents()->OpenURL(params); } } diff --git a/chrome/browser/google/google_url_tracker.h b/chrome/browser/google/google_url_tracker.h index 21f4a01..2035bc1 100644 --- a/chrome/browser/google/google_url_tracker.h +++ b/chrome/browser/google/google_url_tracker.h @@ -23,6 +23,7 @@ #include "net/url_request/url_fetcher_delegate.h" class GoogleURLTrackerInfoBarDelegate; +class InfoBarTabHelper; class PrefService; class Profile; diff --git a/chrome/browser/infobars/infobar_container.cc b/chrome/browser/infobars/infobar_container.cc index 527e99c..71b277c 100644 --- a/chrome/browser/infobars/infobar_container.cc +++ b/chrome/browser/infobars/infobar_container.cc @@ -54,7 +54,7 @@ void InfoBarContainer::ChangeTabContents(InfoBarTabHelper* tab_helper) { registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED, th_source); - for (size_t i = 0; i < tab_helper_->infobar_count(); ++i) { + for (size_t i = 0; i < tab_helper_->GetInfoBarCount(); ++i) { // As when we removed the infobars above, we prevent callbacks to // OnInfoBarAnimated() for each infobar. AddInfoBar( diff --git a/chrome/browser/infobars/infobar_tab_helper.cc b/chrome/browser/infobars/infobar_tab_helper.cc index 405661f..275df57 100644 --- a/chrome/browser/infobars/infobar_tab_helper.cc +++ b/chrome/browser/infobars/infobar_tab_helper.cc @@ -7,6 +7,7 @@ #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" @@ -16,6 +17,10 @@ using content::NavigationController; using content::WebContents; +InfoBarTabService* InfoBarTabService::ForTab(TabContents* tab) { + return tab->infobar_tab_helper(); +} + InfoBarTabHelper::InfoBarTabHelper(WebContents* web_contents) : content::WebContentsObserver(web_contents), infobars_enabled_(true) { @@ -94,10 +99,18 @@ bool InfoBarTabHelper::ReplaceInfoBar(InfoBarDelegate* old_delegate, return true; } +size_t InfoBarTabHelper::GetInfoBarCount() const { + return infobars_.size(); +} + InfoBarDelegate* InfoBarTabHelper::GetInfoBarDelegateAt(size_t index) { return infobars_[index]; } +content::WebContents* InfoBarTabHelper::GetWebContents() { + return content::WebContentsObserver::web_contents(); +} + void InfoBarTabHelper::RemoveInfoBarInternal(InfoBarDelegate* delegate, bool animate) { if (!infobars_enabled_) { @@ -129,7 +142,7 @@ void InfoBarTabHelper::RemoveInfoBarInternal(InfoBarDelegate* delegate, void InfoBarTabHelper::RemoveAllInfoBars(bool animate) { while (!infobars_.empty()) - RemoveInfoBarInternal(GetInfoBarDelegateAt(infobar_count() - 1), animate); + RemoveInfoBarInternal(GetInfoBarDelegateAt(GetInfoBarCount() - 1), animate); } void InfoBarTabHelper::OnDidBlockDisplayingInsecureContent() { diff --git a/chrome/browser/infobars/infobar_tab_helper.h b/chrome/browser/infobars/infobar_tab_helper.h index 3221741..b9a5603 100644 --- a/chrome/browser/infobars/infobar_tab_helper.h +++ b/chrome/browser/infobars/infobar_tab_helper.h @@ -6,6 +6,7 @@ #define CHROME_BROWSER_INFOBARS_INFOBAR_TAB_HELPER_H_ #include "base/basictypes.h" +#include "chrome/browser/api/infobars/infobar_tab_service.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/web_contents_observer.h" @@ -13,43 +14,23 @@ class InfoBarDelegate; // Per-tab info bar manager. -class InfoBarTabHelper : public content::WebContentsObserver, +class InfoBarTabHelper : public InfoBarTabService, + public content::WebContentsObserver, public content::NotificationObserver { public: explicit InfoBarTabHelper(content::WebContents* web_contents); virtual ~InfoBarTabHelper(); - // Adds an InfoBar for the specified |delegate|. - // - // If infobars are disabled for this tab or the tab already has a delegate - // which returns true for InfoBarDelegate::EqualsDelegate(delegate), - // |delegate| is closed immediately without being added. - // - // Returns whether |delegate| was successfully added. - bool AddInfoBar(InfoBarDelegate* delegate); + // InfoBarTabService implementation. + virtual bool AddInfoBar(InfoBarDelegate* delegate) OVERRIDE; + virtual void RemoveInfoBar(InfoBarDelegate* delegate) OVERRIDE; + virtual bool ReplaceInfoBar(InfoBarDelegate* old_delegate, + InfoBarDelegate* new_delegate) OVERRIDE; + virtual size_t GetInfoBarCount() const OVERRIDE; + virtual InfoBarDelegate* GetInfoBarDelegateAt(size_t index) OVERRIDE; + virtual content::WebContents* GetWebContents() OVERRIDE; - // Removes the InfoBar for the specified |delegate|. - // - // If infobars are disabled for this tab, this will do nothing, on the - // assumption that the matching AddInfoBar() call will have already closed the - // delegate (see above). - void RemoveInfoBar(InfoBarDelegate* delegate); - - // Replaces one infobar with another, without any animation in between. - // - // If infobars are disabled for this tab, |new_delegate| is closed immediately - // without being added, and nothing else happens. - // - // Returns whether |new_delegate| was successfully added. - // - // NOTE: This does not perform any EqualsDelegate() checks like AddInfoBar(). - bool ReplaceInfoBar(InfoBarDelegate* old_delegate, - InfoBarDelegate* new_delegate); - - // Enumeration and access functions. - size_t infobar_count() const { return infobars_.size(); } - // WARNING: This does not sanity-check |index|! - InfoBarDelegate* GetInfoBarDelegateAt(size_t index); + // Enables or disables infobars for the given tab. void set_infobars_enabled(bool value) { infobars_enabled_ = value; } // content::WebContentsObserver overrides: @@ -61,11 +42,6 @@ class InfoBarTabHelper : public content::WebContentsObserver, const content::NotificationSource& source, const content::NotificationDetails& details) OVERRIDE; - // Helper functions for infobars: - content::WebContents* web_contents() { - return content::WebContentsObserver::web_contents(); - } - private: typedef std::vector<InfoBarDelegate*> InfoBars; diff --git a/chrome/browser/infobars/infobars_browsertest.cc b/chrome/browser/infobars/infobars_browsertest.cc index 5ac1e40..968804b 100644 --- a/chrome/browser/infobars/infobars_browsertest.cc +++ b/chrome/browser/infobars/infobars_browsertest.cc @@ -76,7 +76,7 @@ IN_PROC_BROWSER_TEST_F(InfoBarsTest, TestInfoBarsCloseOnNewTheme) { infobar_removed_1.Wait(); EXPECT_EQ(0u, chrome::GetTabContentsAt(browser(), 0)->infobar_tab_helper()-> - infobar_count()); + GetInfoBarCount()); content::WindowedNotificationObserver infobar_removed_2( chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, @@ -85,5 +85,5 @@ IN_PROC_BROWSER_TEST_F(InfoBarsTest, TestInfoBarsCloseOnNewTheme) { infobar_removed_2.Wait(); EXPECT_EQ(0u, chrome::GetActiveTabContents(browser())->infobar_tab_helper()-> - infobar_count()); + GetInfoBarCount()); } diff --git a/chrome/browser/infobars/insecure_content_infobar_delegate.cc b/chrome/browser/infobars/insecure_content_infobar_delegate.cc index 1734103..34ac0d4 100644 --- a/chrome/browser/infobars/insecure_content_infobar_delegate.cc +++ b/chrome/browser/infobars/insecure_content_infobar_delegate.cc @@ -8,6 +8,7 @@ #include "chrome/browser/google/google_util.h" #include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/common/render_messages.h" +#include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "content/public/common/page_transition_types.h" #include "grit/generated_resources.h" @@ -67,10 +68,16 @@ bool InsecureContentInfoBarDelegate::Cancel() { (type_ == DISPLAY) ? DISPLAY_USER_OVERRIDE : RUN_USER_OVERRIDE, NUM_EVENTS); - int32 routing_id = owner()->routing_id(); - owner()->Send((type_ == DISPLAY) ? static_cast<IPC::Message*>( - new ChromeViewMsg_SetAllowDisplayingInsecureContent(routing_id, true)) : - new ChromeViewMsg_SetAllowRunningInsecureContent(routing_id, true)); + content::WebContents* web_contents = owner()->GetWebContents(); + if (web_contents) { + int32 routing_id = web_contents->GetRoutingID(); + web_contents->Send((type_ == DISPLAY) ? + static_cast<IPC::Message*>( + new ChromeViewMsg_SetAllowDisplayingInsecureContent( + routing_id, true)) : + new ChromeViewMsg_SetAllowRunningInsecureContent( + routing_id, true)); + } return true; } @@ -80,7 +87,7 @@ string16 InsecureContentInfoBarDelegate::GetLinkText() const { bool InsecureContentInfoBarDelegate::LinkClicked( WindowOpenDisposition disposition) { - owner()->web_contents()->OpenURL(OpenURLParams( + owner()->GetWebContents()->OpenURL(OpenURLParams( google_util::AppendGoogleLocaleParam(GURL( "https://www.google.com/support/chrome/bin/answer.py?answer=1342714")), content::Referrer(), diff --git a/chrome/browser/infobars/insecure_content_infobar_delegate.h b/chrome/browser/infobars/insecure_content_infobar_delegate.h index f199897..97d65c0e 100644 --- a/chrome/browser/infobars/insecure_content_infobar_delegate.h +++ b/chrome/browser/infobars/insecure_content_infobar_delegate.h @@ -7,6 +7,8 @@ #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +class InfoBarTabHelper; + // Base class for delegates that show warnings on HTTPS pages which try to // display or run insecure content. class InsecureContentInfoBarDelegate : public ConfirmInfoBarDelegate { diff --git a/chrome/browser/notifications/notification_browsertest.cc b/chrome/browser/notifications/notification_browsertest.cc index 58aea69..21da5dd 100644 --- a/chrome/browser/notifications/notification_browsertest.cc +++ b/chrome/browser/notifications/notification_browsertest.cc @@ -38,7 +38,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsPermissionTest, TestUserGestureInfobar) { EXPECT_TRUE(result); EXPECT_EQ(1U, chrome::GetTabContentsAt(browser(), 0)->infobar_tab_helper()-> - infobar_count()); + GetInfoBarCount()); } // If this flakes, use http://crbug.com/62311. @@ -53,5 +53,5 @@ IN_PROC_BROWSER_TEST_F(NotificationsPermissionTest, TestNoUserGestureInfobar) { "files/notifications/notifications_request_inline.html")); EXPECT_EQ(0U, chrome::GetTabContentsAt(browser(), 0)->infobar_tab_helper()-> - infobar_count()); + GetInfoBarCount()); } diff --git a/chrome/browser/plugin_infobar_delegates.cc b/chrome/browser/plugin_infobar_delegates.cc index fba356a..e359246 100644 --- a/chrome/browser/plugin_infobar_delegates.cc +++ b/chrome/browser/plugin_infobar_delegates.cc @@ -5,9 +5,9 @@ #include "chrome/browser/plugin_infobar_delegates.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/api/infobars/infobar_tab_service.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/google/google_util.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/plugin_observer.h" #include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/common/render_messages.h" @@ -35,10 +35,10 @@ using content::OpenURLParams; using content::Referrer; using content::UserMetricsAction; -PluginInfoBarDelegate::PluginInfoBarDelegate(InfoBarTabHelper* infobar_helper, +PluginInfoBarDelegate::PluginInfoBarDelegate(InfoBarTabService* infobar_service, const string16& name, const std::string& identifier) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), name_(name), identifier_(identifier) { } @@ -52,13 +52,16 @@ bool PluginInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, content::PAGE_TRANSITION_LINK, false); - owner()->web_contents()->OpenURL(params); + owner()->GetWebContents()->OpenURL(params); return false; } void PluginInfoBarDelegate::LoadBlockedPlugins() { - owner()->Send( - new ChromeViewMsg_LoadBlockedPlugins(owner()->routing_id(), identifier_)); + content::WebContents* web_contents = owner()->GetWebContents(); + if (web_contents) { + web_contents->Send(new ChromeViewMsg_LoadBlockedPlugins( + web_contents->GetRoutingID(), identifier_)); + } } gfx::Image* PluginInfoBarDelegate::GetIcon() const { @@ -73,11 +76,11 @@ string16 PluginInfoBarDelegate::GetLinkText() const { // UnauthorizedPluginInfoBarDelegate ------------------------------------------ UnauthorizedPluginInfoBarDelegate::UnauthorizedPluginInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarTabService* infobar_service, HostContentSettingsMap* content_settings, const string16& utf16_name, const std::string& identifier) - : PluginInfoBarDelegate(infobar_helper, utf16_name, identifier), + : PluginInfoBarDelegate(infobar_service, utf16_name, identifier), content_settings_(content_settings) { content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Shown")); std::string name = UTF16ToUTF8(utf16_name); @@ -126,8 +129,8 @@ bool UnauthorizedPluginInfoBarDelegate::Accept() { bool UnauthorizedPluginInfoBarDelegate::Cancel() { content::RecordAction( UserMetricsAction("BlockedPluginInfobar.AlwaysAllow")); - content_settings_->AddExceptionForURL(owner()->web_contents()->GetURL(), - owner()->web_contents()->GetURL(), + content_settings_->AddExceptionForURL(owner()->GetWebContents()->GetURL(), + owner()->GetWebContents()->GetURL(), CONTENT_SETTINGS_TYPE_PLUGINS, std::string(), CONTENT_SETTING_ALLOW); @@ -173,7 +176,8 @@ OutdatedPluginInfoBarDelegate::OutdatedPluginInfoBarDelegate( PluginInstaller* installer, const string16& message) : PluginInfoBarDelegate( - observer->tab_contents()->infobar_tab_helper(), + +InfoBarTabService::ForTab(observer->tab_contents()), installer->name(), installer->identifier()), WeakPluginInstallerObserver(installer), @@ -226,7 +230,7 @@ bool OutdatedPluginInfoBarDelegate::Accept() { return false; } - content::WebContents* web_contents = owner()->web_contents(); + content::WebContents* web_contents = owner()->GetWebContents(); if (installer()->url_for_display()) { installer()->OpenDownloadURL(web_contents); } else { @@ -297,12 +301,12 @@ void OutdatedPluginInfoBarDelegate::ReplaceWithInfoBar( // PluginInstallerInfoBarDelegate --------------------------------------------- PluginInstallerInfoBarDelegate::PluginInstallerInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarTabService* infobar_service, PluginInstaller* installer, const base::Closure& callback, bool new_install, const string16& message) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), WeakPluginInstallerObserver(installer), callback_(callback), new_install_(new_install), @@ -313,7 +317,7 @@ PluginInstallerInfoBarDelegate::~PluginInstallerInfoBarDelegate() { } InfoBarDelegate* PluginInstallerInfoBarDelegate::Create( - InfoBarTabHelper* infobar_helper, + InfoBarTabService* infobar_service, PluginInstaller* installer, const base::Closure& callback) { string16 message; @@ -328,7 +332,7 @@ InfoBarDelegate* PluginInstallerInfoBarDelegate::Create( break; } return new PluginInstallerInfoBarDelegate( - infobar_helper, installer, callback, true, message); + infobar_service, installer, callback, true, message); } gfx::Image* PluginInstallerInfoBarDelegate::GetIcon() const { @@ -373,7 +377,7 @@ bool PluginInstallerInfoBarDelegate::LinkClicked( url, Referrer(), (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, content::PAGE_TRANSITION_LINK, false); - owner()->web_contents()->OpenURL(params); + owner()->GetWebContents()->OpenURL(params); return false; } @@ -421,16 +425,16 @@ void PluginInstallerInfoBarDelegate::ReplaceWithInfoBar( // PluginMetroModeInfoBarDelegate --------------------------------------------- #if defined(OS_WIN) InfoBarDelegate* PluginMetroModeInfoBarDelegate::Create( - InfoBarTabHelper* infobar_helper, const string16& plugin_name) { + InfoBarTabService* infobar_service, const string16& plugin_name) { string16 message = l10n_util::GetStringFUTF16( IDS_METRO_MISSING_PLUGIN_PROMPT, plugin_name); return new PluginMetroModeInfoBarDelegate( - infobar_helper, message); + infobar_service, message); } PluginMetroModeInfoBarDelegate::PluginMetroModeInfoBarDelegate( - InfoBarTabHelper* infobar_helper, const string16& message) - : ConfirmInfoBarDelegate(infobar_helper), + InfoBarTabService* infobar_service, const string16& message) + : ConfirmInfoBarDelegate(infobar_service), message_(message) { } @@ -457,7 +461,7 @@ string16 PluginMetroModeInfoBarDelegate::GetButtonLabel( } bool PluginMetroModeInfoBarDelegate::Accept() { - content::WebContents* web_contents = owner()->web_contents(); + content::WebContents* web_contents = owner()->GetWebContents(); if (!web_contents) return false; // Note that empty urls are not valid. @@ -485,7 +489,7 @@ bool PluginMetroModeInfoBarDelegate::LinkClicked( url, Referrer(), (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, content::PAGE_TRANSITION_LINK, false); - owner()->web_contents()->OpenURL(params); + owner()->GetWebContents()->OpenURL(params); return false; } #endif // defined(OS_WIN) diff --git a/chrome/browser/plugin_infobar_delegates.h b/chrome/browser/plugin_infobar_delegates.h index 5bb17d5..31be3e3 100644 --- a/chrome/browser/plugin_infobar_delegates.h +++ b/chrome/browser/plugin_infobar_delegates.h @@ -13,13 +13,14 @@ #include "chrome/browser/plugin_installer_observer.h" #endif // defined(ENABLE_PLUGIN_INSTALLATION) +class InfoBarTabService; class HostContentSettingsMap; class PluginObserver; // Base class for blocked plug-in infobars. class PluginInfoBarDelegate : public ConfirmInfoBarDelegate { public: - PluginInfoBarDelegate(InfoBarTabHelper* infobar_helper, + PluginInfoBarDelegate(InfoBarTabService* infobar_service, const string16& name, const std::string& identifier); @@ -48,7 +49,7 @@ class PluginInfoBarDelegate : public ConfirmInfoBarDelegate { // Infobar that's shown when a plug-in requires user authorization to run. class UnauthorizedPluginInfoBarDelegate : public PluginInfoBarDelegate { public: - UnauthorizedPluginInfoBarDelegate(InfoBarTabHelper* infobar_helper, + UnauthorizedPluginInfoBarDelegate(InfoBarTabService* infobar_service, HostContentSettingsMap* content_settings, const string16& name, const std::string& identifier); @@ -107,7 +108,7 @@ class OutdatedPluginInfoBarDelegate : public PluginInfoBarDelegate, void ReplaceWithInfoBar(const string16& message); // Has the same lifetime as TabContents, which owns us - // (transitively via InfoBarTabHelper). + // (transitively via InfoBarTabService). PluginObserver* observer_; string16 message_; @@ -124,14 +125,14 @@ class PluginInstallerInfoBarDelegate : public ConfirmInfoBarDelegate, // |installer|. When the user accepts, |callback| is called. // During installation of the plug-in, the infobar will change to reflect the // installation state. - static InfoBarDelegate* Create(InfoBarTabHelper* infobar_helper, + static InfoBarDelegate* Create(InfoBarTabService* infobar_service, PluginInstaller* installer, const base::Closure& callback); private: friend class OutdatedPluginInfoBarDelegate; - PluginInstallerInfoBarDelegate(InfoBarTabHelper* infobar_helper, + PluginInstallerInfoBarDelegate(InfoBarTabService* infobar_service, PluginInstaller* installer, const base::Closure& callback, bool new_install, @@ -176,10 +177,10 @@ class PluginMetroModeInfoBarDelegate : public ConfirmInfoBarDelegate { public: // Shows an infobar asking the user to switch to desktop chrome if they // want to use the plugin. - static InfoBarDelegate* Create(InfoBarTabHelper* infobar_helper, + static InfoBarDelegate* Create(InfoBarTabService* infobar_service, const string16& plugin_name); private: - PluginMetroModeInfoBarDelegate(InfoBarTabHelper* infobar_helper, + PluginMetroModeInfoBarDelegate(InfoBarTabService* infobar_service, const string16& message); virtual ~PluginMetroModeInfoBarDelegate(); diff --git a/chrome/browser/tab_contents/tab_contents_ssl_helper.cc b/chrome/browser/tab_contents/tab_contents_ssl_helper.cc index 56d80c4..99bab73 100644 --- a/chrome/browser/tab_contents/tab_contents_ssl_helper.cc +++ b/chrome/browser/tab_contents/tab_contents_ssl_helper.cc @@ -100,8 +100,8 @@ string16 SSLCertAddedInfoBarDelegate::GetButtonLabel( bool SSLCertAddedInfoBarDelegate::Accept() { ShowCertificateViewer( - owner()->web_contents(), - owner()->web_contents()->GetView()->GetTopLevelNativeWindow(), + owner()->GetWebContents(), + owner()->GetWebContents()->GetView()->GetTopLevelNativeWindow(), cert_); return false; // Hiding the infobar just as the dialog opens looks weird. } diff --git a/chrome/browser/task_manager/task_manager_browsertest.cc b/chrome/browser/task_manager/task_manager_browsertest.cc index 1493722..483ca65 100644 --- a/chrome/browser/task_manager/task_manager_browsertest.cc +++ b/chrome/browser/task_manager/task_manager_browsertest.cc @@ -456,7 +456,7 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, // gets reloaded and noticed in the task manager. InfoBarTabHelper* infobar_helper = chrome::GetActiveTabContents(browser())->infobar_tab_helper(); - ASSERT_EQ(1U, infobar_helper->infobar_count()); + ASSERT_EQ(1U, infobar_helper->GetInfoBarCount()); ConfirmInfoBarDelegate* delegate = infobar_helper-> GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(delegate); diff --git a/chrome/browser/translate/options_menu_model.cc b/chrome/browser/translate/options_menu_model.cc index 4680ef29..9631d8a 100644 --- a/chrome/browser/translate/options_menu_model.cc +++ b/chrome/browser/translate/options_menu_model.cc @@ -33,7 +33,7 @@ OptionsMenuModel::OptionsMenuModel( // Populate the menu. // Incognito mode does not get any preferences related items. - if (!translate_delegate->owner()->web_contents()-> + if (!translate_delegate->owner()->GetWebContents()-> GetBrowserContext()->IsOffTheRecord()) { AddCheckItem(IDC_TRANSLATE_OPTIONS_ALWAYS, l10n_util::GetStringFUTF16(IDS_TRANSLATE_INFOBAR_OPTIONS_ALWAYS, @@ -90,9 +90,9 @@ bool OptionsMenuModel::IsCommandIdEnabled(int command_id) const { // we don't report errors that happened on secure URLs. DCHECK(translate_infobar_delegate_ != NULL); DCHECK(translate_infobar_delegate_->owner() != NULL); - DCHECK(translate_infobar_delegate_->owner()->web_contents() != NULL); + DCHECK(translate_infobar_delegate_->owner()->GetWebContents() != NULL); NavigationEntry* entry = translate_infobar_delegate_->owner()-> - web_contents()->GetController().GetActiveEntry(); + GetWebContents()->GetController().GetActiveEntry(); // Delegate and tab contents should never be NULL, but active entry // can be NULL when running tests. We want to return false if NULL. return (entry != NULL) && !entry->GetURL().SchemeIsSecure(); @@ -131,7 +131,7 @@ void OptionsMenuModel::ExecuteCommand(int command_id) { case IDC_TRANSLATE_OPTIONS_ABOUT: { WebContents* web_contents = - translate_infobar_delegate_->owner()->web_contents(); + translate_infobar_delegate_->owner()->GetWebContents(); if (web_contents) { OpenURLParams params( GURL(chrome::kAboutGoogleTranslateURL), Referrer(), diff --git a/chrome/browser/translate/translate_infobar_delegate.cc b/chrome/browser/translate/translate_infobar_delegate.cc index e7e0b2e..cd0566e 100644 --- a/chrome/browser/translate/translate_infobar_delegate.cc +++ b/chrome/browser/translate/translate_infobar_delegate.cc @@ -114,29 +114,29 @@ void TranslateInfoBarDelegate::SetTargetLanguage(size_t language_index) { void TranslateInfoBarDelegate::Translate() { const std::string& original_language_code = GetOriginalLanguageCode(); - if (!owner()->web_contents()->GetBrowserContext()->IsOffTheRecord()) { + if (!owner()->GetWebContents()->GetBrowserContext()->IsOffTheRecord()) { prefs_.ResetTranslationDeniedCount(original_language_code); prefs_.IncrementTranslationAcceptedCount(original_language_code); } - TranslateManager::GetInstance()->TranslatePage(owner()->web_contents(), + TranslateManager::GetInstance()->TranslatePage(owner()->GetWebContents(), GetLanguageCodeAt(original_language_index()), GetLanguageCodeAt(target_language_index())); } void TranslateInfoBarDelegate::RevertTranslation() { - TranslateManager::GetInstance()->RevertTranslation(owner()->web_contents()); + TranslateManager::GetInstance()->RevertTranslation(owner()->GetWebContents()); RemoveSelf(); } void TranslateInfoBarDelegate::ReportLanguageDetectionError() { TranslateManager::GetInstance()-> - ReportLanguageDetectionError(owner()->web_contents()); + ReportLanguageDetectionError(owner()->GetWebContents()); } void TranslateInfoBarDelegate::TranslationDeclined() { const std::string& original_language_code = GetOriginalLanguageCode(); - if (!owner()->web_contents()->GetBrowserContext()->IsOffTheRecord()) { + if (!owner()->GetWebContents()->GetBrowserContext()->IsOffTheRecord()) { prefs_.ResetTranslationAcceptedCount(original_language_code); prefs_.IncrementTranslationDeniedCount(original_language_code); } @@ -147,7 +147,7 @@ void TranslateInfoBarDelegate::TranslationDeclined() { // happens when a load stops. That could happen multiple times, including // after the user already declined the translation.) TranslateTabHelper* helper = TabContents::FromWebContents( - owner()->web_contents())->translate_tab_helper(); + owner()->GetWebContents())->translate_tab_helper(); helper->language_state().set_translation_declined(true); } @@ -263,7 +263,7 @@ void TranslateInfoBarDelegate::MessageInfoBarButtonPressed() { return; } // This is the "Try again..." case. - TranslateManager::GetInstance()->TranslatePage(owner()->web_contents(), + TranslateManager::GetInstance()->TranslatePage(owner()->GetWebContents(), GetOriginalLanguageCode(), GetTargetLanguageCode()); } @@ -273,13 +273,13 @@ bool TranslateInfoBarDelegate::ShouldShowMessageInfoBarButton() { bool TranslateInfoBarDelegate::ShouldShowNeverTranslateButton() { DCHECK_EQ(BEFORE_TRANSLATE, type_); - return !owner()->web_contents()->GetBrowserContext()->IsOffTheRecord() && + return !owner()->GetWebContents()->GetBrowserContext()->IsOffTheRecord() && (prefs_.GetTranslationDeniedCount(GetOriginalLanguageCode()) >= 3); } bool TranslateInfoBarDelegate::ShouldShowAlwaysTranslateButton() { DCHECK_EQ(BEFORE_TRANSLATE, type_); - return !owner()->web_contents()->GetBrowserContext()->IsOffTheRecord() && + return !owner()->GetWebContents()->GetBrowserContext()->IsOffTheRecord() && (prefs_.GetTranslationAcceptedCount(GetOriginalLanguageCode()) >= 3); } @@ -402,6 +402,6 @@ TranslateInfoBarDelegate* std::string TranslateInfoBarDelegate::GetPageHost() { NavigationEntry* entry = - owner()->web_contents()->GetController().GetActiveEntry(); + owner()->GetWebContents()->GetController().GetActiveEntry(); return entry ? entry->GetURL().HostNoBrackets() : std::string(); } diff --git a/chrome/browser/translate/translate_infobar_delegate.h b/chrome/browser/translate/translate_infobar_delegate.h index 8932f36..a6affca 100644 --- a/chrome/browser/translate/translate_infobar_delegate.h +++ b/chrome/browser/translate/translate_infobar_delegate.h @@ -14,6 +14,7 @@ #include "chrome/browser/translate/translate_prefs.h" #include "chrome/common/translate_errors.h" +class InfoBarTabHelper; class PrefService; class TranslateInfoBarView; @@ -162,7 +163,7 @@ class TranslateInfoBarDelegate : public InfoBarDelegate { typedef std::pair<std::string, string16> LanguageNamePair; // InfoBarDelegate: - virtual InfoBar* CreateInfoBar(InfoBarTabHelper* infobar_helper) OVERRIDE; + virtual InfoBar* CreateInfoBar(InfoBarTabService* infobar_helper) OVERRIDE; virtual void InfoBarDismissed() OVERRIDE; virtual gfx::Image* GetIcon() const OVERRIDE; virtual InfoBarDelegate::Type GetInfoBarType() const OVERRIDE; diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc index f9de869..b0457f9 100644 --- a/chrome/browser/translate/translate_manager.cc +++ b/chrome/browser/translate/translate_manager.cc @@ -898,7 +898,7 @@ TranslateInfoBarDelegate* TranslateManager::GetTranslateInfoBarDelegate( return NULL; InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); - for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { + for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); ++i) { TranslateInfoBarDelegate* delegate = infobar_helper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); if (delegate) diff --git a/chrome/browser/translate/translate_manager_browsertest.cc b/chrome/browser/translate/translate_manager_browsertest.cc index ce72252..d1ede69 100644 --- a/chrome/browser/translate/translate_manager_browsertest.cc +++ b/chrome/browser/translate/translate_manager_browsertest.cc @@ -107,7 +107,7 @@ class TranslateManagerTest : public TabContentsTestHarness, // Returns the translate infobar if there is 1 infobar and it is a translate // infobar. TranslateInfoBarDelegate* GetTranslateInfoBar() { - return (infobar_tab_helper()->infobar_count() == 1) ? + return (infobar_tab_helper()->GetInfoBarCount() == 1) ? infobar_tab_helper()->GetInfoBarDelegateAt(0)-> AsTranslateInfoBarDelegate() : NULL; } @@ -731,18 +731,18 @@ TEST_F(TranslateManagerTest, MultipleOnPageContents) { // Simulate clicking 'Nope' (don't translate). EXPECT_TRUE(DenyTranslation()); - EXPECT_EQ(0U, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); // Send a new PageContents, we should not show an infobar. SimulateOnTranslateLanguageDetermined("fr", true); - EXPECT_EQ(0U, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); // Do the same steps but simulate closing the infobar this time. SimulateNavigation(GURL("http://www.youtube.fr"), "fr", true); EXPECT_TRUE(CloseTranslateInfoBar()); - EXPECT_EQ(0U, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); SimulateOnTranslateLanguageDetermined("fr", true); - EXPECT_EQ(0U, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); } // Test that reloading the page brings back the infobar. diff --git a/chrome/browser/ui/android/infobar_stubs.cc b/chrome/browser/ui/android/infobar_stubs.cc index e96e24a..ba34d26 100644 --- a/chrome/browser/ui/android/infobar_stubs.cc +++ b/chrome/browser/ui/android/infobar_stubs.cc @@ -8,12 +8,12 @@ // Infobars are implemented in Java on Android. -InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { +InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { NOTIMPLEMENTED(); return NULL; } -InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { +InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { NOTIMPLEMENTED(); return NULL; } diff --git a/chrome/browser/ui/auto_login_info_bar_delegate.cc b/chrome/browser/ui/auto_login_info_bar_delegate.cc index 68e4a33..bf9cb1e 100644 --- a/chrome/browser/ui/auto_login_info_bar_delegate.cc +++ b/chrome/browser/ui/auto_login_info_bar_delegate.cc @@ -176,7 +176,7 @@ AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate( registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, content::Source<Profile>(Profile::FromBrowserContext( - owner->web_contents()->GetBrowserContext()))); + owner->GetWebContents()->GetBrowserContext()))); } AutoLoginInfoBarDelegate::~AutoLoginInfoBarDelegate() { @@ -215,7 +215,7 @@ string16 AutoLoginInfoBarDelegate::GetButtonLabel( bool AutoLoginInfoBarDelegate::Accept() { // AutoLoginRedirector deletes itself. - new AutoLoginRedirector(&owner()->web_contents()->GetController(), + new AutoLoginRedirector(&owner()->GetWebContents()->GetController(), params_.args); RecordHistogramAction(HISTOGRAM_ACCEPTED); button_pressed_ = true; @@ -224,7 +224,7 @@ bool AutoLoginInfoBarDelegate::Accept() { bool AutoLoginInfoBarDelegate::Cancel() { PrefService* pref_service = TabContents::FromWebContents( - owner()->web_contents())->profile()->GetPrefs(); + owner()->GetWebContents())->profile()->GetPrefs(); pref_service->SetBoolean(prefs::kAutologinEnabled, false); RecordHistogramAction(HISTOGRAM_REJECTED); button_pressed_ = true; diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 8254e51..8a05182 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -915,7 +915,7 @@ void Browser::RegisterProtocolHandlerHelper(WebContents* web_contents, registry, handler); - for (size_t i = 0; i < infobar_helper->infobar_count(); i++) { + for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); i++) { InfoBarDelegate* delegate = infobar_helper->GetInfoBarDelegateAt(i); RegisterProtocolHandlerInfoBarDelegate* cast_delegate = delegate->AsRegisterProtocolHandlerInfoBarDelegate(); @@ -962,7 +962,7 @@ void Browser::RequestMediaAccessPermissionHelper( if (!controller->DismissInfoBarAndTakeActionOnSettings()) { InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); InfoBarDelegate* old_infobar = NULL; - for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { + for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); ++i) { old_infobar = infobar_helper->GetInfoBarDelegateAt(i)-> AsMediaStreamInfoBarDelegate(); if (old_infobar) diff --git a/chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.mm b/chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.mm index 293a773..5a1825b 100644 --- a/chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.mm @@ -38,7 +38,7 @@ NSButton* CreateNSButtonWithResourceIDAndParameter( } - (id)initWithDelegate:(InfoBarDelegate*)delegate - owner:(InfoBarTabHelper*)owner { + owner:(InfoBarTabService*)owner { if ((self = [super initWithDelegate:delegate owner:owner])) { [self initializeExtraControls]; } diff --git a/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm b/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm index ef8cb28..86c6b51 100644 --- a/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm @@ -6,10 +6,10 @@ #include <cmath> +#include "chrome/browser/api/infobars/infobar_tab_service.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_infobar_delegate.h" #include "chrome/browser/extensions/image_loading_tracker.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/ui/browser_finder.h" #import "chrome/browser/ui/cocoa/animatable_view.h" #import "chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h" @@ -140,7 +140,7 @@ class InfobarBridge : public ExtensionInfoBarDelegate::DelegateObserver, @implementation ExtensionInfoBarController - (id)initWithDelegate:(InfoBarDelegate*)delegate - owner:(InfoBarTabHelper*)owner + owner:(InfoBarTabService*)owner window:(NSWindow*)window { if ((self = [super initWithDelegate:delegate owner:owner])) { window_ = window; @@ -150,7 +150,7 @@ class InfobarBridge : public ExtensionInfoBarDelegate::DelegateObserver, extensions::ExtensionHost* extensionHost = delegate_->AsExtensionInfoBarDelegate()->extension_host(); Browser* browser = - browser::FindBrowserWithWebContents(owner->web_contents()); + browser::FindBrowserWithWebContents(owner->GetWebContents()); contextMenu_.reset([[ExtensionActionContextMenu alloc] initWithExtension:extensionHost->extension() browser:browser @@ -272,9 +272,9 @@ class InfobarBridge : public ExtensionInfoBarDelegate::DelegateObserver, @end -InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { +InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { NSWindow* window = - [(NSView*)owner->web_contents()->GetContentNativeView() window]; + [(NSView*)owner->GetWebContents()->GetContentNativeView() window]; ExtensionInfoBarController* controller = [[ExtensionInfoBarController alloc] initWithDelegate:this owner:owner diff --git a/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm b/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm index 940eca0..fe1be7b 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm @@ -144,7 +144,7 @@ class InfoBarNotificationObserver : public content::NotificationObserver { if (currentTabContents_) { InfoBarTabHelper* infobar_helper = currentTabContents_->infobar_tab_helper(); - for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { + for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); ++i) { InfoBar* infobar = infobar_helper-> GetInfoBarDelegateAt(i)->CreateInfoBar(infobar_helper); [self addInfoBar:infobar animate:NO]; diff --git a/chrome/browser/ui/cocoa/infobars/infobar_controller.h b/chrome/browser/ui/cocoa/infobars/infobar_controller.h index e3c18b2..1fc7b51 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_controller.h +++ b/chrome/browser/ui/cocoa/infobars/infobar_controller.h @@ -10,7 +10,7 @@ @class HoverCloseButton; @protocol InfoBarContainer; class InfoBarDelegate; -class InfoBarTabHelper; +class InfoBarTabService; @class InfoBarGradientView; // A controller for an infobar in the browser window. There is one @@ -20,7 +20,7 @@ class InfoBarTabHelper; @interface InfoBarController : NSViewController<NSTextViewDelegate> { @private id<InfoBarContainer> containerController_; // weak, owns us - InfoBarTabHelper* owner_; // weak + InfoBarTabService* owner_; // weak BOOL infoBarClosing_; @protected @@ -45,7 +45,7 @@ class InfoBarTabHelper; // Initializes a new InfoBarController. - (id)initWithDelegate:(InfoBarDelegate*)delegate - owner:(InfoBarTabHelper*)owner; + owner:(InfoBarTabService*)owner; // Returns YES if the infobar is owned. If this is NO, it is not safe to call // any delegate functions, since they might attempt to access the owner. Code diff --git a/chrome/browser/ui/cocoa/infobars/infobar_controller.mm b/chrome/browser/ui/cocoa/infobars/infobar_controller.mm index d7b584d..4c99c7e 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_controller.mm @@ -9,8 +9,8 @@ #include "base/mac/mac_util.h" #include "base/sys_string_conversions.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_tab_service.h" #include "chrome/browser/api/infobars/link_infobar_delegate.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #import "chrome/browser/ui/cocoa/animatable_view.h" #import "chrome/browser/ui/cocoa/browser_window_controller.h" #include "chrome/browser/ui/cocoa/event_utils.h" @@ -51,7 +51,7 @@ const float kAnimateCloseDuration = 0.12; @synthesize delegate = delegate_; - (id)initWithDelegate:(InfoBarDelegate*)delegate - owner:(InfoBarTabHelper*)owner { + owner:(InfoBarTabService*)owner { DCHECK(delegate); if ((self = [super initWithNibName:@"InfoBar" bundle:base::mac::FrameworkBundle()])) { @@ -451,13 +451,13 @@ const float kAnimateCloseDuration = 0.12; ////////////////////////////////////////////////////////////////////////// // CreateInfoBar() implementations -InfoBar* LinkInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { +InfoBar* LinkInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { LinkInfoBarController* controller = [[LinkInfoBarController alloc] initWithDelegate:this owner:owner]; return new InfoBar(controller, this); } -InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { +InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { ConfirmInfoBarController* controller = [[ConfirmInfoBarController alloc] initWithDelegate:this owner:owner]; return new InfoBar(controller, this); diff --git a/chrome/browser/ui/cocoa/infobars/media_stream_infobar_controller.h b/chrome/browser/ui/cocoa/infobars/media_stream_infobar_controller.h index 1daa635..ac6d508 100644 --- a/chrome/browser/ui/cocoa/infobars/media_stream_infobar_controller.h +++ b/chrome/browser/ui/cocoa/infobars/media_stream_infobar_controller.h @@ -10,7 +10,7 @@ #import "base/memory/scoped_nsobject.h" #include "base/memory/scoped_ptr.h" -class InfoBarTabHelper; +class InfoBarTabService; class MediaStreamDevicesMenuModel; class MediaStreamInfoBarDelegate; @class NSButton; @@ -32,7 +32,7 @@ class MediaStreamInfoBarDelegate; } - (id)initWithDelegate:(MediaStreamInfoBarDelegate*)delegate - owner:(InfoBarTabHelper*)owner; + owner:(InfoBarTabService*)owner; // Called when the selection in the device menu has changed. - (IBAction)deviceMenuChanged:(id)sender; diff --git a/chrome/browser/ui/cocoa/infobars/media_stream_infobar_controller.mm b/chrome/browser/ui/cocoa/infobars/media_stream_infobar_controller.mm index b364734..4770a2c 100644 --- a/chrome/browser/ui/cocoa/infobars/media_stream_infobar_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/media_stream_infobar_controller.mm @@ -23,7 +23,7 @@ using InfoBarUtilities::MoveControl; using InfoBarUtilities::VerifyControlOrderAndSpacing; using l10n_util::GetNSStringWithFixup; -InfoBar* MediaStreamInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { +InfoBar* MediaStreamInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { MediaStreamInfoBarController* infobar_controller = [[MediaStreamInfoBarController alloc] initWithDelegate:this owner:owner]; @@ -52,7 +52,7 @@ InfoBar* MediaStreamInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { @implementation MediaStreamInfoBarController - (id)initWithDelegate:(MediaStreamInfoBarDelegate*)delegate - owner:(InfoBarTabHelper*)owner { + owner:(InfoBarTabService*)owner { if (self = [super initWithDelegate:delegate owner:owner]) { deviceMenuModel_.reset(new MediaStreamDevicesMenuModel(delegate)); } diff --git a/chrome/browser/ui/cocoa/infobars/translate_infobar_base.mm b/chrome/browser/ui/cocoa/infobars/translate_infobar_base.mm index e13e4da..5978e5f 100644 --- a/chrome/browser/ui/cocoa/infobars/translate_infobar_base.mm +++ b/chrome/browser/ui/cocoa/infobars/translate_infobar_base.mm @@ -29,7 +29,7 @@ using InfoBarUtilities::CreateLabel; using InfoBarUtilities::AddMenuItem; // TranslateInfoBarDelegate views specific method: -InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { +InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { TranslateInfoBarControllerBase* infobar_controller = NULL; switch (type_) { case BEFORE_TRANSLATE: @@ -100,7 +100,7 @@ InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { @implementation TranslateInfoBarControllerBase - (id)initWithDelegate:(InfoBarDelegate*)delegate - owner:(InfoBarTabHelper*)owner { + owner:(InfoBarTabService*)owner { if ((self = [super initWithDelegate:delegate owner:owner])) { originalLanguageMenuModel_.reset( new LanguagesMenuModel([self delegate], diff --git a/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm b/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm index 9af09e9..fafdca5 100644 --- a/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm +++ b/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm @@ -8,6 +8,7 @@ #import "base/string_util.h" #include "base/utf_string_conversions.h" #import "chrome/app/chrome_command_ids.h" // For translate menu command ids. +#include "chrome/browser/infobars/infobar_tab_helper.h" #import "chrome/browser/translate/translate_infobar_delegate.h" #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" #import "chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.h" diff --git a/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm b/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm index 7345b25..e5763cd 100644 --- a/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm +++ b/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm @@ -39,7 +39,7 @@ namespace { class KeystonePromotionInfoBarDelegate : public ConfirmInfoBarDelegate { public: - KeystonePromotionInfoBarDelegate(InfoBarTabHelper* infobar_helper, + KeystonePromotionInfoBarDelegate(InfoBarTabService* infobar_service, PrefService* prefs); private: @@ -71,9 +71,9 @@ class KeystonePromotionInfoBarDelegate : public ConfirmInfoBarDelegate { }; KeystonePromotionInfoBarDelegate::KeystonePromotionInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarTabService* infobar_service, PrefService* prefs) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), prefs_(prefs), can_expire_(false), ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { @@ -198,7 +198,7 @@ bool KeystonePromotionInfoBarDelegate::ShouldExpireInternal( // default browser info bar works. if (tabContents) { InfoBarTabHelper* infobar_helper = tabContents->infobar_tab_helper(); - if (infobar_helper->infobar_count() == 0) { + if (infobar_helper->GetInfoBarCount() == 0) { infobar_helper->AddInfoBar( new KeystonePromotionInfoBarDelegate( infobar_helper, diff --git a/chrome/browser/ui/collected_cookies_infobar_delegate.cc b/chrome/browser/ui/collected_cookies_infobar_delegate.cc index 76ae6d1..7da616c 100644 --- a/chrome/browser/ui/collected_cookies_infobar_delegate.cc +++ b/chrome/browser/ui/collected_cookies_infobar_delegate.cc @@ -41,6 +41,6 @@ string16 CollectedCookiesInfoBarDelegate::GetButtonLabel( } bool CollectedCookiesInfoBarDelegate::Accept() { - owner()->web_contents()->GetController().Reload(true); + owner()->GetWebContents()->GetController().Reload(true); return true; } diff --git a/chrome/browser/ui/collected_cookies_infobar_delegate.h b/chrome/browser/ui/collected_cookies_infobar_delegate.h index 3493081..d8ab851 100644 --- a/chrome/browser/ui/collected_cookies_infobar_delegate.h +++ b/chrome/browser/ui/collected_cookies_infobar_delegate.h @@ -7,6 +7,8 @@ #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +class InfoBarTabHelper; + // This class configures an infobar shown when the collected cookies dialog // is closed and the settings for one or more cookies have been changed. The // user is shown a message indicating that a reload of the page is diff --git a/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc index e9ccbea..65e47e1 100644 --- a/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc @@ -7,6 +7,7 @@ #include <gtk/gtk.h> #include "base/utf_string_conversions.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/ui/gtk/event_utils.h" #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" #include "chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.h" @@ -15,8 +16,8 @@ // ConfirmInfoBarDelegate ------------------------------------------------------ -InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { - return new ConfirmInfoBarGtk(owner, this); +InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { + return new ConfirmInfoBarGtk(static_cast<InfoBarTabHelper*>(owner), this); } // ConfirmInfoBarGtk ----------------------------------------------------------- diff --git a/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc index ed28e05..694c922 100644 --- a/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc @@ -7,6 +7,7 @@ #include "base/debug/trace_event.h" #include "chrome/browser/extensions/extension_context_menu_model.h" #include "chrome/browser/extensions/extension_host.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/platform_util.h" #include "chrome/browser/ui/gtk/browser_window_gtk.h" #include "chrome/browser/ui/gtk/custom_button.h" @@ -202,6 +203,6 @@ gboolean ExtensionInfoBarGtk::OnExpose(GtkWidget* sender, return FALSE; } -InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { - return new ExtensionInfoBarGtk(owner, this); +InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { + return new ExtensionInfoBarGtk(static_cast<InfoBarTabHelper*>(owner), this); } diff --git a/chrome/browser/ui/gtk/infobars/infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/infobar_gtk.cc index 28a1499..5c93192 100644 --- a/chrome/browser/ui/gtk/infobars/infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/infobar_gtk.cc @@ -53,7 +53,7 @@ const int InfoBarGtk::kEndOfLabelSpacing = 6; InfoBarGtk::InfoBarGtk(InfoBarTabHelper* owner, InfoBarDelegate* delegate) : InfoBar(owner, delegate), theme_service_(GtkThemeService::GetFrom(Profile::FromBrowserContext( - owner->web_contents()->GetBrowserContext()))), + owner->GetWebContents()->GetBrowserContext()))), signals_(new ui::GtkSignalRegistrar) { DCHECK(delegate); // Create |hbox_| and pad the sides. diff --git a/chrome/browser/ui/gtk/infobars/link_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/link_infobar_gtk.cc index b64b556..fe8b677 100644 --- a/chrome/browser/ui/gtk/infobars/link_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/link_infobar_gtk.cc @@ -5,12 +5,13 @@ #include "chrome/browser/ui/gtk/infobars/link_infobar_gtk.h" #include "chrome/browser/api/infobars/link_infobar_delegate.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/ui/gtk/event_utils.h" // LinkInfoBarDelegate --------------------------------------------------------- -InfoBar* LinkInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { - return new LinkInfoBarGtk(owner, this); +InfoBar* LinkInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { + return new LinkInfoBarGtk(static_cast<InfoBarTabHelper*>(owner), this); } // LinkInfoBarGtk -------------------------------------------------------------- diff --git a/chrome/browser/ui/gtk/infobars/link_infobar_gtk.h b/chrome/browser/ui/gtk/infobars/link_infobar_gtk.h index dd93c0e..87bc7a6 100644 --- a/chrome/browser/ui/gtk/infobars/link_infobar_gtk.h +++ b/chrome/browser/ui/gtk/infobars/link_infobar_gtk.h @@ -10,6 +10,7 @@ #include "ui/base/gtk/gtk_signal.h" class LinkInfoBarDelegate; +class InfoBarTabHelper; // An infobar that shows a string with an embedded link. class LinkInfoBarGtk : public InfoBarGtk { diff --git a/chrome/browser/ui/gtk/infobars/media_stream_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/media_stream_infobar_gtk.cc index acc329c..b319b33 100644 --- a/chrome/browser/ui/gtk/infobars/media_stream_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/media_stream_infobar_gtk.cc @@ -7,6 +7,7 @@ #include <string> #include "base/utf_string_conversions.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/media/media_stream_devices_menu_model.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/media_stream_infobar_delegate.h" @@ -15,9 +16,9 @@ #include "ui/base/gtk/gtk_signal_registrar.h" #include "ui/base/l10n/l10n_util.h" -InfoBar* MediaStreamInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { +InfoBar* MediaStreamInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { DCHECK(owner); - return new MediaStreamInfoBarGtk(owner, this); + return new MediaStreamInfoBarGtk(static_cast<InfoBarTabHelper*>(owner), this); } MediaStreamInfoBarGtk::MediaStreamInfoBarGtk( diff --git a/chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.cc b/chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.cc index e0f7c8f..97f9438 100644 --- a/chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.cc @@ -5,6 +5,7 @@ #include "chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/translate/options_menu_model.h" #include "chrome/browser/translate/translate_infobar_delegate.h" #include "chrome/browser/ui/gtk/gtk_util.h" @@ -194,18 +195,19 @@ void TranslateInfoBarBase::OnOptionsClicked(GtkWidget* sender) { } // TranslateInfoBarDelegate specific method: -InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { +InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { + InfoBarTabHelper* helper = static_cast<InfoBarTabHelper*>(owner); TranslateInfoBarBase* infobar = NULL; switch (type_) { case BEFORE_TRANSLATE: - infobar = new BeforeTranslateInfoBar(owner, this); + infobar = new BeforeTranslateInfoBar(helper, this); break; case AFTER_TRANSLATE: - infobar = new AfterTranslateInfoBar(owner, this); + infobar = new AfterTranslateInfoBar(helper, this); break; case TRANSLATING: case TRANSLATION_ERROR: - infobar = new TranslateMessageInfoBar(owner, this); + infobar = new TranslateMessageInfoBar(helper, this); break; default: NOTREACHED(); diff --git a/chrome/browser/ui/media_stream_infobar_delegate.cc b/chrome/browser/ui/media_stream_infobar_delegate.cc index da9b342..8c0c4da 100644 --- a/chrome/browser/ui/media_stream_infobar_delegate.cc +++ b/chrome/browser/ui/media_stream_infobar_delegate.cc @@ -5,6 +5,7 @@ #include "chrome/browser/ui/media_stream_infobar_delegate.h" #include "base/logging.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "googleurl/src/gurl.h" #include "grit/theme_resources.h" #include "ui/base/resource/resource_bundle.h" diff --git a/chrome/browser/ui/media_stream_infobar_delegate.h b/chrome/browser/ui/media_stream_infobar_delegate.h index c984d77..63a73f6 100644 --- a/chrome/browser/ui/media_stream_infobar_delegate.h +++ b/chrome/browser/ui/media_stream_infobar_delegate.h @@ -11,6 +11,9 @@ #include "chrome/browser/api/infobars/infobar_delegate.h" #include "chrome/browser/media/media_stream_devices_controller.h" +class InfoBarTabHelper; +class InfoBarTabService; + // This class configures an infobar shown when a page requests access to a // user's microphone and/or video camera. The user is shown a message asking // which audio and/or video devices he wishes to use with the current page, and @@ -51,7 +54,7 @@ class MediaStreamInfoBarDelegate : public InfoBarDelegate { private: // InfoBarDelegate: - virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) OVERRIDE; + virtual InfoBar* CreateInfoBar(InfoBarTabService* owner) OVERRIDE; virtual void InfoBarDismissed() OVERRIDE; virtual gfx::Image* GetIcon() const OVERRIDE; virtual Type GetInfoBarType() const OVERRIDE; diff --git a/chrome/browser/ui/startup/autolaunch_prompt_win.cc b/chrome/browser/ui/startup/autolaunch_prompt_win.cc index c37ae8b..c39750d 100644 --- a/chrome/browser/ui/startup/autolaunch_prompt_win.cc +++ b/chrome/browser/ui/startup/autolaunch_prompt_win.cc @@ -158,7 +158,7 @@ void CheckAutoLaunchCallback(Profile* profile) { // Don't show the info-bar if there are already info-bars showing. InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); - if (infobar_helper->infobar_count() > 0) + if (infobar_helper->GetInfoBarCount() > 0) return; infobar_helper->AddInfoBar( diff --git a/chrome/browser/ui/startup/default_browser_prompt.cc b/chrome/browser/ui/startup/default_browser_prompt.cc index 6fe2518..6b92167 100644 --- a/chrome/browser/ui/startup/default_browser_prompt.cc +++ b/chrome/browser/ui/startup/default_browser_prompt.cc @@ -222,7 +222,7 @@ void NotifyNotDefaultBrowserCallback() { // Don't show the info-bar if there are already info-bars showing. InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); - if (infobar_helper->infobar_count() > 0) + if (infobar_helper->GetInfoBarCount() > 0) return; bool interactive_flow = ShellIntegration::CanSetAsDefaultBrowser() == diff --git a/chrome/browser/ui/startup/obsolete_os_info_bar.cc b/chrome/browser/ui/startup/obsolete_os_info_bar.cc index 45d59b7..4a0f935 100644 --- a/chrome/browser/ui/startup/obsolete_os_info_bar.cc +++ b/chrome/browser/ui/startup/obsolete_os_info_bar.cc @@ -42,7 +42,7 @@ bool ObsoleteOSInfoBar::LinkClicked(WindowOpenDisposition disposition) { OpenURLParams params( learn_more_url_, Referrer(), disposition, content::PAGE_TRANSITION_LINK, false); - owner()->web_contents()->OpenURL(params); + owner()->GetWebContents()->OpenURL(params); return false; } diff --git a/chrome/browser/ui/startup/session_crashed_prompt.cc b/chrome/browser/ui/startup/session_crashed_prompt.cc index fa75e04..ef6b95a 100644 --- a/chrome/browser/ui/startup/session_crashed_prompt.cc +++ b/chrome/browser/ui/startup/session_crashed_prompt.cc @@ -60,7 +60,7 @@ SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate( : ConfirmInfoBarDelegate(infobar_helper), accepted_(false), removed_notification_received_(false), - browser_(browser::FindBrowserWithWebContents(owner()->web_contents())) { + browser_(browser::FindBrowserWithWebContents(owner()->GetWebContents())) { // TODO(pkasting,marja): Once InfoBars own they delegates, this is not needed // any more. Then we can rely on delegates getting destroyed, and we can // initiate the session storage scavenging only in the destructor. (Currently, @@ -144,7 +144,7 @@ void ShowSessionCrashedPrompt(Browser* browser) { return; // Don't show the info-bar if there are already info-bars showing. - if (tab->infobar_tab_helper()->infobar_count() > 0) + if (tab->infobar_tab_helper()->GetInfoBarCount() > 0) return; tab->infobar_tab_helper()->AddInfoBar( diff --git a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc index a7ed550..3a4a1b1 100644 --- a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc +++ b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc @@ -645,7 +645,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) { EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), chrome::GetWebContentsAt(new_browser, 0)->GetURL()); EXPECT_EQ(1U, chrome::GetTabContentsAt(new_browser, 0)->infobar_tab_helper()-> - infobar_count()); + GetInfoBarCount()); // The profile which normally opens last open pages displays the new tab page. ASSERT_EQ(1u, browser::GetBrowserCount(profile_last)); @@ -655,7 +655,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) { EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), chrome::GetWebContentsAt(new_browser, 0)->GetURL()); EXPECT_EQ(1U, chrome::GetTabContentsAt(new_browser, 0)->infobar_tab_helper()-> - infobar_count()); + GetInfoBarCount()); // The profile which normally opens URLs displays the new tab page. ASSERT_EQ(1u, browser::GetBrowserCount(profile_urls)); @@ -665,6 +665,6 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) { EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), chrome::GetWebContentsAt(new_browser, 0)->GetURL()); EXPECT_EQ(1U, chrome::GetTabContentsAt(new_browser, 0)->infobar_tab_helper()-> - infobar_count()); + 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 93d437e..3534226 100644 --- a/chrome/browser/ui/sync/one_click_signin_helper.cc +++ b/chrome/browser/ui/sync/one_click_signin_helper.cc @@ -153,7 +153,7 @@ bool OneClickLoginInfoBarDelegate::Accept() { // User has accepted one-click sign-in for this account. Never ask again for // this profile. DisableOneClickSignIn(); - content::WebContents* web_contents = owner()->web_contents(); + content::WebContents* web_contents = owner()->GetWebContents(); RecordHistogramAction(one_click_signin::HISTOGRAM_ACCEPTED); browser::FindBrowserWithWebContents(web_contents)->window()-> ShowOneClickSigninBubble(base::Bind(&StartSync, web_contents, @@ -179,7 +179,7 @@ bool OneClickLoginInfoBarDelegate::LinkClicked( content::OpenURLParams params( GURL(chrome::kChromeSyncLearnMoreURL), content::Referrer(), disposition, content::PAGE_TRANSITION_LINK, false); - owner()->web_contents()->OpenURL(params); + owner()->GetWebContents()->OpenURL(params); return false; } @@ -191,7 +191,7 @@ InfoBarDelegate::InfoBarAutomationType void OneClickLoginInfoBarDelegate::DisableOneClickSignIn() { PrefService* pref_service = - TabContents::FromWebContents(owner()->web_contents())-> + TabContents::FromWebContents(owner()->GetWebContents())-> profile()->GetPrefs(); pref_service->SetBoolean(prefs::kReverseAutologinEnabled, false); } @@ -199,7 +199,7 @@ void OneClickLoginInfoBarDelegate::DisableOneClickSignIn() { void OneClickLoginInfoBarDelegate::AddEmailToOneClickRejectedList( const std::string& email) { PrefService* pref_service = - TabContents::FromWebContents(owner()->web_contents())-> + TabContents::FromWebContents(owner()->GetWebContents())-> profile()->GetPrefs(); ListPrefUpdate updater(pref_service, prefs::kReverseAutologinRejectedEmailList); diff --git a/chrome/browser/ui/views/infobars/confirm_infobar.cc b/chrome/browser/ui/views/infobars/confirm_infobar.cc index 08ed1c1..7357f8b4 100644 --- a/chrome/browser/ui/views/infobars/confirm_infobar.cc +++ b/chrome/browser/ui/views/infobars/confirm_infobar.cc @@ -7,14 +7,15 @@ #include "base/logging.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" #include "chrome/browser/event_disposition.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "ui/views/controls/button/text_button.h" #include "ui/views/controls/label.h" #include "ui/views/controls/link.h" // ConfirmInfoBarDelegate ----------------------------------------------------- -InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { - return new ConfirmInfoBar(owner, this); +InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { + return new ConfirmInfoBar(static_cast<InfoBarTabHelper*>(owner), this); } // ConfirmInfoBar ------------------------------------------------------------- diff --git a/chrome/browser/ui/views/infobars/extension_infobar.cc b/chrome/browser/ui/views/infobars/extension_infobar.cc index 9a783d7..8074f63 100644 --- a/chrome/browser/ui/views/infobars/extension_infobar.cc +++ b/chrome/browser/ui/views/infobars/extension_infobar.cc @@ -7,6 +7,7 @@ #include "chrome/browser/extensions/extension_context_menu_model.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_infobar_delegate.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/platform_util.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/common/extensions/extension.h" @@ -25,8 +26,9 @@ // ExtensionInfoBarDelegate ---------------------------------------------------- -InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { - return new ExtensionInfoBar(browser_, owner, this); +InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { + return new ExtensionInfoBar( + browser_, static_cast<InfoBarTabHelper*>(owner), this); } // ExtensionInfoBar ------------------------------------------------------------ diff --git a/chrome/browser/ui/views/infobars/link_infobar.cc b/chrome/browser/ui/views/infobars/link_infobar.cc index 49a65f4..855df60 100644 --- a/chrome/browser/ui/views/infobars/link_infobar.cc +++ b/chrome/browser/ui/views/infobars/link_infobar.cc @@ -7,13 +7,14 @@ #include "base/logging.h" #include "chrome/browser/api/infobars/link_infobar_delegate.h" #include "chrome/browser/event_disposition.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "ui/views/controls/label.h" #include "ui/views/controls/link.h" // LinkInfoBarDelegate -------------------------------------------------------- -InfoBar* LinkInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { - return new LinkInfoBar(owner, this); +InfoBar* LinkInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { + return new LinkInfoBar(static_cast<InfoBarTabHelper*>(owner), this); } // LinkInfoBar ---------------------------------------------------------------- diff --git a/chrome/browser/ui/views/infobars/media_stream_infobar.cc b/chrome/browser/ui/views/infobars/media_stream_infobar.cc index cd858f0..f065a67 100644 --- a/chrome/browser/ui/views/infobars/media_stream_infobar.cc +++ b/chrome/browser/ui/views/infobars/media_stream_infobar.cc @@ -14,9 +14,9 @@ #include "ui/views/controls/button/menu_button.h" #include "ui/views/controls/label.h" -InfoBar* MediaStreamInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { +InfoBar* MediaStreamInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { DCHECK(owner); - return new MediaStreamInfoBar(owner, this); + return new MediaStreamInfoBar(static_cast<InfoBarTabHelper*>(owner), this); } MediaStreamInfoBar::MediaStreamInfoBar( diff --git a/chrome/browser/ui/views/infobars/translate_infobar_base.cc b/chrome/browser/ui/views/infobars/translate_infobar_base.cc index b3f5e3a..908271d 100644 --- a/chrome/browser/ui/views/infobars/translate_infobar_base.cc +++ b/chrome/browser/ui/views/infobars/translate_infobar_base.cc @@ -5,6 +5,7 @@ #include "chrome/browser/ui/views/infobars/translate_infobar_base.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/translate/translate_infobar_delegate.h" #include "chrome/browser/ui/views/infobars/after_translate_infobar.h" #include "chrome/browser/ui/views/infobars/before_translate_infobar.h" @@ -18,18 +19,19 @@ // TranslateInfoBarDelegate --------------------------------------------------- -InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { +InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { + InfoBarTabHelper* helper = static_cast<InfoBarTabHelper*>(owner); TranslateInfoBarBase* infobar = NULL; switch (type_) { case BEFORE_TRANSLATE: - infobar = new BeforeTranslateInfoBar(owner, this); + infobar = new BeforeTranslateInfoBar(helper, this); break; case AFTER_TRANSLATE: - infobar = new AfterTranslateInfoBar(owner, this); + infobar = new AfterTranslateInfoBar(helper, this); break; case TRANSLATING: case TRANSLATION_ERROR: - infobar = new TranslateMessageInfoBar(owner, this); + infobar = new TranslateMessageInfoBar(helper, this); break; default: NOTREACHED(); diff --git a/chrome/browser/ui/website_settings/website_settings_infobar_delegate.cc b/chrome/browser/ui/website_settings/website_settings_infobar_delegate.cc index 61d7bfc..3b96398 100644 --- a/chrome/browser/ui/website_settings/website_settings_infobar_delegate.cc +++ b/chrome/browser/ui/website_settings/website_settings_infobar_delegate.cc @@ -42,6 +42,6 @@ string16 WebsiteSettingsInfobarDelegate::GetButtonLabel( } bool WebsiteSettingsInfobarDelegate::Accept() { - owner()->web_contents()->GetController().Reload(true); + owner()->GetWebContents()->GetController().Reload(true); return true; } diff --git a/chrome/browser/ui/website_settings/website_settings_infobar_delegate.h b/chrome/browser/ui/website_settings/website_settings_infobar_delegate.h index 88def0e..8dedb7b 100644 --- a/chrome/browser/ui/website_settings/website_settings_infobar_delegate.h +++ b/chrome/browser/ui/website_settings/website_settings_infobar_delegate.h @@ -7,6 +7,8 @@ #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +class InfoBarTabHelper; + // This class configures an infobar that is shown when the website settings UI // is closed and the settings for one or more site permissions have been // changed. The user is shown a message indicating that a reload of the page is diff --git a/chrome/browser/ui/website_settings/website_settings_unittest.cc b/chrome/browser/ui/website_settings/website_settings_unittest.cc index d8cedc0..ae9f6bdc 100644 --- a/chrome/browser/ui/website_settings/website_settings_unittest.cc +++ b/chrome/browser/ui/website_settings/website_settings_unittest.cc @@ -329,18 +329,18 @@ TEST_F(WebsiteSettingsTest, HTTPSConnectionError) { TEST_F(WebsiteSettingsTest, NoInfoBar) { SetDefaultUIExpectations(mock_ui()); - EXPECT_EQ(0u, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(0u, infobar_tab_helper()->GetInfoBarCount()); website_settings()->OnUIClosing(); - EXPECT_EQ(0u, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(0u, infobar_tab_helper()->GetInfoBarCount()); } TEST_F(WebsiteSettingsTest, ShowInfoBar) { SetDefaultUIExpectations(mock_ui()); - EXPECT_EQ(0u, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(0u, infobar_tab_helper()->GetInfoBarCount()); website_settings()->OnSitePermissionChanged( CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ALLOW); website_settings()->OnUIClosing(); - EXPECT_EQ(1u, infobar_tab_helper()->infobar_count()); + EXPECT_EQ(1u, infobar_tab_helper()->GetInfoBarCount()); // Removing an |InfoBarDelegate| from the |InfoBarTabHelper| does not delete // it. Hence the |delegate| must be cleaned up after it was removed from the diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 220b5563..cbedcc4 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -128,6 +128,7 @@ 'browser/api/infobars/confirm_infobar_delegate.h', 'browser/api/infobars/infobar_delegate.cc', 'browser/api/infobars/infobar_delegate.h', + 'browser/api/infobars/infobar_tab_service.h', 'browser/api/infobars/link_infobar_delegate.cc', 'browser/api/infobars/link_infobar_delegate.h', 'browser/api/infobars/simple_alert_infobar_delegate.cc', diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc index 93f2650..b284674 100644 --- a/chrome/test/base/ui_test_utils.cc +++ b/chrome/test/base/ui_test_utils.cc @@ -384,7 +384,7 @@ int FindInPage(TabContents* tab_contents, const string16& search_string, void CloseAllInfoBars(TabContents* tab) { InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); - while (infobar_helper->infobar_count() > 0) + while (infobar_helper->GetInfoBarCount() > 0) infobar_helper->RemoveInfoBar(infobar_helper->GetInfoBarDelegateAt(0)); } |