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

Unified Diff: device/bluetooth/bluetooth_adapter_experimental_chromeos.cc

Issue 14898004: Bluetooth: set a name for the adapter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_adapter_experimental_chromeos.cc
diff --git a/device/bluetooth/bluetooth_adapter_experimental_chromeos.cc b/device/bluetooth/bluetooth_adapter_experimental_chromeos.cc
index 6f3a185cbf1ee9832038e6471c48053637cfbe7e..579dbb5120c4bf9a14b92278bd650417c0fa06cc 100644
--- a/device/bluetooth/bluetooth_adapter_experimental_chromeos.cc
+++ b/device/bluetooth/bluetooth_adapter_experimental_chromeos.cc
@@ -7,8 +7,10 @@
#include <string>
#include "base/bind.h"
+#include "base/command_line.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
+#include "chromeos/chromeos_switches.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/experimental_bluetooth_adapter_client.h"
#include "chromeos/dbus/experimental_bluetooth_device_client.h"
@@ -310,6 +312,8 @@ void BluetoothAdapterExperimentalChromeOS::SetAdapter(
VLOG(1) << object_path_.value() << ": using adapter.";
+ SetAdapterName();
+
ExperimentalBluetoothAdapterClient::Properties* properties =
DBusThreadManager::Get()->GetExperimentalBluetoothAdapterClient()->
GetProperties(object_path_);
@@ -337,6 +341,38 @@ void BluetoothAdapterExperimentalChromeOS::SetAdapter(
}
}
+void BluetoothAdapterExperimentalChromeOS::SetAdapterName() {
+ // Set a better name for the adapter than "BlueZ 5.x"; this isn't an ideal
+ // way to do this but it'll do for now. See http://crbug.com/126732 and
+ // http://crbug.com/126802.
+ std::string board;
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(chromeos::switches::kChromeOSReleaseBoard)) {
+ board = command_line->
+ GetSwitchValueASCII(chromeos::switches::kChromeOSReleaseBoard);
+ }
+
+ std::string alias;
+ if (board.substr(0, 6) == "stumpy") {
+ alias = "Chromebox";
+ } else if (board.substr(0, 4) == "link") {
+ alias = "Chromebook Pixel";
+ } else {
+ alias = "Chromebook";
+ }
+
+ DBusThreadManager::Get()->GetExperimentalBluetoothAdapterClient()->
+ GetProperties(object_path_)->alias.Set(
+ alias,
+ base::Bind(&BluetoothAdapterExperimentalChromeOS::OnSetAlias,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void BluetoothAdapterExperimentalChromeOS::OnSetAlias(bool success) {
+ LOG_IF(WARNING, !success) << object_path_.value()
+ << ": Failed to set adapter alias";
+}
+
void BluetoothAdapterExperimentalChromeOS::RemoveAdapter() {
DCHECK(IsPresent());
VLOG(1) << object_path_.value() << ": adapter removed.";

Powered by Google App Engine
This is Rietveld 408576698