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

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: 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/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
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
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 device_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
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_ =
222 device_bluetooth::BluetoothAdapterFactory::DefaultAdapter();
223 DCHECK(bluetooth_adapter_.get());
222 bluetooth_adapter_->AddObserver(this); 224 bluetooth_adapter_->AddObserver(this);
223 } 225 }
224 226
225 virtual ~SystemTrayDelegate() { 227 virtual ~SystemTrayDelegate() {
226 AudioHandler* audiohandler = AudioHandler::GetInstance(); 228 AudioHandler* audiohandler = AudioHandler::GetInstance();
227 if (audiohandler) 229 if (audiohandler)
228 audiohandler->RemoveVolumeObserver(this); 230 audiohandler->RemoveVolumeObserver(this);
229 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); 231 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this);
230 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); 232 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this);
231 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); 233 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 virtual void RequestLockScreen() OVERRIDE { 359 virtual void RequestLockScreen() OVERRIDE {
358 DBusThreadManager::Get()->GetSessionManagerClient()->RequestLockScreen(); 360 DBusThreadManager::Get()->GetSessionManagerClient()->RequestLockScreen();
359 } 361 }
360 362
361 virtual void RequestRestart() OVERRIDE { 363 virtual void RequestRestart() OVERRIDE {
362 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); 364 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart();
363 } 365 }
364 366
365 virtual void GetAvailableBluetoothDevices( 367 virtual void GetAvailableBluetoothDevices(
366 ash::BluetoothDeviceList* list) OVERRIDE { 368 ash::BluetoothDeviceList* list) OVERRIDE {
367 BluetoothAdapter::DeviceList devices = bluetooth_adapter_->GetDevices(); 369 device_bluetooth::BluetoothAdapter::DeviceList devices =
370 bluetooth_adapter_->GetDevices();
368 for (size_t i = 0; i < devices.size(); ++i) { 371 for (size_t i = 0; i < devices.size(); ++i) {
369 BluetoothDevice* device = devices[i]; 372 device_bluetooth::BluetoothDevice* device = devices[i];
370 if (!device->IsPaired()) 373 if (!device->IsPaired())
371 continue; 374 continue;
372 ash::BluetoothDeviceInfo info; 375 ash::BluetoothDeviceInfo info;
373 info.address = device->address(); 376 info.address = device->address();
374 info.display_name = device->GetName(); 377 info.display_name = device->GetName();
375 info.connected = device->IsConnected(); 378 info.connected = device->IsConnected();
376 list->push_back(info); 379 list->push_back(info);
377 } 380 }
378 } 381 }
379 382
380 virtual void ToggleBluetoothConnection(const std::string& address) OVERRIDE { 383 virtual void ToggleBluetoothConnection(const std::string& address) OVERRIDE {
381 BluetoothDevice* device = bluetooth_adapter_->GetDevice(address); 384 device_bluetooth::BluetoothDevice* device =
385 bluetooth_adapter_->GetDevice(address);
382 if (!device) 386 if (!device)
383 return; 387 return;
384 if (device->IsConnected()) { 388 if (device->IsConnected()) {
385 device->Disconnect( 389 device->Disconnect(
386 base::Bind(&base::DoNothing), 390 base::Bind(&base::DoNothing),
387 base::Bind(&BluetoothDeviceDisconnectError)); 391 base::Bind(&BluetoothDeviceDisconnectError));
388 } else if (device->IsPaired()) { 392 } else if (device->IsPaired()) {
389 device->Connect( 393 device->Connect(
390 NULL, 394 NULL,
391 base::Bind(&base::DoNothing), 395 base::Bind(&base::DoNothing),
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 if (!gdata::util::IsGDataAvailable(profile)) 1151 if (!gdata::util::IsGDataAvailable(profile))
1148 return NULL; 1152 return NULL;
1149 return DriveSystemServiceFactory::FindForProfile(profile); 1153 return DriveSystemServiceFactory::FindForProfile(profile);
1150 } 1154 }
1151 1155
1152 // Overridden from system::TimezoneSettings::Observer. 1156 // Overridden from system::TimezoneSettings::Observer.
1153 virtual void TimezoneChanged(const icu::TimeZone& timezone) OVERRIDE { 1157 virtual void TimezoneChanged(const icu::TimeZone& timezone) OVERRIDE {
1154 NotifyRefreshClock(); 1158 NotifyRefreshClock();
1155 } 1159 }
1156 1160
1157 // Overridden from BluetoothAdapter::Observer. 1161 // Overridden from device_bluetooth::BluetoothAdapter::Observer.
1158 virtual void AdapterPresentChanged(BluetoothAdapter* adapter, 1162 virtual void AdapterPresentChanged(
1159 bool present) OVERRIDE { 1163 device_bluetooth::BluetoothAdapter* adapter,
1164 bool present) OVERRIDE {
1160 NotifyRefreshBluetooth(); 1165 NotifyRefreshBluetooth();
1161 } 1166 }
1162 1167
1163 virtual void AdapterPoweredChanged(BluetoothAdapter* adapter, 1168 virtual void AdapterPoweredChanged(
1164 bool powered) OVERRIDE { 1169 device_bluetooth::BluetoothAdapter* adapter,
1170 bool powered) OVERRIDE {
1165 NotifyRefreshBluetooth(); 1171 NotifyRefreshBluetooth();
1166 } 1172 }
1167 1173
1168 virtual void AdapterDiscoveringChanged(BluetoothAdapter* adapter, 1174 virtual void AdapterDiscoveringChanged(
1169 bool discovering) OVERRIDE { 1175 device_bluetooth::BluetoothAdapter* adapter,
1176 bool discovering) OVERRIDE {
1170 // TODO: Perhaps start/stop throbbing the icon, or some other visual 1177 // TODO: Perhaps start/stop throbbing the icon, or some other visual
1171 // effects? 1178 // effects?
1172 } 1179 }
1173 1180
1174 virtual void DeviceAdded(BluetoothAdapter* adapter, 1181 virtual void DeviceAdded(device_bluetooth::BluetoothAdapter* adapter,
1175 BluetoothDevice* device) OVERRIDE { 1182 device_bluetooth::BluetoothDevice* device) OVERRIDE {
1176 NotifyRefreshBluetooth(); 1183 NotifyRefreshBluetooth();
1177 } 1184 }
1178 1185
1179 virtual void DeviceChanged(BluetoothAdapter* adapter, 1186 virtual void DeviceChanged(
1180 BluetoothDevice* device) OVERRIDE { 1187 device_bluetooth::BluetoothAdapter* adapter,
1188 device_bluetooth::BluetoothDevice* device) OVERRIDE {
1181 NotifyRefreshBluetooth(); 1189 NotifyRefreshBluetooth();
1182 } 1190 }
1183 1191
1184 virtual void DeviceRemoved(BluetoothAdapter* adapter, 1192 virtual void DeviceRemoved(
1185 BluetoothDevice* device) OVERRIDE { 1193 device_bluetooth::BluetoothAdapter* adapter,
1194 device_bluetooth::BluetoothDevice* device) OVERRIDE {
1186 NotifyRefreshBluetooth(); 1195 NotifyRefreshBluetooth();
1187 } 1196 }
1188 1197
1189 // Overridden from SystemKeyEventListener::CapsLockObserver. 1198 // Overridden from SystemKeyEventListener::CapsLockObserver.
1190 virtual void OnCapsLockChange(bool enabled) OVERRIDE { 1199 virtual void OnCapsLockChange(bool enabled) OVERRIDE {
1191 bool search_mapped_to_caps_lock = false; 1200 bool search_mapped_to_caps_lock = false;
1192 if (!base::chromeos::IsRunningOnChromeOS() || 1201 if (!base::chromeos::IsRunningOnChromeOS() ||
1193 search_key_mapped_to_ == input_method::kCapsLockKey) 1202 search_key_mapped_to_ == input_method::kCapsLockKey)
1194 search_mapped_to_caps_lock = true; 1203 search_mapped_to_caps_lock = true;
1195 1204
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 std::string active_network_path_; 1253 std::string active_network_path_;
1245 PowerSupplyStatus power_supply_status_; 1254 PowerSupplyStatus power_supply_status_;
1246 base::HourClockType clock_type_; 1255 base::HourClockType clock_type_;
1247 int search_key_mapped_to_; 1256 int search_key_mapped_to_;
1248 bool screen_locked_; 1257 bool screen_locked_;
1249 ConnectionState connected_network_state_; 1258 ConnectionState connected_network_state_;
1250 std::string connected_network_path_; 1259 std::string connected_network_path_;
1251 1260
1252 std::string last_connection_string_; 1261 std::string last_connection_string_;
1253 1262
1254 scoped_refptr<BluetoothAdapter> bluetooth_adapter_; 1263 scoped_refptr<device_bluetooth::BluetoothAdapter> bluetooth_adapter_;
1255 1264
1256 BooleanPrefMember accessibility_enabled_; 1265 BooleanPrefMember accessibility_enabled_;
1257 1266
1258 scoped_ptr<DataPromoNotification> data_promo_notification_; 1267 scoped_ptr<DataPromoNotification> data_promo_notification_;
1259 1268
1260 scoped_ptr<ash::VolumeControlDelegate> volume_control_delegate_; 1269 scoped_ptr<ash::VolumeControlDelegate> volume_control_delegate_;
1261 1270
1262 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); 1271 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate);
1263 }; 1272 };
1264 1273
1265 } // namespace 1274 } // namespace
1266 1275
1267 ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) { 1276 ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) {
1268 return new chromeos::SystemTrayDelegate(tray); 1277 return new chromeos::SystemTrayDelegate(tray);
1269 } 1278 }
1270 1279
1271 } // namespace chromeos 1280 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698