Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Unified Diff: chrome/browser/chromeos/locale_change_guard.cc

Issue 382973002: ChromeOS: should not show "Language changed" notification for certain languages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) <<
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698