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/system/ash_system_tray_delegate.h" | 5 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
9 #include "ash/system/audio/audio_observer.h" | 9 #include "ash/system/audio/audio_observer.h" |
10 #include "ash/system/bluetooth/bluetooth_observer.h" | 10 #include "ash/system/bluetooth/bluetooth_observer.h" |
11 #include "ash/system/brightness/brightness_observer.h" | 11 #include "ash/system/brightness/brightness_observer.h" |
12 #include "ash/system/chromeos/network/network_observer.h" | 12 #include "ash/system/chromeos/network/network_observer.h" |
13 #include "ash/system/date/clock_observer.h" | 13 #include "ash/system/date/clock_observer.h" |
14 #include "ash/system/drive/drive_observer.h" | 14 #include "ash/system/drive/drive_observer.h" |
15 #include "ash/system/ime/ime_observer.h" | 15 #include "ash/system/ime/ime_observer.h" |
16 #include "ash/system/power/power_status_observer.h" | 16 #include "ash/system/power/power_status_observer.h" |
17 #include "ash/system/tray/system_tray.h" | 17 #include "ash/system/tray/system_tray.h" |
18 #include "ash/system/tray/system_tray_delegate.h" | 18 #include "ash/system/tray/system_tray_delegate.h" |
19 #include "ash/system/tray_accessibility.h" | 19 #include "ash/system/tray_accessibility.h" |
20 #include "ash/system/tray_caps_lock.h" | 20 #include "ash/system/tray_caps_lock.h" |
21 #include "ash/system/user/update_observer.h" | 21 #include "ash/system/user/update_observer.h" |
22 #include "ash/system/user/user_observer.h" | 22 #include "ash/system/user/user_observer.h" |
23 #include "ash/volume_control_delegate.h" | 23 #include "ash/volume_control_delegate.h" |
24 #include "base/bind_helpers.h" | 24 #include "base/bind_helpers.h" |
25 #include "base/callback.h" | 25 #include "base/callback.h" |
26 #include "base/chromeos/chromeos_version.h" | 26 #include "base/chromeos/chromeos_version.h" |
27 #include "base/logging.h" | 27 #include "base/logging.h" |
28 #include "base/memory/weak_ptr.h" | 28 #include "base/memory/weak_ptr.h" |
| 29 #include "base/prefs/public/pref_observer.h" |
29 #include "base/utf_string_conversions.h" | 30 #include "base/utf_string_conversions.h" |
30 #include "chrome/browser/browser_process.h" | 31 #include "chrome/browser/browser_process.h" |
31 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 32 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
32 #include "chrome/browser/chromeos/audio/audio_handler.h" | 33 #include "chrome/browser/chromeos/audio/audio_handler.h" |
33 #include "chrome/browser/chromeos/cros/cros_library.h" | 34 #include "chrome/browser/chromeos/cros/cros_library.h" |
34 #include "chrome/browser/chromeos/cros/network_library.h" | 35 #include "chrome/browser/chromeos/cros/network_library.h" |
35 #include "chrome/browser/chromeos/drive/drive_system_service.h" | 36 #include "chrome/browser/chromeos/drive/drive_system_service.h" |
36 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 37 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
37 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 38 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
38 #include "chrome/browser/chromeos/input_method/xkeyboard.h" | 39 #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 145 |
145 class SystemTrayDelegate : public ash::SystemTrayDelegate, | 146 class SystemTrayDelegate : public ash::SystemTrayDelegate, |
146 public AudioHandler::VolumeObserver, | 147 public AudioHandler::VolumeObserver, |
147 public PowerManagerClient::Observer, | 148 public PowerManagerClient::Observer, |
148 public SessionManagerClient::Observer, | 149 public SessionManagerClient::Observer, |
149 public NetworkMenuIcon::Delegate, | 150 public NetworkMenuIcon::Delegate, |
150 public NetworkMenu::Delegate, | 151 public NetworkMenu::Delegate, |
151 public NetworkLibrary::NetworkManagerObserver, | 152 public NetworkLibrary::NetworkManagerObserver, |
152 public NetworkLibrary::NetworkObserver, | 153 public NetworkLibrary::NetworkObserver, |
153 public NetworkLibrary::CellularDataPlanObserver, | 154 public NetworkLibrary::CellularDataPlanObserver, |
| 155 public PrefObserver, |
154 public google_apis::DriveServiceObserver, | 156 public google_apis::DriveServiceObserver, |
155 public content::NotificationObserver, | 157 public content::NotificationObserver, |
156 public input_method::InputMethodManager::Observer, | 158 public input_method::InputMethodManager::Observer, |
157 public system::TimezoneSettings::Observer, | 159 public system::TimezoneSettings::Observer, |
158 public device::BluetoothAdapter::Observer, | 160 public device::BluetoothAdapter::Observer, |
159 public SystemKeyEventListener::CapsLockObserver, | 161 public SystemKeyEventListener::CapsLockObserver, |
160 public ash::NetworkTrayDelegate { | 162 public ash::NetworkTrayDelegate { |
161 public: | 163 public: |
162 explicit SystemTrayDelegate(ash::SystemTray* tray) | 164 explicit SystemTrayDelegate(ash::SystemTray* tray) |
163 : tray_(tray), | 165 : tray_(tray), |
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 if (observer) | 1083 if (observer) |
1082 observer->OnUserUpdate(); | 1084 observer->OnUserUpdate(); |
1083 } | 1085 } |
1084 break; | 1086 break; |
1085 } | 1087 } |
1086 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: { | 1088 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: { |
1087 // GData system service exists by the time if enabled. | 1089 // GData system service exists by the time if enabled. |
1088 ObserveGDataUpdates(); | 1090 ObserveGDataUpdates(); |
1089 break; | 1091 break; |
1090 } | 1092 } |
1091 case chrome::NOTIFICATION_PREF_CHANGED: { | |
1092 std::string pref = *content::Details<std::string>(details).ptr(); | |
1093 PrefService* service = content::Source<PrefService>(source).ptr(); | |
1094 if (pref == prefs::kUse24HourClock) { | |
1095 UpdateClockType(service); | |
1096 } else if (pref == prefs::kLanguageXkbRemapSearchKeyTo) { | |
1097 search_key_mapped_to_ = | |
1098 service->GetInteger(prefs::kLanguageXkbRemapSearchKeyTo); | |
1099 } else if (pref == prefs::kSpokenFeedbackEnabled) { | |
1100 ash::AccessibilityObserver* observer = | |
1101 tray_->accessibility_observer(); | |
1102 if (observer) { | |
1103 observer->OnAccessibilityModeChanged( | |
1104 service->GetBoolean(prefs::kSpokenFeedbackEnabled)); | |
1105 } | |
1106 } else { | |
1107 NOTREACHED(); | |
1108 } | |
1109 break; | |
1110 } | |
1111 case chrome::NOTIFICATION_PROFILE_CREATED: { | 1093 case chrome::NOTIFICATION_PROFILE_CREATED: { |
1112 SetProfile(content::Source<Profile>(source).ptr()); | 1094 SetProfile(content::Source<Profile>(source).ptr()); |
1113 registrar_.Remove(this, | 1095 registrar_.Remove(this, |
1114 chrome::NOTIFICATION_PROFILE_CREATED, | 1096 chrome::NOTIFICATION_PROFILE_CREATED, |
1115 content::NotificationService::AllSources()); | 1097 content::NotificationService::AllSources()); |
1116 break; | 1098 break; |
1117 } | 1099 } |
1118 case chrome::NOTIFICATION_SESSION_STARTED: { | 1100 case chrome::NOTIFICATION_SESSION_STARTED: { |
1119 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( | 1101 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( |
1120 GetUserLoginStatus()); | 1102 GetUserLoginStatus()); |
1121 SetProfile(ProfileManager::GetDefaultProfile()); | 1103 SetProfile(ProfileManager::GetDefaultProfile()); |
1122 break; | 1104 break; |
1123 } | 1105 } |
1124 default: | 1106 default: |
1125 NOTREACHED(); | 1107 NOTREACHED(); |
1126 } | 1108 } |
1127 } | 1109 } |
1128 | 1110 |
| 1111 virtual void OnPreferenceChanged(PrefServiceBase* service, |
| 1112 const std::string& pref) OVERRIDE { |
| 1113 if (pref == prefs::kUse24HourClock) { |
| 1114 UpdateClockType(static_cast<PrefService*>(service)); |
| 1115 } else if (pref == prefs::kLanguageXkbRemapSearchKeyTo) { |
| 1116 search_key_mapped_to_ = |
| 1117 service->GetInteger(prefs::kLanguageXkbRemapSearchKeyTo); |
| 1118 } else if (pref == prefs::kSpokenFeedbackEnabled) { |
| 1119 ash::AccessibilityObserver* observer = |
| 1120 tray_->accessibility_observer(); |
| 1121 if (observer) { |
| 1122 observer->OnAccessibilityModeChanged( |
| 1123 service->GetBoolean(prefs::kSpokenFeedbackEnabled)); |
| 1124 } |
| 1125 } else { |
| 1126 NOTREACHED(); |
| 1127 } |
| 1128 } |
| 1129 |
1129 // Overridden from InputMethodManager::Observer. | 1130 // Overridden from InputMethodManager::Observer. |
1130 virtual void InputMethodChanged( | 1131 virtual void InputMethodChanged( |
1131 input_method::InputMethodManager* manager, bool show_message) OVERRIDE { | 1132 input_method::InputMethodManager* manager, bool show_message) OVERRIDE { |
1132 NotifyRefreshIME(show_message); | 1133 NotifyRefreshIME(show_message); |
1133 } | 1134 } |
1134 | 1135 |
1135 virtual void InputMethodPropertyChanged( | 1136 virtual void InputMethodPropertyChanged( |
1136 input_method::InputMethodManager* manager) OVERRIDE { | 1137 input_method::InputMethodManager* manager) OVERRIDE { |
1137 NotifyRefreshIME(false); | 1138 NotifyRefreshIME(false); |
1138 } | 1139 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); | 1301 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); |
1301 }; | 1302 }; |
1302 | 1303 |
1303 } // namespace | 1304 } // namespace |
1304 | 1305 |
1305 ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) { | 1306 ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) { |
1306 return new chromeos::SystemTrayDelegate(tray); | 1307 return new chromeos::SystemTrayDelegate(tray); |
1307 } | 1308 } |
1308 | 1309 |
1309 } // namespace chromeos | 1310 } // namespace chromeos |
OLD | NEW |