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

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

Powered by Google App Engine
This is Rietveld 408576698