| 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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "ash/system/tray_caps_lock.h" | 22 #include "ash/system/tray_caps_lock.h" |
| 23 #include "ash/system/user/update_observer.h" | 23 #include "ash/system/user/update_observer.h" |
| 24 #include "ash/system/user/user_observer.h" | 24 #include "ash/system/user/user_observer.h" |
| 25 #include "ash/volume_control_delegate.h" | 25 #include "ash/volume_control_delegate.h" |
| 26 #include "ash/wm/session_state_controller.h" | 26 #include "ash/wm/session_state_controller.h" |
| 27 #include "base/bind_helpers.h" | 27 #include "base/bind_helpers.h" |
| 28 #include "base/callback.h" | 28 #include "base/callback.h" |
| 29 #include "base/chromeos/chromeos_version.h" | 29 #include "base/chromeos/chromeos_version.h" |
| 30 #include "base/logging.h" | 30 #include "base/logging.h" |
| 31 #include "base/memory/weak_ptr.h" | 31 #include "base/memory/weak_ptr.h" |
| 32 #include "base/prefs/public/pref_observer.h" | |
| 33 #include "base/utf_string_conversions.h" | 32 #include "base/utf_string_conversions.h" |
| 34 #include "chrome/browser/browser_process.h" | 33 #include "chrome/browser/browser_process.h" |
| 35 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 34 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 36 #include "chrome/browser/chromeos/audio/audio_handler.h" | 35 #include "chrome/browser/chromeos/audio/audio_handler.h" |
| 37 #include "chrome/browser/chromeos/cros/cros_library.h" | 36 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 38 #include "chrome/browser/chromeos/cros/network_library.h" | 37 #include "chrome/browser/chromeos/cros/network_library.h" |
| 39 #include "chrome/browser/chromeos/drive/drive_system_service.h" | 38 #include "chrome/browser/chromeos/drive/drive_system_service.h" |
| 40 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 39 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
| 41 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 40 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 42 #include "chrome/browser/chromeos/input_method/xkeyboard.h" | 41 #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 147 |
| 149 class SystemTrayDelegate : public ash::SystemTrayDelegate, | 148 class SystemTrayDelegate : public ash::SystemTrayDelegate, |
| 150 public AudioHandler::VolumeObserver, | 149 public AudioHandler::VolumeObserver, |
| 151 public PowerManagerClient::Observer, | 150 public PowerManagerClient::Observer, |
| 152 public SessionManagerClient::Observer, | 151 public SessionManagerClient::Observer, |
| 153 public NetworkMenuIcon::Delegate, | 152 public NetworkMenuIcon::Delegate, |
| 154 public NetworkMenu::Delegate, | 153 public NetworkMenu::Delegate, |
| 155 public NetworkLibrary::NetworkManagerObserver, | 154 public NetworkLibrary::NetworkManagerObserver, |
| 156 public NetworkLibrary::NetworkObserver, | 155 public NetworkLibrary::NetworkObserver, |
| 157 public NetworkLibrary::CellularDataPlanObserver, | 156 public NetworkLibrary::CellularDataPlanObserver, |
| 158 public PrefObserver, | |
| 159 public google_apis::DriveServiceObserver, | 157 public google_apis::DriveServiceObserver, |
| 160 public content::NotificationObserver, | 158 public content::NotificationObserver, |
| 161 public input_method::InputMethodManager::Observer, | 159 public input_method::InputMethodManager::Observer, |
| 162 public system::TimezoneSettings::Observer, | 160 public system::TimezoneSettings::Observer, |
| 163 public device::BluetoothAdapter::Observer, | 161 public device::BluetoothAdapter::Observer, |
| 164 public SystemKeyEventListener::CapsLockObserver, | 162 public SystemKeyEventListener::CapsLockObserver, |
| 165 public ash::NetworkTrayDelegate { | 163 public ash::NetworkTrayDelegate { |
| 166 public: | 164 public: |
| 167 SystemTrayDelegate() | 165 SystemTrayDelegate() |
| 168 : ui_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST( | 166 : ui_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 OnNetworkManagerChanged(crosnet); | 210 OnNetworkManagerChanged(crosnet); |
| 213 crosnet->AddCellularDataPlanObserver(this); | 211 crosnet->AddCellularDataPlanObserver(this); |
| 214 | 212 |
| 215 input_method::InputMethodManager::GetInstance()->AddObserver(this); | 213 input_method::InputMethodManager::GetInstance()->AddObserver(this); |
| 216 | 214 |
| 217 system::TimezoneSettings::GetInstance()->AddObserver(this); | 215 system::TimezoneSettings::GetInstance()->AddObserver(this); |
| 218 | 216 |
| 219 if (SystemKeyEventListener::GetInstance()) | 217 if (SystemKeyEventListener::GetInstance()) |
| 220 SystemKeyEventListener::GetInstance()->AddCapsLockObserver(this); | 218 SystemKeyEventListener::GetInstance()->AddCapsLockObserver(this); |
| 221 | 219 |
| 222 accessibility_enabled_.Init(prefs::kSpokenFeedbackEnabled, | 220 accessibility_enabled_.Init( |
| 223 g_browser_process->local_state(), this); | 221 prefs::kSpokenFeedbackEnabled, |
| 222 g_browser_process->local_state(), |
| 223 base::Bind(&SystemTrayDelegate::OnSpokenFeedbackEnabledChanged, |
| 224 base::Unretained(this))); |
| 224 | 225 |
| 225 network_icon_->SetResourceColorTheme(NetworkMenuIcon::COLOR_LIGHT); | 226 network_icon_->SetResourceColorTheme(NetworkMenuIcon::COLOR_LIGHT); |
| 226 network_icon_dark_->SetResourceColorTheme(NetworkMenuIcon::COLOR_DARK); | 227 network_icon_dark_->SetResourceColorTheme(NetworkMenuIcon::COLOR_DARK); |
| 227 | 228 |
| 228 bluetooth_adapter_ = device::BluetoothAdapterFactory::DefaultAdapter(); | 229 bluetooth_adapter_ = device::BluetoothAdapterFactory::DefaultAdapter(); |
| 229 bluetooth_adapter_->AddObserver(this); | 230 bluetooth_adapter_->AddObserver(this); |
| 230 } | 231 } |
| 231 | 232 |
| 232 virtual ~SystemTrayDelegate() { | 233 virtual ~SystemTrayDelegate() { |
| 233 AudioHandler* audiohandler = AudioHandler::GetInstance(); | 234 AudioHandler* audiohandler = AudioHandler::GetInstance(); |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 Browser* GetAppropriateBrowser() { | 749 Browser* GetAppropriateBrowser() { |
| 749 return browser::FindOrCreateTabbedBrowser( | 750 return browser::FindOrCreateTabbedBrowser( |
| 750 ProfileManager::GetDefaultProfileOrOffTheRecord(), | 751 ProfileManager::GetDefaultProfileOrOffTheRecord(), |
| 751 chrome::HOST_DESKTOP_TYPE_ASH); | 752 chrome::HOST_DESKTOP_TYPE_ASH); |
| 752 } | 753 } |
| 753 | 754 |
| 754 void SetProfile(Profile* profile) { | 755 void SetProfile(Profile* profile) { |
| 755 PrefService* prefs = profile->GetPrefs(); | 756 PrefService* prefs = profile->GetPrefs(); |
| 756 pref_registrar_.reset(new PrefChangeRegistrar); | 757 pref_registrar_.reset(new PrefChangeRegistrar); |
| 757 pref_registrar_->Init(prefs); | 758 pref_registrar_->Init(prefs); |
| 758 pref_registrar_->Add(prefs::kUse24HourClock, this); | 759 pref_registrar_->Add( |
| 759 pref_registrar_->Add(prefs::kLanguageRemapSearchKeyTo, this); | 760 prefs::kUse24HourClock, |
| 760 pref_registrar_->Add(prefs::kShowLogoutButtonInTray, this); | 761 base::Bind(&SystemTrayDelegate::UpdateClockType, |
| 761 UpdateClockType(prefs); | 762 base::Unretained(this))); |
| 762 UpdateShowLogoutButtonInTray(prefs); | 763 pref_registrar_->Add( |
| 764 prefs::kLanguageRemapSearchKeyTo, |
| 765 base::Bind(&SystemTrayDelegate::OnLanguageRemapSearchKeyToChanged, |
| 766 base::Unretained(this))); |
| 767 pref_registrar_->Add( |
| 768 prefs::kShowLogoutButtonInTray, |
| 769 base::Bind(&SystemTrayDelegate::UpdateShowLogoutButtonInTray, |
| 770 base::Unretained(this))); |
| 771 UpdateClockType(); |
| 772 UpdateShowLogoutButtonInTray(); |
| 763 search_key_mapped_to_ = | 773 search_key_mapped_to_ = |
| 764 profile->GetPrefs()->GetInteger(prefs::kLanguageRemapSearchKeyTo); | 774 profile->GetPrefs()->GetInteger(prefs::kLanguageRemapSearchKeyTo); |
| 765 } | 775 } |
| 766 | 776 |
| 767 void ObserveGDataUpdates() { | 777 void ObserveGDataUpdates() { |
| 768 DriveSystemService* system_service = FindDriveSystemService(); | 778 DriveSystemService* system_service = FindDriveSystemService(); |
| 769 if (!system_service) | 779 if (!system_service) |
| 770 return; | 780 return; |
| 771 | 781 |
| 772 system_service->drive_service()->AddObserver(this); | 782 system_service->drive_service()->AddObserver(this); |
| 773 } | 783 } |
| 774 | 784 |
| 775 void UpdateClockType(PrefServiceBase* service) { | 785 void UpdateClockType() { |
| 776 clock_type_ = service->GetBoolean(prefs::kUse24HourClock) ? | 786 clock_type_ = pref_registrar_->prefs()->GetBoolean(prefs::kUse24HourClock) ? |
| 777 base::k24HourClock : base::k12HourClock; | 787 base::k24HourClock : base::k12HourClock; |
| 778 GetSystemTrayNotifier()->NotifyDateFormatChanged(); | 788 GetSystemTrayNotifier()->NotifyDateFormatChanged(); |
| 779 } | 789 } |
| 780 | 790 |
| 781 void UpdateShowLogoutButtonInTray(PrefServiceBase* service) { | 791 void UpdateShowLogoutButtonInTray() { |
| 782 GetSystemTrayNotifier()->NotifyShowLoginButtonChanged( | 792 GetSystemTrayNotifier()->NotifyShowLoginButtonChanged( |
| 783 service->GetBoolean(prefs::kShowLogoutButtonInTray)); | 793 pref_registrar_->prefs()->GetBoolean(prefs::kShowLogoutButtonInTray)); |
| 784 } | 794 } |
| 785 | 795 |
| 786 void NotifyRefreshNetwork() { | 796 void NotifyRefreshNetwork() { |
| 787 chromeos::NetworkLibrary* crosnet = | 797 chromeos::NetworkLibrary* crosnet = |
| 788 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 798 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 789 ash::NetworkIconInfo info; | 799 ash::NetworkIconInfo info; |
| 790 info.image = network_icon_->GetIconAndText(&info.description); | 800 info.image = network_icon_->GetIconAndText(&info.description); |
| 791 info.tray_icon_visible = network_icon_->ShouldShowIconInTray(); | 801 info.tray_icon_visible = network_icon_->ShouldShowIconInTray(); |
| 792 GetSystemTrayNotifier()->NotifyRefreshNetwork(info); | 802 GetSystemTrayNotifier()->NotifyRefreshNetwork(info); |
| 793 GetSystemTrayNotifier()->NotifyVpnRefreshNetwork(info); | 803 GetSystemTrayNotifier()->NotifyVpnRefreshNetwork(info); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( | 1087 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( |
| 1078 GetUserLoginStatus()); | 1088 GetUserLoginStatus()); |
| 1079 SetProfile(ProfileManager::GetDefaultProfile()); | 1089 SetProfile(ProfileManager::GetDefaultProfile()); |
| 1080 break; | 1090 break; |
| 1081 } | 1091 } |
| 1082 default: | 1092 default: |
| 1083 NOTREACHED(); | 1093 NOTREACHED(); |
| 1084 } | 1094 } |
| 1085 } | 1095 } |
| 1086 | 1096 |
| 1087 virtual void OnPreferenceChanged(PrefServiceBase* service, | 1097 void OnLanguageRemapSearchKeyToChanged() { |
| 1088 const std::string& pref) OVERRIDE { | 1098 search_key_mapped_to_ = pref_registrar_->prefs()->GetInteger( |
| 1089 if (pref == prefs::kUse24HourClock) { | 1099 prefs::kLanguageRemapSearchKeyTo); |
| 1090 UpdateClockType(service); | 1100 } |
| 1091 } else if (pref == prefs::kLanguageRemapSearchKeyTo) { | 1101 |
| 1092 search_key_mapped_to_ = | 1102 void OnSpokenFeedbackEnabledChanged() { |
| 1093 service->GetInteger(prefs::kLanguageRemapSearchKeyTo); | 1103 GetSystemTrayNotifier()->NotifyAccessibilityModeChanged( |
| 1094 } else if (pref == prefs::kSpokenFeedbackEnabled) { | 1104 accessibility_enabled_.prefs()->GetBoolean( |
| 1095 GetSystemTrayNotifier()->NotifyAccessibilityModeChanged( | 1105 prefs::kSpokenFeedbackEnabled)); |
| 1096 service->GetBoolean(prefs::kSpokenFeedbackEnabled)); | |
| 1097 } else if (pref == prefs::kShowLogoutButtonInTray) { | |
| 1098 UpdateShowLogoutButtonInTray(service); | |
| 1099 } else { | |
| 1100 NOTREACHED(); | |
| 1101 } | |
| 1102 } | 1106 } |
| 1103 | 1107 |
| 1104 // Overridden from InputMethodManager::Observer. | 1108 // Overridden from InputMethodManager::Observer. |
| 1105 virtual void InputMethodChanged( | 1109 virtual void InputMethodChanged( |
| 1106 input_method::InputMethodManager* manager, bool show_message) OVERRIDE { | 1110 input_method::InputMethodManager* manager, bool show_message) OVERRIDE { |
| 1107 GetSystemTrayNotifier()->NotifyRefreshIME(show_message); | 1111 GetSystemTrayNotifier()->NotifyRefreshIME(show_message); |
| 1108 } | 1112 } |
| 1109 | 1113 |
| 1110 virtual void InputMethodPropertyChanged( | 1114 virtual void InputMethodPropertyChanged( |
| 1111 input_method::InputMethodManager* manager) OVERRIDE { | 1115 input_method::InputMethodManager* manager) OVERRIDE { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1272 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); | 1276 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); |
| 1273 }; | 1277 }; |
| 1274 | 1278 |
| 1275 } // namespace | 1279 } // namespace |
| 1276 | 1280 |
| 1277 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 1281 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
| 1278 return new chromeos::SystemTrayDelegate(); | 1282 return new chromeos::SystemTrayDelegate(); |
| 1279 } | 1283 } |
| 1280 | 1284 |
| 1281 } // namespace chromeos | 1285 } // namespace chromeos |
| OLD | NEW |