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

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

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

Powered by Google App Engine
This is Rietveld 408576698