| Index: trunk/src/chrome/browser/translate/translate_infobar_delegate.cc
|
| ===================================================================
|
| --- trunk/src/chrome/browser/translate/translate_infobar_delegate.cc (revision 238401)
|
| +++ trunk/src/chrome/browser/translate/translate_infobar_delegate.cc (working copy)
|
| @@ -10,7 +10,6 @@
|
| #include "base/metrics/histogram.h"
|
| #include "base/prefs/pref_service.h"
|
| #include "chrome/browser/browser_process.h"
|
| -#include "chrome/browser/infobars/infobar.h"
|
| #include "chrome/browser/infobars/infobar_service.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/translate/translate_accept_languages.h"
|
| @@ -59,18 +58,16 @@
|
| if ((infobar_type == TranslateInfoBarDelegate::AFTER_TRANSLATE) ||
|
| (infobar_type == TranslateInfoBarDelegate::TRANSLATING)) {
|
| TranslateTabHelper* translate_tab_helper =
|
| - TranslateTabHelper::FromWebContents(infobar_service->web_contents());
|
| + TranslateTabHelper::FromWebContents(infobar_service->web_contents());
|
| if (!translate_tab_helper ||
|
| - translate_tab_helper->language_state().InTranslateNavigation())
|
| + translate_tab_helper->language_state().InTranslateNavigation())
|
| return;
|
| }
|
|
|
| // Find any existing translate infobar delegate.
|
| - InfoBar* old_infobar = NULL;
|
| TranslateInfoBarDelegate* old_delegate = NULL;
|
| for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
|
| - old_infobar = infobar_service->infobar_at(i);
|
| - old_delegate = old_infobar->delegate()->AsTranslateInfoBarDelegate();
|
| + old_delegate = infobar_service->infobar_at(i)->AsTranslateInfoBarDelegate();
|
| if (old_delegate) {
|
| if (!replace_existing_infobar)
|
| return;
|
| @@ -79,12 +76,12 @@
|
| }
|
|
|
| // Add the new delegate.
|
| - scoped_ptr<InfoBar> infobar(CreateInfoBar(
|
| - scoped_ptr<TranslateInfoBarDelegate>(new TranslateInfoBarDelegate(
|
| - infobar_type, old_delegate, original_language, target_language,
|
| - error_type, prefs, shortcut_config))));
|
| + scoped_ptr<InfoBarDelegate> infobar(
|
| + new TranslateInfoBarDelegate(infobar_service, infobar_type, old_delegate,
|
| + original_language, target_language,
|
| + error_type, prefs, shortcut_config));
|
| if (old_delegate)
|
| - infobar_service->ReplaceInfoBar(old_infobar, infobar.Pass());
|
| + infobar_service->ReplaceInfoBar(old_delegate, infobar.Pass());
|
| else
|
| infobar_service->AddInfoBar(infobar.Pass());
|
| }
|
| @@ -128,7 +125,7 @@
|
| TranslateManager::GetInstance()->RevertTranslation(web_contents());
|
| UMA_HISTOGRAM_BOOLEAN(TranslateBrowserMetrics::GetMetricsName(
|
| TranslateBrowserMetrics::UMA_REVERT_TRANSLATION), true);
|
| - infobar()->RemoveSelf();
|
| + RemoveSelf();
|
| }
|
|
|
| void TranslateInfoBarDelegate::ReportLanguageDetectionError() {
|
| @@ -171,7 +168,7 @@
|
| TranslateTabHelper::FromWebContents(web_contents());
|
| DCHECK(translate_tab_helper);
|
| translate_tab_helper->language_state().SetTranslateEnabled(false);
|
| - infobar()->RemoveSelf();
|
| + RemoveSelf();
|
| }
|
|
|
| UMA_HISTOGRAM_BOOLEAN(TranslateBrowserMetrics::GetMetricsName(
|
| @@ -196,7 +193,7 @@
|
| TranslateTabHelper::FromWebContents(web_contents());
|
| DCHECK(translate_tab_helper);
|
| translate_tab_helper->language_state().SetTranslateEnabled(false);
|
| - infobar()->RemoveSelf();
|
| + RemoveSelf();
|
| }
|
|
|
| UMA_HISTOGRAM_BOOLEAN(TranslateBrowserMetrics::GetMetricsName(
|
| @@ -240,7 +237,7 @@
|
| UMA_HISTOGRAM_BOOLEAN(TranslateBrowserMetrics::GetMetricsName(
|
| TranslateBrowserMetrics::UMA_NEVER_TRANSLATE_LANG), true);
|
|
|
| - infobar()->RemoveSelf();
|
| + RemoveSelf();
|
| }
|
|
|
| string16 TranslateInfoBarDelegate::GetMessageInfoBarText() {
|
| @@ -362,6 +359,7 @@
|
| }
|
|
|
| TranslateInfoBarDelegate::TranslateInfoBarDelegate(
|
| + InfoBarService* infobar_service,
|
| Type infobar_type,
|
| TranslateInfoBarDelegate* old_delegate,
|
| const std::string& original_language,
|
| @@ -369,7 +367,7 @@
|
| TranslateErrors::Type error_type,
|
| PrefService* prefs,
|
| ShortcutConfiguration shortcut_config)
|
| - : InfoBarDelegate(),
|
| + : InfoBarDelegate(infobar_service),
|
| infobar_type_(infobar_type),
|
| background_animation_(NONE),
|
| original_language_index_(kNoIndex),
|
| @@ -396,9 +394,6 @@
|
| }
|
| }
|
|
|
| -// TranslateInfoBarDelegate::CreateInfoBar() is implemented in platform-specific
|
| -// files.
|
| -
|
| void TranslateInfoBarDelegate::InfoBarDismissed() {
|
| if (infobar_type_ != BEFORE_TRANSLATE)
|
| return;
|
|
|