summaryrefslogtreecommitdiffstats
path: root/chrome/browser/translate
diff options
context:
space:
mode:
authorkuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-26 18:43:09 +0000
committerkuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-26 18:43:09 +0000
commit8f5d9b53d113c26935205c71a128d055e60cd787 (patch)
tree075c2b44f651c3df937701fccb45b44cb4b84838 /chrome/browser/translate
parent7a130f3789ad66ea6a3ed381c0a581ac3dab9bf3 (diff)
downloadchromium_src-8f5d9b53d113c26935205c71a128d055e60cd787.zip
chromium_src-8f5d9b53d113c26935205c71a128d055e60cd787.tar.gz
chromium_src-8f5d9b53d113c26935205c71a128d055e60cd787.tar.bz2
fix bug where translate infobar gets stuck at "Loading..." between switching tabs.
- problem happened because infobars are destructed when switching between tabs, only the delegates persist. without the infobar to receive the PAGE_TRANSLATED notification to update the translate state, the infobar gets stuck at translating state when user switches back to the associated tab. - fix was to update the state in the infobar delegate on receiving PAGE_TRANSLATE notification so that when a new translate infobar is created, its visual display will reflect the updated after-translate state. BUG=36895 TEST=verify per bug report. Review URL: http://codereview.chromium.org/660187 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40135 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/translate')
-rw-r--r--chrome/browser/translate/translate_infobars_delegates.cc2
-rw-r--r--chrome/browser/translate/translate_manager.cc10
2 files changed, 9 insertions, 3 deletions
diff --git a/chrome/browser/translate/translate_infobars_delegates.cc b/chrome/browser/translate/translate_infobars_delegates.cc
index 2aad0b4..8107f4f 100644
--- a/chrome/browser/translate/translate_infobars_delegates.cc
+++ b/chrome/browser/translate/translate_infobars_delegates.cc
@@ -97,6 +97,8 @@ void TranslateInfoBarDelegate::GetAvailableTargetLanguages(
}
void TranslateInfoBarDelegate::Translate() {
+ if (state_ == kBeforeTranslate)
+ UpdateState(kTranslating);
tab_contents_->TranslatePage(original_lang_code(), target_lang_code());
}
diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc
index 8c90bdf..9435786 100644
--- a/chrome/browser/translate/translate_manager.cc
+++ b/chrome/browser/translate/translate_manager.cc
@@ -75,13 +75,17 @@ void TranslateManager::Observe(NotificationType type,
}
case NotificationType::PAGE_TRANSLATED: {
// Only add translate infobar if it doesn't exist; if it already exists,
- // it would have received the same notification and acted accordingly.
+ // just update the state, the actual infobar would have received the same
+ // notification and update the visual display accordingly.
TabContents* tab = Source<TabContents>(source).ptr();
int i;
for (i = 0; i < tab->infobar_delegate_count(); ++i) {
- InfoBarDelegate* info_bar = tab->GetInfoBarDelegateAt(i);
- if (info_bar->AsTranslateInfoBarDelegate())
+ TranslateInfoBarDelegate* info_bar =
+ tab->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate();
+ if (info_bar) {
+ info_bar->UpdateState(TranslateInfoBarDelegate::kAfterTranslate);
break;
+ }
}
if (i == tab->infobar_delegate_count()) {
NavigationEntry* entry = tab->controller().GetActiveEntry();