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..4cc5a6362f5f262658a2d3561c199a3f8cd396d5 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,28 @@ using content::WebContents; |
namespace chromeos { |
+namespace { |
+ |
+bool ShouldShowLanguageNotification(const std::string& from_locale, |
Nikita (slow)
2014/07/14 09:37:42
nit: Language -> Locale
Nikita (slow)
2014/07/14 09:37:42
This function might as well have unit_test.
Alexander Alekseev
2014/07/14 22:01:59
Done.
Alexander Alekseev
2014/07/14 22:01:59
Done.
|
+ 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_lang != to_lang) |
+ return true; |
+ |
+ const char* const ignore_languages[] = {"en", "de", "fr", "it"}; |
Nikita (slow)
2014/07/14 09:37:41
Do you think that pt* (pt/pt-BR/pt-PT) should not
Alexander Alekseev
2014/07/14 22:01:59
Actually no. We should show notification for "pt".
|
+ if (std::find(ignore_languages, |
Nikita (slow)
2014/07/14 09:37:41
return !std::find(...);
Alexander Alekseev
2014/07/14 22:01:59
Done.
|
+ ignore_languages + arraysize(ignore_languages), |
+ from_lang) != ignore_languages + arraysize(ignore_languages)) { |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
+} // anonymous namespace |
+ |
LocaleChangeGuard::LocaleChangeGuard(Profile* profile) |
: profile_(profile), |
reverted_(false), |
@@ -153,7 +177,11 @@ void LocaleChangeGuard::Check() { |
if (prefs->GetString(prefs::kApplicationLocaleAccepted) == to_locale) |
return; // Already accepted. |
- // Locale change detected, showing notification. |
+ // Locale change detected |
Nikita (slow)
2014/07/14 09:37:41
nit: dot at the end.
Alexander Alekseev
2014/07/14 22:01:59
Done.
|
+ if (!ShouldShowLanguageNotification(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) << |