| Index: chrome/browser/chromeos/system/ash_system_tray_delegate.cc
|
| diff --git a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
|
| index b538e307150e6202f432eca26b2754398b290319..1963242872441030dad7d44d2eade67f78195916 100644
|
| --- a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
|
| +++ b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
|
| @@ -7,6 +7,7 @@
|
| #include "ash/shell.h"
|
| #include "ash/shell_window_ids.h"
|
| #include "ash/system/audio/audio_observer.h"
|
| +#include "ash/system/bluetooth/bluetooth_observer.h"
|
| #include "ash/system/brightness/brightness_observer.h"
|
| #include "ash/system/ime/ime_observer.h"
|
| #include "ash/system/network/network_observer.h"
|
| @@ -22,6 +23,8 @@
|
| #include "base/utf_string_conversions.h"
|
| #include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/chromeos/audio/audio_handler.h"
|
| +#include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h"
|
| +#include "chrome/browser/chromeos/bluetooth/bluetooth_device.h"
|
| #include "chrome/browser/chromeos/cros/cros_library.h"
|
| #include "chrome/browser/chromeos/cros/network_library.h"
|
| #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
|
| @@ -65,6 +68,9 @@ ash::NetworkIconInfo CreateNetworkIconInfo(const Network* network,
|
| return info;
|
| }
|
|
|
| +void BluetoothPowerFailure() {
|
| +}
|
| +
|
| class SystemTrayDelegate : public ash::SystemTrayDelegate,
|
| public AudioHandler::VolumeObserver,
|
| public PowerManagerClient::Observer,
|
| @@ -76,6 +82,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
|
| public content::NotificationObserver,
|
| public input_method::InputMethodManager::Observer,
|
| public system::TimezoneSettings::Observer,
|
| + public BluetoothAdapter::Observer,
|
| public SystemKeyEventListener::CapsLockObserver {
|
| public:
|
| explicit SystemTrayDelegate(ash::SystemTray* tray)
|
| @@ -122,6 +129,9 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
|
|
|
| accessibility_enabled_.Init(prefs::kSpokenFeedbackEnabled,
|
| g_browser_process->local_state(), this);
|
| +
|
| + bluetooth_adapter_.reset(BluetoothAdapter::CreateDefaultAdapter());
|
| + bluetooth_adapter_->AddObserver(this);
|
| }
|
|
|
| virtual ~SystemTrayDelegate() {
|
| @@ -193,6 +203,10 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
|
| GetAppropriateBrowser()->OpenInternetOptionsDialog();
|
| }
|
|
|
| + virtual void ShowBluetoothSettings() OVERRIDE {
|
| + // TODO(sad): Make this work.
|
| + }
|
| +
|
| virtual void ShowHelp() OVERRIDE {
|
| GetAppropriateBrowser()->ShowHelpTab();
|
| }
|
| @@ -236,6 +250,20 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
|
| NotifyScreenLockRequested();
|
| }
|
|
|
| + virtual ash::BluetoothDeviceList GetAvailableBluetoothDevices() OVERRIDE {
|
| + BluetoothAdapter::DeviceList devices = bluetooth_adapter_->GetDevices();
|
| + ash::BluetoothDeviceList list;
|
| + for (size_t i = 0; i < devices.size(); ++i) {
|
| + BluetoothDevice* device = devices[i];
|
| + ash::BluetoothDeviceInfo info;
|
| + info.address = device->address();
|
| + info.display_name = device->GetName();
|
| + info.connected = device->IsConnected();
|
| + list.push_back(info);
|
| + }
|
| + return list;
|
| + }
|
| +
|
| virtual ash::IMEInfoList GetAvailableIMEList() OVERRIDE {
|
| ash::IMEInfoList list;
|
| input_method::InputMethodManager* manager =
|
| @@ -327,6 +355,10 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
|
| network_menu_->ConnectToNetwork(network);
|
| }
|
|
|
| + virtual void AddBluetoothDevice() OVERRIDE {
|
| + GetAppropriateBrowser()->OpenAddBluetoothDeviceDialog();
|
| + }
|
| +
|
| virtual void ToggleAirplaneMode() OVERRIDE {
|
| NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
|
| crosnet->EnableOfflineMode(!crosnet->offline_mode());
|
| @@ -340,6 +372,11 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
|
| network_menu_->ToggleCellular();
|
| }
|
|
|
| + virtual void ToggleBluetooth() OVERRIDE {
|
| + bluetooth_adapter_->SetPowered(!bluetooth_adapter_->IsPowered(),
|
| + base::Bind(&BluetoothPowerFailure));
|
| + }
|
| +
|
| virtual bool GetWifiAvailable() OVERRIDE {
|
| return CrosLibrary::Get()->GetNetworkLibrary()->wifi_available();
|
| }
|
| @@ -348,6 +385,10 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
|
| return CrosLibrary::Get()->GetNetworkLibrary()->cellular_available();
|
| }
|
|
|
| + virtual bool GetBluetoothAvailable() OVERRIDE {
|
| + return bluetooth_adapter_->IsPresent();
|
| + }
|
| +
|
| virtual bool GetWifiEnabled() OVERRIDE {
|
| return CrosLibrary::Get()->GetNetworkLibrary()->wifi_enabled();
|
| }
|
| @@ -356,6 +397,10 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
|
| return CrosLibrary::Get()->GetNetworkLibrary()->cellular_enabled();
|
| }
|
|
|
| + virtual bool GetBluetoothEnabled() OVERRIDE {
|
| + return bluetooth_adapter_->IsPowered();
|
| + }
|
| +
|
| virtual void ChangeProxySettings() OVERRIDE {
|
| CHECK(GetUserLoginStatus() == ash::user::LOGGED_IN_NONE);
|
| BaseLoginDisplayHost::default_host()->OpenProxySettings();
|
| @@ -406,6 +451,13 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
|
| }
|
| }
|
|
|
| + void NotifyRefreshBluetooth() {
|
| + ash::BluetoothObserver* observer =
|
| + ash::Shell::GetInstance()->tray()->bluetooth_observer();
|
| + if (observer)
|
| + observer->OnBluetoothRefresh();
|
| + }
|
| +
|
| void NotifyRefreshIME() {
|
| ash::IMEObserver* observer =
|
| ash::Shell::GetInstance()->tray()->ime_observer();
|
| @@ -590,6 +642,38 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
|
| NotifyRefreshClock();
|
| }
|
|
|
| + // Overridden from BluetoothAdapter::Observer.
|
| + virtual void AdapterPresentChanged(BluetoothAdapter* adapter,
|
| + bool present) OVERRIDE {
|
| + NotifyRefreshBluetooth();
|
| + }
|
| +
|
| + virtual void AdapterPoweredChanged(BluetoothAdapter* adapter,
|
| + bool powered) OVERRIDE {
|
| + NotifyRefreshBluetooth();
|
| + }
|
| +
|
| + virtual void AdapterDiscoveringChanged(BluetoothAdapter* adapter,
|
| + bool discovering) OVERRIDE {
|
| + // TODO: Perhaps start/stop throbbing the icon, or some other visual
|
| + // effects?
|
| + }
|
| +
|
| + virtual void DeviceAdded(BluetoothAdapter* adapter,
|
| + BluetoothDevice* device) OVERRIDE {
|
| + NotifyRefreshBluetooth();
|
| + }
|
| +
|
| + virtual void DeviceChanged(BluetoothAdapter* adapter,
|
| + BluetoothDevice* device) OVERRIDE {
|
| + NotifyRefreshBluetooth();
|
| + }
|
| +
|
| + virtual void DeviceRemoved(BluetoothAdapter* adapter,
|
| + BluetoothDevice* device) OVERRIDE {
|
| + NotifyRefreshBluetooth();
|
| + }
|
| +
|
| // Overridden from SystemKeyEventListener::CapsLockObserver.
|
| virtual void OnCapsLockChange(bool enabled) OVERRIDE {
|
| ash::CapsLockObserver* observer =
|
| @@ -610,6 +694,8 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
|
| PowerSupplyStatus power_supply_status_;
|
| base::HourClockType clock_type_;
|
|
|
| + scoped_ptr<BluetoothAdapter> bluetooth_adapter_;
|
| +
|
| BooleanPrefMember accessibility_enabled_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate);
|
|
|