| 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 12 matching lines...) Expand all Loading... |
| 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/utf_string_conversions.h" | 29 #include "base/utf_string_conversions.h" |
| 30 #include "chrome/browser/browser_process.h" | 30 #include "chrome/browser/browser_process.h" |
| 31 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 31 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 32 #include "chrome/browser/chromeos/audio/audio_handler.h" | 32 #include "chrome/browser/chromeos/audio/audio_handler.h" |
| 33 #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h" | |
| 34 #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter_factory.h" | |
| 35 #include "chrome/browser/chromeos/bluetooth/bluetooth_device.h" | |
| 36 #include "chrome/browser/chromeos/cros/cros_library.h" | 33 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 37 #include "chrome/browser/chromeos/cros/network_library.h" | 34 #include "chrome/browser/chromeos/cros/network_library.h" |
| 38 #include "chrome/browser/chromeos/drive/drive_system_service.h" | 35 #include "chrome/browser/chromeos/drive/drive_system_service.h" |
| 39 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 36 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
| 40 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 37 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 41 #include "chrome/browser/chromeos/input_method/xkeyboard.h" | 38 #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
| 42 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" | 39 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" |
| 43 #include "chrome/browser/chromeos/login/base_login_display_host.h" | 40 #include "chrome/browser/chromeos/login/base_login_display_host.h" |
| 44 #include "chrome/browser/chromeos/login/login_display_host.h" | 41 #include "chrome/browser/chromeos/login/login_display_host.h" |
| 45 #include "chrome/browser/chromeos/login/message_bubble.h" | 42 #include "chrome/browser/chromeos/login/message_bubble.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 65 #include "chrome/common/chrome_notification_types.h" | 62 #include "chrome/common/chrome_notification_types.h" |
| 66 #include "chrome/common/pref_names.h" | 63 #include "chrome/common/pref_names.h" |
| 67 #include "chrome/common/url_constants.h" | 64 #include "chrome/common/url_constants.h" |
| 68 #include "chromeos/dbus/dbus_thread_manager.h" | 65 #include "chromeos/dbus/dbus_thread_manager.h" |
| 69 #include "chromeos/dbus/power_manager_client.h" | 66 #include "chromeos/dbus/power_manager_client.h" |
| 70 #include "chromeos/dbus/session_manager_client.h" | 67 #include "chromeos/dbus/session_manager_client.h" |
| 71 #include "content/public/browser/browser_thread.h" | 68 #include "content/public/browser/browser_thread.h" |
| 72 #include "content/public/browser/notification_observer.h" | 69 #include "content/public/browser/notification_observer.h" |
| 73 #include "content/public/browser/notification_service.h" | 70 #include "content/public/browser/notification_service.h" |
| 74 #include "content/public/browser/user_metrics.h" | 71 #include "content/public/browser/user_metrics.h" |
| 72 #include "device/bluetooth/bluetooth_adapter.h" |
| 73 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 74 #include "device/bluetooth/bluetooth_device.h" |
| 75 #include "grit/generated_resources.h" | 75 #include "grit/generated_resources.h" |
| 76 #include "ui/base/l10n/l10n_util.h" | 76 #include "ui/base/l10n/l10n_util.h" |
| 77 | 77 |
| 78 using drive::DriveSystemService; | 78 using drive::DriveSystemService; |
| 79 using drive::DriveSystemServiceFactory; | 79 using drive::DriveSystemServiceFactory; |
| 80 | 80 |
| 81 namespace chromeos { | 81 namespace chromeos { |
| 82 | 82 |
| 83 namespace { | 83 namespace { |
| 84 | 84 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 public SessionManagerClient::Observer, | 147 public SessionManagerClient::Observer, |
| 148 public NetworkMenuIcon::Delegate, | 148 public NetworkMenuIcon::Delegate, |
| 149 public NetworkMenu::Delegate, | 149 public NetworkMenu::Delegate, |
| 150 public NetworkLibrary::NetworkManagerObserver, | 150 public NetworkLibrary::NetworkManagerObserver, |
| 151 public NetworkLibrary::NetworkObserver, | 151 public NetworkLibrary::NetworkObserver, |
| 152 public NetworkLibrary::CellularDataPlanObserver, | 152 public NetworkLibrary::CellularDataPlanObserver, |
| 153 public drive::DriveServiceObserver, | 153 public drive::DriveServiceObserver, |
| 154 public content::NotificationObserver, | 154 public content::NotificationObserver, |
| 155 public input_method::InputMethodManager::Observer, | 155 public input_method::InputMethodManager::Observer, |
| 156 public system::TimezoneSettings::Observer, | 156 public system::TimezoneSettings::Observer, |
| 157 public BluetoothAdapter::Observer, | 157 public device::BluetoothAdapter::Observer, |
| 158 public SystemKeyEventListener::CapsLockObserver, | 158 public SystemKeyEventListener::CapsLockObserver, |
| 159 public ash::NetworkTrayDelegate { | 159 public ash::NetworkTrayDelegate { |
| 160 public: | 160 public: |
| 161 explicit SystemTrayDelegate(ash::SystemTray* tray) | 161 explicit SystemTrayDelegate(ash::SystemTray* tray) |
| 162 : tray_(tray), | 162 : tray_(tray), |
| 163 ui_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST( | 163 ui_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST( |
| 164 new base::WeakPtrFactory<SystemTrayDelegate>(this))), | 164 new base::WeakPtrFactory<SystemTrayDelegate>(this))), |
| 165 network_icon_(ALLOW_THIS_IN_INITIALIZER_LIST( | 165 network_icon_(ALLOW_THIS_IN_INITIALIZER_LIST( |
| 166 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))), | 166 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))), |
| 167 network_icon_dark_(ALLOW_THIS_IN_INITIALIZER_LIST( | 167 network_icon_dark_(ALLOW_THIS_IN_INITIALIZER_LIST( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 registrar_.Add(this, | 209 registrar_.Add(this, |
| 210 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 210 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
| 211 content::NotificationService::AllSources()); | 211 content::NotificationService::AllSources()); |
| 212 | 212 |
| 213 accessibility_enabled_.Init(prefs::kSpokenFeedbackEnabled, | 213 accessibility_enabled_.Init(prefs::kSpokenFeedbackEnabled, |
| 214 g_browser_process->local_state(), this); | 214 g_browser_process->local_state(), this); |
| 215 | 215 |
| 216 network_icon_->SetResourceColorTheme(NetworkMenuIcon::COLOR_LIGHT); | 216 network_icon_->SetResourceColorTheme(NetworkMenuIcon::COLOR_LIGHT); |
| 217 network_icon_dark_->SetResourceColorTheme(NetworkMenuIcon::COLOR_DARK); | 217 network_icon_dark_->SetResourceColorTheme(NetworkMenuIcon::COLOR_DARK); |
| 218 | 218 |
| 219 bluetooth_adapter_ = BluetoothAdapterFactory::DefaultAdapter(); | 219 bluetooth_adapter_ = device::BluetoothAdapterFactory::DefaultAdapter(); |
| 220 bluetooth_adapter_->AddObserver(this); | 220 bluetooth_adapter_->AddObserver(this); |
| 221 } | 221 } |
| 222 | 222 |
| 223 virtual ~SystemTrayDelegate() { | 223 virtual ~SystemTrayDelegate() { |
| 224 AudioHandler* audiohandler = AudioHandler::GetInstance(); | 224 AudioHandler* audiohandler = AudioHandler::GetInstance(); |
| 225 if (audiohandler) | 225 if (audiohandler) |
| 226 audiohandler->RemoveVolumeObserver(this); | 226 audiohandler->RemoveVolumeObserver(this); |
| 227 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); | 227 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); |
| 228 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | 228 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
| 229 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); | 229 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 virtual void RequestLockScreen() OVERRIDE { | 355 virtual void RequestLockScreen() OVERRIDE { |
| 356 DBusThreadManager::Get()->GetSessionManagerClient()->RequestLockScreen(); | 356 DBusThreadManager::Get()->GetSessionManagerClient()->RequestLockScreen(); |
| 357 } | 357 } |
| 358 | 358 |
| 359 virtual void RequestRestart() OVERRIDE { | 359 virtual void RequestRestart() OVERRIDE { |
| 360 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); | 360 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); |
| 361 } | 361 } |
| 362 | 362 |
| 363 virtual void GetAvailableBluetoothDevices( | 363 virtual void GetAvailableBluetoothDevices( |
| 364 ash::BluetoothDeviceList* list) OVERRIDE { | 364 ash::BluetoothDeviceList* list) OVERRIDE { |
| 365 BluetoothAdapter::DeviceList devices = bluetooth_adapter_->GetDevices(); | 365 device::BluetoothAdapter::DeviceList devices = |
| 366 bluetooth_adapter_->GetDevices(); |
| 366 for (size_t i = 0; i < devices.size(); ++i) { | 367 for (size_t i = 0; i < devices.size(); ++i) { |
| 367 BluetoothDevice* device = devices[i]; | 368 device::BluetoothDevice* device = devices[i]; |
| 368 if (!device->IsPaired()) | 369 if (!device->IsPaired()) |
| 369 continue; | 370 continue; |
| 370 ash::BluetoothDeviceInfo info; | 371 ash::BluetoothDeviceInfo info; |
| 371 info.address = device->address(); | 372 info.address = device->address(); |
| 372 info.display_name = device->GetName(); | 373 info.display_name = device->GetName(); |
| 373 info.connected = device->IsConnected(); | 374 info.connected = device->IsConnected(); |
| 374 list->push_back(info); | 375 list->push_back(info); |
| 375 } | 376 } |
| 376 } | 377 } |
| 377 | 378 |
| 378 virtual void ToggleBluetoothConnection(const std::string& address) OVERRIDE { | 379 virtual void ToggleBluetoothConnection(const std::string& address) OVERRIDE { |
| 379 BluetoothDevice* device = bluetooth_adapter_->GetDevice(address); | 380 device::BluetoothDevice* device = bluetooth_adapter_->GetDevice(address); |
| 380 if (!device) | 381 if (!device) |
| 381 return; | 382 return; |
| 382 if (device->IsConnected()) { | 383 if (device->IsConnected()) { |
| 383 device->Disconnect( | 384 device->Disconnect( |
| 384 base::Bind(&base::DoNothing), | 385 base::Bind(&base::DoNothing), |
| 385 base::Bind(&BluetoothDeviceDisconnectError)); | 386 base::Bind(&BluetoothDeviceDisconnectError)); |
| 386 } else if (device->IsPaired()) { | 387 } else if (device->IsPaired()) { |
| 387 device->Connect( | 388 device->Connect( |
| 388 NULL, | 389 NULL, |
| 389 base::Bind(&base::DoNothing), | 390 base::Bind(&base::DoNothing), |
| (...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 Profile* profile = ProfileManager::GetDefaultProfile(); | 1145 Profile* profile = ProfileManager::GetDefaultProfile(); |
| 1145 return DriveSystemServiceFactory::FindForProfile(profile); | 1146 return DriveSystemServiceFactory::FindForProfile(profile); |
| 1146 } | 1147 } |
| 1147 | 1148 |
| 1148 // Overridden from system::TimezoneSettings::Observer. | 1149 // Overridden from system::TimezoneSettings::Observer. |
| 1149 virtual void TimezoneChanged(const icu::TimeZone& timezone) OVERRIDE { | 1150 virtual void TimezoneChanged(const icu::TimeZone& timezone) OVERRIDE { |
| 1150 NotifyRefreshClock(); | 1151 NotifyRefreshClock(); |
| 1151 } | 1152 } |
| 1152 | 1153 |
| 1153 // Overridden from BluetoothAdapter::Observer. | 1154 // Overridden from BluetoothAdapter::Observer. |
| 1154 virtual void AdapterPresentChanged(BluetoothAdapter* adapter, | 1155 virtual void AdapterPresentChanged(device::BluetoothAdapter* adapter, |
| 1155 bool present) OVERRIDE { | 1156 bool present) OVERRIDE { |
| 1156 NotifyRefreshBluetooth(); | 1157 NotifyRefreshBluetooth(); |
| 1157 } | 1158 } |
| 1158 | 1159 |
| 1159 virtual void AdapterPoweredChanged(BluetoothAdapter* adapter, | 1160 virtual void AdapterPoweredChanged(device::BluetoothAdapter* adapter, |
| 1160 bool powered) OVERRIDE { | 1161 bool powered) OVERRIDE { |
| 1161 NotifyRefreshBluetooth(); | 1162 NotifyRefreshBluetooth(); |
| 1162 } | 1163 } |
| 1163 | 1164 |
| 1164 virtual void AdapterDiscoveringChanged(BluetoothAdapter* adapter, | 1165 virtual void AdapterDiscoveringChanged(device::BluetoothAdapter* adapter, |
| 1165 bool discovering) OVERRIDE { | 1166 bool discovering) OVERRIDE { |
| 1166 // TODO: Perhaps start/stop throbbing the icon, or some other visual | 1167 // TODO: Perhaps start/stop throbbing the icon, or some other visual |
| 1167 // effects? | 1168 // effects? |
| 1168 } | 1169 } |
| 1169 | 1170 |
| 1170 virtual void DeviceAdded(BluetoothAdapter* adapter, | 1171 virtual void DeviceAdded(device::BluetoothAdapter* adapter, |
| 1171 BluetoothDevice* device) OVERRIDE { | 1172 device::BluetoothDevice* device) OVERRIDE { |
| 1172 NotifyRefreshBluetooth(); | 1173 NotifyRefreshBluetooth(); |
| 1173 } | 1174 } |
| 1174 | 1175 |
| 1175 virtual void DeviceChanged(BluetoothAdapter* adapter, | 1176 virtual void DeviceChanged(device::BluetoothAdapter* adapter, |
| 1176 BluetoothDevice* device) OVERRIDE { | 1177 device::BluetoothDevice* device) OVERRIDE { |
| 1177 NotifyRefreshBluetooth(); | 1178 NotifyRefreshBluetooth(); |
| 1178 } | 1179 } |
| 1179 | 1180 |
| 1180 virtual void DeviceRemoved(BluetoothAdapter* adapter, | 1181 virtual void DeviceRemoved(device::BluetoothAdapter* adapter, |
| 1181 BluetoothDevice* device) OVERRIDE { | 1182 device::BluetoothDevice* device) OVERRIDE { |
| 1182 NotifyRefreshBluetooth(); | 1183 NotifyRefreshBluetooth(); |
| 1183 } | 1184 } |
| 1184 | 1185 |
| 1185 // Overridden from SystemKeyEventListener::CapsLockObserver. | 1186 // Overridden from SystemKeyEventListener::CapsLockObserver. |
| 1186 virtual void OnCapsLockChange(bool enabled) OVERRIDE { | 1187 virtual void OnCapsLockChange(bool enabled) OVERRIDE { |
| 1187 bool search_mapped_to_caps_lock = false; | 1188 bool search_mapped_to_caps_lock = false; |
| 1188 if (!base::chromeos::IsRunningOnChromeOS() || | 1189 if (!base::chromeos::IsRunningOnChromeOS() || |
| 1189 search_key_mapped_to_ == input_method::kCapsLockKey) | 1190 search_key_mapped_to_ == input_method::kCapsLockKey) |
| 1190 search_mapped_to_caps_lock = true; | 1191 search_mapped_to_caps_lock = true; |
| 1191 | 1192 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 std::string active_network_path_; | 1241 std::string active_network_path_; |
| 1241 PowerSupplyStatus power_supply_status_; | 1242 PowerSupplyStatus power_supply_status_; |
| 1242 base::HourClockType clock_type_; | 1243 base::HourClockType clock_type_; |
| 1243 int search_key_mapped_to_; | 1244 int search_key_mapped_to_; |
| 1244 bool screen_locked_; | 1245 bool screen_locked_; |
| 1245 ConnectionState connected_network_state_; | 1246 ConnectionState connected_network_state_; |
| 1246 std::string connected_network_path_; | 1247 std::string connected_network_path_; |
| 1247 | 1248 |
| 1248 std::string last_connection_string_; | 1249 std::string last_connection_string_; |
| 1249 | 1250 |
| 1250 scoped_refptr<BluetoothAdapter> bluetooth_adapter_; | 1251 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_; |
| 1251 | 1252 |
| 1252 BooleanPrefMember accessibility_enabled_; | 1253 BooleanPrefMember accessibility_enabled_; |
| 1253 | 1254 |
| 1254 scoped_ptr<DataPromoNotification> data_promo_notification_; | 1255 scoped_ptr<DataPromoNotification> data_promo_notification_; |
| 1255 | 1256 |
| 1256 scoped_ptr<ash::VolumeControlDelegate> volume_control_delegate_; | 1257 scoped_ptr<ash::VolumeControlDelegate> volume_control_delegate_; |
| 1257 | 1258 |
| 1258 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); | 1259 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); |
| 1259 }; | 1260 }; |
| 1260 | 1261 |
| 1261 } // namespace | 1262 } // namespace |
| 1262 | 1263 |
| 1263 ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) { | 1264 ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) { |
| 1264 return new chromeos::SystemTrayDelegate(tray); | 1265 return new chromeos::SystemTrayDelegate(tray); |
| 1265 } | 1266 } |
| 1266 | 1267 |
| 1267 } // namespace chromeos | 1268 } // namespace chromeos |
| OLD | NEW |