diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-30 15:07:08 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-30 15:07:08 +0000 |
commit | 95a33ed6cb8688573249f7cd7032d23518879c6d (patch) | |
tree | 77c2f8d28412caa3aeb6cdb94de420bb811113d6 /chrome/browser | |
parent | 14ea9bf12826e740fd77fda742e67605df06ce4a (diff) | |
download | chromium_src-95a33ed6cb8688573249f7cd7032d23518879c6d.zip chromium_src-95a33ed6cb8688573249f7cd7032d23518879c6d.tar.gz chromium_src-95a33ed6cb8688573249f7cd7032d23518879c6d.tar.bz2 |
Move infobar handling to a tab helper.
Part 2:
- Removed TabContentsWrapper from core infobar classes
- Made InfoBarTabHelper the owner of the infobar delegates
- Removed all owner references from the delegate subclasses
BUG=94741
TEST=no visible change
Review URL: http://codereview.chromium.org/7862003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103463 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
129 files changed, 694 insertions, 613 deletions
diff --git a/chrome/browser/alternate_nav_url_fetcher.cc b/chrome/browser/alternate_nav_url_fetcher.cc index a9ede47..d2df971 100644 --- a/chrome/browser/alternate_nav_url_fetcher.cc +++ b/chrome/browser/alternate_nav_url_fetcher.cc @@ -24,7 +24,7 @@ class AlternateNavInfoBarDelegate : public LinkInfoBarDelegate { public: - AlternateNavInfoBarDelegate(TabContents* tab_contents, + AlternateNavInfoBarDelegate(InfoBarTabHelper* owner, const GURL& alternate_nav_url); virtual ~AlternateNavInfoBarDelegate(); @@ -36,17 +36,15 @@ class AlternateNavInfoBarDelegate : public LinkInfoBarDelegate { virtual string16 GetLinkText() const OVERRIDE; virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; - TabContents* tab_contents_; GURL alternate_nav_url_; DISALLOW_COPY_AND_ASSIGN(AlternateNavInfoBarDelegate); }; AlternateNavInfoBarDelegate::AlternateNavInfoBarDelegate( - TabContents* tab_contents, + InfoBarTabHelper* owner, const GURL& alternate_nav_url) - : LinkInfoBarDelegate(tab_contents), - tab_contents_(tab_contents), + : LinkInfoBarDelegate(owner), alternate_nav_url_(alternate_nav_url) { } @@ -75,7 +73,7 @@ string16 AlternateNavInfoBarDelegate::GetLinkText() const { bool AlternateNavInfoBarDelegate::LinkClicked( WindowOpenDisposition disposition) { - tab_contents_->OpenURL( + owner()->tab_contents()->OpenURL( alternate_nav_url_, GURL(), disposition, // Pretend the user typed this URL, so that navigating to // it will be the default action when it's typed again in @@ -202,9 +200,11 @@ void AlternateNavURLFetcher::ShowInfobarIfPossible() { return; } - TabContents* tab_contents = controller_->tab_contents(); - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents)-> - infobar_tab_helper()->AddInfoBar(new AlternateNavInfoBarDelegate( - tab_contents, alternate_nav_url_)); + TabContentsWrapper* wrapper = + TabContentsWrapper::GetCurrentWrapperForContents( + controller_->tab_contents()); + InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); + infobar_helper->AddInfoBar( + new AlternateNavInfoBarDelegate(infobar_helper, alternate_nav_url_)); delete this; } diff --git a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc b/chrome/browser/autofill/autofill_cc_infobar_delegate.cc index a58b610..e633bdb 100644 --- a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc +++ b/chrome/browser/autofill/autofill_cc_infobar_delegate.cc @@ -15,11 +15,11 @@ #include "ui/base/resource/resource_bundle.h" AutofillCCInfoBarDelegate::AutofillCCInfoBarDelegate( - TabContents* tab_contents, + InfoBarTabHelper* infobar_helper, const CreditCard* credit_card, PersonalDataManager* personal_data, const AutofillMetrics* metric_logger) - : ConfirmInfoBarDelegate(tab_contents), + : ConfirmInfoBarDelegate(infobar_helper), credit_card_(credit_card), personal_data_(personal_data), metric_logger_(metric_logger), diff --git a/chrome/browser/autofill/autofill_cc_infobar_delegate.h b/chrome/browser/autofill/autofill_cc_infobar_delegate.h index f534631..415fe7c 100644 --- a/chrome/browser/autofill/autofill_cc_infobar_delegate.h +++ b/chrome/browser/autofill/autofill_cc_infobar_delegate.h @@ -26,7 +26,7 @@ struct LoadCommittedDetails; // card information gathered from a form submission. class AutofillCCInfoBarDelegate : public ConfirmInfoBarDelegate { public: - AutofillCCInfoBarDelegate(TabContents* tab_contents, + AutofillCCInfoBarDelegate(InfoBarTabHelper* infobar_helper, 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 fdc3d55..d51736b 100644 --- a/chrome/browser/autofill/autofill_feedback_infobar_delegate.cc +++ b/chrome/browser/autofill/autofill_feedback_infobar_delegate.cc @@ -5,20 +5,20 @@ #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/ui/browser.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/webui/bug_report_ui.h" #include "chrome/browser/userfeedback/proto/extension.pb.h" #include "content/browser/tab_contents/navigation_details.h" +#include "content/browser/tab_contents/tab_contents.h" #include "googleurl/src/gurl.h" AutofillFeedbackInfoBarDelegate::AutofillFeedbackInfoBarDelegate( - TabContents* tab_contents, + InfoBarTabHelper* infobar_helper, const string16& message, const string16& link_text, const std::string& feedback_message) - : LinkInfoBarDelegate(tab_contents), - tab_contents_(tab_contents), + : LinkInfoBarDelegate(infobar_helper), message_(message), link_text_(link_text), feedback_message_(feedback_message), @@ -49,7 +49,8 @@ bool AutofillFeedbackInfoBarDelegate::LinkClicked( #endif browser::ShowHtmlBugReportView( - Browser::GetBrowserForController(&tab_contents_->controller(), NULL), + Browser::GetBrowserForController(&owner()->tab_contents()->controller(), + NULL), feedback_message_, issue_type); return true; diff --git a/chrome/browser/autofill/autofill_feedback_infobar_delegate.h b/chrome/browser/autofill/autofill_feedback_infobar_delegate.h index 7c16863..04e4eca 100644 --- a/chrome/browser/autofill/autofill_feedback_infobar_delegate.h +++ b/chrome/browser/autofill/autofill_feedback_infobar_delegate.h @@ -17,7 +17,7 @@ class TabContents; // the Autofill developers. class AutofillFeedbackInfoBarDelegate : public LinkInfoBarDelegate { public: - AutofillFeedbackInfoBarDelegate(TabContents* tab_contents, + AutofillFeedbackInfoBarDelegate(InfoBarTabHelper* infobar_helper, const string16& message, const string16& link_text, const std::string& feedback_message); @@ -30,8 +30,6 @@ class AutofillFeedbackInfoBarDelegate : public LinkInfoBarDelegate { virtual string16 GetLinkText() const OVERRIDE; virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; - // The tab for the page with the form of interest. - TabContents* const tab_contents_; // The non-linked infobar text. const string16 message_; // The infobar link text. diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc index 4558c5a..88e49ad 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -192,8 +192,10 @@ void CheckForPopularForms(const std::vector<FormStructure*>& forms, ASCIIToUTF16(form_signature), UTF8ToUTF16((*it)->source_url().spec())); - tab_contents_wrapper->infobar_tab_helper()->AddInfoBar( - new AutofillFeedbackInfoBarDelegate(tab_contents, text, link, + InfoBarTabHelper* infobar_helper = + tab_contents_wrapper->infobar_tab_helper(); + infobar_helper->AddInfoBar( + new AutofillFeedbackInfoBarDelegate(infobar_helper, text, link, message)); break; } @@ -680,8 +682,10 @@ void AutofillManager::ImportFormData(const FormStructure& submitted_form) { // it. scoped_ptr<const CreditCard> scoped_credit_card(imported_credit_card); if (imported_credit_card && tab_contents()) { - tab_contents_wrapper_->infobar_tab_helper()->AddInfoBar( - new AutofillCCInfoBarDelegate(tab_contents(), + InfoBarTabHelper* infobar_helper = + tab_contents_wrapper_->infobar_tab_helper(); + infobar_helper->AddInfoBar( + new AutofillCCInfoBarDelegate(infobar_helper, 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 baaed3f..d5b8db4 100644 --- a/chrome/browser/autofill/autofill_metrics_unittest.cc +++ b/chrome/browser/autofill/autofill_metrics_unittest.cc @@ -17,6 +17,7 @@ #include "chrome/browser/webdata/web_data_service.h" #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" #include "chrome/test/base/testing_profile.h" +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "content/browser/browser_thread.h" #include "content/browser/tab_contents/test_tab_contents.h" #include "testing/gmock/include/gmock/gmock.h" @@ -268,8 +269,10 @@ AutofillCCInfoBarDelegate* AutofillMetricsTest::CreateDelegate( CreditCard* credit_card = new CreditCard(); if (created_card) *created_card = credit_card; - return new AutofillCCInfoBarDelegate(contents(), credit_card, - &personal_data_, metric_logger); + return new AutofillCCInfoBarDelegate(contents_wrapper()->infobar_tab_helper(), + 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 facb9cd..db7afad 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -1386,7 +1386,7 @@ InfoBarCountObserver::InfoBarCountObserver(AutomationProvider* automation, reply_message_(reply_message), tab_contents_(tab_contents), target_count_(target_count) { - Source<TabContentsWrapper> source(tab_contents); + Source<InfoBarTabHelper> source(tab_contents->infobar_tab_helper()); registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, source); registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, @@ -2325,7 +2325,7 @@ AutofillFormSubmittedObserver::AutofillFormSubmittedObserver( : automation_(automation->AsWeakPtr()), reply_message_(reply_message), pdm_(pdm), - tab_contents_(NULL) { + infobar_helper_(NULL) { pdm_->SetObserver(this); registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, NotificationService::AllSources()); @@ -2334,12 +2334,11 @@ AutofillFormSubmittedObserver::AutofillFormSubmittedObserver( AutofillFormSubmittedObserver::~AutofillFormSubmittedObserver() { pdm_->RemoveObserver(this); - if (tab_contents_) { - InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); + if (infobar_helper_) { InfoBarDelegate* infobar = NULL; - if (infobar_helper->infobar_count() > 0 && - (infobar = infobar_helper->GetInfoBarDelegateAt(0))) { - infobar_helper->RemoveInfoBar(infobar); + if (infobar_helper_->infobar_count() > 0 && + (infobar = infobar_helper_->GetInfoBarDelegateAt(0))) { + infobar_helper_->RemoveInfoBar(infobar); } } } @@ -2367,9 +2366,9 @@ void AutofillFormSubmittedObserver::Observe( DCHECK(type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED); // Accept in the infobar. - tab_contents_ = Source<TabContentsWrapper>(source).ptr(); + infobar_helper_ = Source<InfoBarTabHelper>(source).ptr(); InfoBarDelegate* infobar = NULL; - infobar = tab_contents_->infobar_tab_helper()->GetInfoBarDelegateAt(0); + infobar = infobar_helper_->GetInfoBarDelegateAt(0); ConfirmInfoBarDelegate* confirm_infobar = infobar->AsConfirmInfoBarDelegate(); if (!confirm_infobar) { diff --git a/chrome/browser/automation/automation_provider_observers.h b/chrome/browser/automation/automation_provider_observers.h index 14973c22..ffffeaf 100644 --- a/chrome/browser/automation/automation_provider_observers.h +++ b/chrome/browser/automation/automation_provider_observers.h @@ -61,6 +61,7 @@ class Browser; class Extension; class ExtensionProcessManager; class ExtensionService; +class InfoBarTabHelper; class NavigationController; class Profile; class RenderViewHost; @@ -1500,7 +1501,7 @@ class AutofillFormSubmittedObserver base::WeakPtr<AutomationProvider> automation_; scoped_ptr<IPC::Message> reply_message_; PersonalDataManager* pdm_; - TabContentsWrapper* tab_contents_; + InfoBarTabHelper* infobar_helper_; }; // Allows the automation provider to wait until all the notification diff --git a/chrome/browser/chrome_plugin_message_filter.cc b/chrome/browser/chrome_plugin_message_filter.cc index 6e73f6e..38fa099 100644 --- a/chrome/browser/chrome_plugin_message_filter.cc +++ b/chrome/browser/chrome_plugin_message_filter.cc @@ -123,14 +123,12 @@ void ChromePluginMessageFilter::HandleMissingPluginStatus( TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( host->delegate()->GetAsTabContents()); - if (!tcw) - return; + DCHECK(tcw); InfoBarTabHelper* infobar_helper = tcw->infobar_tab_helper(); if (status == webkit::npapi::default_plugin::MISSING_PLUGIN_AVAILABLE) { infobar_helper->AddInfoBar( - new PluginInstallerInfoBarDelegate( - host->delegate()->GetAsTabContents(), window)); + new PluginInstallerInfoBarDelegate(infobar_helper, window)); return; } diff --git a/chrome/browser/chrome_quota_permission_context.cc b/chrome/browser/chrome_quota_permission_context.cc index a557b64..09acedd 100644 --- a/chrome/browser/chrome_quota_permission_context.cc +++ b/chrome/browser/chrome_quota_permission_context.cc @@ -16,7 +16,6 @@ #include "chrome/common/pref_names.h" #include "content/browser/browser_thread.h" #include "content/browser/tab_contents/navigation_details.h" -#include "content/browser/tab_contents/tab_contents.h" #include "googleurl/src/gurl.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" @@ -35,13 +34,13 @@ class RequestQuotaInfoBarDelegate : public ConfirmInfoBarDelegate { typedef QuotaPermissionContext::PermissionCallback PermissionCallback; RequestQuotaInfoBarDelegate( - TabContents* tab_contents, + InfoBarTabHelper* infobar_helper, ChromeQuotaPermissionContext* context, const GURL& origin_url, int64 requested_quota, const std::string& display_languages, PermissionCallback* callback) - : ConfirmInfoBarDelegate(tab_contents), + : ConfirmInfoBarDelegate(infobar_helper), context_(context), origin_url_(origin_url), display_languages_(display_languages), @@ -144,9 +143,12 @@ void ChromeQuotaPermissionContext::RequestQuotaPermission( TabContentsWrapper* wrapper = TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); - wrapper->infobar_tab_helper()->AddInfoBar(new RequestQuotaInfoBarDelegate( - tab_contents, this, - origin_url, requested_quota, + InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); + infobar_helper->AddInfoBar(new RequestQuotaInfoBarDelegate( + infobar_helper, + this, + origin_url, + requested_quota, wrapper->profile()->GetPrefs()->GetString(prefs::kAcceptLanguages), callback.release())); } 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 e3f1653..9b5ef29 100644 --- a/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc +++ b/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc @@ -7,6 +7,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h" #include "chrome/browser/google/google_util.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/common/url_constants.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/browser/user_metrics.h" @@ -14,11 +15,10 @@ #include "ui/base/l10n/l10n_util.h" RegisterProtocolHandlerInfoBarDelegate::RegisterProtocolHandlerInfoBarDelegate( - TabContents* tab_contents, + InfoBarTabHelper* infobar_helper, ProtocolHandlerRegistry* registry, const ProtocolHandler& handler) - : ConfirmInfoBarDelegate(tab_contents), - tab_contents_(tab_contents), + : ConfirmInfoBarDelegate(infobar_helper), registry_(registry), handler_(handler) { } @@ -91,7 +91,7 @@ bool RegisterProtocolHandlerInfoBarDelegate::LinkClicked( WindowOpenDisposition disposition) { UserMetrics::RecordAction( UserMetricsAction("RegisterProtocolHandler.InfoBar_LearnMore")); - tab_contents_->OpenURL(google_util::AppendGoogleLocaleParam(GURL( + owner()->tab_contents()->OpenURL(google_util::AppendGoogleLocaleParam(GURL( chrome::kLearnMoreRegisterProtocolHandlerURL)), GURL(), (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, PageTransition::LINK); 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 6fefd20..8746713 100644 --- a/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.h +++ b/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.h @@ -11,13 +11,12 @@ #include "chrome/common/custom_handlers/protocol_handler.h" class ProtocolHandlerRegistry; -class TabContents; // 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(TabContents* tab_contents, + RegisterProtocolHandlerInfoBarDelegate(InfoBarTabHelper* infobar_helper, ProtocolHandlerRegistry* registry, const ProtocolHandler& handler); @@ -36,7 +35,6 @@ class RegisterProtocolHandlerInfoBarDelegate : public ConfirmInfoBarDelegate { private: // Returns a user-friendly name for the protocol of this protocol handler. string16 GetProtocolName(const ProtocolHandler& handler) const; - TabContents* tab_contents_; ProtocolHandlerRegistry* registry_; ProtocolHandler handler_; diff --git a/chrome/browser/download/download_request_infobar_delegate.cc b/chrome/browser/download/download_request_infobar_delegate.cc index ff33efc..7943378 100644 --- a/chrome/browser/download/download_request_infobar_delegate.cc +++ b/chrome/browser/download/download_request_infobar_delegate.cc @@ -4,16 +4,15 @@ #include "chrome/browser/download/download_request_infobar_delegate.h" -#include "content/browser/tab_contents/tab_contents.h" #include "grit/generated_resources.h" #include "grit/theme_resources_standard.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" DownloadRequestInfoBarDelegate::DownloadRequestInfoBarDelegate( - TabContents* tab, + InfoBarTabHelper* infobar_helper, DownloadRequestLimiter::TabDownloadState* host) - : ConfirmInfoBarDelegate(tab), + : ConfirmInfoBarDelegate(infobar_helper), host_(host) { } diff --git a/chrome/browser/download/download_request_infobar_delegate.h b/chrome/browser/download/download_request_infobar_delegate.h index 23ca16a..0442b8d 100644 --- a/chrome/browser/download/download_request_infobar_delegate.h +++ b/chrome/browser/download/download_request_infobar_delegate.h @@ -19,7 +19,7 @@ class TabContents; class DownloadRequestInfoBarDelegate : public ConfirmInfoBarDelegate { public: DownloadRequestInfoBarDelegate( - TabContents* tab, + InfoBarTabHelper* infobar_helper, DownloadRequestLimiter::TabDownloadState* host); void set_host(DownloadRequestLimiter::TabDownloadState* host) { diff --git a/chrome/browser/download/download_request_limiter.cc b/chrome/browser/download/download_request_limiter.cc index 011f2c1..b3e24414 100644 --- a/chrome/browser/download/download_request_limiter.cc +++ b/chrome/browser/download/download_request_limiter.cc @@ -74,10 +74,11 @@ void DownloadRequestLimiter::TabDownloadState::PromptUserForDownload( if (DownloadRequestLimiter::delegate_) { NotifyCallbacks(DownloadRequestLimiter::delegate_->ShouldAllowDownload()); } else { - infobar_ = new DownloadRequestInfoBarDelegate(tab, this); - TabContentsWrapper* wrapper = - TabContentsWrapper::GetCurrentWrapperForContents(tab); - wrapper->infobar_tab_helper()->AddInfoBar(infobar_); + InfoBarTabHelper* infobar_helper = + TabContentsWrapper::GetCurrentWrapperForContents(tab)-> + infobar_tab_helper(); + infobar_ = new DownloadRequestInfoBarDelegate(infobar_helper, this); + infobar_helper->AddInfoBar(infobar_); } } diff --git a/chrome/browser/extensions/extension_disabled_infobar_delegate.cc b/chrome/browser/extensions/extension_disabled_infobar_delegate.cc index 4f996a3..ef5894b 100644 --- a/chrome/browser/extensions/extension_disabled_infobar_delegate.cc +++ b/chrome/browser/extensions/extension_disabled_infobar_delegate.cc @@ -86,7 +86,7 @@ void ExtensionDisabledDialogDelegate::InstallUIAbort(bool user_initiated) { class ExtensionDisabledInfobarDelegate : public ConfirmInfoBarDelegate, public NotificationObserver { public: - ExtensionDisabledInfobarDelegate(TabContentsWrapper* tab_contents, + ExtensionDisabledInfobarDelegate(InfoBarTabHelper* infobar_helper, ExtensionService* service, const Extension* extension); @@ -105,17 +105,15 @@ class ExtensionDisabledInfobarDelegate : public ConfirmInfoBarDelegate, const NotificationDetails& details) OVERRIDE; NotificationRegistrar registrar_; - TabContentsWrapper* tab_contents_; ExtensionService* service_; const Extension* extension_; }; ExtensionDisabledInfobarDelegate::ExtensionDisabledInfobarDelegate( - TabContentsWrapper* tab_contents, + InfoBarTabHelper* infobar_helper, ExtensionService* service, const Extension* extension) - : ConfirmInfoBarDelegate(tab_contents->tab_contents()), - tab_contents_(tab_contents), + : ConfirmInfoBarDelegate(infobar_helper), service_(service), extension_(extension) { // The user might re-enable the extension in other ways, so watch for that. @@ -147,7 +145,7 @@ string16 ExtensionDisabledInfobarDelegate::GetButtonLabel( bool ExtensionDisabledInfobarDelegate::Accept() { // This object manages its own lifetime. - new ExtensionDisabledDialogDelegate(tab_contents_->profile(), service_, + new ExtensionDisabledDialogDelegate(service_->profile(), service_, extension_); return true; } @@ -175,7 +173,8 @@ void ExtensionDisabledInfobarDelegate::Observe( // Globals -------------------------------------------------------------------- -void ShowExtensionDisabledUI(ExtensionService* service, Profile* profile, +void ShowExtensionDisabledUI(ExtensionService* service, + Profile* profile, const Extension* extension) { Browser* browser = BrowserList::GetLastActiveWithProfile(profile); if (!browser) @@ -185,8 +184,9 @@ void ShowExtensionDisabledUI(ExtensionService* service, Profile* profile, if (!tab_contents) return; - tab_contents->infobar_tab_helper()->AddInfoBar( - new ExtensionDisabledInfobarDelegate(tab_contents, service, extension)); + InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); + infobar_helper->AddInfoBar( + new ExtensionDisabledInfobarDelegate(infobar_helper, service, extension)); } void ShowExtensionDisabledDialog(ExtensionService* service, Profile* profile, diff --git a/chrome/browser/extensions/extension_infobar_delegate.cc b/chrome/browser/extensions/extension_infobar_delegate.cc index f2da1b8..fbbf053 100644 --- a/chrome/browser/extensions/extension_infobar_delegate.cc +++ b/chrome/browser/extensions/extension_infobar_delegate.cc @@ -6,27 +6,29 @@ #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/tab_contents/infobar.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/extensions/extension.h" #include "content/common/notification_details.h" #include "content/common/notification_source.h" -ExtensionInfoBarDelegate::ExtensionInfoBarDelegate(Browser* browser, - TabContents* tab_contents, - const Extension* extension, - const GURL& url, - int height) - : InfoBarDelegate(tab_contents), - observer_(NULL), - extension_(extension), - closing_(false) { +ExtensionInfoBarDelegate::ExtensionInfoBarDelegate( + Browser* browser, + InfoBarTabHelper* infobar_helper, + const Extension* extension, + const GURL& url, + int height) + : InfoBarDelegate(infobar_helper), + observer_(NULL), + extension_(extension), + closing_(false) { ExtensionProcessManager* manager = browser->profile()->GetExtensionProcessManager(); extension_host_.reset(manager->CreateInfobarHost(url, browser)); - extension_host_->set_associated_tab_contents(tab_contents); + extension_host_->set_associated_tab_contents(infobar_helper->tab_contents()); registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, Source<Profile>(browser->profile())); diff --git a/chrome/browser/extensions/extension_infobar_delegate.h b/chrome/browser/extensions/extension_infobar_delegate.h index 8a86992..2af5881 100644 --- a/chrome/browser/extensions/extension_infobar_delegate.h +++ b/chrome/browser/extensions/extension_infobar_delegate.h @@ -15,6 +15,7 @@ class Browser; class Extension; class ExtensionHost; class GURL; +class Profile; // The InfobarDelegate for creating and managing state for the ExtensionInfobar // plus monitor when the extension goes away. @@ -31,7 +32,7 @@ class ExtensionInfoBarDelegate : public InfoBarDelegate, }; ExtensionInfoBarDelegate(Browser* browser, - TabContents* contents, + InfoBarTabHelper* infobar_helper, const Extension* extension, const GURL& url, int height); @@ -48,7 +49,7 @@ class ExtensionInfoBarDelegate : public InfoBarDelegate, virtual ~ExtensionInfoBarDelegate(); // InfoBarDelegate: - virtual InfoBar* CreateInfoBar(TabContentsWrapper* owner) OVERRIDE; + virtual InfoBar* CreateInfoBar(InfoBarTabHelper* 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_infobar_module.cc b/chrome/browser/extensions/extension_infobar_module.cc index dea559f..0032207 100644 --- a/chrome/browser/extensions/extension_infobar_module.cc +++ b/chrome/browser/extensions/extension_infobar_module.cc @@ -58,7 +58,7 @@ bool ShowInfoBarFunction::RunImpl() { } tab_contents->infobar_tab_helper()->AddInfoBar( - new ExtensionInfoBarDelegate(browser, tab_contents->tab_contents(), + new ExtensionInfoBarDelegate(browser, tab_contents->infobar_tab_helper(), GetExtension(), url, height)); // TODO(finnur): Return the actual DOMWindow object. Bug 26463. diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc index 5dabef3..14c47e4 100644 --- a/chrome/browser/extensions/extension_install_ui.cc +++ b/chrome/browser/extensions/extension_install_ui.cc @@ -394,8 +394,7 @@ void ExtensionInstallUI::ShowThemeInfoBar(const std::string& previous_theme_id, // Then either replace that old one or add a new one. InfoBarDelegate* new_delegate = GetNewThemeInstalledInfoBarDelegate( - tab_contents->tab_contents(), new_theme, previous_theme_id, - previous_using_native_theme); + tab_contents, new_theme, previous_theme_id, previous_using_native_theme); if (old_delegate) infobar_helper->ReplaceInfoBar(old_delegate, new_delegate); @@ -415,11 +414,16 @@ void ExtensionInstallUI::ShowConfirmation(PromptType prompt_type) { } InfoBarDelegate* ExtensionInstallUI::GetNewThemeInstalledInfoBarDelegate( - TabContents* tab_contents, + TabContentsWrapper* tab_contents, const Extension* new_theme, const std::string& previous_theme_id, bool previous_using_native_theme) { - return new ThemeInstalledInfoBarDelegate(tab_contents, new_theme, - previous_theme_id, - previous_using_native_theme); + Profile* profile = tab_contents->profile(); + return new ThemeInstalledInfoBarDelegate( + tab_contents->infobar_tab_helper(), + profile->GetExtensionService(), + ThemeServiceFactory::GetForProfile(profile), + new_theme, + previous_theme_id, + previous_using_native_theme); } diff --git a/chrome/browser/extensions/extension_install_ui.h b/chrome/browser/extensions/extension_install_ui.h index 105c565..171606d 100644 --- a/chrome/browser/extensions/extension_install_ui.h +++ b/chrome/browser/extensions/extension_install_ui.h @@ -22,7 +22,7 @@ class ExtensionPermissionSet; class MessageLoop; class Profile; class InfoBarDelegate; -class TabContents; +class TabContentsWrapper; // Displays all the UI around extension installation. class ExtensionInstallUI : public ImageLoadingTracker::Observer { @@ -179,7 +179,7 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer { // Returns the delegate to control the browser's info bar. This is // within its own function due to its platform-specific nature. static InfoBarDelegate* GetNewThemeInstalledInfoBarDelegate( - TabContents* tab_contents, + TabContentsWrapper* tab_contents, const Extension* new_theme, const std::string& previous_theme_id, bool previous_using_native_theme); diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.cc b/chrome/browser/extensions/theme_installed_infobar_delegate.cc index 709089c..fa3b884 100644 --- a/chrome/browser/extensions/theme_installed_infobar_delegate.cc +++ b/chrome/browser/extensions/theme_installed_infobar_delegate.cc @@ -13,7 +13,6 @@ #include "chrome/browser/themes/theme_service_factory.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/extensions/extension.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/common/notification_service.h" #include "grit/generated_resources.h" #include "grit/theme_resources_standard.h" @@ -21,13 +20,15 @@ #include "ui/base/resource/resource_bundle.h" ThemeInstalledInfoBarDelegate::ThemeInstalledInfoBarDelegate( - TabContents* tab_contents, + InfoBarTabHelper* infobar_helper, + ExtensionService* extension_service, + ThemeService* theme_service, const Extension* new_theme, const std::string& previous_theme_id, bool previous_using_native_theme) - : ConfirmInfoBarDelegate(tab_contents), - profile_(Profile::FromBrowserContext(tab_contents->browser_context())), - theme_service_(ThemeServiceFactory::GetForProfile(profile_)), + : ConfirmInfoBarDelegate(infobar_helper), + extension_service_(extension_service), + theme_service_(theme_service), name_(new_theme->name()), theme_id_(new_theme->id()), previous_theme_id_(previous_theme_id), @@ -50,14 +51,11 @@ ThemeInstalledInfoBarDelegate::~ThemeInstalledInfoBarDelegate() { bool ThemeInstalledInfoBarDelegate::Cancel() { if (!previous_theme_id_.empty()) { - ExtensionService* service = profile_->GetExtensionService(); - if (service) { - const Extension* previous_theme = - service->GetExtensionById(previous_theme_id_, true); - if (previous_theme) { - theme_service_->SetTheme(previous_theme); - return true; - } + const Extension* previous_theme = + extension_service_->GetExtensionById(previous_theme_id_, true); + if (previous_theme) { + theme_service_->SetTheme(previous_theme); + return true; } } diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.h b/chrome/browser/extensions/theme_installed_infobar_delegate.h index e54ca0a..eb1ec58 100644 --- a/chrome/browser/extensions/theme_installed_infobar_delegate.h +++ b/chrome/browser/extensions/theme_installed_infobar_delegate.h @@ -11,17 +11,19 @@ #include "content/common/notification_observer.h" #include "content/common/notification_registrar.h" -class ThemeService; class Extension; -class Profile; +class ExtensionService; class SkBitmap; +class ThemeService; // When a user installs a theme, we display it immediately, but provide an // infobar allowing them to cancel. class ThemeInstalledInfoBarDelegate : public ConfirmInfoBarDelegate, public NotificationObserver { public: - ThemeInstalledInfoBarDelegate(TabContents* tab_contents, + ThemeInstalledInfoBarDelegate(InfoBarTabHelper* infobar_helper, + ExtensionService* extension_service, + ThemeService* theme_service, const Extension* new_theme, const std::string& previous_theme_id, bool previous_using_native_theme); @@ -53,7 +55,7 @@ class ThemeInstalledInfoBarDelegate : public ConfirmInfoBarDelegate, const NotificationSource& source, const NotificationDetails& details) OVERRIDE; - Profile* profile_; + ExtensionService* extension_service_; ThemeService* theme_service_; // Name of theme that's just been installed. diff --git a/chrome/browser/external_tab_container_win.cc b/chrome/browser/external_tab_container_win.cc index 45d7e49..93cb2b7 100644 --- a/chrome/browser/external_tab_container_win.cc +++ b/chrome/browser/external_tab_container_win.cc @@ -1161,7 +1161,7 @@ void ExternalTabContainer::SetupExternalTabView() { external_tab_view_ = new views::View(); InfoBarContainerView* info_bar_container = new InfoBarContainerView(this); - info_bar_container->ChangeTabContents(tab_contents_.get()); + info_bar_container->ChangeTabContents(tab_contents_->infobar_tab_helper()); views::GridLayout* layout = new views::GridLayout(external_tab_view_); // Give this column an identifier of 0. diff --git a/chrome/browser/external_tab_container_win.h b/chrome/browser/external_tab_container_win.h index b8340db..e606cc9 100644 --- a/chrome/browser/external_tab_container_win.h +++ b/chrome/browser/external_tab_container_win.h @@ -14,8 +14,8 @@ #include "base/lazy_instance.h" #include "base/memory/scoped_ptr.h" #include "chrome/browser/automation/automation_resource_message_filter.h" +#include "chrome/browser/infobars/infobar_container.h" #include "chrome/browser/net/chrome_url_request_context.h" -#include "chrome/browser/tab_contents/infobar_container.h" #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.h" #include "chrome/browser/ui/views/frame/browser_bubble_host.h" #include "chrome/browser/ui/views/unhandled_keyboard_event_handler.h" diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context.cc index fc7af06..6288e6e 100644 --- a/chrome/browser/geolocation/chrome_geolocation_permission_context.cc +++ b/chrome/browser/geolocation/chrome_geolocation_permission_context.cc @@ -24,6 +24,7 @@ #include "content/browser/browser_thread.h" #include "content/browser/geolocation/geolocation_provider.h" #include "content/browser/renderer_host/render_view_host.h" +#include "content/browser/tab_contents/tab_contents.h" #include "content/common/content_notification_types.h" #include "content/common/notification_registrar.h" #include "content/common/notification_source.h" @@ -114,7 +115,7 @@ namespace { class GeolocationConfirmInfoBarDelegate : public ConfirmInfoBarDelegate { public: GeolocationConfirmInfoBarDelegate( - TabContents* tab_contents, + InfoBarTabHelper* infobar_helper, GeolocationInfoBarQueueController* controller, int render_process_id, int render_view_id, @@ -135,7 +136,6 @@ class GeolocationConfirmInfoBarDelegate : public ConfirmInfoBarDelegate { virtual string16 GetLinkText() const OVERRIDE; virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; - TabContents* tab_contents_; GeolocationInfoBarQueueController* controller_; int render_process_id_; int render_view_id_; @@ -147,15 +147,14 @@ class GeolocationConfirmInfoBarDelegate : public ConfirmInfoBarDelegate { }; GeolocationConfirmInfoBarDelegate::GeolocationConfirmInfoBarDelegate( - TabContents* tab_contents, + InfoBarTabHelper* infobar_helper, GeolocationInfoBarQueueController* controller, int render_process_id, int render_view_id, int bridge_id, const GURL& requesting_frame_url, const std::string& display_languages) - : ConfirmInfoBarDelegate(tab_contents), - tab_contents_(tab_contents), + : ConfirmInfoBarDelegate(infobar_helper), controller_(controller), render_process_id_(render_process_id), render_view_id_(render_view_id), @@ -192,13 +191,13 @@ string16 GeolocationConfirmInfoBarDelegate::GetButtonLabel( bool GeolocationConfirmInfoBarDelegate::Accept() { controller_->OnPermissionSet(render_process_id_, render_view_id_, bridge_id_, - requesting_frame_url_, tab_contents_->GetURL(), true); + requesting_frame_url_, owner()->tab_contents()->GetURL(), true); return true; } bool GeolocationConfirmInfoBarDelegate::Cancel() { controller_->OnPermissionSet(render_process_id_, render_view_id_, bridge_id_, - requesting_frame_url_, tab_contents_->GetURL(), false); + requesting_frame_url_, owner()->tab_contents()->GetURL(), false); return true; } @@ -215,7 +214,7 @@ bool GeolocationConfirmInfoBarDelegate::LinkClicked( "https://www.google.com/support/chrome/bin/answer.py?answer=142065"; #endif - tab_contents_->OpenURL( + owner()->tab_contents()->OpenURL( google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl)), GURL(), (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, PageTransition::LINK); @@ -463,8 +462,8 @@ void GeolocationInfoBarQueueController::ShowQueuedInfoBar(int render_process_id, Source<TabContents>(tab_contents)); } i->infobar_delegate = new GeolocationConfirmInfoBarDelegate( - tab_contents, this, render_process_id, render_view_id, i->bridge_id, - i->requesting_frame, + wrapper->infobar_tab_helper(), this, render_process_id, + render_view_id, i->bridge_id, i->requesting_frame, profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); wrapper->infobar_tab_helper()->AddInfoBar(i->infobar_delegate); } diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc index 74452f9..1a6c464 100644 --- a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc +++ b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc @@ -9,9 +9,9 @@ #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" +#include "chrome/browser/infobars/infobar.h" #include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" -#include "chrome/browser/tab_contents/infobar.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" #include "chrome/test/base/testing_profile.h" diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc index d13da5a..2ef5f8f 100644 --- a/chrome/browser/geolocation/geolocation_browsertest.cc +++ b/chrome/browser/geolocation/geolocation_browsertest.cc @@ -12,10 +12,10 @@ #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/dom_operation_notification_details.h" #include "chrome/browser/geolocation/geolocation_settings_state.h" +#include "chrome/browser/infobars/infobar.h" #include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" -#include "chrome/browser/tab_contents/infobar.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" diff --git a/chrome/browser/google/google_url_tracker.cc b/chrome/browser/google/google_url_tracker.cc index 8feabab..cdf5c15 100644 --- a/chrome/browser/google/google_url_tracker.cc +++ b/chrome/browser/google/google_url_tracker.cc @@ -21,6 +21,7 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "content/browser/tab_contents/navigation_controller.h" +#include "content/browser/tab_contents/tab_contents.h" #include "content/common/notification_service.h" #include "grit/generated_resources.h" #include "net/base/load_flags.h" @@ -31,14 +32,12 @@ namespace { -InfoBarDelegate* CreateInfobar(TabContents* tab_contents, +InfoBarDelegate* CreateInfobar(InfoBarTabHelper* infobar_helper, GoogleURLTracker* google_url_tracker, const GURL& new_google_url) { - InfoBarDelegate* infobar = new GoogleURLTrackerInfoBarDelegate(tab_contents, + InfoBarDelegate* infobar = new GoogleURLTrackerInfoBarDelegate(infobar_helper, google_url_tracker, new_google_url); - TabContentsWrapper* wrapper = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); - wrapper->infobar_tab_helper()->AddInfoBar(infobar); + infobar_helper->AddInfoBar(infobar); return infobar; } @@ -47,13 +46,12 @@ InfoBarDelegate* CreateInfobar(TabContents* tab_contents, // GoogleURLTrackerInfoBarDelegate -------------------------------------------- GoogleURLTrackerInfoBarDelegate::GoogleURLTrackerInfoBarDelegate( - TabContents* tab_contents, + InfoBarTabHelper* infobar_helper, GoogleURLTracker* google_url_tracker, const GURL& new_google_url) - : ConfirmInfoBarDelegate(tab_contents), + : ConfirmInfoBarDelegate(infobar_helper), google_url_tracker_(google_url_tracker), - new_google_url_(new_google_url), - tab_contents_(tab_contents) { + new_google_url_(new_google_url) { } bool GoogleURLTrackerInfoBarDelegate::Accept() { @@ -73,7 +71,7 @@ string16 GoogleURLTrackerInfoBarDelegate::GetLinkText() const { bool GoogleURLTrackerInfoBarDelegate::LinkClicked( WindowOpenDisposition disposition) { - tab_contents_->OpenURL(google_util::AppendGoogleLocaleParam(GURL( + owner()->tab_contents()->OpenURL(google_util::AppendGoogleLocaleParam(GURL( "https://www.google.com/support/chrome/bin/answer.py?answer=1618699")), GURL(), (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, PageTransition::LINK); @@ -382,5 +380,12 @@ void GoogleURLTracker::ShowGoogleURLInfoBarIfNecessary( return; DCHECK(!fetched_google_url_.is_empty()); - infobar_ = (*infobar_creator_)(tab_contents, this, fetched_google_url_); + // |tab_contents| can be NULL during tests. + InfoBarTabHelper* infobar_helper = NULL; + if (tab_contents) { + TabContentsWrapper* wrapper = + TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); + infobar_helper = wrapper->infobar_tab_helper(); + } + infobar_ = (*infobar_creator_)(infobar_helper, this, fetched_google_url_); } diff --git a/chrome/browser/google/google_url_tracker.h b/chrome/browser/google/google_url_tracker.h index 5fd97ce..f784326 100644 --- a/chrome/browser/google/google_url_tracker.h +++ b/chrome/browser/google/google_url_tracker.h @@ -85,7 +85,7 @@ class GoogleURLTracker : public URLFetcher::Delegate, private: friend class GoogleURLTrackerTest; - typedef InfoBarDelegate* (*InfobarCreator)(TabContents*, + typedef InfoBarDelegate* (*InfobarCreator)(InfoBarTabHelper*, GoogleURLTracker*, const GURL&); @@ -164,7 +164,7 @@ class GoogleURLTracker : public URLFetcher::Delegate, // code can subclass it. class GoogleURLTrackerInfoBarDelegate : public ConfirmInfoBarDelegate { public: - GoogleURLTrackerInfoBarDelegate(TabContents* tab_contents, + GoogleURLTrackerInfoBarDelegate(InfoBarTabHelper* infobar_helper, GoogleURLTracker* google_url_tracker, const GURL& new_google_url); @@ -188,8 +188,6 @@ class GoogleURLTrackerInfoBarDelegate : public ConfirmInfoBarDelegate { // Returns the portion of the appropriate hostname to display. string16 GetHost(bool new_host) const; - TabContents* tab_contents_; - DISALLOW_COPY_AND_ASSIGN(GoogleURLTrackerInfoBarDelegate); }; diff --git a/chrome/browser/google/google_url_tracker_unittest.cc b/chrome/browser/google/google_url_tracker_unittest.cc index 0aa1be6..07561fd 100644 --- a/chrome/browser/google/google_url_tracker_unittest.cc +++ b/chrome/browser/google/google_url_tracker_unittest.cc @@ -68,7 +68,7 @@ class TestInfoBarDelegate : public InfoBarDelegate { virtual ~TestInfoBarDelegate(); // InfoBarDelegate: - virtual InfoBar* CreateInfoBar(TabContentsWrapper* owner); + virtual InfoBar* CreateInfoBar(InfoBarTabHelper* infobar_helper) OVERRIDE; GoogleURLTracker* google_url_tracker_; GURL new_google_url_; @@ -84,12 +84,12 @@ TestInfoBarDelegate::TestInfoBarDelegate(GoogleURLTracker* google_url_tracker, TestInfoBarDelegate::~TestInfoBarDelegate() { } -InfoBar* TestInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { +InfoBar* TestInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* infobar_helper) { return NULL; } InfoBarDelegate* CreateTestInfobar( - TabContents* tab_contents, + InfoBarTabHelper* infobar_helper, GoogleURLTracker* google_url_tracker, const GURL& new_google_url) { return new TestInfoBarDelegate(google_url_tracker, new_google_url); diff --git a/chrome/browser/tab_contents/infobar.cc b/chrome/browser/infobars/infobar.cc index 788ef11..f909d23 100644 --- a/chrome/browser/tab_contents/infobar.cc +++ b/chrome/browser/infobars/infobar.cc @@ -2,15 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/tab_contents/infobar.h" +#include "chrome/browser/infobars/infobar.h" #include <cmath> #include "build/build_config.h" #include "base/logging.h" +#include "chrome/browser/infobars/infobar_container.h" #include "chrome/browser/infobars/infobar_tab_helper.h" -#include "chrome/browser/tab_contents/infobar_container.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "ui/base/animation/slide_animation.h" SkColor GetInfoBarTopColor(InfoBarDelegate::Type infobar_type) { @@ -40,7 +39,7 @@ SkColor GetInfoBarBottomColor(InfoBarDelegate::Type infobar_type) { // TODO(pkasting): Port Mac to use this. #if defined(TOOLKIT_VIEWS) || defined(TOOLKIT_GTK) -InfoBar::InfoBar(TabContentsWrapper* owner, InfoBarDelegate* delegate) +InfoBar::InfoBar(InfoBarTabHelper* owner, InfoBarDelegate* delegate) : owner_(owner), delegate_(delegate), container_(NULL), @@ -104,7 +103,7 @@ void InfoBar::AnimationProgressed(const ui::Animation* animation) { void InfoBar::RemoveSelf() { DCHECK(owner_); - owner_->infobar_tab_helper()->RemoveInfoBar(delegate_); + owner_->RemoveInfoBar(delegate_); } void InfoBar::SetBarTargetHeight(int height) { diff --git a/chrome/browser/tab_contents/infobar.h b/chrome/browser/infobars/infobar.h index 3149137..35095f4 100644 --- a/chrome/browser/tab_contents/infobar.h +++ b/chrome/browser/infobars/infobar.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_TAB_CONTENTS_INFOBAR_H_ -#define CHROME_BROWSER_TAB_CONTENTS_INFOBAR_H_ +#ifndef CHROME_BROWSER_INFOBARS_INFOBAR_H_ +#define CHROME_BROWSER_INFOBARS_INFOBAR_H_ #pragma once #include <utility> @@ -11,7 +11,7 @@ #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "build/build_config.h" -#include "chrome/browser/tab_contents/infobar_delegate.h" +#include "chrome/browser/infobars/infobar_delegate.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/base/animation/animation_delegate.h" #include "ui/base/animation/slide_animation.h" @@ -31,11 +31,11 @@ typedef std::pair<InfoBarDelegate*, InfoBarDelegate*> InfoBarReplacedDetails; #if defined(TOOLKIT_VIEWS) || defined(TOOLKIT_GTK) class InfoBarContainer; -class TabContentsWrapper; +class InfoBarTabHelper; class InfoBar : public ui::AnimationDelegate { public: - InfoBar(TabContentsWrapper* owner, InfoBarDelegate* delegate); + InfoBar(InfoBarTabHelper* owner, InfoBarDelegate* delegate); virtual ~InfoBar(); // Platforms must define these. @@ -119,7 +119,7 @@ class InfoBar : public ui::AnimationDelegate { // delete us) and closes the delegate. void MaybeDelete(); - TabContentsWrapper* owner_; + InfoBarTabHelper* owner_; InfoBarDelegate* delegate_; InfoBarContainer* container_; ui::SlideAnimation animation_; @@ -140,4 +140,4 @@ class InfoBar : public ui::AnimationDelegate { #include "chrome/browser/ui/cocoa/infobars/infobar.h" #endif -#endif // CHROME_BROWSER_TAB_CONTENTS_INFOBAR_H_ +#endif // CHROME_BROWSER_INFOBARS_INFOBAR_H_ diff --git a/chrome/browser/tab_contents/infobar_container.cc b/chrome/browser/infobars/infobar_container.cc index e01d38a..c3e74a6 100644 --- a/chrome/browser/tab_contents/infobar_container.cc +++ b/chrome/browser/infobars/infobar_container.cc @@ -7,12 +7,13 @@ // TODO(pkasting): Port Mac to use this. #if defined(TOOLKIT_VIEWS) || defined(TOOLKIT_GTK) -#include "chrome/browser/tab_contents/infobar_container.h" +#include "chrome/browser/infobars/infobar_container.h" +#include <algorithm> + +#include "chrome/browser/infobars/infobar.h" +#include "chrome/browser/infobars/infobar_delegate.h" #include "chrome/browser/infobars/infobar_tab_helper.h" -#include "chrome/browser/tab_contents/infobar.h" -#include "chrome/browser/tab_contents/infobar_delegate.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_notification_types.h" #include "content/common/notification_details.h" #include "content/common/notification_source.h" @@ -23,7 +24,7 @@ InfoBarContainer::Delegate::~Delegate() { InfoBarContainer::InfoBarContainer(Delegate* delegate) : delegate_(delegate), - tab_contents_(NULL), + tab_helper_(NULL), top_arrow_target_height_(InfoBar::kDefaultArrowTargetHeight) { } @@ -32,7 +33,7 @@ InfoBarContainer::~InfoBarContainer() { DCHECK(infobars_.empty()); } -void InfoBarContainer::ChangeTabContents(TabContentsWrapper* contents) { +void InfoBarContainer::ChangeTabContents(InfoBarTabHelper* tab_helper) { registrar_.RemoveAll(); while (!infobars_.empty()) { @@ -42,24 +43,21 @@ void InfoBarContainer::ChangeTabContents(TabContentsWrapper* contents) { infobar->Hide(false); } - tab_contents_ = contents; - if (tab_contents_) { - Source<TabContentsWrapper> tc_source(tab_contents_); + tab_helper_ = tab_helper; + if (tab_helper_) { + Source<InfoBarTabHelper> th_source(tab_helper_); registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, - tc_source); + th_source); registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - tc_source); + th_source); registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED, - tc_source); + th_source); - for (size_t i = 0; - i < tab_contents_->infobar_tab_helper()->infobar_count(); - ++i) { + for (size_t i = 0; i < tab_helper_->infobar_count(); ++i) { // As when we removed the infobars above, we prevent callbacks to // OnInfoBarAnimated() for each infobar. AddInfoBar( - tab_contents_->infobar_tab_helper()->GetInfoBarDelegateAt(i)-> - CreateInfoBar(tab_contents_), + tab_helper_->GetInfoBarDelegateAt(i)->CreateInfoBar(tab_helper_), i, false, NO_CALLBACK); } } @@ -131,7 +129,7 @@ void InfoBarContainer::Observe(int type, switch (type) { case chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED: AddInfoBar( - Details<InfoBarAddedDetails>(details)->CreateInfoBar(tab_contents_), + Details<InfoBarAddedDetails>(details)->CreateInfoBar(tab_helper_), infobars_.size(), true, WANT_CALLBACK); break; @@ -145,7 +143,7 @@ void InfoBarContainer::Observe(int type, case chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED: { InfoBarReplacedDetails* replaced_details = Details<InfoBarReplacedDetails>(details).ptr(); - AddInfoBar(replaced_details->second->CreateInfoBar(tab_contents_), + AddInfoBar(replaced_details->second->CreateInfoBar(tab_helper_), HideInfoBar(replaced_details->first, false), false, WANT_CALLBACK); break; } @@ -159,7 +157,7 @@ void InfoBarContainer::Observe(int type, size_t InfoBarContainer::HideInfoBar(InfoBarDelegate* delegate, bool use_animation) { // Search for the infobar associated with |delegate|. We cannot search for - // |delegate| in |tab_contents_|, because an InfoBar remains alive until its + // |delegate| in |tab_helper_|, because an InfoBar remains alive until its // close animation completes, while the delegate is removed from the tab // immediately. for (InfoBars::iterator i(infobars_.begin()); i != infobars_.end(); ++i) { diff --git a/chrome/browser/tab_contents/infobar_container.h b/chrome/browser/infobars/infobar_container.h index 01d310c..ff63fa5 100644 --- a/chrome/browser/tab_contents/infobar_container.h +++ b/chrome/browser/infobars/infobar_container.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_TAB_CONTENTS_INFOBAR_CONTAINER_H_ -#define CHROME_BROWSER_TAB_CONTENTS_INFOBAR_CONTAINER_H_ +#ifndef CHROME_BROWSER_INFOBARS_INFOBAR_CONTAINER_H_ +#define CHROME_BROWSER_INFOBARS_INFOBAR_CONTAINER_H_ #pragma once #include <vector> @@ -15,7 +15,7 @@ class InfoBar; class InfoBarDelegate; -class TabContentsWrapper; +class InfoBarTabHelper; // InfoBarContainer is a cross-platform base class to handle the visibility- // related aspects of InfoBars. While InfoBars own themselves, the @@ -46,10 +46,10 @@ class InfoBarContainer : public NotificationObserver { explicit InfoBarContainer(Delegate* delegate); virtual ~InfoBarContainer(); - // Changes the TabContentsWrapper for which this container is showing + // Changes the InfoBarTabHelper for which this container is showing // infobars. This will remove all current infobars from the container, add // the infobars from |contents|, and show them all. |contents| may be NULL. - void ChangeTabContents(TabContentsWrapper* contents); + void ChangeTabContents(InfoBarTabHelper* tab_helper); // Returns the amount by which to overlap the toolbar above, and, when // |total_height| is non-NULL, set it to the height of the InfoBarContainer @@ -101,7 +101,7 @@ class InfoBarContainer : public NotificationObserver { const NotificationDetails& details) OVERRIDE; // Hides an InfoBar for the specified delegate, in response to a notification - // from the selected TabContentsWrapper. The InfoBar's disappearance will be + // from the selected InfoBarTabHelper. The InfoBar's disappearance will be // animated if |use_animation| is true. The InfoBar will call back to // RemoveInfoBar() to remove itself once it's hidden (which may mean // synchronously). Returns the position within |infobars_| the infobar was @@ -124,7 +124,7 @@ class InfoBarContainer : public NotificationObserver { NotificationRegistrar registrar_; Delegate* delegate_; - TabContentsWrapper* tab_contents_; + InfoBarTabHelper* tab_helper_; InfoBars infobars_; // Calculated in SetMaxTopArrowHeight(). @@ -133,4 +133,4 @@ class InfoBarContainer : public NotificationObserver { DISALLOW_COPY_AND_ASSIGN(InfoBarContainer); }; -#endif // CHROME_BROWSER_TAB_CONTENTS_INFOBAR_CONTAINER_H_ +#endif // CHROME_BROWSER_INFOBARS_INFOBAR_CONTAINER_H_ diff --git a/chrome/browser/tab_contents/infobar_delegate.cc b/chrome/browser/infobars/infobar_delegate.cc index e2b9477..0f13590 100644 --- a/chrome/browser/tab_contents/infobar_delegate.cc +++ b/chrome/browser/infobars/infobar_delegate.cc @@ -2,12 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/tab_contents/infobar_delegate.h" +#include "chrome/browser/infobars/infobar_delegate.h" #include "base/logging.h" #include "build/build_config.h" #include "chrome/browser/infobars/infobar_tab_helper.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "content/browser/tab_contents/navigation_details.h" #include "content/browser/tab_contents/navigation_entry.h" #include "content/browser/tab_contents/tab_contents.h" @@ -75,15 +74,17 @@ TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() { return NULL; } -InfoBarDelegate::InfoBarDelegate(TabContents* contents) +InfoBarDelegate::InfoBarDelegate(InfoBarTabHelper* infobar_helper) : contents_unique_id_(0), - owner_(contents) { - if (contents) - StoreActiveEntryUniqueID(contents); + owner_(infobar_helper) { + if (infobar_helper) + StoreActiveEntryUniqueID(infobar_helper); } -void InfoBarDelegate::StoreActiveEntryUniqueID(TabContents* contents) { - NavigationEntry* active_entry = contents->controller().GetActiveEntry(); +void InfoBarDelegate::StoreActiveEntryUniqueID( + InfoBarTabHelper* infobar_helper) { + NavigationEntry* active_entry = + infobar_helper->tab_contents()->controller().GetActiveEntry(); contents_unique_id_ = active_entry ? active_entry->unique_id() : 0; } @@ -95,8 +96,6 @@ bool InfoBarDelegate::ShouldExpireInternal( } void InfoBarDelegate::RemoveSelf() { - if (owner_) { - TabContentsWrapper::GetCurrentWrapperForContents(owner_)-> - infobar_tab_helper()->RemoveInfoBar(this); // Clears |owner_|. - } + if (owner_) + owner_->RemoveInfoBar(this); // Clears |owner_|. } diff --git a/chrome/browser/tab_contents/infobar_delegate.h b/chrome/browser/infobars/infobar_delegate.h index 29faba8..22f8152 100644 --- a/chrome/browser/tab_contents/infobar_delegate.h +++ b/chrome/browser/infobars/infobar_delegate.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ -#define CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ +#ifndef CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_ +#define CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_ #pragma once #include "base/basictypes.h" @@ -13,11 +13,10 @@ class ConfirmInfoBarDelegate; class ExtensionInfoBarDelegate; class InfoBar; +class InfoBarTabHelper; class InsecureContentInfoBarDelegate; class LinkInfoBarDelegate; class PluginInstallerInfoBarDelegate; -class TabContents; -class TabContentsWrapper; class ThemeInstalledInfoBarDelegate; class TranslateInfoBarDelegate; @@ -46,16 +45,19 @@ class InfoBarDelegate { // Called to create the InfoBar. Implementation of this method is // platform-specific. - virtual InfoBar* CreateInfoBar(TabContentsWrapper* owner) = 0; + virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) = 0; - // Called by the TabContentsWrapper when it removes us. + // Called by the InfoBarTabHelper when it removes us. void clear_owner() { owner_ = NULL; } + // TODO(pkasting): Move to InfoBar once InfoBars own their delegates. + InfoBarTabHelper* owner() { return owner_; } + // 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 - // TabContentsWrapper when determining whether or not a delegate should be + // InfoBarTabHelper when determining whether or not a delegate should be // added because a matching one already exists. If this function returns true, - // the TabContentsWrapper will not add the new delegate because it considers + // the InfoBarTabHelper will not add the new delegate because it considers // one to already be present. virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; @@ -92,12 +94,12 @@ class InfoBarDelegate { protected: // If |contents| is non-NULL, its active entry's unique ID will be stored // using StoreActiveEntryUniqueID automatically. - explicit InfoBarDelegate(TabContents* contents); + explicit InfoBarDelegate(InfoBarTabHelper* infobar_helper); // Store the unique id for the active entry in the specified TabContents, to // be used later upon navigation to determine if this InfoBarDelegate should // be expired from |contents_|. - void StoreActiveEntryUniqueID(TabContents* contents); + void StoreActiveEntryUniqueID(InfoBarTabHelper* infobar_helper); // Returns true if the navigation is to a new URL or a reload occured. bool ShouldExpireInternal( @@ -113,9 +115,9 @@ class InfoBarDelegate { int contents_unique_id_; // TODO(pkasting): Remove. - TabContents* owner_; + InfoBarTabHelper* owner_; DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); }; -#endif // CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ +#endif // CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_ diff --git a/chrome/browser/infobars/infobar_tab_helper.cc b/chrome/browser/infobars/infobar_tab_helper.cc index 4109189..12dbb27 100644 --- a/chrome/browser/infobars/infobar_tab_helper.cc +++ b/chrome/browser/infobars/infobar_tab_helper.cc @@ -4,19 +4,17 @@ #include "chrome/browser/infobars/infobar_tab_helper.h" -#include "chrome/browser/tab_contents/infobar.h" -#include "chrome/browser/tab_contents/infobar_delegate.h" +#include "chrome/browser/infobars/infobar.h" +#include "chrome/browser/infobars/infobar_delegate.h" #include "chrome/browser/tab_contents/insecure_content_infobar_delegate.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/render_messages.h" #include "content/common/notification_service.h" #include "content/browser/tab_contents/tab_contents.h" -InfoBarTabHelper::InfoBarTabHelper(TabContentsWrapper* tab_contents) - : TabContentsObserver(tab_contents->tab_contents()), - infobars_enabled_(true), - tab_contents_wrapper_(tab_contents) { +InfoBarTabHelper::InfoBarTabHelper(TabContents* tab_contents) + : TabContentsObserver(tab_contents), + infobars_enabled_(true) { DCHECK(tab_contents); } @@ -43,10 +41,12 @@ void InfoBarTabHelper::AddInfoBar(InfoBarDelegate* delegate) { } } + // TODO(pkasting): Consider removing InfoBarTabHelper arg from delegate + // constructors and instead using a setter from here. infobars_.push_back(delegate); NotificationService::current()->Notify( chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, - Source<TabContentsWrapper>(tab_contents_wrapper_), + Source<InfoBarTabHelper>(this), Details<InfoBarAddedDetails>(delegate)); // Add ourselves as an observer for navigations the first time a delegate is @@ -82,7 +82,7 @@ void InfoBarTabHelper::ReplaceInfoBar(InfoBarDelegate* old_delegate, InfoBarReplacedDetails replaced_details(old_delegate, new_delegate); NotificationService::current()->Notify( chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED, - Source<TabContentsWrapper>(tab_contents_wrapper_), + Source<InfoBarTabHelper>(this), Details<InfoBarReplacedDetails>(&replaced_details)); infobars_.erase(infobars_.begin() + i + 1); @@ -111,7 +111,7 @@ void InfoBarTabHelper::RemoveInfoBarInternal(InfoBarDelegate* delegate, InfoBarRemovedDetails removed_details(infobar, animate); NotificationService::current()->Notify( chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - Source<TabContentsWrapper>(tab_contents_wrapper_), + Source<InfoBarTabHelper>(this), Details<InfoBarRemovedDetails>(&removed_details)); infobars_.erase(infobars_.begin() + i); @@ -133,7 +133,7 @@ void InfoBarTabHelper::OnDidBlockDisplayingInsecureContent() { if (GetInfoBarDelegateAt(i)->AsInsecureContentInfoBarDelegate()) return; } - AddInfoBar(new InsecureContentInfoBarDelegate(tab_contents_wrapper_, + AddInfoBar(new InsecureContentInfoBarDelegate(this, InsecureContentInfoBarDelegate::DISPLAY)); } @@ -145,13 +145,12 @@ void InfoBarTabHelper::OnDidBlockRunningInsecureContent() { if (delegate) { if (delegate->type() != InsecureContentInfoBarDelegate::RUN) { ReplaceInfoBar(delegate, new InsecureContentInfoBarDelegate( - tab_contents_wrapper_, - InsecureContentInfoBarDelegate::RUN)); + this, InsecureContentInfoBarDelegate::RUN)); } return; } } - AddInfoBar(new InsecureContentInfoBarDelegate(tab_contents_wrapper_, + AddInfoBar(new InsecureContentInfoBarDelegate(this, InsecureContentInfoBarDelegate::RUN)); } diff --git a/chrome/browser/infobars/infobar_tab_helper.h b/chrome/browser/infobars/infobar_tab_helper.h index 9d15d36..5fec0b6 100644 --- a/chrome/browser/infobars/infobar_tab_helper.h +++ b/chrome/browser/infobars/infobar_tab_helper.h @@ -11,13 +11,13 @@ #include "content/common/notification_registrar.h" class InfoBarDelegate; -class TabContentsWrapper; +class TabContents; // Per-tab info bar manager. class InfoBarTabHelper : public TabContentsObserver, public NotificationObserver { public: - explicit InfoBarTabHelper(TabContentsWrapper* tab_contents); + explicit InfoBarTabHelper(TabContents* tab_contents); virtual ~InfoBarTabHelper(); // Adds an InfoBar for the specified |delegate|. @@ -58,6 +58,11 @@ class InfoBarTabHelper : public TabContentsObserver, const NotificationSource& source, const NotificationDetails& details) OVERRIDE; + // Helper functions for infobars: + TabContents* tab_contents() { + return TabContentsObserver::tab_contents(); + } + private: void RemoveInfoBarInternal(InfoBarDelegate* delegate, bool animate); void RemoveAllInfoBars(bool animate); @@ -72,9 +77,6 @@ class InfoBarTabHelper : public TabContentsObserver, NotificationRegistrar registrar_; - // Owning TabContentsWrapper. - TabContentsWrapper* tab_contents_wrapper_; - DISALLOW_COPY_AND_ASSIGN(InfoBarTabHelper); }; diff --git a/chrome/browser/tab_contents/infobars_uitest.cc b/chrome/browser/infobars/infobars_uitest.cc index e9eaa75..e9eaa75 100644 --- a/chrome/browser/tab_contents/infobars_uitest.cc +++ b/chrome/browser/infobars/infobars_uitest.cc diff --git a/chrome/browser/intents/register_intent_handler_infobar_delegate.cc b/chrome/browser/intents/register_intent_handler_infobar_delegate.cc index 58206dc..4c711e4 100644 --- a/chrome/browser/intents/register_intent_handler_infobar_delegate.cc +++ b/chrome/browser/intents/register_intent_handler_infobar_delegate.cc @@ -9,15 +9,15 @@ #include "chrome/browser/intents/web_intents_registry.h" #include "chrome/browser/intents/web_intents_registry_factory.h" #include "chrome/browser/profiles/profile.h" -#include "content/browser/tab_contents/tab_contents.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" RegisterIntentHandlerInfoBarDelegate::RegisterIntentHandlerInfoBarDelegate( - TabContents* tab_contents, const WebIntentServiceData& service) - : ConfirmInfoBarDelegate(tab_contents), - tab_contents_(tab_contents), - profile_(Profile::FromBrowserContext(tab_contents->browser_context())), + InfoBarTabHelper* infobar_helper, + WebIntentsRegistry* registry, + const WebIntentServiceData& service) + : ConfirmInfoBarDelegate(infobar_helper), + registry_(registry), service_(service) { } @@ -45,9 +45,7 @@ string16 RegisterIntentHandlerInfoBarDelegate::GetButtonLabel( } bool RegisterIntentHandlerInfoBarDelegate::Accept() { - WebIntentsRegistry* registry = - WebIntentsRegistryFactory::GetForProfile(profile_); - registry->RegisterIntentProvider(service_); + registry_->RegisterIntentProvider(service_); return true; } diff --git a/chrome/browser/intents/register_intent_handler_infobar_delegate.h b/chrome/browser/intents/register_intent_handler_infobar_delegate.h index cd887e1..83ae2fa 100644 --- a/chrome/browser/intents/register_intent_handler_infobar_delegate.h +++ b/chrome/browser/intents/register_intent_handler_infobar_delegate.h @@ -11,14 +11,15 @@ #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" #include "webkit/glue/web_intent_service_data.h" -class Profile; class TabContents; +class WebIntentsRegistry; // The InfoBar used to request permission for a site to be registered as an // Intent handler. class RegisterIntentHandlerInfoBarDelegate : public ConfirmInfoBarDelegate { public: - RegisterIntentHandlerInfoBarDelegate(TabContents* tab_contents, + RegisterIntentHandlerInfoBarDelegate(InfoBarTabHelper* infobar_helper, + WebIntentsRegistry* registry, const WebIntentServiceData& service); // ConfirmInfoBarDelegate implementation. @@ -30,11 +31,8 @@ class RegisterIntentHandlerInfoBarDelegate : public ConfirmInfoBarDelegate { virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; private: - // The TabContents that contains this InfoBar. Weak pointer. - TabContents* tab_contents_; - - // The profile associated with |tab_contents_|. Weak pointer. - Profile* profile_; + // The web intents registry to use. Weak pointer. + WebIntentsRegistry* registry_; // The cached intent data bundle passed up from the renderer. WebIntentServiceData service_; diff --git a/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc b/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc index 56b08d5..32dcfac 100644 --- a/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc +++ b/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc @@ -2,15 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/memory/scoped_ptr.h" #include "base/utf_string_conversions.h" #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" #include "chrome/browser/intents/web_intents_registry.h" #include "chrome/browser/intents/web_intents_registry_factory.h" -#include "chrome/test/base/chrome_render_view_host_test_harness.h" +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" +#include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" #include "chrome/test/base/testing_profile.h" #include "content/browser/browser_thread.h" -#include "content/browser/site_instance.h" #include "content/browser/tab_contents/test_tab_contents.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -34,30 +33,24 @@ MockWebIntentsRegistry* BuildForProfile(Profile* profile) { } class RegisterIntentHandlerInfoBarDelegateTest - : public ChromeRenderViewHostTestHarness { + : public TabContentsWrapperTestHarness { protected: RegisterIntentHandlerInfoBarDelegateTest() : ui_thread_(BrowserThread::UI, MessageLoopForUI::current()) {} virtual void SetUp() { - ChromeRenderViewHostTestHarness::SetUp(); + TabContentsWrapperTestHarness::SetUp(); profile()->CreateWebDataService(false); - - SiteInstance* instance = SiteInstance::CreateSiteInstance(profile()); - tab_contents_.reset(new TestTabContents(profile(), instance)); - web_intents_registry_ = BuildForProfile(profile()); } virtual void TearDown() { - tab_contents_.reset(); web_intents_registry_ = NULL; - ChromeRenderViewHostTestHarness::TearDown(); + TabContentsWrapperTestHarness::TearDown(); } - scoped_ptr<TestTabContents> tab_contents_; MockWebIntentsRegistry* web_intents_registry_; private: @@ -71,7 +64,10 @@ TEST_F(RegisterIntentHandlerInfoBarDelegateTest, Accept) { service.service_url = GURL("google.com"); service.action = ASCIIToUTF16("http://webintents.org/share"); service.type = ASCIIToUTF16("text/url"); - RegisterIntentHandlerInfoBarDelegate delegate(tab_contents_.get(), service); + RegisterIntentHandlerInfoBarDelegate delegate( + contents_wrapper()->infobar_tab_helper(), + WebIntentsRegistryFactory::GetForProfile(profile()), + service); EXPECT_CALL(*web_intents_registry_, RegisterIntentProvider(service)); delegate.Accept(); diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc index 95e2ac7..88f9ea2 100644 --- a/chrome/browser/notifications/desktop_notification_service.cc +++ b/chrome/browser/notifications/desktop_notification_service.cc @@ -53,12 +53,14 @@ const ContentSetting kDefaultSetting = CONTENT_SETTING_ASK; // permissions. class NotificationPermissionInfoBarDelegate : public ConfirmInfoBarDelegate { public: - NotificationPermissionInfoBarDelegate(TabContents* contents, - const GURL& origin, - const string16& display_name, - int process_id, - int route_id, - int callback_context); + NotificationPermissionInfoBarDelegate( + InfoBarTabHelper* infobar_helper, + DesktopNotificationService* notification_service, + const GURL& origin, + const string16& display_name, + int process_id, + int route_id, + int callback_context); private: virtual ~NotificationPermissionInfoBarDelegate(); @@ -78,8 +80,8 @@ class NotificationPermissionInfoBarDelegate : public ConfirmInfoBarDelegate { // origin_ for extensions. string16 display_name_; - // The Profile that we restore sessions from. - Profile* profile_; + // The notification service to be used. + DesktopNotificationService* notification_service_; // The callback information that tells us how to respond to javascript via // the correct RenderView. @@ -94,16 +96,17 @@ class NotificationPermissionInfoBarDelegate : public ConfirmInfoBarDelegate { }; NotificationPermissionInfoBarDelegate::NotificationPermissionInfoBarDelegate( - TabContents* contents, + InfoBarTabHelper* infobar_helper, + DesktopNotificationService* notification_service, const GURL& origin, const string16& display_name, int process_id, int route_id, int callback_context) - : ConfirmInfoBarDelegate(contents), + : ConfirmInfoBarDelegate(infobar_helper), origin_(origin), display_name_(display_name), - profile_(Profile::FromBrowserContext(contents->browser_context())), + notification_service_(notification_service), process_id_(process_id), route_id_(route_id), callback_context_(callback_context), @@ -143,16 +146,14 @@ string16 NotificationPermissionInfoBarDelegate::GetButtonLabel( bool NotificationPermissionInfoBarDelegate::Accept() { UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Allowed", 1); - DesktopNotificationServiceFactory::GetForProfile(profile_)-> - GrantPermission(origin_); + notification_service_->GrantPermission(origin_); action_taken_ = true; return true; } bool NotificationPermissionInfoBarDelegate::Cancel() { UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Denied", 1); - DesktopNotificationServiceFactory::GetForProfile(profile_)-> - DenyPermission(origin_); + notification_service_->DenyPermission(origin_); action_taken_ = true; return true; } @@ -347,10 +348,15 @@ void DesktopNotificationService::RequestPermission( // Show an info bar requesting permission. TabContentsWrapper* wrapper = TabContentsWrapper::GetCurrentWrapperForContents(tab); - wrapper->infobar_tab_helper()->AddInfoBar( - new NotificationPermissionInfoBarDelegate( - tab, origin, DisplayNameForOrigin(origin), process_id, - route_id, callback_context)); + InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); + infobar_helper->AddInfoBar(new NotificationPermissionInfoBarDelegate( + infobar_helper, + DesktopNotificationServiceFactory::GetForProfile(wrapper->profile()), + origin, + DisplayNameForOrigin(origin), + process_id, + route_id, + callback_context)); } else { // Notify renderer immediately. RenderViewHost* host = RenderViewHost::FromID(process_id, route_id); diff --git a/chrome/browser/omnibox_search_hint.cc b/chrome/browser/omnibox_search_hint.cc index 97961df..deec98a 100644 --- a/chrome/browser/omnibox_search_hint.cc +++ b/chrome/browser/omnibox_search_hint.cc @@ -85,7 +85,7 @@ class HintInfoBar : public ConfirmInfoBarDelegate { }; HintInfoBar::HintInfoBar(OmniboxSearchHint* omnibox_hint) - : ConfirmInfoBarDelegate(omnibox_hint->tab()->tab_contents()), + : ConfirmInfoBarDelegate(omnibox_hint->tab()->infobar_tab_helper()), omnibox_hint_(omnibox_hint), action_taken_(false), should_expire_(false), diff --git a/chrome/browser/password_manager_delegate_impl.cc b/chrome/browser/password_manager_delegate_impl.cc index c30c638..550aafb 100644 --- a/chrome/browser/password_manager_delegate_impl.cc +++ b/chrome/browser/password_manager_delegate_impl.cc @@ -28,7 +28,7 @@ // forms never end up in an infobar. class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate { public: - SavePasswordInfoBarDelegate(TabContents* tab_contents, + SavePasswordInfoBarDelegate(InfoBarTabHelper* infobar_helper, PasswordFormManager* form_to_save); private: @@ -60,9 +60,9 @@ class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate { }; SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( - TabContents* tab_contents, + InfoBarTabHelper* infobar_helper, PasswordFormManager* form_to_save) - : ConfirmInfoBarDelegate(tab_contents), + : ConfirmInfoBarDelegate(infobar_helper), form_to_save_(form_to_save), infobar_response_(NO_RESPONSE) { } @@ -118,7 +118,7 @@ void PasswordManagerDelegateImpl::AddSavePasswordInfoBar( PasswordFormManager* form_to_save) { tab_contents_->infobar_tab_helper()->AddInfoBar( new SavePasswordInfoBarDelegate( - tab_contents_->tab_contents(), form_to_save)); + tab_contents_->infobar_tab_helper(), form_to_save)); } Profile* PasswordManagerDelegateImpl::GetProfileForPasswordManager() { diff --git a/chrome/browser/pdf_unsupported_feature.cc b/chrome/browser/pdf_unsupported_feature.cc index e83b6e1..7a5f25f 100644 --- a/chrome/browser/pdf_unsupported_feature.cc +++ b/chrome/browser/pdf_unsupported_feature.cc @@ -49,7 +49,9 @@ static const char kReaderUpdateUrl[] = // the buttons, and the meaning of the delegate callbacks. class PDFEnableAdobeReaderInfoBarDelegate : public ConfirmInfoBarDelegate { public: - explicit PDFEnableAdobeReaderInfoBarDelegate(TabContents* tab_contents); + explicit PDFEnableAdobeReaderInfoBarDelegate( + InfoBarTabHelper* infobar_helper, + Profile* profile); virtual ~PDFEnableAdobeReaderInfoBarDelegate(); // ConfirmInfoBarDelegate @@ -64,15 +66,15 @@ class PDFEnableAdobeReaderInfoBarDelegate : public ConfirmInfoBarDelegate { void OnYes(); void OnNo(); - TabContents* tab_contents_; + Profile* profile_; DISALLOW_IMPLICIT_CONSTRUCTORS(PDFEnableAdobeReaderInfoBarDelegate); }; PDFEnableAdobeReaderInfoBarDelegate::PDFEnableAdobeReaderInfoBarDelegate( - TabContents* tab_contents) - : ConfirmInfoBarDelegate(tab_contents), - tab_contents_(tab_contents) { + InfoBarTabHelper* infobar_helper, Profile* profile) + : ConfirmInfoBarDelegate(infobar_helper), + profile_(profile) { UserMetrics::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarShown")); } @@ -89,9 +91,7 @@ InfoBarDelegate::Type } bool PDFEnableAdobeReaderInfoBarDelegate::Accept() { - Profile* profile = - Profile::FromBrowserContext(tab_contents_->browser_context()); - profile->GetPrefs()->SetBoolean( + profile_->GetPrefs()->SetBoolean( prefs::kPluginsShowSetReaderDefaultInfobar, false); OnNo(); return true; @@ -115,9 +115,7 @@ string16 PDFEnableAdobeReaderInfoBarDelegate::GetMessageText() const { void PDFEnableAdobeReaderInfoBarDelegate::OnYes() { UserMetrics::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarOK")); - Profile* profile = - Profile::FromBrowserContext(tab_contents_->browser_context()); - PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile); + PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile_); plugin_prefs->EnablePluginGroup( true, ASCIIToUTF16(webkit::npapi::PluginGroup::kAdobeReaderGroupName)); plugin_prefs->EnablePluginGroup( @@ -262,7 +260,7 @@ class PDFUnsupportedFeatureInfoBarDelegate : public ConfirmInfoBarDelegate { PDFUnsupportedFeatureInfoBarDelegate::PDFUnsupportedFeatureInfoBarDelegate( TabContentsWrapper* tab_contents, const PluginGroup* reader_group) - : ConfirmInfoBarDelegate(tab_contents->tab_contents()), + : ConfirmInfoBarDelegate(tab_contents->infobar_tab_helper()), tab_contents_(tab_contents), reader_installed_(!!reader_group), reader_vulnerable_(false) { @@ -345,8 +343,8 @@ bool PDFUnsupportedFeatureInfoBarDelegate::OnYes() { if (tab_contents_->profile()->GetPrefs()->GetBoolean( prefs::kPluginsShowSetReaderDefaultInfobar)) { - InfoBarDelegate* bar = - new PDFEnableAdobeReaderInfoBarDelegate(tab_contents_->tab_contents()); + InfoBarDelegate* bar = new PDFEnableAdobeReaderInfoBarDelegate( + tab_contents_->infobar_tab_helper(), tab_contents_->profile()); OpenUsingReader(tab_contents_, reader_webplugininfo_, this, bar); return false; } diff --git a/chrome/browser/plugin_installer_infobar_delegate.cc b/chrome/browser/plugin_installer_infobar_delegate.cc index a6e002e..e570a2a 100644 --- a/chrome/browser/plugin_installer_infobar_delegate.cc +++ b/chrome/browser/plugin_installer_infobar_delegate.cc @@ -5,6 +5,7 @@ #include "chrome/browser/plugin_installer_infobar_delegate.h" #include "chrome/browser/google/google_util.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/common/view_messages.h" @@ -16,9 +17,8 @@ #include "webkit/plugins/npapi/default_plugin_shared.h" PluginInstallerInfoBarDelegate::PluginInstallerInfoBarDelegate( - TabContents* tab_contents, gfx::NativeWindow window) - : ConfirmInfoBarDelegate(tab_contents), - tab_contents_(tab_contents), + InfoBarTabHelper* infobar_helper, gfx::NativeWindow window) + : ConfirmInfoBarDelegate(infobar_helper), window_(window) { } @@ -69,7 +69,7 @@ string16 PluginInstallerInfoBarDelegate::GetLinkText() const { bool PluginInstallerInfoBarDelegate::LinkClicked( WindowOpenDisposition disposition) { - tab_contents_->OpenURL(google_util::AppendGoogleLocaleParam(GURL( + owner()->tab_contents()->OpenURL(google_util::AppendGoogleLocaleParam(GURL( "http://www.google.com/support/chrome/bin/answer.py?answer=95697&topic=" "14687")), GURL(), (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, diff --git a/chrome/browser/plugin_installer_infobar_delegate.h b/chrome/browser/plugin_installer_infobar_delegate.h index f338258..519b73a 100644 --- a/chrome/browser/plugin_installer_infobar_delegate.h +++ b/chrome/browser/plugin_installer_infobar_delegate.h @@ -9,13 +9,11 @@ #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" #include "ui/gfx/native_widget_types.h" -class TabContents; - // The main purpose for this class is to popup/close the infobar when there is // a missing plugin. class PluginInstallerInfoBarDelegate : public ConfirmInfoBarDelegate { public: - PluginInstallerInfoBarDelegate(TabContents* tab_contents, + PluginInstallerInfoBarDelegate(InfoBarTabHelper* infobar_helper, gfx::NativeWindow window); private: @@ -32,8 +30,6 @@ class PluginInstallerInfoBarDelegate : public ConfirmInfoBarDelegate { virtual string16 GetLinkText() const OVERRIDE; virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; - // The containing TabContents - TabContents* tab_contents_; gfx::NativeWindow window_; DISALLOW_COPY_AND_ASSIGN(PluginInstallerInfoBarDelegate); diff --git a/chrome/browser/plugin_observer.cc b/chrome/browser/plugin_observer.cc index 2364a52..13fe1016 100644 --- a/chrome/browser/plugin_observer.cc +++ b/chrome/browser/plugin_observer.cc @@ -14,6 +14,7 @@ #include "chrome/common/render_messages.h" #include "chrome/common/url_constants.h" #include "content/browser/renderer_host/render_view_host.h" +#include "content/browser/tab_contents/tab_contents.h" #include "content/browser/user_metrics.h" #include "content/common/view_messages.h" #include "grit/generated_resources.h" @@ -30,7 +31,7 @@ namespace { class PluginInfoBarDelegate : public ConfirmInfoBarDelegate { public: - PluginInfoBarDelegate(TabContents* tab_contents, const string16& name); + PluginInfoBarDelegate(InfoBarTabHelper* infobar_helper, const string16& name); protected: virtual ~PluginInfoBarDelegate(); @@ -42,7 +43,6 @@ class PluginInfoBarDelegate : public ConfirmInfoBarDelegate { virtual std::string GetLearnMoreURL() const = 0; string16 name_; - TabContents* tab_contents_; private: // ConfirmInfoBarDelegate: @@ -52,24 +52,22 @@ class PluginInfoBarDelegate : public ConfirmInfoBarDelegate { DISALLOW_COPY_AND_ASSIGN(PluginInfoBarDelegate); }; -PluginInfoBarDelegate::PluginInfoBarDelegate(TabContents* tab_contents, +PluginInfoBarDelegate::PluginInfoBarDelegate(InfoBarTabHelper* infobar_helper, const string16& name) - : ConfirmInfoBarDelegate(tab_contents), - name_(name), - tab_contents_(tab_contents) { + : ConfirmInfoBarDelegate(infobar_helper), + name_(name) { } PluginInfoBarDelegate::~PluginInfoBarDelegate() { } bool PluginInfoBarDelegate::Cancel() { - tab_contents_->render_view_host()->Send(new ChromeViewMsg_LoadBlockedPlugins( - tab_contents_->render_view_host()->routing_id())); + owner()->Send(new ChromeViewMsg_LoadBlockedPlugins(owner()->routing_id())); return true; } bool PluginInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { - tab_contents_->OpenURL( + owner()->tab_contents()->OpenURL( google_util::AppendGoogleLocaleParam(GURL(GetLearnMoreURL())), GURL(), (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, PageTransition::LINK); @@ -90,7 +88,8 @@ string16 PluginInfoBarDelegate::GetLinkText() const { class BlockedPluginInfoBarDelegate : public PluginInfoBarDelegate { public: - BlockedPluginInfoBarDelegate(TabContents* tab_contents, + BlockedPluginInfoBarDelegate(InfoBarTabHelper* infobar_helper, + HostContentSettingsMap* content_settings, const string16& name); private: @@ -105,13 +104,17 @@ class BlockedPluginInfoBarDelegate : public PluginInfoBarDelegate { virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; virtual std::string GetLearnMoreURL() const OVERRIDE; + HostContentSettingsMap* content_settings_; + DISALLOW_COPY_AND_ASSIGN(BlockedPluginInfoBarDelegate); }; BlockedPluginInfoBarDelegate::BlockedPluginInfoBarDelegate( - TabContents* tab_contents, + InfoBarTabHelper* infobar_helper, + HostContentSettingsMap* content_settings, const string16& utf16_name) - : PluginInfoBarDelegate(tab_contents, utf16_name) { + : PluginInfoBarDelegate(infobar_helper, utf16_name), + content_settings_(content_settings) { UserMetrics::RecordAction(UserMetricsAction("BlockedPluginInfobar.Shown")); std::string name = UTF16ToUTF8(utf16_name); if (name == webkit::npapi::PluginGroup::kJavaGroupName) @@ -158,14 +161,11 @@ bool BlockedPluginInfoBarDelegate::Accept() { bool BlockedPluginInfoBarDelegate::Cancel() { UserMetrics::RecordAction( UserMetricsAction("BlockedPluginInfobar.AlwaysAllow")); - Profile* profile = - Profile::FromBrowserContext(tab_contents_->browser_context()); - profile->GetHostContentSettingsMap()->AddExceptionForURL( - tab_contents_->GetURL(), - tab_contents_->GetURL(), - CONTENT_SETTINGS_TYPE_PLUGINS, - std::string(), - CONTENT_SETTING_ALLOW); + content_settings_->AddExceptionForURL(owner()->tab_contents()->GetURL(), + owner()->tab_contents()->GetURL(), + CONTENT_SETTINGS_TYPE_PLUGINS, + std::string(), + CONTENT_SETTING_ALLOW); return PluginInfoBarDelegate::Cancel(); } @@ -185,7 +185,7 @@ bool BlockedPluginInfoBarDelegate::LinkClicked( class OutdatedPluginInfoBarDelegate : public PluginInfoBarDelegate { public: - OutdatedPluginInfoBarDelegate(TabContents* tab_contents, + OutdatedPluginInfoBarDelegate(InfoBarTabHelper* infobar_helper, const string16& name, const GURL& update_url); @@ -207,10 +207,10 @@ class OutdatedPluginInfoBarDelegate : public PluginInfoBarDelegate { }; OutdatedPluginInfoBarDelegate::OutdatedPluginInfoBarDelegate( - TabContents* tab_contents, + InfoBarTabHelper* infobar_helper, const string16& utf16_name, const GURL& update_url) - : PluginInfoBarDelegate(tab_contents, utf16_name), + : PluginInfoBarDelegate(infobar_helper, utf16_name), update_url_(update_url) { UserMetrics::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Shown")); std::string name = UTF16ToUTF8(utf16_name); @@ -254,8 +254,8 @@ string16 OutdatedPluginInfoBarDelegate::GetButtonLabel( bool OutdatedPluginInfoBarDelegate::Accept() { UserMetrics::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Update")); - tab_contents_->OpenURL(update_url_, GURL(), NEW_FOREGROUND_TAB, - PageTransition::LINK); + owner()->tab_contents()->OpenURL(update_url_, GURL(), NEW_FOREGROUND_TAB, + PageTransition::LINK); return false; } @@ -302,8 +302,11 @@ bool PluginObserver::OnMessageReceived(const IPC::Message& message) { void PluginObserver::OnBlockedOutdatedPlugin(const string16& name, const GURL& update_url) { - tab_contents_->infobar_tab_helper()->AddInfoBar(update_url.is_empty() ? + InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); + infobar_helper->AddInfoBar(update_url.is_empty() ? static_cast<InfoBarDelegate*>(new BlockedPluginInfoBarDelegate( - tab_contents(), name)) : - new OutdatedPluginInfoBarDelegate(tab_contents(), name, update_url)); + infobar_helper, + tab_contents_->profile()->GetHostContentSettingsMap(), + name)) : + new OutdatedPluginInfoBarDelegate(infobar_helper, name, update_url)); } diff --git a/chrome/browser/tab_contents/confirm_infobar_delegate.cc b/chrome/browser/tab_contents/confirm_infobar_delegate.cc index fa35c4d..4662e5e 100644 --- a/chrome/browser/tab_contents/confirm_infobar_delegate.cc +++ b/chrome/browser/tab_contents/confirm_infobar_delegate.cc @@ -37,8 +37,8 @@ bool ConfirmInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { return true; } -ConfirmInfoBarDelegate::ConfirmInfoBarDelegate(TabContents* contents) - : InfoBarDelegate(contents) { +ConfirmInfoBarDelegate::ConfirmInfoBarDelegate(InfoBarTabHelper* infobar_helper) + : InfoBarDelegate(infobar_helper) { } ConfirmInfoBarDelegate::~ConfirmInfoBarDelegate() { diff --git a/chrome/browser/tab_contents/confirm_infobar_delegate.h b/chrome/browser/tab_contents/confirm_infobar_delegate.h index 7c5cb4e..c39f1e1 100644 --- a/chrome/browser/tab_contents/confirm_infobar_delegate.h +++ b/chrome/browser/tab_contents/confirm_infobar_delegate.h @@ -9,7 +9,7 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/string16.h" -#include "chrome/browser/tab_contents/infobar_delegate.h" +#include "chrome/browser/infobars/infobar_delegate.h" // An interface derived from InfoBarDelegate implemented by objects wishing to // control a ConfirmInfoBar. @@ -56,7 +56,7 @@ class ConfirmInfoBarDelegate : public InfoBarDelegate { virtual bool LinkClicked(WindowOpenDisposition disposition); protected: - explicit ConfirmInfoBarDelegate(TabContents* contents); + explicit ConfirmInfoBarDelegate(InfoBarTabHelper* infobar_helper); virtual ~ConfirmInfoBarDelegate(); virtual bool ShouldExpire( @@ -64,7 +64,7 @@ class ConfirmInfoBarDelegate : public InfoBarDelegate { private: // InfoBarDelegate: - virtual InfoBar* CreateInfoBar(TabContentsWrapper* owner) OVERRIDE; + virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) OVERRIDE; virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE; virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate() OVERRIDE; diff --git a/chrome/browser/tab_contents/insecure_content_infobar_delegate.cc b/chrome/browser/tab_contents/insecure_content_infobar_delegate.cc index 9b0efe3..6c05f8c 100644 --- a/chrome/browser/tab_contents/insecure_content_infobar_delegate.cc +++ b/chrome/browser/tab_contents/insecure_content_infobar_delegate.cc @@ -6,17 +6,17 @@ #include "base/metrics/histogram.h" #include "chrome/browser/google/google_util.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/common/render_messages.h" +#include "content/browser/tab_contents/tab_contents.h" #include "content/common/page_transition_types.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" InsecureContentInfoBarDelegate::InsecureContentInfoBarDelegate( - TabContentsWrapper* tab_contents, + InfoBarTabHelper* infobar_helper, InfoBarType type) - : ConfirmInfoBarDelegate(tab_contents->tab_contents()), - tab_contents_(tab_contents), + : ConfirmInfoBarDelegate(infobar_helper), type_(type) { UMA_HISTOGRAM_ENUMERATION("InsecureContentInfoBarDelegateV2", (type_ == DISPLAY) ? DISPLAY_INFOBAR_SHOWN : RUN_INFOBAR_SHOWN, @@ -65,8 +65,8 @@ bool InsecureContentInfoBarDelegate::Cancel() { (type_ == DISPLAY) ? DISPLAY_USER_OVERRIDE : RUN_USER_OVERRIDE, NUM_EVENTS); - int32 routing_id = tab_contents_->routing_id(); - tab_contents_->Send((type_ == DISPLAY) ? static_cast<IPC::Message*>( + 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)); return true; @@ -78,7 +78,7 @@ string16 InsecureContentInfoBarDelegate::GetLinkText() const { bool InsecureContentInfoBarDelegate::LinkClicked( WindowOpenDisposition disposition) { - tab_contents_->tab_contents()->OpenURL( + owner()->tab_contents()->OpenURL( google_util::AppendGoogleLocaleParam(GURL( "https://www.google.com/support/chrome/bin/answer.py?answer=1342714")), GURL(), (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, diff --git a/chrome/browser/tab_contents/insecure_content_infobar_delegate.h b/chrome/browser/tab_contents/insecure_content_infobar_delegate.h index 6395b35..08ec1c6 100644 --- a/chrome/browser/tab_contents/insecure_content_infobar_delegate.h +++ b/chrome/browser/tab_contents/insecure_content_infobar_delegate.h @@ -8,8 +8,6 @@ #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" -class TabContentsWrapper; - // Base class for delegates that show warnings on HTTPS pages which try to // display or run insecure content. class InsecureContentInfoBarDelegate : public ConfirmInfoBarDelegate { @@ -19,7 +17,7 @@ class InsecureContentInfoBarDelegate : public ConfirmInfoBarDelegate { RUN, // Shown when "active" content (e.g. script) has been blocked. }; - InsecureContentInfoBarDelegate(TabContentsWrapper* tab_contents, + InsecureContentInfoBarDelegate(InfoBarTabHelper* infobar_helper, InfoBarType type); virtual ~InsecureContentInfoBarDelegate(); @@ -49,7 +47,6 @@ class InsecureContentInfoBarDelegate : public ConfirmInfoBarDelegate { virtual string16 GetLinkText() const OVERRIDE; virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; - TabContentsWrapper* tab_contents_; InfoBarType type_; DISALLOW_IMPLICIT_CONSTRUCTORS(InsecureContentInfoBarDelegate); diff --git a/chrome/browser/tab_contents/link_infobar_delegate.cc b/chrome/browser/tab_contents/link_infobar_delegate.cc index 8410dec..02c2c2e 100644 --- a/chrome/browser/tab_contents/link_infobar_delegate.cc +++ b/chrome/browser/tab_contents/link_infobar_delegate.cc @@ -4,14 +4,12 @@ #include "chrome/browser/tab_contents/link_infobar_delegate.h" -#include "content/browser/tab_contents/tab_contents.h" - bool LinkInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { return true; } -LinkInfoBarDelegate::LinkInfoBarDelegate(TabContents* contents) - : InfoBarDelegate(contents) { +LinkInfoBarDelegate::LinkInfoBarDelegate(InfoBarTabHelper* infobar_helper) + : InfoBarDelegate(infobar_helper) { } LinkInfoBarDelegate::~LinkInfoBarDelegate() { diff --git a/chrome/browser/tab_contents/link_infobar_delegate.h b/chrome/browser/tab_contents/link_infobar_delegate.h index 8744a4f..0a20f13 100644 --- a/chrome/browser/tab_contents/link_infobar_delegate.h +++ b/chrome/browser/tab_contents/link_infobar_delegate.h @@ -9,10 +9,9 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/string16.h" -#include "chrome/browser/tab_contents/infobar_delegate.h" +#include "chrome/browser/infobars/infobar_delegate.h" -class TabContents; -class TabContentsWrapper; +class InfoBarTabHelper; // An interface derived from InfoBarDelegate implemented by objects wishing to // control a LinkInfoBar. @@ -33,12 +32,12 @@ class LinkInfoBarDelegate : public InfoBarDelegate { virtual bool LinkClicked(WindowOpenDisposition disposition); protected: - explicit LinkInfoBarDelegate(TabContents* contents); + explicit LinkInfoBarDelegate(InfoBarTabHelper* infobar_helper); virtual ~LinkInfoBarDelegate(); private: // InfoBarDelegate: - virtual InfoBar* CreateInfoBar(TabContentsWrapper* owner) OVERRIDE; + virtual InfoBar* CreateInfoBar(InfoBarTabHelper* infobar_helper) OVERRIDE; virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate() OVERRIDE; DISALLOW_COPY_AND_ASSIGN(LinkInfoBarDelegate); diff --git a/chrome/browser/tab_contents/simple_alert_infobar_delegate.cc b/chrome/browser/tab_contents/simple_alert_infobar_delegate.cc index e51935a..3182130 100644 --- a/chrome/browser/tab_contents/simple_alert_infobar_delegate.cc +++ b/chrome/browser/tab_contents/simple_alert_infobar_delegate.cc @@ -4,15 +4,14 @@ #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" -#include "content/browser/tab_contents/tab_contents.h" #include "third_party/skia/include/core/SkBitmap.h" SimpleAlertInfoBarDelegate::SimpleAlertInfoBarDelegate( - TabContents* contents, + InfoBarTabHelper* infobar_helper, gfx::Image* icon, const string16& message, bool auto_expire) - : ConfirmInfoBarDelegate(contents), + : ConfirmInfoBarDelegate(infobar_helper), icon_(icon), message_(message), auto_expire_(auto_expire) { diff --git a/chrome/browser/tab_contents/simple_alert_infobar_delegate.h b/chrome/browser/tab_contents/simple_alert_infobar_delegate.h index 55cda91..0ea8249 100644 --- a/chrome/browser/tab_contents/simple_alert_infobar_delegate.h +++ b/chrome/browser/tab_contents/simple_alert_infobar_delegate.h @@ -16,7 +16,7 @@ class TabContents; class SimpleAlertInfoBarDelegate : public ConfirmInfoBarDelegate { public: - SimpleAlertInfoBarDelegate(TabContents* contents, + SimpleAlertInfoBarDelegate(InfoBarTabHelper* infobar_helper, gfx::Image* icon, // May be NULL. const string16& message, bool auto_expire); diff --git a/chrome/browser/tab_contents/tab_contents_ssl_helper.cc b/chrome/browser/tab_contents/tab_contents_ssl_helper.cc index 317e4b5..b8cae38 100644 --- a/chrome/browser/tab_contents/tab_contents_ssl_helper.cc +++ b/chrome/browser/tab_contents/tab_contents_ssl_helper.cc @@ -14,12 +14,12 @@ #include "base/values.h" #include "chrome/browser/certificate_viewer.h" #include "chrome/browser/content_settings/host_content_settings_map.h" +#include "chrome/browser/infobars/infobar.h" #include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ssl/ssl_add_cert_handler.h" #include "chrome/browser/ssl_client_certificate_selector.h" #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" -#include "chrome/browser/tab_contents/infobar.h" #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_notification_types.h" @@ -63,7 +63,7 @@ bool CertMatchesFilter(const net::X509Certificate& cert, class SSLCertAddedInfoBarDelegate : public ConfirmInfoBarDelegate { public: - SSLCertAddedInfoBarDelegate(TabContents* tab_contents, + SSLCertAddedInfoBarDelegate(InfoBarTabHelper* infobar_helper, net::X509Certificate* cert); private: @@ -77,15 +77,13 @@ class SSLCertAddedInfoBarDelegate : public ConfirmInfoBarDelegate { virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; virtual bool Accept() OVERRIDE; - TabContents* tab_contents_; // The TabContents we are attached to. scoped_refptr<net::X509Certificate> cert_; // The cert we added. }; SSLCertAddedInfoBarDelegate::SSLCertAddedInfoBarDelegate( - TabContents* tab_contents, + InfoBarTabHelper* infobar_helper, net::X509Certificate* cert) - : ConfirmInfoBarDelegate(tab_contents), - tab_contents_(tab_contents), + : ConfirmInfoBarDelegate(infobar_helper), cert_(cert) { } @@ -117,7 +115,7 @@ string16 SSLCertAddedInfoBarDelegate::GetButtonLabel( } bool SSLCertAddedInfoBarDelegate::Accept() { - ShowCertificateViewer(tab_contents_->GetDialogRootWindow(), cert_); + ShowCertificateViewer(owner()->tab_contents()->GetDialogRootWindow(), cert_); return false; // Hiding the infobar just as the dialog opens looks weird. } @@ -156,7 +154,7 @@ TabContentsSSLHelper::SSLAddCertData::SSLAddCertData( TabContentsWrapper* tab_contents) : tab_contents_(tab_contents), infobar_delegate_(NULL) { - Source<TabContentsWrapper> source(tab_contents_); + Source<InfoBarTabHelper> source(tab_contents_->infobar_tab_helper()); registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, source); registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED, @@ -179,7 +177,7 @@ void TabContentsSSLHelper::SSLAddCertData::ShowInfoBar( void TabContentsSSLHelper::SSLAddCertData::ShowErrorInfoBar( const string16& message) { ShowInfoBar(new SimpleAlertInfoBarDelegate( - tab_contents_->tab_contents(), GetCertIcon(), message, true)); + tab_contents_->infobar_tab_helper(), GetCertIcon(), message, true)); } void TabContentsSSLHelper::SSLAddCertData::Observe( @@ -274,7 +272,7 @@ void TabContentsSSLHelper::OnAddClientCertificateSuccess( SSLAddCertData* add_cert_data = GetAddCertData(handler); // Display an infobar to inform the user. add_cert_data->ShowInfoBar(new SSLCertAddedInfoBarDelegate( - tab_contents_->tab_contents(), handler->cert())); + tab_contents_->infobar_tab_helper(), handler->cert())); } void TabContentsSSLHelper::OnAddClientCertificateError( diff --git a/chrome/browser/translate/options_menu_model.cc b/chrome/browser/translate/options_menu_model.cc index fc3a59f..ce52693 100644 --- a/chrome/browser/translate/options_menu_model.cc +++ b/chrome/browser/translate/options_menu_model.cc @@ -7,6 +7,7 @@ #include "base/metrics/histogram.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/google/google_util.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/translate/translate_infobar_delegate.h" #include "content/browser/tab_contents/tab_contents.h" @@ -36,7 +37,7 @@ OptionsMenuModel::OptionsMenuModel( // Populate the menu. // Incognito mode does not get any preferences related items. - if (!translate_delegate->tab_contents()-> + if (!translate_delegate->owner()->tab_contents()-> browser_context()->IsOffTheRecord()) { AddCheckItem(IDC_TRANSLATE_OPTIONS_ALWAYS, l10n_util::GetStringFUTF16(IDS_TRANSLATE_INFOBAR_OPTIONS_ALWAYS, @@ -121,7 +122,8 @@ void OptionsMenuModel::ExecuteCommand(int command_id) { break; case IDC_TRANSLATE_OPTIONS_ABOUT: { - TabContents* tab_contents = translate_infobar_delegate_->tab_contents(); + TabContents* tab_contents = + translate_infobar_delegate_->owner()->tab_contents(); if (tab_contents) { GURL about_url = google_util::AppendGoogleLocaleParam( GURL(kAboutGoogleTranslateUrl)); diff --git a/chrome/browser/translate/translate_infobar_delegate.cc b/chrome/browser/translate/translate_infobar_delegate.cc index daba227..65dbe1c 100644 --- a/chrome/browser/translate/translate_infobar_delegate.cc +++ b/chrome/browser/translate/translate_infobar_delegate.cc @@ -8,6 +8,7 @@ #include "base/metrics/histogram.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/translate/translate_infobar_view.h" #include "chrome/browser/translate/translate_manager.h" @@ -15,6 +16,7 @@ #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_constants.h" #include "content/browser/tab_contents/navigation_details.h" +#include "content/browser/tab_contents/tab_contents.h" #include "grit/generated_resources.h" #include "grit/theme_resources_standard.h" #include "ui/base/l10n/l10n_util.h" @@ -26,7 +28,8 @@ const size_t TranslateInfoBarDelegate::kNoIndex = static_cast<size_t>(-1); // static TranslateInfoBarDelegate* TranslateInfoBarDelegate::CreateDelegate( Type type, - TabContents* tab_contents, + InfoBarTabHelper* infobar_helper, + PrefService* prefs, const std::string& original_language, const std::string& target_language) { DCHECK_NE(TRANSLATION_ERROR, type); @@ -39,19 +42,28 @@ TranslateInfoBarDelegate* TranslateInfoBarDelegate::CreateDelegate( ((type == TRANSLATING) && (original_language == chrome::kUnknownLanguageCode))); TranslateInfoBarDelegate* delegate = - new TranslateInfoBarDelegate(type, TranslateErrors::NONE, tab_contents, - original_language, target_language); + new TranslateInfoBarDelegate(type, + TranslateErrors::NONE, + infobar_helper, + prefs, + original_language, + target_language); DCHECK_NE(kNoIndex, delegate->target_language_index()); return delegate; } TranslateInfoBarDelegate* TranslateInfoBarDelegate::CreateErrorDelegate( TranslateErrors::Type error, - TabContents* tab_contents, + InfoBarTabHelper* infobar_helper, + PrefService* prefs, const std::string& original_language, const std::string& target_language) { - return new TranslateInfoBarDelegate(TRANSLATION_ERROR, error, tab_contents, - original_language, target_language); + return new TranslateInfoBarDelegate(TRANSLATION_ERROR, + error, + infobar_helper, + prefs, + original_language, + target_language); } TranslateInfoBarDelegate::~TranslateInfoBarDelegate() { @@ -99,28 +111,29 @@ void TranslateInfoBarDelegate::SetTargetLanguage(size_t language_index) { void TranslateInfoBarDelegate::Translate() { const std::string& original_language_code = GetOriginalLanguageCode(); - if (!tab_contents()->browser_context()->IsOffTheRecord()) { + if (!owner()->tab_contents()->browser_context()->IsOffTheRecord()) { prefs_.ResetTranslationDeniedCount(original_language_code); prefs_.IncrementTranslationAcceptedCount(original_language_code); } - TranslateManager::GetInstance()->TranslatePage(tab_contents_, + TranslateManager::GetInstance()->TranslatePage(owner()->tab_contents(), GetLanguageCodeAt(original_language_index()), GetLanguageCodeAt(target_language_index())); } void TranslateInfoBarDelegate::RevertTranslation() { - TranslateManager::GetInstance()->RevertTranslation(tab_contents_); + TranslateManager::GetInstance()->RevertTranslation(owner()->tab_contents()); RemoveSelf(); } void TranslateInfoBarDelegate::ReportLanguageDetectionError() { - TranslateManager::GetInstance()->ReportLanguageDetectionError(tab_contents_); + TranslateManager::GetInstance()-> + ReportLanguageDetectionError(owner()->tab_contents()); } void TranslateInfoBarDelegate::TranslationDeclined() { const std::string& original_language_code = GetOriginalLanguageCode(); - if (!tab_contents()->browser_context()->IsOffTheRecord()) { + if (!owner()->tab_contents()->browser_context()->IsOffTheRecord()) { prefs_.ResetTranslationAcceptedCount(original_language_code); prefs_.IncrementTranslationDeniedCount(original_language_code); } @@ -131,7 +144,7 @@ void TranslateInfoBarDelegate::TranslationDeclined() { // happens when a load stops. That could happen multiple times, including // after the user already declined the translation.) TranslateTabHelper* helper = TabContentsWrapper::GetCurrentWrapperForContents( - tab_contents_)->translate_tab_helper(); + owner()->tab_contents())->translate_tab_helper(); helper->language_state().set_translation_declined(true); } @@ -247,7 +260,7 @@ void TranslateInfoBarDelegate::MessageInfoBarButtonPressed() { return; } // This is the "Try again..." case. - TranslateManager::GetInstance()->TranslatePage(tab_contents_, + TranslateManager::GetInstance()->TranslatePage(owner()->tab_contents(), GetOriginalLanguageCode(), GetTargetLanguageCode()); } @@ -257,13 +270,13 @@ bool TranslateInfoBarDelegate::ShouldShowMessageInfoBarButton() { bool TranslateInfoBarDelegate::ShouldShowNeverTranslateButton() { DCHECK_EQ(BEFORE_TRANSLATE, type_); - return !tab_contents()->browser_context()->IsOffTheRecord() && + return !owner()->tab_contents()->browser_context()->IsOffTheRecord() && (prefs_.GetTranslationDeniedCount(GetOriginalLanguageCode()) >= 3); } bool TranslateInfoBarDelegate::ShouldShowAlwaysTranslateButton() { DCHECK_EQ(BEFORE_TRANSLATE, type_); - return !tab_contents()->browser_context()->IsOffTheRecord() && + return !owner()->tab_contents()->browser_context()->IsOffTheRecord() && (prefs_.GetTranslationAcceptedCount(GetOriginalLanguageCode()) >= 3); } @@ -306,20 +319,19 @@ void TranslateInfoBarDelegate::GetAfterTranslateStrings( TranslateInfoBarDelegate::TranslateInfoBarDelegate( Type type, TranslateErrors::Type error, - TabContents* tab_contents, + InfoBarTabHelper* infobar_helper, + PrefService* prefs, const std::string& original_language, const std::string& target_language) - : InfoBarDelegate(tab_contents), + : InfoBarDelegate(infobar_helper), type_(type), background_animation_(NONE), - tab_contents_(tab_contents), original_language_index_(kNoIndex), initial_original_language_index_(kNoIndex), target_language_index_(kNoIndex), error_(error), infobar_view_(NULL), - prefs_(Profile::FromBrowserContext( - tab_contents_->browser_context())->GetPrefs()) { + prefs_(prefs) { DCHECK_NE((type_ == TRANSLATION_ERROR), (error == TranslateErrors::NONE)); std::vector<std::string> language_codes; @@ -386,6 +398,7 @@ TranslateInfoBarDelegate* } std::string TranslateInfoBarDelegate::GetPageHost() { - NavigationEntry* entry = tab_contents_->controller().GetActiveEntry(); + NavigationEntry* entry = + owner()->tab_contents()->controller().GetActiveEntry(); return entry ? entry->url().HostNoBrackets() : std::string(); } diff --git a/chrome/browser/translate/translate_infobar_delegate.h b/chrome/browser/translate/translate_infobar_delegate.h index 6010d4e..0670bfc 100644 --- a/chrome/browser/translate/translate_infobar_delegate.h +++ b/chrome/browser/translate/translate_infobar_delegate.h @@ -10,10 +10,11 @@ #include <vector> #include "base/compiler_specific.h" -#include "chrome/browser/tab_contents/infobar_delegate.h" +#include "chrome/browser/infobars/infobar_delegate.h" #include "chrome/browser/translate/translate_prefs.h" #include "chrome/common/translate_errors.h" +class PrefService; class SkBitmap; class TranslateInfoBarView; @@ -44,14 +45,16 @@ class TranslateInfoBarDelegate : public InfoBarDelegate { // |originalLanguage| == kUnknownLanguageCode. static TranslateInfoBarDelegate* CreateDelegate( Type infobar_type, - TabContents* tab_contents, + InfoBarTabHelper* infobar_helper, + PrefService* prefs, const std::string& original_language, const std::string& target_language); // Factory method to create an error translate infobar. static TranslateInfoBarDelegate* CreateErrorDelegate( TranslateErrors::Type error_type, - TabContents* tab_contents, + InfoBarTabHelper* infobar_helper, + PrefService* prefs, const std::string& original_language, const std::string& target_language); @@ -66,8 +69,6 @@ class TranslateInfoBarDelegate : public InfoBarDelegate { // Returns the displayable name for the language at |index|. string16 GetLanguageDisplayableNameAt(size_t index) const; - TabContents* tab_contents() const { return tab_contents_; } - Type type() const { return type_; } TranslateErrors::Type error() const { return error_; } @@ -152,7 +153,8 @@ class TranslateInfoBarDelegate : public InfoBarDelegate { // For testing. TranslateInfoBarDelegate(Type infobar_type, TranslateErrors::Type error, - TabContents* tab_contents, + InfoBarTabHelper* infobar_helper, + PrefService* prefs, const std::string& original_language, const std::string& target_language); Type type_; @@ -161,7 +163,7 @@ class TranslateInfoBarDelegate : public InfoBarDelegate { typedef std::pair<std::string, string16> LanguageNamePair; // InfoBarDelegate: - virtual InfoBar* CreateInfoBar(TabContentsWrapper* owner) OVERRIDE; + virtual InfoBar* CreateInfoBar(InfoBarTabHelper* infobar_helper) OVERRIDE; virtual void InfoBarDismissed() OVERRIDE; virtual gfx::Image* GetIcon() const OVERRIDE; virtual InfoBarDelegate::Type GetInfoBarType() const OVERRIDE; @@ -177,8 +179,6 @@ class TranslateInfoBarDelegate : public InfoBarDelegate { // infobar. BackgroundAnimationType background_animation_; - TabContents* tab_contents_; - // The list supported languages for translation. // The pair first string is the language ISO code (ex: en, fr...), the second // string is the displayable name on the current locale. diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc index 0adff98..dd6033c 100644 --- a/chrome/browser/translate/translate_manager.cc +++ b/chrome/browser/translate/translate_manager.cc @@ -404,9 +404,16 @@ void TranslateManager::OnURLFetchComplete(const URLFetcher* source, } if (error) { - ShowInfoBar(tab, TranslateInfoBarDelegate::CreateErrorDelegate( - TranslateErrors::NETWORK, tab, - request.source_lang, request.target_lang)); + TabContentsWrapper* wrapper = + TabContentsWrapper::GetCurrentWrapperForContents(tab); + InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); + ShowInfoBar( + tab, TranslateInfoBarDelegate::CreateErrorDelegate( + TranslateErrors::NETWORK, + infobar_helper, + wrapper->profile()->GetPrefs(), + request.source_lang, + request.target_lang)); } else { // Translate the page. DoTranslatePage(tab, translate_script_, @@ -512,11 +519,12 @@ void TranslateManager::InitiateTranslation(TabContents* tab, return; } + InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); // Prompts the user if he/she wants the page translated. - wrapper->infobar_tab_helper()->AddInfoBar( + infobar_helper->AddInfoBar( TranslateInfoBarDelegate::CreateDelegate( - TranslateInfoBarDelegate::BEFORE_TRANSLATE, tab, language_code, - target_lang)); + TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar_helper, + wrapper->profile()->GetPrefs(), language_code, target_lang)); } void TranslateManager::InitiateTranslationPosted( @@ -543,9 +551,12 @@ void TranslateManager::TranslatePage(TabContents* tab_contents, return; } + TabContentsWrapper* wrapper = + TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); + InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); ShowInfoBar(tab_contents, TranslateInfoBarDelegate::CreateDelegate( - TranslateInfoBarDelegate::TRANSLATING, tab_contents, - source_lang, target_lang)); + TranslateInfoBarDelegate::TRANSLATING, infobar_helper, + wrapper->profile()->GetPrefs(), source_lang, target_lang)); if (!translate_script_.empty()) { DoTranslatePage(tab_contents, translate_script_, source_lang, target_lang); @@ -636,23 +647,32 @@ void TranslateManager::DoTranslatePage(TabContents* tab, void TranslateManager::PageTranslated(TabContents* tab, PageTranslatedDetails* details) { + TabContentsWrapper* wrapper = + TabContentsWrapper::GetCurrentWrapperForContents(tab); + InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); + PrefService* prefs = wrapper->profile()->GetPrefs(); + // Create the new infobar to display. TranslateInfoBarDelegate* infobar; if (details->error_type != TranslateErrors::NONE) { - infobar = TranslateInfoBarDelegate::CreateErrorDelegate(details->error_type, - tab, details->source_language, details->target_language); + infobar = TranslateInfoBarDelegate::CreateErrorDelegate( + details->error_type, + infobar_helper, + prefs, + details->source_language, + details->target_language); } else if (!IsSupportedLanguage(details->source_language)) { // TODO(jcivelli): http://crbug.com/9390 We should change the "after // translate" infobar to support unknown as the original // language. UMA_HISTOGRAM_COUNTS("Translate.ServerReportedUnsupportedLanguage", 1); infobar = TranslateInfoBarDelegate::CreateErrorDelegate( - TranslateErrors::UNSUPPORTED_LANGUAGE, tab, - details->source_language, details->target_language); + TranslateErrors::UNSUPPORTED_LANGUAGE, infobar_helper, + prefs, details->source_language, details->target_language); } else { infobar = TranslateInfoBarDelegate::CreateDelegate( - TranslateInfoBarDelegate::AFTER_TRANSLATE, tab, - details->source_language, details->target_language); + TranslateInfoBarDelegate::AFTER_TRANSLATE, infobar_helper, + prefs, details->source_language, details->target_language); } ShowInfoBar(tab, infobar); } @@ -763,11 +783,12 @@ void TranslateManager::ShowInfoBar(TabContents* tab, TabContentsWrapper::GetCurrentWrapperForContents(tab); if (!wrapper) return; + InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); if (old_infobar) { // There already is a translate infobar, simply replace it. - wrapper->infobar_tab_helper()->ReplaceInfoBar(old_infobar, infobar); + infobar_helper->ReplaceInfoBar(old_infobar, infobar); } else { - wrapper->infobar_tab_helper()->AddInfoBar(infobar); + infobar_helper->AddInfoBar(infobar); } } diff --git a/chrome/browser/translate/translate_manager_browsertest.cc b/chrome/browser/translate/translate_manager_browsertest.cc index 03ff8e5..259e63e 100644 --- a/chrome/browser/translate/translate_manager_browsertest.cc +++ b/chrome/browser/translate/translate_manager_browsertest.cc @@ -10,10 +10,10 @@ #include "base/utf_string_conversions.h" #include "base/stringprintf.h" #include "chrome/app/chrome_command_ids.h" +#include "chrome/browser/infobars/infobar.h" #include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/browser/prefs/pref_service.h" -#include "chrome/browser/tab_contents/infobar.h" #include "chrome/browser/tab_contents/render_view_context_menu.h" #include "chrome/browser/translate/translate_infobar_delegate.h" #include "chrome/browser/translate/translate_manager.h" @@ -168,7 +168,7 @@ class TranslateManagerTest : public TabContentsWrapperTestHarness, notification_registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - Source<TabContentsWrapper>(contents_wrapper())); + Source<InfoBarTabHelper>(contents_wrapper()->infobar_tab_helper())); } virtual void TearDown() { @@ -176,7 +176,7 @@ class TranslateManagerTest : public TabContentsWrapperTestHarness, notification_registrar_.Remove(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - Source<TabContentsWrapper>(contents_wrapper())); + Source<InfoBarTabHelper>(contents_wrapper()->infobar_tab_helper())); TabContentsWrapperTestHarness::TearDown(); } diff --git a/chrome/browser/ui/auto_login_prompter.cc b/chrome/browser/ui/auto_login_prompter.cc index 1725c62..bbe0669 100644 --- a/chrome/browser/ui/auto_login_prompter.cc +++ b/chrome/browser/ui/auto_login_prompter.cc @@ -134,7 +134,8 @@ void AutoLoginRedirector::RedirectToMergeSession(const std::string& token) { // This is the actual infobar displayed to prompt the user to auto-login. class AutoLoginInfoBarDelegate : public ConfirmInfoBarDelegate { public: - AutoLoginInfoBarDelegate(TabContents* tab_contents, + AutoLoginInfoBarDelegate(InfoBarTabHelper* owner, + NavigationController* navigation_controller, TokenService* token_service, PrefService* pref_service, const std::string& username, @@ -159,13 +160,15 @@ class AutoLoginInfoBarDelegate : public ConfirmInfoBarDelegate { DISALLOW_COPY_AND_ASSIGN(AutoLoginInfoBarDelegate); }; -AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate(TabContents* tab_contents, - TokenService* token_service, - PrefService* pref_service, - const std::string& username, - const std::string& args) - : ConfirmInfoBarDelegate(tab_contents), - navigation_controller_(&tab_contents->controller()), +AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate( + InfoBarTabHelper* owner, + NavigationController* navigation_controller, + TokenService* token_service, + PrefService* pref_service, + const std::string& username, + const std::string& args) + : ConfirmInfoBarDelegate(owner), + navigation_controller_(navigation_controller), token_service_(token_service), pref_service_(pref_service), username_(username), @@ -320,9 +323,11 @@ void AutoLoginPrompter::Observe(int type, TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_); // |wrapper| is NULL for TabContents hosted in HTMLDialog. if (wrapper) { + InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); Profile* profile = wrapper->profile(); - wrapper->infobar_tab_helper()->AddInfoBar(new AutoLoginInfoBarDelegate( - tab_contents_, profile->GetTokenService(), profile->GetPrefs(), + infobar_helper->AddInfoBar(new AutoLoginInfoBarDelegate( + infobar_helper, &tab_contents_->controller(), + profile->GetTokenService(), profile->GetPrefs(), username_, args_)); } } diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index ad29969..5178a7a 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -57,6 +57,7 @@ #include "chrome/browser/instant/instant_controller.h" #include "chrome/browser/instant/instant_unload_handler.h" #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" +#include "chrome/browser/intents/web_intents_registry_factory.h" #include "chrome/browser/net/browser_url_util.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/notifications/notification_ui_manager.h" @@ -2416,8 +2417,11 @@ void Browser::JSOutOfMemoryHelper(TabContents* tab) { TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( tab); if (tcw) { - tcw->infobar_tab_helper()->AddInfoBar(new SimpleAlertInfoBarDelegate( - tab, NULL, l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), + InfoBarTabHelper* infobar_helper = tcw->infobar_tab_helper(); + infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( + infobar_helper, + NULL, + l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), true)); } } @@ -2453,8 +2457,11 @@ void Browser::RegisterProtocolHandlerHelper(TabContents* tab, return; UserMetrics::RecordAction( UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown")); - tcw->infobar_tab_helper()->AddInfoBar( - new RegisterProtocolHandlerInfoBarDelegate(tab, registry, handler)); + InfoBarTabHelper* infobar_helper = tcw->infobar_tab_helper(); + infobar_helper->AddInfoBar( + new RegisterProtocolHandlerInfoBarDelegate(infobar_helper, + registry, + handler)); } } @@ -2483,8 +2490,11 @@ void Browser::RegisterIntentHandlerHelper(TabContents* tab, service.action = action; service.type = type; service.title = title; - tcw->infobar_tab_helper()->AddInfoBar( - new RegisterIntentHandlerInfoBarDelegate(tab, service)); + InfoBarTabHelper* infobar_helper = tcw->infobar_tab_helper(); + infobar_helper->AddInfoBar(new RegisterIntentHandlerInfoBarDelegate( + infobar_helper, + WebIntentsRegistryFactory::GetForProfile(tcw->profile()), + service)); } // static @@ -2530,9 +2540,10 @@ void Browser::CrashedPluginHelper(TabContents* tab, } gfx::Image* icon = &ResourceBundle::GetSharedInstance().GetNativeImageNamed( IDR_INFOBAR_PLUGIN_CRASHED); - tcw->infobar_tab_helper()->AddInfoBar( + InfoBarTabHelper* infobar_helper = tcw->infobar_tab_helper(); + infobar_helper->AddInfoBar( new SimpleAlertInfoBarDelegate( - tab, + infobar_helper, icon, l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT, plugin_name), true)); @@ -3733,8 +3744,11 @@ void Browser::RendererResponsive(TabContents* source) { void Browser::WorkerCrashed(TabContents* source) { TabContentsWrapper* wrapper = TabContentsWrapper::GetCurrentWrapperForContents(source); - wrapper->infobar_tab_helper()->AddInfoBar(new SimpleAlertInfoBarDelegate( - source, NULL, l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT), + InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); + infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( + infobar_helper, + NULL, + l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT), true)); } diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc index 32804cd..55264ac 100644 --- a/chrome/browser/ui/browser_init.cc +++ b/chrome/browser/ui/browser_init.cc @@ -137,7 +137,8 @@ void SetAsDefaultBrowserTask::Run() { // The delegate for the infobar shown when Chrome is not the default browser. class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate { public: - explicit DefaultBrowserInfoBarDelegate(TabContents* contents); + explicit DefaultBrowserInfoBarDelegate(InfoBarTabHelper* infobar_helper, + PrefService* prefs); private: virtual ~DefaultBrowserInfoBarDelegate(); @@ -154,8 +155,8 @@ class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate { virtual bool Accept() OVERRIDE; virtual bool Cancel() OVERRIDE; - // The Profile that we restore sessions from. - Profile* profile_; + // The prefs to use. + PrefService* prefs_; // Whether the user clicked one of the buttons. bool action_taken_; @@ -170,9 +171,10 @@ class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate { }; DefaultBrowserInfoBarDelegate::DefaultBrowserInfoBarDelegate( - TabContents* contents) - : ConfirmInfoBarDelegate(contents), - profile_(Profile::FromBrowserContext(contents->browser_context())), + InfoBarTabHelper* infobar_helper, + PrefService* prefs) + : ConfirmInfoBarDelegate(infobar_helper), + prefs_(prefs), action_taken_(false), should_expire_(false), ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { @@ -225,7 +227,7 @@ bool DefaultBrowserInfoBarDelegate::Cancel() { action_taken_ = true; UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.DontSetAsDefault", 1); // User clicked "Don't ask me again", remember that. - profile_->GetPrefs()->SetBoolean(prefs::kCheckDefaultBrowser, false); + prefs_->SetBoolean(prefs::kCheckDefaultBrowser, false); return true; } @@ -253,14 +255,21 @@ void NotifyNotDefaultBrowserTask::Run() { Browser* browser = BrowserList::GetLastActive(); if (!browser) return; // Reached during ui tests. - // Don't show the info-bar if there are already info-bars showing. + // In ChromeBot tests, there might be a race. This line appears to get // called during shutdown and |tab| can be NULL. TabContentsWrapper* tab = browser->GetSelectedTabContentsWrapper(); - if (!tab || tab->infobar_tab_helper()->infobar_count() > 0) + if (!tab) return; - tab->infobar_tab_helper()->AddInfoBar( - new DefaultBrowserInfoBarDelegate(tab->tab_contents())); + + // 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) + return; + + infobar_helper->AddInfoBar( + new DefaultBrowserInfoBarDelegate(infobar_helper, + tab->profile()->GetPrefs())); } @@ -298,7 +307,8 @@ void CheckDefaultBrowserTask::Run() { // A delegate for the InfoBar shown when the previous session has crashed. class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate { public: - SessionCrashedInfoBarDelegate(Profile* profile, TabContents* contents); + SessionCrashedInfoBarDelegate(Profile* profile, + InfoBarTabHelper* infobar_helper); private: virtual ~SessionCrashedInfoBarDelegate(); @@ -318,8 +328,8 @@ class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate { SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate( Profile* profile, - TabContents* contents) - : ConfirmInfoBarDelegate(contents), + InfoBarTabHelper* infobar_helper) + : ConfirmInfoBarDelegate(infobar_helper), profile_(profile) { } @@ -1092,7 +1102,7 @@ void BrowserInit::LaunchWithProfile::AddCrashedInfoBarIfNecessary( // so that they can restore if they want. The delegate deletes itself when // it is closed. tab->infobar_tab_helper()->AddInfoBar( - new SessionCrashedInfoBarDelegate(profile_, tab->tab_contents())); + new SessionCrashedInfoBarDelegate(profile_, tab->infobar_tab_helper())); } } @@ -1119,7 +1129,7 @@ void BrowserInit::LaunchWithProfile::AddBadFlagsInfoBarIfNecessary( if (bad_flag) { tab->infobar_tab_helper()->AddInfoBar( new SimpleAlertInfoBarDelegate( - tab->tab_contents(), NULL, + tab->infobar_tab_helper(), NULL, l10n_util::GetStringFUTF16( IDS_BAD_FLAGS_WARNING_MESSAGE, UTF8ToUTF16(std::string("--") + bad_flag)), @@ -1129,7 +1139,7 @@ void BrowserInit::LaunchWithProfile::AddBadFlagsInfoBarIfNecessary( class LearnMoreInfoBar : public LinkInfoBarDelegate { public: - LearnMoreInfoBar(TabContents* tab_contents, + LearnMoreInfoBar(InfoBarTabHelper* infobar_helper, const string16& message, const GURL& url); virtual ~LearnMoreInfoBar(); @@ -1139,18 +1149,16 @@ class LearnMoreInfoBar : public LinkInfoBarDelegate { virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; private: - TabContents* const tab_contents_; string16 message_; GURL learn_more_url_; DISALLOW_COPY_AND_ASSIGN(LearnMoreInfoBar); }; -LearnMoreInfoBar::LearnMoreInfoBar(TabContents* tab_contents, +LearnMoreInfoBar::LearnMoreInfoBar(InfoBarTabHelper* infobar_helper, const string16& message, const GURL& url) - : LinkInfoBarDelegate(tab_contents), - tab_contents_(tab_contents), + : LinkInfoBarDelegate(infobar_helper), message_(message), learn_more_url_(url) { } @@ -1170,8 +1178,8 @@ string16 LearnMoreInfoBar::GetLinkText() const { } bool LearnMoreInfoBar::LinkClicked(WindowOpenDisposition disposition) { - tab_contents_->OpenURL(learn_more_url_, GURL(), disposition, - PageTransition::LINK); + owner()->tab_contents()->OpenURL(learn_more_url_, GURL(), disposition, + PageTransition::LINK); return false; } @@ -1188,7 +1196,7 @@ void BrowserInit::LaunchWithProfile:: string16 message = l10n_util::GetStringUTF16( IDS_DNS_CERT_PROVENANCE_CHECKING_WARNING_MESSAGE); tab->infobar_tab_helper()->AddInfoBar( - new LearnMoreInfoBar(tab->tab_contents(), + new LearnMoreInfoBar(tab->infobar_tab_helper(), message, GURL(kLearnMoreURL))); } @@ -1211,8 +1219,9 @@ void BrowserInit::LaunchWithProfile::AddObsoleteSystemInfoBarIfNecessary( // Link to an article in the help center on minimum system requirements. const char* kLearnMoreURL = "http://www.google.com/support/chrome/bin/answer.py?answer=95411"; - tab->infobar_tab_helper()->AddInfoBar( - new LearnMoreInfoBar(tab->tab_contents(), + InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); + infobar_helper->AddInfoBar( + new LearnMoreInfoBar(infobar_helper, message, GURL(kLearnMoreURL))); } diff --git a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm index 6b01865..df9c0e2 100644 --- a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm +++ b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm @@ -215,8 +215,9 @@ void CollectedCookiesMac::OnSheetDidEnd(NSWindow* sheet) { - (void)windowWillClose:(NSNotification*)notif { if (contentSettingsChanged_) { - wrapper_->infobar_tab_helper()->AddInfoBar( - new CollectedCookiesInfoBarDelegate(wrapper_->tab_contents())); + InfoBarTabHelper* infobar_helper = wrapper_->infobar_tab_helper(); + infobar_helper->AddInfoBar( + new CollectedCookiesInfoBarDelegate(infobar_helper)); } [allowedOutlineView_ setDelegate:nil]; [blockedOutlineView_ setDelegate:nil]; diff --git a/chrome/browser/ui/cocoa/extensions/extension_installed_bubble_bridge.mm b/chrome/browser/ui/cocoa/extensions/extension_installed_bubble_bridge.mm index 66757a7..98e1609 100644 --- a/chrome/browser/ui/cocoa/extensions/extension_installed_bubble_bridge.mm +++ b/chrome/browser/ui/cocoa/extensions/extension_installed_bubble_bridge.mm @@ -42,9 +42,10 @@ static void ShowGenericExtensionInstalledInfoBar( extension_name) + UTF8ToUTF16(" ") + l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO_MAC); + InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); InfoBarDelegate* delegate = new SimpleAlertInfoBarDelegate( - wrapper->tab_contents(), new gfx::Image(new SkBitmap(icon)), msg, true); - wrapper->infobar_tab_helper()->AddInfoBar(delegate); + infobar_helper, new gfx::Image(new SkBitmap(icon)), msg, true); + infobar_helper->AddInfoBar(delegate); } namespace browser { 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 082af8e..7f35e2a 100644 --- a/chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.mm @@ -36,8 +36,8 @@ NSButton* CreateNSButtonWithResourceIDAndParameter( [super dealloc]; } -- (id) initWithDelegate:(InfoBarDelegate *)delegate - owner:(TabContentsWrapper*)owner { +- (id)initWithDelegate:(InfoBarDelegate*)delegate + owner:(InfoBarTabHelper*)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 55843bb..244c4d6 100644 --- a/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm @@ -9,6 +9,7 @@ #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" #import "chrome/browser/ui/cocoa/animatable_view.h" #import "chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h" #import "chrome/browser/ui/cocoa/menu_button.h" @@ -136,7 +137,7 @@ class InfobarBridge : public ExtensionInfoBarDelegate::DelegateObserver, @implementation ExtensionInfoBarController - (id)initWithDelegate:(InfoBarDelegate*)delegate - owner:(TabContentsWrapper*)owner + owner:(InfoBarTabHelper*)owner window:(NSWindow*)window { if ((self = [super initWithDelegate:delegate owner:owner])) { window_ = window; @@ -266,7 +267,7 @@ class InfobarBridge : public ExtensionInfoBarDelegate::DelegateObserver, @end -InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { +InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { NSWindow* window = [(NSView*)owner->tab_contents()->GetContentNativeView() window]; ExtensionInfoBarController* controller = diff --git a/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm b/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm index 65f927a..7f2483d 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm @@ -4,9 +4,9 @@ #include "base/logging.h" #include "base/mac/mac_util.h" +#include "chrome/browser/infobars/infobar.h" #include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" -#include "chrome/browser/tab_contents/infobar.h" #import "chrome/browser/ui/cocoa/animatable_view.h" #import "chrome/browser/ui/cocoa/browser_window_controller.h" #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" @@ -31,11 +31,11 @@ class InfoBarNotificationObserver : public NotificationObserver { void Observe(int type, const NotificationSource& source, const NotificationDetails& details) { - TabContentsWrapper* tab_contents = Source<TabContentsWrapper>(source).ptr(); + InfoBarTabHelper* infobar_helper = Source<InfoBarTabHelper>(source).ptr(); switch (type) { case chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED: [controller_ addInfoBar:Details<InfoBarAddedDetails>(details)-> - CreateInfoBar(tab_contents) + CreateInfoBar(infobar_helper) animate:YES]; break; @@ -54,7 +54,7 @@ class InfoBarNotificationObserver : public NotificationObserver { [controller_ closeInfoBarsForDelegate:replaced_details->first animate:NO]; [controller_ addInfoBar:replaced_details->second-> - CreateInfoBar(tab_contents) + CreateInfoBar(infobar_helper) animate:NO]; break; } @@ -144,11 +144,11 @@ class InfoBarNotificationObserver : public NotificationObserver { currentTabContents_->infobar_tab_helper(); for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { InfoBar* infobar = infobar_helper-> - GetInfoBarDelegateAt(i)->CreateInfoBar(currentTabContents_); + GetInfoBarDelegateAt(i)->CreateInfoBar(infobar_helper); [self addInfoBar:infobar animate:NO]; } - Source<TabContentsWrapper> source(currentTabContents_); + Source<InfoBarTabHelper> source(infobar_helper); registrar_.Add(infoBarObserver_.get(), chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, source); registrar_.Add(infoBarObserver_.get(), diff --git a/chrome/browser/ui/cocoa/infobars/infobar_controller.h b/chrome/browser/ui/cocoa/infobars/infobar_controller.h index 32e5633..5570d52 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_controller.h +++ b/chrome/browser/ui/cocoa/infobars/infobar_controller.h @@ -11,8 +11,8 @@ @class HoverCloseButton; @protocol InfoBarContainer; class InfoBarDelegate; +class InfoBarTabHelper; @class InfoBarGradientView; -class TabContentsWrapper; // A controller for an infobar in the browser window. There is one // controller per infobar view. The base InfoBarController is able to @@ -21,7 +21,7 @@ class TabContentsWrapper; @interface InfoBarController : NSViewController<NSTextViewDelegate> { @private id<InfoBarContainer> containerController_; // weak, owns us - TabContentsWrapper* owner_; // weak + InfoBarTabHelper* owner_; // weak BOOL infoBarClosing_; @protected @@ -46,7 +46,7 @@ class TabContentsWrapper; // Initializes a new InfoBarController. - (id)initWithDelegate:(InfoBarDelegate*)delegate - owner:(TabContentsWrapper*)owner; + owner:(InfoBarTabHelper*)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 bc7889d..d7e8177 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_controller.mm @@ -50,7 +50,7 @@ const float kAnimateCloseDuration = 0.12; @synthesize delegate = delegate_; - (id)initWithDelegate:(InfoBarDelegate*)delegate - owner:(TabContentsWrapper*)owner { + owner:(InfoBarTabHelper*)owner { DCHECK(delegate); if ((self = [super initWithNibName:@"InfoBar" bundle:base::mac::MainAppBundle()])) { @@ -127,7 +127,7 @@ const float kAnimateCloseDuration = 0.12; - (void)removeSelf { DCHECK(owner_); - owner_->infobar_tab_helper()->RemoveInfoBar(delegate_); + owner_->RemoveInfoBar(delegate_); } - (AnimatableView*)animatableView { @@ -444,13 +444,13 @@ const float kAnimateCloseDuration = 0.12; ////////////////////////////////////////////////////////////////////////// // CreateInfoBar() implementations -InfoBar* LinkInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { +InfoBar* LinkInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { LinkInfoBarController* controller = [[LinkInfoBarController alloc] initWithDelegate:this owner:owner]; return new InfoBar(controller, this); } -InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { +InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { ConfirmInfoBarController* controller = [[ConfirmInfoBarController alloc] initWithDelegate:this owner:owner]; return new InfoBar(controller, this); diff --git a/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm b/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm index d4b24c1..1ffffc54 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm @@ -104,7 +104,7 @@ class LinkInfoBarControllerTest : public CocoaProfileTest, delegate_ = new MockLinkInfoBarDelegate(this); controller_.reset([[TestLinkInfoBarController alloc] initWithDelegate:delegate_ - owner:tab_contents_.get()]); + owner:tab_contents_.get()->infobar_tab_helper()]); container_.reset( [[InfoBarContainerTest alloc] initWithController:controller_]); [controller_ setContainerController:container_]; @@ -148,7 +148,7 @@ class ConfirmInfoBarControllerTest : public CocoaProfileTest, delegate_ = new MockConfirmInfoBarDelegate(this); controller_.reset([[TestConfirmInfoBarController alloc] initWithDelegate:delegate_ - owner:tab_contents_.get()]); + owner:tab_contents_.get()->infobar_tab_helper()]); container_.reset( [[InfoBarContainerTest alloc] initWithController:controller_]); [controller_ setContainerController:container_]; diff --git a/chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h b/chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h index 1c398a9..2ba9480 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h +++ b/chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h @@ -6,7 +6,7 @@ #define CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_GRADIENT_VIEW_H_ #pragma once -#include "chrome/browser/tab_contents/infobar_delegate.h" +#include "chrome/browser/infobars/infobar_delegate.h" #import "chrome/browser/ui/cocoa/vertical_gradient_view.h" #import <Cocoa/Cocoa.h> diff --git a/chrome/browser/ui/cocoa/infobars/infobar_gradient_view.mm b/chrome/browser/ui/cocoa/infobars/infobar_gradient_view.mm index f87daf6..55c9ac9 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_gradient_view.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_gradient_view.mm @@ -5,7 +5,7 @@ #include "chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h" #include "base/memory/scoped_nsobject.h" -#include "chrome/browser/tab_contents/infobar.h" +#include "chrome/browser/infobars/infobar.h" #import "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/browser_window_controller.h" #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" diff --git a/chrome/browser/ui/cocoa/infobars/translate_infobar_base.mm b/chrome/browser/ui/cocoa/infobars/translate_infobar_base.mm index 644002e..584c68e 100644 --- a/chrome/browser/ui/cocoa/infobars/translate_infobar_base.mm +++ b/chrome/browser/ui/cocoa/infobars/translate_infobar_base.mm @@ -110,7 +110,7 @@ void AddMenuItem(NSMenu *menu, id target, SEL selector, NSString* title, } // namespace TranslateInfoBarUtilities // TranslateInfoBarDelegate views specific method: -InfoBar* TranslateInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { +InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { TranslateInfoBarControllerBase* infobar_controller = NULL; switch (type_) { case BEFORE_TRANSLATE: @@ -181,7 +181,7 @@ InfoBar* TranslateInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { @implementation TranslateInfoBarControllerBase - (id)initWithDelegate:(InfoBarDelegate*)delegate - owner:(TabContentsWrapper*)owner { + owner:(InfoBarTabHelper*)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 874f3d9..66bf41b7 100644 --- a/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm +++ b/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm @@ -34,8 +34,10 @@ class MockTranslateInfoBarDelegate : public TranslateInfoBarDelegate { public: MockTranslateInfoBarDelegate(TranslateInfoBarDelegate::Type type, TranslateErrors::Type error, - TabContents* contents) - : TranslateInfoBarDelegate(type, error, contents, "en", "es"){ + InfoBarTabHelper* infobar_helper, + PrefService* prefs) + : TranslateInfoBarDelegate(type, error, infobar_helper, prefs, + "en", "es") { // Start out in the "Before Translate" state. type_ = type; @@ -67,16 +69,11 @@ class MockTranslateInfoBarDelegate : public TranslateInfoBarDelegate { class TranslationInfoBarTest : public CocoaProfileTest { public: - scoped_ptr<TabContentsWrapper> tab_contents; - scoped_ptr<MockTranslateInfoBarDelegate> infobar_delegate; - scoped_nsobject<TranslateInfoBarControllerBase> infobar_controller; - - public: // Each test gets a single Mock translate delegate for the lifetime of // the test. virtual void SetUp() { CocoaProfileTest::SetUp(); - tab_contents.reset(new TabContentsWrapper(new TabContents( + tab_contents_.reset(new TabContentsWrapper(new TabContents( profile(), NULL, MSG_ROUTING_NONE, NULL, NULL))); CreateInfoBar(); } @@ -89,35 +86,42 @@ class TranslationInfoBarTest : public CocoaProfileTest { TranslateErrors::Type error = TranslateErrors::NONE; if (type == TranslateInfoBarDelegate::TRANSLATION_ERROR) error = TranslateErrors::NETWORK; - infobar_delegate.reset(new MockTranslateInfoBarDelegate(type, error, - tab_contents->tab_contents())); - [[infobar_controller view] removeFromSuperview]; + infobar_delegate_.reset(new MockTranslateInfoBarDelegate( + type, + error, + tab_contents_->infobar_tab_helper(), + tab_contents_->profile()->GetPrefs())); + [[infobar_controller_ view] removeFromSuperview]; scoped_ptr<InfoBar> infobar( - static_cast<InfoBarDelegate*>(infobar_delegate.get())-> - CreateInfoBar(tab_contents.get())); - infobar_controller.reset( + static_cast<InfoBarDelegate*>(infobar_delegate_.get())-> + CreateInfoBar(tab_contents_->infobar_tab_helper())); + infobar_controller_.reset( reinterpret_cast<TranslateInfoBarControllerBase*>( infobar->controller())); // We need to set the window to be wide so that the options button // doesn't overlap the other buttons. [test_window() setContentSize:NSMakeSize(2000, 500)]; - [[infobar_controller view] setFrame:NSMakeRect(0, 0, 2000, 500)]; - [[test_window() contentView] addSubview:[infobar_controller view]]; + [[infobar_controller_ view] setFrame:NSMakeRect(0, 0, 2000, 500)]; + [[test_window() contentView] addSubview:[infobar_controller_ view]]; } + + scoped_ptr<TabContentsWrapper> tab_contents_; + scoped_ptr<MockTranslateInfoBarDelegate> infobar_delegate_; + scoped_nsobject<TranslateInfoBarControllerBase> infobar_controller_; }; // Check that we can instantiate a Translate Infobar correctly. TEST_F(TranslationInfoBarTest, Instantiate) { CreateInfoBar(); - ASSERT_TRUE(infobar_controller.get()); + ASSERT_TRUE(infobar_controller_.get()); } // Check that clicking the Translate button calls Translate(). TEST_F(TranslationInfoBarTest, TranslateCalledOnButtonPress) { CreateInfoBar(); - EXPECT_CALL(*infobar_delegate, Translate()).Times(1); - [infobar_controller ok:nil]; + EXPECT_CALL(*infobar_delegate_, Translate()).Times(1); + [infobar_controller_ ok:nil]; } // Check that clicking the "Retry" button calls Translate() when we're @@ -125,26 +129,26 @@ TEST_F(TranslationInfoBarTest, TranslateCalledOnButtonPress) { TEST_F(TranslationInfoBarTest, TranslateCalledInErrorMode) { CreateInfoBar(TranslateInfoBarDelegate::TRANSLATION_ERROR); - EXPECT_CALL(*infobar_delegate, Translate()).Times(1); + EXPECT_CALL(*infobar_delegate_, Translate()).Times(1); - [infobar_controller ok:nil]; + [infobar_controller_ ok:nil]; } // Check that clicking the "Show Original button calls RevertTranslation(). TEST_F(TranslationInfoBarTest, RevertCalledOnButtonPress) { CreateInfoBar(); - EXPECT_CALL(*infobar_delegate, RevertTranslation()).Times(1); - [infobar_controller showOriginal:nil]; + EXPECT_CALL(*infobar_delegate_, RevertTranslation()).Times(1); + [infobar_controller_ showOriginal:nil]; } // Check that items in the options menu are hooked up correctly. TEST_F(TranslationInfoBarTest, OptionsMenuItemsHookedUp) { - EXPECT_CALL(*infobar_delegate, Translate()) + EXPECT_CALL(*infobar_delegate_, Translate()) .Times(0); - [infobar_controller rebuildOptionsMenu:NO]; - NSMenu* optionsMenu = [infobar_controller optionsMenu]; + [infobar_controller_ rebuildOptionsMenu:NO]; + NSMenu* optionsMenu = [infobar_controller_ optionsMenu]; NSArray* optionsMenuItems = [optionsMenu itemArray]; EXPECT_EQ(7U, [optionsMenuItems count]); @@ -154,7 +158,7 @@ TEST_F(TranslationInfoBarTest, OptionsMenuItemsHookedUp) { for (NSUInteger i = 1; i < [optionsMenuItems count]; ++i) { NSMenuItem* item = [optionsMenuItems objectAtIndex:i]; if (![item isSeparatorItem]) - EXPECT_EQ([item target], infobar_controller.get()); + EXPECT_EQ([item target], infobar_controller_.get()); } NSMenuItem* alwaysTranslateLanguateItem = [optionsMenuItems objectAtIndex:1]; NSMenuItem* neverTranslateLanguateItem = [optionsMenuItems objectAtIndex:2]; @@ -164,21 +168,21 @@ TEST_F(TranslationInfoBarTest, OptionsMenuItemsHookedUp) { NSMenuItem* aboutTranslateItem = [optionsMenuItems objectAtIndex:6]; { - EXPECT_CALL(*infobar_delegate, ToggleAlwaysTranslate()) + EXPECT_CALL(*infobar_delegate_, ToggleAlwaysTranslate()) .Times(1); - [infobar_controller optionsMenuChanged:alwaysTranslateLanguateItem]; + [infobar_controller_ optionsMenuChanged:alwaysTranslateLanguateItem]; } { - EXPECT_CALL(*infobar_delegate, ToggleLanguageBlacklist()) + EXPECT_CALL(*infobar_delegate_, ToggleLanguageBlacklist()) .Times(1); - [infobar_controller optionsMenuChanged:neverTranslateLanguateItem]; + [infobar_controller_ optionsMenuChanged:neverTranslateLanguateItem]; } { - EXPECT_CALL(*infobar_delegate, ToggleSiteBlacklist()) + EXPECT_CALL(*infobar_delegate_, ToggleSiteBlacklist()) .Times(1); - [infobar_controller optionsMenuChanged:neverTranslateSiteItem]; + [infobar_controller_ optionsMenuChanged:neverTranslateSiteItem]; } { @@ -194,13 +198,13 @@ TEST_F(TranslationInfoBarTest, OptionsMenuItemsHookedUp) { // translate" mode doesn't trigger a translation or change state. // http://crbug.com/36666 TEST_F(TranslationInfoBarTest, Bug36666) { - EXPECT_CALL(*infobar_delegate, Translate()) + EXPECT_CALL(*infobar_delegate_, Translate()) .Times(0); CreateInfoBar(); int arbitrary_index = 2; - [infobar_controller sourceLanguageModified:arbitrary_index]; - EXPECT_CALL(*infobar_delegate, Translate()) + [infobar_controller_ sourceLanguageModified:arbitrary_index]; + EXPECT_CALL(*infobar_delegate_, Translate()) .Times(0); } @@ -208,13 +212,13 @@ TEST_F(TranslationInfoBarTest, Bug36666) { // each of the states. // http://crbug.com/36895 TEST_F(TranslationInfoBarTest, Bug36895) { - EXPECT_CALL(*infobar_delegate, Translate()) + EXPECT_CALL(*infobar_delegate_, Translate()) .Times(0); for (size_t i = 0; i < arraysize(kTranslateToolbarStates); ++i) { CreateInfoBar(kTranslateToolbarStates[i]); EXPECT_TRUE( - [infobar_controller verifyLayout]) << "Layout wrong, for state #" << i; + [infobar_controller_ verifyLayout]) << "Layout wrong, for state #" << i; } } @@ -228,7 +232,7 @@ TEST_F(TranslationInfoBarTest, TriggerShowAlwaysTranslateButton) { } CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE); BeforeTranslateInfobarController* controller = - (BeforeTranslateInfobarController*)infobar_controller.get(); + (BeforeTranslateInfobarController*)infobar_controller_.get(); EXPECT_TRUE([[controller alwaysTranslateButton] superview] != nil); EXPECT_TRUE([[controller neverTranslateButton] superview] == nil); } @@ -243,7 +247,7 @@ TEST_F(TranslationInfoBarTest, TriggerShowNeverTranslateButton) { } CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE); BeforeTranslateInfobarController* controller = - (BeforeTranslateInfobarController*)infobar_controller.get(); + (BeforeTranslateInfobarController*)infobar_controller_.get(); EXPECT_TRUE([[controller alwaysTranslateButton] superview] == nil); EXPECT_TRUE([[controller neverTranslateButton] superview] != nil); } diff --git a/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm b/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm index eded2c8..d994d23 100644 --- a/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm +++ b/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm @@ -38,7 +38,8 @@ namespace { class KeystonePromotionInfoBarDelegate : public ConfirmInfoBarDelegate { public: - explicit KeystonePromotionInfoBarDelegate(TabContents* tab_contents); + KeystonePromotionInfoBarDelegate(InfoBarTabHelper* infobar_helper, + PrefService* prefs); private: virtual ~KeystonePromotionInfoBarDelegate(); @@ -56,8 +57,8 @@ class KeystonePromotionInfoBarDelegate : public ConfirmInfoBarDelegate { virtual bool Accept() OVERRIDE; virtual bool Cancel() OVERRIDE; - // The TabContents' profile. - Profile* profile_; // weak + // The prefs to use. + PrefService* prefs_; // weak // Whether the info bar should be dismissed on the next navigation. bool can_expire_; @@ -69,9 +70,10 @@ class KeystonePromotionInfoBarDelegate : public ConfirmInfoBarDelegate { }; KeystonePromotionInfoBarDelegate::KeystonePromotionInfoBarDelegate( - TabContents* tab_contents) - : ConfirmInfoBarDelegate(tab_contents), - profile_(Profile::FromBrowserContext(tab_contents->browser_context())), + InfoBarTabHelper* infobar_helper, + PrefService* prefs) + : ConfirmInfoBarDelegate(infobar_helper), + prefs_(prefs), can_expire_(false), ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { const int kCanExpireOnNavigationAfterMilliseconds = 8 * 1000; @@ -111,7 +113,7 @@ bool KeystonePromotionInfoBarDelegate::Accept() { } bool KeystonePromotionInfoBarDelegate::Cancel() { - profile_->GetPrefs()->SetBoolean(prefs::kShowUpdatePromotionInfoBar, false); + prefs_->SetBoolean(prefs::kShowUpdatePromotionInfoBar, false); return true; } @@ -192,9 +194,14 @@ bool KeystonePromotionInfoBarDelegate::Cancel() { // Only show if no other info bars are showing, because that's how the // default browser info bar works. - if (wrapper && wrapper->infobar_tab_helper()->infobar_count() == 0) { - wrapper->infobar_tab_helper()->AddInfoBar( - new KeystonePromotionInfoBarDelegate(wrapper->tab_contents())); + if (wrapper) { + InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); + if (infobar_helper->infobar_count() == 0) { + infobar_helper->AddInfoBar( + new KeystonePromotionInfoBarDelegate( + infobar_helper, + wrapper->profile()->GetPrefs())); + } } } } diff --git a/chrome/browser/ui/collected_cookies_infobar_delegate.cc b/chrome/browser/ui/collected_cookies_infobar_delegate.cc index 5e97a7d..0bd0d4f 100644 --- a/chrome/browser/ui/collected_cookies_infobar_delegate.cc +++ b/chrome/browser/ui/collected_cookies_infobar_delegate.cc @@ -5,6 +5,7 @@ #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" #include "base/logging.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "content/browser/tab_contents/tab_contents.h" #include "grit/generated_resources.h" #include "grit/theme_resources_standard.h" @@ -12,9 +13,8 @@ #include "ui/base/resource/resource_bundle.h" CollectedCookiesInfoBarDelegate::CollectedCookiesInfoBarDelegate( - TabContents* tab_contents) - : ConfirmInfoBarDelegate(tab_contents), - tab_contents_(tab_contents) { + InfoBarTabHelper* infobar_helper) + : ConfirmInfoBarDelegate(infobar_helper) { } gfx::Image* CollectedCookiesInfoBarDelegate::GetIcon() const { @@ -41,6 +41,6 @@ string16 CollectedCookiesInfoBarDelegate::GetButtonLabel( } bool CollectedCookiesInfoBarDelegate::Accept() { - tab_contents_->controller().Reload(true); + owner()->tab_contents()->controller().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 fd2bf8e..71186fc 100644 --- a/chrome/browser/ui/collected_cookies_infobar_delegate.h +++ b/chrome/browser/ui/collected_cookies_infobar_delegate.h @@ -14,7 +14,7 @@ // the reload right from the infobar. class CollectedCookiesInfoBarDelegate : public ConfirmInfoBarDelegate { public: - explicit CollectedCookiesInfoBarDelegate(TabContents* tab_contents); + explicit CollectedCookiesInfoBarDelegate(InfoBarTabHelper* infobar_helper); private: // ConfirmInfoBarDelegate overrides. @@ -25,8 +25,6 @@ class CollectedCookiesInfoBarDelegate : public ConfirmInfoBarDelegate { virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; virtual bool Accept() OVERRIDE; - TabContents* tab_contents_; - DISALLOW_COPY_AND_ASSIGN(CollectedCookiesInfoBarDelegate); }; diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc index a5eb196..887e6a6 100644 --- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc @@ -318,8 +318,9 @@ class ContentSettingCookiesBubbleModel : public ContentSettingSingleRadioGroup { virtual ~ContentSettingCookiesBubbleModel() { if (settings_changed()) { - tab_contents()->infobar_tab_helper()->AddInfoBar( - new CollectedCookiesInfoBarDelegate(tab_contents()->tab_contents())); + InfoBarTabHelper* infobar_helper = tab_contents()->infobar_tab_helper(); + infobar_helper->AddInfoBar( + new CollectedCookiesInfoBarDelegate(infobar_helper)); } } diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc index 30c7b20..3ff9296 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.cc +++ b/chrome/browser/ui/gtk/browser_window_gtk.cc @@ -1219,7 +1219,7 @@ void BrowserWindowGtk::ActiveTabChanged(TabContentsWrapper* old_contents, // Update various elements that are interested in knowing the current // TabContents. - infobar_container_->ChangeTabContents(new_contents); + infobar_container_->ChangeTabContents(new_contents->infobar_tab_helper()); contents_container_->SetTab(new_contents); UpdateDevToolsForContents(new_contents->tab_contents()); diff --git a/chrome/browser/ui/gtk/browser_window_gtk.h b/chrome/browser/ui/gtk/browser_window_gtk.h index 818f8f8..58f7d9e 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.h +++ b/chrome/browser/ui/gtk/browser_window_gtk.h @@ -13,8 +13,8 @@ #include "base/memory/scoped_ptr.h" #include "base/timer.h" #include "build/build_config.h" +#include "chrome/browser/infobars/infobar_container.h" #include "chrome/browser/prefs/pref_member.h" -#include "chrome/browser/tab_contents/infobar_container.h" #include "chrome/browser/tabs/tab_strip_model_observer.h" #include "chrome/browser/ui/browser_window.h" #include "ui/base/gtk/gtk_signal.h" diff --git a/chrome/browser/ui/gtk/collected_cookies_gtk.cc b/chrome/browser/ui/gtk/collected_cookies_gtk.cc index eb1095b..e175f60 100644 --- a/chrome/browser/ui/gtk/collected_cookies_gtk.cc +++ b/chrome/browser/ui/gtk/collected_cookies_gtk.cc @@ -428,8 +428,9 @@ void CollectedCookiesGtk::Observe(int type, void CollectedCookiesGtk::OnClose(GtkWidget* close_button) { if (status_changed_) { - wrapper_->infobar_tab_helper()->AddInfoBar( - new CollectedCookiesInfoBarDelegate(wrapper_->tab_contents())); + InfoBarTabHelper* infobar_helper = wrapper_->infobar_tab_helper(); + infobar_helper->AddInfoBar( + new CollectedCookiesInfoBarDelegate(infobar_helper)); } window_->CloseConstrainedWindow(); } diff --git a/chrome/browser/ui/gtk/infobars/after_translate_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/after_translate_infobar_gtk.cc index d806a73..75da0d4 100644 --- a/chrome/browser/ui/gtk/infobars/after_translate_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/after_translate_infobar_gtk.cc @@ -15,7 +15,7 @@ #include "ui/base/l10n/l10n_util.h" AfterTranslateInfoBar::AfterTranslateInfoBar( - TabContentsWrapper* owner, + InfoBarTabHelper* owner, TranslateInfoBarDelegate* delegate) : TranslateInfoBarBase(owner, delegate), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { diff --git a/chrome/browser/ui/gtk/infobars/after_translate_infobar_gtk.h b/chrome/browser/ui/gtk/infobars/after_translate_infobar_gtk.h index 73d2b91..c025495 100644 --- a/chrome/browser/ui/gtk/infobars/after_translate_infobar_gtk.h +++ b/chrome/browser/ui/gtk/infobars/after_translate_infobar_gtk.h @@ -13,7 +13,7 @@ class TranslateInfoBarDelegate; class AfterTranslateInfoBar : public TranslateInfoBarBase { public: - AfterTranslateInfoBar(TabContentsWrapper* owner, + AfterTranslateInfoBar(InfoBarTabHelper* owner, TranslateInfoBarDelegate* delegate); virtual ~AfterTranslateInfoBar(); diff --git a/chrome/browser/ui/gtk/infobars/before_translate_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/before_translate_infobar_gtk.cc index 8dca63b..3e458de 100644 --- a/chrome/browser/ui/gtk/infobars/before_translate_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/before_translate_infobar_gtk.cc @@ -13,7 +13,7 @@ #include "ui/base/l10n/l10n_util.h" BeforeTranslateInfoBar::BeforeTranslateInfoBar( - TabContentsWrapper* owner, + InfoBarTabHelper* owner, TranslateInfoBarDelegate* delegate) : TranslateInfoBarBase(owner, delegate) { } diff --git a/chrome/browser/ui/gtk/infobars/before_translate_infobar_gtk.h b/chrome/browser/ui/gtk/infobars/before_translate_infobar_gtk.h index f412c81..1f3a711 100644 --- a/chrome/browser/ui/gtk/infobars/before_translate_infobar_gtk.h +++ b/chrome/browser/ui/gtk/infobars/before_translate_infobar_gtk.h @@ -12,7 +12,7 @@ class TranslateInfoBarDelegate; class BeforeTranslateInfoBar : public TranslateInfoBarBase { public: - BeforeTranslateInfoBar(TabContentsWrapper* owner, + BeforeTranslateInfoBar(InfoBarTabHelper* owner, TranslateInfoBarDelegate* delegate); virtual ~BeforeTranslateInfoBar(); diff --git a/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc index 06b0fb6..537f989 100644 --- a/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc @@ -14,13 +14,13 @@ // ConfirmInfoBarDelegate ------------------------------------------------------ -InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { +InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { return new ConfirmInfoBarGtk(owner, this); } // ConfirmInfoBarGtk ----------------------------------------------------------- -ConfirmInfoBarGtk::ConfirmInfoBarGtk(TabContentsWrapper* owner, +ConfirmInfoBarGtk::ConfirmInfoBarGtk(InfoBarTabHelper* owner, ConfirmInfoBarDelegate* delegate) : InfoBarGtk(owner, delegate), size_group_(NULL) { diff --git a/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.h b/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.h index 35dc89c..69842a23 100644 --- a/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.h +++ b/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.h @@ -19,7 +19,7 @@ typedef struct _GtkWidget GtkWidget; // "Would you like to do X? [Yes] [No] _Learn More_ [x]" class ConfirmInfoBarGtk : public InfoBarGtk { public: - ConfirmInfoBarGtk(TabContentsWrapper* owner, + ConfirmInfoBarGtk(InfoBarTabHelper* owner, ConfirmInfoBarDelegate* delegate); private: diff --git a/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc index 9b57976..f3ce57c 100644 --- a/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc @@ -24,7 +24,7 @@ #include "ui/gfx/gtk_util.h" #include "ui/gfx/image/image.h" -ExtensionInfoBarGtk::ExtensionInfoBarGtk(TabContentsWrapper* owner, +ExtensionInfoBarGtk::ExtensionInfoBarGtk(InfoBarTabHelper* owner, ExtensionInfoBarDelegate* delegate) : InfoBarGtk(owner, delegate), tracker_(this), @@ -199,6 +199,6 @@ gboolean ExtensionInfoBarGtk::OnExpose(GtkWidget* sender, return FALSE; } -InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { +InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { return new ExtensionInfoBarGtk(owner, this); } diff --git a/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.h b/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.h index 94e2a55..84146f5 100644 --- a/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.h +++ b/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.h @@ -23,7 +23,7 @@ class ExtensionInfoBarGtk : public InfoBarGtk, public ImageLoadingTracker::Observer, public MenuGtk::Delegate { public: - ExtensionInfoBarGtk(TabContentsWrapper* owner, + ExtensionInfoBarGtk(InfoBarTabHelper* owner, ExtensionInfoBarDelegate* delegate); virtual ~ExtensionInfoBarGtk(); diff --git a/chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc b/chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc index 96b221f..e42a03d 100644 --- a/chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc @@ -9,8 +9,8 @@ #include <utility> #include "base/message_loop.h" +#include "chrome/browser/infobars/infobar_delegate.h" #include "chrome/browser/platform_util.h" -#include "chrome/browser/tab_contents/infobar_delegate.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/gtk/browser_window_gtk.h" #include "chrome/browser/ui/gtk/gtk_util.h" diff --git a/chrome/browser/ui/gtk/infobars/infobar_container_gtk.h b/chrome/browser/ui/gtk/infobars/infobar_container_gtk.h index 16b5f27..feb3faf 100644 --- a/chrome/browser/ui/gtk/infobars/infobar_container_gtk.h +++ b/chrome/browser/ui/gtk/infobars/infobar_container_gtk.h @@ -10,7 +10,7 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" -#include "chrome/browser/tab_contents/infobar_container.h" +#include "chrome/browser/infobars/infobar_container.h" #include "ui/base/gtk/owned_widget_gtk.h" class InfoBar; diff --git a/chrome/browser/ui/gtk/infobars/infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/infobar_gtk.cc index 2d55c95..e9b9b30 100644 --- a/chrome/browser/ui/gtk/infobars/infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/infobar_gtk.cc @@ -5,6 +5,8 @@ #include "chrome/browser/ui/gtk/infobars/infobar_gtk.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/gtk/browser_window_gtk.h" #include "chrome/browser/ui/gtk/custom_button.h" #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" @@ -13,6 +15,7 @@ #include "chrome/browser/ui/gtk/infobars/infobar_container_gtk.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_notification_types.h" +#include "content/browser/tab_contents/tab_contents.h" #include "content/common/notification_service.h" #include "ui/base/gtk/gtk_expanded_container.h" #include "ui/base/gtk/gtk_hig_constants.h" @@ -46,9 +49,10 @@ const int InfoBar::kDefaultBarTargetHeight = 36; // static const int InfoBarGtk::kEndOfLabelSpacing = 6; -InfoBarGtk::InfoBarGtk(TabContentsWrapper* owner, InfoBarDelegate* delegate) +InfoBarGtk::InfoBarGtk(InfoBarTabHelper* owner, InfoBarDelegate* delegate) : InfoBar(owner, delegate), - theme_service_(GtkThemeService::GetFrom(owner->profile())), + theme_service_(GtkThemeService::GetFrom(Profile::FromBrowserContext( + owner->tab_contents()->browser_context()))), signals_(new ui::GtkSignalRegistrar) { DCHECK(delegate); // Create |hbox_| and pad the sides. diff --git a/chrome/browser/ui/gtk/infobars/infobar_gtk.h b/chrome/browser/ui/gtk/infobars/infobar_gtk.h index 1277e9a..5835175 100644 --- a/chrome/browser/ui/gtk/infobars/infobar_gtk.h +++ b/chrome/browser/ui/gtk/infobars/infobar_gtk.h @@ -10,8 +10,8 @@ #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/tab_contents/infobar_delegate.h" -#include "chrome/browser/tab_contents/infobar.h" +#include "chrome/browser/infobars/infobar.h" +#include "chrome/browser/infobars/infobar_delegate.h" #include "chrome/browser/ui/gtk/menu_gtk.h" #include "content/common/notification_observer.h" #include "content/common/notification_registrar.h" @@ -21,7 +21,6 @@ class CustomDrawButton; class GtkThemeService; -class InfoBarDelegate; class MenuGtk; namespace ui { @@ -32,7 +31,7 @@ class MenuModel; class InfoBarGtk : public InfoBar, public NotificationObserver { public: - InfoBarGtk(TabContentsWrapper* owner, InfoBarDelegate* delegate); + InfoBarGtk(InfoBarTabHelper* owner, InfoBarDelegate* delegate); virtual ~InfoBarGtk(); // Get the top level native GTK widget for this infobar. diff --git a/chrome/browser/ui/gtk/infobars/link_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/link_infobar_gtk.cc index f3a7c2c..f375e7a 100644 --- a/chrome/browser/ui/gtk/infobars/link_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/link_infobar_gtk.cc @@ -9,13 +9,13 @@ // LinkInfoBarDelegate --------------------------------------------------------- -InfoBar* LinkInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { +InfoBar* LinkInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { return new LinkInfoBarGtk(owner, this); } // LinkInfoBarGtk -------------------------------------------------------------- -LinkInfoBarGtk::LinkInfoBarGtk(TabContentsWrapper* owner, +LinkInfoBarGtk::LinkInfoBarGtk(InfoBarTabHelper* owner, LinkInfoBarDelegate* delegate) : InfoBarGtk(owner, delegate) { size_t link_offset; diff --git a/chrome/browser/ui/gtk/infobars/link_infobar_gtk.h b/chrome/browser/ui/gtk/infobars/link_infobar_gtk.h index c6f5168..cb1afa3 100644 --- a/chrome/browser/ui/gtk/infobars/link_infobar_gtk.h +++ b/chrome/browser/ui/gtk/infobars/link_infobar_gtk.h @@ -15,7 +15,7 @@ class LinkInfoBarDelegate; // An infobar that shows a string with an embedded link. class LinkInfoBarGtk : public InfoBarGtk { public: - LinkInfoBarGtk(TabContentsWrapper* owner, LinkInfoBarDelegate* delegate); + LinkInfoBarGtk(InfoBarTabHelper* owner, LinkInfoBarDelegate* delegate); private: virtual ~LinkInfoBarGtk(); 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 2de99d3..bc33058 100644 --- a/chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.cc @@ -31,7 +31,7 @@ enum { } // namespace -TranslateInfoBarBase::TranslateInfoBarBase(TabContentsWrapper* owner, +TranslateInfoBarBase::TranslateInfoBarBase(InfoBarTabHelper* owner, TranslateInfoBarDelegate* delegate) : InfoBarGtk(owner, delegate) { DCHECK(delegate); @@ -214,7 +214,7 @@ void TranslateInfoBarBase::OnOptionsClicked(GtkWidget* sender) { } // TranslateInfoBarDelegate specific method: -InfoBar* TranslateInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { +InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { TranslateInfoBarBase* infobar = NULL; switch (type_) { case BEFORE_TRANSLATE: diff --git a/chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.h b/chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.h index 3789c1e..285a495 100644 --- a/chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.h +++ b/chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.h @@ -15,7 +15,7 @@ class TranslateInfoBarDelegate; // use. class TranslateInfoBarBase : public InfoBarGtk { public: - TranslateInfoBarBase(TabContentsWrapper* owner, + TranslateInfoBarBase(InfoBarTabHelper* owner, TranslateInfoBarDelegate* delegate); virtual ~TranslateInfoBarBase(); diff --git a/chrome/browser/ui/gtk/infobars/translate_message_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/translate_message_infobar_gtk.cc index a8ace40..1ec87bd 100644 --- a/chrome/browser/ui/gtk/infobars/translate_message_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/translate_message_infobar_gtk.cc @@ -11,7 +11,7 @@ #include "ui/base/gtk/gtk_signal_registrar.h" TranslateMessageInfoBar::TranslateMessageInfoBar( - TabContentsWrapper* owner, + InfoBarTabHelper* owner, TranslateInfoBarDelegate* delegate) : TranslateInfoBarBase(owner, delegate) { } diff --git a/chrome/browser/ui/gtk/infobars/translate_message_infobar_gtk.h b/chrome/browser/ui/gtk/infobars/translate_message_infobar_gtk.h index 2635546..b13c926 100644 --- a/chrome/browser/ui/gtk/infobars/translate_message_infobar_gtk.h +++ b/chrome/browser/ui/gtk/infobars/translate_message_infobar_gtk.h @@ -12,7 +12,7 @@ class TranslateInfoBarDelegate; class TranslateMessageInfoBar : public TranslateInfoBarBase { public: - TranslateMessageInfoBar(TabContentsWrapper* owner, + TranslateMessageInfoBar(InfoBarTabHelper* owner, TranslateInfoBarDelegate* delegate); virtual ~TranslateMessageInfoBar(); diff --git a/chrome/browser/ui/shell_dialogs.cc b/chrome/browser/ui/shell_dialogs.cc index 13fddd9..1a36897 100644 --- a/chrome/browser/ui/shell_dialogs.cc +++ b/chrome/browser/ui/shell_dialogs.cc @@ -55,8 +55,9 @@ void SelectFileDialog::SelectFile(Type type, if (source_contents) { TabContentsWrapper* wrapper = TabContentsWrapper::GetCurrentWrapperForContents(source_contents); - wrapper->infobar_tab_helper()->AddInfoBar(new SimpleAlertInfoBarDelegate( - source_contents, + InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); + infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( + infobar_helper, NULL, l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR), true)); diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc index 7a97a87..8f18ac6 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc @@ -256,7 +256,7 @@ TabContentsWrapper::TabContentsWrapper(TabContents* contents) favicon_tab_helper_.reset(new FaviconTabHelper(contents)); find_tab_helper_.reset(new FindTabHelper(contents)); history_tab_helper_.reset(new HistoryTabHelper(contents)); - infobar_tab_helper_.reset(new InfoBarTabHelper(this)); + infobar_tab_helper_.reset(new InfoBarTabHelper(contents)); password_manager_delegate_.reset(new PasswordManagerDelegateImpl(this)); password_manager_.reset( new PasswordManager(contents, password_manager_delegate_.get())); diff --git a/chrome/browser/ui/views/collected_cookies_win.cc b/chrome/browser/ui/views/collected_cookies_win.cc index d68290d..325c705 100644 --- a/chrome/browser/ui/views/collected_cookies_win.cc +++ b/chrome/browser/ui/views/collected_cookies_win.cc @@ -372,8 +372,9 @@ void CollectedCookiesWin::DeleteDelegate() { bool CollectedCookiesWin::Cancel() { if (status_changed_) { - wrapper_->infobar_tab_helper()->AddInfoBar( - new CollectedCookiesInfoBarDelegate(wrapper_->tab_contents())); + InfoBarTabHelper* infobar_helper = wrapper_->infobar_tab_helper(); + infobar_helper->AddInfoBar( + new CollectedCookiesInfoBarDelegate(infobar_helper)); } return true; diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 374305a..b49c1dc 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -2566,7 +2566,7 @@ void BrowserView::ProcessTabSelected(TabContentsWrapper* new_contents, // avoid an unnecessary resize and re-layout of a TabContents. if (change_tab_contents) contents_container_->ChangeTabContents(NULL); - infobar_container_->ChangeTabContents(new_contents); + infobar_container_->ChangeTabContents(new_contents->infobar_tab_helper()); if (bookmark_bar_view_.get()) { bookmark_bar_view_->SetBookmarkBarState( browser_->bookmark_bar_state(), diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h index 713333e..4d75f07 100644 --- a/chrome/browser/ui/views/frame/browser_view.h +++ b/chrome/browser/ui/views/frame/browser_view.h @@ -13,7 +13,7 @@ #include "base/memory/scoped_ptr.h" #include "base/timer.h" #include "build/build_config.h" -#include "chrome/browser/tab_contents/infobar_container.h" +#include "chrome/browser/infobars/infobar_container.h" #include "chrome/browser/tabs/tab_strip_model_observer.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_window.h" diff --git a/chrome/browser/ui/views/infobars/after_translate_infobar.cc b/chrome/browser/ui/views/infobars/after_translate_infobar.cc index e6879da..671dcaa 100644 --- a/chrome/browser/ui/views/infobars/after_translate_infobar.cc +++ b/chrome/browser/ui/views/infobars/after_translate_infobar.cc @@ -13,7 +13,7 @@ #include "views/controls/menu/menu_item_view.h" AfterTranslateInfoBar::AfterTranslateInfoBar( - TabContentsWrapper* owner, + InfoBarTabHelper* owner, TranslateInfoBarDelegate* delegate) : TranslateInfoBarBase(owner, delegate), label_1_(NULL), diff --git a/chrome/browser/ui/views/infobars/after_translate_infobar.h b/chrome/browser/ui/views/infobars/after_translate_infobar.h index bf26881..b148bbe 100644 --- a/chrome/browser/ui/views/infobars/after_translate_infobar.h +++ b/chrome/browser/ui/views/infobars/after_translate_infobar.h @@ -19,7 +19,7 @@ class MenuButton; class AfterTranslateInfoBar : public TranslateInfoBarBase, public views::ViewMenuDelegate { public: - AfterTranslateInfoBar(TabContentsWrapper* owner, + AfterTranslateInfoBar(InfoBarTabHelper* owner, TranslateInfoBarDelegate* delegate); private: diff --git a/chrome/browser/ui/views/infobars/before_translate_infobar.cc b/chrome/browser/ui/views/infobars/before_translate_infobar.cc index 1a3c831..0544a0f 100644 --- a/chrome/browser/ui/views/infobars/before_translate_infobar.cc +++ b/chrome/browser/ui/views/infobars/before_translate_infobar.cc @@ -13,7 +13,7 @@ #include "views/controls/menu/menu_item_view.h" BeforeTranslateInfoBar::BeforeTranslateInfoBar( - TabContentsWrapper* owner, + InfoBarTabHelper* owner, TranslateInfoBarDelegate* delegate) : TranslateInfoBarBase(owner, delegate), label_1_(NULL), diff --git a/chrome/browser/ui/views/infobars/before_translate_infobar.h b/chrome/browser/ui/views/infobars/before_translate_infobar.h index 18d2125..d6a11b7 100644 --- a/chrome/browser/ui/views/infobars/before_translate_infobar.h +++ b/chrome/browser/ui/views/infobars/before_translate_infobar.h @@ -19,7 +19,7 @@ class MenuButton; class BeforeTranslateInfoBar : public TranslateInfoBarBase, public views::ViewMenuDelegate { public: - BeforeTranslateInfoBar(TabContentsWrapper* owner, + BeforeTranslateInfoBar(InfoBarTabHelper* owner, TranslateInfoBarDelegate* delegate); private: diff --git a/chrome/browser/ui/views/infobars/confirm_infobar.cc b/chrome/browser/ui/views/infobars/confirm_infobar.cc index 20b5dde..9f9c9ec 100644 --- a/chrome/browser/ui/views/infobars/confirm_infobar.cc +++ b/chrome/browser/ui/views/infobars/confirm_infobar.cc @@ -13,13 +13,13 @@ // ConfirmInfoBarDelegate ----------------------------------------------------- -InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { +InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { return new ConfirmInfoBar(owner, this); } // ConfirmInfoBar ------------------------------------------------------------- -ConfirmInfoBar::ConfirmInfoBar(TabContentsWrapper* owner, +ConfirmInfoBar::ConfirmInfoBar(InfoBarTabHelper* owner, ConfirmInfoBarDelegate* delegate) : InfoBarView(owner, delegate), label_(NULL), diff --git a/chrome/browser/ui/views/infobars/confirm_infobar.h b/chrome/browser/ui/views/infobars/confirm_infobar.h index a93d27b..9dd7aac 100644 --- a/chrome/browser/ui/views/infobars/confirm_infobar.h +++ b/chrome/browser/ui/views/infobars/confirm_infobar.h @@ -24,7 +24,7 @@ class TextButton; class ConfirmInfoBar : public InfoBarView, public views::LinkListener { public: - ConfirmInfoBar(TabContentsWrapper* owner, ConfirmInfoBarDelegate* delegate); + ConfirmInfoBar(InfoBarTabHelper* owner, ConfirmInfoBarDelegate* delegate); private: virtual ~ConfirmInfoBar(); diff --git a/chrome/browser/ui/views/infobars/extension_infobar.cc b/chrome/browser/ui/views/infobars/extension_infobar.cc index 467a8dc..22b3342 100644 --- a/chrome/browser/ui/views/infobars/extension_infobar.cc +++ b/chrome/browser/ui/views/infobars/extension_infobar.cc @@ -22,7 +22,7 @@ // ExtensionInfoBarDelegate ---------------------------------------------------- -InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { +InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { return new ExtensionInfoBar(owner, this); } @@ -33,7 +33,7 @@ namespace { const int kMenuHorizontalMargin = 1; } // namespace -ExtensionInfoBar::ExtensionInfoBar(TabContentsWrapper* owner, +ExtensionInfoBar::ExtensionInfoBar(InfoBarTabHelper* owner, ExtensionInfoBarDelegate* delegate) : InfoBarView(owner, delegate), delegate_(delegate), diff --git a/chrome/browser/ui/views/infobars/extension_infobar.h b/chrome/browser/ui/views/infobars/extension_infobar.h index 0eff801..13abb4b 100644 --- a/chrome/browser/ui/views/infobars/extension_infobar.h +++ b/chrome/browser/ui/views/infobars/extension_infobar.h @@ -21,7 +21,7 @@ class ExtensionInfoBar : public InfoBarView, public ExtensionInfoBarDelegate::DelegateObserver, public views::ViewMenuDelegate { public: - ExtensionInfoBar(TabContentsWrapper* owner, + ExtensionInfoBar(InfoBarTabHelper* owner, ExtensionInfoBarDelegate* delegate); private: diff --git a/chrome/browser/ui/views/infobars/infobar_background.cc b/chrome/browser/ui/views/infobars/infobar_background.cc index c8e2fdd..e28e1ac 100644 --- a/chrome/browser/ui/views/infobars/infobar_background.cc +++ b/chrome/browser/ui/views/infobars/infobar_background.cc @@ -4,7 +4,7 @@ #include "chrome/browser/ui/views/infobars/infobar_background.h" -#include "chrome/browser/tab_contents/infobar.h" +#include "chrome/browser/infobars/infobar.h" #include "chrome/browser/ui/views/infobars/infobar_view.h" #include "ui/gfx/canvas.h" #include "ui/gfx/canvas_skia_paint.h" diff --git a/chrome/browser/ui/views/infobars/infobar_background.h b/chrome/browser/ui/views/infobars/infobar_background.h index 20e1df7..4f9cc1e 100644 --- a/chrome/browser/ui/views/infobars/infobar_background.h +++ b/chrome/browser/ui/views/infobars/infobar_background.h @@ -6,7 +6,7 @@ #define CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_BACKGROUND_H_ #pragma once -#include "chrome/browser/tab_contents/infobar_delegate.h" +#include "chrome/browser/infobars/infobar_delegate.h" #include "views/background.h" class InfoBarBackground : public views::Background { diff --git a/chrome/browser/ui/views/infobars/infobar_container_view.h b/chrome/browser/ui/views/infobars/infobar_container_view.h index e46ea2c..2e2d552c 100644 --- a/chrome/browser/ui/views/infobars/infobar_container_view.h +++ b/chrome/browser/ui/views/infobars/infobar_container_view.h @@ -6,7 +6,7 @@ #define CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_CONTAINER_VIEW_H_ #pragma once -#include "chrome/browser/tab_contents/infobar_container.h" +#include "chrome/browser/infobars/infobar_container.h" #include "chrome/browser/ui/views/accessible_pane_view.h" // The views-specific implementation of InfoBarContainer. diff --git a/chrome/browser/ui/views/infobars/infobar_view.cc b/chrome/browser/ui/views/infobars/infobar_view.cc index d1124d7..2d911e2 100644 --- a/chrome/browser/ui/views/infobars/infobar_view.cc +++ b/chrome/browser/ui/views/infobars/infobar_view.cc @@ -8,7 +8,7 @@ #include "base/memory/scoped_ptr.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/tab_contents/infobar_delegate.h" +#include "chrome/browser/infobars/infobar_delegate.h" #include "chrome/browser/ui/views/infobars/infobar_background.h" #include "chrome/browser/ui/views/infobars/infobar_button_border.h" #include "grit/generated_resources.h" @@ -59,7 +59,7 @@ const int InfoBarView::kButtonButtonSpacing = 10; const int InfoBarView::kEndOfLabelSpacing = 16; const int InfoBarView::kHorizontalPadding = 6; -InfoBarView::InfoBarView(TabContentsWrapper* owner, InfoBarDelegate* delegate) +InfoBarView::InfoBarView(InfoBarTabHelper* owner, InfoBarDelegate* delegate) : InfoBar(owner, delegate), icon_(NULL), close_button_(NULL) { diff --git a/chrome/browser/ui/views/infobars/infobar_view.h b/chrome/browser/ui/views/infobars/infobar_view.h index bb83c10..f46232a 100644 --- a/chrome/browser/ui/views/infobars/infobar_view.h +++ b/chrome/browser/ui/views/infobars/infobar_view.h @@ -8,8 +8,8 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" -#include "chrome/browser/tab_contents/infobar.h" -#include "chrome/browser/tab_contents/infobar_container.h" +#include "chrome/browser/infobars/infobar.h" +#include "chrome/browser/infobars/infobar_container.h" #include "third_party/skia/include/core/SkPath.h" #include "views/controls/button/button.h" #include "views/controls/menu/menu_item_view.h" @@ -36,7 +36,7 @@ class InfoBarView : public InfoBar, public views::ButtonListener, public views::FocusChangeListener { public: - InfoBarView(TabContentsWrapper* owner, InfoBarDelegate* delegate); + InfoBarView(InfoBarTabHelper* owner, InfoBarDelegate* delegate); const SkPath& fill_path() const { return fill_path_; } const SkPath& stroke_path() const { return stroke_path_; } diff --git a/chrome/browser/ui/views/infobars/link_infobar.cc b/chrome/browser/ui/views/infobars/link_infobar.cc index 4496b0a..be319d2 100644 --- a/chrome/browser/ui/views/infobars/link_infobar.cc +++ b/chrome/browser/ui/views/infobars/link_infobar.cc @@ -12,13 +12,13 @@ // LinkInfoBarDelegate -------------------------------------------------------- -InfoBar* LinkInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { +InfoBar* LinkInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { return new LinkInfoBar(owner, this); } // LinkInfoBar ---------------------------------------------------------------- -LinkInfoBar::LinkInfoBar(TabContentsWrapper* owner, +LinkInfoBar::LinkInfoBar(InfoBarTabHelper* owner, LinkInfoBarDelegate* delegate) : InfoBarView(owner, delegate), label_1_(NULL), diff --git a/chrome/browser/ui/views/infobars/link_infobar.h b/chrome/browser/ui/views/infobars/link_infobar.h index 168b095..4c10924 100644 --- a/chrome/browser/ui/views/infobars/link_infobar.h +++ b/chrome/browser/ui/views/infobars/link_infobar.h @@ -17,7 +17,7 @@ class LinkInfoBarDelegate; class LinkInfoBar : public InfoBarView, public views::LinkListener { public: - LinkInfoBar(TabContentsWrapper* owner, LinkInfoBarDelegate* delegate); + LinkInfoBar(InfoBarTabHelper* owner, LinkInfoBarDelegate* delegate); private: virtual ~LinkInfoBar(); diff --git a/chrome/browser/ui/views/infobars/translate_infobar_base.cc b/chrome/browser/ui/views/infobars/translate_infobar_base.cc index 0d09046..c47ea3c 100644 --- a/chrome/browser/ui/views/infobars/translate_infobar_base.cc +++ b/chrome/browser/ui/views/infobars/translate_infobar_base.cc @@ -19,7 +19,7 @@ // TranslateInfoBarDelegate --------------------------------------------------- -InfoBar* TranslateInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { +InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { TranslateInfoBarBase* infobar = NULL; switch (type_) { case BEFORE_TRANSLATE: @@ -44,7 +44,7 @@ InfoBar* TranslateInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { // static const int TranslateInfoBarBase::kButtonInLabelSpacing = 5; -TranslateInfoBarBase::TranslateInfoBarBase(TabContentsWrapper* owner, +TranslateInfoBarBase::TranslateInfoBarBase(InfoBarTabHelper* owner, TranslateInfoBarDelegate* delegate) : InfoBarView(owner, delegate), error_background_(InfoBarDelegate::WARNING_TYPE) { diff --git a/chrome/browser/ui/views/infobars/translate_infobar_base.h b/chrome/browser/ui/views/infobars/translate_infobar_base.h index 30865e8..6e1ebfd 100644 --- a/chrome/browser/ui/views/infobars/translate_infobar_base.h +++ b/chrome/browser/ui/views/infobars/translate_infobar_base.h @@ -22,7 +22,7 @@ class MenuButton; class TranslateInfoBarBase : public TranslateInfoBarView, public InfoBarView { public: - TranslateInfoBarBase(TabContentsWrapper* owner, + TranslateInfoBarBase(InfoBarTabHelper* owner, TranslateInfoBarDelegate* delegate); virtual ~TranslateInfoBarBase(); diff --git a/chrome/browser/ui/views/infobars/translate_message_infobar.cc b/chrome/browser/ui/views/infobars/translate_message_infobar.cc index d08fcf3..8f75a54 100644 --- a/chrome/browser/ui/views/infobars/translate_message_infobar.cc +++ b/chrome/browser/ui/views/infobars/translate_message_infobar.cc @@ -9,7 +9,7 @@ #include "views/controls/label.h" TranslateMessageInfoBar::TranslateMessageInfoBar( - TabContentsWrapper* owner, + InfoBarTabHelper* owner, TranslateInfoBarDelegate* delegate) : TranslateInfoBarBase(owner, delegate), label_(NULL), diff --git a/chrome/browser/ui/views/infobars/translate_message_infobar.h b/chrome/browser/ui/views/infobars/translate_message_infobar.h index d59ba01..5301bbf 100644 --- a/chrome/browser/ui/views/infobars/translate_message_infobar.h +++ b/chrome/browser/ui/views/infobars/translate_message_infobar.h @@ -10,7 +10,7 @@ class TranslateMessageInfoBar : public TranslateInfoBarBase { public: - TranslateMessageInfoBar(TabContentsWrapper* owner, + TranslateMessageInfoBar(InfoBarTabHelper* owner, TranslateInfoBarDelegate* delegate); private: |