| 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 "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/system/tray/system_tray.h" | 9 #include "ash/system/tray/system_tray.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 58 } |
| 59 | 59 |
| 60 LocaleChangeGuard::~LocaleChangeGuard() {} | 60 LocaleChangeGuard::~LocaleChangeGuard() {} |
| 61 | 61 |
| 62 void LocaleChangeGuard::OnLogin() { | 62 void LocaleChangeGuard::OnLogin() { |
| 63 registrar_.Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 63 registrar_.Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 64 content::NotificationService::AllBrowserContextsAndSources()); | 64 content::NotificationService::AllBrowserContextsAndSources()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void LocaleChangeGuard::RevertLocaleChange() { | 67 void LocaleChangeGuard::RevertLocaleChange() { |
| 68 if (note_ == NULL || | 68 if (profile_ == NULL || |
| 69 profile_ == NULL || | |
| 70 from_locale_.empty() || | 69 from_locale_.empty() || |
| 71 to_locale_.empty()) { | 70 to_locale_.empty()) { |
| 72 NOTREACHED(); | 71 NOTREACHED(); |
| 73 return; | 72 return; |
| 74 } | 73 } |
| 75 if (reverted_) | 74 if (reverted_) |
| 76 return; | 75 return; |
| 77 reverted_ = true; | 76 reverted_ = true; |
| 78 content::RecordAction(UserMetricsAction("LanguageChange_Revert")); | 77 content::RecordAction(UserMetricsAction("LanguageChange_Revert")); |
| 79 profile_->ChangeAppLocale( | 78 profile_->ChangeAppLocale( |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 title_text_)); | 183 title_text_)); |
| 185 note_->Show( | 184 note_->Show( |
| 186 message_text_, revert_link_text_, | 185 message_text_, revert_link_text_, |
| 187 base::Bind(&LocaleChangeGuard::RevertLocaleChangeCallback, | 186 base::Bind(&LocaleChangeGuard::RevertLocaleChangeCallback, |
| 188 AsWeakPtr()), | 187 AsWeakPtr()), |
| 189 true, // urgent | 188 true, // urgent |
| 190 false); // non-sticky | 189 false); // non-sticky |
| 191 } | 190 } |
| 192 | 191 |
| 193 void LocaleChangeGuard::AcceptLocaleChange() { | 192 void LocaleChangeGuard::AcceptLocaleChange() { |
| 194 if (note_ == NULL || | 193 if (profile_ == NULL || |
| 195 profile_ == NULL || | |
| 196 from_locale_.empty() || | 194 from_locale_.empty() || |
| 197 to_locale_.empty()) { | 195 to_locale_.empty()) { |
| 198 NOTREACHED(); | 196 NOTREACHED(); |
| 199 return; | 197 return; |
| 200 } | 198 } |
| 201 | 199 |
| 202 // Check whether locale has been reverted or changed. | 200 // Check whether locale has been reverted or changed. |
| 203 // If not: mark current locale as accepted. | 201 // If not: mark current locale as accepted. |
| 204 if (reverted_) | 202 if (reverted_) |
| 205 return; | 203 return; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 if (by_user) | 240 if (by_user) |
| 243 master_->AcceptLocaleChange(); | 241 master_->AcceptLocaleChange(); |
| 244 } | 242 } |
| 245 | 243 |
| 246 std::string LocaleChangeGuard::Delegate::id() const { | 244 std::string LocaleChangeGuard::Delegate::id() const { |
| 247 // Arbitrary unique Id. | 245 // Arbitrary unique Id. |
| 248 return "8c386938-1e3f-11e0-ac7b-18a90520e2e5"; | 246 return "8c386938-1e3f-11e0-ac7b-18a90520e2e5"; |
| 249 } | 247 } |
| 250 | 248 |
| 251 } // namespace chromeos | 249 } // namespace chromeos |
| OLD | NEW |