summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-23 22:27:37 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-23 22:27:37 +0000
commita608d17f9338dc10159d50f81a9f64fcd51c9c80 (patch)
tree7a3b2220b49c859d1fe96ddb3ead21e51b468bde
parentb92e740735220100d7b05664b20ef96cc8342a81 (diff)
downloadchromium_src-a608d17f9338dc10159d50f81a9f64fcd51c9c80.zip
chromium_src-a608d17f9338dc10159d50f81a9f64fcd51c9c80.tar.gz
chromium_src-a608d17f9338dc10159d50f81a9f64fcd51c9c80.tar.bz2
Eliminate InfoBarTabHelper. Make InfoBarService a concrete class.
Most changes here are from inlining and renaming the simple accessors in the API. BUG=none TEST=none Review URL: https://codereview.chromium.org/14241006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195922 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/accessibility/accessibility_extension_api.cc4
-rw-r--r--chrome/browser/autofill/autofill_browsertest.cc20
-rw-r--r--chrome/browser/autofill/autofill_cc_infobar_delegate.cc4
-rw-r--r--chrome/browser/automation/automation_provider_observers.cc2
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc8
-rw-r--r--chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc6
-rw-r--r--chrome/browser/download/download_browsertest.cc15
-rw-r--r--chrome/browser/extensions/extension_infobar_delegate.cc2
-rw-r--r--chrome/browser/extensions/extension_install_ui_browsertest.cc8
-rw-r--r--chrome/browser/extensions/theme_installed_infobar_delegate.cc4
-rw-r--r--chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc124
-rw-r--r--chrome/browser/geolocation/geolocation_browsertest.cc4
-rw-r--r--chrome/browser/geolocation/geolocation_infobar_delegate.cc6
-rw-r--r--chrome/browser/google/google_url_tracker_infobar_delegate.cc4
-rw-r--r--chrome/browser/infobars/infobar_container.cc5
-rw-r--r--chrome/browser/infobars/infobar_delegate.cc2
-rw-r--r--chrome/browser/infobars/infobar_service.cc (renamed from chrome/browser/infobars/infobar_tab_helper.cc)117
-rw-r--r--chrome/browser/infobars/infobar_service.h70
-rw-r--r--chrome/browser/infobars/infobar_tab_helper.h69
-rw-r--r--chrome/browser/infobars/infobars_browsertest.cc4
-rw-r--r--chrome/browser/infobars/insecure_content_infobar_delegate.cc10
-rw-r--r--chrome/browser/managed_mode/managed_mode_browsertest.cc6
-rw-r--r--chrome/browser/managed_mode/managed_mode_navigation_observer.cc15
-rw-r--r--chrome/browser/media/media_stream_infobar_delegate.cc8
-rw-r--r--chrome/browser/notifications/notification_browsertest.cc15
-rw-r--r--chrome/browser/password_manager/password_manager_browsertest.cc2
-rw-r--r--chrome/browser/pepper_broker_infobar_delegate.cc2
-rw-r--r--chrome/browser/plugins/plugin_infobar_delegates.cc16
-rw-r--r--chrome/browser/policy/policy_browsertest.cc20
-rw-r--r--chrome/browser/ssl/ssl_tab_helper.cc4
-rw-r--r--chrome/browser/task_manager/task_manager_browsertest.cc6
-rw-r--r--chrome/browser/three_d_api_observer.cc4
-rw-r--r--chrome/browser/translate/options_menu_model.cc6
-rw-r--r--chrome/browser/translate/translate_infobar_delegate.cc28
-rw-r--r--chrome/browser/translate/translate_manager_browsertest.cc13
-rw-r--r--chrome/browser/ui/auto_login_infobar_delegate.cc6
-rw-r--r--chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm4
-rw-r--r--chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm6
-rw-r--r--chrome/browser/ui/collected_cookies_infobar_delegate.cc2
-rw-r--r--chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc3
-rw-r--r--chrome/browser/ui/content_settings/content_setting_changed_infobar_delegate.cc2
-rw-r--r--chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc6
-rw-r--r--chrome/browser/ui/gtk/infobars/infobar_gtk.cc2
-rw-r--r--chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.cc2
-rw-r--r--chrome/browser/ui/startup/obsolete_os_infobar_delegate.cc2
-rw-r--r--chrome/browser/ui/startup/startup_browser_creator_browsertest.cc6
-rw-r--r--chrome/browser/ui/sync/one_click_signin_helper.cc6
-rw-r--r--chrome/browser/ui/views/external_tab_container_win.cc2
-rw-r--r--chrome/browser/ui/website_settings/website_settings_infobar_delegate.cc2
-rw-r--r--chrome/browser/ui/website_settings/website_settings_unittest.cc11
-rw-r--r--chrome/chrome_browser.gypi3
-rw-r--r--chrome/test/gpu/webgl_infobar_browsertest.cc13
52 files changed, 308 insertions, 403 deletions
diff --git a/chrome/browser/accessibility/accessibility_extension_api.cc b/chrome/browser/accessibility/accessibility_extension_api.cc
index b41615b..95ed9c2 100644
--- a/chrome/browser/accessibility/accessibility_extension_api.cc
+++ b/chrome/browser/accessibility/accessibility_extension_api.cc
@@ -213,10 +213,10 @@ bool AccessibilityGetAlertsForTabFunction::RunImpl() {
ListValue* alerts_value = new ListValue;
InfoBarService* infobar_service = InfoBarService::FromWebContents(contents);
- for (size_t i = 0; i < infobar_service->GetInfoBarCount(); ++i) {
+ for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
// TODO(hashimoto): Make other kind of alerts available. crosbug.com/24281
ConfirmInfoBarDelegate* confirm_infobar_delegate =
- infobar_service->GetInfoBarDelegateAt(i)->AsConfirmInfoBarDelegate();
+ infobar_service->infobar_at(i)->AsConfirmInfoBarDelegate();
if (confirm_infobar_delegate) {
DictionaryValue* alert_value = new DictionaryValue;
const string16 message_text = confirm_infobar_delegate->GetMessageText();
diff --git a/chrome/browser/autofill/autofill_browsertest.cc b/chrome/browser/autofill/autofill_browsertest.cc
index 11e6868..ed13d76 100644
--- a/chrome/browser/autofill/autofill_browsertest.cc
+++ b/chrome/browser/autofill/autofill_browsertest.cc
@@ -137,14 +137,8 @@ class WindowedPersonalDataManagerObserver
}
virtual ~WindowedPersonalDataManagerObserver() {
- if (!infobar_service_)
- return;
-
- InfoBarDelegate* infobar = NULL;
- if (infobar_service_->GetInfoBarCount() > 0 &&
- (infobar = infobar_service_->GetInfoBarDelegateAt(0))) {
- infobar_service_->RemoveInfoBar(infobar);
- }
+ if (infobar_service_ && infobar_service_->infobar_count() > 0)
+ infobar_service_->RemoveInfoBar(infobar_service_->infobar_at(0));
}
void Wait() {
@@ -176,7 +170,7 @@ class WindowedPersonalDataManagerObserver
// Accept in the infobar.
infobar_service_ = InfoBarService::FromWebContents(
browser_->tab_strip_model()->GetActiveWebContents());
- InfoBarDelegate* infobar = infobar_service_->GetInfoBarDelegateAt(0);
+ InfoBarDelegate* infobar = infobar_service_->infobar_at(0);
ConfirmInfoBarDelegate* confirm_infobar =
infobar->AsConfirmInfoBarDelegate();
@@ -985,8 +979,8 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, DISABLED_AutofillAfterTranslate) {
render_view_host(),
ChromeViewHostMsg_TranslateLanguageDetermined(0, "ja", true));
TranslateInfoBarDelegate* infobar = InfoBarService::FromWebContents(
- browser()->tab_strip_model()->GetActiveWebContents())->
- GetInfoBarDelegateAt(0)->AsTranslateInfoBarDelegate();
+ browser()->tab_strip_model()->GetActiveWebContents())->infobar_at(0)->
+ AsTranslateInfoBarDelegate();
ASSERT_TRUE(infobar != NULL);
EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE,
@@ -1220,7 +1214,7 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, InvalidCreditCardNumberIsNotAggregated) {
ASSERT_EQ(0u,
InfoBarService::FromWebContents(
browser()->tab_strip_model()->GetActiveWebContents())->
- GetInfoBarCount());
+ infobar_count());
}
// Test whitespaces and separator chars are stripped for valid CC numbers.
@@ -1443,7 +1437,7 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, CCInfoNotStoredWhenAutocompleteOff) {
ASSERT_EQ(0u,
InfoBarService::FromWebContents(
browser()->tab_strip_model()->GetActiveWebContents())->
- GetInfoBarCount());
+ infobar_count());
}
// http://crbug.com/150084
diff --git a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc b/chrome/browser/autofill/autofill_cc_infobar_delegate.cc
index 478d277..a0a0ddb 100644
--- a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc
+++ b/chrome/browser/autofill/autofill_cc_infobar_delegate.cc
@@ -108,8 +108,8 @@ string16 AutofillCCInfoBarDelegate::GetLinkText() const {
}
bool AutofillCCInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
- owner()->GetWebContents()->GetDelegate()->OpenURLFromTab(
- owner()->GetWebContents(),
+ owner()->web_contents()->GetDelegate()->OpenURLFromTab(
+ owner()->web_contents(),
content::OpenURLParams(
GURL(autofill::kHelpURL),
content::Referrer(),
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc
index 4f2a939..5b32841 100644
--- a/chrome/browser/automation/automation_provider_observers.cc
+++ b/chrome/browser/automation/automation_provider_observers.cc
@@ -1239,7 +1239,7 @@ void InfoBarCountObserver::Observe(
void InfoBarCountObserver::CheckCount() {
InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents_);
- if (infobar_service->GetInfoBarCount() != target_count_)
+ if (infobar_service->infobar_count() != target_count_)
return;
if (automation_) {
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index e7c74d1..9a45b7c 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -2099,9 +2099,9 @@ ListValue* TestingAutomationProvider::GetInfobarsInfo(WebContents* wc) {
// Each infobar may have different properties depending on the type.
ListValue* infobars = new ListValue;
InfoBarService* infobar_service = InfoBarService::FromWebContents(wc);
- for (size_t i = 0; i < infobar_service->GetInfoBarCount(); ++i) {
+ for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
DictionaryValue* infobar_item = new DictionaryValue;
- InfoBarDelegate* infobar = infobar_service->GetInfoBarDelegateAt(i);
+ InfoBarDelegate* infobar = infobar_service->infobar_at(i);
switch (infobar->GetInfoBarAutomationType()) {
case InfoBarDelegate::CONFIRM_INFOBAR:
infobar_item->SetString("type", "confirm_infobar");
@@ -2181,12 +2181,12 @@ void TestingAutomationProvider::PerformActionOnInfobar(
InfoBarDelegate* infobar = NULL;
size_t infobar_index = static_cast<size_t>(infobar_index_int);
- if (infobar_index >= infobar_service->GetInfoBarCount()) {
+ if (infobar_index >= infobar_service->infobar_count()) {
reply.SendError(base::StringPrintf("No such infobar at index %" PRIuS,
infobar_index));
return;
}
- infobar = infobar_service->GetInfoBarDelegateAt(infobar_index);
+ infobar = infobar_service->infobar_at(infobar_index);
if ("dismiss" == action) {
infobar->InfoBarDismissed();
diff --git a/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc b/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc
index 90e28db..b730712 100644
--- a/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc
+++ b/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc
@@ -29,9 +29,9 @@ void RegisterProtocolHandlerInfoBarDelegate::Create(
new RegisterProtocolHandlerInfoBarDelegate(infobar_service, registry,
handler));
- for (size_t i = 0; i < infobar_service->GetInfoBarCount(); ++i) {
+ for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
RegisterProtocolHandlerInfoBarDelegate* existing_delegate =
- infobar_service->GetInfoBarDelegateAt(i)->
+ infobar_service->infobar_at(i)->
AsRegisterProtocolHandlerInfoBarDelegate();
if ((existing_delegate != NULL) &&
existing_delegate->handler_.IsEquivalent(handler)) {
@@ -123,7 +123,7 @@ bool RegisterProtocolHandlerInfoBarDelegate::LinkClicked(
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK,
false);
- owner()->GetWebContents()->OpenURL(params);
+ owner()->web_contents()->OpenURL(params);
return false;
}
diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc
index 5ec91a2..b26b5a2 100644
--- a/chrome/browser/download/download_browsertest.cc
+++ b/chrome/browser/download/download_browsertest.cc
@@ -2681,17 +2681,14 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, TestMultipleDownloadsInfobar) {
InfoBarService* infobar_service = InfoBarService::FromWebContents(
browser()->tab_strip_model()->GetActiveWebContents());
// Verify that there is only one infobar.
- EXPECT_EQ(1u, infobar_service->GetInfoBarCount());
+ ASSERT_EQ(1u, infobar_service->infobar_count());
// Get the infobar at index 0.
- int infobar_index = 0;
- InfoBarDelegate* infobar =
- infobar_service->GetInfoBarDelegateAt(infobar_index);
- EXPECT_TRUE(infobar != NULL);
+ InfoBarDelegate* infobar = infobar_service->infobar_at(0);
+ ASSERT_TRUE(infobar != NULL);
- ConfirmInfoBarDelegate* confirm_infobar =
- infobar->AsConfirmInfoBarDelegate();
- EXPECT_TRUE(confirm_infobar != NULL);
+ ConfirmInfoBarDelegate* confirm_infobar = infobar->AsConfirmInfoBarDelegate();
+ ASSERT_TRUE(confirm_infobar != NULL);
// Verify multi download warning infobar message.
EXPECT_EQ(confirm_infobar->GetMessageText(),
@@ -2701,7 +2698,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, TestMultipleDownloadsInfobar) {
if (confirm_infobar->Accept())
infobar_service->RemoveInfoBar(infobar);
// Verify that there are no more infobars.
- EXPECT_EQ(0u, infobar_service->GetInfoBarCount());
+ EXPECT_EQ(0u, infobar_service->infobar_count());
// Waits for the download to complete.
downloads_observer->WaitForFinished();
diff --git a/chrome/browser/extensions/extension_infobar_delegate.cc b/chrome/browser/extensions/extension_infobar_delegate.cc
index 0c59ae2..6f215a0 100644
--- a/chrome/browser/extensions/extension_infobar_delegate.cc
+++ b/chrome/browser/extensions/extension_infobar_delegate.cc
@@ -47,7 +47,7 @@ ExtensionInfoBarDelegate::ExtensionInfoBarDelegate(
ExtensionProcessManager* manager =
extensions::ExtensionSystem::Get(browser->profile())->process_manager();
extension_host_.reset(manager->CreateInfobarHost(url, browser));
- extension_host_->SetAssociatedWebContents(infobar_service->GetWebContents());
+ extension_host_->SetAssociatedWebContents(infobar_service->web_contents());
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
content::Source<Profile>(browser->profile()));
diff --git a/chrome/browser/extensions/extension_install_ui_browsertest.cc b/chrome/browser/extensions/extension_install_ui_browsertest.cc
index be8173f..ef338fdd 100644
--- a/chrome/browser/extensions/extension_install_ui_browsertest.cc
+++ b/chrome/browser/extensions/extension_install_ui_browsertest.cc
@@ -31,12 +31,12 @@ class ExtensionInstallUIBrowserTest : public ExtensionBrowserTest {
ASSERT_TRUE(web_contents);
InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents);
- ASSERT_EQ(1U, infobar_service->GetInfoBarCount());
- ConfirmInfoBarDelegate* delegate = infobar_service->
- GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ ASSERT_EQ(1U, infobar_service->infobar_count());
+ ConfirmInfoBarDelegate* delegate =
+ infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate();
ASSERT_TRUE(delegate);
delegate->Cancel();
- ASSERT_EQ(0U, infobar_service->GetInfoBarCount());
+ ASSERT_EQ(0U, infobar_service->infobar_count());
}
// Install the given theme from the data dir and verify expected name.
diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.cc b/chrome/browser/extensions/theme_installed_infobar_delegate.cc
index 521dacf..941ef7d 100644
--- a/chrome/browser/extensions/theme_installed_infobar_delegate.cc
+++ b/chrome/browser/extensions/theme_installed_infobar_delegate.cc
@@ -48,8 +48,8 @@ void ThemeInstalledInfoBarDelegate::Create(
// First find any previous theme preview infobars.
InfoBarDelegate* old_delegate = NULL;
- for (size_t i = 0; i < infobar_service->GetInfoBarCount(); ++i) {
- InfoBarDelegate* delegate = infobar_service->GetInfoBarDelegateAt(i);
+ for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
+ InfoBarDelegate* delegate = infobar_service->infobar_at(i);
ThemeInstalledInfoBarDelegate* theme_infobar =
delegate->AsThemePreviewInfobarDelegate();
if (theme_infobar) {
diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
index 400269c..2e0de99 100644
--- a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
+++ b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
@@ -285,11 +285,11 @@ void GeolocationPermissionContextTests::TearDown() {
TEST_F(GeolocationPermissionContextTests, SinglePermission) {
GURL requesting_frame("http://www.example.com/geolocation");
NavigateAndCommit(requesting_frame);
- EXPECT_EQ(0U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
RequestGeolocationPermission(RequestID(0), requesting_frame);
- ASSERT_EQ(1U, infobar_service()->GetInfoBarCount());
+ ASSERT_EQ(1U, infobar_service()->infobar_count());
ConfirmInfoBarDelegate* infobar_0 =
- infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ infobar_service()->infobar_at(0)->AsConfirmInfoBarDelegate();
infobar_0->Cancel();
infobar_service()->RemoveInfoBar(infobar_0);
EXPECT_EQ(1U, closed_delegate_tracker_.size());
@@ -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_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
RequestGeolocationPermission(RequestID(0), requesting_frame);
- EXPECT_EQ(1U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(1U, infobar_service()->infobar_count());
ConfirmInfoBarDelegate* infobar_0 =
- infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ infobar_service()->infobar_at(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_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
RequestGeolocationPermission(RequestID(0), requesting_frame);
- EXPECT_EQ(1U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(1U, infobar_service()->infobar_count());
ConfirmInfoBarDelegate* infobar_1 =
- infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ infobar_service()->infobar_at(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_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
RequestGeolocationPermission(RequestID(0), requesting_frame);
- EXPECT_EQ(0U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
}
TEST_F(GeolocationPermissionContextTests, MasterEnabledGoogleAppsEnabled) {
GURL requesting_frame("http://www.example.com/geolocation");
NavigateAndCommit(requesting_frame);
MockGoogleLocationSettingsHelper::SetLocationStatus(true, true);
- EXPECT_EQ(0U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
RequestGeolocationPermission(RequestID(0), requesting_frame);
- EXPECT_EQ(1U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(1U, infobar_service()->infobar_count());
ConfirmInfoBarDelegate* infobar_0 =
- infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ infobar_service()->infobar_at(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_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
RequestGeolocationPermission(RequestID(0), requesting_frame);
- EXPECT_EQ(1U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(1U, infobar_service()->infobar_count());
ConfirmInfoBarDelegate* infobar_0 =
- infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ infobar_service()->infobar_at(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_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
// 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_service()->GetInfoBarCount());
+ ASSERT_EQ(1U, infobar_service()->infobar_count());
ConfirmInfoBarDelegate* infobar_0 =
- infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ infobar_service()->infobar_at(0)->AsConfirmInfoBarDelegate();
ASSERT_TRUE(infobar_0);
string16 text_0 = infobar_0->GetMessageText();
@@ -401,10 +401,10 @@ TEST_F(GeolocationPermissionContextTests, QueuedPermission) {
closed_delegate_tracker_.Clear();
delete infobar_0;
// Now we should have a new infobar for the second frame.
- ASSERT_EQ(1U, infobar_service()->GetInfoBarCount());
+ ASSERT_EQ(1U, infobar_service()->infobar_count());
ConfirmInfoBarDelegate* infobar_1 =
- infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ infobar_service()->infobar_at(0)->AsConfirmInfoBarDelegate();
ASSERT_TRUE(infobar_1);
string16 text_1 = infobar_1->GetMessageText();
EXPECT_NE(text_0, text_1);
@@ -417,7 +417,7 @@ TEST_F(GeolocationPermissionContextTests, QueuedPermission) {
EXPECT_EQ(1U, closed_delegate_tracker_.size());
EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_1));
delete infobar_1;
- EXPECT_EQ(0U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
// Ensure the persisted permissions are ok.
EXPECT_EQ(CONTENT_SETTING_ALLOW,
profile()->GetHostContentSettingsMap()->GetContentSetting(
@@ -437,11 +437,11 @@ TEST_F(GeolocationPermissionContextTests, QueuedPermission) {
TEST_F(GeolocationPermissionContextTests, PermissionForFileScheme) {
GURL requesting_frame("file://example/geolocation.html");
NavigateAndCommit(requesting_frame);
- EXPECT_EQ(0U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
RequestGeolocationPermission(RequestID(0), requesting_frame);
- EXPECT_EQ(1U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(1U, infobar_service()->infobar_count());
ConfirmInfoBarDelegate* infobar =
- infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ infobar_service()->infobar_at(0)->AsConfirmInfoBarDelegate();
ASSERT_TRUE(infobar);
// Accept the frame
infobar->Accept();
@@ -478,14 +478,14 @@ TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) {
NavigateAndCommit(requesting_frame_0);
- EXPECT_EQ(0U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
// Request permission for two frames.
RequestGeolocationPermission(RequestID(0), requesting_frame_0);
RequestGeolocationPermission(RequestID(1), requesting_frame_1);
- ASSERT_EQ(1U, infobar_service()->GetInfoBarCount());
+ ASSERT_EQ(1U, infobar_service()->infobar_count());
ConfirmInfoBarDelegate* infobar_0 =
- infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ infobar_service()->infobar_at(0)->AsConfirmInfoBarDelegate();
ASSERT_TRUE(infobar_0);
string16 text_0 = infobar_0->GetMessageText();
@@ -496,10 +496,10 @@ TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) {
EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0));
closed_delegate_tracker_.Clear();
delete infobar_0;
- ASSERT_EQ(1U, infobar_service()->GetInfoBarCount());
+ ASSERT_EQ(1U, infobar_service()->infobar_count());
ConfirmInfoBarDelegate* infobar_1 =
- infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ infobar_service()->infobar_at(0)->AsConfirmInfoBarDelegate();
ASSERT_TRUE(infobar_1);
string16 text_1 = infobar_1->GetMessageText();
EXPECT_NE(text_0, text_1);
@@ -512,7 +512,7 @@ TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) {
EXPECT_EQ(1U, closed_delegate_tracker_.size());
EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_1));
delete infobar_1;
- EXPECT_EQ(0U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
// Ensure the persisted permissions are ok.
EXPECT_EQ(CONTENT_SETTING_ASK,
profile()->GetHostContentSettingsMap()->GetContentSetting(
@@ -533,9 +533,9 @@ TEST_F(GeolocationPermissionContextTests, InvalidURL) {
GURL invalid_embedder("about:blank");
GURL requesting_frame;
NavigateAndCommit(invalid_embedder);
- EXPECT_EQ(0U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
RequestGeolocationPermission(RequestID(0), requesting_frame);
- EXPECT_EQ(0U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
CheckPermissionMessageSent(0, false);
}
@@ -546,22 +546,22 @@ TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) {
AddNewTab(url_b);
AddNewTab(url_a);
- EXPECT_EQ(0U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
RequestGeolocationPermission(RequestID(0), url_a);
- ASSERT_EQ(1U, infobar_service()->GetInfoBarCount());
+ ASSERT_EQ(1U, infobar_service()->infobar_count());
RequestGeolocationPermission(RequestIDForTab(0, 0), url_b);
- EXPECT_EQ(1U, infobar_service_for_tab(0)->GetInfoBarCount());
+ EXPECT_EQ(1U, infobar_service_for_tab(0)->infobar_count());
RequestGeolocationPermission(RequestIDForTab(1, 0), url_a);
- ASSERT_EQ(1U, infobar_service_for_tab(1)->GetInfoBarCount());
+ ASSERT_EQ(1U, infobar_service_for_tab(1)->infobar_count());
- ConfirmInfoBarDelegate* removed_infobar = infobar_service_for_tab(1)->
- GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ ConfirmInfoBarDelegate* removed_infobar =
+ infobar_service_for_tab(1)->infobar_at(0)->AsConfirmInfoBarDelegate();
// Accept the first tab.
ConfirmInfoBarDelegate* infobar_0 =
- infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ infobar_service()->infobar_at(0)->AsConfirmInfoBarDelegate();
ASSERT_TRUE(infobar_0);
infobar_0->Accept();
CheckPermissionMessageSent(0, true);
@@ -570,7 +570,7 @@ TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) {
EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0));
delete infobar_0;
// Now the infobar for the tab with the same origin should have gone.
- EXPECT_EQ(0U, infobar_service_for_tab(1)->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service_for_tab(1)->infobar_count());
CheckPermissionMessageSentForTab(1, 0, true);
EXPECT_TRUE(closed_delegate_tracker_.Contains(removed_infobar));
closed_delegate_tracker_.Clear();
@@ -578,9 +578,9 @@ TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) {
delete removed_infobar;
// But the other tab should still have the info bar...
- ASSERT_EQ(1U, infobar_service_for_tab(0)->GetInfoBarCount());
- ConfirmInfoBarDelegate* infobar_1 = infobar_service_for_tab(0)->
- GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count());
+ ConfirmInfoBarDelegate* infobar_1 =
+ infobar_service_for_tab(0)->infobar_at(0)->AsConfirmInfoBarDelegate();
infobar_1->Cancel();
infobar_service_for_tab(0)->RemoveInfoBar(infobar_1);
EXPECT_EQ(1U, closed_delegate_tracker_.size());
@@ -594,22 +594,22 @@ TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) {
NavigateAndCommit(url_a);
AddNewTab(url_a);
- EXPECT_EQ(0U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
RequestGeolocationPermission(RequestID(0), url_a);
- ASSERT_EQ(1U, infobar_service()->GetInfoBarCount());
+ ASSERT_EQ(1U, infobar_service()->infobar_count());
RequestGeolocationPermission(RequestIDForTab(0, 0), url_a);
- EXPECT_EQ(1U, infobar_service_for_tab(0)->GetInfoBarCount());
+ EXPECT_EQ(1U, infobar_service_for_tab(0)->infobar_count());
RequestGeolocationPermission(RequestIDForTab(0, 1), url_b);
- ASSERT_EQ(1U, infobar_service_for_tab(0)->GetInfoBarCount());
+ ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count());
ConfirmInfoBarDelegate* removed_infobar =
- infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ infobar_service()->infobar_at(0)->AsConfirmInfoBarDelegate();
// Accept the second tab.
- ConfirmInfoBarDelegate* infobar_0 = infobar_service_for_tab(0)->
- GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ ConfirmInfoBarDelegate* infobar_0 =
+ infobar_service_for_tab(0)->infobar_at(0)->AsConfirmInfoBarDelegate();
ASSERT_TRUE(infobar_0);
infobar_0->Accept();
CheckPermissionMessageSentForTab(0, 0, true);
@@ -618,7 +618,7 @@ TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) {
EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0));
delete infobar_0;
// Now the infobar for the tab with the same origin should have gone.
- EXPECT_EQ(0U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
CheckPermissionMessageSent(0, true);
EXPECT_TRUE(closed_delegate_tracker_.Contains(removed_infobar));
closed_delegate_tracker_.Clear();
@@ -626,11 +626,11 @@ TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) {
delete removed_infobar;
// And we should have the queued infobar displayed now.
- ASSERT_EQ(1U, infobar_service_for_tab(0)->GetInfoBarCount());
+ ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count());
// Accept the second infobar.
- ConfirmInfoBarDelegate* infobar_1 = infobar_service_for_tab(0)->
- GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ ConfirmInfoBarDelegate* infobar_1 =
+ infobar_service_for_tab(0)->infobar_at(0)->AsConfirmInfoBarDelegate();
ASSERT_TRUE(infobar_1);
infobar_1->Accept();
CheckPermissionMessageSentForTab(0, 1, true);
@@ -660,14 +660,14 @@ TEST_F(GeolocationPermissionContextTests, TabDestroyed) {
std::string()));
NavigateAndCommit(requesting_frame_0);
- EXPECT_EQ(0U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
// 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_service()->GetInfoBarCount());
+ ASSERT_EQ(1U, infobar_service()->infobar_count());
ConfirmInfoBarDelegate* infobar_0 =
- infobar_service()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ infobar_service()->infobar_at(0)->AsConfirmInfoBarDelegate();
ASSERT_TRUE(infobar_0);
// Delete the tab contents.
@@ -685,15 +685,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_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
// 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_service()->GetInfoBarCount());
- InfoBarDelegate* infobar_0 = infobar_service()->GetInfoBarDelegateAt(0);
+ ASSERT_EQ(1U, infobar_service()->infobar_count());
+ InfoBarDelegate* infobar_0 = infobar_service()->infobar_at(0);
ASSERT_TRUE(infobar_0);
// Ensure the infobar wouldn't expire for a navigation to the committed entry.
content::LoadCommittedDetails details;
diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc
index f10b327..ffab305 100644
--- a/chrome/browser/geolocation/geolocation_browsertest.cc
+++ b/chrome/browser/geolocation/geolocation_browsertest.cc
@@ -583,10 +583,10 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest,
InfoBarService* infobar_service = InfoBarService::FromWebContents(
current_browser_->tab_strip_model()->GetActiveWebContents());
- size_t num_infobars_before_cancel = infobar_service->GetInfoBarCount();
+ size_t num_infobars_before_cancel = infobar_service->infobar_count();
// 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_service->GetInfoBarCount();
+ size_t num_infobars_after_cancel = infobar_service->infobar_count();
EXPECT_EQ(num_infobars_before_cancel, num_infobars_after_cancel + 1);
}
diff --git a/chrome/browser/geolocation/geolocation_infobar_delegate.cc b/chrome/browser/geolocation/geolocation_infobar_delegate.cc
index 47cb102..3d477a1 100644
--- a/chrome/browser/geolocation/geolocation_infobar_delegate.cc
+++ b/chrome/browser/geolocation/geolocation_infobar_delegate.cc
@@ -49,7 +49,7 @@ GeolocationInfoBarDelegate::GeolocationInfoBarDelegate(
requesting_frame_(requesting_frame),
display_languages_(display_languages) {
const content::NavigationEntry* committed_entry = infobar_service->
- GetWebContents()->GetController().GetLastCommittedEntry();
+ web_contents()->GetController().GetLastCommittedEntry();
contents_unique_id_ = committed_entry ? committed_entry->GetUniqueID() : 0;
}
@@ -87,7 +87,7 @@ string16 GeolocationInfoBarDelegate::GetButtonLabel(
void GeolocationInfoBarDelegate::SetPermission(bool update_content_setting,
bool allowed) {
controller_->OnPermissionSet(id_, requesting_frame_,
- owner()->GetWebContents()->GetURL(),
+ owner()->web_contents()->GetURL(),
update_content_setting, allowed);
}
@@ -119,6 +119,6 @@ bool GeolocationInfoBarDelegate::LinkClicked(
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false);
- owner()->GetWebContents()->OpenURL(params);
+ owner()->web_contents()->OpenURL(params);
return false; // Do not dismiss the info bar.
}
diff --git a/chrome/browser/google/google_url_tracker_infobar_delegate.cc b/chrome/browser/google/google_url_tracker_infobar_delegate.cc
index 29d5a7c..584772b 100644
--- a/chrome/browser/google/google_url_tracker_infobar_delegate.cc
+++ b/chrome/browser/google/google_url_tracker_infobar_delegate.cc
@@ -48,7 +48,7 @@ bool GoogleURLTrackerInfoBarDelegate::LinkClicked(
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false);
- owner()->GetWebContents()->OpenURL(params);
+ owner()->web_contents()->OpenURL(params);
return false;
}
@@ -73,7 +73,7 @@ void GoogleURLTrackerInfoBarDelegate::Close(bool redo_search) {
replacements.SetHost(host.data(), url_parse::Component(0, host.length()));
GURL new_search_url(search_url_.ReplaceComponents(replacements));
if (new_search_url.is_valid()) {
- owner()->GetWebContents()->OpenURL(content::OpenURLParams(
+ owner()->web_contents()->OpenURL(content::OpenURLParams(
new_search_url, content::Referrer(), CURRENT_TAB,
content::PAGE_TRANSITION_GENERATED, false));
}
diff --git a/chrome/browser/infobars/infobar_container.cc b/chrome/browser/infobars/infobar_container.cc
index 1829c9e..bb13a07 100644
--- a/chrome/browser/infobars/infobar_container.cc
+++ b/chrome/browser/infobars/infobar_container.cc
@@ -70,12 +70,11 @@ void InfoBarContainer::ChangeInfoBarService(InfoBarService* infobar_service) {
registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED,
source);
- for (size_t i = 0; i < infobar_service_->GetInfoBarCount(); ++i) {
+ for (size_t i = 0; i < infobar_service_->infobar_count(); ++i) {
// As when we removed the infobars above, we prevent callbacks to
// OnInfoBarAnimated() for each infobar.
AddInfoBar(
- infobar_service_->GetInfoBarDelegateAt(i)->CreateInfoBar(
- infobar_service_),
+ infobar_service_->infobar_at(i)->CreateInfoBar(infobar_service_),
i, false, NO_CALLBACK);
}
}
diff --git a/chrome/browser/infobars/infobar_delegate.cc b/chrome/browser/infobars/infobar_delegate.cc
index 4f1b366..7adffd8 100644
--- a/chrome/browser/infobars/infobar_delegate.cc
+++ b/chrome/browser/infobars/infobar_delegate.cc
@@ -99,7 +99,7 @@ InfoBarDelegate::InfoBarDelegate(InfoBarService* infobar_service)
}
void InfoBarDelegate::StoreActiveEntryUniqueID() {
- content::WebContents* web_contents = owner_->GetWebContents();
+ content::WebContents* web_contents = owner_->web_contents();
DCHECK(web_contents);
NavigationEntry* active_entry =
web_contents->GetController().GetActiveEntry();
diff --git a/chrome/browser/infobars/infobar_tab_helper.cc b/chrome/browser/infobars/infobar_service.cc
index 36b41af..ad478ae 100644
--- a/chrome/browser/infobars/infobar_tab_helper.cc
+++ b/chrome/browser/infobars/infobar_service.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/infobars/infobar_tab_helper.h"
+#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/infobars/infobar.h"
#include "chrome/browser/infobars/infobar_delegate.h"
@@ -13,54 +13,10 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h"
-using content::NavigationController;
-using content::WebContents;
-DEFINE_WEB_CONTENTS_USER_DATA_KEY(InfoBarTabHelper);
+DEFINE_WEB_CONTENTS_USER_DATA_KEY(InfoBarService);
-void InfoBarService::CreateForWebContents(content::WebContents* web_contents) {
- return content::WebContentsUserData<InfoBarTabHelper>::CreateForWebContents(
- web_contents);
-}
-
-InfoBarService* InfoBarService::FromWebContents(WebContents* 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)
- : content::WebContentsObserver(web_contents),
- infobars_enabled_(true) {
- DCHECK(web_contents);
- registrar_.Add(this,
- content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
- content::Source<WebContents>(web_contents));
-}
-
-InfoBarTabHelper::~InfoBarTabHelper() {
- // Destroy all remaining InfoBars. It's important to not animate here so that
- // we guarantee that we'll delete all delegates before we do anything else.
- //
- // TODO(pkasting): If there is no InfoBarContainer, this leaks all the
- // InfoBarDelegates. This will be fixed once we call CloseSoon() directly on
- // Infobars.
- RemoveAllInfoBars(false);
-}
-
-void InfoBarTabHelper::SetInfoBarsEnabled(bool enabled) {
- infobars_enabled_ = enabled;
-}
-
-InfoBarDelegate* InfoBarTabHelper::AddInfoBar(
+InfoBarDelegate* InfoBarService::AddInfoBar(
scoped_ptr<InfoBarDelegate> delegate) {
if (!infobars_enabled_)
return NULL;
@@ -73,7 +29,7 @@ InfoBarDelegate* InfoBarTabHelper::AddInfoBar(
}
}
- // TODO(pkasting): Consider removing InfoBarTabHelper arg from delegate
+ // TODO(pkasting): Consider removing InfoBarService arg from delegate
// constructors and instead using a setter from here.
InfoBarDelegate* delegate_ptr = delegate.release();
infobars_.push_back(delegate_ptr);
@@ -83,7 +39,7 @@ InfoBarDelegate* InfoBarTabHelper::AddInfoBar(
if (infobars_.size() == 1) {
registrar_.Add(
this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
- content::Source<NavigationController>(
+ content::Source<content::NavigationController>(
&web_contents()->GetController()));
}
@@ -94,11 +50,11 @@ InfoBarDelegate* InfoBarTabHelper::AddInfoBar(
return delegate_ptr;
}
-void InfoBarTabHelper::RemoveInfoBar(InfoBarDelegate* delegate) {
+void InfoBarService::RemoveInfoBar(InfoBarDelegate* delegate) {
RemoveInfoBarInternal(delegate, true);
}
-InfoBarDelegate* InfoBarTabHelper::ReplaceInfoBar(
+InfoBarDelegate* InfoBarService::ReplaceInfoBar(
InfoBarDelegate* old_delegate,
scoped_ptr<InfoBarDelegate> new_delegate) {
if (!infobars_enabled_)
@@ -123,25 +79,32 @@ InfoBarDelegate* InfoBarTabHelper::ReplaceInfoBar(
return new_delegate_ptr;
}
-size_t InfoBarTabHelper::GetInfoBarCount() const {
- return infobars_.size();
-}
-
-InfoBarDelegate* InfoBarTabHelper::GetInfoBarDelegateAt(size_t index) {
- return infobars_[index];
+InfoBarService::InfoBarService(content::WebContents* web_contents)
+ : content::WebContentsObserver(web_contents),
+ infobars_enabled_(true) {
+ DCHECK(web_contents);
+ registrar_.Add(this,
+ content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
+ content::Source<content::WebContents>(web_contents));
}
-content::WebContents* InfoBarTabHelper::GetWebContents() {
- return content::WebContentsObserver::web_contents();
+InfoBarService::~InfoBarService() {
+ // Destroy all remaining InfoBars. It's important to not animate here so that
+ // we guarantee that we'll delete all delegates before we do anything else.
+ //
+ // TODO(pkasting): If there is no InfoBarContainer, this leaks all the
+ // InfoBarDelegates. This will be fixed once we call CloseSoon() directly on
+ // Infobars.
+ RemoveAllInfoBars(false);
}
-void InfoBarTabHelper::RenderViewGone(base::TerminationStatus status) {
+void InfoBarService::RenderViewGone(base::TerminationStatus status) {
RemoveAllInfoBars(true);
}
-bool InfoBarTabHelper::OnMessageReceived(const IPC::Message& message) {
+bool InfoBarService::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(InfoBarTabHelper, message)
+ IPC_BEGIN_MESSAGE_MAP(InfoBarService, message)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidBlockDisplayingInsecureContent,
OnDidBlockDisplayingInsecureContent)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidBlockRunningInsecureContent,
@@ -151,12 +114,12 @@ bool InfoBarTabHelper::OnMessageReceived(const IPC::Message& message) {
return handled;
}
-void InfoBarTabHelper::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
+void InfoBarService::Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) {
DCHECK(&web_contents()->GetController() ==
- content::Source<NavigationController>(source).ptr());
+ content::Source<content::NavigationController>(source).ptr());
content::LoadCommittedDetails& committed_details =
*(content::Details<content::LoadCommittedDetails>(details).ptr());
@@ -165,7 +128,7 @@ void InfoBarTabHelper::Observe(int type,
// use iterators, as the RemoveInfoBar() call synchronously modifies our
// delegate list.
for (size_t i = infobars_.size(); i > 0; --i) {
- InfoBarDelegate* delegate = GetInfoBarDelegateAt(i - 1);
+ InfoBarDelegate* delegate = infobars_[i - 1];
if (delegate->ShouldExpire(committed_details))
RemoveInfoBar(delegate);
}
@@ -177,14 +140,16 @@ void InfoBarTabHelper::Observe(int type,
// The WebContents is going away; be aggressively paranoid and delete
// ourselves lest other parts of the system attempt to add infobars or use
// us otherwise during the destruction.
- DCHECK_EQ(web_contents(), content::Source<WebContents>(source).ptr());
+ DCHECK_EQ(web_contents(),
+ content::Source<content::WebContents>(source).ptr());
web_contents()->RemoveUserData(UserDataKey());
// That was the equivalent of "delete this". This object is now destroyed;
// returning from this function is the only safe thing to do.
return;
}
-void InfoBarTabHelper::RemoveInfoBarInternal(InfoBarDelegate* delegate,
- bool animate) {
+
+void InfoBarService::RemoveInfoBarInternal(InfoBarDelegate* delegate,
+ bool animate) {
if (!infobars_enabled_) {
DCHECK(infobars_.empty());
return;
@@ -201,7 +166,7 @@ void InfoBarTabHelper::RemoveInfoBarInternal(InfoBarDelegate* delegate,
if (infobars_.empty()) {
registrar_.Remove(
this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
- content::Source<NavigationController>(
+ content::Source<content::NavigationController>(
&web_contents()->GetController()));
}
@@ -212,17 +177,17 @@ void InfoBarTabHelper::RemoveInfoBarInternal(InfoBarDelegate* delegate,
content::Details<InfoBarRemovedDetails>(&removed_details));
}
-void InfoBarTabHelper::RemoveAllInfoBars(bool animate) {
+void InfoBarService::RemoveAllInfoBars(bool animate) {
while (!infobars_.empty())
- RemoveInfoBarInternal(GetInfoBarDelegateAt(GetInfoBarCount() - 1), animate);
+ RemoveInfoBarInternal(infobars_.back(), animate);
}
-void InfoBarTabHelper::OnDidBlockDisplayingInsecureContent() {
+void InfoBarService::OnDidBlockDisplayingInsecureContent() {
InsecureContentInfoBarDelegate::Create(
this, InsecureContentInfoBarDelegate::DISPLAY);
}
-void InfoBarTabHelper::OnDidBlockRunningInsecureContent() {
+void InfoBarService::OnDidBlockRunningInsecureContent() {
InsecureContentInfoBarDelegate::Create(this,
InsecureContentInfoBarDelegate::RUN);
}
diff --git a/chrome/browser/infobars/infobar_service.h b/chrome/browser/infobars/infobar_service.h
index cab8149..5ea6ce0 100644
--- a/chrome/browser/infobars/infobar_service.h
+++ b/chrome/browser/infobars/infobar_service.h
@@ -5,7 +5,13 @@
#ifndef CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_
#define CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_
+#include <vector>
+
#include "base/memory/scoped_ptr.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+#include "content/public/browser/web_contents_observer.h"
+#include "content/public/browser/web_contents_user_data.h"
namespace content {
class WebContents;
@@ -15,19 +21,12 @@ class InfoBarDelegate;
// Provides access to creating, removing and enumerating info bars
// attached to a tab.
-class InfoBarService {
+class InfoBarService : public content::WebContentsObserver,
+ public content::NotificationObserver,
+ public content::WebContentsUserData<InfoBarService> {
public:
- // 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();
-
// Changes whether infobars are enabled. The default is true.
- virtual void SetInfoBarsEnabled(bool enabled) = 0;
+ void set_infobars_enabled(bool enabled) { infobars_enabled_ = enabled; }
// Adds an InfoBar for the specified |delegate|.
//
@@ -36,14 +35,14 @@ class InfoBarService {
// |delegate| is closed immediately without being added.
//
// Returns the delegate if it was successfully added.
- virtual InfoBarDelegate* AddInfoBar(scoped_ptr<InfoBarDelegate> delegate) = 0;
+ InfoBarDelegate* AddInfoBar(scoped_ptr<InfoBarDelegate> delegate);
// Removes the InfoBar for the specified |delegate|.
//
// If infobars are disabled for this tab, this will do nothing, on the
// assumption that the matching AddInfoBar() call will have already closed the
// delegate (see above).
- virtual void RemoveInfoBar(InfoBarDelegate* delegate) = 0;
+ void RemoveInfoBar(InfoBarDelegate* delegate);
// Replaces one infobar with another, without any animation in between.
//
@@ -53,21 +52,54 @@ class InfoBarService {
// Returns the new delegate if it was successfully added.
//
// NOTE: This does not perform any EqualsDelegate() checks like AddInfoBar().
- virtual InfoBarDelegate* ReplaceInfoBar(
- InfoBarDelegate* old_delegate,
- scoped_ptr<InfoBarDelegate> new_delegate) = 0;
+ InfoBarDelegate* ReplaceInfoBar(InfoBarDelegate* old_delegate,
+ scoped_ptr<InfoBarDelegate> new_delegate);
// Returns the number of infobars for this tab.
- virtual size_t GetInfoBarCount() const = 0;
+ size_t infobar_count() const { return infobars_.size(); }
// Returns the infobar delegate at the given |index|. The InfoBarService
// retains ownership.
//
// Warning: Does not sanity check |index|.
- virtual InfoBarDelegate* GetInfoBarDelegateAt(size_t index) = 0;
+ InfoBarDelegate* infobar_at(size_t index) { return infobars_[index]; }
// Retrieve the WebContents for the tab this service is associated with.
- virtual content::WebContents* GetWebContents() = 0;
+ content::WebContents* web_contents() {
+ return content::WebContentsObserver::web_contents();
+ }
+
+ private:
+ friend class content::WebContentsUserData<InfoBarService>;
+
+ typedef std::vector<InfoBarDelegate*> InfoBars;
+
+ explicit InfoBarService(content::WebContents* web_contents);
+ virtual ~InfoBarService();
+
+ // content::WebContentsObserver:
+ virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
+ // content::NotificationObserver:
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ void RemoveInfoBarInternal(InfoBarDelegate* delegate, bool animate);
+ void RemoveAllInfoBars(bool animate);
+
+ // Message handlers.
+ void OnDidBlockDisplayingInsecureContent();
+ void OnDidBlockRunningInsecureContent();
+
+ // Delegates for InfoBars associated with this InfoBarService.
+ InfoBars infobars_;
+ bool infobars_enabled_;
+
+ content::NotificationRegistrar registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(InfoBarService);
};
#endif // CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_
diff --git a/chrome/browser/infobars/infobar_tab_helper.h b/chrome/browser/infobars/infobar_tab_helper.h
deleted file mode 100644
index 2ee9f6e..0000000
--- a/chrome/browser/infobars/infobar_tab_helper.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_INFOBARS_INFOBAR_TAB_HELPER_H_
-#define CHROME_BROWSER_INFOBARS_INFOBAR_TAB_HELPER_H_
-
-#include <vector>
-
-#include "base/basictypes.h"
-#include "chrome/browser/infobars/infobar_service.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
-#include "content/public/browser/web_contents_observer.h"
-#include "content/public/browser/web_contents_user_data.h"
-
-class InfoBarDelegate;
-
-// Per-tab info bar manager.
-class InfoBarTabHelper : public InfoBarService,
- public content::WebContentsObserver,
- public content::NotificationObserver,
- public content::WebContentsUserData<InfoBarTabHelper> {
- private:
- friend class content::WebContentsUserData<InfoBarTabHelper>;
-
- typedef std::vector<InfoBarDelegate*> InfoBars;
-
- explicit InfoBarTabHelper(content::WebContents* web_contents);
- virtual ~InfoBarTabHelper();
-
- // InfoBarService:
- virtual void SetInfoBarsEnabled(bool enabled) OVERRIDE;
- virtual InfoBarDelegate* AddInfoBar(
- scoped_ptr<InfoBarDelegate> delegate) OVERRIDE;
- virtual void RemoveInfoBar(InfoBarDelegate* delegate) OVERRIDE;
- virtual InfoBarDelegate* ReplaceInfoBar(
- InfoBarDelegate* old_delegate,
- scoped_ptr<InfoBarDelegate> new_delegate) OVERRIDE;
- virtual size_t GetInfoBarCount() const OVERRIDE;
- virtual InfoBarDelegate* GetInfoBarDelegateAt(size_t index) OVERRIDE;
- virtual content::WebContents* GetWebContents() OVERRIDE;
-
- // content::WebContentsObserver:
- virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
-
- // content::NotificationObserver:
- virtual void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) OVERRIDE;
-
- void RemoveInfoBarInternal(InfoBarDelegate* delegate, bool animate);
- void RemoveAllInfoBars(bool animate);
-
- // Message handlers.
- void OnDidBlockDisplayingInsecureContent();
- void OnDidBlockRunningInsecureContent();
-
- // Delegates for InfoBars associated with this InfoBarTabHelper.
- InfoBars infobars_;
- bool infobars_enabled_;
-
- content::NotificationRegistrar registrar_;
-
- DISALLOW_COPY_AND_ASSIGN(InfoBarTabHelper);
-};
-
-#endif // CHROME_BROWSER_INFOBARS_INFOBAR_TAB_HELPER_H_
diff --git a/chrome/browser/infobars/infobars_browsertest.cc b/chrome/browser/infobars/infobars_browsertest.cc
index c833a67..ed807a0 100644
--- a/chrome/browser/infobars/infobars_browsertest.cc
+++ b/chrome/browser/infobars/infobars_browsertest.cc
@@ -76,7 +76,7 @@ IN_PROC_BROWSER_TEST_F(InfoBarsTest, TestInfoBarsCloseOnNewTheme) {
infobar_removed_1.Wait();
EXPECT_EQ(0u,
InfoBarService::FromWebContents(browser()->tab_strip_model()->
- GetWebContentsAt(0))->GetInfoBarCount());
+ GetWebContentsAt(0))->infobar_count());
content::WindowedNotificationObserver infobar_removed_2(
chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
@@ -85,5 +85,5 @@ IN_PROC_BROWSER_TEST_F(InfoBarsTest, TestInfoBarsCloseOnNewTheme) {
infobar_removed_2.Wait();
EXPECT_EQ(0u,
InfoBarService::FromWebContents(browser()->tab_strip_model()->
- GetActiveWebContents())->GetInfoBarCount());
+ GetActiveWebContents())->infobar_count());
}
diff --git a/chrome/browser/infobars/insecure_content_infobar_delegate.cc b/chrome/browser/infobars/insecure_content_infobar_delegate.cc
index 4cef78e..ea136c9 100644
--- a/chrome/browser/infobars/insecure_content_infobar_delegate.cc
+++ b/chrome/browser/infobars/insecure_content_infobar_delegate.cc
@@ -24,9 +24,9 @@ void InsecureContentInfoBarDelegate::Create(InfoBarService* infobar_service,
// Only supsersede an existing insecure content infobar if we are upgrading
// from DISPLAY to RUN.
- for (size_t i = 0; i < infobar_service->GetInfoBarCount(); ++i) {
- InsecureContentInfoBarDelegate* delegate = infobar_service->
- GetInfoBarDelegateAt(i)->AsInsecureContentInfoBarDelegate();
+ for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
+ InsecureContentInfoBarDelegate* delegate =
+ infobar_service->infobar_at(i)->AsInsecureContentInfoBarDelegate();
if (delegate != NULL) {
if ((type == RUN) && (delegate->type_ == DISPLAY))
return;
@@ -91,7 +91,7 @@ bool InsecureContentInfoBarDelegate::Cancel() {
(type_ == DISPLAY) ? DISPLAY_USER_OVERRIDE : RUN_USER_OVERRIDE,
NUM_EVENTS);
- content::WebContents* web_contents = owner()->GetWebContents();
+ content::WebContents* web_contents = owner()->web_contents();
if (web_contents) {
int32 routing_id = web_contents->GetRoutingID();
web_contents->Send((type_ == DISPLAY) ?
@@ -110,7 +110,7 @@ string16 InsecureContentInfoBarDelegate::GetLinkText() const {
bool InsecureContentInfoBarDelegate::LinkClicked(
WindowOpenDisposition disposition) {
- owner()->GetWebContents()->OpenURL(OpenURLParams(
+ owner()->web_contents()->OpenURL(OpenURLParams(
google_util::AppendGoogleLocaleParam(GURL(
"https://www.google.com/support/chrome/bin/answer.py?answer=1342714")),
content::Referrer(),
diff --git a/chrome/browser/managed_mode/managed_mode_browsertest.cc b/chrome/browser/managed_mode/managed_mode_browsertest.cc
index d3a53d6..f9aa4b4 100644
--- a/chrome/browser/managed_mode/managed_mode_browsertest.cc
+++ b/chrome/browser/managed_mode/managed_mode_browsertest.cc
@@ -8,7 +8,7 @@
#include "base/values.h"
#include "chrome/browser/infobars/confirm_infobar_delegate.h"
#include "chrome/browser/infobars/infobar.h"
-#include "chrome/browser/infobars/infobar_tab_helper.h"
+#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/managed_mode/managed_mode.h"
#include "chrome/browser/managed_mode/managed_mode_interstitial.h"
#include "chrome/browser/managed_mode/managed_mode_navigation_observer.h"
@@ -131,9 +131,9 @@ class ManagedModeBlockModeTest : public InProcessBrowserTest {
InfoBarService* service = InfoBarService::FromWebContents(
browser()->tab_strip_model()->GetActiveWebContents());
- for (unsigned int i = 0; i < service->GetInfoBarCount(); ++i) {
+ for (size_t i = 0; i < service->infobar_count(); ++i) {
ConfirmInfoBarDelegate* delegate =
- service->GetInfoBarDelegateAt(i)->AsConfirmInfoBarDelegate();
+ service->infobar_at(i)->AsConfirmInfoBarDelegate();
if (delegate->GetMessageText() == l10n_util::GetStringUTF16(message_id))
return true;
}
diff --git a/chrome/browser/managed_mode/managed_mode_navigation_observer.cc b/chrome/browser/managed_mode/managed_mode_navigation_observer.cc
index 35911f9..359d29d 100644
--- a/chrome/browser/managed_mode/managed_mode_navigation_observer.cc
+++ b/chrome/browser/managed_mode/managed_mode_navigation_observer.cc
@@ -138,7 +138,7 @@ string16 ManagedModeWarningInfobarDelegate::GetButtonLabel(
}
bool ManagedModeWarningInfobarDelegate::Accept() {
- GoBackToSafety(owner()->GetWebContents());
+ GoBackToSafety(owner()->web_contents());
return false;
}
@@ -156,7 +156,7 @@ bool ManagedModeWarningInfobarDelegate::ShouldExpire(
void ManagedModeWarningInfobarDelegate::InfoBarDismissed() {
ManagedModeNavigationObserver* observer =
- ManagedModeNavigationObserver::FromWebContents(owner()->GetWebContents());
+ ManagedModeNavigationObserver::FromWebContents(owner()->web_contents());
observer->WarnInfobarDismissed();
}
@@ -216,8 +216,7 @@ string16 ManagedModePreviewInfobarDelegate::GetButtonLabel(
bool ManagedModePreviewInfobarDelegate::Accept() {
ManagedModeNavigationObserver* observer =
- ManagedModeNavigationObserver::FromWebContents(
- owner()->GetWebContents());
+ ManagedModeNavigationObserver::FromWebContents(owner()->web_contents());
UMA_HISTOGRAM_ENUMERATION("ManagedMode.PreviewInfobarCommand",
INFOBAR_ACCEPT,
INFOBAR_HISTOGRAM_BOUNDING_VALUE);
@@ -227,12 +226,11 @@ bool ManagedModePreviewInfobarDelegate::Accept() {
bool ManagedModePreviewInfobarDelegate::Cancel() {
ManagedModeNavigationObserver* observer =
- ManagedModeNavigationObserver::FromWebContents(
- owner()->GetWebContents());
+ ManagedModeNavigationObserver::FromWebContents(owner()->web_contents());
UMA_HISTOGRAM_ENUMERATION("ManagedMode.PreviewInfobarCommand",
INFOBAR_CANCEL,
INFOBAR_HISTOGRAM_BOUNDING_VALUE);
- GoBackToSafety(owner()->GetWebContents());
+ GoBackToSafety(owner()->web_contents());
observer->ClearObserverState();
return false;
}
@@ -245,8 +243,7 @@ bool ManagedModePreviewInfobarDelegate::ShouldExpire(
void ManagedModePreviewInfobarDelegate::InfoBarDismissed() {
ManagedModeNavigationObserver* observer =
- ManagedModeNavigationObserver::FromWebContents(
- owner()->GetWebContents());
+ ManagedModeNavigationObserver::FromWebContents(owner()->web_contents());
observer->PreviewInfobarDismissed();
}
diff --git a/chrome/browser/media/media_stream_infobar_delegate.cc b/chrome/browser/media/media_stream_infobar_delegate.cc
index ddfaaaf..eccedd2 100644
--- a/chrome/browser/media/media_stream_infobar_delegate.cc
+++ b/chrome/browser/media/media_stream_infobar_delegate.cc
@@ -38,9 +38,9 @@ bool MediaStreamInfoBarDelegate::Create(
InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents);
InfoBarDelegate* old_infobar = NULL;
- for (size_t i = 0; i < infobar_service->GetInfoBarCount(); ++i) {
- old_infobar = infobar_service->GetInfoBarDelegateAt(i)->
- AsMediaStreamInfoBarDelegate();
+ for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
+ old_infobar =
+ infobar_service->infobar_at(i)->AsMediaStreamInfoBarDelegate();
if (old_infobar)
break;
}
@@ -114,7 +114,7 @@ bool MediaStreamInfoBarDelegate::LinkClicked(
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK,
false);
- owner()->GetWebContents()->OpenURL(params);
+ owner()->web_contents()->OpenURL(params);
return false; // Do not dismiss the info bar.
}
diff --git a/chrome/browser/notifications/notification_browsertest.cc b/chrome/browser/notifications/notification_browsertest.cc
index 109a447..d8a839d 100644
--- a/chrome/browser/notifications/notification_browsertest.cc
+++ b/chrome/browser/notifications/notification_browsertest.cc
@@ -344,8 +344,8 @@ void NotificationsTest::VerifyInfobar(const Browser* browser, int index) {
InfoBarService* infobar_service = InfoBarService::FromWebContents(
browser->tab_strip_model()->GetWebContentsAt(index));
- ASSERT_EQ(1U, infobar_service->GetInfoBarCount());
- InfoBarDelegate* infobar = infobar_service->GetInfoBarDelegateAt(0);
+ ASSERT_EQ(1U, infobar_service->infobar_count());
+ InfoBarDelegate* infobar = infobar_service->infobar_at(0);
ConfirmInfoBarDelegate* confirm_infobar = infobar->AsConfirmInfoBarDelegate();
ASSERT_TRUE(confirm_infobar);
int buttons = confirm_infobar->GetButtons();
@@ -428,8 +428,7 @@ bool NotificationsTest::PerformActionOnInfobar(
InfoBarService* infobar_service = InfoBarService::FromWebContents(
browser->tab_strip_model()->GetWebContentsAt(tab_index));
- InfoBarDelegate* infobar =
- infobar_service->GetInfoBarDelegateAt(infobar_index);
+ InfoBarDelegate* infobar = infobar_service->infobar_at(infobar_index);
switch (action) {
case DISMISS:
infobar->InfoBarDismissed();
@@ -510,7 +509,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsTest, TestUserGestureInfobar) {
EXPECT_TRUE(result);
EXPECT_EQ(1U, InfoBarService::FromWebContents(
- browser()->tab_strip_model()->GetWebContentsAt(0))->GetInfoBarCount());
+ browser()->tab_strip_model()->GetWebContentsAt(0))->infobar_count());
}
// If this flakes, use http://crbug.com/62311.
@@ -523,7 +522,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsTest, TestNoUserGestureInfobar) {
"files/notifications/notifications_request_inline.html"));
EXPECT_EQ(0U, InfoBarService::FromWebContents(
- browser()->tab_strip_model()->GetWebContentsAt(0))->GetInfoBarCount());
+ browser()->tab_strip_model()->GetWebContentsAt(0))->infobar_count());
}
IN_PROC_BROWSER_TEST_F(NotificationsTest, TestCreateSimpleNotification) {
@@ -675,7 +674,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsTest, TestAllowNotificationsFromAllSites) {
ASSERT_EQ(1, GetNotificationCount());
EXPECT_EQ(0U, InfoBarService::FromWebContents(
- browser()->tab_strip_model()->GetWebContentsAt(0))->GetInfoBarCount());
+ browser()->tab_strip_model()->GetWebContentsAt(0))->infobar_count());
}
IN_PROC_BROWSER_TEST_F(NotificationsTest, TestDenyNotificationsFromAllSites) {
@@ -744,7 +743,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsTest, TestDenyAndThenAllowDomain) {
ASSERT_EQ(1, GetNotificationCount());
EXPECT_EQ(0U, InfoBarService::FromWebContents(
- browser()->tab_strip_model()->GetWebContentsAt(0))->GetInfoBarCount());
+ browser()->tab_strip_model()->GetWebContentsAt(0))->infobar_count());
}
IN_PROC_BROWSER_TEST_F(NotificationsTest, TestCreateDenyCloseNotifications) {
diff --git a/chrome/browser/password_manager/password_manager_browsertest.cc b/chrome/browser/password_manager/password_manager_browsertest.cc
index 7a4596e..c340342 100644
--- a/chrome/browser/password_manager/password_manager_browsertest.cc
+++ b/chrome/browser/password_manager/password_manager_browsertest.cc
@@ -52,7 +52,7 @@ class NavigationObserver : public content::NotificationObserver,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE {
// Accept in the infobar.
- InfoBarDelegate* infobar = infobar_service_->GetInfoBarDelegateAt(0);
+ InfoBarDelegate* infobar = infobar_service_->infobar_at(0);
ConfirmInfoBarDelegate* confirm_infobar =
infobar->AsConfirmInfoBarDelegate();
confirm_infobar->Accept();
diff --git a/chrome/browser/pepper_broker_infobar_delegate.cc b/chrome/browser/pepper_broker_infobar_delegate.cc
index 597022b..6dfa3e1 100644
--- a/chrome/browser/pepper_broker_infobar_delegate.cc
+++ b/chrome/browser/pepper_broker_infobar_delegate.cc
@@ -158,7 +158,7 @@ bool PepperBrokerInfoBarDelegate::LinkClicked(
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK,
false);
- owner()->GetWebContents()->OpenURL(params);
+ owner()->web_contents()->OpenURL(params);
return false;
}
diff --git a/chrome/browser/plugins/plugin_infobar_delegates.cc b/chrome/browser/plugins/plugin_infobar_delegates.cc
index 81ba685..40ac60f 100644
--- a/chrome/browser/plugins/plugin_infobar_delegates.cc
+++ b/chrome/browser/plugins/plugin_infobar_delegates.cc
@@ -57,12 +57,12 @@ bool PluginInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK,
false);
- owner()->GetWebContents()->OpenURL(params);
+ owner()->web_contents()->OpenURL(params);
return false;
}
void PluginInfoBarDelegate::LoadBlockedPlugins() {
- content::WebContents* web_contents = owner()->GetWebContents();
+ content::WebContents* web_contents = owner()->web_contents();
if (web_contents) {
content::RenderViewHost* host = web_contents->GetRenderViewHost();
ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins(
@@ -149,8 +149,8 @@ bool UnauthorizedPluginInfoBarDelegate::Accept() {
bool UnauthorizedPluginInfoBarDelegate::Cancel() {
content::RecordAction(
UserMetricsAction("BlockedPluginInfobar.AlwaysAllow"));
- content_settings_->AddExceptionForURL(owner()->GetWebContents()->GetURL(),
- owner()->GetWebContents()->GetURL(),
+ content_settings_->AddExceptionForURL(owner()->web_contents()->GetURL(),
+ owner()->web_contents()->GetURL(),
CONTENT_SETTINGS_TYPE_PLUGINS,
std::string(),
CONTENT_SETTING_ALLOW);
@@ -252,7 +252,7 @@ bool OutdatedPluginInfoBarDelegate::Accept() {
return false;
}
- content::WebContents* web_contents = owner()->GetWebContents();
+ content::WebContents* web_contents = owner()->web_contents();
// A call to any of |OpenDownloadURL()| or |StartInstalling()| will
// result in deleting ourselves. Accordingly, we make sure to
// not pass a reference to an object that can go away.
@@ -429,7 +429,7 @@ bool PluginInstallerInfoBarDelegate::LinkClicked(
url, Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false);
- owner()->GetWebContents()->OpenURL(params);
+ owner()->web_contents()->OpenURL(params);
return false;
}
@@ -524,7 +524,7 @@ bool PluginMetroModeInfoBarDelegate::Accept() {
bool PluginMetroModeInfoBarDelegate::Cancel() {
DCHECK_EQ(DESKTOP_MODE_REQUIRED, mode_);
- content::WebContents* web_contents = owner()->GetWebContents();
+ content::WebContents* web_contents = owner()->web_contents();
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
HostContentSettingsMap* content_settings =
@@ -552,7 +552,7 @@ bool PluginMetroModeInfoBarDelegate::LinkClicked(
Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false);
- owner()->GetWebContents()->OpenURL(params);
+ owner()->web_contents()->OpenURL(params);
return false;
}
#endif // defined(OS_WIN)
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index 00fdce6..5ac8b2e 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -1102,15 +1102,14 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, AlwaysAuthorizePlugins) {
ASSERT_TRUE(contents);
InfoBarService* infobar_service = InfoBarService::FromWebContents(contents);
ASSERT_TRUE(infobar_service);
- EXPECT_EQ(0u, infobar_service->GetInfoBarCount());
+ EXPECT_EQ(0u, infobar_service->infobar_count());
base::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_service->GetInfoBarCount());
- InfoBarDelegate* infobar_delegate =
- infobar_service->GetInfoBarDelegateAt(0);
+ ASSERT_EQ(1u, infobar_service->infobar_count());
+ InfoBarDelegate* infobar_delegate = infobar_service->infobar_at(0);
EXPECT_TRUE(infobar_delegate->AsConfirmInfoBarDelegate());
// And the plugin isn't running.
EXPECT_EQ(0, CountPlugins());
@@ -1122,7 +1121,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, AlwaysAuthorizePlugins) {
UpdateProviderPolicy(policies);
// Reloading the page shouldn't trigger the infobar this time.
ui_test_utils::NavigateToURL(browser(), url);
- EXPECT_EQ(0u, infobar_service->GetInfoBarCount());
+ EXPECT_EQ(0u, infobar_service->infobar_count());
// And the plugin started automatically.
EXPECT_EQ(1, CountPlugins());
}
@@ -1518,7 +1517,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, MAYBE_TranslateEnabled) {
ASSERT_TRUE(contents);
InfoBarService* infobar_service = InfoBarService::FromWebContents(contents);
ASSERT_TRUE(infobar_service);
- EXPECT_EQ(0u, infobar_service->GetInfoBarCount());
+ EXPECT_EQ(0u, infobar_service->infobar_count());
// Force enable the translate feature.
PolicyMap policies;
@@ -1538,9 +1537,8 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, MAYBE_TranslateEnabled) {
ui_test_utils::NavigateToURL(browser(), url);
language_observer1.Wait();
// Verify that the translate infobar showed up.
- ASSERT_EQ(1u, infobar_service->GetInfoBarCount());
- InfoBarDelegate* infobar_delegate =
- infobar_service->GetInfoBarDelegateAt(0);
+ ASSERT_EQ(1u, infobar_service->infobar_count());
+ InfoBarDelegate* infobar_delegate = infobar_service->infobar_at(0);
TranslateInfoBarDelegate* delegate =
infobar_delegate->AsTranslateInfoBarDelegate();
ASSERT_TRUE(delegate);
@@ -1550,7 +1548,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, MAYBE_TranslateEnabled) {
// Now force disable translate.
infobar_service->RemoveInfoBar(infobar_delegate);
- EXPECT_EQ(0u, infobar_service->GetInfoBarCount());
+ EXPECT_EQ(0u, infobar_service->infobar_count());
policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false));
UpdateProviderPolicy(policies);
@@ -1560,7 +1558,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, MAYBE_TranslateEnabled) {
content::NotificationService::AllSources());
ui_test_utils::NavigateToURL(browser(), url);
language_observer2.Wait();
- EXPECT_EQ(0u, infobar_service->GetInfoBarCount());
+ EXPECT_EQ(0u, infobar_service->infobar_count());
}
IN_PROC_BROWSER_TEST_F(PolicyTest, URLBlacklist) {
diff --git a/chrome/browser/ssl/ssl_tab_helper.cc b/chrome/browser/ssl/ssl_tab_helper.cc
index 8caa2df..19f1a14 100644
--- a/chrome/browser/ssl/ssl_tab_helper.cc
+++ b/chrome/browser/ssl/ssl_tab_helper.cc
@@ -121,8 +121,8 @@ string16 SSLCertResultInfoBarDelegate::GetButtonLabel(
bool SSLCertResultInfoBarDelegate::Accept() {
ShowCertificateViewer(
- owner()->GetWebContents(),
- owner()->GetWebContents()->GetView()->GetTopLevelNativeWindow(),
+ owner()->web_contents(),
+ owner()->web_contents()->GetView()->GetTopLevelNativeWindow(),
cert_);
return false; // Hiding the infobar just as the dialog opens looks weird.
}
diff --git a/chrome/browser/task_manager/task_manager_browsertest.cc b/chrome/browser/task_manager/task_manager_browsertest.cc
index d9a292a..a0f62a6 100644
--- a/chrome/browser/task_manager/task_manager_browsertest.cc
+++ b/chrome/browser/task_manager/task_manager_browsertest.cc
@@ -474,9 +474,9 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest,
// gets reloaded and noticed in the task manager.
InfoBarService* infobar_service = InfoBarService::FromWebContents(
browser()->tab_strip_model()->GetActiveWebContents());
- ASSERT_EQ(1U, infobar_service->GetInfoBarCount());
- ConfirmInfoBarDelegate* delegate = infobar_service->
- GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ ASSERT_EQ(1U, infobar_service->infobar_count());
+ ConfirmInfoBarDelegate* delegate =
+ infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate();
ASSERT_TRUE(delegate);
delegate->Accept();
TaskManagerBrowserTestUtil::WaitForWebResourceChange(3);
diff --git a/chrome/browser/three_d_api_observer.cc b/chrome/browser/three_d_api_observer.cc
index 803bf58..39b78d7 100644
--- a/chrome/browser/three_d_api_observer.cc
+++ b/chrome/browser/three_d_api_observer.cc
@@ -144,7 +144,7 @@ bool ThreeDAPIInfoBarDelegate::Cancel() {
THREE_D_INFOBAR_RELOADED,
THREE_D_INFOBAR_DISMISSAL_MAX);
content::GpuDataManager::GetInstance()->UnblockDomainFrom3DAPIs(url_);
- owner()->GetWebContents()->GetController().Reload(true);
+ owner()->web_contents()->GetController().Reload(true);
return true;
}
@@ -153,7 +153,7 @@ string16 ThreeDAPIInfoBarDelegate::GetLinkText() const {
}
bool ThreeDAPIInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
- owner()->GetWebContents()->OpenURL(content::OpenURLParams(
+ owner()->web_contents()->OpenURL(content::OpenURLParams(
GURL("https://support.google.com/chrome/?p=ib_webgl"),
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
diff --git a/chrome/browser/translate/options_menu_model.cc b/chrome/browser/translate/options_menu_model.cc
index 75d0243..f28d5ea 100644
--- a/chrome/browser/translate/options_menu_model.cc
+++ b/chrome/browser/translate/options_menu_model.cc
@@ -33,8 +33,8 @@ OptionsMenuModel::OptionsMenuModel(
// Populate the menu.
// Incognito mode does not get any preferences related items.
- if (!translate_delegate->owner()->GetWebContents()->
- GetBrowserContext()->IsOffTheRecord()) {
+ if (!translate_delegate->owner()->web_contents()->GetBrowserContext()->
+ IsOffTheRecord()) {
AddCheckItem(IDC_TRANSLATE_OPTIONS_ALWAYS,
l10n_util::GetStringFUTF16(IDS_TRANSLATE_INFOBAR_OPTIONS_ALWAYS,
original_language, target_language));
@@ -119,7 +119,7 @@ void OptionsMenuModel::ExecuteCommand(int command_id, int event_flags) {
case IDC_TRANSLATE_OPTIONS_ABOUT: {
WebContents* web_contents =
- translate_infobar_delegate_->owner()->GetWebContents();
+ translate_infobar_delegate_->owner()->web_contents();
if (web_contents) {
OpenURLParams params(
GURL(chrome::kAboutGoogleTranslateURL), Referrer(),
diff --git a/chrome/browser/translate/translate_infobar_delegate.cc b/chrome/browser/translate/translate_infobar_delegate.cc
index 2616a20..63f4833 100644
--- a/chrome/browser/translate/translate_infobar_delegate.cc
+++ b/chrome/browser/translate/translate_infobar_delegate.cc
@@ -52,9 +52,8 @@ void TranslateInfoBarDelegate::Create(InfoBarService* infobar_service,
// Find any existing translate infobar delegate.
TranslateInfoBarDelegate* old_delegate = NULL;
- for (size_t i = 0; i < infobar_service->GetInfoBarCount(); ++i) {
- old_delegate =
- infobar_service->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate();
+ for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
+ old_delegate = infobar_service->infobar_at(i)->AsTranslateInfoBarDelegate();
if (old_delegate)
break;
}
@@ -75,12 +74,12 @@ void TranslateInfoBarDelegate::Create(InfoBarService* infobar_service,
}
void TranslateInfoBarDelegate::Translate() {
- if (!owner()->GetWebContents()->GetBrowserContext()->IsOffTheRecord()) {
+ if (!owner()->web_contents()->GetBrowserContext()->IsOffTheRecord()) {
prefs_.ResetTranslationDeniedCount(original_language_code());
prefs_.IncrementTranslationAcceptedCount(original_language_code());
}
- TranslateManager::GetInstance()->TranslatePage(owner()->GetWebContents(),
+ TranslateManager::GetInstance()->TranslatePage(owner()->web_contents(),
original_language_code(),
target_language_code());
@@ -88,17 +87,17 @@ void TranslateInfoBarDelegate::Translate() {
}
void TranslateInfoBarDelegate::RevertTranslation() {
- TranslateManager::GetInstance()->RevertTranslation(owner()->GetWebContents());
+ TranslateManager::GetInstance()->RevertTranslation(owner()->web_contents());
RemoveSelf();
}
void TranslateInfoBarDelegate::ReportLanguageDetectionError() {
TranslateManager::GetInstance()->
- ReportLanguageDetectionError(owner()->GetWebContents());
+ ReportLanguageDetectionError(owner()->web_contents());
}
void TranslateInfoBarDelegate::TranslationDeclined() {
- if (!owner()->GetWebContents()->GetBrowserContext()->IsOffTheRecord()) {
+ if (!owner()->web_contents()->GetBrowserContext()->IsOffTheRecord()) {
prefs_.ResetTranslationAcceptedCount(original_language_code());
prefs_.IncrementTranslationDeniedCount(original_language_code());
}
@@ -109,7 +108,7 @@ void TranslateInfoBarDelegate::TranslationDeclined() {
// happens when a load stops. That could happen multiple times, including
// after the user already declined the translation.)
TranslateTabHelper* translate_tab_helper =
- TranslateTabHelper::FromWebContents(owner()->GetWebContents());
+ TranslateTabHelper::FromWebContents(owner()->web_contents());
translate_tab_helper->language_state().set_translation_declined(true);
UMA_HISTOGRAM_COUNTS("Translate.DeclineTranslate", 1);
@@ -227,8 +226,9 @@ void TranslateInfoBarDelegate::MessageInfoBarButtonPressed() {
return;
}
// This is the "Try again..." case.
- TranslateManager::GetInstance()->TranslatePage(owner()->GetWebContents(),
- original_language_code(), target_language_code());
+ TranslateManager::GetInstance()->TranslatePage(owner()->web_contents(),
+ original_language_code(),
+ target_language_code());
}
bool TranslateInfoBarDelegate::ShouldShowMessageInfoBarButton() {
@@ -237,13 +237,13 @@ bool TranslateInfoBarDelegate::ShouldShowMessageInfoBarButton() {
bool TranslateInfoBarDelegate::ShouldShowNeverTranslateButton() {
DCHECK_EQ(BEFORE_TRANSLATE, infobar_type_);
- return !owner()->GetWebContents()->GetBrowserContext()->IsOffTheRecord() &&
+ return !owner()->web_contents()->GetBrowserContext()->IsOffTheRecord() &&
(prefs_.GetTranslationDeniedCount(original_language_code()) >= 3);
}
bool TranslateInfoBarDelegate::ShouldShowAlwaysTranslateButton() {
DCHECK_EQ(BEFORE_TRANSLATE, infobar_type_);
- return !owner()->GetWebContents()->GetBrowserContext()->IsOffTheRecord() &&
+ return !owner()->web_contents()->GetBrowserContext()->IsOffTheRecord() &&
(prefs_.GetTranslationAcceptedCount(original_language_code()) >= 3);
}
@@ -375,6 +375,6 @@ TranslateInfoBarDelegate*
std::string TranslateInfoBarDelegate::GetPageHost() {
NavigationEntry* entry =
- owner()->GetWebContents()->GetController().GetActiveEntry();
+ owner()->web_contents()->GetController().GetActiveEntry();
return entry ? entry->GetURL().HostNoBrackets() : std::string();
}
diff --git a/chrome/browser/translate/translate_manager_browsertest.cc b/chrome/browser/translate/translate_manager_browsertest.cc
index 0740325..6c87f0f 100644
--- a/chrome/browser/translate/translate_manager_browsertest.cc
+++ b/chrome/browser/translate/translate_manager_browsertest.cc
@@ -145,9 +145,8 @@ class TranslateManagerBrowserTest : public ChromeRenderViewHostTestHarness,
// Returns the translate infobar if there is 1 infobar and it is a translate
// infobar.
TranslateInfoBarDelegate* GetTranslateInfoBar() {
- return (infobar_service()->GetInfoBarCount() == 1) ?
- infobar_service()->GetInfoBarDelegateAt(0)->
- AsTranslateInfoBarDelegate() : NULL;
+ return (infobar_service()->infobar_count() == 1) ?
+ infobar_service()->infobar_at(0)->AsTranslateInfoBarDelegate() : NULL;
}
// If there is 1 infobar and it is a translate infobar, closes it and returns
@@ -734,18 +733,18 @@ TEST_F(TranslateManagerBrowserTest, MultipleOnPageContents) {
// Simulate clicking 'Nope' (don't translate).
EXPECT_TRUE(DenyTranslation());
- EXPECT_EQ(0U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
// Send a new PageContents, we should not show an infobar.
SimulateOnTranslateLanguageDetermined("fr", true);
- EXPECT_EQ(0U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
// 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_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
SimulateOnTranslateLanguageDetermined("fr", true);
- EXPECT_EQ(0U, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
}
// Test that reloading the page brings back the infobar if the
diff --git a/chrome/browser/ui/auto_login_infobar_delegate.cc b/chrome/browser/ui/auto_login_infobar_delegate.cc
index dd7ad3b..9c0ad93 100644
--- a/chrome/browser/ui/auto_login_infobar_delegate.cc
+++ b/chrome/browser/ui/auto_login_infobar_delegate.cc
@@ -203,7 +203,7 @@ string16 AutoLoginInfoBarDelegate::GetButtonLabel(
bool AutoLoginInfoBarDelegate::Accept() {
// AutoLoginRedirector deletes itself.
- new AutoLoginRedirector(&owner()->GetWebContents()->GetController(),
+ new AutoLoginRedirector(&owner()->web_contents()->GetController(),
params_.header.args);
RecordHistogramAction(HISTOGRAM_ACCEPTED);
button_pressed_ = true;
@@ -212,7 +212,7 @@ bool AutoLoginInfoBarDelegate::Accept() {
bool AutoLoginInfoBarDelegate::Cancel() {
Profile* profile = Profile::FromBrowserContext(
- owner()->GetWebContents()->GetBrowserContext());
+ owner()->web_contents()->GetBrowserContext());
PrefService* pref_service = profile->GetPrefs();
pref_service->SetBoolean(prefs::kAutologinEnabled, false);
RecordHistogramAction(HISTOGRAM_REJECTED);
@@ -236,7 +236,7 @@ AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate(
registrar_.Add(this,
chrome::NOTIFICATION_GOOGLE_SIGNED_OUT,
content::Source<Profile>(Profile::FromBrowserContext(
- owner->GetWebContents()->GetBrowserContext())));
+ owner->web_contents()->GetBrowserContext())));
}
AutoLoginInfoBarDelegate::~AutoLoginInfoBarDelegate() {
diff --git a/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm b/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm
index 2ecbabd..80d5b0e 100644
--- a/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm
+++ b/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm
@@ -152,7 +152,7 @@ class InfobarBridge : public ExtensionInfoBarDelegate::DelegateObserver {
extensions::ExtensionHost* extensionHost =
delegate_->AsExtensionInfoBarDelegate()->extension_host();
Browser* browser =
- chrome::FindBrowserWithWebContents(owner->GetWebContents());
+ chrome::FindBrowserWithWebContents(owner->web_contents());
contextMenu_.reset([[ExtensionActionContextMenu alloc]
initWithExtension:extensionHost->extension()
browser:browser
@@ -276,7 +276,7 @@ class InfobarBridge : public ExtensionInfoBarDelegate::DelegateObserver {
InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarService* owner) {
NSWindow* window =
- [(NSView*)owner->GetWebContents()->GetView()->GetContentNativeView()
+ [(NSView*)owner->web_contents()->GetView()->GetContentNativeView()
window];
ExtensionInfoBarController* controller =
[[ExtensionInfoBarController alloc] initWithDelegate:this
diff --git a/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm b/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm
index 9ab2474..6d1299e4 100644
--- a/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm
+++ b/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm
@@ -144,9 +144,9 @@ class InfoBarNotificationObserver : public content::NotificationObserver {
if (currentWebContents_) {
InfoBarService* infobarService =
InfoBarService::FromWebContents(currentWebContents_);
- for (size_t i = 0; i < infobarService->GetInfoBarCount(); ++i) {
- InfoBar* infobar = infobarService->
- GetInfoBarDelegateAt(i)->CreateInfoBar(infobarService);
+ for (size_t i = 0; i < infobarService->infobar_count(); ++i) {
+ InfoBar* infobar =
+ infobarService->infobar_at(i)->CreateInfoBar(infobarService);
[self addInfoBar:infobar animate:NO];
}
diff --git a/chrome/browser/ui/collected_cookies_infobar_delegate.cc b/chrome/browser/ui/collected_cookies_infobar_delegate.cc
index 4607a75..10b84a8 100644
--- a/chrome/browser/ui/collected_cookies_infobar_delegate.cc
+++ b/chrome/browser/ui/collected_cookies_infobar_delegate.cc
@@ -47,6 +47,6 @@ string16 CollectedCookiesInfoBarDelegate::GetButtonLabel(
}
bool CollectedCookiesInfoBarDelegate::Accept() {
- owner()->GetWebContents()->GetController().Reload(true);
+ owner()->web_contents()->GetController().Reload(true);
return true;
}
diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc
index a1becb9..0fb178b 100644
--- a/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc
+++ b/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc
@@ -230,8 +230,7 @@ TEST_F(ContentSettingBubbleModelTest, BlockedMediastream) {
// |infobar_service|.
InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents());
- scoped_ptr<InfoBarDelegate> delegate(
- infobar_service->GetInfoBarDelegateAt(0));
+ scoped_ptr<InfoBarDelegate> delegate(infobar_service->infobar_at(0));
infobar_service->RemoveInfoBar(delegate.get());
}
diff --git a/chrome/browser/ui/content_settings/content_setting_changed_infobar_delegate.cc b/chrome/browser/ui/content_settings/content_setting_changed_infobar_delegate.cc
index 74262ae..1e5a18a 100644
--- a/chrome/browser/ui/content_settings/content_setting_changed_infobar_delegate.cc
+++ b/chrome/browser/ui/content_settings/content_setting_changed_infobar_delegate.cc
@@ -59,6 +59,6 @@ string16 ContentSettingChangedInfoBarDelegate::GetButtonLabel(
}
bool ContentSettingChangedInfoBarDelegate::Accept() {
- owner()->GetWebContents()->GetController().Reload(true);
+ owner()->web_contents()->GetController().Reload(true);
return true;
}
diff --git a/chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc b/chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc
index 5e8dbdb..ed4f081b 100644
--- a/chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc
+++ b/chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc
@@ -94,7 +94,7 @@ string16 AppMetroInfoBarDelegateWin::GetButtonLabel(
bool AppMetroInfoBarDelegateWin::Accept() {
PrefService* prefs = g_browser_process->local_state();
- content::WebContents* web_contents = owner()->GetWebContents();
+ content::WebContents* web_contents = owner()->web_contents();
if (mode_ == SHOW_APP_LIST) {
prefs->SetBoolean(prefs::kRestartWithAppList, true);
} else {
@@ -109,7 +109,7 @@ bool AppMetroInfoBarDelegateWin::Accept() {
}
bool AppMetroInfoBarDelegateWin::Cancel() {
- owner()->GetWebContents()->Close();
+ owner()->web_contents()->Close();
return false;
}
@@ -124,7 +124,7 @@ bool AppMetroInfoBarDelegateWin::LinkClicked(
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false);
- owner()->GetWebContents()->OpenURL(params);
+ owner()->web_contents()->OpenURL(params);
return false;
}
diff --git a/chrome/browser/ui/gtk/infobars/infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/infobar_gtk.cc
index dff45b3..712c530 100644
--- a/chrome/browser/ui/gtk/infobars/infobar_gtk.cc
+++ b/chrome/browser/ui/gtk/infobars/infobar_gtk.cc
@@ -65,7 +65,7 @@ void InfoBarGtk::InitWidgets() {
DCHECK(owner());
DCHECK(!theme_service_);
theme_service_ = GtkThemeService::GetFrom(Profile::FromBrowserContext(
- owner()->GetWebContents()->GetBrowserContext()));
+ owner()->web_contents()->GetBrowserContext()));
// Create |hbox_| and pad the sides.
hbox_ = gtk_hbox_new(FALSE, kElementPadding);
diff --git a/chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.cc b/chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.cc
index 80ff0fcf..280a247 100644
--- a/chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.cc
+++ b/chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.cc
@@ -49,7 +49,7 @@ bool AlternateNavInfoBarDelegate::LinkClicked(
// the future.
content::PAGE_TRANSITION_TYPED,
false);
- owner()->GetWebContents()->OpenURL(params);
+ owner()->web_contents()->OpenURL(params);
// We should always close, even if the navigation did not occur within this
// WebContents.
diff --git a/chrome/browser/ui/startup/obsolete_os_infobar_delegate.cc b/chrome/browser/ui/startup/obsolete_os_infobar_delegate.cc
index 3dbf3b9..cc11fd9 100644
--- a/chrome/browser/ui/startup/obsolete_os_infobar_delegate.cc
+++ b/chrome/browser/ui/startup/obsolete_os_infobar_delegate.cc
@@ -64,7 +64,7 @@ bool ObsoleteOSInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
OpenURLParams params(learn_more_url_, Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false);
- owner()->GetWebContents()->OpenURL(params);
+ owner()->web_contents()->OpenURL(params);
return false;
}
diff --git a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
index a982f88..0e51f01 100644
--- a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
@@ -872,7 +872,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) {
content::WebContents* web_contents = tab_strip->GetWebContentsAt(0);
EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL());
EXPECT_EQ(1U,
- InfoBarService::FromWebContents(web_contents)->GetInfoBarCount());
+ InfoBarService::FromWebContents(web_contents)->infobar_count());
// The profile which normally opens last open pages displays the new tab page.
ASSERT_EQ(1u, chrome::GetBrowserCount(profile_last,
@@ -884,7 +884,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) {
web_contents = tab_strip->GetWebContentsAt(0);
EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL());
EXPECT_EQ(1U,
- InfoBarService::FromWebContents(web_contents)->GetInfoBarCount());
+ InfoBarService::FromWebContents(web_contents)->infobar_count());
// The profile which normally opens URLs displays the new tab page.
ASSERT_EQ(1u, chrome::GetBrowserCount(profile_urls,
@@ -896,7 +896,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) {
web_contents = tab_strip->GetWebContentsAt(0);
EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL());
EXPECT_EQ(1U,
- InfoBarService::FromWebContents(web_contents)->GetInfoBarCount());
+ InfoBarService::FromWebContents(web_contents)->infobar_count());
}
class ManagedModeBrowserCreatorTest : public InProcessBrowserTest {
diff --git a/chrome/browser/ui/sync/one_click_signin_helper.cc b/chrome/browser/ui/sync/one_click_signin_helper.cc
index 678a1c2..dd4903e 100644
--- a/chrome/browser/ui/sync/one_click_signin_helper.cc
+++ b/chrome/browser/ui/sync/one_click_signin_helper.cc
@@ -552,7 +552,7 @@ string16 OneClickInfoBarDelegateImpl::GetButtonLabel(
}
bool OneClickInfoBarDelegateImpl::Accept() {
- content::WebContents* web_contents = owner()->GetWebContents();
+ content::WebContents* web_contents = owner()->web_contents();
Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
Profile* profile = Profile::FromBrowserContext(
web_contents->GetBrowserContext());
@@ -576,7 +576,7 @@ bool OneClickInfoBarDelegateImpl::Accept() {
bool OneClickInfoBarDelegateImpl::Cancel() {
AddEmailToOneClickRejectedList(Profile::FromBrowserContext(
- owner()->GetWebContents()->GetBrowserContext()), email_);
+ owner()->web_contents()->GetBrowserContext()), email_);
RecordHistogramAction(one_click_signin::HISTOGRAM_REJECTED);
button_pressed_ = true;
return true;
@@ -593,7 +593,7 @@ bool OneClickInfoBarDelegateImpl::LinkClicked(
GURL(chrome::kChromeSyncLearnMoreURL), content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false);
- owner()->GetWebContents()->OpenURL(params);
+ owner()->web_contents()->OpenURL(params);
return false;
}
diff --git a/chrome/browser/ui/views/external_tab_container_win.cc b/chrome/browser/ui/views/external_tab_container_win.cc
index f41cd4e..ef2b35c 100644
--- a/chrome/browser/ui/views/external_tab_container_win.cc
+++ b/chrome/browser/ui/views/external_tab_container_win.cc
@@ -264,7 +264,7 @@ bool ExternalTabContainerWin::Init(Profile* profile,
if (!infobars_enabled) {
InfoBarService* infobar_service =
InfoBarService::FromWebContents(existing_contents);
- infobar_service->SetInfoBarsEnabled(false);
+ infobar_service->set_infobars_enabled(false);
}
// Start loading initial URL
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 a4f8dc1..d86ee28 100644
--- a/chrome/browser/ui/website_settings/website_settings_infobar_delegate.cc
+++ b/chrome/browser/ui/website_settings/website_settings_infobar_delegate.cc
@@ -48,6 +48,6 @@ string16 WebsiteSettingsInfobarDelegate::GetButtonLabel(
}
bool WebsiteSettingsInfobarDelegate::Accept() {
- owner()->GetWebContents()->GetController().Reload(true);
+ owner()->web_contents()->GetController().Reload(true);
return true;
}
diff --git a/chrome/browser/ui/website_settings/website_settings_unittest.cc b/chrome/browser/ui/website_settings/website_settings_unittest.cc
index 8f486af..ef08744 100644
--- a/chrome/browser/ui/website_settings/website_settings_unittest.cc
+++ b/chrome/browser/ui/website_settings/website_settings_unittest.cc
@@ -368,9 +368,9 @@ TEST_F(WebsiteSettingsTest, NoInfoBar) {
SetDefaultUIExpectations(mock_ui());
EXPECT_CALL(*mock_ui(), SetSelectedTab(
WebsiteSettingsUI::TAB_ID_PERMISSIONS));
- EXPECT_EQ(0u, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(0u, infobar_service()->infobar_count());
website_settings()->OnUIClosing();
- EXPECT_EQ(0u, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(0u, infobar_service()->infobar_count());
}
TEST_F(WebsiteSettingsTest, ShowInfoBar) {
@@ -390,16 +390,15 @@ TEST_F(WebsiteSettingsTest, ShowInfoBar) {
EXPECT_CALL(*mock_ui(), SetSelectedTab(
WebsiteSettingsUI::TAB_ID_PERMISSIONS));
- EXPECT_EQ(0u, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(0u, infobar_service()->infobar_count());
website_settings()->OnSitePermissionChanged(
CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ALLOW);
website_settings()->OnUIClosing();
- EXPECT_EQ(1u, infobar_service()->GetInfoBarCount());
+ EXPECT_EQ(1u, infobar_service()->infobar_count());
// Removing an |InfoBarDelegate| from the |InfoBarService| does not delete
// it. Hence the |delegate| must be cleaned up after it was removed from the
// |infobar_service|.
- scoped_ptr<InfoBarDelegate> delegate(
- infobar_service()->GetInfoBarDelegateAt(0));
+ scoped_ptr<InfoBarDelegate> delegate(infobar_service()->infobar_at(0));
infobar_service()->RemoveInfoBar(delegate.get());
}
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 01ae2d8..ec8cce6 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -853,9 +853,8 @@
'browser/infobars/infobar_container.h',
'browser/infobars/infobar_delegate.cc',
'browser/infobars/infobar_delegate.h',
+ 'browser/infobars/infobar_service.cc',
'browser/infobars/infobar_service.h',
- 'browser/infobars/infobar_tab_helper.cc',
- 'browser/infobars/infobar_tab_helper.h',
'browser/infobars/insecure_content_infobar_delegate.cc',
'browser/infobars/insecure_content_infobar_delegate.h',
'browser/infobars/simple_alert_infobar_delegate.cc',
diff --git a/chrome/test/gpu/webgl_infobar_browsertest.cc b/chrome/test/gpu/webgl_infobar_browsertest.cc
index 15286d0..e5c8a0c 100644
--- a/chrome/test/gpu/webgl_infobar_browsertest.cc
+++ b/chrome/test/gpu/webgl_infobar_browsertest.cc
@@ -87,7 +87,7 @@ IN_PROC_BROWSER_TEST_F(WebGLInfobarTest, ContextLossRaisesInfobar) {
EXPECT_EQ(1u,
InfoBarService::FromWebContents(
browser()->tab_strip_model()->GetActiveWebContents())->
- GetInfoBarCount());
+ infobar_count());
}
IN_PROC_BROWSER_TEST_F(WebGLInfobarTest, ContextLossInfobarReload) {
@@ -118,13 +118,10 @@ IN_PROC_BROWSER_TEST_F(WebGLInfobarTest, ContextLossInfobarReload) {
content::NotificationService::AllSources());
SimulateGPUCrash(browser());
infobar_added.Wait();
- EXPECT_EQ(1u,
- InfoBarService::FromWebContents(
- browser()->tab_strip_model()->GetActiveWebContents())->
- GetInfoBarCount());
- InfoBarDelegate* delegate = InfoBarService::FromWebContents(
- browser()->tab_strip_model()->GetActiveWebContents())->
- GetInfoBarDelegateAt(0);
+ InfoBarService* infobar_service = InfoBarService::FromWebContents(
+ browser()->tab_strip_model()->GetActiveWebContents());
+ EXPECT_EQ(1u, infobar_service->infobar_count());
+ InfoBarDelegate* delegate = infobar_service->infobar_at(0);
ASSERT_TRUE(delegate);
ASSERT_TRUE(delegate->AsThreeDAPIInfoBarDelegate());
delegate->AsConfirmInfoBarDelegate()->Cancel();