diff options
Diffstat (limited to 'chrome/browser/translate')
-rw-r--r-- | chrome/browser/translate/translate_manager.cc | 17 | ||||
-rw-r--r-- | chrome/browser/translate/translate_manager_browsertest.cc | 23 |
2 files changed, 24 insertions, 16 deletions
diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc index 94a499c..0adff98 100644 --- a/chrome/browser/translate/translate_manager.cc +++ b/chrome/browser/translate/translate_manager.cc @@ -14,6 +14,7 @@ #include "base/values.h" #include "chrome/browser/autofill/autofill_manager.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tab_contents/language_state.h" @@ -512,9 +513,10 @@ void TranslateManager::InitiateTranslation(TabContents* tab, } // Prompts the user if he/she wants the page translated. - wrapper->AddInfoBar(TranslateInfoBarDelegate::CreateDelegate( - TranslateInfoBarDelegate::BEFORE_TRANSLATE, tab, language_code, - target_lang)); + wrapper->infobar_tab_helper()->AddInfoBar( + TranslateInfoBarDelegate::CreateDelegate( + TranslateInfoBarDelegate::BEFORE_TRANSLATE, tab, language_code, + target_lang)); } void TranslateManager::InitiateTranslationPosted( @@ -763,9 +765,9 @@ void TranslateManager::ShowInfoBar(TabContents* tab, return; if (old_infobar) { // There already is a translate infobar, simply replace it. - wrapper->ReplaceInfoBar(old_infobar, infobar); + wrapper->infobar_tab_helper()->ReplaceInfoBar(old_infobar, infobar); } else { - wrapper->AddInfoBar(infobar); + wrapper->infobar_tab_helper()->AddInfoBar(infobar); } } @@ -801,10 +803,11 @@ TranslateInfoBarDelegate* TranslateManager::GetTranslateInfoBarDelegate( TabContentsWrapper::GetCurrentWrapperForContents(tab); if (!wrapper) return NULL; + InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); - for (size_t i = 0; i < wrapper->infobar_count(); ++i) { + for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { TranslateInfoBarDelegate* delegate = - wrapper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); + infobar_helper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); if (delegate) return delegate; } diff --git a/chrome/browser/translate/translate_manager_browsertest.cc b/chrome/browser/translate/translate_manager_browsertest.cc index 0900f3f..c0e32ff 100644 --- a/chrome/browser/translate/translate_manager_browsertest.cc +++ b/chrome/browser/translate/translate_manager_browsertest.cc @@ -10,6 +10,7 @@ #include "base/utf_string_conversions.h" #include "base/stringprintf.h" #include "chrome/app/chrome_command_ids.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/tab_contents/infobar.h" @@ -52,7 +53,7 @@ class TranslateManagerTest : public TabContentsWrapperTestHarness, : ui_thread_(BrowserThread::UI, &message_loop_) { } - // Simluates navigating to a page and getting the page contents and language + // Simulates navigating to a page and getting the page contents and language // for that navigation. void SimulateNavigation(const GURL& url, const std::string& lang, @@ -87,11 +88,15 @@ class TranslateManagerTest : public TabContentsWrapperTestHarness, return true; } + InfoBarTabHelper* infobar_tab_helper() { + return contents_wrapper()->infobar_tab_helper(); + } + // Returns the translate infobar if there is 1 infobar and it is a translate // infobar. TranslateInfoBarDelegate* GetTranslateInfoBar() { - return (contents_wrapper()->infobar_count() == 1) ? - contents_wrapper()->GetInfoBarDelegateAt(0)-> + return (infobar_tab_helper()->infobar_count() == 1) ? + infobar_tab_helper()->GetInfoBarDelegateAt(0)-> AsTranslateInfoBarDelegate() : NULL; } @@ -102,7 +107,7 @@ class TranslateManagerTest : public TabContentsWrapperTestHarness, if (!infobar) return false; infobar->InfoBarDismissed(); // Simulates closing the infobar. - contents_wrapper()->RemoveInfoBar(infobar); + infobar_tab_helper()->RemoveInfoBar(infobar); return true; } @@ -135,7 +140,7 @@ class TranslateManagerTest : public TabContentsWrapperTestHarness, if (!infobar) return false; infobar->TranslationDeclined(); - contents_wrapper()->RemoveInfoBar(infobar); + infobar_tab_helper()->RemoveInfoBar(infobar); return true; } @@ -632,18 +637,18 @@ TEST_F(TranslateManagerTest, MultipleOnPageContents) { // Simulate clicking 'Nope' (don't translate). EXPECT_TRUE(DenyTranslation()); - EXPECT_EQ(0U, contents_wrapper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->infobar_count()); // Send a new PageContents, we should not show an infobar. SimulateOnTranslateLanguageDetermined("fr", true); - EXPECT_EQ(0U, contents_wrapper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->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, contents_wrapper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->infobar_count()); SimulateOnTranslateLanguageDetermined("fr", true); - EXPECT_EQ(0U, contents_wrapper()->infobar_count()); + EXPECT_EQ(0U, infobar_tab_helper()->infobar_count()); } // Test that reloading the page brings back the infobar. |