OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/locale_change_guard.h" | 5 #include "chrome/browser/chromeos/locale_change_guard.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/public/interfaces/constants.mojom.h" | 9 #include "ash/public/interfaces/constants.mojom.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/metrics/user_metrics.h" |
12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
14 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
16 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 17 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
17 #include "chrome/browser/lifetime/application_lifetime.h" | 18 #include "chrome/browser/lifetime/application_lifetime.h" |
18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/browser_commands.h" | 21 #include "chrome/browser/ui/browser_commands.h" |
21 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
22 #include "components/prefs/pref_service.h" | 23 #include "components/prefs/pref_service.h" |
23 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
24 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
25 #include "content/public/browser/user_metrics.h" | |
26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
27 #include "content/public/common/service_manager_connection.h" | 27 #include "content/public/common/service_manager_connection.h" |
28 #include "services/service_manager/public/cpp/connector.h" | 28 #include "services/service_manager/public/cpp/connector.h" |
29 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
30 | 30 |
31 using base::UserMetricsAction; | 31 using base::UserMetricsAction; |
32 using content::WebContents; | 32 using content::WebContents; |
33 | 33 |
34 namespace chromeos { | 34 namespace chromeos { |
35 | 35 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 void LocaleChangeGuard::RevertLocaleChange() { | 78 void LocaleChangeGuard::RevertLocaleChange() { |
79 if (profile_ == NULL || | 79 if (profile_ == NULL || |
80 from_locale_.empty() || | 80 from_locale_.empty() || |
81 to_locale_.empty()) { | 81 to_locale_.empty()) { |
82 NOTREACHED(); | 82 NOTREACHED(); |
83 return; | 83 return; |
84 } | 84 } |
85 if (reverted_) | 85 if (reverted_) |
86 return; | 86 return; |
87 reverted_ = true; | 87 reverted_ = true; |
88 content::RecordAction(UserMetricsAction("LanguageChange_Revert")); | 88 base::RecordAction(UserMetricsAction("LanguageChange_Revert")); |
89 profile_->ChangeAppLocale( | 89 profile_->ChangeAppLocale( |
90 from_locale_, Profile::APP_LOCALE_CHANGED_VIA_REVERT); | 90 from_locale_, Profile::APP_LOCALE_CHANGED_VIA_REVERT); |
91 chrome::AttemptUserExit(); | 91 chrome::AttemptUserExit(); |
92 } | 92 } |
93 | 93 |
94 void LocaleChangeGuard::RevertLocaleChangeCallback( | 94 void LocaleChangeGuard::RevertLocaleChangeCallback( |
95 const base::ListValue* list) { | 95 const base::ListValue* list) { |
96 RevertLocaleChange(); | 96 RevertLocaleChange(); |
97 } | 97 } |
98 | 98 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 // If not: mark current locale as accepted. | 219 // If not: mark current locale as accepted. |
220 if (reverted_) | 220 if (reverted_) |
221 return; | 221 return; |
222 PrefService* prefs = profile_->GetPrefs(); | 222 PrefService* prefs = profile_->GetPrefs(); |
223 if (prefs == NULL) { | 223 if (prefs == NULL) { |
224 NOTREACHED(); | 224 NOTREACHED(); |
225 return; | 225 return; |
226 } | 226 } |
227 if (prefs->GetString(prefs::kApplicationLocale) != to_locale_) | 227 if (prefs->GetString(prefs::kApplicationLocale) != to_locale_) |
228 return; | 228 return; |
229 content::RecordAction(UserMetricsAction("LanguageChange_Accept")); | 229 base::RecordAction(UserMetricsAction("LanguageChange_Accept")); |
230 prefs->SetString(prefs::kApplicationLocaleBackup, to_locale_); | 230 prefs->SetString(prefs::kApplicationLocaleBackup, to_locale_); |
231 prefs->SetString(prefs::kApplicationLocaleAccepted, to_locale_); | 231 prefs->SetString(prefs::kApplicationLocaleAccepted, to_locale_); |
232 } | 232 } |
233 | 233 |
234 void LocaleChangeGuard::PrepareChangingLocale( | 234 void LocaleChangeGuard::PrepareChangingLocale( |
235 const std::string& from_locale, const std::string& to_locale) { | 235 const std::string& from_locale, const std::string& to_locale) { |
236 std::string cur_locale = g_browser_process->GetApplicationLocale(); | 236 std::string cur_locale = g_browser_process->GetApplicationLocale(); |
237 if (!from_locale.empty()) | 237 if (!from_locale.empty()) |
238 from_locale_ = from_locale; | 238 from_locale_ = from_locale; |
239 if (!to_locale.empty()) | 239 if (!to_locale.empty()) |
(...skipping 25 matching lines...) Expand all Loading... |
265 LocaleChangeGuard::GetSkipShowNotificationLanguagesForTesting() { | 265 LocaleChangeGuard::GetSkipShowNotificationLanguagesForTesting() { |
266 return kSkipShowNotificationLanguages; | 266 return kSkipShowNotificationLanguages; |
267 } | 267 } |
268 | 268 |
269 // static | 269 // static |
270 size_t LocaleChangeGuard::GetSkipShowNotificationLanguagesSizeForTesting() { | 270 size_t LocaleChangeGuard::GetSkipShowNotificationLanguagesSizeForTesting() { |
271 return arraysize(kSkipShowNotificationLanguages); | 271 return arraysize(kSkipShowNotificationLanguages); |
272 } | 272 } |
273 | 273 |
274 } // namespace chromeos | 274 } // namespace chromeos |
OLD | NEW |