Bug fix: Translate infobar should appear when the user configured so.

When the flag --enable-translate-settings is on, the user can configure which language should be translated.  When so, even though the page is written in the user's locale language, the infobar should appear.

TEST=unit_tests

Review URL: https://chromiumcodereview.appspot.com/17157015

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207816 0039d316-1c4b-4281-b951-d872f2087c98
parent 1ccd050b
...@@ -438,17 +438,23 @@ void TranslateManager::InitiateTranslation(WebContents* web_contents, ...@@ -438,17 +438,23 @@ void TranslateManager::InitiateTranslation(WebContents* web_contents,
return; return;
} }
// Don't translate similar languages (ex: en-US to en).
std::string target_lang = GetTargetLanguage(prefs); std::string target_lang = GetTargetLanguage(prefs);
std::string language_code = GetLanguageCode(page_lang); std::string language_code = GetLanguageCode(page_lang);
if (language_code == target_lang) {
TranslateBrowserMetrics::ReportInitiationStatus(
TranslateBrowserMetrics::INITIATION_STATUS_SIMILAR_LANGUAGES);
return;
}
CommandLine* command_line = CommandLine::ForCurrentProcess(); CommandLine* command_line = CommandLine::ForCurrentProcess();
// Don't translate similar languages (ex: en-US to en).
// When the flag --enable-translate-settings is on, the locale (|target_lang|)
// is not needed to be considered because the user can configure the languages
// in the settings UI.
if (!command_line->HasSwitch(switches::kEnableTranslateSettings)) {
if (language_code == target_lang) {
TranslateBrowserMetrics::ReportInitiationStatus(
TranslateBrowserMetrics::INITIATION_STATUS_SIMILAR_LANGUAGES);
return;
}
}
// Don't translate any language the user configured as accepted languages. // Don't translate any language the user configured as accepted languages.
// When the flag --enable-translate-settings is on, the condition is // When the flag --enable-translate-settings is on, the condition is
// different. In this case, even though a language is an Accept language, // different. In this case, even though a language is an Accept language,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment