| Index: chrome/browser/chromeos/locale_change_guard.cc
|
| diff --git a/chrome/browser/chromeos/locale_change_guard.cc b/chrome/browser/chromeos/locale_change_guard.cc
|
| index 0bcf9d38f7b6c8637731deeec04a354971997ab7..abb51a9b885689fdd028d27488727d77e577e8d2 100644
|
| --- a/chrome/browser/chromeos/locale_change_guard.cc
|
| +++ b/chrome/browser/chromeos/locale_change_guard.cc
|
| @@ -4,6 +4,8 @@
|
|
|
| #include "chrome/browser/chromeos/locale_change_guard.h"
|
|
|
| +#include <algorithm>
|
| +
|
| #include "ash/shell.h"
|
| #include "ash/system/tray/system_tray.h"
|
| #include "ash/system/tray/system_tray_notifier.h"
|
| @@ -33,6 +35,17 @@ using content::WebContents;
|
|
|
| namespace chromeos {
|
|
|
| +namespace {
|
| +
|
| +// This is the list of languages that do not require user notification when
|
| +// locale is switched automatically between regions within the same language.
|
| +//
|
| +// New language in kAcceptLanguageList should be added either here or to
|
| +// to the exception list in unit test.
|
| +const char* const kSkipShowNotificationLanguages[4] = {"en", "de", "fr", "it"};
|
| +
|
| +} // anonymous namespace
|
| +
|
| LocaleChangeGuard::LocaleChangeGuard(Profile* profile)
|
| : profile_(profile),
|
| reverted_(false),
|
| @@ -153,7 +166,11 @@ void LocaleChangeGuard::Check() {
|
| if (prefs->GetString(prefs::kApplicationLocaleAccepted) == to_locale)
|
| return; // Already accepted.
|
|
|
| - // Locale change detected, showing notification.
|
| + // Locale change detected.
|
| + if (!ShouldShowLocaleChangeNotification(from_locale, to_locale))
|
| + return;
|
| +
|
| + // Showing notification.
|
| if (from_locale_ != from_locale || to_locale_ != to_locale) {
|
| // Falling back to showing message in current locale.
|
| LOG(ERROR) <<
|
| @@ -212,4 +229,35 @@ void LocaleChangeGuard::PrepareChangingLocale(
|
| }
|
| }
|
|
|
| +// static
|
| +bool LocaleChangeGuard::ShouldShowLocaleChangeNotification(
|
| + const std::string& from_locale,
|
| + const std::string& to_locale) {
|
| + const std::string from_lang = l10n_util::GetLanguage(from_locale);
|
| + const std::string to_lang = l10n_util::GetLanguage(to_locale);
|
| +
|
| + if (from_locale == to_locale)
|
| + return false;
|
| +
|
| + if (from_lang != to_lang)
|
| + return true;
|
| +
|
| + const char* const* begin = kSkipShowNotificationLanguages;
|
| + const char* const* end = kSkipShowNotificationLanguages +
|
| + arraysize(kSkipShowNotificationLanguages);
|
| +
|
| + return std::find(begin, end, from_lang) == end;
|
| +}
|
| +
|
| +// static
|
| +const char* const*
|
| +LocaleChangeGuard::GetSkipShowNotificationLanguagesForTesting() {
|
| + return kSkipShowNotificationLanguages;
|
| +}
|
| +
|
| +// static
|
| +size_t LocaleChangeGuard::GetSkipShowNotificationLanguagesSizeForTesting() {
|
| + return arraysize(kSkipShowNotificationLanguages);
|
| +}
|
| +
|
| } // namespace chromeos
|
|
|