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