diff options
Diffstat (limited to 'chrome/browser/tab_contents/tab_contents.cc')
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 2f94369..310f2e9 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -45,6 +45,7 @@ #include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/browser/renderer_host/resource_request_details.h" #include "chrome/browser/renderer_host/site_instance.h" +#include "chrome/browser/renderer_host/translation_service.h" #include "chrome/browser/renderer_host/web_cache_manager.h" #include "chrome/browser/renderer_preferences_util.h" #include "chrome/browser/sessions/session_types.h" @@ -1807,6 +1808,19 @@ void TabContents::OnPageContents(const GURL& url, entry->set_language(language); } + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kAutoPageTranslate) && + TranslationService::IsTranslationEnabled()) { + std::string locale = g_browser_process->GetApplicationLocale(); + if (!locale.empty() && locale != language) { + // Don't translate the NTP, download page, history... + if (entry && !entry->url().SchemeIs("chrome") && + TranslationService::ShouldTranslatePage(language, locale)) { + render_view_host()->TranslatePage(entry->page_id(), language, locale); + } + } + } + std::string lang = language; NotificationService::current()->Notify( NotificationType::TAB_LANGUAGE_DETERMINED, |