summaryrefslogtreecommitdiffstats
path: root/chrome/browser/translate
diff options
context:
space:
mode:
authordroger@chromium.org <droger@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-10 13:53:26 +0000
committerdroger@chromium.org <droger@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-10 13:53:26 +0000
commitb44f1d387d68ab967d19c39c621d11526928f576 (patch)
tree059b0d4a2f7d1c94ce99e9d24dd9cf45b8ef35d6 /chrome/browser/translate
parent78ecee494f7c61af7923b3f61126b088b5592e2b (diff)
downloadchromium_src-b44f1d387d68ab967d19c39c621d11526928f576.zip
chromium_src-b44f1d387d68ab967d19c39c621d11526928f576.tar.gz
chromium_src-b44f1d387d68ab967d19c39c621d11526928f576.tar.bz2
InfoBarService inherits from InfoBarManager
This allows to change the implementation of InfoBarDelegate::web_contents() such that it no longer calls InfoBarManager::web_contents() (which will be removed), but InfoBarService::web_contents() instead. BUG=354379 TBR=jochen Review URL: https://codereview.chromium.org/228293004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262976 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/translate')
-rw-r--r--chrome/browser/translate/translate_browsertest.cc14
-rw-r--r--chrome/browser/translate/translate_infobar_delegate.cc6
-rw-r--r--chrome/browser/translate/translate_manager_render_view_host_unittest.cc27
3 files changed, 19 insertions, 28 deletions
diff --git a/chrome/browser/translate/translate_browsertest.cc b/chrome/browser/translate/translate_browsertest.cc
index e666aed..7c0bef7 100644
--- a/chrome/browser/translate/translate_browsertest.cc
+++ b/chrome/browser/translate/translate_browsertest.cc
@@ -92,19 +92,19 @@ class TranslateBrowserTest : public InProcessBrowserTest {
}
TranslateInfoBarDelegate* delegate = NULL;
- InfoBarManager* infobar_manager = infobar_service_->infobar_manager();
- for (size_t i = 0; i < infobar_manager->infobar_count(); ++i) {
+ for (size_t i = 0; i < infobar_service_->infobar_count(); ++i) {
// Check if the shown infobar is a confirm infobar coming from the
// |kTranslateSecurityOrigin| flag specified in SetUpCommandLine().
// This infobar appears in all tests of TranslateBrowserTest and can be
// ignored here.
- ConfirmInfoBarDelegate* confirm = infobar_manager->infobar_at(i)
- ->delegate()->AsConfirmInfoBarDelegate();
- if (confirm)
+ if (infobar_service_->infobar_at(i)->delegate()->
+ AsConfirmInfoBarDelegate()) {
continue;
+ }
- TranslateInfoBarDelegate* translate = infobar_manager->infobar_at(i)
- ->delegate()->AsTranslateInfoBarDelegate();
+ TranslateInfoBarDelegate* translate =
+ infobar_service_->infobar_at(i)->delegate()->
+ AsTranslateInfoBarDelegate();
if (translate) {
EXPECT_FALSE(delegate) << "multiple infobars are shown unexpectedly";
delegate = translate;
diff --git a/chrome/browser/translate/translate_infobar_delegate.cc b/chrome/browser/translate/translate_infobar_delegate.cc
index bcfb5ae0..6eef845 100644
--- a/chrome/browser/translate/translate_infobar_delegate.cc
+++ b/chrome/browser/translate/translate_infobar_delegate.cc
@@ -11,7 +11,6 @@
#include "base/prefs/pref_service.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/infobars/infobar.h"
-#include "chrome/browser/infobars/infobar_manager.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/translate/translate_tab_helper.h"
@@ -89,10 +88,9 @@ void TranslateInfoBarDelegate::Create(bool replace_existing_infobar,
InfoBar* old_infobar = NULL;
InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents);
- InfoBarManager* infobar_manager = infobar_service->infobar_manager();
TranslateInfoBarDelegate* old_delegate = NULL;
- for (size_t i = 0; i < infobar_manager->infobar_count(); ++i) {
- old_infobar = infobar_manager->infobar_at(i);
+ for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
+ old_infobar = infobar_service->infobar_at(i);
old_delegate = old_infobar->delegate()->AsTranslateInfoBarDelegate();
if (old_delegate) {
if (!replace_existing_infobar)
diff --git a/chrome/browser/translate/translate_manager_render_view_host_unittest.cc b/chrome/browser/translate/translate_manager_render_view_host_unittest.cc
index d5e428a..71e13f2 100644
--- a/chrome/browser/translate/translate_manager_render_view_host_unittest.cc
+++ b/chrome/browser/translate/translate_manager_render_view_host_unittest.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/browser/infobars/infobar.h"
-#include "chrome/browser/infobars/infobar_manager.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/renderer_context_menu/render_view_context_menu_test_util.h"
#include "chrome/browser/translate/translate_infobar_delegate.h"
@@ -148,19 +147,13 @@ class TranslateManagerRenderViewHostTest
return InfoBarService::FromWebContents(web_contents());
}
- InfoBarManager* infobar_manager() {
- return infobar_service()->infobar_manager();
- }
-
// Returns the translate infobar if there is 1 infobar and it is a translate
// infobar.
TranslateInfoBarDelegate* GetTranslateInfoBar() {
- return (infobar_manager()->infobar_count() == 1)
- ? infobar_manager()
- ->infobar_at(0)
- ->delegate()
- ->AsTranslateInfoBarDelegate()
- : NULL;
+ return (infobar_service()->infobar_count() == 1) ?
+ infobar_service()->infobar_at(0)->delegate()->
+ AsTranslateInfoBarDelegate() :
+ NULL;
}
// If there is 1 infobar and it is a translate infobar, closes it and returns
@@ -170,7 +163,7 @@ class TranslateManagerRenderViewHostTest
if (!infobar)
return false;
infobar->InfoBarDismissed(); // Simulates closing the infobar.
- infobar_manager()->RemoveInfoBar(infobar_manager()->infobar_at(0));
+ infobar_service()->RemoveInfoBar(infobar_service()->infobar_at(0));
return true;
}
@@ -194,7 +187,7 @@ class TranslateManagerRenderViewHostTest
if (!infobar)
return false;
infobar->TranslationDeclined();
- infobar_manager()->RemoveInfoBar(infobar_manager()->infobar_at(0));
+ infobar_service()->RemoveInfoBar(infobar_service()->infobar_at(0));
return true;
}
@@ -749,18 +742,18 @@ TEST_F(TranslateManagerRenderViewHostTest, MultipleOnPageContents) {
// Simulate clicking 'Nope' (don't translate).
EXPECT_TRUE(DenyTranslation());
- EXPECT_EQ(0U, infobar_manager()->infobar_count());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
// Send a new PageContents, we should not show an infobar.
SimulateOnTranslateLanguageDetermined("fr", true);
- EXPECT_EQ(0U, infobar_manager()->infobar_count());
+ 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_manager()->infobar_count());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
SimulateOnTranslateLanguageDetermined("fr", true);
- EXPECT_EQ(0U, infobar_manager()->infobar_count());
+ EXPECT_EQ(0U, infobar_service()->infobar_count());
}
// Test that reloading the page brings back the infobar if the