diff options
author | kuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-26 18:43:09 +0000 |
---|---|---|
committer | kuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-26 18:43:09 +0000 |
commit | 8f5d9b53d113c26935205c71a128d055e60cd787 (patch) | |
tree | 075c2b44f651c3df937701fccb45b44cb4b84838 /chrome/browser | |
parent | 7a130f3789ad66ea6a3ed381c0a581ac3dab9bf3 (diff) | |
download | chromium_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')
-rw-r--r-- | chrome/browser/translate/translate_infobars_delegates.cc | 2 | ||||
-rw-r--r-- | chrome/browser/translate/translate_manager.cc | 10 | ||||
-rw-r--r-- | chrome/browser/views/infobars/translate_infobars.cc | 12 |
3 files changed, 13 insertions, 11 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(); diff --git a/chrome/browser/views/infobars/translate_infobars.cc b/chrome/browser/views/infobars/translate_infobars.cc index 21482a2..1caedec 100644 --- a/chrome/browser/views/infobars/translate_infobars.cc +++ b/chrome/browser/views/infobars/translate_infobars.cc @@ -263,12 +263,6 @@ TranslateInfoBar::~TranslateInfoBar() { void TranslateInfoBar::UpdateState( TranslateInfoBarDelegate::TranslateState new_state) { - // If this is not a call for initialization (i.e. called from Constructor), - // only proceed with state has changed. - if (label_1_ && GetDelegate()->state() == new_state) - return; - GetDelegate()->UpdateState(new_state); - // Create and initialize state-dependent controls if necessary. switch (new_state) { case TranslateInfoBarDelegate::kAfterTranslate: @@ -599,8 +593,8 @@ void TranslateInfoBar::ExecuteCommand(int command_id) { void TranslateInfoBar::ButtonPressed( views::Button* sender, const views::Event& event) { if (sender == accept_button_) { - UpdateState(TranslateInfoBarDelegate::kTranslating); GetDelegate()->Translate(); + UpdateState(GetDelegate()->state()); } else if (sender == deny_button_) { GetDelegate()->TranslationDeclined(); RemoveInfoBar(); @@ -618,7 +612,9 @@ void TranslateInfoBar::Observe(NotificationType type, TabContents* tab = Source<TabContents>(source).ptr(); if (tab != GetDelegate()->tab_contents()) return; - UpdateState(TranslateInfoBarDelegate::kAfterTranslate); + if (!target_language_menu_button_ || + !target_language_menu_button_->IsVisible()) + UpdateState(TranslateInfoBarDelegate::kAfterTranslate); } // TranslateInfoBar, private: -------------------------------------------------- |