diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-20 19:11:42 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-20 19:11:42 +0000 |
commit | 4f822f02cd6800ee9c276803c6c6e271ca8146de (patch) | |
tree | afbd6986454f4d587c9d09d9790ce9e7c473d04a | |
parent | de794ebc37fdefdb61f340b8e91f1ac80b1b8678 (diff) | |
download | chromium_src-4f822f02cd6800ee9c276803c6c6e271ca8146de.zip chromium_src-4f822f02cd6800ee9c276803c6c6e271ca8146de.tar.gz chromium_src-4f822f02cd6800ee9c276803c6c6e271ca8146de.tar.bz2 |
Convert all uses of InfoBarTabHelper -> InfoBarService. Make InfoBarTabHelper
an implementation detail by declaring all its functions private.
BUG=none
TEST=none
Review URL: https://codereview.chromium.org/11442041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174196 0039d316-1c4b-4281-b951-d872f2087c98
153 files changed, 910 insertions, 918 deletions
diff --git a/chrome/browser/accessibility/accessibility_extension_api.cc b/chrome/browser/accessibility/accessibility_extension_api.cc index 729e616..3a22840 100644 --- a/chrome/browser/accessibility/accessibility_extension_api.cc +++ b/chrome/browser/accessibility/accessibility_extension_api.cc @@ -10,11 +10,11 @@ #include "chrome/browser/accessibility/accessibility_extension_api_constants.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" #include "chrome/browser/api/infobars/infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/extensions/api/tabs/tabs_constants.h" #include "chrome/browser/extensions/event_router.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/extension_tab_util.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_notification_types.h" #include "content/public/browser/notification_service.h" @@ -212,13 +212,11 @@ bool GetAlertsForTabFunction::RunImpl() { ListValue* alerts_value = new ListValue; - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(contents); - for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); ++i) { + InfoBarService* infobar_service = InfoBarService::FromWebContents(contents); + for (size_t i = 0; i < infobar_service->GetInfoBarCount(); ++i) { // TODO(hashimoto): Make other kind of alerts available. crosbug.com/24281 - InfoBarDelegate* infobar_delegate = infobar_helper->GetInfoBarDelegateAt(i); ConfirmInfoBarDelegate* confirm_infobar_delegate = - infobar_delegate->AsConfirmInfoBarDelegate(); + infobar_service->GetInfoBarDelegateAt(i)->AsConfirmInfoBarDelegate(); if (confirm_infobar_delegate) { DictionaryValue* alert_value = new DictionaryValue; const string16 message_text = confirm_infobar_delegate->GetMessageText(); diff --git a/chrome/browser/accessibility/accessibility_extension_apitest.cc b/chrome/browser/accessibility/accessibility_extension_apitest.cc index f661f31..2c224ba 100644 --- a/chrome/browser/accessibility/accessibility_extension_apitest.cc +++ b/chrome/browser/accessibility/accessibility_extension_apitest.cc @@ -3,9 +3,9 @@ // found in the LICENSE file. #include "base/utf_string_conversions.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/api/infobars/simple_alert_infobar_delegate.h" #include "chrome/browser/extensions/extension_apitest.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/common/chrome_switches.h" @@ -19,13 +19,13 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_GetAlertsForTab) { content::WebContents* web_contents = chrome::GetActiveWebContents(browser()); ASSERT_TRUE(web_contents); - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents); - ASSERT_TRUE(infobar_helper); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); + ASSERT_TRUE(infobar_service); const char kAlertMessage[] = "Simple Alert Infobar."; - infobar_helper->AddInfoBar( - new SimpleAlertInfoBarDelegate(infobar_helper, + infobar_service->AddInfoBar( + new SimpleAlertInfoBarDelegate(infobar_service, NULL, ASCIIToUTF16(kAlertMessage), false)); diff --git a/chrome/browser/alternate_nav_url_fetcher.cc b/chrome/browser/alternate_nav_url_fetcher.cc index 17bdfe8..6dd9661 100644 --- a/chrome/browser/alternate_nav_url_fetcher.cc +++ b/chrome/browser/alternate_nav_url_fetcher.cc @@ -5,8 +5,8 @@ #include "chrome/browser/alternate_nav_url_fetcher.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/api/infobars/link_infobar_delegate.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/intranet_redirect_detector.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_notification_types.h" @@ -32,7 +32,7 @@ using content::Referrer; class AlternateNavInfoBarDelegate : public LinkInfoBarDelegate { public: - AlternateNavInfoBarDelegate(InfoBarTabHelper* owner, + AlternateNavInfoBarDelegate(InfoBarService* owner, const GURL& alternate_nav_url); virtual ~AlternateNavInfoBarDelegate(); @@ -50,7 +50,7 @@ class AlternateNavInfoBarDelegate : public LinkInfoBarDelegate { }; AlternateNavInfoBarDelegate::AlternateNavInfoBarDelegate( - InfoBarTabHelper* owner, + InfoBarService* owner, const GURL& alternate_nav_url) : LinkInfoBarDelegate(owner), alternate_nav_url_(alternate_nav_url) { @@ -219,10 +219,10 @@ void AlternateNavURLFetcher::SetStatusFromURLFetch( void AlternateNavURLFetcher::ShowInfobarIfPossible() { if (navigated_to_entry_ && (state_ == SUCCEEDED)) { - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(controller_->GetWebContents()); - infobar_helper->AddInfoBar( - new AlternateNavInfoBarDelegate(infobar_helper, alternate_nav_url_)); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(controller_->GetWebContents()); + infobar_service->AddInfoBar( + new AlternateNavInfoBarDelegate(infobar_service, alternate_nav_url_)); } else if (state_ != FAILED) { return; } diff --git a/chrome/browser/android/tab_android.cc b/chrome/browser/android/tab_android.cc index 98506ce..711f6cf 100644 --- a/chrome/browser/android/tab_android.cc +++ b/chrome/browser/android/tab_android.cc @@ -3,13 +3,13 @@ // found in the LICENSE file. #include "chrome/browser/android/tab_android.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/autofill/autofill_external_delegate.h" #include "chrome/browser/autofill/autofill_manager.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/extensions/tab_helper.h" #include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/history/history_tab_helper.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/password_manager/password_manager.h" #include "chrome/browser/password_manager/password_manager_delegate_impl.h" #include "chrome/browser/prerender/prerender_tab_helper.h" @@ -69,7 +69,7 @@ void BrowserTabContents::AttachTabHelpers(WebContents* contents) { FaviconTabHelper::CreateForWebContents(contents); FindTabHelper::CreateForWebContents(contents); HistoryTabHelper::CreateForWebContents(contents); - InfoBarTabHelper::CreateForWebContents(contents); + InfoBarService::CreateForWebContents(contents); PasswordManagerDelegateImpl::CreateForWebContents(contents); PasswordManager::CreateForWebContentsAndDelegate( contents, PasswordManagerDelegateImpl::FromWebContents(contents)); diff --git a/chrome/browser/api/infobars/infobar_service.h b/chrome/browser/api/infobars/infobar_service.h index 32b792f..c58353c 100644 --- a/chrome/browser/api/infobars/infobar_service.h +++ b/chrome/browser/api/infobars/infobar_service.h @@ -5,6 +5,8 @@ #ifndef CHROME_BROWSER_API_INFOBARS_INFOBAR_SERVICE_H_ #define CHROME_BROWSER_API_INFOBARS_INFOBAR_SERVICE_H_ +#include <cstddef> + namespace content { class WebContents; } @@ -15,10 +17,17 @@ class InfoBarDelegate; // attached to a tab. class InfoBarService { public: - // Retrieves the InfoBarService for a given WebContents. + // Passthrough functions to the implementing subclass. The subclass .cc file + // should define these. + static void CreateForWebContents(content::WebContents* web_contents); static InfoBarService* FromWebContents(content::WebContents* web_contents); + static const InfoBarService* + FromWebContents(const content::WebContents* web_contents); + + virtual ~InfoBarService(); - virtual ~InfoBarService() {} + // Changes whether infobars are enabled. The default is true. + virtual void SetInfoBarsEnabled(bool enabled) = 0; // Adds an InfoBar for the specified |delegate|. // diff --git a/chrome/browser/api/infobars/link_infobar_delegate.h b/chrome/browser/api/infobars/link_infobar_delegate.h index 711d516..b05c4a3 100644 --- a/chrome/browser/api/infobars/link_infobar_delegate.h +++ b/chrome/browser/api/infobars/link_infobar_delegate.h @@ -10,8 +10,6 @@ #include "base/string16.h" #include "chrome/browser/api/infobars/infobar_delegate.h" -class InfoBarTabHelper; - // An interface derived from InfoBarDelegate implemented by objects wishing to // control a LinkInfoBar. class LinkInfoBarDelegate : public InfoBarDelegate { diff --git a/chrome/browser/autofill/DEPS b/chrome/browser/autofill/DEPS index 32aaa6c..4d2dbde 100644 --- a/chrome/browser/autofill/DEPS +++ b/chrome/browser/autofill/DEPS @@ -25,7 +25,6 @@ specific_include_rules = { # Do not add to the list of temporarily-allowed dependencies below, # and please do not introduce more #includes of these files. '.*_[a-z]*test\.cc': [ - "!chrome/browser/infobars/infobar_tab_helper.h", "!chrome/browser/password_manager/encryptor.h", "!chrome/browser/password_manager/password_manager.h", "!chrome/browser/password_manager/password_manager_delegate_impl.h", diff --git a/chrome/browser/autofill/autofill_metrics_unittest.cc b/chrome/browser/autofill/autofill_metrics_unittest.cc index 83f21d8..3471b5c2 100644 --- a/chrome/browser/autofill/autofill_metrics_unittest.cc +++ b/chrome/browser/autofill/autofill_metrics_unittest.cc @@ -16,7 +16,6 @@ #include "chrome/browser/autofill/autofill_metrics.h" #include "chrome/browser/autofill/personal_data_manager.h" #include "chrome/browser/autofill/personal_data_manager_factory.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" #include "chrome/browser/webdata/web_data_service.h" #include "chrome/common/form_data.h" @@ -1139,7 +1138,7 @@ TEST_F(AutofillMetricsTest, AutofillIsEnabledAtPageLoad) { // Test that credit card infobar metrics are logged correctly. TEST_F(AutofillMetricsTest, CreditCardInfoBar) { - InfoBarTabHelper::CreateForWebContents(web_contents()); + InfoBarService::CreateForWebContents(web_contents()); MockAutofillMetrics metric_logger; ::testing::InSequence dummy; diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index 736072a..3577482 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -24,6 +24,7 @@ #include "base/values.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/automation/automation_provider.h" #include "chrome/browser/automation/automation_provider_json.h" #include "chrome/browser/bookmarks/bookmark_model.h" @@ -38,7 +39,6 @@ #include "chrome/browser/extensions/extension_tab_util.h" #include "chrome/browser/history/history_types.h" #include "chrome/browser/history/top_sites.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/metrics/metric_event_duration_details.h" #include "chrome/browser/notifications/balloon.h" #include "chrome/browser/notifications/balloon_collection.h" @@ -1208,8 +1208,8 @@ InfoBarCountObserver::InfoBarCountObserver(AutomationProvider* automation, reply_message_(reply_message), web_contents_(web_contents), target_count_(target_count) { - content::Source<InfoBarTabHelper> source( - InfoBarTabHelper::FromWebContents(web_contents)); + content::Source<InfoBarService> source( + InfoBarService::FromWebContents(web_contents)); registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, source); registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, @@ -1229,9 +1229,9 @@ void InfoBarCountObserver::Observe( } void InfoBarCountObserver::CheckCount() { - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(web_contents_); - if (infobar_tab_helper->GetInfoBarCount() != target_count_) + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents_); + if (infobar_service->GetInfoBarCount() != target_count_) return; if (automation_) { diff --git a/chrome/browser/automation/automation_provider_observers.h b/chrome/browser/automation/automation_provider_observers.h index ce8d536..61edd34 100644 --- a/chrome/browser/automation/automation_provider_observers.h +++ b/chrome/browser/automation/automation_provider_observers.h @@ -58,7 +58,6 @@ class BalloonCollection; class Browser; class ExtensionProcessManager; class ExtensionService; -class InfoBarTabHelper; class Notification; class Profile; class SavePackage; diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 03f1b34..29ea238 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -26,6 +26,7 @@ #include "base/utf_string_conversions.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/api/infobars/link_infobar_delegate.h" #include "chrome/browser/autocomplete/autocomplete_controller.h" #include "chrome/browser/autocomplete/autocomplete_match.h" @@ -64,7 +65,6 @@ #include "chrome/browser/history/top_sites.h" #include "chrome/browser/importer/importer_host.h" #include "chrome/browser/importer/importer_list.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/notifications/balloon.h" #include "chrome/browser/notifications/balloon_collection.h" @@ -2121,10 +2121,10 @@ void TestingAutomationProvider::SetWindowDimensions( ListValue* TestingAutomationProvider::GetInfobarsInfo(WebContents* wc) { // Each infobar may have different properties depending on the type. ListValue* infobars = new ListValue; - InfoBarTabHelper* infobar_helper = InfoBarTabHelper::FromWebContents(wc); - for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); ++i) { + InfoBarService* infobar_service = InfoBarService::FromWebContents(wc); + for (size_t i = 0; i < infobar_service->GetInfoBarCount(); ++i) { DictionaryValue* infobar_item = new DictionaryValue; - InfoBarDelegate* infobar = infobar_helper->GetInfoBarDelegateAt(i); + InfoBarDelegate* infobar = infobar_service->GetInfoBarDelegateAt(i); switch (infobar->GetInfoBarAutomationType()) { case InfoBarDelegate::CONFIRM_INFOBAR: infobar_item->SetString("type", "confirm_infobar"); @@ -2202,21 +2202,21 @@ void TestingAutomationProvider::PerformActionOnInfobar( reply.SendError(StringPrintf("No such tab at index %d", tab_index)); return; } - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); InfoBarDelegate* infobar = NULL; size_t infobar_index = static_cast<size_t>(infobar_index_int); - if (infobar_index >= infobar_helper->GetInfoBarCount()) { + if (infobar_index >= infobar_service->GetInfoBarCount()) { reply.SendError(StringPrintf("No such infobar at index %" PRIuS, infobar_index)); return; } - infobar = infobar_helper->GetInfoBarDelegateAt(infobar_index); + infobar = infobar_service->GetInfoBarDelegateAt(infobar_index); if ("dismiss" == action) { infobar->InfoBarDismissed(); - infobar_helper->RemoveInfoBar(infobar); + infobar_service->RemoveInfoBar(infobar); reply.SendSuccess(NULL); return; } @@ -2228,10 +2228,10 @@ void TestingAutomationProvider::PerformActionOnInfobar( } if ("accept" == action) { if (confirm_infobar->Accept()) - infobar_helper->RemoveInfoBar(infobar); + infobar_service->RemoveInfoBar(infobar); } else if ("cancel" == action) { if (confirm_infobar->Cancel()) - infobar_helper->RemoveInfoBar(infobar); + infobar_service->RemoveInfoBar(infobar); } reply.SendSuccess(NULL); return; diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 0c511cf..6f7edfe 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -39,7 +39,6 @@ #include "chrome/browser/extensions/suggest_permission_util.h" #include "chrome/browser/geolocation/chrome_access_token_store.h" #include "chrome/browser/google/google_util.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/media/media_internals.h" #include "chrome/browser/nacl_host/nacl_process_host.h" #include "chrome/browser/net/chrome_net_log.h" diff --git a/chrome/browser/chrome_quota_permission_context.cc b/chrome/browser/chrome_quota_permission_context.cc index 5086a76..be882c5 100644 --- a/chrome/browser/chrome_quota_permission_context.cc +++ b/chrome/browser/chrome_quota_permission_context.cc @@ -9,13 +9,14 @@ #include "base/bind.h" #include "base/utf_string_conversions.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tab_contents/tab_util.h" #include "chrome/common/pref_names.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_details.h" +#include "content/public/browser/web_contents.h" #include "googleurl/src/gurl.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" @@ -38,13 +39,13 @@ class RequestQuotaInfoBarDelegate : public ConfirmInfoBarDelegate { typedef QuotaPermissionContext::PermissionCallback PermissionCallback; RequestQuotaInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, ChromeQuotaPermissionContext* context, const GURL& origin_url, int64 requested_quota, const std::string& display_languages, const PermissionCallback& callback) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), context_(context), origin_url_(origin_url), display_languages_(display_languages), @@ -136,10 +137,10 @@ void ChromeQuotaPermissionContext::RequestQuotaPermission( return; } - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents); - if (!infobar_helper) { - // The tab has no infobar helper. + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); + if (!infobar_service) { + // The tab has no infobar service. LOG(WARNING) << "Attempt to request quota from a background page: " << render_process_id << "," << render_view_id; DispatchCallbackOnIOThread(callback, QUOTA_PERMISSION_RESPONSE_CANCELLED); @@ -147,8 +148,8 @@ void ChromeQuotaPermissionContext::RequestQuotaPermission( } Profile* profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); - infobar_helper->AddInfoBar(new RequestQuotaInfoBarDelegate( - infobar_helper, this, origin_url, requested_quota, + infobar_service->AddInfoBar(new RequestQuotaInfoBarDelegate( + infobar_service, this, origin_url, requested_quota, profile->GetPrefs()->GetString(prefs::kAcceptLanguages), callback)); } diff --git a/chrome/browser/download/download_request_limiter.cc b/chrome/browser/download/download_request_limiter.cc index d861d8e..2e93af8 100644 --- a/chrome/browser/download/download_request_limiter.cc +++ b/chrome/browser/download/download_request_limiter.cc @@ -6,8 +6,8 @@ #include "base/bind.h" #include "base/stl_util.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/download/download_request_infobar_delegate.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/tab_contents/tab_util.h" #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.h" @@ -64,14 +64,14 @@ void DownloadRequestLimiter::TabDownloadState::DidGetUserGesture() { return; } - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents()); - // See PromptUserForDownload(): if there's no InfoBarTabHelper, then + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents()); + // See PromptUserForDownload(): if there's no InfoBarService, then // DOWNLOADS_NOT_ALLOWED is functionally equivalent to PROMPT_BEFORE_DOWNLOAD. - if ((infobar_helper && + if ((infobar_service && status_ != DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS && status_ != DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED) || - (!infobar_helper && + (!infobar_service && status_ != DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS)) { // Revert to default status. host_->Remove(this); @@ -92,10 +92,10 @@ void DownloadRequestLimiter::TabDownloadState::PromptUserForDownload( return; } - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents); - if (!infobar_helper) { - // |web_contents| may not have a InfoBarTabHelper if it's actually a + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); + if (!infobar_service) { + // |web_contents| may not have a InfoBarService if it's actually a // WebContents like those used for extension popups/bubbles and hosted apps // etc. // TODO(benjhayden): If this is an automatic download from an extension, @@ -106,8 +106,8 @@ void DownloadRequestLimiter::TabDownloadState::PromptUserForDownload( Cancel(); return; } - infobar_ = new DownloadRequestInfoBarDelegate(infobar_helper, this); - infobar_helper->AddInfoBar(infobar_); + infobar_ = new DownloadRequestInfoBarDelegate(infobar_service, this); + infobar_service->AddInfoBar(infobar_); } void DownloadRequestLimiter::TabDownloadState::Cancel() { diff --git a/chrome/browser/download/download_request_limiter_unittest.cc b/chrome/browser/download/download_request_limiter_unittest.cc index 1628659..8e69957 100644 --- a/chrome/browser/download/download_request_limiter_unittest.cc +++ b/chrome/browser/download/download_request_limiter_unittest.cc @@ -3,8 +3,8 @@ // found in the LICENSE file. #include "base/bind.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/download/download_request_limiter.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" @@ -28,7 +28,7 @@ class DownloadRequestLimiterTest : public ChromeRenderViewHostTestHarness { virtual void SetUp() { ChromeRenderViewHostTestHarness::SetUp(); BlockedContentTabHelper::CreateForWebContents(web_contents()); - InfoBarTabHelper::CreateForWebContents(web_contents()); + InfoBarService::CreateForWebContents(web_contents()); allow_download_ = true; ask_allow_count_ = cancel_count_ = continue_count_ = 0; @@ -239,8 +239,8 @@ TEST_F(DownloadRequestLimiterTest, DownloadRequestLimiter_RawWebContents) { scoped_ptr<WebContents> web_contents(CreateTestWebContents()); // DownloadRequestLimiter won't try to make an infobar if it doesn't have a - // InfoBarTabHelper, and we want to test that it will Cancel() instead of - // prompting when it doesn't have a InfoBarTabHelper, so unset the delegate. + // InfoBarService, and we want to test that it will Cancel() instead of + // prompting when it doesn't have a InfoBarService, so unset the delegate. UnsetDelegate(); EXPECT_EQ(0, continue_count_); EXPECT_EQ(0, cancel_count_); diff --git a/chrome/browser/extensions/api/debugger/debugger_api.cc b/chrome/browser/extensions/api/debugger/debugger_api.cc index 293ba43..c1784b4 100644 --- a/chrome/browser/extensions/api/debugger/debugger_api.cc +++ b/chrome/browser/extensions/api/debugger/debugger_api.cc @@ -17,12 +17,12 @@ #include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/extensions/api/debugger/debugger_api_constants.h" #include "chrome/browser/extensions/event_router.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/extension_tab_util.h" #include "chrome/browser/infobars/infobar.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" #include "chrome/common/chrome_notification_types.h" @@ -61,7 +61,7 @@ class ExtensionDevToolsClientHost; class ExtensionDevToolsInfoBarDelegate : public ConfirmInfoBarDelegate { public: ExtensionDevToolsInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, const std::string& client_name, ExtensionDevToolsClientHost* client_host); virtual ~ExtensionDevToolsInfoBarDelegate(); @@ -196,14 +196,14 @@ ExtensionDevToolsClientHost::ExtensionDevToolsClientHost( web_contents_->GetRenderViewHost()); DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(agent, this); - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents_); - infobar_delegate_ = new ExtensionDevToolsInfoBarDelegate(infobar_helper, + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents_); + infobar_delegate_ = new ExtensionDevToolsInfoBarDelegate(infobar_service, extension_name, this); - if (infobar_helper->AddInfoBar(infobar_delegate_)) { + if (infobar_service->AddInfoBar(infobar_delegate_)) { registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - content::Source<InfoBarTabHelper>(infobar_helper)); + content::Source<InfoBarService>(infobar_service)); } else { infobar_delegate_ = NULL; } @@ -216,10 +216,10 @@ ExtensionDevToolsClientHost::~ExtensionDevToolsClientHost() { if (infobar_delegate_) { infobar_delegate_->DiscardClientHost(); - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(web_contents_); - if (infobar_tab_helper) - infobar_tab_helper->RemoveInfoBar(infobar_delegate_); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents_); + if (infobar_service) + infobar_service->RemoveInfoBar(infobar_delegate_); } AttachedClientHosts::GetInstance()->Remove(this); } @@ -350,10 +350,10 @@ void ExtensionDevToolsClientHost::DispatchOnInspectorFrontend( } ExtensionDevToolsInfoBarDelegate::ExtensionDevToolsInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, const std::string& client_name, ExtensionDevToolsClientHost* client_host) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), client_name_(client_name), client_host_(client_host) { } diff --git a/chrome/browser/extensions/api/management/management_browsertest.cc b/chrome/browser/extensions/api/management/management_browsertest.cc index e0949d2..aee9ef5 100644 --- a/chrome/browser/extensions/api/management/management_browsertest.cc +++ b/chrome/browser/extensions/api/management/management_browsertest.cc @@ -14,7 +14,6 @@ #include "chrome/browser/extensions/external_policy_loader.h" #include "chrome/browser/extensions/updater/extension_downloader.h" #include "chrome/browser/extensions/updater/extension_updater.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/profiles/profile.h" diff --git a/chrome/browser/extensions/app_notify_channel_ui_impl.cc b/chrome/browser/extensions/app_notify_channel_ui_impl.cc index 7b2f9f7..34f53ed 100644 --- a/chrome/browser/extensions/app_notify_channel_ui_impl.cc +++ b/chrome/browser/extensions/app_notify_channel_ui_impl.cc @@ -6,7 +6,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager_factory.h" @@ -32,7 +32,7 @@ namespace extensions { class AppNotifyChannelUIImpl::InfoBar : public ConfirmInfoBarDelegate { public: InfoBar(AppNotifyChannelUIImpl* creator, - InfoBarTabHelper* helper, + InfoBarService* infobar_service, const std::string& app_name); virtual ~InfoBar(); @@ -52,9 +52,11 @@ class AppNotifyChannelUIImpl::InfoBar : public ConfirmInfoBarDelegate { AppNotifyChannelUIImpl::InfoBar::InfoBar( AppNotifyChannelUIImpl* creator, - InfoBarTabHelper* helper, + InfoBarService* infobar_service, const std::string& app_name) - : ConfirmInfoBarDelegate(helper), creator_(creator), app_name_(app_name) { + : ConfirmInfoBarDelegate(infobar_service), + creator_(creator), + app_name_(app_name) { } AppNotifyChannelUIImpl::InfoBar::~InfoBar() {} @@ -135,10 +137,10 @@ void AppNotifyChannelUIImpl::PromptSyncSetup( return; } - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(web_contents_); - infobar_tab_helper->AddInfoBar(new AppNotifyChannelUIImpl::InfoBar( - this, infobar_tab_helper, app_name_)); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents_); + infobar_service->AddInfoBar(new AppNotifyChannelUIImpl::InfoBar( + this, infobar_service, app_name_)); } void AppNotifyChannelUIImpl::OnInfoBarResult(bool accepted) { diff --git a/chrome/browser/extensions/extension_install_ui_browsertest.cc b/chrome/browser/extensions/extension_install_ui_browsertest.cc index d17e76e..bb916bf 100644 --- a/chrome/browser/extensions/extension_install_ui_browsertest.cc +++ b/chrome/browser/extensions/extension_install_ui_browsertest.cc @@ -4,10 +4,10 @@ #include "base/string_util.h" #include "chrome/app/chrome_command_ids.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" @@ -28,14 +28,14 @@ class ExtensionInstallUIBrowserTest : public ExtensionBrowserTest { void VerifyThemeInfoBarAndUndoInstall() { WebContents* web_contents = chrome::GetActiveWebContents(browser()); ASSERT_TRUE(web_contents); - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents); - ASSERT_EQ(1U, infobar_helper->GetInfoBarCount()); - ConfirmInfoBarDelegate* delegate = infobar_helper-> + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); + ASSERT_EQ(1U, infobar_service->GetInfoBarCount()); + ConfirmInfoBarDelegate* delegate = infobar_service-> GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(delegate); delegate->Cancel(); - ASSERT_EQ(0U, infobar_helper->GetInfoBarCount()); + ASSERT_EQ(0U, infobar_service->GetInfoBarCount()); } // Install the given theme from the data dir and verify expected name. diff --git a/chrome/browser/extensions/extension_install_ui_default.cc b/chrome/browser/extensions/extension_install_ui_default.cc index c6d4b80..dcb7f70 100644 --- a/chrome/browser/extensions/extension_install_ui_default.cc +++ b/chrome/browser/extensions/extension_install_ui_default.cc @@ -7,9 +7,9 @@ #include "base/command_line.h" #include "base/utf_string_conversions.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/extensions/extension_install_prompt.h" #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" @@ -52,10 +52,10 @@ bool disable_failure_ui_for_tests = false; // Helper class to put up an infobar when installation fails. class ErrorInfobarDelegate : public ConfirmInfoBarDelegate { public: - ErrorInfobarDelegate(InfoBarTabHelper* infobar_helper, + ErrorInfobarDelegate(InfoBarService* infobar_service, Browser* browser, const extensions::CrxInstallerError& error) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), browser_(browser), error_(error) { } @@ -166,10 +166,10 @@ void ExtensionInstallUIDefault::OnInstallFailure( WebContents* web_contents = chrome::GetActiveWebContents(browser); if (!web_contents) return; - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents); - infobar_helper->AddInfoBar( - new ErrorInfobarDelegate(infobar_helper, browser, error)); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); + infobar_service->AddInfoBar( + new ErrorInfobarDelegate(infobar_service, browser, error)); } void ExtensionInstallUIDefault::SetSkipPostInstallUI(bool skip_ui) { @@ -197,13 +197,13 @@ void ExtensionInstallUIDefault::ShowThemeInfoBar( WebContents* web_contents = chrome::GetActiveWebContents(browser); if (!web_contents) return; - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); // First find any previous theme preview infobars. InfoBarDelegate* old_delegate = NULL; - for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); ++i) { - InfoBarDelegate* delegate = infobar_helper->GetInfoBarDelegateAt(i); + for (size_t i = 0; i < infobar_service->GetInfoBarCount(); ++i) { + InfoBarDelegate* delegate = infobar_service->GetInfoBarDelegateAt(i); ThemeInstalledInfoBarDelegate* theme_infobar = delegate->AsThemePreviewInfobarDelegate(); if (theme_infobar) { @@ -222,9 +222,9 @@ void ExtensionInstallUIDefault::ShowThemeInfoBar( web_contents, new_theme, previous_theme_id, previous_using_native_theme); if (old_delegate) - infobar_helper->ReplaceInfoBar(old_delegate, new_delegate); + infobar_service->ReplaceInfoBar(old_delegate, new_delegate); else - infobar_helper->AddInfoBar(new_delegate); + infobar_service->AddInfoBar(new_delegate); } InfoBarDelegate* ExtensionInstallUIDefault::GetNewThemeInstalledInfoBarDelegate( @@ -235,7 +235,7 @@ InfoBarDelegate* ExtensionInstallUIDefault::GetNewThemeInstalledInfoBarDelegate( Profile* profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); return new ThemeInstalledInfoBarDelegate( - InfoBarTabHelper::FromWebContents(web_contents), + InfoBarService::FromWebContents(web_contents), profile->GetExtensionService(), ThemeServiceFactory::GetForProfile(profile), new_theme, diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.cc b/chrome/browser/extensions/theme_installed_infobar_delegate.cc index 33c9876c..b8d34fa 100644 --- a/chrome/browser/extensions/theme_installed_infobar_delegate.cc +++ b/chrome/browser/extensions/theme_installed_infobar_delegate.cc @@ -7,8 +7,8 @@ #include <string> #include "base/utf_string_conversions.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/extensions/extension_service.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" @@ -21,13 +21,13 @@ #include "ui/base/resource/resource_bundle.h" ThemeInstalledInfoBarDelegate::ThemeInstalledInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, ExtensionService* extension_service, ThemeService* theme_service, const extensions::Extension* new_theme, const std::string& previous_theme_id, bool previous_using_native_theme) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), extension_service_(extension_service), theme_service_(theme_service), name_(new_theme->name()), diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.h b/chrome/browser/extensions/theme_installed_infobar_delegate.h index a527709..9cee571 100644 --- a/chrome/browser/extensions/theme_installed_infobar_delegate.h +++ b/chrome/browser/extensions/theme_installed_infobar_delegate.h @@ -13,7 +13,7 @@ #include "content/public/browser/notification_registrar.h" class ExtensionService; -class InfoBarTabHelper; +class InfoBarService; class ThemeService; namespace extensions { @@ -25,7 +25,7 @@ class Extension; class ThemeInstalledInfoBarDelegate : public ConfirmInfoBarDelegate, public content::NotificationObserver { public: - ThemeInstalledInfoBarDelegate(InfoBarTabHelper* infobar_helper, + ThemeInstalledInfoBarDelegate(InfoBarService* infobar_service, ExtensionService* extension_service, ThemeService* theme_service, const extensions::Extension* new_theme, diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc index d5c088c..fd3d8c1 100644 --- a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc +++ b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc @@ -11,13 +11,13 @@ #include "base/memory/scoped_vector.h" #include "base/synchronization/waitable_event.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #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/geolocation/chrome_geolocation_permission_context_factory.h" #include "chrome/browser/geolocation/geolocation_permission_request_id.h" #include "chrome/browser/infobars/infobar.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/view_type_utils.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" @@ -106,11 +106,11 @@ class GeolocationPermissionContextTests GeolocationPermissionRequestID RequestID(int bridge_id); GeolocationPermissionRequestID RequestIDForTab(int tab, int bridge_id); - InfoBarTabHelper* infobar_tab_helper() { - return InfoBarTabHelper::FromWebContents(web_contents()); + InfoBarService* infobar_service() { + return InfoBarService::FromWebContents(web_contents()); } - InfoBarTabHelper* infobar_tab_helper_for_tab(int tab) { - return InfoBarTabHelper::FromWebContents(extra_tabs_[tab]); + InfoBarService* infobar_service_for_tab(int tab) { + return InfoBarService::FromWebContents(extra_tabs_[tab]); } void RequestGeolocationPermission(const GeolocationPermissionRequestID& id, @@ -231,7 +231,7 @@ void GeolocationPermissionContextTests::AddNewTab(const GURL& url) { // Set up required helpers, and make this be as "tabby" as the code requires. chrome::SetViewType(new_tab, chrome::VIEW_TYPE_TAB_CONTENTS); - InfoBarTabHelper::CreateForWebContents(new_tab); + InfoBarService::CreateForWebContents(new_tab); extra_tabs_.push_back(new_tab); } @@ -258,7 +258,7 @@ void GeolocationPermissionContextTests::SetUp() { // Set up required helpers, and make this be as "tabby" as the code requires. chrome::SetViewType(web_contents(), chrome::VIEW_TYPE_TAB_CONTENTS); - InfoBarTabHelper::CreateForWebContents(web_contents()); + InfoBarService::CreateForWebContents(web_contents()); TabSpecificContentSettings::CreateForWebContents(web_contents()); #if defined(OS_ANDROID) MockGoogleLocationSettingsHelper::SetLocationStatus(true, true); @@ -285,13 +285,13 @@ void GeolocationPermissionContextTests::TearDown() { TEST_F(GeolocationPermissionContextTests, SinglePermission) { GURL requesting_frame("http://www.example.com/geolocation"); NavigateAndCommit(requesting_frame); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); RequestGeolocationPermission(RequestID(0), requesting_frame); - ASSERT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); + ASSERT_EQ(1U, infobar_service()->GetInfoBarCount()); ConfirmInfoBarDelegate* infobar_0 = - infobar_tab_helper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); + infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); infobar_0->Cancel(); - infobar_tab_helper()->RemoveInfoBar(infobar_0); + infobar_service()->RemoveInfoBar(infobar_0); EXPECT_EQ(1U, closed_delegate_tracker_.size()); EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0)); infobar_0->InfoBarClosed(); @@ -302,22 +302,22 @@ TEST_F(GeolocationPermissionContextTests, GeolocationEnabledDisabled) { GURL requesting_frame("http://www.example.com/geolocation"); NavigateAndCommit(requesting_frame); MockGoogleLocationSettingsHelper::SetLocationStatus(true, true); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); RequestGeolocationPermission(RequestID(0), requesting_frame); - EXPECT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); - ConfirmInfoBarDelegate* infobar_0 = infobar_tab_helper()-> - GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); + EXPECT_EQ(1U, infobar_service()->GetInfoBarCount()); + ConfirmInfoBarDelegate* infobar_0 = + infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(infobar_0); string16 text_0 = infobar_0->GetButtonLabel( ConfirmInfoBarDelegate::BUTTON_OK); NavigateAndCommit(requesting_frame); MockGoogleLocationSettingsHelper::SetLocationStatus(true, false); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); RequestGeolocationPermission(RequestID(0), requesting_frame); - EXPECT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); - ConfirmInfoBarDelegate* infobar_1 = infobar_tab_helper()-> - GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); + EXPECT_EQ(1U, infobar_service()->GetInfoBarCount()); + ConfirmInfoBarDelegate* infobar_1 = + infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(infobar_1); string16 text_1 = infobar_1->GetButtonLabel( ConfirmInfoBarDelegate::BUTTON_OK); @@ -325,20 +325,20 @@ TEST_F(GeolocationPermissionContextTests, GeolocationEnabledDisabled) { NavigateAndCommit(requesting_frame); MockGoogleLocationSettingsHelper::SetLocationStatus(false, false); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); RequestGeolocationPermission(RequestID(0), requesting_frame); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); } TEST_F(GeolocationPermissionContextTests, MasterEnabledGoogleAppsEnabled) { GURL requesting_frame("http://www.example.com/geolocation"); NavigateAndCommit(requesting_frame); MockGoogleLocationSettingsHelper::SetLocationStatus(true, true); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); RequestGeolocationPermission(RequestID(0), requesting_frame); - EXPECT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); - ConfirmInfoBarDelegate* infobar_0 = infobar_tab_helper()-> - GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); + EXPECT_EQ(1U, infobar_service()->GetInfoBarCount()); + ConfirmInfoBarDelegate* infobar_0 = + infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(infobar_0); infobar_0->Accept(); CheckTabContentsState(requesting_frame, CONTENT_SETTING_ALLOW); @@ -349,11 +349,11 @@ TEST_F(GeolocationPermissionContextTests, MasterEnabledGoogleAppsDisabled) { GURL requesting_frame("http://www.example.com/geolocation"); NavigateAndCommit(requesting_frame); MockGoogleLocationSettingsHelper::SetLocationStatus(true, false); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); RequestGeolocationPermission(RequestID(0), requesting_frame); - EXPECT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); - ConfirmInfoBarDelegate* infobar_0 = infobar_tab_helper()-> - GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); + EXPECT_EQ(1U, infobar_service()->GetInfoBarCount()); + ConfirmInfoBarDelegate* infobar_0 = + infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(infobar_0); infobar_0->Accept(); EXPECT_TRUE( @@ -379,14 +379,14 @@ TEST_F(GeolocationPermissionContextTests, QueuedPermission) { NavigateAndCommit(requesting_frame_0); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); // Request permission for two frames. RequestGeolocationPermission(RequestID(0), requesting_frame_0); RequestGeolocationPermission(RequestID(1), requesting_frame_1); // Ensure only one infobar is created. - ASSERT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); + ASSERT_EQ(1U, infobar_service()->GetInfoBarCount()); ConfirmInfoBarDelegate* infobar_0 = - infobar_tab_helper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); + infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(infobar_0); string16 text_0 = infobar_0->GetMessageText(); @@ -395,16 +395,16 @@ TEST_F(GeolocationPermissionContextTests, QueuedPermission) { CheckTabContentsState(requesting_frame_0, CONTENT_SETTING_ALLOW); CheckPermissionMessageSent(0, true); - infobar_tab_helper()->RemoveInfoBar(infobar_0); + infobar_service()->RemoveInfoBar(infobar_0); EXPECT_EQ(1U, closed_delegate_tracker_.size()); EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0)); closed_delegate_tracker_.Clear(); infobar_0->InfoBarClosed(); // Now we should have a new infobar for the second frame. - ASSERT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); + ASSERT_EQ(1U, infobar_service()->GetInfoBarCount()); ConfirmInfoBarDelegate* infobar_1 = - infobar_tab_helper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); + infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(infobar_1); string16 text_1 = infobar_1->GetMessageText(); EXPECT_NE(text_0, text_1); @@ -413,11 +413,11 @@ TEST_F(GeolocationPermissionContextTests, QueuedPermission) { infobar_1->Cancel(); CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_BLOCK); CheckPermissionMessageSent(1, false); - infobar_tab_helper()->RemoveInfoBar(infobar_1); + infobar_service()->RemoveInfoBar(infobar_1); EXPECT_EQ(1U, closed_delegate_tracker_.size()); EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_1)); infobar_1->InfoBarClosed(); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); // Ensure the persisted permissions are ok. EXPECT_EQ(CONTENT_SETTING_ALLOW, profile()->GetHostContentSettingsMap()->GetContentSetting( @@ -453,14 +453,14 @@ TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) { NavigateAndCommit(requesting_frame_0); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); // Request permission for two frames. RequestGeolocationPermission(RequestID(0), requesting_frame_0); RequestGeolocationPermission(RequestID(1), requesting_frame_1); - ASSERT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); + ASSERT_EQ(1U, infobar_service()->GetInfoBarCount()); ConfirmInfoBarDelegate* infobar_0 = - infobar_tab_helper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); + infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(infobar_0); string16 text_0 = infobar_0->GetMessageText(); @@ -471,10 +471,10 @@ TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) { EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0)); closed_delegate_tracker_.Clear(); infobar_0->InfoBarClosed(); - ASSERT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); + ASSERT_EQ(1U, infobar_service()->GetInfoBarCount()); ConfirmInfoBarDelegate* infobar_1 = - infobar_tab_helper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); + infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(infobar_1); string16 text_1 = infobar_1->GetMessageText(); EXPECT_NE(text_0, text_1); @@ -483,11 +483,11 @@ TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) { infobar_1->Accept(); CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_ALLOW); CheckPermissionMessageSent(1, true); - infobar_tab_helper()->RemoveInfoBar(infobar_1); + infobar_service()->RemoveInfoBar(infobar_1); EXPECT_EQ(1U, closed_delegate_tracker_.size()); EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_1)); infobar_1->InfoBarClosed(); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); // Ensure the persisted permissions are ok. EXPECT_EQ(CONTENT_SETTING_ASK, profile()->GetHostContentSettingsMap()->GetContentSetting( @@ -508,9 +508,9 @@ TEST_F(GeolocationPermissionContextTests, InvalidURL) { GURL invalid_embedder("about:blank"); GURL requesting_frame; NavigateAndCommit(invalid_embedder); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); RequestGeolocationPermission(RequestID(0), requesting_frame); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); CheckPermissionMessageSent(0, false); } @@ -521,31 +521,31 @@ TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) { AddNewTab(url_b); AddNewTab(url_a); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); RequestGeolocationPermission(RequestID(0), url_a); - ASSERT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); + ASSERT_EQ(1U, infobar_service()->GetInfoBarCount()); RequestGeolocationPermission(RequestIDForTab(0, 0), url_b); - EXPECT_EQ(1U, infobar_tab_helper_for_tab(0)->GetInfoBarCount()); + EXPECT_EQ(1U, infobar_service_for_tab(0)->GetInfoBarCount()); RequestGeolocationPermission(RequestIDForTab(1, 0), url_a); - ASSERT_EQ(1U, infobar_tab_helper_for_tab(1)->GetInfoBarCount()); + ASSERT_EQ(1U, infobar_service_for_tab(1)->GetInfoBarCount()); - ConfirmInfoBarDelegate* removed_infobar = infobar_tab_helper_for_tab(1)-> + ConfirmInfoBarDelegate* removed_infobar = infobar_service_for_tab(1)-> GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); // Accept the first tab. ConfirmInfoBarDelegate* infobar_0 = - infobar_tab_helper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); + infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(infobar_0); infobar_0->Accept(); CheckPermissionMessageSent(0, true); - infobar_tab_helper()->RemoveInfoBar(infobar_0); + infobar_service()->RemoveInfoBar(infobar_0); EXPECT_EQ(2U, closed_delegate_tracker_.size()); EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0)); infobar_0->InfoBarClosed(); // Now the infobar for the tab with the same origin should have gone. - EXPECT_EQ(0U, infobar_tab_helper_for_tab(1)->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service_for_tab(1)->GetInfoBarCount()); CheckPermissionMessageSentForTab(1, 0, true); EXPECT_TRUE(closed_delegate_tracker_.Contains(removed_infobar)); closed_delegate_tracker_.Clear(); @@ -553,11 +553,11 @@ TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) { removed_infobar->InfoBarClosed(); // But the other tab should still have the info bar... - ASSERT_EQ(1U, infobar_tab_helper_for_tab(0)->GetInfoBarCount()); - ConfirmInfoBarDelegate* infobar_1 = infobar_tab_helper_for_tab(0)-> + ASSERT_EQ(1U, infobar_service_for_tab(0)->GetInfoBarCount()); + ConfirmInfoBarDelegate* infobar_1 = infobar_service_for_tab(0)-> GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); infobar_1->Cancel(); - infobar_tab_helper_for_tab(0)->RemoveInfoBar(infobar_1); + infobar_service_for_tab(0)->RemoveInfoBar(infobar_1); EXPECT_EQ(1U, closed_delegate_tracker_.size()); EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_1)); infobar_1->InfoBarClosed(); @@ -569,31 +569,31 @@ TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) { NavigateAndCommit(url_a); AddNewTab(url_a); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); RequestGeolocationPermission(RequestID(0), url_a); - ASSERT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); + ASSERT_EQ(1U, infobar_service()->GetInfoBarCount()); RequestGeolocationPermission(RequestIDForTab(0, 0), url_a); - EXPECT_EQ(1U, infobar_tab_helper_for_tab(0)->GetInfoBarCount()); + EXPECT_EQ(1U, infobar_service_for_tab(0)->GetInfoBarCount()); RequestGeolocationPermission(RequestIDForTab(0, 1), url_b); - ASSERT_EQ(1U, infobar_tab_helper_for_tab(0)->GetInfoBarCount()); + ASSERT_EQ(1U, infobar_service_for_tab(0)->GetInfoBarCount()); ConfirmInfoBarDelegate* removed_infobar = - infobar_tab_helper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); + infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); // Accept the second tab. - ConfirmInfoBarDelegate* infobar_0 = infobar_tab_helper_for_tab(0)-> + ConfirmInfoBarDelegate* infobar_0 = infobar_service_for_tab(0)-> GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(infobar_0); infobar_0->Accept(); CheckPermissionMessageSentForTab(0, 0, true); - infobar_tab_helper_for_tab(0)->RemoveInfoBar(infobar_0); + infobar_service_for_tab(0)->RemoveInfoBar(infobar_0); EXPECT_EQ(2U, closed_delegate_tracker_.size()); EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0)); infobar_0->InfoBarClosed(); // Now the infobar for the tab with the same origin should have gone. - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); CheckPermissionMessageSent(0, true); EXPECT_TRUE(closed_delegate_tracker_.Contains(removed_infobar)); closed_delegate_tracker_.Clear(); @@ -601,15 +601,15 @@ TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) { removed_infobar->InfoBarClosed(); // And we should have the queued infobar displayed now. - ASSERT_EQ(1U, infobar_tab_helper_for_tab(0)->GetInfoBarCount()); + ASSERT_EQ(1U, infobar_service_for_tab(0)->GetInfoBarCount()); // Accept the second infobar. - ConfirmInfoBarDelegate* infobar_1 = infobar_tab_helper_for_tab(0)-> + ConfirmInfoBarDelegate* infobar_1 = infobar_service_for_tab(0)-> GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(infobar_1); infobar_1->Accept(); CheckPermissionMessageSentForTab(0, 1, true); - infobar_tab_helper_for_tab(0)->RemoveInfoBar(infobar_1); + infobar_service_for_tab(0)->RemoveInfoBar(infobar_1); EXPECT_EQ(1U, closed_delegate_tracker_.size()); EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_1)); infobar_1->InfoBarClosed(); @@ -635,14 +635,14 @@ TEST_F(GeolocationPermissionContextTests, TabDestroyed) { std::string())); NavigateAndCommit(requesting_frame_0); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); // Request permission for two frames. RequestGeolocationPermission(RequestID(0), requesting_frame_0); RequestGeolocationPermission(RequestID(1), requesting_frame_1); // Ensure only one infobar is created. - ASSERT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); + ASSERT_EQ(1U, infobar_service()->GetInfoBarCount()); ConfirmInfoBarDelegate* infobar_0 = - infobar_tab_helper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); + infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(infobar_0); // Delete the tab contents. @@ -660,15 +660,15 @@ TEST_F(GeolocationPermissionContextTests, InfoBarUsesCommittedEntry) { GURL requesting_frame_1("http://www.example-2.com/geolocation"); NavigateAndCommit(requesting_frame_0); NavigateAndCommit(requesting_frame_1); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); // Go back: navigate to a pending entry before requesting geolocation // permission. web_contents()->GetController().GoBack(); // Request permission for the committed frame (not the pending one). RequestGeolocationPermission(RequestID(0), requesting_frame_1); // Ensure the infobar is created. - ASSERT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); - InfoBarDelegate* infobar_0 = infobar_tab_helper()->GetInfoBarDelegateAt(0); + ASSERT_EQ(1U, infobar_service()->GetInfoBarCount()); + InfoBarDelegate* infobar_0 = infobar_service()->GetInfoBarDelegateAt(0); ASSERT_TRUE(infobar_0); // Ensure the infobar is not yet expired. content::LoadCommittedDetails details; diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc index 04da72b..40c5e7f 100644 --- a/chrome/browser/geolocation/geolocation_browsertest.cc +++ b/chrome/browser/geolocation/geolocation_browsertest.cc @@ -9,11 +9,11 @@ #include "base/stringprintf.h" #include "base/utf_string_conversions.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/content_settings/tab_specific_content_settings.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/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" @@ -309,7 +309,7 @@ class GeolocationBrowserTest : public InProcessBrowserTest { observer.Wait(); } - InfoBarTabHelper::FromWebContents(web_contents)->RemoveInfoBar(infobar_); + InfoBarService::FromWebContents(web_contents)->RemoveInfoBar(infobar_); LOG(WARNING) << "infobar response set"; infobar_ = NULL; EXPECT_GT(settings_state.state_map().size(), state_map_size); @@ -554,12 +554,12 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, CancelPermissionForFrame) { iframe_xpath_ = L"//iframe[@id='iframe_1']"; AddGeolocationWatch(true); - InfoBarTabHelper* infobar_helper = InfoBarTabHelper::FromWebContents( + InfoBarService* infobar_service = InfoBarService::FromWebContents( chrome::GetActiveWebContents(current_browser_)); - size_t num_infobars_before_cancel = infobar_helper->GetInfoBarCount(); + size_t num_infobars_before_cancel = infobar_service->GetInfoBarCount(); // Change the iframe, and ensure the infobar is gone. IFrameLoader change_iframe_1(current_browser_, 1, current_url_); - size_t num_infobars_after_cancel = infobar_helper->GetInfoBarCount(); + size_t num_infobars_after_cancel = infobar_service->GetInfoBarCount(); EXPECT_EQ(num_infobars_before_cancel, num_infobars_after_cancel + 1); } diff --git a/chrome/browser/geolocation/geolocation_confirm_infobar_delegate.cc b/chrome/browser/geolocation/geolocation_confirm_infobar_delegate.cc index 0419d7d..36c4c49 100644 --- a/chrome/browser/geolocation/geolocation_confirm_infobar_delegate.cc +++ b/chrome/browser/geolocation/geolocation_confirm_infobar_delegate.cc @@ -4,11 +4,12 @@ #include "chrome/browser/geolocation/geolocation_confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/geolocation/geolocation_infobar_queue_controller.h" #include "chrome/browser/google/google_util.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "content/public/browser/navigation_details.h" #include "content/public/browser/navigation_entry.h" +#include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" #include "grit/theme_resources.h" @@ -18,18 +19,18 @@ GeolocationConfirmInfoBarDelegate::GeolocationConfirmInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, GeolocationInfoBarQueueController* controller, const GeolocationPermissionRequestID& id, const GURL& requesting_frame, const std::string& display_languages) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), controller_(controller), id_(id), requesting_frame_(requesting_frame), display_languages_(display_languages) { - const content::NavigationEntry* committed_entry = - infobar_helper->GetWebContents()->GetController().GetLastCommittedEntry(); + const content::NavigationEntry* committed_entry = infobar_service-> + GetWebContents()->GetController().GetLastCommittedEntry(); set_contents_unique_id(committed_entry ? committed_entry->GetUniqueID() : 0); } diff --git a/chrome/browser/geolocation/geolocation_confirm_infobar_delegate.h b/chrome/browser/geolocation/geolocation_confirm_infobar_delegate.h index 695cbda..4cd20df 100644 --- a/chrome/browser/geolocation/geolocation_confirm_infobar_delegate.h +++ b/chrome/browser/geolocation/geolocation_confirm_infobar_delegate.h @@ -12,7 +12,7 @@ #include <string> class GeolocationInfoBarQueueController; -class InfoBarTabHelper; +class InfoBarService; // GeolocationInfoBarDelegates are created by the // GeolocationInfoBarQueueController to control the display @@ -20,7 +20,7 @@ class InfoBarTabHelper; class GeolocationConfirmInfoBarDelegate : public ConfirmInfoBarDelegate { public: GeolocationConfirmInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, GeolocationInfoBarQueueController* controller, const GeolocationPermissionRequestID& id, const GURL& requesting_frame, diff --git a/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_android.cc b/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_android.cc index 86cbb54..2cc5989 100644 --- a/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_android.cc +++ b/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_android.cc @@ -13,12 +13,12 @@ GeolocationConfirmInfoBarDelegateAndroid:: GeolocationConfirmInfoBarDelegateAndroid( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, GeolocationInfoBarQueueController* controller, const GeolocationPermissionRequestID& id, const GURL& requesting_frame_url, const std::string& display_languages) - : GeolocationConfirmInfoBarDelegate(infobar_helper, controller, id, + : GeolocationConfirmInfoBarDelegate(infobar_service, controller, id, requesting_frame_url, display_languages), google_location_settings_helper_( diff --git a/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_android.h b/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_android.h index 2068db1..8024cfa 100644 --- a/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_android.h +++ b/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_android.h @@ -14,7 +14,7 @@ class GeolocationConfirmInfoBarDelegateAndroid : public GeolocationConfirmInfoBarDelegate { public: GeolocationConfirmInfoBarDelegateAndroid( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, GeolocationInfoBarQueueController* controller, const GeolocationPermissionRequestID& id, const GURL& requesting_frame_url, diff --git a/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_factory.cc b/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_factory.cc index d120119..14daafc 100644 --- a/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_factory.cc +++ b/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_factory.cc @@ -12,7 +12,7 @@ GeolocationConfirmInfoBarDelegate* GeolocationConfirmInfoBarDelegateFactory::Create( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, GeolocationInfoBarQueueController* controller, const GeolocationPermissionRequestID& id, const GURL& requesting_frame_url, @@ -22,5 +22,5 @@ GeolocationConfirmInfoBarDelegate* #else return new GeolocationConfirmInfoBarDelegate( #endif - infobar_helper, controller, id, requesting_frame_url, display_languages); + infobar_service, controller, id, requesting_frame_url, display_languages); } diff --git a/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_factory.h b/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_factory.h index 00d0134..c33045b 100644 --- a/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_factory.h +++ b/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_factory.h @@ -11,14 +11,14 @@ class GeolocationConfirmInfoBarDelegate; class GeolocationInfoBarQueueController; class GeolocationPermissionRequestID; class GURL; -class InfoBarTabHelper; +class InfoBarService; class GeolocationConfirmInfoBarDelegateFactory { public: GeolocationConfirmInfoBarDelegateFactory() {} ~GeolocationConfirmInfoBarDelegateFactory() {} static GeolocationConfirmInfoBarDelegate* Create( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, GeolocationInfoBarQueueController* controller, const GeolocationPermissionRequestID& id, const GURL& requesting_frame_url, diff --git a/chrome/browser/geolocation/geolocation_infobar_queue_controller.cc b/chrome/browser/geolocation/geolocation_infobar_queue_controller.cc index fd6cf93..57dc9d5 100644 --- a/chrome/browser/geolocation/geolocation_infobar_queue_controller.cc +++ b/chrome/browser/geolocation/geolocation_infobar_queue_controller.cc @@ -4,11 +4,11 @@ #include "chrome/browser/geolocation/geolocation_infobar_queue_controller.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/geolocation/geolocation_confirm_infobar_delegate.h" #include "chrome/browser/geolocation/geolocation_confirm_infobar_delegate_factory.h" #include "chrome/browser/infobars/infobar.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tab_contents/tab_util.h" @@ -26,10 +26,10 @@ namespace { -InfoBarTabHelper* GetInfoBarHelper(const GeolocationPermissionRequestID& id) { +InfoBarService* GetInfoBarService(const GeolocationPermissionRequestID& id) { content::WebContents* web_contents = tab_util::GetWebContentsByID(id.render_process_id(), id.render_view_id()); - return web_contents ? InfoBarTabHelper::FromWebContents(web_contents) : NULL; + return web_contents ? InfoBarService::FromWebContents(web_contents) : NULL; } } @@ -100,7 +100,7 @@ void GeolocationInfoBarQueueController::PendingInfoBarRequest:: CreateInfoBarDelegate(GeolocationInfoBarQueueController* controller, const std::string& display_languages) { infobar_delegate_ = GeolocationConfirmInfoBarDelegateFactory::Create( - GetInfoBarHelper(id_), controller, id_, requesting_frame_, + GetInfoBarService(id_), controller, id_, requesting_frame_, display_languages); } @@ -143,7 +143,7 @@ void GeolocationInfoBarQueueController::CancelInfoBarRequest( i != pending_infobar_requests_.end(); ++i) { if (i->id().Equals(id)) { if (i->has_infobar_delegate()) - GetInfoBarHelper(id)->RemoveInfoBar(i->infobar_delegate()); + GetInfoBarService(id)->RemoveInfoBar(i->infobar_delegate()); else pending_infobar_requests_.erase(i); return; @@ -201,7 +201,7 @@ void GeolocationInfoBarQueueController::OnPermissionSet( // Remove all InfoBars for the same |requesting_frame| and |embedder|. for (PendingInfoBarRequests::iterator i = infobars_to_remove.begin(); i != infobars_to_remove.end(); ++i) - GetInfoBarHelper(i->id())->RemoveInfoBar(i->infobar_delegate()); + GetInfoBarService(i->id())->RemoveInfoBar(i->infobar_delegate()); // Send out the permission notifications. for (PendingInfoBarRequests::iterator i = requests_to_notify.begin(); @@ -252,14 +252,14 @@ void GeolocationInfoBarQueueController::ShowQueuedInfoBarForTab( const GeolocationPermissionRequestID& id) { DCHECK(!AlreadyShowingInfoBarForTab(id)); - InfoBarTabHelper* helper = GetInfoBarHelper(id); - if (!helper) { + InfoBarService* infobar_service = GetInfoBarService(id); + if (!infobar_service) { // We can get here for example during tab shutdown, when the - // InfoBarTabHelper is removing all existing infobars, thus calling back to - // Observe(). In this case the helper still exists, and is supplied as the + // InfoBarService is removing all existing infobars, thus calling back to + // Observe(). In this case the service still exists, and is supplied as the // source of the notification we observed, but is no longer accessible from // its WebContents. In this case we should just go ahead and cancel further - // infobars for this tab instead of trying to access the helper. + // infobars for this tab instead of trying to access the service. ClearPendingInfoBarRequestsForTab(id); return; } @@ -267,15 +267,15 @@ void GeolocationInfoBarQueueController::ShowQueuedInfoBarForTab( for (PendingInfoBarRequests::iterator i = pending_infobar_requests_.begin(); i != pending_infobar_requests_.end(); ++i) { if (i->id().IsForSameTabAs(id) && !i->has_infobar_delegate()) { - RegisterForInfoBarNotifications(helper); + RegisterForInfoBarNotifications(infobar_service); i->CreateInfoBarDelegate( this, profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); - helper->AddInfoBar(i->infobar_delegate()); + infobar_service->AddInfoBar(i->infobar_delegate()); return; } } - UnregisterForInfoBarNotifications(helper); + UnregisterForInfoBarNotifications(infobar_service); } void GeolocationInfoBarQueueController::ClearPendingInfoBarRequestsForTab( @@ -290,23 +290,23 @@ void GeolocationInfoBarQueueController::ClearPendingInfoBarRequestsForTab( } void GeolocationInfoBarQueueController::RegisterForInfoBarNotifications( - InfoBarTabHelper* helper) { + InfoBarService* infobar_service) { if (!registrar_.IsRegistered( this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - content::Source<InfoBarTabHelper>(helper))) { + content::Source<InfoBarService>(infobar_service))) { registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - content::Source<InfoBarTabHelper>(helper)); + content::Source<InfoBarService>(infobar_service)); } } void GeolocationInfoBarQueueController::UnregisterForInfoBarNotifications( - InfoBarTabHelper* helper) { + InfoBarService* infobar_service) { if (registrar_.IsRegistered( this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - content::Source<InfoBarTabHelper>(helper))) { + content::Source<InfoBarService>(infobar_service))) { registrar_.Remove(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - content::Source<InfoBarTabHelper>(helper)); + content::Source<InfoBarService>(infobar_service)); } } diff --git a/chrome/browser/geolocation/geolocation_infobar_queue_controller.h b/chrome/browser/geolocation/geolocation_infobar_queue_controller.h index 1aa9e51..3260c1d 100644 --- a/chrome/browser/geolocation/geolocation_infobar_queue_controller.h +++ b/chrome/browser/geolocation/geolocation_infobar_queue_controller.h @@ -12,7 +12,7 @@ class GURL; class GeolocationConfirmInfoBarDelegate; class GeolocationPermissionRequestID; -class InfoBarTabHelper; +class InfoBarService; class Profile; // This class controls the geolocation infobar queue per profile, and it's @@ -68,15 +68,15 @@ class GeolocationInfoBarQueueController : content::NotificationObserver { // Shows the next pending infobar for the tab corresponding to |id|, if any. // Note that this may not be the pending request whose ID is |id| if other // requests are higher in the queue. If we can't show infobars because there - // is no InfoBarTabHelper for this tab, removes all queued requests for this + // is no InfoBarService for this tab, removes all queued requests for this // tab. void ShowQueuedInfoBarForTab(const GeolocationPermissionRequestID& id); void ClearPendingInfoBarRequestsForTab( const GeolocationPermissionRequestID& id); - void RegisterForInfoBarNotifications(InfoBarTabHelper* helper); - void UnregisterForInfoBarNotifications(InfoBarTabHelper* helper); + void RegisterForInfoBarNotifications(InfoBarService* infobar_service); + void UnregisterForInfoBarNotifications(InfoBarService* infobar_service); content::NotificationRegistrar registrar_; diff --git a/chrome/browser/geolocation/geolocation_infobar_queue_controller_unittest.cc b/chrome/browser/geolocation/geolocation_infobar_queue_controller_unittest.cc index f8f345b..1c2d0df 100644 --- a/chrome/browser/geolocation/geolocation_infobar_queue_controller_unittest.cc +++ b/chrome/browser/geolocation/geolocation_infobar_queue_controller_unittest.cc @@ -3,9 +3,9 @@ // found in the LICENSE file. #include "base/synchronization/waitable_event.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/geolocation/geolocation_infobar_queue_controller.h" #include "chrome/browser/geolocation/geolocation_permission_request_id.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" #include "content/public/browser/web_contents.h" @@ -44,7 +44,7 @@ GeolocationPermissionRequestID void GeolocationInfoBarQueueControllerTests::SetUp() { ChromeRenderViewHostTestHarness::SetUp(); - InfoBarTabHelper::CreateForWebContents(web_contents()); + InfoBarService::CreateForWebContents(web_contents()); } class ObservationCountingQueueController : diff --git a/chrome/browser/google/google_url_tracker.cc b/chrome/browser/google/google_url_tracker.cc index 93cde3e5..7f0b3ba1 100644 --- a/chrome/browser/google/google_url_tracker.cc +++ b/chrome/browser/google/google_url_tracker.cc @@ -7,10 +7,10 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/string_util.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/google/google_url_tracker_factory.h" #include "chrome/browser/google/google_url_tracker_infobar_delegate.h" #include "chrome/browser/google/google_util.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_notification_types.h" @@ -29,14 +29,14 @@ namespace { GoogleURLTrackerInfoBarDelegate* CreateInfoBar( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, GoogleURLTracker* google_url_tracker, const GURL& search_url) { GoogleURLTrackerInfoBarDelegate* infobar = - new GoogleURLTrackerInfoBarDelegate(infobar_helper, google_url_tracker, + new GoogleURLTrackerInfoBarDelegate(infobar_service, google_url_tracker, search_url); // AddInfoBar() takes ownership; it will delete |infobar| if it fails. - return infobar_helper->AddInfoBar(infobar) ? infobar : NULL; + return infobar_service->AddInfoBar(infobar) ? infobar : NULL; } } // namespace @@ -211,15 +211,15 @@ void GoogleURLTracker::Observe(int type, content::NavigationController* controller = content::Source<content::NavigationController>(source).ptr(); content::WebContents* web_contents = controller->GetWebContents(); - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(web_contents); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); // Because we're listening to all sources, there may be no - // InfoBarTabHelper for some notifications, e.g. navigations in + // InfoBarService for some notifications, e.g. navigations in // bubbles/balloons etc. - if (infobar_tab_helper) { + if (infobar_service) { OnNavigationPending( source, content::Source<content::WebContents>(web_contents), - infobar_tab_helper, controller->GetPendingEntry()->GetUniqueID()); + infobar_service, controller->GetPendingEntry()->GetUniqueID()); } break; } @@ -228,15 +228,15 @@ void GoogleURLTracker::Observe(int type, content::NavigationController* controller = content::Source<content::NavigationController>(source).ptr(); // Here we're only listening to notifications where we already know - // there's an associated InfoBarTabHelper. + // there's an associated InfoBarService. content::WebContents* web_contents = controller->GetWebContents(); - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(web_contents); - DCHECK(infobar_tab_helper); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); + DCHECK(infobar_service); const GURL& search_url = controller->GetActiveEntry()->GetURL(); if (!search_url.is_valid()) // Not clear if this can happen. OnTabClosed(content::Source<content::WebContents>(web_contents)); - OnNavigationCommitted(infobar_tab_helper, search_url); + OnNavigationCommitted(infobar_service, search_url); break; } @@ -253,7 +253,7 @@ void GoogleURLTracker::Observe(int type, OnInstantCommitted( content::Source<content::NavigationController>( &web_contents->GetController()), - source, InfoBarTabHelper::FromWebContents(web_contents), search_url); + source, InfoBarService::FromWebContents(web_contents), search_url); break; } @@ -274,11 +274,11 @@ void GoogleURLTracker::Shutdown() { net::NetworkChangeNotifier::RemoveIPAddressObserver(this); } -void GoogleURLTracker::DeleteMapEntryForHelper( - const InfoBarTabHelper* infobar_helper) { - // WARNING: |infobar_helper| may point to a deleted object. Do not +void GoogleURLTracker::DeleteMapEntryForService( + const InfoBarService* infobar_service) { + // WARNING: |infobar_service| may point to a deleted object. Do not // dereference it! See OnTabClosed(). - EntryMap::iterator i(entry_map_.find(infobar_helper)); + EntryMap::iterator i(entry_map_.find(infobar_service)); DCHECK(i != entry_map_.end()); GoogleURLTrackerMapEntry* map_entry = i->second; @@ -351,9 +351,9 @@ void GoogleURLTracker::SearchCommitted() { void GoogleURLTracker::OnNavigationPending( const content::NotificationSource& navigation_controller_source, const content::NotificationSource& web_contents_source, - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, int pending_id) { - EntryMap::iterator i(entry_map_.find(infobar_helper)); + EntryMap::iterator i(entry_map_.find(infobar_service)); if (search_committed_) { search_committed_ = false; @@ -377,8 +377,8 @@ void GoogleURLTracker::OnNavigationPending( registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, web_contents_source); entry_map_.insert(std::make_pair( - infobar_helper, - new GoogleURLTrackerMapEntry(this, infobar_helper, + infobar_service, + new GoogleURLTrackerMapEntry(this, infobar_service, navigation_controller_source, web_contents_source))); } else if (i->second->has_infobar()) { @@ -410,9 +410,9 @@ void GoogleURLTracker::OnNavigationPending( } } -void GoogleURLTracker::OnNavigationCommitted(InfoBarTabHelper* infobar_helper, +void GoogleURLTracker::OnNavigationCommitted(InfoBarService* infobar_service, const GURL& search_url) { - EntryMap::iterator i(entry_map_.find(infobar_helper)); + EntryMap::iterator i(entry_map_.find(infobar_service)); DCHECK(i != entry_map_.end()); GoogleURLTrackerMapEntry* map_entry = i->second; DCHECK(search_url.is_valid()); @@ -422,7 +422,7 @@ void GoogleURLTracker::OnNavigationCommitted(InfoBarTabHelper* infobar_helper, map_entry->infobar()->Update(search_url); } else { GoogleURLTrackerInfoBarDelegate* infobar_delegate = - infobar_creator_.Run(infobar_helper, this, search_url); + infobar_creator_.Run(infobar_service, this, search_url); if (infobar_delegate) map_entry->SetInfoBar(infobar_delegate); else @@ -432,12 +432,12 @@ void GoogleURLTracker::OnNavigationCommitted(InfoBarTabHelper* infobar_helper, void GoogleURLTracker::OnTabClosed( const content::NotificationSource& web_contents_source) { - // Because InfoBarTabHelper tears itself down in response to + // Because InfoBarService tears itself down in response to // NOTIFICATION_WEB_CONTENTS_DESTROYED, it may or may not be possible to - // get a non-NULL pointer back from InfoBarTabHelper::FromWebContents() here, + // get a non-NULL pointer back from InfoBarService::FromWebContents() here, // depending on which order notifications fired in. Likewise, the pointer in // |entry_map_| (and in its associated MapEntry) may point to deleted memory. - // Therefore, if we were to access to the InfoBarTabHelper* we have for this + // Therefore, if we were to access to the InfoBarService* we have for this // tab, we'd need to ensure we just looked at the raw pointer value, and never // dereferenced it. This function doesn't need to do even that, but others in // the call chain from here might (and have comments pointing back here). @@ -453,7 +453,7 @@ void GoogleURLTracker::OnTabClosed( void GoogleURLTracker::OnInstantCommitted( const content::NotificationSource& navigation_controller_source, const content::NotificationSource& web_contents_source, - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, const GURL& search_url) { // If this was the search we were listening for, OnNavigationPending() should // ensure we're registered for NAV_ENTRY_COMMITTED, and we should call @@ -465,14 +465,14 @@ void GoogleURLTracker::OnInstantCommitted( // |search_committed_| here because OnNavigationPending() will reset it. bool was_search_committed = search_committed_; OnNavigationPending(navigation_controller_source, web_contents_source, - infobar_helper, 0); - EntryMap::iterator i(entry_map_.find(infobar_helper)); + infobar_service, 0); + EntryMap::iterator i(entry_map_.find(infobar_service)); DCHECK_EQ(was_search_committed, (i != entry_map_.end()) && registrar_.IsRegistered(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, i->second->navigation_controller_source())); if (was_search_committed) - OnNavigationCommitted(infobar_helper, search_url); + OnNavigationCommitted(infobar_service, search_url); } void GoogleURLTracker::CloseAllEntries(bool redo_searches) { diff --git a/chrome/browser/google/google_url_tracker.h b/chrome/browser/google/google_url_tracker.h index 7b95c56..620f12d 100644 --- a/chrome/browser/google/google_url_tracker.h +++ b/chrome/browser/google/google_url_tracker.h @@ -93,7 +93,7 @@ class GoogleURLTracker : public net::URLFetcherDelegate, const GURL& fetched_google_url() const { return fetched_google_url_; } // No one but GoogleURLTrackerMapEntry should call this. - void DeleteMapEntryForHelper(const InfoBarTabHelper* infobar_helper); + void DeleteMapEntryForService(const InfoBarService* infobar_service); static const char kDefaultGoogleHomepage[]; static const char kSearchDomainCheckURL[]; @@ -101,8 +101,7 @@ class GoogleURLTracker : public net::URLFetcherDelegate, private: friend class GoogleURLTrackerTest; - typedef std::map<const InfoBarTabHelper*, - GoogleURLTrackerMapEntry*> EntryMap; + typedef std::map<const InfoBarService*, GoogleURLTrackerMapEntry*> EntryMap; // net::URLFetcherDelegate: virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; @@ -139,9 +138,9 @@ class GoogleURLTracker : public net::URLFetcherDelegate, // Called by Observe() after SearchCommitted() registers notification // listeners, to indicate that we've received the "load now pending" // notification. |navigation_controller_source| and |web_contents_source| are - // the NotificationSource pointing to the associated NavigationController and - // the WebContents, respectively, for this load; |infobar_helper| is the - // InfoBarTabHelper of the associated tab; and |pending_id| is the unique ID + // NotificationSources pointing to the associated NavigationController and + // WebContents, respectively, for this load; |infobar_service| is the + // InfoBarService of the associated tab; and |pending_id| is the unique ID // of the newly pending NavigationEntry. If there is already a visible // GoogleURLTracker infobar for this tab, this function resets its associated // pending entry ID to the new ID. Otherwise this function creates a @@ -149,16 +148,16 @@ class GoogleURLTracker : public net::URLFetcherDelegate, void OnNavigationPending( const content::NotificationSource& navigation_controller_source, const content::NotificationSource& web_contents_source, - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, int pending_id); - // Called by Observe() once a load we're watching commits. |infobar_helper| + // Called by Observe() once a load we're watching commits. |infobar_service| // is the same as for OnNavigationPending(); |search_url| is guaranteed to be // valid. - void OnNavigationCommitted(InfoBarTabHelper* infobar_helper, + void OnNavigationCommitted(InfoBarService* infobar_service, const GURL& search_url); - // Called by Observe() when a tab closes. Because the InfoBarTabHelper may + // Called by Observe() when a tab closes. Because the InfoBarService may // have already been torn down in this case, we look up the appropriate map // entry by |web_contents_source| instead. void OnTabClosed(const content::NotificationSource& web_contents_source); @@ -169,7 +168,7 @@ class GoogleURLTracker : public net::URLFetcherDelegate, void OnInstantCommitted( const content::NotificationSource& navigation_controller_source, const content::NotificationSource& web_contents_source, - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, const GURL& search_url); // Closes all map entries. If |redo_searches| is true, this also triggers @@ -191,11 +190,11 @@ class GoogleURLTracker : public net::URLFetcherDelegate, Profile* profile_; content::NotificationRegistrar registrar_; - // Creates an infobar delegate and adds it to the provided InfoBarHelper. + // Creates an infobar delegate and adds it to the provided InfoBarService. // Returns the delegate pointer on success or NULL on failure. The caller - // does not own the returned object, the InfoBarTabHelper does. + // does not own the returned object, the InfoBarService does. base::Callback<GoogleURLTrackerInfoBarDelegate*( - InfoBarTabHelper*, + InfoBarService*, GoogleURLTracker*, const GURL&)> infobar_creator_; diff --git a/chrome/browser/google/google_url_tracker_infobar_delegate.cc b/chrome/browser/google/google_url_tracker_infobar_delegate.cc index 0930254..a0435c2 100644 --- a/chrome/browser/google/google_url_tracker_infobar_delegate.cc +++ b/chrome/browser/google/google_url_tracker_infobar_delegate.cc @@ -4,9 +4,9 @@ #include "chrome/browser/google/google_url_tracker_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/google/google_url_tracker.h" #include "chrome/browser/google/google_util.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "content/public/browser/navigation_details.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/page_navigator.h" @@ -17,10 +17,10 @@ GoogleURLTrackerInfoBarDelegate::GoogleURLTrackerInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, GoogleURLTracker* google_url_tracker, const GURL& search_url) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), google_url_tracker_(google_url_tracker), search_url_(search_url), pending_id_(0) { diff --git a/chrome/browser/google/google_url_tracker_infobar_delegate.h b/chrome/browser/google/google_url_tracker_infobar_delegate.h index ce8bcb2..c055361 100644 --- a/chrome/browser/google/google_url_tracker_infobar_delegate.h +++ b/chrome/browser/google/google_url_tracker_infobar_delegate.h @@ -9,13 +9,12 @@ #include "googleurl/src/gurl.h" class GoogleURLTracker; -class InfoBarTabHelper; // This infobar is shown by the GoogleURLTracker when the Google base URL has // changed. class GoogleURLTrackerInfoBarDelegate : public ConfirmInfoBarDelegate { public: - GoogleURLTrackerInfoBarDelegate(InfoBarTabHelper* infobar_helper, + GoogleURLTrackerInfoBarDelegate(InfoBarService* infobar_service, GoogleURLTracker* google_url_tracker, const GURL& search_url); diff --git a/chrome/browser/google/google_url_tracker_map_entry.cc b/chrome/browser/google/google_url_tracker_map_entry.cc index 1c02253..89a3ea6 100644 --- a/chrome/browser/google/google_url_tracker_map_entry.cc +++ b/chrome/browser/google/google_url_tracker_map_entry.cc @@ -13,11 +13,11 @@ GoogleURLTrackerMapEntry::GoogleURLTrackerMapEntry( GoogleURLTracker* google_url_tracker, - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, const content::NotificationSource& navigation_controller_source, const content::NotificationSource& web_contents_source) : google_url_tracker_(google_url_tracker), - infobar_helper_(infobar_helper), + infobar_service_(infobar_service), infobar_(NULL), navigation_controller_source_(navigation_controller_source), web_contents_source_(web_contents_source) { @@ -31,9 +31,9 @@ void GoogleURLTrackerMapEntry::Observe( const content::NotificationSource& source, const content::NotificationDetails& details) { DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type); - DCHECK_EQ(infobar_helper_, content::Source<InfoBarTabHelper>(source).ptr()); + DCHECK_EQ(infobar_service_, content::Source<InfoBarService>(source).ptr()); if (content::Details<InfoBarRemovedDetails>(details)->first == infobar_) { - google_url_tracker_->DeleteMapEntryForHelper(infobar_helper_); + google_url_tracker_->DeleteMapEntryForService(infobar_service_); // WARNING: At this point |this| has been deleted! } } @@ -43,16 +43,16 @@ void GoogleURLTrackerMapEntry::SetInfoBar( DCHECK(!infobar_); infobar_ = infobar; registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - content::Source<InfoBarTabHelper>(infobar_helper_)); + content::Source<InfoBarService>(infobar_service_)); } void GoogleURLTrackerMapEntry::Close(bool redo_search) { if (infobar_) { infobar_->Close(redo_search); } else { - // WARNING: |infobar_helper_| may point to a deleted object. Do not + // WARNING: |infobar_service_| may point to a deleted object. Do not // dereference it! See GoogleURLTracker::OnTabClosed(). - google_url_tracker_->DeleteMapEntryForHelper(infobar_helper_); + google_url_tracker_->DeleteMapEntryForService(infobar_service_); } // WARNING: At this point |this| has been deleted! } diff --git a/chrome/browser/google/google_url_tracker_map_entry.h b/chrome/browser/google/google_url_tracker_map_entry.h index 495a1ed..fbe6fc2 100644 --- a/chrome/browser/google/google_url_tracker_map_entry.h +++ b/chrome/browser/google/google_url_tracker_map_entry.h @@ -11,13 +11,13 @@ class GoogleURLTracker; class GoogleURLTrackerInfoBarDelegate; -class InfoBarTabHelper; +class InfoBarService; class GoogleURLTrackerMapEntry : public content::NotificationObserver { public: GoogleURLTrackerMapEntry( GoogleURLTracker* google_url_tracker, - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, const content::NotificationSource& navigation_controller_source, const content::NotificationSource& web_contents_source); virtual ~GoogleURLTrackerMapEntry(); @@ -45,7 +45,7 @@ class GoogleURLTrackerMapEntry : public content::NotificationObserver { content::NotificationRegistrar registrar_; GoogleURLTracker* const google_url_tracker_; - const InfoBarTabHelper* const infobar_helper_; + const InfoBarService* const infobar_service_; GoogleURLTrackerInfoBarDelegate* infobar_; const content::NotificationSource navigation_controller_source_; const content::NotificationSource web_contents_source_; diff --git a/chrome/browser/google/google_url_tracker_unittest.cc b/chrome/browser/google/google_url_tracker_unittest.cc index 82d5184..8ad21b7 100644 --- a/chrome/browser/google/google_url_tracker_unittest.cc +++ b/chrome/browser/google/google_url_tracker_unittest.cc @@ -32,7 +32,7 @@ namespace { class TestInfoBarDelegate : public GoogleURLTrackerInfoBarDelegate { public: TestInfoBarDelegate(GoogleURLTrackerTest* test_harness, - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, GoogleURLTracker* google_url_tracker, const GURL& search_url); virtual ~TestInfoBarDelegate(); @@ -43,7 +43,7 @@ class TestInfoBarDelegate : public GoogleURLTrackerInfoBarDelegate { virtual void Close(bool redo_search) OVERRIDE; GoogleURLTrackerTest* test_harness_; - InfoBarTabHelper* infobar_helper_; + InfoBarService* infobar_service_; DISALLOW_COPY_AND_ASSIGN(TestInfoBarDelegate); }; @@ -90,7 +90,7 @@ void TestNotificationObserver::Observe( // Ths class exercises GoogleURLTracker. In order to avoid instantiating more // of the Chrome infrastructure than necessary, the GoogleURLTracker functions // are carefully written so that many of the functions which take WebContents*, -// NavigationController*, InfoBarTabHelper*, or objects containing such pointers +// NavigationController*, InfoBarService*, or objects containing such pointers // (e.g. NotificationSource) do not actually dereference the objects, merely use // them for comparisons and lookups, e.g. in |entry_map_|. This then allows the // test code here to not create any of these objects, and instead supply @@ -107,7 +107,7 @@ class GoogleURLTrackerTest : public testing::Test { public: // Called by TestInfoBarDelegate::Close(). void OnInfoBarClosed(GoogleURLTrackerInfoBarDelegate* infobar, - InfoBarTabHelper* infobar_helper); + InfoBarService* infobar_service); protected: GoogleURLTrackerTest(); @@ -144,12 +144,12 @@ class GoogleURLTrackerTest : public testing::Test { void clear_observer_notified() { observer_.clear_notified(); } private: - // Since |infobar_helper| is really a magic number rather than an actual + // Since |infobar_service| is really a magic number rather than an actual // object, we don't add the created infobar to it. Instead we will simulate // any helper<->infobar interaction necessary. The returned object will be // cleaned up in CloseTab(). GoogleURLTrackerInfoBarDelegate* CreateTestInfoBar( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, GoogleURLTracker* google_url_tracker, const GURL& search_url); @@ -172,16 +172,16 @@ class GoogleURLTrackerTest : public testing::Test { void GoogleURLTrackerTest::OnInfoBarClosed( GoogleURLTrackerInfoBarDelegate* infobar, - InfoBarTabHelper* infobar_helper) { - // First, simulate the InfoBarTabHelper firing INFOBAR_REMOVED. + InfoBarService* infobar_service) { + // First, simulate the InfoBarService firing INFOBAR_REMOVED. InfoBarRemovedDetails removed_details(infobar, false); GoogleURLTracker::EntryMap::const_iterator i = - google_url_tracker_->entry_map_.find(infobar_helper); + google_url_tracker_->entry_map_.find(infobar_service); ASSERT_FALSE(i == google_url_tracker_->entry_map_.end()); GoogleURLTrackerMapEntry* map_entry = i->second; ASSERT_EQ(infobar, map_entry->infobar()); map_entry->Observe(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - content::Source<InfoBarTabHelper>(infobar_helper), + content::Source<InfoBarService>(infobar_service), content::Details<InfoBarRemovedDetails>(&removed_details)); // Second, simulate the infobar container closing the infobar in response. @@ -278,7 +278,7 @@ void GoogleURLTrackerTest::SetNavigationPending(intptr_t unique_id, reinterpret_cast<content::NavigationController*>(unique_id)), content::Source<content::WebContents>( reinterpret_cast<content::WebContents*>(unique_id)), - reinterpret_cast<InfoBarTabHelper*>(unique_id), unique_id); + reinterpret_cast<InfoBarService*>(unique_id), unique_id); } } @@ -309,7 +309,7 @@ void GoogleURLTrackerTest::CommitSearch(intptr_t unique_id, content::Source<content::NavigationController>( reinterpret_cast<content::NavigationController*>(unique_id)))) { google_url_tracker_->OnNavigationCommitted( - reinterpret_cast<InfoBarTabHelper*>(unique_id), + reinterpret_cast<InfoBarService*>(unique_id), search_url); } } @@ -331,7 +331,7 @@ void GoogleURLTrackerTest::DoInstantNavigation(intptr_t unique_id, reinterpret_cast<content::NavigationController*>(unique_id)), content::Source<content::WebContents>( reinterpret_cast<content::WebContents*>(unique_id)), - reinterpret_cast<InfoBarTabHelper*>(unique_id), search_url); + reinterpret_cast<InfoBarService*>(unique_id), search_url); } } @@ -355,7 +355,7 @@ GoogleURLTrackerMapEntry* GoogleURLTrackerTest::GetMapEntry( intptr_t unique_id) { GoogleURLTracker::EntryMap::const_iterator i = google_url_tracker_->entry_map_.find( - reinterpret_cast<InfoBarTabHelper*>(unique_id)); + reinterpret_cast<InfoBarService*>(unique_id)); return (i == google_url_tracker_->entry_map_.end()) ? NULL : i->second; } @@ -383,10 +383,10 @@ void GoogleURLTrackerTest::ExpectListeningForCommit(intptr_t unique_id, } GoogleURLTrackerInfoBarDelegate* GoogleURLTrackerTest::CreateTestInfoBar( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, GoogleURLTracker* google_url_tracker, const GURL& search_url) { - return new TestInfoBarDelegate(this, infobar_helper, google_url_tracker, + return new TestInfoBarDelegate(this, infobar_service, google_url_tracker, search_url); } @@ -396,12 +396,12 @@ GoogleURLTrackerInfoBarDelegate* GoogleURLTrackerTest::CreateTestInfoBar( namespace { TestInfoBarDelegate::TestInfoBarDelegate(GoogleURLTrackerTest* test_harness, - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, GoogleURLTracker* google_url_tracker, const GURL& search_url) : GoogleURLTrackerInfoBarDelegate(NULL, google_url_tracker, search_url), test_harness_(test_harness), - infobar_helper_(infobar_helper) { + infobar_service_(infobar_service) { } TestInfoBarDelegate::~TestInfoBarDelegate() { @@ -413,7 +413,7 @@ void TestInfoBarDelegate::Update(const GURL& search_url) { } void TestInfoBarDelegate::Close(bool redo_search) { - test_harness_->OnInfoBarClosed(this, infobar_helper_); + test_harness_->OnInfoBarClosed(this, infobar_service_); } } // namespace diff --git a/chrome/browser/infobars/infobar.cc b/chrome/browser/infobars/infobar.cc index 4ef4ee6..92844e0 100644 --- a/chrome/browser/infobars/infobar.cc +++ b/chrome/browser/infobars/infobar.cc @@ -8,8 +8,8 @@ #include "base/logging.h" #include "build/build_config.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/infobars/infobar_container.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "ui/base/animation/slide_animation.h" SkColor GetInfoBarTopColor(InfoBarDelegate::Type infobar_type) { @@ -39,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(InfoBarTabHelper* owner, InfoBarDelegate* delegate) +InfoBar::InfoBar(InfoBarService* owner, InfoBarDelegate* delegate) : owner_(owner), delegate_(delegate), container_(NULL), diff --git a/chrome/browser/infobars/infobar.h b/chrome/browser/infobars/infobar.h index bf2a626..fb3b4f0 100644 --- a/chrome/browser/infobars/infobar.h +++ b/chrome/browser/infobars/infobar.h @@ -30,11 +30,11 @@ typedef std::pair<InfoBarDelegate*, InfoBarDelegate*> InfoBarReplacedDetails; #if defined(TOOLKIT_VIEWS) || defined(TOOLKIT_GTK) class InfoBarContainer; -class InfoBarTabHelper; +class InfoBarService; class InfoBar : public ui::AnimationDelegate { public: - InfoBar(InfoBarTabHelper* owner, InfoBarDelegate* delegate); + InfoBar(InfoBarService* owner, InfoBarDelegate* delegate); virtual ~InfoBar(); // Platforms must define these. @@ -118,7 +118,7 @@ class InfoBar : public ui::AnimationDelegate { // delete us) and closes the delegate. void MaybeDelete(); - InfoBarTabHelper* owner_; + InfoBarService* owner_; InfoBarDelegate* delegate_; InfoBarContainer* container_; ui::SlideAnimation animation_; diff --git a/chrome/browser/infobars/infobar_container.cc b/chrome/browser/infobars/infobar_container.cc index 6bc2069..a252025 100644 --- a/chrome/browser/infobars/infobar_container.cc +++ b/chrome/browser/infobars/infobar_container.cc @@ -13,8 +13,8 @@ #include "base/logging.h" #include "chrome/browser/api/infobars/infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/infobars/infobar.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/ui/search/search_model.h" #include "chrome/common/chrome_notification_types.h" #include "content/public/browser/notification_details.h" @@ -28,7 +28,7 @@ InfoBarContainer::InfoBarContainer( Delegate* delegate, chrome::search::SearchModel* search_model) : delegate_(delegate), - tab_helper_(NULL), + infobar_service_(NULL), search_model_(search_model), top_arrow_target_height_(InfoBar::kDefaultArrowTargetHeight) { if (search_model_) @@ -42,27 +42,28 @@ InfoBarContainer::~InfoBarContainer() { search_model_->RemoveObserver(this); } -void InfoBarContainer::ChangeTabContents(InfoBarTabHelper* tab_helper) { +void InfoBarContainer::ChangeInfoBarService(InfoBarService* infobar_service) { registrar_.RemoveAll(); infobars_shown_time_ = base::TimeTicks(); HideAllInfoBars(); - tab_helper_ = tab_helper; - if (tab_helper_) { - content::Source<InfoBarTabHelper> th_source(tab_helper_); + infobar_service_ = infobar_service; + if (infobar_service_) { + content::Source<InfoBarService> source(infobar_service_); registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, - th_source); + source); registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - th_source); + source); registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED, - th_source); + source); - for (size_t i = 0; i < tab_helper_->GetInfoBarCount(); ++i) { + for (size_t i = 0; i < infobar_service_->GetInfoBarCount(); ++i) { // As when we removed the infobars above, we prevent callbacks to // OnInfoBarAnimated() for each infobar. AddInfoBar( - tab_helper_->GetInfoBarDelegateAt(i)->CreateInfoBar(tab_helper_), + infobar_service_->GetInfoBarDelegateAt(i)->CreateInfoBar( + infobar_service_), i, false, NO_CALLBACK); } } @@ -124,7 +125,7 @@ void InfoBarContainer::RemoveAllInfoBarsForDestruction() { for (size_t i = infobars_.size(); i > 0; --i) infobars_[i - 1]->CloseSoon(); - ChangeTabContents(NULL); + ChangeInfoBarService(NULL); } void InfoBarContainer::Observe(int type, @@ -134,7 +135,7 @@ void InfoBarContainer::Observe(int type, case chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED: AddInfoBar( content::Details<InfoBarAddedDetails>(details)->CreateInfoBar( - tab_helper_), + infobar_service_), infobars_.size(), true, WANT_CALLBACK); break; @@ -148,7 +149,7 @@ void InfoBarContainer::Observe(int type, case chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED: { InfoBarReplacedDetails* replaced_details = content::Details<InfoBarReplacedDetails>(details).ptr(); - AddInfoBar(replaced_details->second->CreateInfoBar(tab_helper_), + AddInfoBar(replaced_details->second->CreateInfoBar(infobar_service_), HideInfoBar(replaced_details->first, false), false, WANT_CALLBACK); break; } @@ -166,7 +167,7 @@ void InfoBarContainer::ModeChanged(const chrome::search::Mode& old_mode, HideAllInfoBars(); OnInfoBarStateChanged(false); } else { - ChangeTabContents(tab_helper_); + ChangeInfoBarService(infobar_service_); infobars_shown_time_ = base::TimeTicks::Now(); } } diff --git a/chrome/browser/infobars/infobar_container.h b/chrome/browser/infobars/infobar_container.h index 57021c6..508bf76 100644 --- a/chrome/browser/infobars/infobar_container.h +++ b/chrome/browser/infobars/infobar_container.h @@ -17,7 +17,7 @@ class InfoBar; class InfoBarDelegate; -class InfoBarTabHelper; +class InfoBarService; namespace chrome { namespace search { @@ -67,10 +67,11 @@ class InfoBarContainer : public content::NotificationObserver, chrome::search::SearchModel* search_model); virtual ~InfoBarContainer(); - // Changes the InfoBarTabHelper for which this container is showing + // Changes the InfoBarService 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(InfoBarTabHelper* tab_helper); + // the infobars from |infobar_service|, and show them all. |infobar_service| + // may be NULL. + void ChangeInfoBarService(InfoBarService* infobar_service); // 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 @@ -126,7 +127,7 @@ class InfoBarContainer : public content::NotificationObserver, const chrome::search::Mode& new_mode) OVERRIDE; // Hides an InfoBar for the specified delegate, in response to a notification - // from the selected InfoBarTabHelper. The InfoBar's disappearance will be + // from the selected InfoBarService. The InfoBar's disappearance will be // animated if |use_animation| is true and it has been more than 50ms since // infobars were reshown due to an Instant Extended mode change. The InfoBar // will call back to RemoveInfoBar() to remove itself once it's hidden (which @@ -153,7 +154,7 @@ class InfoBarContainer : public content::NotificationObserver, content::NotificationRegistrar registrar_; Delegate* delegate_; - InfoBarTabHelper* tab_helper_; + InfoBarService* infobar_service_; InfoBars infobars_; // Tracks the most recent time infobars were re-shown after being hidden due diff --git a/chrome/browser/infobars/infobar_extension_api.cc b/chrome/browser/infobars/infobar_extension_api.cc index 7ae85d6..d89dc5f 100644 --- a/chrome/browser/infobars/infobar_extension_api.cc +++ b/chrome/browser/infobars/infobar_extension_api.cc @@ -8,12 +8,12 @@ #include "base/string_util.h" #include "base/values.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/extensions/api/tabs/tabs_constants.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_infobar_delegate.h" #include "chrome/browser/extensions/extension_tab_util.h" #include "chrome/browser/extensions/window_controller.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/url_constants.h" @@ -67,10 +67,10 @@ bool ShowInfoBarFunction::RunImpl() { return false; } - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(web_contents); - infobar_tab_helper->AddInfoBar( - new ExtensionInfoBarDelegate(browser, infobar_tab_helper, + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); + infobar_service->AddInfoBar( + new ExtensionInfoBarDelegate(browser, infobar_service, GetExtension(), url, height)); // TODO(finnur): Return the actual DOMWindow object. Bug 26463. diff --git a/chrome/browser/infobars/infobar_tab_helper.cc b/chrome/browser/infobars/infobar_tab_helper.cc index bcbd721..f6c0ca7 100644 --- a/chrome/browser/infobars/infobar_tab_helper.cc +++ b/chrome/browser/infobars/infobar_tab_helper.cc @@ -18,8 +18,23 @@ using content::WebContents; DEFINE_WEB_CONTENTS_USER_DATA_KEY(InfoBarTabHelper) +void InfoBarService::CreateForWebContents(content::WebContents* web_contents) { + return content::WebContentsUserData<InfoBarTabHelper>::CreateForWebContents( + web_contents); +} + InfoBarService* InfoBarService::FromWebContents(WebContents* web_contents) { - return InfoBarTabHelper::FromWebContents(web_contents); + return content::WebContentsUserData<InfoBarTabHelper>::FromWebContents( + web_contents); +} + +const InfoBarService* InfoBarService::FromWebContents( + const WebContents* web_contents) { + return content::WebContentsUserData<InfoBarTabHelper>::FromWebContents( + web_contents); +} + +InfoBarService::~InfoBarService() { } InfoBarTabHelper::InfoBarTabHelper(WebContents* web_contents) @@ -41,6 +56,10 @@ InfoBarTabHelper::~InfoBarTabHelper() { RemoveAllInfoBars(false); } +void InfoBarTabHelper::SetInfoBarsEnabled(bool enabled) { + infobars_enabled_ = enabled; +} + bool InfoBarTabHelper::AddInfoBar(InfoBarDelegate* delegate) { if (!infobars_enabled_) { delegate->InfoBarClosed(); @@ -71,7 +90,7 @@ bool InfoBarTabHelper::AddInfoBar(InfoBarDelegate* delegate) { content::NotificationService::current()->Notify( chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, - content::Source<InfoBarTabHelper>(this), + content::Source<InfoBarService>(this), content::Details<InfoBarAddedDetails>(delegate)); return true; } @@ -98,7 +117,7 @@ bool InfoBarTabHelper::ReplaceInfoBar(InfoBarDelegate* old_delegate, InfoBarReplacedDetails replaced_details(old_delegate, new_delegate); content::NotificationService::current()->Notify( chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED, - content::Source<InfoBarTabHelper>(this), + content::Source<InfoBarService>(this), content::Details<InfoBarReplacedDetails>(&replaced_details)); return true; } @@ -140,7 +159,7 @@ void InfoBarTabHelper::RemoveInfoBarInternal(InfoBarDelegate* delegate, InfoBarRemovedDetails removed_details(delegate, animate); content::NotificationService::current()->Notify( chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - content::Source<InfoBarTabHelper>(this), + content::Source<InfoBarService>(this), content::Details<InfoBarRemovedDetails>(&removed_details)); } diff --git a/chrome/browser/infobars/infobar_tab_helper.h b/chrome/browser/infobars/infobar_tab_helper.h index a0070f6..cde1862 100644 --- a/chrome/browser/infobars/infobar_tab_helper.h +++ b/chrome/browser/infobars/infobar_tab_helper.h @@ -5,6 +5,8 @@ #ifndef CHROME_BROWSER_INFOBARS_INFOBAR_TAB_HELPER_H_ #define CHROME_BROWSER_INFOBARS_INFOBAR_TAB_HELPER_H_ +#include <vector> + #include "base/basictypes.h" #include "chrome/browser/api/infobars/infobar_service.h" #include "content/public/browser/notification_observer.h" @@ -19,12 +21,16 @@ class InfoBarTabHelper : public InfoBarService, public content::WebContentsObserver, public content::NotificationObserver, public content::WebContentsUserData<InfoBarTabHelper> { - public: - virtual ~InfoBarTabHelper(); + private: + friend class content::WebContentsUserData<InfoBarTabHelper>; - using content::WebContentsUserData<InfoBarTabHelper>::FromWebContents; + typedef std::vector<InfoBarDelegate*> InfoBars; + + explicit InfoBarTabHelper(content::WebContents* web_contents); + virtual ~InfoBarTabHelper(); - // InfoBarService implementation. + // InfoBarService: + virtual void SetInfoBarsEnabled(bool enabled) OVERRIDE; virtual bool AddInfoBar(InfoBarDelegate* delegate) OVERRIDE; virtual void RemoveInfoBar(InfoBarDelegate* delegate) OVERRIDE; virtual bool ReplaceInfoBar(InfoBarDelegate* old_delegate, @@ -33,25 +39,15 @@ class InfoBarTabHelper : public InfoBarService, virtual InfoBarDelegate* GetInfoBarDelegateAt(size_t index) OVERRIDE; virtual content::WebContents* GetWebContents() OVERRIDE; - // Enables or disables infobars for the given tab. - void set_infobars_enabled(bool value) { infobars_enabled_ = value; } - - // content::WebContentsObserver overrides: + // content::WebContentsObserver: virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - // content::NotificationObserver overrides: + // content::NotificationObserver: virtual void Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) OVERRIDE; - private: - friend class content::WebContentsUserData<InfoBarTabHelper>; - - typedef std::vector<InfoBarDelegate*> InfoBars; - - explicit InfoBarTabHelper(content::WebContents* web_contents); - void RemoveInfoBarInternal(InfoBarDelegate* delegate, bool animate); void RemoveAllInfoBars(bool animate); diff --git a/chrome/browser/infobars/infobars_browsertest.cc b/chrome/browser/infobars/infobars_browsertest.cc index 0c5a3a6..f43f8f1 100644 --- a/chrome/browser/infobars/infobars_browsertest.cc +++ b/chrome/browser/infobars/infobars_browsertest.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/extensions/crx_installer.h" #include "chrome/browser/extensions/extension_install_prompt.h" #include "chrome/browser/extensions/extension_service.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" @@ -74,7 +74,7 @@ IN_PROC_BROWSER_TEST_F(InfoBarsTest, TestInfoBarsCloseOnNewTheme) { infobar_added_2.Wait(); infobar_removed_1.Wait(); EXPECT_EQ(0u, - InfoBarTabHelper::FromWebContents( + InfoBarService::FromWebContents( chrome::GetWebContentsAt(browser(), 0))->GetInfoBarCount()); content::WindowedNotificationObserver infobar_removed_2( @@ -83,6 +83,6 @@ IN_PROC_BROWSER_TEST_F(InfoBarsTest, TestInfoBarsCloseOnNewTheme) { ThemeServiceFactory::GetForProfile(browser()->profile())->UseDefaultTheme(); infobar_removed_2.Wait(); EXPECT_EQ(0u, - InfoBarTabHelper::FromWebContents( + InfoBarService::FromWebContents( chrome::GetActiveWebContents(browser()))->GetInfoBarCount()); } diff --git a/chrome/browser/infobars/insecure_content_infobar_delegate.cc b/chrome/browser/infobars/insecure_content_infobar_delegate.cc index 34ac0d4..3a3cf32 100644 --- a/chrome/browser/infobars/insecure_content_infobar_delegate.cc +++ b/chrome/browser/infobars/insecure_content_infobar_delegate.cc @@ -5,8 +5,8 @@ #include "chrome/browser/infobars/insecure_content_infobar_delegate.h" #include "base/metrics/histogram.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/google/google_util.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/common/render_messages.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" @@ -17,9 +17,9 @@ using content::OpenURLParams; InsecureContentInfoBarDelegate::InsecureContentInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, InfoBarType type) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), type_(type) { UMA_HISTOGRAM_ENUMERATION("InsecureContentInfoBarDelegateV2", (type_ == DISPLAY) ? DISPLAY_INFOBAR_SHOWN : RUN_INFOBAR_SHOWN, diff --git a/chrome/browser/infobars/insecure_content_infobar_delegate.h b/chrome/browser/infobars/insecure_content_infobar_delegate.h index 97d65c0e..144806b 100644 --- a/chrome/browser/infobars/insecure_content_infobar_delegate.h +++ b/chrome/browser/infobars/insecure_content_infobar_delegate.h @@ -7,8 +7,6 @@ #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" -class InfoBarTabHelper; - // Base class for delegates that show warnings on HTTPS pages which try to // display or run insecure content. class InsecureContentInfoBarDelegate : public ConfirmInfoBarDelegate { @@ -18,7 +16,7 @@ class InsecureContentInfoBarDelegate : public ConfirmInfoBarDelegate { RUN, // Shown when "active" content (e.g. script) has been blocked. }; - InsecureContentInfoBarDelegate(InfoBarTabHelper* infobar_helper, + InsecureContentInfoBarDelegate(InfoBarService* infobar_service, InfoBarType type); virtual ~InsecureContentInfoBarDelegate(); diff --git a/chrome/browser/intents/register_intent_handler_helper.cc b/chrome/browser/intents/register_intent_handler_helper.cc index 12e6acb..2cca3c0 100644 --- a/chrome/browser/intents/register_intent_handler_helper.cc +++ b/chrome/browser/intents/register_intent_handler_helper.cc @@ -4,9 +4,9 @@ #include <string> +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/favicon/favicon_service.h" #include "chrome/browser/favicon/favicon_service_factory.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" #include "chrome/browser/intents/web_intents_registry_factory.h" #include "chrome/browser/intents/web_intents_util.h" @@ -34,7 +34,7 @@ void Browser::RegisterIntentHandlerHelper( profile, Profile::EXPLICIT_ACCESS); RegisterIntentHandlerInfoBarDelegate::MaybeShowIntentInfoBar( - InfoBarTabHelper::FromWebContents(web_contents), + InfoBarService::FromWebContents(web_contents), WebIntentsRegistryFactory::GetForProfile(profile), data, favicon_service, diff --git a/chrome/browser/intents/register_intent_handler_infobar_delegate.cc b/chrome/browser/intents/register_intent_handler_infobar_delegate.cc index 854fd9f..d9df3ef 100644 --- a/chrome/browser/intents/register_intent_handler_infobar_delegate.cc +++ b/chrome/browser/intents/register_intent_handler_infobar_delegate.cc @@ -8,8 +8,8 @@ #include "base/bind_helpers.h" #include "base/logging.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/favicon/favicon_service.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/intents/web_intents_registry.h" #include "chrome/browser/intents/web_intents_registry_factory.h" #include "chrome/browser/profiles/profile.h" @@ -17,12 +17,12 @@ #include "ui/base/l10n/l10n_util.h" RegisterIntentHandlerInfoBarDelegate::RegisterIntentHandlerInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, WebIntentsRegistry* registry, const webkit_glue::WebIntentServiceData& service, FaviconService* favicon_service, const GURL& origin_url) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), registry_(registry), service_(service), favicon_service_(favicon_service), @@ -77,15 +77,15 @@ bool RegisterIntentHandlerInfoBarDelegate::LinkClicked( namespace { // Helper continuation for MaybeShowIntentInfoBar. -void CheckProvider(InfoBarTabHelper* infobar_helper, +void CheckProvider(InfoBarService* infobar_service, WebIntentsRegistry* registry, const webkit_glue::WebIntentServiceData& service, FaviconService* favicon_service, const GURL& origin_url, bool provider_exists) { if (!provider_exists) { - infobar_helper->AddInfoBar(new RegisterIntentHandlerInfoBarDelegate( - infobar_helper, registry, service, favicon_service, origin_url)); + infobar_service->AddInfoBar(new RegisterIntentHandlerInfoBarDelegate( + infobar_service, registry, service, favicon_service, origin_url)); } } @@ -93,16 +93,16 @@ void CheckProvider(InfoBarTabHelper* infobar_helper, // static void RegisterIntentHandlerInfoBarDelegate::MaybeShowIntentInfoBar( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, WebIntentsRegistry* registry, const webkit_glue::WebIntentServiceData& service, FaviconService* favicon_service, const GURL& origin_url) { - DCHECK(infobar_helper); + DCHECK(infobar_service); DCHECK(registry); registry->IntentServiceExists(service, base::Bind(&CheckProvider, - base::Unretained(infobar_helper), + base::Unretained(infobar_service), registry, service, favicon_service, diff --git a/chrome/browser/intents/register_intent_handler_infobar_delegate.h b/chrome/browser/intents/register_intent_handler_infobar_delegate.h index 36cbf28..db15538 100644 --- a/chrome/browser/intents/register_intent_handler_infobar_delegate.h +++ b/chrome/browser/intents/register_intent_handler_infobar_delegate.h @@ -10,7 +10,6 @@ #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" #include "webkit/glue/web_intent_service_data.h" -class InfoBarTabHelper; class WebIntentsRegistry; class FaviconService; class GURL; @@ -20,7 +19,7 @@ class GURL; class RegisterIntentHandlerInfoBarDelegate : public ConfirmInfoBarDelegate { public: RegisterIntentHandlerInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, WebIntentsRegistry* registry, const webkit_glue::WebIntentServiceData& service, FaviconService* favicon_service, @@ -36,14 +35,14 @@ class RegisterIntentHandlerInfoBarDelegate : public ConfirmInfoBarDelegate { // Shows the intent registration infobar if |service| has not already been // registered. - // |infobar_helper| is the infobar controller for the tab in which the infobar - // may be shown. Must not be NULL. + // |infobar_service| is the infobar controller for the tab in which the + // infobar may be shown. Must not be NULL. // |registry| is the data source for web intents. Must not be NULL. // |service| is the candidate service to show the infobar for. // |favicon_service| is the favicon service to use. Must not be NULL. // |origin_url| is the URL that the intent is registered from. static void MaybeShowIntentInfoBar( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, WebIntentsRegistry* registry, const webkit_glue::WebIntentServiceData& service, FaviconService* favicon_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 da32169..5b09920 100644 --- a/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc +++ b/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc @@ -4,7 +4,7 @@ #include "base/synchronization/waitable_event.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" +#include "chrome/browser/api/infobars/infobar_service.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" @@ -44,7 +44,7 @@ class RegisterIntentHandlerInfoBarDelegateTest virtual void SetUp() { ChromeRenderViewHostTestHarness::SetUp(); - InfoBarTabHelper::CreateForWebContents(web_contents()); + InfoBarService::CreateForWebContents(web_contents()); profile()->CreateWebDataService(); web_intents_registry_ = BuildForProfile(profile()); @@ -71,7 +71,7 @@ TEST_F(RegisterIntentHandlerInfoBarDelegateTest, Accept) { service.action = ASCIIToUTF16("http://webintents.org/share"); service.type = ASCIIToUTF16("text/url"); RegisterIntentHandlerInfoBarDelegate delegate( - InfoBarTabHelper::FromWebContents(web_contents()), + InfoBarService::FromWebContents(web_contents()), WebIntentsRegistryFactory::GetForProfile(profile()), service, NULL, GURL()); diff --git a/chrome/browser/managed_mode/managed_mode_navigation_observer.cc b/chrome/browser/managed_mode/managed_mode_navigation_observer.cc index a2076d5..945802e 100644 --- a/chrome/browser/managed_mode/managed_mode_navigation_observer.cc +++ b/chrome/browser/managed_mode/managed_mode_navigation_observer.cc @@ -5,7 +5,7 @@ #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/managed_mode/managed_mode.h" #include "chrome/browser/managed_mode/managed_mode_url_filter.h" #include "chrome/browser/ui/browser.h" @@ -22,8 +22,7 @@ namespace { class ManagedModeWarningInfobarDelegate : public ConfirmInfoBarDelegate { public: - explicit ManagedModeWarningInfobarDelegate( - InfoBarTabHelper* infobar_tab_helper); + explicit ManagedModeWarningInfobarDelegate(InfoBarService* infobar_service); private: virtual ~ManagedModeWarningInfobarDelegate(); @@ -66,8 +65,8 @@ void GoBackToSafety(content::WebContents* web_contents) { } ManagedModeWarningInfobarDelegate::ManagedModeWarningInfobarDelegate( - InfoBarTabHelper* infobar_tab_helper) - : ConfirmInfoBarDelegate(infobar_tab_helper) {} + InfoBarService* infobar_service) + : ConfirmInfoBarDelegate(infobar_service) {} ManagedModeWarningInfobarDelegate::~ManagedModeWarningInfobarDelegate() {} @@ -139,17 +138,17 @@ void ManagedModeNavigationObserver::DidCommitProvisionalLoadForFrame( if (behavior == ManagedModeURLFilter::WARN) { if (!warn_infobar_delegate_) { - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(web_contents()); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents()); warn_infobar_delegate_ = - new ManagedModeWarningInfobarDelegate(infobar_tab_helper); - infobar_tab_helper->AddInfoBar(warn_infobar_delegate_); + new ManagedModeWarningInfobarDelegate(infobar_service); + infobar_service->AddInfoBar(warn_infobar_delegate_); } } else { if (warn_infobar_delegate_) { - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(web_contents()); - infobar_tab_helper->RemoveInfoBar(warn_infobar_delegate_); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents()); + infobar_service->RemoveInfoBar(warn_infobar_delegate_); warn_infobar_delegate_= NULL; } } diff --git a/chrome/browser/managed_mode/managed_mode_navigation_observer.h b/chrome/browser/managed_mode/managed_mode_navigation_observer.h index 3f84381..06e0f84 100644 --- a/chrome/browser/managed_mode/managed_mode_navigation_observer.h +++ b/chrome/browser/managed_mode/managed_mode_navigation_observer.h @@ -35,7 +35,7 @@ class ManagedModeNavigationObserver // Owned by ManagedMode (which is a singleton and outlives us). const ManagedModeURLFilter* url_filter_; - // Owned by the InfoBarTabHelper, which has the same lifetime as this object. + // Owned by the InfoBarService, which has the same lifetime as this object. InfoBarDelegate* warn_infobar_delegate_; DISALLOW_COPY_AND_ASSIGN(ManagedModeNavigationObserver); diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc index 5db02c2..ef0ed71 100644 --- a/chrome/browser/notifications/desktop_notification_service.cc +++ b/chrome/browser/notifications/desktop_notification_service.cc @@ -8,13 +8,13 @@ #include "base/threading/thread.h" #include "base/utf_string_conversions.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/content_settings/content_settings_details.h" #include "chrome/browser/content_settings/content_settings_provider.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/notifications/desktop_notification_service_factory.h" #include "chrome/browser/notifications/notification.h" #include "chrome/browser/notifications/notification_object_proxy.h" @@ -60,7 +60,7 @@ const ContentSetting kDefaultSetting = CONTENT_SETTING_ASK; class NotificationPermissionInfoBarDelegate : public ConfirmInfoBarDelegate { public: NotificationPermissionInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, DesktopNotificationService* notification_service, const GURL& origin, const string16& display_name, @@ -102,14 +102,14 @@ class NotificationPermissionInfoBarDelegate : public ConfirmInfoBarDelegate { }; NotificationPermissionInfoBarDelegate::NotificationPermissionInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, DesktopNotificationService* notification_service, const GURL& origin, const string16& display_name, int process_id, int route_id, int callback_context) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), origin_(origin), display_name_(display_name), notification_service_(notification_service), @@ -410,14 +410,14 @@ void DesktopNotificationService::RequestPermission( ContentSetting setting = GetContentSetting(origin); if (setting == CONTENT_SETTING_ASK) { // Show an info bar requesting permission. - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(contents); - // |infobar_tab_helper| may be NULL, e.g., if this request originated in a + InfoBarService* infobar_service = + InfoBarService::FromWebContents(contents); + // |infobar_service| may be NULL, e.g., if this request originated in a // browser action popup, extension background page, or any HTML that runs // outside of a tab. - if (infobar_tab_helper) { - infobar_tab_helper->AddInfoBar(new NotificationPermissionInfoBarDelegate( - infobar_tab_helper, + if (infobar_service) { + infobar_service->AddInfoBar(new NotificationPermissionInfoBarDelegate( + infobar_service, DesktopNotificationServiceFactory::GetForProfile( Profile::FromBrowserContext(contents->GetBrowserContext())), origin, diff --git a/chrome/browser/notifications/notification_browsertest.cc b/chrome/browser/notifications/notification_browsertest.cc index a171425..86a7d57 100644 --- a/chrome/browser/notifications/notification_browsertest.cc +++ b/chrome/browser/notifications/notification_browsertest.cc @@ -13,9 +13,8 @@ #include "base/stringprintf.h" #include "base/utf_string_conversions.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" -#include "chrome/browser/api/infobars/infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/notifications/balloon.h" #include "chrome/browser/notifications/balloon_collection.h" #include "chrome/browser/notifications/balloon_host.h" @@ -248,11 +247,11 @@ void NotificationsTest::AllowAllOrigins() { } void NotificationsTest::VerifyInfobar(const Browser* browser, int index) { - InfoBarTabHelper* infobar_helper = InfoBarTabHelper::FromWebContents( + InfoBarService* infobar_service = InfoBarService::FromWebContents( browser->tab_strip_model()->GetWebContentsAt(index)); - ASSERT_EQ(1U, infobar_helper->GetInfoBarCount()); - InfoBarDelegate* infobar = infobar_helper->GetInfoBarDelegateAt(0); + ASSERT_EQ(1U, infobar_service->GetInfoBarCount()); + InfoBarDelegate* infobar = infobar_service->GetInfoBarDelegateAt(0); ConfirmInfoBarDelegate* confirm_infobar = infobar->AsConfirmInfoBarDelegate(); ASSERT_TRUE(confirm_infobar); int buttons = confirm_infobar->GetButtons(); @@ -294,11 +293,11 @@ std::string NotificationsTest::CreateSimpleNotification( } bool NotificationsTest::RequestPermissionAndWait(Browser* browser) { - InfoBarTabHelper* infobar_helper = InfoBarTabHelper::FromWebContents( + InfoBarService* infobar_service = InfoBarService::FromWebContents( browser->tab_strip_model()->GetActiveWebContents()); content::WindowedNotificationObserver observer( chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, - content::Source<InfoBarTabHelper>(infobar_helper)); + content::Source<InfoBarService>(infobar_service)); std::string result; bool success = content::ExecuteJavaScriptAndExtractString( browser->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(), @@ -335,28 +334,29 @@ bool NotificationsTest::PerformActionOnInfobar( InfobarAction action, int infobar_index, int tab_index) { - InfoBarTabHelper* infobar_helper = InfoBarTabHelper::FromWebContents( + InfoBarService* infobar_service = InfoBarService::FromWebContents( browser->tab_strip_model()->GetWebContentsAt(tab_index)); - InfoBarDelegate* infobar = infobar_helper->GetInfoBarDelegateAt( - infobar_index); + InfoBarDelegate* infobar = + infobar_service->GetInfoBarDelegateAt(infobar_index); switch (action) { - case DISMISS: { + case DISMISS: infobar->InfoBarDismissed(); - infobar_helper->RemoveInfoBar(infobar); + infobar_service->RemoveInfoBar(infobar); return true; - } + case ALLOW: { ConfirmInfoBarDelegate* confirm_bar = infobar->AsConfirmInfoBarDelegate(); if (confirm_bar->Accept()) { - infobar_helper->RemoveInfoBar(infobar); + infobar_service->RemoveInfoBar(infobar); return true; } } + case DENY: { ConfirmInfoBarDelegate* confirm_bar = infobar->AsConfirmInfoBarDelegate(); if (confirm_bar->Cancel()) { - infobar_helper->RemoveInfoBar(infobar); + infobar_service->RemoveInfoBar(infobar); return true; } } @@ -419,7 +419,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsTest, TestUserGestureInfobar) { &result)); EXPECT_TRUE(result); - EXPECT_EQ(1U, InfoBarTabHelper::FromWebContents( + EXPECT_EQ(1U, InfoBarService::FromWebContents( browser()->tab_strip_model()->GetWebContentsAt(0))->GetInfoBarCount()); } @@ -432,7 +432,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsTest, TestNoUserGestureInfobar) { test_server()->GetURL( "files/notifications/notifications_request_inline.html")); - EXPECT_EQ(0U, InfoBarTabHelper::FromWebContents( + EXPECT_EQ(0U, InfoBarService::FromWebContents( browser()->tab_strip_model()->GetWebContentsAt(0))->GetInfoBarCount()); } @@ -558,7 +558,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsTest, TestAllowNotificationsFromAllSites) { EXPECT_NE("-1", result); ASSERT_EQ(1, GetNotificationCount()); - EXPECT_EQ(0U, InfoBarTabHelper::FromWebContents( + EXPECT_EQ(0U, InfoBarService::FromWebContents( browser()->tab_strip_model()->GetWebContentsAt(0))->GetInfoBarCount()); } @@ -617,7 +617,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsTest, TestDenyAndThenAllowDomain) { EXPECT_NE("-1", result); ASSERT_EQ(1, GetNotificationCount()); - EXPECT_EQ(0U, InfoBarTabHelper::FromWebContents( + EXPECT_EQ(0U, InfoBarService::FromWebContents( browser()->tab_strip_model()->GetWebContentsAt(0))->GetInfoBarCount()); } diff --git a/chrome/browser/omnibox_search_hint.cc b/chrome/browser/omnibox_search_hint.cc index c700632..1b4f564 100644 --- a/chrome/browser/omnibox_search_hint.cc +++ b/chrome/browser/omnibox_search_hint.cc @@ -10,10 +10,10 @@ #include "base/message_loop.h" #include "base/metrics/histogram.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/autocomplete/autocomplete_log.h" #include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/autocomplete/autocomplete_result.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search_engines/template_url.h" @@ -59,7 +59,7 @@ const char* const kSearchEngineURLs[] = { class HintInfoBar : public ConfirmInfoBarDelegate { public: HintInfoBar(OmniboxSearchHint* omnibox_hint, - InfoBarTabHelper* infobar_tab_helper); + InfoBarService* infobar_service); private: virtual ~HintInfoBar(); @@ -93,8 +93,8 @@ class HintInfoBar : public ConfirmInfoBarDelegate { }; HintInfoBar::HintInfoBar(OmniboxSearchHint* omnibox_hint, - InfoBarTabHelper* infobar_tab_helper) - : ConfirmInfoBarDelegate(infobar_tab_helper), + InfoBarService* infobar_service) + : ConfirmInfoBarDelegate(infobar_service), omnibox_hint_(omnibox_hint), action_taken_(false), should_expire_(false), @@ -214,9 +214,9 @@ void OmniboxSearchHint::Observe(int type, } void OmniboxSearchHint::ShowInfoBar() { - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(web_contents_); - infobar_tab_helper->AddInfoBar(new HintInfoBar(this, infobar_tab_helper)); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents_); + infobar_service->AddInfoBar(new HintInfoBar(this, infobar_service)); } void OmniboxSearchHint::ShowEnteringQuery() { diff --git a/chrome/browser/password_manager/password_manager_delegate_impl.cc b/chrome/browser/password_manager/password_manager_delegate_impl.cc index 8df5fa4..de91fb1 100644 --- a/chrome/browser/password_manager/password_manager_delegate_impl.cc +++ b/chrome/browser/password_manager/password_manager_delegate_impl.cc @@ -8,8 +8,8 @@ #include "base/metrics/histogram.h" #include "base/utf_string_conversions.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/autofill/autofill_manager.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/password_manager/password_form_manager.h" #include "chrome/browser/password_manager/password_manager.h" #include "chrome/browser/profiles/profile.h" @@ -38,7 +38,7 @@ DEFINE_WEB_CONTENTS_USER_DATA_KEY(PasswordManagerDelegateImpl) // forms never end up in an infobar. class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate { public: - SavePasswordInfoBarDelegate(InfoBarTabHelper* infobar_helper, + SavePasswordInfoBarDelegate(InfoBarService* infobar_service, PasswordFormManager* form_to_save); private: @@ -72,9 +72,9 @@ class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate { }; SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, PasswordFormManager* form_to_save) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), form_to_save_(form_to_save), infobar_response_(NO_RESPONSE) { } @@ -163,10 +163,10 @@ void PasswordManagerDelegateImpl::AddSavePasswordInfoBarIfPermitted( } #endif - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(web_contents_); - infobar_tab_helper->AddInfoBar( - new SavePasswordInfoBarDelegate(infobar_tab_helper, form_to_save)); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents_); + infobar_service->AddInfoBar( + new SavePasswordInfoBarDelegate(infobar_service, form_to_save)); } Profile* PasswordManagerDelegateImpl::GetProfile() { diff --git a/chrome/browser/pepper_broker_infobar_delegate.cc b/chrome/browser/pepper_broker_infobar_delegate.cc index 6d322a3..91e9b9d 100644 --- a/chrome/browser/pepper_broker_infobar_delegate.cc +++ b/chrome/browser/pepper_broker_infobar_delegate.cc @@ -4,8 +4,8 @@ #include "chrome/browser/pepper_broker_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/content_settings/host_content_settings_map.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/plugins/plugin_finder.h" #include "chrome/browser/plugins/plugin_metadata.h" #include "chrome/browser/prefs/pref_service.h" @@ -68,13 +68,13 @@ void PepperBrokerInfoBarDelegate::Show( content::RecordAction( content::UserMetricsAction("PPAPI.BrokerInfobarDisplayed")); - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); std::string languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); - infobar_helper->AddInfoBar( + infobar_service->AddInfoBar( new PepperBrokerInfoBarDelegate( - infobar_helper, url, plugin_path, languages, content_settings, + infobar_service, url, plugin_path, languages, content_settings, callback)); break; } @@ -84,13 +84,13 @@ void PepperBrokerInfoBarDelegate::Show( } PepperBrokerInfoBarDelegate::PepperBrokerInfoBarDelegate( - InfoBarTabHelper* helper, + InfoBarService* infobar_service, const GURL& url, const FilePath& plugin_path, const std::string& languages, HostContentSettingsMap* content_settings, const base::Callback<void(bool)>& callback) - : ConfirmInfoBarDelegate(helper), + : ConfirmInfoBarDelegate(infobar_service), url_(url), plugin_path_(plugin_path), languages_(languages), diff --git a/chrome/browser/pepper_broker_infobar_delegate.h b/chrome/browser/pepper_broker_infobar_delegate.h index 0d05371..361e565 100644 --- a/chrome/browser/pepper_broker_infobar_delegate.h +++ b/chrome/browser/pepper_broker_infobar_delegate.h @@ -11,7 +11,7 @@ #include "googleurl/src/gurl.h" class HostContentSettingsMap; -class InfoBarTabHelper; +class InfoBarService; namespace content { class WebContents; @@ -42,7 +42,7 @@ class PepperBrokerInfoBarDelegate : public ConfirmInfoBarDelegate { private: PepperBrokerInfoBarDelegate( - InfoBarTabHelper* helper, + InfoBarService* infobar_service, const GURL& url, const FilePath& plugin_path, const std::string& languages, diff --git a/chrome/browser/plugins/plugin_observer.cc b/chrome/browser/plugins/plugin_observer.cc index b152615..118b536 100644 --- a/chrome/browser/plugins/plugin_observer.cc +++ b/chrome/browser/plugins/plugin_observer.cc @@ -9,10 +9,10 @@ #include "base/stl_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/api/infobars/simple_alert_infobar_delegate.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/content_settings/host_content_settings_map.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/metrics/metrics_service.h" #include "chrome/browser/plugins/plugin_finder.h" @@ -189,11 +189,11 @@ void PluginObserver::PluginCrashed(const FilePath& plugin_path) { PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); gfx::Image* icon = &ResourceBundle::GetSharedInstance().GetNativeImageNamed( IDR_INFOBAR_PLUGIN_CRASHED); - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents()); - infobar_helper->AddInfoBar( + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents()); + infobar_service->AddInfoBar( new SimpleAlertInfoBarDelegate( - infobar_helper, + infobar_service, icon, l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT, plugin_name), true)); @@ -227,11 +227,11 @@ bool PluginObserver::OnMessageReceived(const IPC::Message& message) { void PluginObserver::OnBlockedUnauthorizedPlugin( const string16& name, const std::string& identifier) { - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents()); - infobar_helper->AddInfoBar( + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents()); + infobar_service->AddInfoBar( new UnauthorizedPluginInfoBarDelegate( - infobar_helper, + infobar_service, Profile::FromBrowserContext(web_contents()->GetBrowserContext())-> GetHostContentSettingsMap(), name, identifier)); @@ -252,9 +252,9 @@ void PluginObserver::OnBlockedOutdatedPlugin(int placeholder_id, plugin_placeholders_[placeholder_id] = new PluginPlaceholderHost(this, placeholder_id, plugin->name(), installer); - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents()); - infobar_helper->AddInfoBar( + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents()); + infobar_service->AddInfoBar( OutdatedPluginInfoBarDelegate::Create(web_contents(), installer, plugin.Pass())); #else @@ -286,25 +286,25 @@ void PluginObserver::OnFindMissingPlugin(int placeholder_id, PluginInstallerInfoBarDelegate::InstallCallback callback = base::Bind(&PluginObserver::InstallMissingPlugin, weak_ptr_factory_.GetWeakPtr(), installer); - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents()); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents()); InfoBarDelegate* delegate; #if !defined(OS_WIN) delegate = PluginInstallerInfoBarDelegate::Create( - infobar_helper, installer, plugin_metadata.Pass(), callback); + infobar_service, installer, plugin_metadata.Pass(), callback); #else delegate = base::win::IsMetroProcess() ? new PluginMetroModeInfoBarDelegate( - infobar_helper, + infobar_service, l10n_util::GetStringFUTF16(IDS_METRO_MISSING_PLUGIN_PROMPT, plugin_metadata->name()), l10n_util::GetStringUTF16(IDS_WIN8_DESKTOP_RESTART), GURL("https://support.google.com/chrome/?ib_display_in_desktop"), false) : PluginInstallerInfoBarDelegate::Create( - infobar_helper, installer, plugin_metadata.Pass(), callback); + infobar_service, installer, plugin_metadata.Pass(), callback); #endif - infobar_helper->AddInfoBar(delegate); + infobar_service->AddInfoBar(delegate); } void PluginObserver::InstallMissingPlugin( @@ -344,10 +344,10 @@ void PluginObserver::OnCouldNotLoadPlugin(const FilePath& plugin_path) { g_browser_process->metrics_service()->LogPluginLoadingError(plugin_path); string16 plugin_name = PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents()); - infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( - infobar_helper, + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents()); + infobar_service->AddInfoBar(new SimpleAlertInfoBarDelegate( + infobar_service, &ResourceBundle::GetSharedInstance().GetNativeImageNamed( IDR_INFOBAR_PLUGIN_CRASHED), l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT, @@ -378,11 +378,11 @@ void PluginObserver::OnNPAPINotSupported(const std::string& identifier) { return; } - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents()); - infobar_helper->AddInfoBar( + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents()); + infobar_service->AddInfoBar( new PluginMetroModeInfoBarDelegate( - infobar_helper, + infobar_service, l10n_util::GetStringFUTF16(IDS_METRO_NPAPI_PLUGIN_PROMPT, plugin->name()), l10n_util::GetStringUTF16(IDS_WIN8_RESTART), diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc index abc0207..7561ae1 100644 --- a/chrome/browser/policy/policy_browsertest.cc +++ b/chrome/browser/policy/policy_browsertest.cc @@ -20,6 +20,7 @@ #include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/app/chrome_command_ids.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/autocomplete/autocomplete_controller.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/devtools/devtools_window.h" @@ -27,7 +28,6 @@ #include "chrome/browser/extensions/crx_installer.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/net/url_request_mock_util.h" #include "chrome/browser/plugins/plugin_prefs.h" #include "chrome/browser/policy/browser_policy_connector.h" @@ -1028,18 +1028,17 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, AlwaysAuthorizePlugins) { content::WebContents* contents = chrome::GetActiveWebContents(browser()); ASSERT_TRUE(contents); - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(contents); - ASSERT_TRUE(infobar_helper); - EXPECT_EQ(0u, infobar_helper->GetInfoBarCount()); + InfoBarService* infobar_service = InfoBarService::FromWebContents(contents); + ASSERT_TRUE(infobar_service); + EXPECT_EQ(0u, infobar_service->GetInfoBarCount()); FilePath path(FILE_PATH_LITERAL("plugin/quicktime.html")); GURL url(URLRequestMockHTTPJob::GetMockUrl(path)); ui_test_utils::NavigateToURL(browser(), url); // This should have triggered the dangerous plugin infobar. - ASSERT_EQ(1u, infobar_helper->GetInfoBarCount()); + ASSERT_EQ(1u, infobar_service->GetInfoBarCount()); InfoBarDelegate* infobar_delegate = - infobar_helper->GetInfoBarDelegateAt(0); + infobar_service->GetInfoBarDelegateAt(0); EXPECT_TRUE(infobar_delegate->AsConfirmInfoBarDelegate()); // And the plugin isn't running. EXPECT_EQ(0, CountPlugins()); @@ -1051,7 +1050,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, AlwaysAuthorizePlugins) { provider_.UpdateChromePolicy(policies); // Reloading the page shouldn't trigger the infobar this time. ui_test_utils::NavigateToURL(browser(), url); - EXPECT_EQ(0u, infobar_helper->GetInfoBarCount()); + EXPECT_EQ(0u, infobar_service->GetInfoBarCount()); // And the plugin started automatically. EXPECT_EQ(1, CountPlugins()); } @@ -1350,13 +1349,12 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) { IN_PROC_BROWSER_TEST_F(PolicyTest, TranslateEnabled) { // Verifies that translate can be forced enabled or disabled by policy. - // Get the |infobar_helper|, and verify that there are no infobars on startup. + // Get the InfoBarService, and verify that there are no infobars on startup. content::WebContents* contents = chrome::GetActiveWebContents(browser()); ASSERT_TRUE(contents); - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(contents); - ASSERT_TRUE(infobar_helper); - EXPECT_EQ(0u, infobar_helper->GetInfoBarCount()); + InfoBarService* infobar_service = InfoBarService::FromWebContents(contents); + ASSERT_TRUE(infobar_service); + EXPECT_EQ(0u, infobar_service->GetInfoBarCount()); // Force enable the translate feature. PolicyMap policies; @@ -1376,9 +1374,9 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, TranslateEnabled) { ui_test_utils::NavigateToURL(browser(), url); language_observer1.Wait(); // Verify that the translate infobar showed up. - ASSERT_EQ(1u, infobar_helper->GetInfoBarCount()); + ASSERT_EQ(1u, infobar_service->GetInfoBarCount()); InfoBarDelegate* infobar_delegate = - infobar_helper->GetInfoBarDelegateAt(0); + infobar_service->GetInfoBarDelegateAt(0); TranslateInfoBarDelegate* delegate = infobar_delegate->AsTranslateInfoBarDelegate(); ASSERT_TRUE(delegate); @@ -1386,8 +1384,8 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, TranslateEnabled) { EXPECT_EQ("fr", delegate->original_language_code()); // Now force disable translate. - infobar_helper->RemoveInfoBar(infobar_delegate); - EXPECT_EQ(0u, infobar_helper->GetInfoBarCount()); + infobar_service->RemoveInfoBar(infobar_delegate); + EXPECT_EQ(0u, infobar_service->GetInfoBarCount()); policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false)); provider_.UpdateChromePolicy(policies); @@ -1397,7 +1395,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, TranslateEnabled) { content::NotificationService::AllSources()); ui_test_utils::NavigateToURL(browser(), url); language_observer2.Wait(); - EXPECT_EQ(0u, infobar_helper->GetInfoBarCount()); + EXPECT_EQ(0u, infobar_service->GetInfoBarCount()); } IN_PROC_BROWSER_TEST_F(PolicyTest, URLBlacklist) { diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc index c8a42fe..b67a1a2 100644 --- a/chrome/browser/prerender/prerender_browsertest.cc +++ b/chrome/browser/prerender/prerender_browsertest.cc @@ -17,7 +17,6 @@ #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/favicon/favicon_tab_helper.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prerender/prerender_contents.h" #include "chrome/browser/prerender/prerender_handle.h" diff --git a/chrome/browser/sessions/better_session_restore_browsertest.cc b/chrome/browser/sessions/better_session_restore_browsertest.cc index d239b96..173970e 100644 --- a/chrome/browser/sessions/better_session_restore_browsertest.cc +++ b/chrome/browser/sessions/better_session_restore_browsertest.cc @@ -9,10 +9,10 @@ #include "base/path_service.h" #include "base/utf_string_conversions.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chromeos/enterprise_extension_observer.h" #include "chrome/browser/content_settings/cookie_settings.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/session_startup_pref.h" #include "chrome/browser/profiles/profile.h" @@ -577,13 +577,11 @@ class BetterSessionRestoreCrashTest : public BetterSessionRestoreTest { chrome::GetActiveWebContents(browser_after_restore); ASSERT_TRUE(web_contents); EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL()); - InfoBarTabHelper* info_bar_tab_helper = - InfoBarTabHelper::FromWebContents(web_contents); - EXPECT_EQ(1U, info_bar_tab_helper->GetInfoBarCount()); - ConfirmInfoBarDelegate* info_bar_delegate = - static_cast<ConfirmInfoBarDelegate*>( - info_bar_tab_helper->GetInfoBarDelegateAt(0)); - info_bar_delegate->Accept(); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); + EXPECT_EQ(1U, infobar_service->GetInfoBarCount()); + infobar_service->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate()-> + Accept(); // Session restore is done ascynhronously. base::RunLoop loop; diff --git a/chrome/browser/ssl/ssl_tab_helper.cc b/chrome/browser/ssl/ssl_tab_helper.cc index ba78aaa..8dca972 100644 --- a/chrome/browser/ssl/ssl_tab_helper.cc +++ b/chrome/browser/ssl/ssl_tab_helper.cc @@ -13,17 +13,19 @@ #include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/api/infobars/simple_alert_infobar_delegate.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/ssl_client_certificate_selector.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_switches.h" #include "content/public/browser/notification_details.h" +#include "content/public/browser/notification_observer.h" +#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_view.h" @@ -46,7 +48,7 @@ gfx::Image* GetCertIcon() { class SSLCertAddedInfoBarDelegate : public ConfirmInfoBarDelegate { public: - SSLCertAddedInfoBarDelegate(InfoBarTabHelper* infobar_helper, + SSLCertAddedInfoBarDelegate(InfoBarService* infobar_service, net::X509Certificate* cert); private: @@ -64,9 +66,9 @@ class SSLCertAddedInfoBarDelegate : public ConfirmInfoBarDelegate { }; SSLCertAddedInfoBarDelegate::SSLCertAddedInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, net::X509Certificate* cert) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), cert_(cert) { } @@ -130,7 +132,7 @@ class SSLTabHelper::SSLAddCertData const content::NotificationSource& source, const content::NotificationDetails& details); - InfoBarTabHelper* infobar_helper_; + InfoBarService* infobar_service_; InfoBarDelegate* infobar_delegate_; content::NotificationRegistrar registrar_; @@ -138,9 +140,9 @@ class SSLTabHelper::SSLAddCertData }; SSLTabHelper::SSLAddCertData::SSLAddCertData(content::WebContents* contents) - : infobar_helper_(InfoBarTabHelper::FromWebContents(contents)), + : infobar_service_(InfoBarService::FromWebContents(contents)), infobar_delegate_(NULL) { - content::Source<InfoBarTabHelper> source(infobar_helper_); + content::Source<InfoBarService> source(infobar_service_); registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, source); registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED, @@ -152,15 +154,15 @@ SSLTabHelper::SSLAddCertData::~SSLAddCertData() { void SSLTabHelper::SSLAddCertData::ShowInfoBar(InfoBarDelegate* delegate) { if (infobar_delegate_) - infobar_helper_->ReplaceInfoBar(infobar_delegate_, delegate); + infobar_service_->ReplaceInfoBar(infobar_delegate_, delegate); else - infobar_helper_->AddInfoBar(delegate); + infobar_service_->AddInfoBar(delegate); infobar_delegate_ = delegate; } void SSLTabHelper::SSLAddCertData::ShowErrorInfoBar(const string16& message) { ShowInfoBar(new SimpleAlertInfoBarDelegate( - infobar_helper_, GetCertIcon(), message, true)); + infobar_service_, GetCertIcon(), message, true)); } void SSLTabHelper::SSLAddCertData::Observe( @@ -216,10 +218,10 @@ void SSLTabHelper::OnAddClientCertificateSuccess( scoped_refptr<SSLAddCertHandler> handler) { SSLAddCertData* add_cert_data = GetAddCertData(handler); // Display an infobar to inform the user. - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(web_contents_); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents_); add_cert_data->ShowInfoBar(new SSLCertAddedInfoBarDelegate( - infobar_tab_helper, handler->cert())); + infobar_service, handler->cert())); } void SSLTabHelper::OnAddClientCertificateError( diff --git a/chrome/browser/task_manager/task_manager_browsertest.cc b/chrome/browser/task_manager/task_manager_browsertest.cc index 992f0d3..3bdc277 100644 --- a/chrome/browser/task_manager/task_manager_browsertest.cc +++ b/chrome/browser/task_manager/task_manager_browsertest.cc @@ -8,13 +8,13 @@ #include "base/stringprintf.h" #include "base/utf_string_conversions.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/background/background_contents_service.h" #include "chrome/browser/background/background_contents_service_factory.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/notifications/desktop_notification_service.h" #include "chrome/browser/notifications/notification.h" #include "chrome/browser/notifications/notification_test_util.h" @@ -524,10 +524,10 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, // Reload the extension using the "crashed extension" infobar while the task // manager is still visible. Make sure we don't crash and the extension // gets reloaded and noticed in the task manager. - InfoBarTabHelper* infobar_helper = InfoBarTabHelper::FromWebContents( + InfoBarService* infobar_service = InfoBarService::FromWebContents( chrome::GetActiveWebContents(browser())); - ASSERT_EQ(1U, infobar_helper->GetInfoBarCount()); - ConfirmInfoBarDelegate* delegate = infobar_helper-> + ASSERT_EQ(1U, infobar_service->GetInfoBarCount()); + ConfirmInfoBarDelegate* delegate = infobar_service-> GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(delegate); delegate->Accept(); diff --git a/chrome/browser/translate/options_menu_model.cc b/chrome/browser/translate/options_menu_model.cc index 8740f29..e00d8ef 100644 --- a/chrome/browser/translate/options_menu_model.cc +++ b/chrome/browser/translate/options_menu_model.cc @@ -6,7 +6,7 @@ #include "base/metrics/histogram.h" #include "chrome/app/chrome_command_ids.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/translate/translate_infobar_delegate.h" #include "chrome/common/url_constants.h" diff --git a/chrome/browser/translate/translate_infobar_delegate.cc b/chrome/browser/translate/translate_infobar_delegate.cc index 753f5fc..8f87ee9 100644 --- a/chrome/browser/translate/translate_infobar_delegate.cc +++ b/chrome/browser/translate/translate_infobar_delegate.cc @@ -7,8 +7,8 @@ #include <algorithm> #include "base/metrics/histogram.h" +#include "chrome/browser/api/infobars/infobar_service.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_manager.h" #include "chrome/browser/translate/translate_tab_helper.h" @@ -28,7 +28,7 @@ const size_t TranslateInfoBarDelegate::kNoIndex = static_cast<size_t>(-1); // static TranslateInfoBarDelegate* TranslateInfoBarDelegate::CreateDelegate( Type type, - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, PrefService* prefs, const std::string& original_language, const std::string& target_language) { @@ -44,7 +44,7 @@ TranslateInfoBarDelegate* TranslateInfoBarDelegate::CreateDelegate( TranslateInfoBarDelegate* delegate = new TranslateInfoBarDelegate(type, TranslateErrors::NONE, - infobar_helper, + infobar_service, prefs, original_language, target_language); @@ -54,13 +54,13 @@ TranslateInfoBarDelegate* TranslateInfoBarDelegate::CreateDelegate( TranslateInfoBarDelegate* TranslateInfoBarDelegate::CreateErrorDelegate( TranslateErrors::Type error, - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, PrefService* prefs, const std::string& original_language, const std::string& target_language) { return new TranslateInfoBarDelegate(TRANSLATION_ERROR, error, - infobar_helper, + infobar_service, prefs, original_language, target_language); @@ -281,11 +281,11 @@ void TranslateInfoBarDelegate::GetAfterTranslateStrings( TranslateInfoBarDelegate::TranslateInfoBarDelegate( Type type, TranslateErrors::Type error, - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, PrefService* prefs, const std::string& original_language, const std::string& target_language) - : InfoBarDelegate(infobar_helper), + : InfoBarDelegate(infobar_service), type_(type), background_animation_(NONE), original_language_index_(kNoIndex), diff --git a/chrome/browser/translate/translate_infobar_delegate.h b/chrome/browser/translate/translate_infobar_delegate.h index 8444d54..72db810 100644 --- a/chrome/browser/translate/translate_infobar_delegate.h +++ b/chrome/browser/translate/translate_infobar_delegate.h @@ -16,7 +16,6 @@ #include "chrome/common/chrome_constants.h" #include "chrome/common/translate_errors.h" -class InfoBarTabHelper; class PrefService; class TranslateInfoBarDelegate : public InfoBarDelegate { @@ -46,7 +45,7 @@ class TranslateInfoBarDelegate : public InfoBarDelegate { // |originalLanguage| == kUnknownLanguageCode. static TranslateInfoBarDelegate* CreateDelegate( Type infobar_type, - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, PrefService* prefs, const std::string& original_language, const std::string& target_language); @@ -54,7 +53,7 @@ class TranslateInfoBarDelegate : public InfoBarDelegate { // Factory method to create an error translate infobar. static TranslateInfoBarDelegate* CreateErrorDelegate( TranslateErrors::Type error_type, - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, PrefService* prefs, const std::string& original_language, const std::string& target_language); @@ -169,7 +168,7 @@ class TranslateInfoBarDelegate : public InfoBarDelegate { // For testing. TranslateInfoBarDelegate(Type infobar_type, TranslateErrors::Type error, - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, PrefService* prefs, const std::string& original_language, const std::string& target_language); @@ -179,7 +178,7 @@ class TranslateInfoBarDelegate : public InfoBarDelegate { typedef std::pair<std::string, string16> LanguageNamePair; // InfoBarDelegate: - virtual InfoBar* CreateInfoBar(InfoBarService* infobar_helper) OVERRIDE; + virtual InfoBar* CreateInfoBar(InfoBarService* infobar_service) OVERRIDE; virtual void InfoBarDismissed() OVERRIDE; virtual gfx::Image* GetIcon() const OVERRIDE; virtual InfoBarDelegate::Type GetInfoBarType() const OVERRIDE; diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc index 5fec694..794507a 100644 --- a/chrome/browser/translate/translate_manager.cc +++ b/chrome/browser/translate/translate_manager.cc @@ -15,8 +15,8 @@ #include "base/string_util.h" #include "base/stringprintf.h" #include "base/values.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tab_contents/language_state.h" @@ -465,13 +465,13 @@ void TranslateManager::OnURLFetchComplete(const net::URLFetcher* source) { if (error) { Profile* profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); ShowInfoBar( web_contents, TranslateInfoBarDelegate::CreateErrorDelegate( TranslateErrors::NETWORK, - infobar_helper, + infobar_service, profile->GetPrefs(), request.source_lang, request.target_lang)); @@ -592,12 +592,12 @@ void TranslateManager::InitiateTranslation(WebContents* web_contents, return; } - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); // Prompts the user if he/she wants the page translated. - infobar_helper->AddInfoBar( + infobar_service->AddInfoBar( TranslateInfoBarDelegate::CreateDelegate( - TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar_helper, + TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar_service, profile->GetPrefs(), language_code, target_lang)); } @@ -628,10 +628,10 @@ void TranslateManager::TranslatePage(WebContents* web_contents, Profile* profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); ShowInfoBar(web_contents, TranslateInfoBarDelegate::CreateDelegate( - TranslateInfoBarDelegate::TRANSLATING, infobar_helper, + TranslateInfoBarDelegate::TRANSLATING, infobar_service, profile->GetPrefs(), source_lang, target_lang)); if (!translate_script_.empty()) { @@ -721,8 +721,8 @@ void TranslateManager::DoTranslatePage(WebContents* web_contents, void TranslateManager::PageTranslated(WebContents* web_contents, PageTranslatedDetails* details) { - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); Profile* profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); PrefService* prefs = profile->GetPrefs(); @@ -732,7 +732,7 @@ void TranslateManager::PageTranslated(WebContents* web_contents, if (details->error_type != TranslateErrors::NONE) { infobar = TranslateInfoBarDelegate::CreateErrorDelegate( details->error_type, - infobar_helper, + infobar_service, prefs, details->source_language, details->target_language); @@ -742,11 +742,11 @@ void TranslateManager::PageTranslated(WebContents* web_contents, // language. UMA_HISTOGRAM_COUNTS("Translate.ServerReportedUnsupportedLanguage", 1); infobar = TranslateInfoBarDelegate::CreateErrorDelegate( - TranslateErrors::UNSUPPORTED_LANGUAGE, infobar_helper, + TranslateErrors::UNSUPPORTED_LANGUAGE, infobar_service, prefs, details->source_language, details->target_language); } else { infobar = TranslateInfoBarDelegate::CreateDelegate( - TranslateInfoBarDelegate::AFTER_TRANSLATE, infobar_helper, + TranslateInfoBarDelegate::AFTER_TRANSLATE, infobar_service, prefs, details->source_language, details->target_language); } ShowInfoBar(web_contents, infobar); @@ -874,15 +874,15 @@ void TranslateManager::ShowInfoBar(content::WebContents* web_contents, TranslateInfoBarDelegate* old_infobar = GetTranslateInfoBarDelegate(web_contents); infobar->UpdateBackgroundAnimation(old_infobar); - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents); - if (!infobar_helper) + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); + if (!infobar_service) return; if (old_infobar) { // There already is a translate infobar, simply replace it. - infobar_helper->ReplaceInfoBar(old_infobar, infobar); + infobar_service->ReplaceInfoBar(old_infobar, infobar); } else { - infobar_helper->AddInfoBar(infobar); + infobar_service->AddInfoBar(infobar); } } @@ -914,14 +914,14 @@ std::string TranslateManager::GetTargetLanguage(PrefService* prefs) { // static TranslateInfoBarDelegate* TranslateManager::GetTranslateInfoBarDelegate( WebContents* web_contents) { - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents); - if (!infobar_helper) + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); + if (!infobar_service) return NULL; - for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); ++i) { + for (size_t i = 0; i < infobar_service->GetInfoBarCount(); ++i) { TranslateInfoBarDelegate* delegate = - infobar_helper->GetInfoBarDelegateAt(i)-> + infobar_service->GetInfoBarDelegateAt(i)-> AsTranslateInfoBarDelegate(); if (delegate) return delegate; diff --git a/chrome/browser/translate/translate_manager_browsertest.cc b/chrome/browser/translate/translate_manager_browsertest.cc index 51c74ba..21e02cd 100644 --- a/chrome/browser/translate/translate_manager_browsertest.cc +++ b/chrome/browser/translate/translate_manager_browsertest.cc @@ -14,9 +14,9 @@ #include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/app/chrome_command_ids.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/extensions/test_extension_system.h" #include "chrome/browser/infobars/infobar.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/session_startup_pref.h" #include "chrome/browser/tab_contents/render_view_context_menu.h" @@ -137,15 +137,15 @@ class TranslateManagerTest : public ChromeRenderViewHostTestHarness, return true; } - InfoBarTabHelper* infobar_tab_helper() { - return InfoBarTabHelper::FromWebContents(web_contents()); + InfoBarService* infobar_service() { + return InfoBarService::FromWebContents(web_contents()); } // Returns the translate infobar if there is 1 infobar and it is a translate // infobar. TranslateInfoBarDelegate* GetTranslateInfoBar() { - return (infobar_tab_helper()->GetInfoBarCount() == 1) ? - infobar_tab_helper()->GetInfoBarDelegateAt(0)-> + return (infobar_service()->GetInfoBarCount() == 1) ? + infobar_service()->GetInfoBarDelegateAt(0)-> AsTranslateInfoBarDelegate() : NULL; } @@ -156,7 +156,7 @@ class TranslateManagerTest : public ChromeRenderViewHostTestHarness, if (!infobar) return false; infobar->InfoBarDismissed(); // Simulates closing the infobar. - infobar_tab_helper()->RemoveInfoBar(infobar); + infobar_service()->RemoveInfoBar(infobar); return true; } @@ -189,7 +189,7 @@ class TranslateManagerTest : public ChromeRenderViewHostTestHarness, if (!infobar) return false; infobar->TranslationDeclined(); - infobar_tab_helper()->RemoveInfoBar(infobar); + infobar_service()->RemoveInfoBar(infobar); return true; } @@ -234,12 +234,12 @@ class TranslateManagerTest : public ChromeRenderViewHostTestHarness, set_translate_script_expiration_delay(60 * 60 * 1000); ChromeRenderViewHostTestHarness::SetUp(); - InfoBarTabHelper::CreateForWebContents(web_contents()); + InfoBarService::CreateForWebContents(web_contents()); TranslateTabHelper::CreateForWebContents(web_contents()); notification_registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - content::Source<InfoBarTabHelper>(infobar_tab_helper())); + content::Source<InfoBarService>(infobar_service())); } virtual void TearDown() { @@ -247,7 +247,7 @@ class TranslateManagerTest : public ChromeRenderViewHostTestHarness, notification_registrar_.Remove(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - content::Source<InfoBarTabHelper>(infobar_tab_helper())); + content::Source<InfoBarService>(infobar_service())); ChromeRenderViewHostTestHarness::TearDown(); WebKit::shutdown(); @@ -760,18 +760,18 @@ TEST_F(TranslateManagerTest, MultipleOnPageContents) { // Simulate clicking 'Nope' (don't translate). EXPECT_TRUE(DenyTranslation()); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); // Send a new PageContents, we should not show an infobar. SimulateOnTranslateLanguageDetermined("fr", true); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); // Do the same steps but simulate closing the infobar this time. SimulateNavigation(GURL("http://www.youtube.fr"), "fr", true); EXPECT_TRUE(CloseTranslateInfoBar()); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); SimulateOnTranslateLanguageDetermined("fr", true); - EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0U, infobar_service()->GetInfoBarCount()); } // Test that reloading the page brings back the infobar. diff --git a/chrome/browser/ui/auto_login_info_bar_delegate.cc b/chrome/browser/ui/auto_login_info_bar_delegate.cc index 10a3106..c875001 100644 --- a/chrome/browser/ui/auto_login_info_bar_delegate.cc +++ b/chrome/browser/ui/auto_login_info_bar_delegate.cc @@ -10,9 +10,9 @@ #include "base/metrics/histogram.h" #include "base/utf_string_conversions.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/google/google_util.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/signin/ubertoken_fetcher.h" @@ -166,7 +166,7 @@ AutoLoginInfoBarDelegate::Params::Params() {} AutoLoginInfoBarDelegate::Params::~Params() {} AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate( - InfoBarTabHelper* owner, + InfoBarService* owner, const Params& params) : ConfirmInfoBarDelegate(owner), params_(params), @@ -245,7 +245,7 @@ void AutoLoginInfoBarDelegate::Observe(int type, const NotificationSource& source, const NotificationDetails& details) { DCHECK_EQ(chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, type); - // owner() can be NULL when InfoBarTabHelper removes us. See + // owner() can be NULL when InfoBarService removes us. See // |InfoBarDelegate::clear_owner|. if (owner()) owner()->RemoveInfoBar(this); diff --git a/chrome/browser/ui/auto_login_info_bar_delegate.h b/chrome/browser/ui/auto_login_info_bar_delegate.h index 12ea339..1cb3f2d 100644 --- a/chrome/browser/ui/auto_login_info_bar_delegate.h +++ b/chrome/browser/ui/auto_login_info_bar_delegate.h @@ -9,7 +9,6 @@ #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" -class InfoBarTabHelper; class PrefService; class TokenService; @@ -41,7 +40,7 @@ class AutoLoginInfoBarDelegate : public ConfirmInfoBarDelegate, std::string username; }; - AutoLoginInfoBarDelegate(InfoBarTabHelper* owner, const Params& params); + AutoLoginInfoBarDelegate(InfoBarService* owner, const Params& params); virtual ~AutoLoginInfoBarDelegate(); // ConfirmInfoBarDelegate: diff --git a/chrome/browser/ui/auto_login_prompter.cc b/chrome/browser/ui/auto_login_prompter.cc index 1efe7e1..ac107d2 100644 --- a/chrome/browser/ui/auto_login_prompter.cc +++ b/chrome/browser/ui/auto_login_prompter.cc @@ -8,8 +8,8 @@ #include "base/command_line.h" #include "base/logging.h" #include "base/string_split.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/google/google_url_tracker.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/signin/signin_manager.h" @@ -175,12 +175,12 @@ void AutoLoginPrompter::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { if (type == content::NOTIFICATION_LOAD_STOP) { - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents_); - // |infobar_helper| is NULL for WebContents hosted in WebDialog. - if (infobar_helper) { - infobar_helper->AddInfoBar( - new AutoLoginInfoBarDelegate(infobar_helper, params_)); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents_); + // |infobar_service| is NULL for WebContents hosted in WebDialog. + if (infobar_service) { + infobar_service->AddInfoBar( + new AutoLoginInfoBarDelegate(infobar_service, params_)); } } // Either we couldn't add the infobar, we added the infobar, or the tab diff --git a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc b/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc index ae430c4..95584f1 100644 --- a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc +++ b/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc @@ -5,8 +5,8 @@ #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" #include "base/logging.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/autofill/password_generator.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/password_manager/password_manager.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" @@ -43,7 +43,7 @@ Profile* TabAutofillManagerDelegate::GetOriginalProfile() const { } InfoBarService* TabAutofillManagerDelegate::GetInfoBarService() { - return InfoBarTabHelper::FromWebContents(web_contents_); + return InfoBarService::FromWebContents(web_contents_); } PrefServiceBase* TabAutofillManagerDelegate::GetPrefs() { diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index c937ac7..0801972 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -27,6 +27,7 @@ #include "base/time.h" #include "base/utf_string_conversions.h" #include "chrome/app/chrome_command_ids.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/api/infobars/simple_alert_infobar_delegate.h" #include "chrome/browser/autofill/personal_data_manager_factory.h" #include "chrome/browser/background/background_contents_service.h" @@ -59,7 +60,6 @@ #include "chrome/browser/file_select_helper.h" #include "chrome/browser/first_run/first_run.h" #include "chrome/browser/google/google_url_tracker.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/intents/device_attached_intent_source.h" #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" #include "chrome/browser/intents/web_intents_reporting.h" @@ -880,13 +880,13 @@ bool Browser::RunUnloadEventsHelper(WebContents* contents) { // static void Browser::JSOutOfMemoryHelper(WebContents* web_contents) { - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents); - if (!infobar_helper) + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); + if (!infobar_service) return; - infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( - infobar_helper, + infobar_service->AddInfoBar(new SimpleAlertInfoBarDelegate( + infobar_service, NULL, l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), true)); @@ -931,27 +931,27 @@ void Browser::RegisterProtocolHandlerHelper(WebContents* web_contents, content::RecordAction( UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown")); - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); RegisterProtocolHandlerInfoBarDelegate* rph_delegate = - new RegisterProtocolHandlerInfoBarDelegate(infobar_helper, + new RegisterProtocolHandlerInfoBarDelegate(infobar_service, registry, handler); - for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); i++) { - InfoBarDelegate* delegate = infobar_helper->GetInfoBarDelegateAt(i); + for (size_t i = 0; i < infobar_service->GetInfoBarCount(); i++) { + InfoBarDelegate* delegate = infobar_service->GetInfoBarDelegateAt(i); RegisterProtocolHandlerInfoBarDelegate* cast_delegate = delegate->AsRegisterProtocolHandlerInfoBarDelegate(); if (cast_delegate != NULL && cast_delegate->IsReplacedBy(rph_delegate)) { - infobar_helper->ReplaceInfoBar(cast_delegate, rph_delegate); + infobar_service->ReplaceInfoBar(cast_delegate, rph_delegate); rph_delegate = NULL; break; } } if (rph_delegate != NULL) - infobar_helper->AddInfoBar(rph_delegate); + infobar_service->AddInfoBar(rph_delegate); } // static @@ -985,22 +985,22 @@ void Browser::RequestMediaAccessPermissionHelper( request, callback)); if (!controller->DismissInfoBarAndTakeActionOnSettings()) { - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); InfoBarDelegate* old_infobar = NULL; - for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); ++i) { - old_infobar = infobar_helper->GetInfoBarDelegateAt(i)-> + for (size_t i = 0; i < infobar_service->GetInfoBarCount(); ++i) { + old_infobar = infobar_service->GetInfoBarDelegateAt(i)-> AsMediaStreamInfoBarDelegate(); if (old_infobar) break; } InfoBarDelegate* infobar = - new MediaStreamInfoBarDelegate(infobar_helper, controller.release()); + new MediaStreamInfoBarDelegate(infobar_service, controller.release()); if (old_infobar) - infobar_helper->ReplaceInfoBar(old_infobar, infobar); + infobar_service->ReplaceInfoBar(old_infobar, infobar); else - infobar_helper->AddInfoBar(infobar); + infobar_service->AddInfoBar(infobar); } } @@ -1606,10 +1606,10 @@ void Browser::RendererResponsive(WebContents* source) { } void Browser::WorkerCrashed(WebContents* source) { - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(source); - infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( - infobar_helper, + InfoBarService* infobar_service = + InfoBarService::FromWebContents(source); + infobar_service->AddInfoBar(new SimpleAlertInfoBarDelegate( + infobar_service, NULL, l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT), true)); diff --git a/chrome/browser/ui/browser_tab_contents.cc b/chrome/browser/ui/browser_tab_contents.cc index 48e9c36..54da082 100644 --- a/chrome/browser/ui/browser_tab_contents.cc +++ b/chrome/browser/ui/browser_tab_contents.cc @@ -5,6 +5,7 @@ #include "chrome/browser/ui/browser_tab_contents.h" #include "base/command_line.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/autofill/autofill_external_delegate.h" #include "chrome/browser/autofill/autofill_manager.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" @@ -13,7 +14,6 @@ #include "chrome/browser/external_protocol/external_protocol_observer.h" #include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/history/history_tab_helper.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h" #include "chrome/browser/net/load_time_stats.h" #include "chrome/browser/net/net_error_tab_helper.h" @@ -130,7 +130,7 @@ void BrowserTabContents::AttachTabHelpers(WebContents* web_contents) { FindTabHelper::CreateForWebContents(web_contents); HistoryTabHelper::CreateForWebContents(web_contents); HungPluginTabHelper::CreateForWebContents(web_contents); - InfoBarTabHelper::CreateForWebContents(web_contents); + InfoBarService::CreateForWebContents(web_contents); ManagedModeNavigationObserver::CreateForWebContents(web_contents); NavigationMetricsRecorder::CreateForWebContents(web_contents); if (OmniboxSearchHint::IsEnabled(profile)) diff --git a/chrome/browser/ui/chrome_select_file_policy.cc b/chrome/browser/ui/chrome_select_file_policy.cc index d5399d9..4fe9337 100644 --- a/chrome/browser/ui/chrome_select_file_policy.cc +++ b/chrome/browser/ui/chrome_select_file_policy.cc @@ -7,9 +7,9 @@ #include "base/bind.h" #include "base/callback.h" #include "base/logging.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/api/infobars/simple_alert_infobar_delegate.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/common/pref_names.h" #include "grit/generated_resources.h" @@ -29,11 +29,11 @@ bool ChromeSelectFilePolicy::CanOpenSelectFileDialog() { void ChromeSelectFilePolicy::SelectFileDenied() { // Show the InfoBar saying that file-selection dialogs are disabled. if (source_contents_) { - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(source_contents_); - DCHECK(infobar_helper); - infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( - infobar_helper, + InfoBarService* infobar_service = + InfoBarService::FromWebContents(source_contents_); + DCHECK(infobar_service); + infobar_service->AddInfoBar(new SimpleAlertInfoBarDelegate( + infobar_service, NULL, l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR), true)); 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 eeeada7..684c9c4 100644 --- a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm +++ b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm @@ -10,6 +10,7 @@ #import "base/mac/mac_util.h" #include "base/message_loop.h" #include "base/sys_string_conversions.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" #include "chrome/browser/browsing_data/browsing_data_database_helper.h" @@ -20,7 +21,6 @@ #include "chrome/browser/content_settings/cookie_settings.h" #include "chrome/browser/content_settings/local_shared_objects_container.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser_dialogs.h" @@ -214,10 +214,10 @@ void CollectedCookiesMac::OnConstrainedWindowClosed( - (void)windowWillClose:(NSNotification*)notif { if (contentSettingsChanged_) { - InfoBarTabHelper* infobarTabHelper = - InfoBarTabHelper::FromWebContents(webContents_); - infobarTabHelper->AddInfoBar( - new CollectedCookiesInfoBarDelegate(infobarTabHelper)); + InfoBarService* infobarService = + InfoBarService::FromWebContents(webContents_); + infobarService->AddInfoBar( + new CollectedCookiesInfoBarDelegate(infobarService)); } [allowedOutlineView_ setDelegate:nil]; [blockedOutlineView_ setDelegate:nil]; diff --git a/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm b/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm index 5b0a89c..1889bb8 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm @@ -6,8 +6,8 @@ #include "base/mac/bundle_locations.h" #include "base/mac/mac_util.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/infobars/infobar.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #import "chrome/browser/ui/cocoa/animatable_view.h" #import "chrome/browser/ui/cocoa/browser_window_controller.h" #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" @@ -31,12 +31,12 @@ class InfoBarNotificationObserver : public content::NotificationObserver { void Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - InfoBarTabHelper* infobar_helper = - content::Source<InfoBarTabHelper>(source).ptr(); + InfoBarService* infobar_service = + content::Source<InfoBarService>(source).ptr(); switch (type) { case chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED: [controller_ addInfoBar:content::Details<InfoBarAddedDetails>(details)-> - CreateInfoBar(infobar_helper) + CreateInfoBar(infobar_service) animate:YES]; break; @@ -55,7 +55,7 @@ class InfoBarNotificationObserver : public content::NotificationObserver { [controller_ closeInfoBarsForDelegate:replaced_details->first animate:NO]; [controller_ addInfoBar:replaced_details->second-> - CreateInfoBar(infobar_helper) + CreateInfoBar(infobar_service) animate:NO]; break; } @@ -141,15 +141,15 @@ class InfoBarNotificationObserver : public content::NotificationObserver { currentWebContents_ = contents; if (currentWebContents_) { - InfoBarTabHelper* infobarTabHelper = - InfoBarTabHelper::FromWebContents(currentWebContents_); - for (size_t i = 0; i < infobarTabHelper->GetInfoBarCount(); ++i) { - InfoBar* infobar = infobarTabHelper-> - GetInfoBarDelegateAt(i)->CreateInfoBar(infobarTabHelper); + InfoBarService* infobarService = + InfoBarService::FromWebContents(currentWebContents_); + for (size_t i = 0; i < infobarService->GetInfoBarCount(); ++i) { + InfoBar* infobar = infobarService-> + GetInfoBarDelegateAt(i)->CreateInfoBar(infobarService); [self addInfoBar:infobar animate:NO]; } - content::Source<InfoBarTabHelper> source(infobarTabHelper); + content::Source<InfoBarService> source(infobarService); registrar_.Add(infoBarObserver_.get(), chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, source); registrar_.Add(infoBarObserver_.get(), diff --git a/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm b/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm index dac2094..7af27a8 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm @@ -8,7 +8,7 @@ #include "base/string_util.h" #include "base/sys_string_conversions.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h" @@ -101,13 +101,13 @@ class LinkInfoBarControllerTest : public CocoaProfileTest, CocoaProfileTest::SetUp(); web_contents_.reset( WebContents::Create(WebContents::CreateParams(profile()))); - InfoBarTabHelper::CreateForWebContents(web_contents_.get()); + InfoBarService::CreateForWebContents(web_contents_.get()); - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(web_contents_.get()); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents_.get()); delegate_ = new MockLinkInfoBarDelegate(this); controller_.reset([[TestLinkInfoBarController alloc] - initWithDelegate:delegate_ owner:infobar_tab_helper]); + initWithDelegate:delegate_ owner:infobar_service]); container_.reset( [[InfoBarContainerTest alloc] initWithController:controller_]); [controller_ setContainerController:container_]; @@ -146,13 +146,13 @@ class ConfirmInfoBarControllerTest : public CocoaProfileTest, CocoaProfileTest::SetUp(); web_contents_.reset( WebContents::Create(WebContents::CreateParams(profile()))); - InfoBarTabHelper::CreateForWebContents(web_contents_.get()); + InfoBarService::CreateForWebContents(web_contents_.get()); - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(web_contents_.get()); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents_.get()); delegate_ = new MockConfirmInfoBarDelegate(this); controller_.reset([[TestConfirmInfoBarController alloc] - initWithDelegate:delegate_ owner:infobar_tab_helper]); + initWithDelegate:delegate_ owner:infobar_service]); container_.reset( [[InfoBarContainerTest alloc] initWithController:controller_]); [controller_ setContainerController:container_]; diff --git a/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm b/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm index 8755e8c..591353c 100644 --- a/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm +++ b/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm @@ -8,7 +8,7 @@ #import "base/string_util.h" #include "base/utf_string_conversions.h" #import "chrome/app/chrome_command_ids.h" // For translate menu command ids. -#include "chrome/browser/infobars/infobar_tab_helper.h" +#include "chrome/browser/api/infobars/infobar_service.h" #import "chrome/browser/translate/translate_infobar_delegate.h" #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" #import "chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.h" @@ -36,9 +36,9 @@ class MockTranslateInfoBarDelegate : public TranslateInfoBarDelegate { public: MockTranslateInfoBarDelegate(TranslateInfoBarDelegate::Type type, TranslateErrors::Type error, - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, PrefService* prefs) - : TranslateInfoBarDelegate(type, error, infobar_helper, prefs, + : TranslateInfoBarDelegate(type, error, infobar_service, prefs, "en", "es") { // Start out in the "Before Translate" state. type_ = type; @@ -66,7 +66,7 @@ class TranslationInfoBarTest : public CocoaProfileTest { CocoaProfileTest::SetUp(); web_contents_.reset( WebContents::Create(WebContents::CreateParams(profile()))); - InfoBarTabHelper::CreateForWebContents(web_contents_.get()); + InfoBarService::CreateForWebContents(web_contents_.get()); CreateInfoBar(); } @@ -78,19 +78,19 @@ class TranslationInfoBarTest : public CocoaProfileTest { TranslateErrors::Type error = TranslateErrors::NONE; if (type == TranslateInfoBarDelegate::TRANSLATION_ERROR) error = TranslateErrors::NETWORK; - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(web_contents_.get()); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents_.get()); Profile* profile = Profile::FromBrowserContext(web_contents_->GetBrowserContext()); infobar_delegate_.reset(new MockTranslateInfoBarDelegate( type, error, - infobar_tab_helper, + infobar_service, profile->GetPrefs())); [[infobar_controller_ view] removeFromSuperview]; scoped_ptr<InfoBar> infobar( static_cast<InfoBarDelegate*>(infobar_delegate_.get())-> - CreateInfoBar(infobar_tab_helper)); + CreateInfoBar(infobar_service)); infobar_controller_.reset( reinterpret_cast<TranslateInfoBarControllerBase*>( infobar->controller())); diff --git a/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm b/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm index 5d7672a..aa37c57 100644 --- a/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm +++ b/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm @@ -13,8 +13,8 @@ #include "base/memory/weak_ptr.h" #include "base/message_loop.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/first_run/first_run.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #import "chrome/browser/mac/keystone_glue.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" @@ -196,12 +196,12 @@ bool KeystonePromotionInfoBarDelegate::ShouldExpireInternal( // Only show if no other info bars are showing, because that's how the // default browser info bar works. if (webContents) { - InfoBarTabHelper* infobarTabHelper = - InfoBarTabHelper::FromWebContents(webContents); - if (infobarTabHelper->GetInfoBarCount() == 0) { - infobarTabHelper->AddInfoBar( + InfoBarService* infobarService = + InfoBarService::FromWebContents(webContents); + if (infobarService->GetInfoBarCount() == 0) { + infobarService->AddInfoBar( new KeystonePromotionInfoBarDelegate( - infobarTabHelper, + infobarService, Profile::FromBrowserContext( webContents->GetBrowserContext())->GetPrefs())); } diff --git a/chrome/browser/ui/cocoa/website_settings_bubble_controller.mm b/chrome/browser/ui/cocoa/website_settings_bubble_controller.mm index 0609f9f..2f038d6 100644 --- a/chrome/browser/ui/cocoa/website_settings_bubble_controller.mm +++ b/chrome/browser/ui/cocoa/website_settings_bubble_controller.mm @@ -10,8 +10,8 @@ #include "base/string_number_conversions.h" #include "base/sys_string_conversions.h" +#include "chrome/browser/api/infobars/infobar_service.h" #import "chrome/browser/certificate_viewer.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #import "chrome/browser/ui/browser_dialogs.h" #import "chrome/browser/ui/cocoa/browser_window_controller.h" #import "chrome/browser/ui/cocoa/flipped_view.h" @@ -1207,7 +1207,7 @@ void WebsiteSettingsUIBridge::Show(gfx::NativeWindow parent, bridge, profile, TabSpecificContentSettings::FromWebContents(web_contents), - InfoBarTabHelper::FromWebContents(web_contents), + InfoBarService::FromWebContents(web_contents), url, ssl, content::CertStore::GetInstance()); diff --git a/chrome/browser/ui/collected_cookies_infobar_delegate.cc b/chrome/browser/ui/collected_cookies_infobar_delegate.cc index 7da616c..53ac137 100644 --- a/chrome/browser/ui/collected_cookies_infobar_delegate.cc +++ b/chrome/browser/ui/collected_cookies_infobar_delegate.cc @@ -5,7 +5,7 @@ #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" #include "base/logging.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -13,8 +13,8 @@ #include "ui/base/resource/resource_bundle.h" CollectedCookiesInfoBarDelegate::CollectedCookiesInfoBarDelegate( - InfoBarTabHelper* infobar_helper) - : ConfirmInfoBarDelegate(infobar_helper) { + InfoBarService* infobar_service) + : ConfirmInfoBarDelegate(infobar_service) { } gfx::Image* CollectedCookiesInfoBarDelegate::GetIcon() const { diff --git a/chrome/browser/ui/collected_cookies_infobar_delegate.h b/chrome/browser/ui/collected_cookies_infobar_delegate.h index d8ab851..fd97d75 100644 --- a/chrome/browser/ui/collected_cookies_infobar_delegate.h +++ b/chrome/browser/ui/collected_cookies_infobar_delegate.h @@ -7,7 +7,7 @@ #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" -class InfoBarTabHelper; +class InfoBarService; // This class configures an infobar shown when the collected cookies dialog // is closed and the settings for one or more cookies have been changed. The @@ -16,7 +16,7 @@ class InfoBarTabHelper; // the reload right from the infobar. class CollectedCookiesInfoBarDelegate : public ConfirmInfoBarDelegate { public: - explicit CollectedCookiesInfoBarDelegate(InfoBarTabHelper* infobar_helper); + explicit CollectedCookiesInfoBarDelegate(InfoBarService* infobar_service); private: // ConfirmInfoBarDelegate overrides. 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 6e3ef6d..075ca46 100644 --- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc @@ -5,13 +5,13 @@ #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/content_settings/content_settings_utils.h" #include "chrome/browser/content_settings/cookie_settings.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h" #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" #include "chrome/browser/favicon/favicon_tab_helper.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" @@ -379,10 +379,10 @@ ContentSettingCookiesBubbleModel::ContentSettingCookiesBubbleModel( ContentSettingCookiesBubbleModel::~ContentSettingCookiesBubbleModel() { if (settings_changed()) { - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents()); - infobar_helper->AddInfoBar( - new CollectedCookiesInfoBarDelegate(infobar_helper)); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents()); + infobar_service->AddInfoBar( + new CollectedCookiesInfoBarDelegate(infobar_service)); } } diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc index b19a4e5..a9b5ec4 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.cc +++ b/chrome/browser/ui/gtk/browser_window_gtk.cc @@ -25,10 +25,10 @@ #include "base/time.h" #include "base/utf_string_conversions.h" #include "chrome/app/chrome_command_ids.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/download/download_item_model.h" #include "chrome/browser/extensions/tab_helper.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/profiles/profile.h" @@ -1195,7 +1195,7 @@ void BrowserWindowGtk::TabDetachedAt(WebContents* contents, int index) { // chrome::GetActiveWebContents(browser_.get()) will return NULL or something // else. if (index == browser_->active_index()) { - infobar_container_->ChangeTabContents(NULL); + infobar_container_->ChangeInfoBarService(NULL); UpdateDevToolsForContents(NULL); } contents_container_->DetachTab(contents); @@ -1212,9 +1212,9 @@ void BrowserWindowGtk::ActiveTabChanged(WebContents* old_contents, // Update various elements that are interested in knowing the current // WebContents. UpdateDevToolsForContents(new_contents); - InfoBarTabHelper* new_infobar_tab_helper = - InfoBarTabHelper::FromWebContents(new_contents); - infobar_container_->ChangeTabContents(new_infobar_tab_helper); + InfoBarService* new_infobar_service = + InfoBarService::FromWebContents(new_contents); + infobar_container_->ChangeInfoBarService(new_infobar_service); contents_container_->SetTab(new_contents); // TODO(estade): after we manage browser activation, add a check to make sure diff --git a/chrome/browser/ui/gtk/collected_cookies_gtk.cc b/chrome/browser/ui/gtk/collected_cookies_gtk.cc index c2266e3..138dfed 100644 --- a/chrome/browser/ui/gtk/collected_cookies_gtk.cc +++ b/chrome/browser/ui/gtk/collected_cookies_gtk.cc @@ -5,6 +5,7 @@ #include "chrome/browser/ui/gtk/collected_cookies_gtk.h" #include <string> +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" #include "chrome/browser/browsing_data/browsing_data_database_helper.h" @@ -17,7 +18,6 @@ #include "chrome/browser/content_settings/cookie_settings.h" #include "chrome/browser/content_settings/local_shared_objects_container.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser_dialogs.h" @@ -460,10 +460,10 @@ void CollectedCookiesGtk::Observe(int type, void CollectedCookiesGtk::OnClose(GtkWidget* close_button) { if (status_changed_) { - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents_); - infobar_helper->AddInfoBar( - new CollectedCookiesInfoBarDelegate(infobar_helper)); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents_); + infobar_service->AddInfoBar( + new CollectedCookiesInfoBarDelegate(infobar_service)); } 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 aaa644f..097b3ec 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( - InfoBarTabHelper* owner, + InfoBarService* 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 131bab6..14cc270 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(InfoBarTabHelper* owner, + AfterTranslateInfoBar(InfoBarService* 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 35ae0cc..d32a7c6 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( - InfoBarTabHelper* owner, + InfoBarService* 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 398020d..c121fdc 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(InfoBarTabHelper* owner, + BeforeTranslateInfoBar(InfoBarService* 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 50537d3..5675c90 100644 --- a/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc @@ -7,7 +7,6 @@ #include <gtk/gtk.h> #include "base/utf_string_conversions.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/ui/gtk/event_utils.h" #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" #include "chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.h" @@ -17,12 +16,12 @@ // ConfirmInfoBarDelegate ------------------------------------------------------ InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { - return new ConfirmInfoBarGtk(static_cast<InfoBarTabHelper*>(owner), this); + return new ConfirmInfoBarGtk(owner, this); } // ConfirmInfoBarGtk ----------------------------------------------------------- -ConfirmInfoBarGtk::ConfirmInfoBarGtk(InfoBarTabHelper* owner, +ConfirmInfoBarGtk::ConfirmInfoBarGtk(InfoBarService* 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 f5d5d77..7638471 100644 --- a/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.h +++ b/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.h @@ -18,7 +18,7 @@ typedef struct _GtkWidget GtkWidget; // "Would you like to do X? [Yes] [No] _Learn More_ [x]" class ConfirmInfoBarGtk : public InfoBarGtk { public: - ConfirmInfoBarGtk(InfoBarTabHelper* owner, + ConfirmInfoBarGtk(InfoBarService* 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 aded0c7..4a188a9 100644 --- a/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc @@ -7,7 +7,6 @@ #include "base/debug/trace_event.h" #include "chrome/browser/extensions/extension_context_menu_model.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/platform_util.h" #include "chrome/browser/ui/gtk/browser_window_gtk.h" #include "chrome/browser/ui/gtk/custom_button.h" @@ -27,7 +26,7 @@ #include "ui/gfx/gtk_util.h" #include "ui/gfx/image/image.h" -ExtensionInfoBarGtk::ExtensionInfoBarGtk(InfoBarTabHelper* owner, +ExtensionInfoBarGtk::ExtensionInfoBarGtk(InfoBarService* owner, ExtensionInfoBarDelegate* delegate) : InfoBarGtk(owner, delegate), tracker_(this), @@ -204,5 +203,5 @@ gboolean ExtensionInfoBarGtk::OnExpose(GtkWidget* sender, } InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { - return new ExtensionInfoBarGtk(static_cast<InfoBarTabHelper*>(owner), this); + 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 6c0c230..9f7a5ab 100644 --- a/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.h +++ b/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.h @@ -21,7 +21,7 @@ class ExtensionInfoBarGtk : public InfoBarGtk, public ImageLoadingTracker::Observer, public MenuGtk::Delegate { public: - ExtensionInfoBarGtk(InfoBarTabHelper* owner, + ExtensionInfoBarGtk(InfoBarService* owner, ExtensionInfoBarDelegate* delegate); virtual ~ExtensionInfoBarGtk(); diff --git a/chrome/browser/ui/gtk/infobars/infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/infobar_gtk.cc index 9a63970..a7c57e8 100644 --- a/chrome/browser/ui/gtk/infobars/infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/infobar_gtk.cc @@ -6,7 +6,7 @@ #include "base/debug/trace_event.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/gtk/browser_window_gtk.h" #include "chrome/browser/ui/gtk/custom_button.h" @@ -49,7 +49,7 @@ const int InfoBar::kDefaultBarTargetHeight = 36; // static const int InfoBarGtk::kEndOfLabelSpacing = 6; -InfoBarGtk::InfoBarGtk(InfoBarTabHelper* owner, InfoBarDelegate* delegate) +InfoBarGtk::InfoBarGtk(InfoBarService* owner, InfoBarDelegate* delegate) : InfoBar(owner, delegate), theme_service_(GtkThemeService::GetFrom(Profile::FromBrowserContext( owner->GetWebContents()->GetBrowserContext()))), diff --git a/chrome/browser/ui/gtk/infobars/infobar_gtk.h b/chrome/browser/ui/gtk/infobars/infobar_gtk.h index bb0afba..96dad53 100644 --- a/chrome/browser/ui/gtk/infobars/infobar_gtk.h +++ b/chrome/browser/ui/gtk/infobars/infobar_gtk.h @@ -29,7 +29,7 @@ class MenuModel; class InfoBarGtk : public InfoBar, public content::NotificationObserver { public: - InfoBarGtk(InfoBarTabHelper* owner, InfoBarDelegate* delegate); + InfoBarGtk(InfoBarService* 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 577ee7f..dc7a8bc 100644 --- a/chrome/browser/ui/gtk/infobars/link_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/link_infobar_gtk.cc @@ -5,18 +5,17 @@ #include "chrome/browser/ui/gtk/infobars/link_infobar_gtk.h" #include "chrome/browser/api/infobars/link_infobar_delegate.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/ui/gtk/event_utils.h" // LinkInfoBarDelegate --------------------------------------------------------- InfoBar* LinkInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { - return new LinkInfoBarGtk(static_cast<InfoBarTabHelper*>(owner), this); + return new LinkInfoBarGtk(owner, this); } // LinkInfoBarGtk -------------------------------------------------------------- -LinkInfoBarGtk::LinkInfoBarGtk(InfoBarTabHelper* owner, +LinkInfoBarGtk::LinkInfoBarGtk(InfoBarService* 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 87bc7a6..34ae403 100644 --- a/chrome/browser/ui/gtk/infobars/link_infobar_gtk.h +++ b/chrome/browser/ui/gtk/infobars/link_infobar_gtk.h @@ -10,12 +10,11 @@ #include "ui/base/gtk/gtk_signal.h" class LinkInfoBarDelegate; -class InfoBarTabHelper; // An infobar that shows a string with an embedded link. class LinkInfoBarGtk : public InfoBarGtk { public: - LinkInfoBarGtk(InfoBarTabHelper* owner, LinkInfoBarDelegate* delegate); + LinkInfoBarGtk(InfoBarService* 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 736edf8..52b979d 100644 --- a/chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.cc @@ -5,7 +5,6 @@ #include "chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/translate/options_menu_model.h" #include "chrome/browser/translate/translate_infobar_delegate.h" #include "chrome/browser/ui/gtk/gtk_util.h" @@ -32,7 +31,7 @@ enum { } // namespace -TranslateInfoBarBase::TranslateInfoBarBase(InfoBarTabHelper* owner, +TranslateInfoBarBase::TranslateInfoBarBase(InfoBarService* owner, TranslateInfoBarDelegate* delegate) : InfoBarGtk(owner, delegate), background_error_percent_(0) { @@ -199,18 +198,17 @@ void TranslateInfoBarBase::OnOptionsClicked(GtkWidget* sender) { // TranslateInfoBarDelegate specific method: InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { - InfoBarTabHelper* helper = static_cast<InfoBarTabHelper*>(owner); TranslateInfoBarBase* infobar = NULL; switch (type_) { case BEFORE_TRANSLATE: - infobar = new BeforeTranslateInfoBar(helper, this); + infobar = new BeforeTranslateInfoBar(owner, this); break; case AFTER_TRANSLATE: - infobar = new AfterTranslateInfoBar(helper, this); + infobar = new AfterTranslateInfoBar(owner, this); break; case TRANSLATING: case TRANSLATION_ERROR: - infobar = new TranslateMessageInfoBar(helper, this); + infobar = new TranslateMessageInfoBar(owner, this); break; default: NOTREACHED(); 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 4c7c583..7181b39 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(InfoBarTabHelper* owner, + TranslateInfoBarBase(InfoBarService* 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 1ec87bd..ccca707 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( - InfoBarTabHelper* owner, + InfoBarService* 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 5bbe817..0a4bb44 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(InfoBarTabHelper* owner, + TranslateMessageInfoBar(InfoBarService* owner, TranslateInfoBarDelegate* delegate); virtual ~TranslateMessageInfoBar(); diff --git a/chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.cc b/chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.cc index 5be6b8b..a5bda8f 100644 --- a/chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.cc +++ b/chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.cc @@ -7,8 +7,8 @@ #include "base/i18n/rtl.h" #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/certificate_viewer.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" @@ -258,11 +258,11 @@ WebsiteSettingsPopupGtk::WebsiteSettingsPopupGtk( TabSpecificContentSettings* content_settings = TabSpecificContentSettings::FromWebContents(web_contents); - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(web_contents); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); presenter_.reset(new WebsiteSettings(this, profile, content_settings, - infobar_tab_helper, + infobar_service, url, ssl, content::CertStore::GetInstance())); } diff --git a/chrome/browser/ui/hung_plugin_tab_helper.cc b/chrome/browser/ui/hung_plugin_tab_helper.cc index 2d66475..a31194a 100644 --- a/chrome/browser/ui/hung_plugin_tab_helper.cc +++ b/chrome/browser/ui/hung_plugin_tab_helper.cc @@ -11,8 +11,8 @@ #include "base/rand_util.h" #include "build/build_config.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/infobars/infobar.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_version_info.h" #include "content/public/browser/browser_child_process_host_iterator.h" @@ -125,7 +125,7 @@ void KillPluginOnIOThread(int child_id) { class HungPluginTabHelper::InfoBarDelegate : public ConfirmInfoBarDelegate { public: InfoBarDelegate(HungPluginTabHelper* helper, - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, int plugin_child_id, const string16& plugin_name); virtual ~InfoBarDelegate(); @@ -148,10 +148,10 @@ class HungPluginTabHelper::InfoBarDelegate : public ConfirmInfoBarDelegate { HungPluginTabHelper::InfoBarDelegate::InfoBarDelegate( HungPluginTabHelper* helper, - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, int plugin_child_id, const string16& plugin_name) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), helper_(helper), plugin_child_id_(plugin_child_id) { message_ = l10n_util::GetStringFUTF16(IDS_BROWSER_HANGMONITOR_PLUGIN_INFOBAR, @@ -216,9 +216,9 @@ void HungPluginTabHelper::PluginCrashed(const FilePath& plugin_path) { // TODO(brettw) ideally this would take the child process ID. When we do this // for NaCl plugins, we'll want to know exactly which process it was since // the path won't be useful. - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents()); - if (!infobar_helper) + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents()); + if (!infobar_service) return; // For now, just do a brute-force search to see if we have this plugin. Since @@ -227,7 +227,7 @@ void HungPluginTabHelper::PluginCrashed(const FilePath& plugin_path) { i != hung_plugins_.end(); ++i) { if (i->second->path == plugin_path) { if (i->second->info_bar) - infobar_helper->RemoveInfoBar(i->second->info_bar); + infobar_service->RemoveInfoBar(i->second->info_bar); hung_plugins_.erase(i); break; } @@ -237,9 +237,9 @@ void HungPluginTabHelper::PluginCrashed(const FilePath& plugin_path) { void HungPluginTabHelper::PluginHungStatusChanged(int plugin_child_id, const FilePath& plugin_path, bool is_hung) { - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents()); - if (!infobar_helper) + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents()); + if (!infobar_service) return; PluginStateMap::iterator found = hung_plugins_.find(plugin_child_id); @@ -247,7 +247,7 @@ void HungPluginTabHelper::PluginHungStatusChanged(int plugin_child_id, if (!is_hung) { // Hung plugin became un-hung, close the infobar and delete our info. if (found->second->info_bar) - infobar_helper->RemoveInfoBar(found->second->info_bar); + infobar_service->RemoveInfoBar(found->second->info_bar); hung_plugins_.erase(found); } return; @@ -357,25 +357,25 @@ void HungPluginTabHelper::OnReshowTimer(int child_id) { } void HungPluginTabHelper::ShowBar(int child_id, PluginState* state) { - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents()); - if (!infobar_helper) + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents()); + if (!infobar_service) return; DCHECK(!state->info_bar); - state->info_bar = new InfoBarDelegate(this, infobar_helper, + state->info_bar = new InfoBarDelegate(this, infobar_service, child_id, state->name); - infobar_helper->AddInfoBar(state->info_bar); + infobar_service->AddInfoBar(state->info_bar); } void HungPluginTabHelper::CloseBar(PluginState* state) { - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents()); - if (!infobar_helper) + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents()); + if (!infobar_service) return; if (state->info_bar) { - infobar_helper->RemoveInfoBar(state->info_bar); + infobar_service->RemoveInfoBar(state->info_bar); state->info_bar = NULL; } } diff --git a/chrome/browser/ui/hung_plugin_tab_helper.h b/chrome/browser/ui/hung_plugin_tab_helper.h index 91e546b..705acf4 100644 --- a/chrome/browser/ui/hung_plugin_tab_helper.h +++ b/chrome/browser/ui/hung_plugin_tab_helper.h @@ -18,7 +18,6 @@ #include "content/public/browser/web_contents_user_data.h" class FilePath; -class InfoBarTabHelper; // Manages per-tab state with regard to hung plugins. This only handles // Pepper plugins which we know are windowless. Hung NPAPI plugins (which diff --git a/chrome/browser/ui/media_stream_infobar_delegate.cc b/chrome/browser/ui/media_stream_infobar_delegate.cc index a15bc07..24452bc 100644 --- a/chrome/browser/ui/media_stream_infobar_delegate.cc +++ b/chrome/browser/ui/media_stream_infobar_delegate.cc @@ -6,9 +6,10 @@ #include "base/logging.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/google/google_util.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/common/url_constants.h" +#include "content/public/browser/web_contents.h" #include "googleurl/src/gurl.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -16,9 +17,9 @@ #include "ui/base/resource/resource_bundle.h" MediaStreamInfoBarDelegate::MediaStreamInfoBarDelegate( - InfoBarTabHelper* tab_helper, + InfoBarService* infobar_service, MediaStreamDevicesController* controller) - : ConfirmInfoBarDelegate(tab_helper), + : ConfirmInfoBarDelegate(infobar_service), controller_(controller) { DCHECK(controller_.get()); DCHECK(controller_->has_audio() || controller_->has_video()); diff --git a/chrome/browser/ui/media_stream_infobar_delegate.h b/chrome/browser/ui/media_stream_infobar_delegate.h index 1eee3df..14f2b2c 100644 --- a/chrome/browser/ui/media_stream_infobar_delegate.h +++ b/chrome/browser/ui/media_stream_infobar_delegate.h @@ -11,7 +11,6 @@ #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" #include "chrome/browser/media/media_stream_devices_controller.h" -class InfoBarTabHelper; // This class configures an infobar shown when a page requests access to a // user's microphone and/or video camera. The user is shown a message asking @@ -22,7 +21,7 @@ class MediaStreamInfoBarDelegate : public ConfirmInfoBarDelegate { public: // MediaStreamInfoBarDelegate takes the ownership of the |controller|. MediaStreamInfoBarDelegate( - InfoBarTabHelper* tab_helper, + InfoBarService* infobar_service, MediaStreamDevicesController* controller); virtual ~MediaStreamInfoBarDelegate(); diff --git a/chrome/browser/ui/startup/autolaunch_prompt_win.cc b/chrome/browser/ui/startup/autolaunch_prompt_win.cc index 2750c94..07e442c 100644 --- a/chrome/browser/ui/startup/autolaunch_prompt_win.cc +++ b/chrome/browser/ui/startup/autolaunch_prompt_win.cc @@ -8,9 +8,9 @@ #include "base/message_loop.h" #include "base/utf_string_conversions.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/auto_launch_trial.h" #include "chrome/browser/first_run/first_run.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" @@ -36,7 +36,7 @@ const int kMaxInfobarShown = 5; // The delegate for the infobar shown when Chrome was auto-launched. class AutolaunchInfoBarDelegate : public ConfirmInfoBarDelegate { public: - AutolaunchInfoBarDelegate(InfoBarTabHelper* infobar_helper, + AutolaunchInfoBarDelegate(InfoBarService* infobar_service, PrefService* prefs, Profile* profile); virtual ~AutolaunchInfoBarDelegate(); @@ -72,10 +72,10 @@ class AutolaunchInfoBarDelegate : public ConfirmInfoBarDelegate { }; AutolaunchInfoBarDelegate::AutolaunchInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, PrefService* prefs, Profile* profile) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), prefs_(prefs), action_taken_(false), should_expire_(false), @@ -177,14 +177,14 @@ bool ShowAutolaunchPrompt(Browser* browser) { content::WebContents* web_contents = chrome::GetActiveWebContents(browser); // Don't show the info-bar if there are already info-bars showing. - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents); - if (infobar_helper->GetInfoBarCount() > 0) + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); + if (infobar_service->GetInfoBarCount() > 0) return false; profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); - infobar_helper->AddInfoBar(new AutolaunchInfoBarDelegate( - infobar_helper, profile->GetPrefs(), profile)); + infobar_service->AddInfoBar(new AutolaunchInfoBarDelegate( + infobar_service, profile->GetPrefs(), profile)); return true; } diff --git a/chrome/browser/ui/startup/bad_flags_prompt.cc b/chrome/browser/ui/startup/bad_flags_prompt.cc index 3eca4a2..64b758d 100644 --- a/chrome/browser/ui/startup/bad_flags_prompt.cc +++ b/chrome/browser/ui/startup/bad_flags_prompt.cc @@ -6,8 +6,8 @@ #include "base/command_line.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/api/infobars/simple_alert_infobar_delegate.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/common/chrome_switches.h" @@ -43,11 +43,11 @@ void ShowBadFlagsPrompt(Browser* browser) { content::WebContents* web_contents = chrome::GetActiveWebContents(browser); if (!web_contents) return; - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(web_contents); - infobar_tab_helper->AddInfoBar( + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); + infobar_service->AddInfoBar( new SimpleAlertInfoBarDelegate( - infobar_tab_helper, NULL, + infobar_service, NULL, l10n_util::GetStringFUTF16( IDS_BAD_FLAGS_WARNING_MESSAGE, UTF8ToUTF16(std::string("--") + bad_flag)), diff --git a/chrome/browser/ui/startup/default_browser_prompt.cc b/chrome/browser/ui/startup/default_browser_prompt.cc index 337e66f..64dcfee 100644 --- a/chrome/browser/ui/startup/default_browser_prompt.cc +++ b/chrome/browser/ui/startup/default_browser_prompt.cc @@ -8,9 +8,9 @@ #include "base/message_loop.h" #include "base/metrics/histogram.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/first_run/first_run.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/shell_integration.h" @@ -20,6 +20,7 @@ #include "chrome/common/pref_names.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_details.h" +#include "content/public/browser/web_contents.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -54,7 +55,7 @@ void SetChromeAsDefaultBrowser(bool interactive_flow, PrefService* prefs) { // The delegate for the infobar shown when Chrome is not the default browser. class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate { public: - DefaultBrowserInfoBarDelegate(InfoBarTabHelper* infobar_helper, + DefaultBrowserInfoBarDelegate(InfoBarService* infobar_service, PrefService* prefs, bool interactive_flow_required); @@ -93,10 +94,10 @@ class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate { }; DefaultBrowserInfoBarDelegate::DefaultBrowserInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarService* infobar_service, PrefService* prefs, bool interactive_flow_required) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), prefs_(prefs), action_taken_(false), should_expire_(false), @@ -171,17 +172,17 @@ void NotifyNotDefaultBrowserCallback(chrome::HostDesktopType desktop_type) { return; // Don't show the info-bar if there are already info-bars showing. - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents); - if (infobar_helper->GetInfoBarCount() > 0) + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); + if (infobar_service->GetInfoBarCount() > 0) return; bool interactive_flow = ShellIntegration::CanSetAsDefaultBrowser() == ShellIntegration::SET_DEFAULT_INTERACTIVE; Profile* profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); - infobar_helper->AddInfoBar( - new DefaultBrowserInfoBarDelegate(infobar_helper, + infobar_service->AddInfoBar( + new DefaultBrowserInfoBarDelegate(infobar_service, profile->GetPrefs(), interactive_flow)); } diff --git a/chrome/browser/ui/startup/obsolete_os_info_bar.cc b/chrome/browser/ui/startup/obsolete_os_info_bar.cc index e712904..456e620 100644 --- a/chrome/browser/ui/startup/obsolete_os_info_bar.cc +++ b/chrome/browser/ui/startup/obsolete_os_info_bar.cc @@ -4,7 +4,7 @@ #include "chrome/browser/ui/startup/obsolete_os_info_bar.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -14,10 +14,10 @@ using content::Referrer; namespace chrome { -ObsoleteOSInfoBar::ObsoleteOSInfoBar(InfoBarTabHelper* infobar_helper, +ObsoleteOSInfoBar::ObsoleteOSInfoBar(InfoBarService* infobar_service, const string16& message, const GURL& url) - : LinkInfoBarDelegate(infobar_helper), + : LinkInfoBarDelegate(infobar_service), message_(message), learn_more_url_(url) { } diff --git a/chrome/browser/ui/startup/obsolete_os_info_bar.h b/chrome/browser/ui/startup/obsolete_os_info_bar.h index 8001b75..5e0871f 100644 --- a/chrome/browser/ui/startup/obsolete_os_info_bar.h +++ b/chrome/browser/ui/startup/obsolete_os_info_bar.h @@ -10,14 +10,14 @@ #include "chrome/browser/api/infobars/link_infobar_delegate.h" #include "googleurl/src/gurl.h" -class InfoBarTabHelper; +class InfoBarService; namespace chrome { // An infobar that is run with a string and a "Learn More" link. class ObsoleteOSInfoBar : public LinkInfoBarDelegate { public: - ObsoleteOSInfoBar(InfoBarTabHelper* infobar_helper, + ObsoleteOSInfoBar(InfoBarService* infobar_service, const string16& message, const GURL& url); virtual ~ObsoleteOSInfoBar(); diff --git a/chrome/browser/ui/startup/obsolete_os_prompt_gtk.cc b/chrome/browser/ui/startup/obsolete_os_prompt_gtk.cc index 4bb6f4e..a27746e 100644 --- a/chrome/browser/ui/startup/obsolete_os_prompt_gtk.cc +++ b/chrome/browser/ui/startup/obsolete_os_prompt_gtk.cc @@ -5,7 +5,7 @@ #include "chrome/browser/ui/startup/obsolete_os_prompt.h" #include "base/logging.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/gtk/gtk_util.h" @@ -33,11 +33,10 @@ void ShowObsoleteOSPrompt(Browser* browser) { content::WebContents* web_contents = chrome::GetActiveWebContents(browser); if (!web_contents) return; - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(web_contents); - infobar_tab_helper->AddInfoBar(new ObsoleteOSInfoBar(infobar_tab_helper, - message, - GURL(kLearnMoreURL))); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); + infobar_service->AddInfoBar(new ObsoleteOSInfoBar(infobar_service, message, + GURL(kLearnMoreURL))); } } diff --git a/chrome/browser/ui/startup/session_crashed_prompt.cc b/chrome/browser/ui/startup/session_crashed_prompt.cc index 9a33df2..57d8b87 100644 --- a/chrome/browser/ui/startup/session_crashed_prompt.cc +++ b/chrome/browser/ui/startup/session_crashed_prompt.cc @@ -5,7 +5,7 @@ #include "chrome/browser/ui/startup/session_crashed_prompt.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sessions/session_restore.h" #include "chrome/browser/ui/browser.h" @@ -30,7 +30,7 @@ namespace { class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate, public content::NotificationObserver { public: - explicit SessionCrashedInfoBarDelegate(InfoBarTabHelper* infobar_helper); + explicit SessionCrashedInfoBarDelegate(InfoBarService* infobar_service); private: virtual ~SessionCrashedInfoBarDelegate(); @@ -56,8 +56,8 @@ class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate, }; SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate( - InfoBarTabHelper* infobar_helper) - : ConfirmInfoBarDelegate(infobar_helper), + InfoBarService* infobar_service) + : ConfirmInfoBarDelegate(infobar_service), accepted_(false), removed_notification_received_(false), browser_(chrome::FindBrowserWithWebContents(owner()->GetWebContents())) { @@ -145,12 +145,12 @@ void ShowSessionCrashedPrompt(Browser* browser) { return; // Don't show the info-bar if there are already info-bars showing. - InfoBarTabHelper* infobar_tab_helper = InfoBarTabHelper::FromWebContents(tab); - if (infobar_tab_helper->GetInfoBarCount() > 0) + InfoBarService* infobar_service = InfoBarService::FromWebContents(tab); + if (infobar_service->GetInfoBarCount() > 0) return; - infobar_tab_helper->AddInfoBar( - new SessionCrashedInfoBarDelegate(infobar_tab_helper)); + infobar_service->AddInfoBar( + new SessionCrashedInfoBarDelegate(infobar_service)); } } // namespace chrome diff --git a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc index ff4a3ef..d5c2d8e 100644 --- a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc +++ b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc @@ -5,12 +5,12 @@ #include "base/command_line.h" #include "base/file_path.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/first_run/first_run.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/session_startup_pref.h" #include "chrome/browser/profiles/profile.h" @@ -656,8 +656,8 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) { content::WebContents* web_contents = chrome::GetWebContentsAt(new_browser, 0); EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL()); - EXPECT_EQ(1U, InfoBarTabHelper::FromWebContents(web_contents)-> - GetInfoBarCount()); + EXPECT_EQ(1U, + InfoBarService::FromWebContents(web_contents)->GetInfoBarCount()); // The profile which normally opens last open pages displays the new tab page. ASSERT_EQ(1u, chrome::GetBrowserCount(profile_last)); @@ -667,8 +667,8 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) { web_contents = chrome::GetWebContentsAt(new_browser, 0); EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL()); - EXPECT_EQ(1U, InfoBarTabHelper::FromWebContents(web_contents)-> - GetInfoBarCount()); + EXPECT_EQ(1U, + InfoBarService::FromWebContents(web_contents)->GetInfoBarCount()); // The profile which normally opens URLs displays the new tab page. ASSERT_EQ(1u, chrome::GetBrowserCount(profile_urls)); @@ -678,7 +678,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) { web_contents = chrome::GetWebContentsAt(new_browser, 0); EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL()); - EXPECT_EQ(1U, InfoBarTabHelper::FromWebContents(web_contents)-> - GetInfoBarCount()); + EXPECT_EQ(1U, + InfoBarService::FromWebContents(web_contents)->GetInfoBarCount()); } #endif // !OS_CHROMEOS diff --git a/chrome/browser/ui/sync/one_click_signin_helper.cc b/chrome/browser/ui/sync/one_click_signin_helper.cc index ba5a953..a3aa899 100644 --- a/chrome/browser/ui/sync/one_click_signin_helper.cc +++ b/chrome/browser/ui/sync/one_click_signin_helper.cc @@ -12,10 +12,10 @@ #include "base/string_split.h" #include "base/supports_user_data.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/api/infobars/one_click_signin_infobar_delegate.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/defaults.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/profiles/profile.h" @@ -184,10 +184,10 @@ const void* const OneClickSigninRequestUserData::kUserDataKey = // of this infobar. class OneClickInfoBarDelegateImpl : public OneClickSigninInfoBarDelegate { public: - OneClickInfoBarDelegateImpl(InfoBarTabHelper* owner, - const std::string& session_index, - const std::string& email, - const std::string& password); + OneClickInfoBarDelegateImpl(InfoBarService* owner, + const std::string& session_index, + const std::string& email, + const std::string& password); virtual ~OneClickInfoBarDelegateImpl(); private: @@ -227,7 +227,7 @@ class OneClickInfoBarDelegateImpl : public OneClickSigninInfoBarDelegate { }; OneClickInfoBarDelegateImpl::OneClickInfoBarDelegateImpl( - InfoBarTabHelper* owner, + InfoBarService* owner, const std::string& session_index, const std::string& email, const std::string& password) @@ -760,8 +760,8 @@ void OneClickSigninHelper::DidStopLoading( return; Browser* browser = chrome::FindBrowserWithWebContents(contents); - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(contents); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(contents); switch (auto_accept_) { case AUTO_ACCEPT: @@ -770,8 +770,8 @@ void OneClickSigninHelper::DidStopLoading( email_, password_)); break; case NO_AUTO_ACCEPT: - infobar_tab_helper->AddInfoBar( - new OneClickInfoBarDelegateImpl(infobar_tab_helper, session_index_, + infobar_service->AddInfoBar( + new OneClickInfoBarDelegateImpl(infobar_service, session_index_, email_, password_)); break; case AUTO_ACCEPT_CONFIGURE: diff --git a/chrome/browser/ui/views/collected_cookies_views.cc b/chrome/browser/ui/views/collected_cookies_views.cc index 9ecef9a..7a17577 100644 --- a/chrome/browser/ui/views/collected_cookies_views.cc +++ b/chrome/browser/ui/views/collected_cookies_views.cc @@ -4,6 +4,7 @@ #include "chrome/browser/ui/views/collected_cookies_views.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" #include "chrome/browser/browsing_data/browsing_data_database_helper.h" @@ -15,7 +16,6 @@ #include "chrome/browser/content_settings/cookie_settings.h" #include "chrome/browser/content_settings/local_shared_objects_container.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" @@ -223,10 +223,10 @@ void CollectedCookiesViews::DeleteDelegate() { bool CollectedCookiesViews::Cancel() { if (status_changed_) { - InfoBarTabHelper* infobar_helper = - InfoBarTabHelper::FromWebContents(web_contents_); - infobar_helper->AddInfoBar( - new CollectedCookiesInfoBarDelegate(infobar_helper)); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents_); + infobar_service->AddInfoBar( + new CollectedCookiesInfoBarDelegate(infobar_service)); } return true; diff --git a/chrome/browser/ui/views/external_tab_container_win.cc b/chrome/browser/ui/views/external_tab_container_win.cc index 3d66c3e..42e67b2 100644 --- a/chrome/browser/ui/views/external_tab_container_win.cc +++ b/chrome/browser/ui/views/external_tab_container_win.cc @@ -18,13 +18,13 @@ #include "base/win/win_util.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/app/chrome_dll_resource.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/automation/automation_provider.h" #include "chrome/browser/devtools/devtools_toggle_action.h" #include "chrome/browser/devtools/devtools_window.h" #include "chrome/browser/file_select_helper.h" #include "chrome/browser/history/history_tab_helper.h" #include "chrome/browser/history/history_types.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/pepper_broker_infobar_delegate.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/repost_form_warning_controller.h" @@ -223,9 +223,9 @@ bool ExternalTabContainerWin::Init(Profile* profile, web_contents_.reset(existing_contents); if (!infobars_enabled) { - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(existing_contents); - infobar_tab_helper->set_infobars_enabled(false); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(existing_contents); + infobar_service->SetInfoBarsEnabled(false); } // Start loading initial URL @@ -1198,9 +1198,9 @@ void ExternalTabContainerWin::SetupExternalTabView() { InfoBarContainerView* info_bar_container = new InfoBarContainerView(this, NULL); - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(web_contents_.get()); - info_bar_container->ChangeTabContents(infobar_tab_helper); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents_.get()); + info_bar_container->ChangeInfoBarService(infobar_service); views::GridLayout* layout = new views::GridLayout(external_tab_view_); // Give this column an identifier of 0. diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 8da8e88..532e1317 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -14,12 +14,12 @@ #include "base/utf_string_conversions.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/app/chrome_dll_resource.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/bookmarks/bookmark_model_factory.h" #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/extensions/tab_helper.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/managed_mode/managed_mode.h" #include "chrome/browser/native_window_notification_source.h" #include "chrome/browser/password_manager/password_manager.h" @@ -1620,7 +1620,7 @@ void BrowserView::TabDetachedAt(WebContents* contents, int index) { // freed. This is because the focus manager performs some operations // on the selected WebContents when it is removed. contents_container_->SetWebContents(NULL); - infobar_container_->ChangeTabContents(NULL); + infobar_container_->ChangeInfoBarService(NULL); UpdateDevToolsForContents(NULL); } } @@ -1663,9 +1663,8 @@ void BrowserView::ActiveTabChanged(content::WebContents* old_contents, // avoid an unnecessary resize and re-layout of a WebContents. if (change_tab_contents) contents_container_->SetWebContents(NULL); - InfoBarTabHelper* new_infobar_tab_helper = - InfoBarTabHelper::FromWebContents(new_contents); - infobar_container_->ChangeTabContents(new_infobar_tab_helper); + infobar_container_->ChangeInfoBarService( + InfoBarService::FromWebContents(new_contents)); if (bookmark_bar_view_.get()) { bookmark_bar_view_->SetBookmarkBarState( browser_->bookmark_bar_state(), diff --git a/chrome/browser/ui/views/infobars/after_translate_infobar.cc b/chrome/browser/ui/views/infobars/after_translate_infobar.cc index dd91163..b136556 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 "ui/views/controls/menu/menu_item_view.h" AfterTranslateInfoBar::AfterTranslateInfoBar( - InfoBarTabHelper* owner, + InfoBarService* 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 c3c9de6..9be2bb4 100644 --- a/chrome/browser/ui/views/infobars/after_translate_infobar.h +++ b/chrome/browser/ui/views/infobars/after_translate_infobar.h @@ -18,7 +18,7 @@ class MenuButton; class AfterTranslateInfoBar : public TranslateInfoBarBase, public views::MenuButtonListener { public: - AfterTranslateInfoBar(InfoBarTabHelper* owner, + AfterTranslateInfoBar(InfoBarService* 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 5cc2941..23f1eed 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 "ui/views/controls/menu/menu_item_view.h" BeforeTranslateInfoBar::BeforeTranslateInfoBar( - InfoBarTabHelper* owner, + InfoBarService* 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 694ec42a..c8764b3 100644 --- a/chrome/browser/ui/views/infobars/before_translate_infobar.h +++ b/chrome/browser/ui/views/infobars/before_translate_infobar.h @@ -18,7 +18,7 @@ class MenuButton; class BeforeTranslateInfoBar : public TranslateInfoBarBase, public views::MenuButtonListener { public: - BeforeTranslateInfoBar(InfoBarTabHelper* owner, + BeforeTranslateInfoBar(InfoBarService* 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 7bb6708..5347e9b 100644 --- a/chrome/browser/ui/views/infobars/confirm_infobar.cc +++ b/chrome/browser/ui/views/infobars/confirm_infobar.cc @@ -7,7 +7,6 @@ #include "base/logging.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" #include "chrome/browser/event_disposition.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "ui/views/controls/button/text_button.h" #include "ui/views/controls/label.h" #include "ui/views/controls/link.h" @@ -15,12 +14,12 @@ // ConfirmInfoBarDelegate ----------------------------------------------------- InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { - return new ConfirmInfoBar(static_cast<InfoBarTabHelper*>(owner), this); + return new ConfirmInfoBar(owner, this); } // ConfirmInfoBar ------------------------------------------------------------- -ConfirmInfoBar::ConfirmInfoBar(InfoBarTabHelper* owner, +ConfirmInfoBar::ConfirmInfoBar(InfoBarService* 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 878100e..ed4093d 100644 --- a/chrome/browser/ui/views/infobars/confirm_infobar.h +++ b/chrome/browser/ui/views/infobars/confirm_infobar.h @@ -23,7 +23,7 @@ class TextButton; class ConfirmInfoBar : public InfoBarView, public views::LinkListener { public: - ConfirmInfoBar(InfoBarTabHelper* owner, ConfirmInfoBarDelegate* delegate); + ConfirmInfoBar(InfoBarService* owner, ConfirmInfoBarDelegate* delegate); protected: // TODO(rogerta): These only need to be protected due to the diff --git a/chrome/browser/ui/views/infobars/extension_infobar.cc b/chrome/browser/ui/views/infobars/extension_infobar.cc index 2bef24c4..552d794 100644 --- a/chrome/browser/ui/views/infobars/extension_infobar.cc +++ b/chrome/browser/ui/views/infobars/extension_infobar.cc @@ -7,7 +7,6 @@ #include "chrome/browser/extensions/extension_context_menu_model.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_infobar_delegate.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/platform_util.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/common/extensions/extension.h" @@ -27,8 +26,7 @@ // ExtensionInfoBarDelegate ---------------------------------------------------- InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { - return new ExtensionInfoBar( - browser_, static_cast<InfoBarTabHelper*>(owner), this); + return new ExtensionInfoBar(browser_, owner, this); } // ExtensionInfoBar ------------------------------------------------------------ @@ -76,7 +74,7 @@ class MenuImageSource: public gfx::CanvasImageSource { } // namespace ExtensionInfoBar::ExtensionInfoBar(Browser* browser, - InfoBarTabHelper* owner, + InfoBarService* 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 0f8c108..302afea 100644 --- a/chrome/browser/ui/views/infobars/extension_infobar.h +++ b/chrome/browser/ui/views/infobars/extension_infobar.h @@ -22,7 +22,7 @@ class ExtensionInfoBar : public InfoBarView, public views::MenuButtonListener { public: ExtensionInfoBar(Browser* browser, - InfoBarTabHelper* owner, + InfoBarService* owner, ExtensionInfoBarDelegate* delegate); private: diff --git a/chrome/browser/ui/views/infobars/infobar_view.cc b/chrome/browser/ui/views/infobars/infobar_view.cc index 3e22567..a8438a6 100644 --- a/chrome/browser/ui/views/infobars/infobar_view.cc +++ b/chrome/browser/ui/views/infobars/infobar_view.cc @@ -56,7 +56,7 @@ const int InfoBarView::kButtonButtonSpacing = 10; const int InfoBarView::kEndOfLabelSpacing = 16; const int InfoBarView::kHorizontalPadding = 6; -InfoBarView::InfoBarView(InfoBarTabHelper* owner, InfoBarDelegate* delegate) +InfoBarView::InfoBarView(InfoBarService* 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 13e72f7..e970b7e 100644 --- a/chrome/browser/ui/views/infobars/infobar_view.h +++ b/chrome/browser/ui/views/infobars/infobar_view.h @@ -35,7 +35,7 @@ class InfoBarView : public InfoBar, public views::ButtonListener, public views::FocusChangeListener { public: - InfoBarView(InfoBarTabHelper* owner, InfoBarDelegate* delegate); + InfoBarView(InfoBarService* 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 8eead6e..46caaf4 100644 --- a/chrome/browser/ui/views/infobars/link_infobar.cc +++ b/chrome/browser/ui/views/infobars/link_infobar.cc @@ -7,19 +7,18 @@ #include "base/logging.h" #include "chrome/browser/api/infobars/link_infobar_delegate.h" #include "chrome/browser/event_disposition.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "ui/views/controls/label.h" #include "ui/views/controls/link.h" // LinkInfoBarDelegate -------------------------------------------------------- InfoBar* LinkInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { - return new LinkInfoBar(static_cast<InfoBarTabHelper*>(owner), this); + return new LinkInfoBar(owner, this); } // LinkInfoBar ---------------------------------------------------------------- -LinkInfoBar::LinkInfoBar(InfoBarTabHelper* owner, +LinkInfoBar::LinkInfoBar(InfoBarService* 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 664a799..8024ae6 100644 --- a/chrome/browser/ui/views/infobars/link_infobar.h +++ b/chrome/browser/ui/views/infobars/link_infobar.h @@ -16,7 +16,7 @@ class LinkInfoBarDelegate; class LinkInfoBar : public InfoBarView, public views::LinkListener { public: - LinkInfoBar(InfoBarTabHelper* owner, LinkInfoBarDelegate* delegate); + LinkInfoBar(InfoBarService* owner, LinkInfoBarDelegate* delegate); private: virtual ~LinkInfoBar(); diff --git a/chrome/browser/ui/views/infobars/one_click_signin_infobar.cc b/chrome/browser/ui/views/infobars/one_click_signin_infobar.cc index 15d605b..af3a60f 100644 --- a/chrome/browser/ui/views/infobars/one_click_signin_infobar.cc +++ b/chrome/browser/ui/views/infobars/one_click_signin_infobar.cc @@ -6,7 +6,6 @@ #include "chrome/browser/api/infobars/one_click_signin_infobar_delegate.h" #include "chrome/browser/defaults.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/ui/views/infobars/infobar_background.h" #include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkPaint.h" @@ -103,14 +102,14 @@ InfoBarColoredButtonBorder::~InfoBarColoredButtonBorder() { // OneClickSigninInfoBarDelegate ---------------------------------------------- InfoBar* OneClickSigninInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { - return new OneClickSigninInfoBar(static_cast<InfoBarTabHelper*>(owner), this); + return new OneClickSigninInfoBar(owner, this); } // OneClickLoginInfoBar ------------------------------------------------------- OneClickSigninInfoBar::OneClickSigninInfoBar( - InfoBarTabHelper* owner, + InfoBarService* owner, OneClickSigninInfoBarDelegate* delegate) : ConfirmInfoBar(owner, delegate), one_click_delegate_(delegate) { diff --git a/chrome/browser/ui/views/infobars/one_click_signin_infobar.h b/chrome/browser/ui/views/infobars/one_click_signin_infobar.h index 94047ef..7296c10 100644 --- a/chrome/browser/ui/views/infobars/one_click_signin_infobar.h +++ b/chrome/browser/ui/views/infobars/one_click_signin_infobar.h @@ -13,7 +13,7 @@ // remains the same. class OneClickSigninInfoBar : public ConfirmInfoBar { public: - OneClickSigninInfoBar(InfoBarTabHelper* owner, + OneClickSigninInfoBar(InfoBarService* owner, OneClickSigninInfoBarDelegate* delegate); ~OneClickSigninInfoBar(); diff --git a/chrome/browser/ui/views/infobars/translate_infobar_base.cc b/chrome/browser/ui/views/infobars/translate_infobar_base.cc index 807797c..284921f 100644 --- a/chrome/browser/ui/views/infobars/translate_infobar_base.cc +++ b/chrome/browser/ui/views/infobars/translate_infobar_base.cc @@ -6,7 +6,6 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/infobars/infobar.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/translate/translate_infobar_delegate.h" #include "chrome/browser/ui/views/infobars/after_translate_infobar.h" #include "chrome/browser/ui/views/infobars/before_translate_infobar.h" @@ -21,12 +20,11 @@ // TranslateInfoBarDelegate --------------------------------------------------- InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { - InfoBarTabHelper* helper = static_cast<InfoBarTabHelper*>(owner); if (type_ == BEFORE_TRANSLATE) - return new BeforeTranslateInfoBar(helper, this); + return new BeforeTranslateInfoBar(owner, this); if (type_ == AFTER_TRANSLATE) - return new AfterTranslateInfoBar(helper, this); - return new TranslateMessageInfoBar(helper, this); + return new AfterTranslateInfoBar(owner, this); + return new TranslateMessageInfoBar(owner, this); } // TranslateInfoBarBase ------------------------------------------------------- @@ -34,7 +32,7 @@ InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { // static const int TranslateInfoBarBase::kButtonInLabelSpacing = 5; -TranslateInfoBarBase::TranslateInfoBarBase(InfoBarTabHelper* owner, +TranslateInfoBarBase::TranslateInfoBarBase(InfoBarService* owner, TranslateInfoBarDelegate* delegate) : InfoBarView(owner, delegate), error_background_(GetInfoBarTopColor(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 b5c7c46..6ebc760 100644 --- a/chrome/browser/ui/views/infobars/translate_infobar_base.h +++ b/chrome/browser/ui/views/infobars/translate_infobar_base.h @@ -19,7 +19,7 @@ class MenuButton; // use. class TranslateInfoBarBase : public InfoBarView { public: - TranslateInfoBarBase(InfoBarTabHelper* owner, + TranslateInfoBarBase(InfoBarService* 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 58987b9..a06c3c3 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 "ui/views/controls/label.h" TranslateMessageInfoBar::TranslateMessageInfoBar( - InfoBarTabHelper* owner, + InfoBarService* 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 7b0d2cf..b5cca3f 100644 --- a/chrome/browser/ui/views/infobars/translate_message_infobar.h +++ b/chrome/browser/ui/views/infobars/translate_message_infobar.h @@ -9,7 +9,7 @@ class TranslateMessageInfoBar : public TranslateInfoBarBase { public: - TranslateMessageInfoBar(InfoBarTabHelper* owner, + TranslateMessageInfoBar(InfoBarService* owner, TranslateInfoBarDelegate* delegate); private: diff --git a/chrome/browser/ui/views/toolbar_view.cc b/chrome/browser/ui/views/toolbar_view.cc index b619a34..8948e1a 100644 --- a/chrome/browser/ui/views/toolbar_view.cc +++ b/chrome/browser/ui/views/toolbar_view.cc @@ -9,7 +9,6 @@ #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/command_updater.h" #include "chrome/browser/event_disposition.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/themes/theme_service.h" diff --git a/chrome/browser/ui/views/website_settings/website_settings_popup_view.cc b/chrome/browser/ui/views/website_settings/website_settings_popup_view.cc index 6213180..1b8b413 100644 --- a/chrome/browser/ui/views/website_settings/website_settings_popup_view.cc +++ b/chrome/browser/ui/views/website_settings/website_settings_popup_view.cc @@ -6,8 +6,8 @@ #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/certificate_viewer.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/views/collected_cookies_views.h" @@ -342,11 +342,11 @@ WebsiteSettingsPopupView::WebsiteSettingsPopupView( TabSpecificContentSettings* content_settings = TabSpecificContentSettings::FromWebContents(web_contents); - InfoBarTabHelper* infobar_tab_helper = - InfoBarTabHelper::FromWebContents(web_contents); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); presenter_.reset(new WebsiteSettings(this, profile, content_settings, - infobar_tab_helper, + infobar_service, url, ssl, content::CertStore::GetInstance())); diff --git a/chrome/browser/ui/website_settings/website_settings.cc b/chrome/browser/ui/website_settings/website_settings.cc index 37ea028..9da367b 100644 --- a/chrome/browser/ui/website_settings/website_settings.cc +++ b/chrome/browser/ui/website_settings/website_settings.cc @@ -14,6 +14,7 @@ #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "base/values.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" #include "chrome/browser/browsing_data/browsing_data_database_helper.h" #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" @@ -24,7 +25,6 @@ #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/content_settings/local_shared_objects_container.h" #include "chrome/browser/history/history_service_factory.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ssl/ssl_error_info.h" #include "chrome/browser/ui/website_settings/website_settings_infobar_delegate.h" @@ -68,14 +68,14 @@ WebsiteSettings::WebsiteSettings( WebsiteSettingsUI* ui, Profile* profile, TabSpecificContentSettings* tab_specific_content_settings, - InfoBarTabHelper* infobar_tab_helper, + InfoBarService* infobar_service, const GURL& url, const content::SSLStatus& ssl, content::CertStore* cert_store) : TabSpecificContentSettings::SiteDataObserver( tab_specific_content_settings), ui_(ui), - infobar_helper_(infobar_tab_helper), + infobar_service_(infobar_service), show_info_bar_(false), site_url_(url), site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN), @@ -221,8 +221,8 @@ void WebsiteSettings::OnSiteDataAccessed() { void WebsiteSettings::OnUIClosing() { if (show_info_bar_) { - infobar_helper_->AddInfoBar( - new WebsiteSettingsInfobarDelegate(infobar_helper_)); + infobar_service_->AddInfoBar( + new WebsiteSettingsInfobarDelegate(infobar_service_)); } } diff --git a/chrome/browser/ui/website_settings/website_settings.h b/chrome/browser/ui/website_settings/website_settings.h index a1daacc..4e1c0e1 100644 --- a/chrome/browser/ui/website_settings/website_settings.h +++ b/chrome/browser/ui/website_settings/website_settings.h @@ -21,7 +21,7 @@ class CertStore; struct SSLStatus; } -class InfoBarTabHelper; +class InfoBarService; class HostContentSettingsMap; class Profile; class WebsiteSettingsUI; @@ -69,7 +69,7 @@ class WebsiteSettings : public TabSpecificContentSettings::SiteDataObserver { WebsiteSettings(WebsiteSettingsUI* ui, Profile* profile, TabSpecificContentSettings* tab_specific_content_settings, - InfoBarTabHelper* infobar_tab_helper, + InfoBarService* infobar_service, const GURL& url, const content::SSLStatus& ssl, content::CertStore* cert_store); @@ -140,8 +140,8 @@ class WebsiteSettings : public TabSpecificContentSettings::SiteDataObserver { // information (identity, connection status, etc.). WebsiteSettingsUI* ui_; - // The infobar helper of the active tab. - InfoBarTabHelper* infobar_helper_; // Owned by the active tab contents. + // The infobar service of the active tab. + InfoBarService* infobar_service_; // Owned by the active tab contents. // The flag that controls whether an infobar is displayed after the website // settings UI is closed or not. diff --git a/chrome/browser/ui/website_settings/website_settings_infobar_delegate.cc b/chrome/browser/ui/website_settings/website_settings_infobar_delegate.cc index 3b96398..a23be8a 100644 --- a/chrome/browser/ui/website_settings/website_settings_infobar_delegate.cc +++ b/chrome/browser/ui/website_settings/website_settings_infobar_delegate.cc @@ -6,7 +6,7 @@ #include "base/logging.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -14,8 +14,8 @@ #include "ui/base/resource/resource_bundle.h" WebsiteSettingsInfobarDelegate::WebsiteSettingsInfobarDelegate( - InfoBarTabHelper* infobar_helper) - : ConfirmInfoBarDelegate(infobar_helper) { + InfoBarService* infobar_service) + : ConfirmInfoBarDelegate(infobar_service) { } gfx::Image* WebsiteSettingsInfobarDelegate::GetIcon() const { diff --git a/chrome/browser/ui/website_settings/website_settings_infobar_delegate.h b/chrome/browser/ui/website_settings/website_settings_infobar_delegate.h index 8dedb7b..c6e90e8 100644 --- a/chrome/browser/ui/website_settings/website_settings_infobar_delegate.h +++ b/chrome/browser/ui/website_settings/website_settings_infobar_delegate.h @@ -7,7 +7,7 @@ #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" -class InfoBarTabHelper; +class InfoBarService; // This class configures an infobar that is shown when the website settings UI // is closed and the settings for one or more site permissions have been @@ -16,7 +16,7 @@ class InfoBarTabHelper; // the reload right from the infobar. class WebsiteSettingsInfobarDelegate : public ConfirmInfoBarDelegate { public: - explicit WebsiteSettingsInfobarDelegate(InfoBarTabHelper* infobar_helper); + explicit WebsiteSettingsInfobarDelegate(InfoBarService* infobar_service); private: // Overwridden from ConfirmInfoBarDelegate: diff --git a/chrome/browser/ui/website_settings/website_settings_unittest.cc b/chrome/browser/ui/website_settings/website_settings_unittest.cc index 961d609..b8f7608c 100644 --- a/chrome/browser/ui/website_settings/website_settings_unittest.cc +++ b/chrome/browser/ui/website_settings/website_settings_unittest.cc @@ -9,11 +9,11 @@ #include "base/string16.h" #include "base/utf_string_conversions.h" #include "chrome/browser/api/infobars/infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/content_settings/content_settings_provider.h" #include "chrome/browser/content_settings/content_settings_utils.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/ui/website_settings/website_settings_ui.h" #include "chrome/common/content_settings.h" #include "chrome/common/content_settings_types.h" @@ -99,7 +99,7 @@ class WebsiteSettingsTest : public ChromeRenderViewHostTestHarness { expiration_date); TabSpecificContentSettings::CreateForWebContents(web_contents()); - InfoBarTabHelper::CreateForWebContents(web_contents()); + InfoBarService::CreateForWebContents(web_contents()); // Setup the mock cert store. EXPECT_CALL(cert_store_, RetrieveCert(cert_id_, _) ) @@ -133,15 +133,15 @@ class WebsiteSettingsTest : public ChromeRenderViewHostTestHarness { TabSpecificContentSettings* tab_specific_content_settings() { return TabSpecificContentSettings::FromWebContents(web_contents()); } - InfoBarTabHelper* infobar_tab_helper() { - return InfoBarTabHelper::FromWebContents(web_contents()); + InfoBarService* infobar_service() { + return InfoBarService::FromWebContents(web_contents()); } WebsiteSettings* website_settings() { if (!website_settings_.get()) { website_settings_.reset(new WebsiteSettings( mock_ui(), profile(), tab_specific_content_settings(), - infobar_tab_helper(), url(), ssl(), cert_store())); + infobar_service(), url(), ssl(), cert_store())); } return website_settings_.get(); } @@ -368,9 +368,9 @@ TEST_F(WebsiteSettingsTest, NoInfoBar) { SetDefaultUIExpectations(mock_ui()); EXPECT_CALL(*mock_ui(), SetSelectedTab( WebsiteSettingsUI::TAB_ID_PERMISSIONS)); - EXPECT_EQ(0u, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0u, infobar_service()->GetInfoBarCount()); website_settings()->OnUIClosing(); - EXPECT_EQ(0u, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0u, infobar_service()->GetInfoBarCount()); } TEST_F(WebsiteSettingsTest, ShowInfoBar) { @@ -390,18 +390,18 @@ TEST_F(WebsiteSettingsTest, ShowInfoBar) { EXPECT_CALL(*mock_ui(), SetSelectedTab( WebsiteSettingsUI::TAB_ID_PERMISSIONS)); - EXPECT_EQ(0u, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(0u, infobar_service()->GetInfoBarCount()); website_settings()->OnSitePermissionChanged( CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ALLOW); website_settings()->OnUIClosing(); - EXPECT_EQ(1u, infobar_tab_helper()->GetInfoBarCount()); + EXPECT_EQ(1u, infobar_service()->GetInfoBarCount()); - // Removing an |InfoBarDelegate| from the |InfoBarTabHelper| does not delete + // Removing an |InfoBarDelegate| from the |InfoBarService| does not delete // it. Hence the |delegate| must be cleaned up after it was removed from the - // |infobar_tab_helper|. + // |infobar_service|. scoped_ptr<InfoBarDelegate> delegate( - infobar_tab_helper()->GetInfoBarDelegateAt(0)); - infobar_tab_helper()->RemoveInfoBar(delegate.get()); + infobar_service()->GetInfoBarDelegateAt(0)); + infobar_service()->RemoveInfoBar(delegate.get()); // Right now InfoBarDelegates delete themselves via // InfoBarClosed(); once InfoBars own their delegates, this can become a // simple reset() call diff --git a/chrome/common/chrome_notification_types.h b/chrome/common/chrome_notification_types.h index c52b32b..5f3ef69 100644 --- a/chrome/common/chrome_notification_types.h +++ b/chrome/common/chrome_notification_types.h @@ -119,25 +119,24 @@ enum NotificationType { // is the dialog. NOTIFICATION_APP_MODAL_DIALOG_SHOWN, - // This message is sent when a new InfoBar has been added to a - // InfoBarTabHelper. The source is a Source<InfoBarTabHelper> with a - // pointer to the InfoBarTabHelper the InfoBar was added to. The details - // is a Details<InfoBarDelegate> with a pointer to the delegate that was - // added. + // This message is sent when a new InfoBar has been added to an + // InfoBarService. The source is a Source<InfoBarService> with a pointer to + // the InfoBarService the InfoBar was added to. The details is a + // Details<InfoBarDelegate> with a pointer to the delegate that was added. NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, - // This message is sent when an InfoBar is about to be removed from a - // InfoBarTabHelper. The source is a Source<InfoBarTabHelper> with a - // pointer to the InfoBarTabHelper the InfoBar was removed from. The - // details is a Details<std::pair<InfoBarDelegate*, bool> > with a pointer - // to the removed delegate and whether the removal should be animated. + // This message is sent when an InfoBar is about to be removed from an + // InfoBarService. The source is a Source<InfoBarService> with a pointer to + // the InfoBarService the InfoBar was removed from. The details is a + // Details<std::pair<InfoBarDelegate*, bool> > with a pointer to the removed + // delegate and whether the removal should be animated. NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - // This message is sent when an InfoBar is replacing another infobar in a - // InfoBarTabHelper. The source is a Source<InfoBarTabHelper> with a - // pointer to the InfoBarTabHelper the InfoBar was removed from. The - // details is a Details<std::pair<InfoBarDelegate*, InfoBarDelegate*> > with - // pointers to the old and new delegates, respectively. + // This message is sent when an InfoBar is replacing another infobar in an + // InfoBarService. The source is a Source<InfoBarService> with a pointer to + // the InfoBarService the InfoBar was removed from. The details is a + // Details<std::pair<InfoBarDelegate*, InfoBarDelegate*> > with pointers to + // the old and new delegates, respectively. NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED, // This is sent when an externally hosted tab is closed. No details are diff --git a/chrome/test/gpu/gpu_crash_browsertest.cc b/chrome/test/gpu/gpu_crash_browsertest.cc index 1fec081..79fb8ef 100644 --- a/chrome/test/gpu/gpu_crash_browsertest.cc +++ b/chrome/test/gpu/gpu_crash_browsertest.cc @@ -6,7 +6,7 @@ #include "base/path_service.h" #include "base/utf_string_conversions.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" +#include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_navigator.h" @@ -111,7 +111,7 @@ IN_PROC_BROWSER_TEST_F(GPUCrashTest, ContextLossRaisesInfobar) { SimulateGPUCrash(browser()); infobar_added.Wait(); EXPECT_EQ(1u, - InfoBarTabHelper::FromWebContents( + InfoBarService::FromWebContents( chrome::GetActiveWebContents(browser()))->GetInfoBarCount()); } @@ -145,10 +145,10 @@ IN_PROC_BROWSER_TEST_F(GPUCrashTest, ContextLossInfobarReload) { SimulateGPUCrash(browser()); infobar_added.Wait(); ASSERT_EQ(1u, - InfoBarTabHelper::FromWebContents( + InfoBarService::FromWebContents( chrome::GetActiveWebContents(browser()))->GetInfoBarCount()); InfoBarDelegate* delegate = - InfoBarTabHelper::FromWebContents( + InfoBarService::FromWebContents( chrome::GetActiveWebContents(browser()))->GetInfoBarDelegateAt(0); ASSERT_TRUE(delegate); ASSERT_TRUE(delegate->AsThreeDAPIInfoBarDelegate()); diff --git a/chrome/test/ppapi/ppapi_test.cc b/chrome/test/ppapi/ppapi_test.cc index 5da65af..1d87c8e 100644 --- a/chrome/test/ppapi/ppapi_test.cc +++ b/chrome/test/ppapi/ppapi_test.cc @@ -15,7 +15,6 @@ #include "chrome/browser/api/infobars/confirm_infobar_delegate.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/ui/browser.h" #include "chrome/browser/ui/browser_tabstrip.h" diff --git a/tools/valgrind/memcheck/suppressions.txt b/tools/valgrind/memcheck/suppressions.txt index 67c7ace..50eb4ac 100644 --- a/tools/valgrind/memcheck/suppressions.txt +++ b/tools/valgrind/memcheck/suppressions.txt @@ -5732,7 +5732,7 @@ bug_145747a Memcheck:Leak fun:_Znw* - fun:_ZN24TranslateInfoBarDelegate19CreateErrorDelegateEN15TranslateErrors4TypeEP16InfoBarTabHelperP11PrefServiceRKSsS7_ + fun:_ZN24TranslateInfoBarDelegate19CreateErrorDelegateEN15TranslateErrors4TypeEP14InfoBarServiceP11PrefServiceRKSsS7_ fun:_ZN16TranslateManager14PageTranslatedEPN7content11WebContentsEP21PageTranslatedDetails fun:_ZN16TranslateManager7ObserveEiRKN7content18NotificationSourceERKNS0_19NotificationDetailsE fun:_ZN23NotificationServiceImpl6NotifyEiRKN7content18NotificationSourceERKNS0_19NotificationDetailsE @@ -5742,7 +5742,7 @@ bug_145747b Memcheck:Leak fun:_Znw* - fun:_ZN24TranslateInfoBarDelegate19CreateErrorDelegateEN15TranslateErrors4TypeEP16InfoBarTabHelperP11PrefServiceRKSsS7_ + fun:_ZN24TranslateInfoBarDelegate19CreateErrorDelegateEN15TranslateErrors4TypeEP14InfoBarServiceP11PrefServiceRKSsS7_ fun:_ZN16TranslateManager18OnURLFetchCompleteEPKN3net10URLFetcherE fun:_ZN20TranslateManagerTest31SimulateTranslateScriptURLFetchEb } @@ -6026,8 +6026,8 @@ bug_156705 Memcheck:Leak fun:_Znw* - fun:_ZN33GeolocationInfoBarQueueController21CreateInfoBarDelegateEP16InfoBarTabHelperPS_iiiRK4GURLRKSs - fun:_ZN33GeolocationInfoBarQueueController17ShowQueuedInfoBarEiiP16InfoBarTabHelper + fun:_ZN33GeolocationInfoBarQueueController21CreateInfoBarDelegateEP14InfoBarServicePS_iiiRK4GURLRKSs + fun:_ZN33GeolocationInfoBarQueueController17ShowQueuedInfoBarEiiP14InfoBarService } { bug_156829 |