Chromium Code Reviews| 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/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/system/tray/system_tray.h" | 8 #include "ash/system/tray/system_tray.h" |
| 9 #include "ash/system/tray/system_tray_delegate.h" | |
| 10 #include "ash/system/tray/system_tray_observers.h" | |
| 9 #include "base/bind.h" | 11 #include "base/bind.h" |
| 10 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/app/chrome_command_ids.h" | 13 #include "chrome/app/chrome_command_ids.h" |
| 12 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 15 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 14 #include "chrome/browser/notifications/notification_delegate.h" | 16 #include "chrome/browser/notifications/notification_delegate.h" |
| 15 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/browser_commands.h" | 20 #include "chrome/browser/ui/browser_commands.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 return; // Already accepted. | 166 return; // Already accepted. |
| 165 | 167 |
| 166 // Locale change detected, showing notification. | 168 // Locale change detected, showing notification. |
| 167 if (from_locale_ != from_locale || to_locale_ != to_locale) { | 169 if (from_locale_ != from_locale || to_locale_ != to_locale) { |
| 168 // Falling back to showing message in current locale. | 170 // Falling back to showing message in current locale. |
| 169 LOG(ERROR) << | 171 LOG(ERROR) << |
| 170 "Showing locale change notification in current (not previous) language"; | 172 "Showing locale change notification in current (not previous) language"; |
| 171 PrepareChangingLocale(from_locale, to_locale); | 173 PrepareChangingLocale(from_locale, to_locale); |
| 172 } | 174 } |
| 173 | 175 |
| 174 if (ash::Shell::GetInstance()->status_area_widget()) { | 176 ash::SystemTrayObservers* observers = |
| 175 ash::Shell::GetInstance()->system_tray()->locale_observer()-> | 177 ash::Shell::GetInstance()->tray_delegate()->GetSystemTrayObservers(); |
|
oshima
2012/11/09 19:21:50
TrayDelegate has NotifyXXX methods for several oth
sadrul
2012/11/09 23:26:32
I agree that it would be nice if these places all
stevenjb
2012/11/09 23:40:45
Yeah, I started to create NotifyXXX, but realized
| |
| 176 OnLocaleChanged(this, cur_locale, from_locale_, to_locale_); | 178 if (observers) { |
| 179 FOR_EACH_OBSERVER( | |
| 180 ash::LocaleObserver, | |
| 181 observers->locale_observers(), | |
| 182 OnLocaleChanged(this, cur_locale, from_locale_, to_locale_)); | |
| 177 } | 183 } |
| 178 } | 184 } |
| 179 | 185 |
| 180 void LocaleChangeGuard::AcceptLocaleChange() { | 186 void LocaleChangeGuard::AcceptLocaleChange() { |
| 181 if (profile_ == NULL || | 187 if (profile_ == NULL || |
| 182 from_locale_.empty() || | 188 from_locale_.empty() || |
| 183 to_locale_.empty()) { | 189 to_locale_.empty()) { |
| 184 NOTREACHED(); | 190 NOTREACHED(); |
| 185 return; | 191 return; |
| 186 } | 192 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 if (by_user) | 234 if (by_user) |
| 229 master_->AcceptLocaleChange(); | 235 master_->AcceptLocaleChange(); |
| 230 } | 236 } |
| 231 | 237 |
| 232 std::string LocaleChangeGuard::Delegate::id() const { | 238 std::string LocaleChangeGuard::Delegate::id() const { |
| 233 // Arbitrary unique Id. | 239 // Arbitrary unique Id. |
| 234 return "8c386938-1e3f-11e0-ac7b-18a90520e2e5"; | 240 return "8c386938-1e3f-11e0-ac7b-18a90520e2e5"; |
| 235 } | 241 } |
| 236 | 242 |
| 237 } // namespace chromeos | 243 } // namespace chromeos |
| OLD | NEW |