| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 #include "chrome/browser/ui/browser_finder.h" | 59 #include "chrome/browser/ui/browser_finder.h" |
| 60 #include "chrome/browser/ui/browser.h" | 60 #include "chrome/browser/ui/browser.h" |
| 61 #include "chrome/browser/ui/chrome_pages.h" | 61 #include "chrome/browser/ui/chrome_pages.h" |
| 62 #include "chrome/browser/ui/singleton_tabs.h" | 62 #include "chrome/browser/ui/singleton_tabs.h" |
| 63 #include "chrome/browser/upgrade_detector.h" | 63 #include "chrome/browser/upgrade_detector.h" |
| 64 #include "chrome/common/chrome_notification_types.h" | 64 #include "chrome/common/chrome_notification_types.h" |
| 65 #include "chrome/common/pref_names.h" | 65 #include "chrome/common/pref_names.h" |
| 66 #include "chrome/common/url_constants.h" | 66 #include "chrome/common/url_constants.h" |
| 67 #include "chromeos/dbus/dbus_thread_manager.h" | 67 #include "chromeos/dbus/dbus_thread_manager.h" |
| 68 #include "chromeos/dbus/power_manager_client.h" | 68 #include "chromeos/dbus/power_manager_client.h" |
| 69 #include "chromeos/dbus/session_manager_client.h" |
| 69 #include "content/public/browser/browser_thread.h" | 70 #include "content/public/browser/browser_thread.h" |
| 70 #include "content/public/browser/notification_observer.h" | 71 #include "content/public/browser/notification_observer.h" |
| 71 #include "content/public/browser/notification_service.h" | 72 #include "content/public/browser/notification_service.h" |
| 72 #include "content/public/browser/user_metrics.h" | 73 #include "content/public/browser/user_metrics.h" |
| 73 #include "grit/generated_resources.h" | 74 #include "grit/generated_resources.h" |
| 74 #include "ui/base/l10n/l10n_util.h" | 75 #include "ui/base/l10n/l10n_util.h" |
| 75 | 76 |
| 76 using gdata::GDataFileSystem; | 77 using gdata::GDataFileSystem; |
| 77 using gdata::GDataOperationRegistry; | 78 using gdata::GDataOperationRegistry; |
| 78 using gdata::GDataSystemService; | 79 using gdata::GDataSystemService; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // TODO(sad): Do something? | 146 // TODO(sad): Do something? |
| 146 } | 147 } |
| 147 | 148 |
| 148 void BluetoothDeviceConnectError() { | 149 void BluetoothDeviceConnectError() { |
| 149 // TODO(sad): Do something? | 150 // TODO(sad): Do something? |
| 150 } | 151 } |
| 151 | 152 |
| 152 class SystemTrayDelegate : public ash::SystemTrayDelegate, | 153 class SystemTrayDelegate : public ash::SystemTrayDelegate, |
| 153 public AudioHandler::VolumeObserver, | 154 public AudioHandler::VolumeObserver, |
| 154 public PowerManagerClient::Observer, | 155 public PowerManagerClient::Observer, |
| 156 public SessionManagerClient::Observer, |
| 155 public NetworkMenuIcon::Delegate, | 157 public NetworkMenuIcon::Delegate, |
| 156 public NetworkMenu::Delegate, | 158 public NetworkMenu::Delegate, |
| 157 public NetworkLibrary::NetworkManagerObserver, | 159 public NetworkLibrary::NetworkManagerObserver, |
| 158 public NetworkLibrary::NetworkObserver, | 160 public NetworkLibrary::NetworkObserver, |
| 159 public NetworkLibrary::CellularDataPlanObserver, | 161 public NetworkLibrary::CellularDataPlanObserver, |
| 160 public gdata::GDataOperationRegistry::Observer, | 162 public gdata::GDataOperationRegistry::Observer, |
| 161 public content::NotificationObserver, | 163 public content::NotificationObserver, |
| 162 public input_method::InputMethodManager::Observer, | 164 public input_method::InputMethodManager::Observer, |
| 163 public system::TimezoneSettings::Observer, | 165 public system::TimezoneSettings::Observer, |
| 164 public BluetoothAdapter::Observer, | 166 public BluetoothAdapter::Observer, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 177 clock_type_(base::k24HourClock), | 179 clock_type_(base::k24HourClock), |
| 178 search_key_mapped_to_(input_method::kSearchKey), | 180 search_key_mapped_to_(input_method::kSearchKey), |
| 179 screen_locked_(false), | 181 screen_locked_(false), |
| 180 state_(STATE_UNKNOWN), | 182 state_(STATE_UNKNOWN), |
| 181 connected_network_(NULL), | 183 connected_network_(NULL), |
| 182 data_promo_notification_(new DataPromoNotification()) { | 184 data_promo_notification_(new DataPromoNotification()) { |
| 183 AudioHandler::GetInstance()->AddVolumeObserver(this); | 185 AudioHandler::GetInstance()->AddVolumeObserver(this); |
| 184 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); | 186 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
| 185 DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate( | 187 DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate( |
| 186 PowerManagerClient::UPDATE_INITIAL); | 188 PowerManagerClient::UPDATE_INITIAL); |
| 189 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); |
| 187 | 190 |
| 188 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); | 191 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); |
| 189 crosnet->AddNetworkManagerObserver(this); | 192 crosnet->AddNetworkManagerObserver(this); |
| 190 OnNetworkManagerChanged(crosnet); | 193 OnNetworkManagerChanged(crosnet); |
| 191 crosnet->AddCellularDataPlanObserver(this); | 194 crosnet->AddCellularDataPlanObserver(this); |
| 192 | 195 |
| 193 input_method::InputMethodManager::GetInstance()->AddObserver(this); | 196 input_method::InputMethodManager::GetInstance()->AddObserver(this); |
| 194 | 197 |
| 195 system::TimezoneSettings::GetInstance()->AddObserver(this); | 198 system::TimezoneSettings::GetInstance()->AddObserver(this); |
| 196 | 199 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 219 network_icon_dark_->SetResourceColorTheme(NetworkMenuIcon::COLOR_DARK); | 222 network_icon_dark_->SetResourceColorTheme(NetworkMenuIcon::COLOR_DARK); |
| 220 | 223 |
| 221 bluetooth_adapter_ = BluetoothAdapter::DefaultAdapter(); | 224 bluetooth_adapter_ = BluetoothAdapter::DefaultAdapter(); |
| 222 bluetooth_adapter_->AddObserver(this); | 225 bluetooth_adapter_->AddObserver(this); |
| 223 } | 226 } |
| 224 | 227 |
| 225 virtual ~SystemTrayDelegate() { | 228 virtual ~SystemTrayDelegate() { |
| 226 AudioHandler* audiohandler = AudioHandler::GetInstance(); | 229 AudioHandler* audiohandler = AudioHandler::GetInstance(); |
| 227 if (audiohandler) | 230 if (audiohandler) |
| 228 audiohandler->RemoveVolumeObserver(this); | 231 audiohandler->RemoveVolumeObserver(this); |
| 232 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); |
| 229 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | 233 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
| 230 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); | 234 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); |
| 231 if (crosnet) { | 235 if (crosnet) { |
| 232 crosnet->RemoveNetworkManagerObserver(this); | 236 crosnet->RemoveNetworkManagerObserver(this); |
| 233 crosnet->RemoveCellularDataPlanObserver(this); | 237 crosnet->RemoveCellularDataPlanObserver(this); |
| 234 } | 238 } |
| 235 input_method::InputMethodManager::GetInstance()->RemoveObserver(this); | 239 input_method::InputMethodManager::GetInstance()->RemoveObserver(this); |
| 236 system::TimezoneSettings::GetInstance()->RemoveObserver(this); | 240 system::TimezoneSettings::GetInstance()->RemoveObserver(this); |
| 237 if (SystemKeyEventListener::GetInstance()) | 241 if (SystemKeyEventListener::GetInstance()) |
| 238 SystemKeyEventListener::GetInstance()->RemoveCapsLockObserver(this); | 242 SystemKeyEventListener::GetInstance()->RemoveCapsLockObserver(this); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 377 |
| 374 virtual void ShutDown() OVERRIDE { | 378 virtual void ShutDown() OVERRIDE { |
| 375 DBusThreadManager::Get()->GetPowerManagerClient()->RequestShutdown(); | 379 DBusThreadManager::Get()->GetPowerManagerClient()->RequestShutdown(); |
| 376 } | 380 } |
| 377 | 381 |
| 378 virtual void SignOut() OVERRIDE { | 382 virtual void SignOut() OVERRIDE { |
| 379 browser::AttemptUserExit(); | 383 browser::AttemptUserExit(); |
| 380 } | 384 } |
| 381 | 385 |
| 382 virtual void RequestLockScreen() OVERRIDE { | 386 virtual void RequestLockScreen() OVERRIDE { |
| 383 DBusThreadManager::Get()->GetPowerManagerClient()-> | 387 DBusThreadManager::Get()->GetSessionManagerClient()->RequestLockScreen(); |
| 384 NotifyScreenLockRequested(); | |
| 385 } | 388 } |
| 386 | 389 |
| 387 virtual void RequestRestart() OVERRIDE { | 390 virtual void RequestRestart() OVERRIDE { |
| 388 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); | 391 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); |
| 389 } | 392 } |
| 390 | 393 |
| 391 virtual void GetAvailableBluetoothDevices( | 394 virtual void GetAvailableBluetoothDevices( |
| 392 ash::BluetoothDeviceList* list) OVERRIDE { | 395 ash::BluetoothDeviceList* list) OVERRIDE { |
| 393 BluetoothAdapter::DeviceList devices = bluetooth_adapter_->GetDevices(); | 396 BluetoothAdapter::DeviceList devices = bluetooth_adapter_->GetDevices(); |
| 394 for (size_t i = 0; i < devices.size(); ++i) { | 397 for (size_t i = 0; i < devices.size(); ++i) { |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 virtual void PowerChanged(const PowerSupplyStatus& power_status) OVERRIDE { | 947 virtual void PowerChanged(const PowerSupplyStatus& power_status) OVERRIDE { |
| 945 power_supply_status_ = power_status; | 948 power_supply_status_ = power_status; |
| 946 FOR_EACH_OBSERVER(ash::PowerStatusObserver, tray_->power_status_observers(), | 949 FOR_EACH_OBSERVER(ash::PowerStatusObserver, tray_->power_status_observers(), |
| 947 OnPowerStatusChanged(power_status)); | 950 OnPowerStatusChanged(power_status)); |
| 948 } | 951 } |
| 949 | 952 |
| 950 virtual void SystemResumed() OVERRIDE { | 953 virtual void SystemResumed() OVERRIDE { |
| 951 NotifyRefreshClock(); | 954 NotifyRefreshClock(); |
| 952 } | 955 } |
| 953 | 956 |
| 957 // Overridden from SessionManagerClient::Observer. |
| 954 virtual void LockScreen() OVERRIDE { | 958 virtual void LockScreen() OVERRIDE { |
| 955 screen_locked_ = true; | 959 screen_locked_ = true; |
| 956 ash::Shell::GetInstance()->status_area_widget()-> | 960 ash::Shell::GetInstance()->status_area_widget()-> |
| 957 UpdateAfterLoginStatusChange(GetUserLoginStatus()); | 961 UpdateAfterLoginStatusChange(GetUserLoginStatus()); |
| 958 } | 962 } |
| 959 | 963 |
| 960 virtual void UnlockScreen() OVERRIDE { | 964 virtual void UnlockScreen() OVERRIDE { |
| 961 screen_locked_ = false; | 965 screen_locked_ = false; |
| 962 ash::Shell::GetInstance()->status_area_widget()-> | 966 ash::Shell::GetInstance()->status_area_widget()-> |
| 963 UpdateAfterLoginStatusChange(GetUserLoginStatus()); | 967 UpdateAfterLoginStatusChange(GetUserLoginStatus()); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); | 1247 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); |
| 1244 }; | 1248 }; |
| 1245 | 1249 |
| 1246 } // namespace | 1250 } // namespace |
| 1247 | 1251 |
| 1248 ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) { | 1252 ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) { |
| 1249 return new chromeos::SystemTrayDelegate(tray); | 1253 return new chromeos::SystemTrayDelegate(tray); |
| 1250 } | 1254 } |
| 1251 | 1255 |
| 1252 } // namespace chromeos | 1256 } // namespace chromeos |
| OLD | NEW |