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

Side by Side Diff: chrome/browser/chromeos/system/ash_system_tray_delegate.cc

Issue 11312139: Add SystemTrayObservers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/system_tray_observers.h"
19 #include "ash/system/tray_accessibility.h" 20 #include "ash/system/tray_accessibility.h"
20 #include "ash/system/tray_caps_lock.h" 21 #include "ash/system/tray_caps_lock.h"
21 #include "ash/system/user/update_observer.h" 22 #include "ash/system/user/update_observer.h"
22 #include "ash/system/user/user_observer.h" 23 #include "ash/system/user/user_observer.h"
23 #include "ash/volume_control_delegate.h" 24 #include "ash/volume_control_delegate.h"
24 #include "base/bind_helpers.h" 25 #include "base/bind_helpers.h"
25 #include "base/callback.h" 26 #include "base/callback.h"
26 #include "base/chromeos/chromeos_version.h" 27 #include "base/chromeos/chromeos_version.h"
27 #include "base/logging.h" 28 #include "base/logging.h"
28 #include "base/memory/weak_ptr.h" 29 #include "base/memory/weak_ptr.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 network_icon_(ALLOW_THIS_IN_INITIALIZER_LIST( 168 network_icon_(ALLOW_THIS_IN_INITIALIZER_LIST(
168 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))), 169 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))),
169 network_icon_dark_(ALLOW_THIS_IN_INITIALIZER_LIST( 170 network_icon_dark_(ALLOW_THIS_IN_INITIALIZER_LIST(
170 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))), 171 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))),
171 network_menu_(ALLOW_THIS_IN_INITIALIZER_LIST(new NetworkMenu(this))), 172 network_menu_(ALLOW_THIS_IN_INITIALIZER_LIST(new NetworkMenu(this))),
172 clock_type_(base::k24HourClock), 173 clock_type_(base::k24HourClock),
173 search_key_mapped_to_(input_method::kSearchKey), 174 search_key_mapped_to_(input_method::kSearchKey),
174 screen_locked_(false), 175 screen_locked_(false),
175 connected_network_state_(STATE_UNKNOWN), 176 connected_network_state_(STATE_UNKNOWN),
176 data_promo_notification_(new DataPromoNotification()), 177 data_promo_notification_(new DataPromoNotification()),
177 volume_control_delegate_(ALLOW_THIS_IN_INITIALIZER_LIST( 178 volume_control_delegate_(new VolumeController()),
178 new VolumeController)) { 179 system_tray_observers_(new ash::SystemTrayObservers()) {
179 // Register notifications on construction so that events such as 180 // Register notifications on construction so that events such as
180 // PROFILE_CREATED do not get missed if they happen before Initialize(). 181 // PROFILE_CREATED do not get missed if they happen before Initialize().
181 registrar_.Add(this, 182 registrar_.Add(this,
182 chrome::NOTIFICATION_UPGRADE_RECOMMENDED, 183 chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
183 content::NotificationService::AllSources()); 184 content::NotificationService::AllSources());
184 registrar_.Add(this, 185 registrar_.Add(this,
185 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 186 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
186 content::NotificationService::AllSources()); 187 content::NotificationService::AllSources());
187 if (GetUserLoginStatus() == ash::user::LOGGED_IN_NONE) { 188 if (GetUserLoginStatus() == ash::user::LOGGED_IN_NONE) {
188 registrar_.Add(this, 189 registrar_.Add(this,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 g_browser_process->local_state(), this); 222 g_browser_process->local_state(), this);
222 223
223 network_icon_->SetResourceColorTheme(NetworkMenuIcon::COLOR_LIGHT); 224 network_icon_->SetResourceColorTheme(NetworkMenuIcon::COLOR_LIGHT);
224 network_icon_dark_->SetResourceColorTheme(NetworkMenuIcon::COLOR_DARK); 225 network_icon_dark_->SetResourceColorTheme(NetworkMenuIcon::COLOR_DARK);
225 226
226 bluetooth_adapter_ = device::BluetoothAdapterFactory::DefaultAdapter(); 227 bluetooth_adapter_ = device::BluetoothAdapterFactory::DefaultAdapter();
227 bluetooth_adapter_->AddObserver(this); 228 bluetooth_adapter_->AddObserver(this);
228 } 229 }
229 230
230 virtual ~SystemTrayDelegate() { 231 virtual ~SystemTrayDelegate() {
232 // Clear observers first.
233 system_tray_observers_.reset();
234
231 AudioHandler* audiohandler = AudioHandler::GetInstance(); 235 AudioHandler* audiohandler = AudioHandler::GetInstance();
232 if (audiohandler) 236 if (audiohandler)
233 audiohandler->RemoveVolumeObserver(this); 237 audiohandler->RemoveVolumeObserver(this);
234 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); 238 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this);
235 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); 239 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this);
236 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); 240 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
237 if (crosnet) { 241 if (crosnet) {
238 crosnet->RemoveNetworkManagerObserver(this); 242 crosnet->RemoveNetworkManagerObserver(this);
239 crosnet->RemoveCellularDataPlanObserver(this); 243 crosnet->RemoveCellularDataPlanObserver(this);
240 } 244 }
241 input_method::InputMethodManager::GetInstance()->RemoveObserver(this); 245 input_method::InputMethodManager::GetInstance()->RemoveObserver(this);
242 system::TimezoneSettings::GetInstance()->RemoveObserver(this); 246 system::TimezoneSettings::GetInstance()->RemoveObserver(this);
243 if (SystemKeyEventListener::GetInstance()) 247 if (SystemKeyEventListener::GetInstance())
244 SystemKeyEventListener::GetInstance()->RemoveCapsLockObserver(this); 248 SystemKeyEventListener::GetInstance()->RemoveCapsLockObserver(this);
245 bluetooth_adapter_->RemoveObserver(this); 249 bluetooth_adapter_->RemoveObserver(this);
246 250
247 // Stop observing gdata operations. 251 // Stop observing gdata operations.
248 DriveSystemService* system_service = FindDriveSystemService(); 252 DriveSystemService* system_service = FindDriveSystemService();
249 if (system_service) { 253 if (system_service) {
250 system_service->drive_service()->RemoveObserver(this); 254 system_service->drive_service()->RemoveObserver(this);
251 } 255 }
252 } 256 }
253 257
258 virtual ash::SystemTrayObservers* GetSystemTrayObservers() OVERRIDE {
259 return system_tray_observers_.get();
260 }
261
254 // Overridden from ash::SystemTrayDelegate: 262 // Overridden from ash::SystemTrayDelegate:
255 virtual bool GetTrayVisibilityOnStartup() OVERRIDE { 263 virtual bool GetTrayVisibilityOnStartup() OVERRIDE {
256 // In case of OOBE / sign in screen tray will be shown later. 264 // In case of OOBE / sign in screen tray will be shown later.
257 return UserManager::Get()->IsUserLoggedIn(); 265 return UserManager::Get()->IsUserLoggedIn();
258 } 266 }
259 267
260 virtual const string16 GetUserDisplayName() const OVERRIDE { 268 virtual const string16 GetUserDisplayName() const OVERRIDE {
261 return UserManager::Get()->GetLoggedInUser()->GetDisplayName(); 269 return UserManager::Get()->GetLoggedInUser()->GetDisplayName();
262 } 270 }
263 271
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 chrome::ShowSettingsSubPage(GetAppropriateBrowser(), 626 chrome::ShowSettingsSubPage(GetAppropriateBrowser(),
619 chrome::kBluetoothAddDeviceSubPage); 627 chrome::kBluetoothAddDeviceSubPage);
620 } 628 }
621 629
622 virtual void ToggleAirplaneMode() OVERRIDE { 630 virtual void ToggleAirplaneMode() OVERRIDE {
623 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); 631 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
624 crosnet->EnableOfflineMode(!crosnet->offline_mode()); 632 crosnet->EnableOfflineMode(!crosnet->offline_mode());
625 } 633 }
626 634
627 virtual void ToggleWifi() OVERRIDE { 635 virtual void ToggleWifi() OVERRIDE {
628 GetSystemTray()->network_observer()->OnWillToggleWifi(); 636 FOR_EACH_OBSERVER(ash::NetworkObserver,
637 system_tray_observers_->network_observers(),
638 OnWillToggleWifi());
629 network_menu_->ToggleWifi(); 639 network_menu_->ToggleWifi();
630 } 640 }
631 641
632 virtual void ToggleMobile() OVERRIDE { 642 virtual void ToggleMobile() OVERRIDE {
633 network_menu_->ToggleMobile(); 643 network_menu_->ToggleMobile();
634 } 644 }
635 645
636 virtual void ToggleBluetooth() OVERRIDE { 646 virtual void ToggleBluetooth() OVERRIDE {
637 bluetooth_adapter_->SetPowered(!bluetooth_adapter_->IsPowered(), 647 bluetooth_adapter_->SetPowered(!bluetooth_adapter_->IsPowered(),
638 base::Bind(&base::DoNothing), 648 base::Bind(&base::DoNothing),
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 DriveSystemService* system_service = FindDriveSystemService(); 771 DriveSystemService* system_service = FindDriveSystemService();
762 if (!system_service) 772 if (!system_service)
763 return; 773 return;
764 774
765 system_service->drive_service()->AddObserver(this); 775 system_service->drive_service()->AddObserver(this);
766 } 776 }
767 777
768 void UpdateClockType(PrefService* service) { 778 void UpdateClockType(PrefService* service) {
769 clock_type_ = service->GetBoolean(prefs::kUse24HourClock) ? 779 clock_type_ = service->GetBoolean(prefs::kUse24HourClock) ?
770 base::k24HourClock : base::k12HourClock; 780 base::k24HourClock : base::k12HourClock;
771 ash::ClockObserver* observer = GetSystemTray()->clock_observer(); 781 FOR_EACH_OBSERVER(ash::ClockObserver,
772 if (observer) 782 system_tray_observers_->clock_observers(),
773 observer->OnDateFormatChanged(); 783 OnDateFormatChanged());
774 } 784 }
775 785
776 void NotifyRefreshClock() { 786 void NotifyRefreshClock() {
777 ash::ClockObserver* observer = GetSystemTray()->clock_observer(); 787 FOR_EACH_OBSERVER(ash::ClockObserver,
778 if (observer) 788 system_tray_observers_->clock_observers(),
779 observer->Refresh(); 789 Refresh());
780 } 790 }
781 791
782 void NotifyRefreshNetwork() { 792 void NotifyRefreshNetwork() {
783 ash::NetworkObserver* observer = GetSystemTray()->network_observer();
784 chromeos::NetworkLibrary* crosnet = 793 chromeos::NetworkLibrary* crosnet =
785 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); 794 chromeos::CrosLibrary::Get()->GetNetworkLibrary();
786 if (observer) { 795 ash::NetworkIconInfo info;
787 ash::NetworkIconInfo info; 796 info.image = network_icon_->GetIconAndText(&info.description);
788 info.image = network_icon_->GetIconAndText(&info.description); 797 info.tray_icon_visible = network_icon_->ShouldShowIconInTray();
789 info.tray_icon_visible = network_icon_->ShouldShowIconInTray(); 798 FOR_EACH_OBSERVER(ash::NetworkObserver,
790 observer->OnNetworkRefresh(info); 799 system_tray_observers_->network_observers(),
791 } 800 OnNetworkRefresh(info));
792 801 FOR_EACH_OBSERVER(ash::NetworkObserver,
793 ash::NetworkObserver* vpn_observer = GetSystemTray()->vpn_observer(); 802 system_tray_observers_->vpn_observers(),
794 if (vpn_observer) { 803 OnNetworkRefresh(info));
795 ash::NetworkIconInfo info;
796 info.image = network_icon_->GetIconAndText(&info.description);
797 info.tray_icon_visible = network_icon_->ShouldShowIconInTray();
798 vpn_observer->OnNetworkRefresh(info);
799 }
800 804
801 // Update Accessibility. 805 // Update Accessibility.
802 806
803 std::string connected_network_path; 807 std::string connected_network_path;
804 ConnectionState connected_network_state(STATE_UNKNOWN); 808 ConnectionState connected_network_state(STATE_UNKNOWN);
805 if (crosnet->connected_network()) { 809 if (crosnet->connected_network()) {
806 connected_network_path = crosnet->connected_network()->service_path(); 810 connected_network_path = crosnet->connected_network()->service_path();
807 connected_network_state = crosnet->connected_network()->state(); 811 connected_network_state = crosnet->connected_network()->state();
808 } 812 }
809 if (accessibility::IsSpokenFeedbackEnabled()) { 813 if (accessibility::IsSpokenFeedbackEnabled()) {
(...skipping 10 matching lines...) Expand all
820 824
821 if (speak) 825 if (speak)
822 AccessibilitySpeak(crosnet->connected_network()); 826 AccessibilitySpeak(crosnet->connected_network());
823 } 827 }
824 828
825 connected_network_path_ = connected_network_path_; 829 connected_network_path_ = connected_network_path_;
826 connected_network_state_ = connected_network_state; 830 connected_network_state_ = connected_network_state;
827 } 831 }
828 832
829 void NotifyRefreshBluetooth() { 833 void NotifyRefreshBluetooth() {
830 ash::BluetoothObserver* observer = GetSystemTray()->bluetooth_observer(); 834 FOR_EACH_OBSERVER(ash::BluetoothObserver,
831 if (observer) 835 system_tray_observers_->bluetooth_observers(),
832 observer->OnBluetoothRefresh(); 836 OnBluetoothRefresh());
833 } 837 }
834 838
835 void NotifyBluetoothDiscoveringChanged() { 839 void NotifyBluetoothDiscoveringChanged() {
836 ash::BluetoothObserver* observer = GetSystemTray()->bluetooth_observer(); 840 FOR_EACH_OBSERVER(ash::BluetoothObserver,
837 if (observer) 841 system_tray_observers_->bluetooth_observers(),
838 observer->OnBluetoothDiscoveringChanged(); 842 OnBluetoothDiscoveringChanged());
839 } 843 }
840 844
841 void NotifyRefreshIME(bool show_message) { 845 void NotifyRefreshIME(bool show_message) {
842 ash::IMEObserver* observer = GetSystemTray()->ime_observer(); 846 FOR_EACH_OBSERVER(ash::IMEObserver,
843 if (observer) 847 system_tray_observers_->ime_observers(),
844 observer->OnIMERefresh(show_message); 848 OnIMERefresh(show_message));
845 } 849 }
846 850
847 void NotifyRefreshDrive(ash::DriveOperationStatusList& list) { 851 void NotifyRefreshDrive(ash::DriveOperationStatusList& list) {
848 ash::DriveObserver* observer = GetSystemTray()->drive_observer(); 852 FOR_EACH_OBSERVER(ash::DriveObserver,
849 if (observer) 853 system_tray_observers_->drive_observers(),
850 observer->OnDriveRefresh(list); 854 OnDriveRefresh(list));
851 } 855 }
852 856
853 void RefreshNetworkObserver(NetworkLibrary* crosnet) { 857 void RefreshNetworkObserver(NetworkLibrary* crosnet) {
854 const Network* network = crosnet->active_network(); 858 const Network* network = crosnet->active_network();
855 std::string new_path = network ? network->service_path() : std::string(); 859 std::string new_path = network ? network->service_path() : std::string();
856 if (active_network_path_ != new_path) { 860 if (active_network_path_ != new_path) {
857 if (!active_network_path_.empty()) 861 if (!active_network_path_.empty())
858 crosnet->RemoveNetworkObserver(active_network_path_, this); 862 crosnet->RemoveNetworkObserver(active_network_path_, this);
859 if (!new_path.empty()) 863 if (!new_path.empty())
860 crosnet->AddNetworkObserver(new_path, this); 864 crosnet->AddNetworkObserver(new_path, this);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 l10n_util::GetStringUTF16( 968 l10n_util::GetStringUTF16(
965 IDS_STATUSBAR_NETWORK_DEVICE_CONNECTING)); 969 IDS_STATUSBAR_NETWORK_DEVICE_CONNECTING));
966 } 970 }
967 added->insert(network); 971 added->insert(network);
968 list->push_back(info); 972 list->push_back(info);
969 } 973 }
970 974
971 // Overridden from AudioHandler::VolumeObserver. 975 // Overridden from AudioHandler::VolumeObserver.
972 virtual void OnVolumeChanged() OVERRIDE { 976 virtual void OnVolumeChanged() OVERRIDE {
973 float level = AudioHandler::GetInstance()->GetVolumePercent() / 100.f; 977 float level = AudioHandler::GetInstance()->GetVolumePercent() / 100.f;
974 GetSystemTray()->audio_observer()->OnVolumeChanged(level); 978 FOR_EACH_OBSERVER(ash::AudioObserver,
979 system_tray_observers_->audio_observers(),
980 OnVolumeChanged(level));
975 } 981 }
976 982
977 // Overridden from AudioHandler::VolumeObserver. 983 // Overridden from AudioHandler::VolumeObserver.
978 virtual void OnMuteToggled() OVERRIDE { 984 virtual void OnMuteToggled() OVERRIDE {
979 GetSystemTray()->audio_observer()->OnMuteToggled(); 985 FOR_EACH_OBSERVER(ash::AudioObserver,
986 system_tray_observers_->audio_observers(),
987 OnMuteToggled());
980 } 988 }
981 989
982 // Overridden from PowerManagerClient::Observer. 990 // Overridden from PowerManagerClient::Observer.
983 virtual void BrightnessChanged(int level, bool user_initiated) OVERRIDE { 991 virtual void BrightnessChanged(int level, bool user_initiated) OVERRIDE {
984 GetSystemTray()->brightness_observer()-> 992 FOR_EACH_OBSERVER(
985 OnBrightnessChanged(static_cast<double>(level), user_initiated); 993 ash::BrightnessObserver,
994 system_tray_observers_->brightness_observers(),
995 OnBrightnessChanged(static_cast<double>(level), user_initiated));
986 } 996 }
987 997
988 virtual void PowerChanged(const PowerSupplyStatus& power_status) OVERRIDE { 998 virtual void PowerChanged(const PowerSupplyStatus& power_status) OVERRIDE {
989 power_supply_status_ = power_status; 999 power_supply_status_ = power_status;
990 FOR_EACH_OBSERVER(ash::PowerStatusObserver, 1000 FOR_EACH_OBSERVER(ash::PowerStatusObserver,
991 GetSystemTray()->power_status_observers(), 1001 system_tray_observers_->power_status_observers(),
992 OnPowerStatusChanged(power_status)); 1002 OnPowerStatusChanged(power_status));
993 } 1003 }
994 1004
995 virtual void SystemResumed() OVERRIDE { 1005 virtual void SystemResumed() OVERRIDE {
996 NotifyRefreshClock(); 1006 NotifyRefreshClock();
997 } 1007 }
998 1008
999 // Overridden from SessionManagerClient::Observer. 1009 // Overridden from SessionManagerClient::Observer.
1000 virtual void LockScreen() OVERRIDE { 1010 virtual void LockScreen() OVERRIDE {
1001 screen_locked_ = true; 1011 screen_locked_ = true;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 1085
1076 case UpgradeDetector::UPGRADE_ANNOYANCE_ELEVATED: 1086 case UpgradeDetector::UPGRADE_ANNOYANCE_ELEVATED:
1077 severity = ash::UpdateObserver::UPDATE_LOW_GREEN; 1087 severity = ash::UpdateObserver::UPDATE_LOW_GREEN;
1078 break; 1088 break;
1079 1089
1080 case UpgradeDetector::UPGRADE_ANNOYANCE_LOW: 1090 case UpgradeDetector::UPGRADE_ANNOYANCE_LOW:
1081 default: 1091 default:
1082 severity = ash::UpdateObserver::UPDATE_NORMAL; 1092 severity = ash::UpdateObserver::UPDATE_NORMAL;
1083 break; 1093 break;
1084 } 1094 }
1085 ash::UpdateObserver* observer = GetSystemTray()->update_observer(); 1095 FOR_EACH_OBSERVER(ash::UpdateObserver,
1086 if (observer) 1096 system_tray_observers_->update_observers(),
1087 observer->OnUpdateRecommended(severity); 1097 OnUpdateRecommended(severity));
1088 break; 1098 break;
1089 } 1099 }
1090 case chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED: { 1100 case chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED: {
1091 // This notification is also sent on login screen when user avatar 1101 // This notification is also sent on login screen when user avatar
1092 // is loaded from file. 1102 // is loaded from file.
1093 if (GetUserLoginStatus() != ash::user::LOGGED_IN_NONE) { 1103 if (GetUserLoginStatus() != ash::user::LOGGED_IN_NONE) {
1094 ash::UserObserver* observer = GetSystemTray()->user_observer(); 1104 FOR_EACH_OBSERVER(ash::UserObserver,
1095 if (observer) 1105 system_tray_observers_->user_observers(),
1096 observer->OnUserUpdate(); 1106 OnUserUpdate());
1097 } 1107 }
1098 break; 1108 break;
1099 } 1109 }
1100 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: { 1110 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: {
1101 // GData system service exists by the time if enabled. 1111 // GData system service exists by the time if enabled.
1102 ObserveGDataUpdates(); 1112 ObserveGDataUpdates();
1103 break; 1113 break;
1104 } 1114 }
1105 case chrome::NOTIFICATION_PROFILE_CREATED: { 1115 case chrome::NOTIFICATION_PROFILE_CREATED: {
1106 SetProfile(content::Source<Profile>(source).ptr()); 1116 SetProfile(content::Source<Profile>(source).ptr());
(...skipping 14 matching lines...) Expand all
1121 } 1131 }
1122 1132
1123 virtual void OnPreferenceChanged(PrefServiceBase* service, 1133 virtual void OnPreferenceChanged(PrefServiceBase* service,
1124 const std::string& pref) OVERRIDE { 1134 const std::string& pref) OVERRIDE {
1125 if (pref == prefs::kUse24HourClock) { 1135 if (pref == prefs::kUse24HourClock) {
1126 UpdateClockType(static_cast<PrefService*>(service)); 1136 UpdateClockType(static_cast<PrefService*>(service));
1127 } else if (pref == prefs::kLanguageRemapSearchKeyTo) { 1137 } else if (pref == prefs::kLanguageRemapSearchKeyTo) {
1128 search_key_mapped_to_ = 1138 search_key_mapped_to_ =
1129 service->GetInteger(prefs::kLanguageRemapSearchKeyTo); 1139 service->GetInteger(prefs::kLanguageRemapSearchKeyTo);
1130 } else if (pref == prefs::kSpokenFeedbackEnabled) { 1140 } else if (pref == prefs::kSpokenFeedbackEnabled) {
1131 ash::AccessibilityObserver* observer = 1141 FOR_EACH_OBSERVER(
1132 GetSystemTray()->accessibility_observer(); 1142 ash::AccessibilityObserver,
1133 if (observer) { 1143 system_tray_observers_->accessibility_observers(),
1134 observer->OnAccessibilityModeChanged( 1144 OnAccessibilityModeChanged(
1135 service->GetBoolean(prefs::kSpokenFeedbackEnabled)); 1145 service->GetBoolean(prefs::kSpokenFeedbackEnabled)));
1136 }
1137 } else { 1146 } else {
1138 NOTREACHED(); 1147 NOTREACHED();
1139 } 1148 }
1140 } 1149 }
1141 1150
1142 // Overridden from InputMethodManager::Observer. 1151 // Overridden from InputMethodManager::Observer.
1143 virtual void InputMethodChanged( 1152 virtual void InputMethodChanged(
1144 input_method::InputMethodManager* manager, bool show_message) OVERRIDE { 1153 input_method::InputMethodManager* manager, bool show_message) OVERRIDE {
1145 NotifyRefreshIME(show_message); 1154 NotifyRefreshIME(show_message);
1146 } 1155 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 NotifyRefreshBluetooth(); 1246 NotifyRefreshBluetooth();
1238 } 1247 }
1239 1248
1240 // Overridden from SystemKeyEventListener::CapsLockObserver. 1249 // Overridden from SystemKeyEventListener::CapsLockObserver.
1241 virtual void OnCapsLockChange(bool enabled) OVERRIDE { 1250 virtual void OnCapsLockChange(bool enabled) OVERRIDE {
1242 bool search_mapped_to_caps_lock = false; 1251 bool search_mapped_to_caps_lock = false;
1243 if (!base::chromeos::IsRunningOnChromeOS() || 1252 if (!base::chromeos::IsRunningOnChromeOS() ||
1244 search_key_mapped_to_ == input_method::kCapsLockKey) 1253 search_key_mapped_to_ == input_method::kCapsLockKey)
1245 search_mapped_to_caps_lock = true; 1254 search_mapped_to_caps_lock = true;
1246 1255
1247 ash::CapsLockObserver* observer = GetSystemTray()->caps_lock_observer(); 1256 FOR_EACH_OBSERVER(ash::CapsLockObserver,
1248 if (observer) 1257 system_tray_observers_->caps_lock_observers(),
1249 observer->OnCapsLockChanged(enabled, search_mapped_to_caps_lock); 1258 OnCapsLockChanged(enabled, search_mapped_to_caps_lock));
1250 } 1259 }
1251 1260
1252 // Overridden from ash::NetworkTrayDelegate 1261 // Overridden from ash::NetworkTrayDelegate
1253 virtual void NotificationLinkClicked(size_t index) OVERRIDE { 1262 virtual void NotificationLinkClicked(size_t index) OVERRIDE {
1254 // If we have deal info URL defined that means that there're 1263 // If we have deal info URL defined that means that there're
1255 // 2 links in bubble. Let the user close it manually then thus giving 1264 // 2 links in bubble. Let the user close it manually then thus giving
1256 // ability to navigate to second link. 1265 // ability to navigate to second link.
1257 // mobile_data_bubble_ will be set to NULL in BubbleClosing callback. 1266 // mobile_data_bubble_ will be set to NULL in BubbleClosing callback.
1258 std::string deal_info_url = data_promo_notification_->deal_info_url(); 1267 std::string deal_info_url = data_promo_notification_->deal_info_url();
1259 std::string deal_topup_url = data_promo_notification_->deal_topup_url(); 1268 std::string deal_topup_url = data_promo_notification_->deal_topup_url();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 std::string last_connection_string_; 1311 std::string last_connection_string_;
1303 1312
1304 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_; 1313 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_;
1305 1314
1306 BooleanPrefMember accessibility_enabled_; 1315 BooleanPrefMember accessibility_enabled_;
1307 1316
1308 scoped_ptr<DataPromoNotification> data_promo_notification_; 1317 scoped_ptr<DataPromoNotification> data_promo_notification_;
1309 1318
1310 scoped_ptr<ash::VolumeControlDelegate> volume_control_delegate_; 1319 scoped_ptr<ash::VolumeControlDelegate> volume_control_delegate_;
1311 1320
1321 scoped_ptr<ash::SystemTrayObservers> system_tray_observers_;
1322
1312 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); 1323 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate);
1313 }; 1324 };
1314 1325
1315 } // namespace 1326 } // namespace
1316 1327
1317 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 1328 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
1318 return new chromeos::SystemTrayDelegate(); 1329 return new chromeos::SystemTrayDelegate();
1319 } 1330 }
1320 1331
1321 } // namespace chromeos 1332 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698