summaryrefslogtreecommitdiffstats
path: root/chrome/browser/translate/translate_manager.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/translate/translate_manager.cc')
-rw-r--r--chrome/browser/translate/translate_manager.cc27
1 files changed, 18 insertions, 9 deletions
diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc
index 5665c43..214d731 100644
--- a/chrome/browser/translate/translate_manager.cc
+++ b/chrome/browser/translate/translate_manager.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_util.h"
+#include "chrome/browser/translate/page_translated_details.h"
#include "chrome/browser/translate/translate_prefs.h"
#include "chrome/common/notification_details.h"
#include "chrome/common/notification_service.h"
@@ -86,23 +87,28 @@ void TranslateManager::Observe(NotificationType type,
// 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();
+ PageTranslatedDetails* page_translated_details =
+ Details<PageTranslatedDetails>(details).ptr();
+ TranslateInfoBarDelegate::TranslateState state =
+ (page_translated_details->error_type == TranslateErrors::NONE ?
+ TranslateInfoBarDelegate::kAfterTranslate :
+ TranslateInfoBarDelegate::kTranslateError);
int i;
for (i = 0; i < tab->infobar_delegate_count(); ++i) {
TranslateInfoBarDelegate* info_bar =
tab->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate();
if (info_bar) {
- info_bar->UpdateState(TranslateInfoBarDelegate::kAfterTranslate);
+ info_bar->UpdateState(state, page_translated_details->error_type);
break;
}
}
if (i == tab->infobar_delegate_count()) {
NavigationEntry* entry = tab->controller().GetActiveEntry();
if (entry) {
- std::pair<std::string, std::string>* language_pair =
- (Details<std::pair<std::string, std::string> >(details).ptr());
- AddTranslateInfoBar(tab, TranslateInfoBarDelegate::kAfterTranslate,
- entry->url(),
- language_pair->first, language_pair->second);
+ AddTranslateInfoBar(tab, state, entry->url(),
+ page_translated_details->source_language,
+ page_translated_details->target_language,
+ page_translated_details->error_type);
}
}
break;
@@ -201,7 +207,8 @@ void TranslateManager::InitiateTranslation(TabContents* tab,
// Prompts the user if he/she wants the page translated.
AddTranslateInfoBar(tab, TranslateInfoBarDelegate::kBeforeTranslate,
- entry->url(), page_lang, target_lang);
+ entry->url(), page_lang, target_lang,
+ TranslateErrors::NONE);
}
void TranslateManager::InitiateTranslationPosted(int process_id,
@@ -270,11 +277,13 @@ void TranslateManager::InitAcceptLanguages(PrefService* prefs) {
void TranslateManager::AddTranslateInfoBar(
TabContents* tab, TranslateInfoBarDelegate::TranslateState state,
const GURL& url,
- const std::string& original_language, const std::string& target_language) {
+ const std::string& original_language, const std::string& target_language,
+ TranslateErrors::Type error_type) {
PrefService* prefs = tab->profile()->GetPrefs();
TranslateInfoBarDelegate* infobar =
TranslateInfoBarDelegate::Create(tab, prefs, state, url,
- original_language, target_language);
+ original_language, target_language,
+ error_type);
if (!infobar) {
NOTREACHED() << "Failed to create infobar for language " <<
original_language << " and " << target_language;