| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/ash/system_tray_delegate_chromeos.h" | 5 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 info.address = device->GetAddress(); | 690 info.address = device->GetAddress(); |
| 691 info.display_name = device->GetName(); | 691 info.display_name = device->GetName(); |
| 692 info.connected = device->IsConnected(); | 692 info.connected = device->IsConnected(); |
| 693 info.connecting = device->IsConnecting(); | 693 info.connecting = device->IsConnecting(); |
| 694 info.paired = device->IsPaired(); | 694 info.paired = device->IsPaired(); |
| 695 list->push_back(info); | 695 list->push_back(info); |
| 696 } | 696 } |
| 697 } | 697 } |
| 698 | 698 |
| 699 void SystemTrayDelegateChromeOS::BluetoothStartDiscovering() { | 699 void SystemTrayDelegateChromeOS::BluetoothStartDiscovering() { |
| 700 if (bluetooth_discovery_session_.get() && | 700 if (GetBluetoothDiscovering()) { |
| 701 bluetooth_discovery_session_->IsActive()) { | |
| 702 LOG(WARNING) << "Already have active Bluetooth device discovery session."; | 701 LOG(WARNING) << "Already have active Bluetooth device discovery session."; |
| 703 return; | 702 return; |
| 704 } | 703 } |
| 705 VLOG(1) << "Requesting new Bluetooth device discovery session."; | 704 VLOG(1) << "Requesting new Bluetooth device discovery session."; |
| 706 should_run_bluetooth_discovery_ = true; | 705 should_run_bluetooth_discovery_ = true; |
| 707 bluetooth_adapter_->StartDiscoverySession( | 706 bluetooth_adapter_->StartDiscoverySession( |
| 708 base::Bind(&SystemTrayDelegateChromeOS::OnStartBluetoothDiscoverySession, | 707 base::Bind(&SystemTrayDelegateChromeOS::OnStartBluetoothDiscoverySession, |
| 709 weak_ptr_factory_.GetWeakPtr()), | 708 weak_ptr_factory_.GetWeakPtr()), |
| 710 base::Bind(&BluetoothSetDiscoveringError)); | 709 base::Bind(&BluetoothSetDiscoveringError)); |
| 711 } | 710 } |
| 712 | 711 |
| 713 void SystemTrayDelegateChromeOS::BluetoothStopDiscovering() { | 712 void SystemTrayDelegateChromeOS::BluetoothStopDiscovering() { |
| 714 should_run_bluetooth_discovery_ = false; | 713 should_run_bluetooth_discovery_ = false; |
| 715 if (!bluetooth_discovery_session_.get() || | 714 if (!GetBluetoothDiscovering()) { |
| 716 !bluetooth_discovery_session_->IsActive()) { | |
| 717 LOG(WARNING) << "No active Bluetooth device discovery session."; | 715 LOG(WARNING) << "No active Bluetooth device discovery session."; |
| 718 return; | 716 return; |
| 719 } | 717 } |
| 720 VLOG(1) << "Stopping Bluetooth device discovery session."; | 718 VLOG(1) << "Stopping Bluetooth device discovery session."; |
| 721 bluetooth_discovery_session_->Stop( | 719 bluetooth_discovery_session_->Stop( |
| 722 base::Bind(&base::DoNothing), base::Bind(&BluetoothSetDiscoveringError)); | 720 base::Bind(&base::DoNothing), base::Bind(&BluetoothSetDiscoveringError)); |
| 723 } | 721 } |
| 724 | 722 |
| 725 void SystemTrayDelegateChromeOS::ConnectToBluetoothDevice( | 723 void SystemTrayDelegateChromeOS::ConnectToBluetoothDevice( |
| 726 const std::string& address) { | 724 const std::string& address) { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 } | 860 } |
| 863 | 861 |
| 864 bool SystemTrayDelegateChromeOS::GetBluetoothAvailable() { | 862 bool SystemTrayDelegateChromeOS::GetBluetoothAvailable() { |
| 865 return bluetooth_adapter_->IsPresent(); | 863 return bluetooth_adapter_->IsPresent(); |
| 866 } | 864 } |
| 867 | 865 |
| 868 bool SystemTrayDelegateChromeOS::GetBluetoothEnabled() { | 866 bool SystemTrayDelegateChromeOS::GetBluetoothEnabled() { |
| 869 return bluetooth_adapter_->IsPowered(); | 867 return bluetooth_adapter_->IsPowered(); |
| 870 } | 868 } |
| 871 | 869 |
| 870 bool SystemTrayDelegateChromeOS::GetBluetoothDiscovering() { |
| 871 return (bluetooth_discovery_session_.get() && |
| 872 bluetooth_discovery_session_->IsActive()); |
| 873 } |
| 874 |
| 872 void SystemTrayDelegateChromeOS::ChangeProxySettings() { | 875 void SystemTrayDelegateChromeOS::ChangeProxySettings() { |
| 873 CHECK(GetUserLoginStatus() == ash::user::LOGGED_IN_NONE); | 876 CHECK(GetUserLoginStatus() == ash::user::LOGGED_IN_NONE); |
| 874 LoginDisplayHostImpl::default_host()->OpenProxySettings(); | 877 LoginDisplayHostImpl::default_host()->OpenProxySettings(); |
| 875 } | 878 } |
| 876 | 879 |
| 877 ash::VolumeControlDelegate* | 880 ash::VolumeControlDelegate* |
| 878 SystemTrayDelegateChromeOS::GetVolumeControlDelegate() const { | 881 SystemTrayDelegateChromeOS::GetVolumeControlDelegate() const { |
| 879 return volume_control_delegate_.get(); | 882 return volume_control_delegate_.get(); |
| 880 } | 883 } |
| 881 | 884 |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1341 | 1344 |
| 1342 void SystemTrayDelegateChromeOS::OnStartBluetoothDiscoverySession( | 1345 void SystemTrayDelegateChromeOS::OnStartBluetoothDiscoverySession( |
| 1343 scoped_ptr<device::BluetoothDiscoverySession> discovery_session) { | 1346 scoped_ptr<device::BluetoothDiscoverySession> discovery_session) { |
| 1344 // If the discovery session was returned after a request to stop discovery | 1347 // If the discovery session was returned after a request to stop discovery |
| 1345 // (e.g. the user dismissed the Bluetooth detailed view before the call | 1348 // (e.g. the user dismissed the Bluetooth detailed view before the call |
| 1346 // returned), don't claim the discovery session and let it clean up. | 1349 // returned), don't claim the discovery session and let it clean up. |
| 1347 if (!should_run_bluetooth_discovery_) | 1350 if (!should_run_bluetooth_discovery_) |
| 1348 return; | 1351 return; |
| 1349 VLOG(1) << "Claiming new Bluetooth device discovery session."; | 1352 VLOG(1) << "Claiming new Bluetooth device discovery session."; |
| 1350 bluetooth_discovery_session_ = discovery_session.Pass(); | 1353 bluetooth_discovery_session_ = discovery_session.Pass(); |
| 1354 GetSystemTrayNotifier()->NotifyBluetoothDiscoveringChanged(); |
| 1351 } | 1355 } |
| 1352 | 1356 |
| 1353 void SystemTrayDelegateChromeOS::UpdateEnterpriseDomain() { | 1357 void SystemTrayDelegateChromeOS::UpdateEnterpriseDomain() { |
| 1354 policy::BrowserPolicyConnectorChromeOS* connector = | 1358 policy::BrowserPolicyConnectorChromeOS* connector = |
| 1355 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 1359 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 1356 std::string enterprise_domain = connector->GetEnterpriseDomain(); | 1360 std::string enterprise_domain = connector->GetEnterpriseDomain(); |
| 1357 if (enterprise_domain_ != enterprise_domain) { | 1361 if (enterprise_domain_ != enterprise_domain) { |
| 1358 enterprise_domain_ = enterprise_domain; | 1362 enterprise_domain_ = enterprise_domain; |
| 1359 GetSystemTrayNotifier()->NotifyEnterpriseDomainChanged(); | 1363 GetSystemTrayNotifier()->NotifyEnterpriseDomainChanged(); |
| 1360 } | 1364 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1399 accessibility_subscription_.reset(); | 1403 accessibility_subscription_.reset(); |
| 1400 else | 1404 else |
| 1401 OnAccessibilityModeChanged(details.notify); | 1405 OnAccessibilityModeChanged(details.notify); |
| 1402 } | 1406 } |
| 1403 | 1407 |
| 1404 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 1408 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
| 1405 return new SystemTrayDelegateChromeOS(); | 1409 return new SystemTrayDelegateChromeOS(); |
| 1406 } | 1410 } |
| 1407 | 1411 |
| 1408 } // namespace chromeos | 1412 } // namespace chromeos |
| OLD | NEW |