OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/dbus/bluetooth_agent_service_provider.h" |
| 6 |
| 7 #include <string> |
| 8 |
| 9 #include "base/bind.h" |
| 10 #include "base/logging.h" |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/threading/platform_thread.h" |
| 13 #include "chrome/browser/chromeos/system/runtime_environment.h" |
| 14 #include "dbus/bus.h" |
| 15 #include "dbus/exported_object.h" |
| 16 #include "dbus/message.h" |
| 17 #include "dbus/object_path.h" |
| 18 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 19 |
| 20 namespace { |
| 21 |
| 22 // Constants used by BlueZ for the ConfirmModeChange method. |
| 23 const char kModeOff[] = "off"; |
| 24 const char kModeConnectable[] = "connectable"; |
| 25 const char kModeDiscoverable[] = "discoverable"; |
| 26 |
| 27 } // namespace |
| 28 |
| 29 namespace chromeos { |
| 30 |
| 31 // The BluetoothAgentServiceProvider implementation used in production. |
| 32 class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider { |
| 33 public: |
| 34 BluetoothAgentServiceProviderImpl(dbus::Bus* bus, |
| 35 const dbus::ObjectPath& object_path, |
| 36 Delegate* delegate) |
| 37 : weak_ptr_factory_(this), |
| 38 origin_thread_id_(base::PlatformThread::CurrentId()), |
| 39 bus_(bus), |
| 40 delegate_(delegate) { |
| 41 DVLOG(1) << "Creating BluetoothAdapterClientImpl for " |
| 42 << object_path.value(); |
| 43 |
| 44 exported_object_ = bus_->GetExportedObject(object_path); |
| 45 |
| 46 exported_object_->ExportMethod( |
| 47 bluetooth_agent::kBluetoothAgentInterface, |
| 48 bluetooth_agent::kRelease, |
| 49 base::Bind(&BluetoothAgentServiceProviderImpl::Release, |
| 50 weak_ptr_factory_.GetWeakPtr()), |
| 51 base::Bind(&BluetoothAgentServiceProviderImpl::ReleaseExported, |
| 52 weak_ptr_factory_.GetWeakPtr())); |
| 53 |
| 54 exported_object_->ExportMethod( |
| 55 bluetooth_agent::kBluetoothAgentInterface, |
| 56 bluetooth_agent::kRequestPinCode, |
| 57 base::Bind(&BluetoothAgentServiceProviderImpl::RequestPinCode, |
| 58 weak_ptr_factory_.GetWeakPtr()), |
| 59 base::Bind(&BluetoothAgentServiceProviderImpl::RequestPinCodeExported, |
| 60 weak_ptr_factory_.GetWeakPtr())); |
| 61 |
| 62 exported_object_->ExportMethod( |
| 63 bluetooth_agent::kBluetoothAgentInterface, |
| 64 bluetooth_agent::kRequestPasskey, |
| 65 base::Bind(&BluetoothAgentServiceProviderImpl::RequestPasskey, |
| 66 weak_ptr_factory_.GetWeakPtr()), |
| 67 base::Bind(&BluetoothAgentServiceProviderImpl::RequestPasskeyExported, |
| 68 weak_ptr_factory_.GetWeakPtr())); |
| 69 |
| 70 exported_object_->ExportMethod( |
| 71 bluetooth_agent::kBluetoothAgentInterface, |
| 72 bluetooth_agent::kDisplayPinCode, |
| 73 base::Bind(&BluetoothAgentServiceProviderImpl::DisplayPinCode, |
| 74 weak_ptr_factory_.GetWeakPtr()), |
| 75 base::Bind(&BluetoothAgentServiceProviderImpl::DisplayPinCodeExported, |
| 76 weak_ptr_factory_.GetWeakPtr())); |
| 77 |
| 78 exported_object_->ExportMethod( |
| 79 bluetooth_agent::kBluetoothAgentInterface, |
| 80 bluetooth_agent::kDisplayPasskey, |
| 81 base::Bind(&BluetoothAgentServiceProviderImpl::DisplayPasskey, |
| 82 weak_ptr_factory_.GetWeakPtr()), |
| 83 base::Bind(&BluetoothAgentServiceProviderImpl::DisplayPasskeyExported, |
| 84 weak_ptr_factory_.GetWeakPtr())); |
| 85 |
| 86 exported_object_->ExportMethod( |
| 87 bluetooth_agent::kBluetoothAgentInterface, |
| 88 bluetooth_agent::kRequestConfirmation, |
| 89 base::Bind(&BluetoothAgentServiceProviderImpl::RequestConfirmation, |
| 90 weak_ptr_factory_.GetWeakPtr()), |
| 91 base::Bind( |
| 92 &BluetoothAgentServiceProviderImpl::RequestConfirmationExported, |
| 93 weak_ptr_factory_.GetWeakPtr())); |
| 94 |
| 95 exported_object_->ExportMethod( |
| 96 bluetooth_agent::kBluetoothAgentInterface, |
| 97 bluetooth_agent::kAuthorize, |
| 98 base::Bind(&BluetoothAgentServiceProviderImpl::Authorize, |
| 99 weak_ptr_factory_.GetWeakPtr()), |
| 100 base::Bind(&BluetoothAgentServiceProviderImpl::AuthorizeExported, |
| 101 weak_ptr_factory_.GetWeakPtr())); |
| 102 |
| 103 exported_object_->ExportMethod( |
| 104 bluetooth_agent::kBluetoothAgentInterface, |
| 105 bluetooth_agent::kConfirmModeChange, |
| 106 base::Bind(&BluetoothAgentServiceProviderImpl::ConfirmModeChange, |
| 107 weak_ptr_factory_.GetWeakPtr()), |
| 108 base::Bind( |
| 109 &BluetoothAgentServiceProviderImpl::ConfirmModeChangeExported, |
| 110 weak_ptr_factory_.GetWeakPtr())); |
| 111 |
| 112 exported_object_->ExportMethod( |
| 113 bluetooth_agent::kBluetoothAgentInterface, |
| 114 bluetooth_agent::kCancel, |
| 115 base::Bind(&BluetoothAgentServiceProviderImpl::Cancel, |
| 116 weak_ptr_factory_.GetWeakPtr()), |
| 117 base::Bind(&BluetoothAgentServiceProviderImpl::CancelExported, |
| 118 weak_ptr_factory_.GetWeakPtr())); |
| 119 } |
| 120 |
| 121 virtual ~BluetoothAgentServiceProviderImpl() { |
| 122 } |
| 123 |
| 124 private: |
| 125 // Returns true if the current thread is on the origin thread. |
| 126 bool OnOriginThread() { |
| 127 return base::PlatformThread::CurrentId() == origin_thread_id_; |
| 128 } |
| 129 |
| 130 // Called by dbus:: when the agent is unregistered from the Bluetooth |
| 131 // daemon, generally at the end of a pairing request. |
| 132 void Release(dbus::MethodCall* method_call, |
| 133 dbus::ExportedObject::ResponseSender response_sender) { |
| 134 DCHECK(OnOriginThread()); |
| 135 DCHECK(delegate_); |
| 136 |
| 137 delegate_->Release(); |
| 138 |
| 139 dbus::Response* response = dbus::Response::FromMethodCall(method_call); |
| 140 response_sender.Run(response); |
| 141 } |
| 142 |
| 143 // Called by dbus:: when the Release method is exported. |
| 144 void ReleaseExported(const std::string& interface_name, |
| 145 const std::string& method_name, |
| 146 bool success) { |
| 147 LOG_IF(WARNING, !success) << "Failed to export " |
| 148 << interface_name << "." << method_name; |
| 149 } |
| 150 |
| 151 // Called by dbus:: when the Bluetooth daemon requires a PIN Code for |
| 152 // device authentication. |
| 153 void RequestPinCode(dbus::MethodCall* method_call, |
| 154 dbus::ExportedObject::ResponseSender response_sender) { |
| 155 DCHECK(OnOriginThread()); |
| 156 DCHECK(delegate_); |
| 157 |
| 158 dbus::MessageReader reader(method_call); |
| 159 dbus::ObjectPath device_path; |
| 160 if (!reader.PopObjectPath(&device_path)) { |
| 161 LOG(WARNING) << "RequestPinCode called with incorrect paramters: " |
| 162 << method_call->ToString(); |
| 163 return; |
| 164 } |
| 165 |
| 166 Delegate::PinCodeCallback callback = base::Bind( |
| 167 &BluetoothAgentServiceProviderImpl::OnPinCode, |
| 168 weak_ptr_factory_.GetWeakPtr(), |
| 169 method_call, |
| 170 response_sender); |
| 171 |
| 172 delegate_->RequestPinCode(device_path, callback); |
| 173 } |
| 174 |
| 175 // Called by dbus:: when the RequestPinCode method is exported. |
| 176 void RequestPinCodeExported(const std::string& interface_name, |
| 177 const std::string& method_name, |
| 178 bool success) { |
| 179 LOG_IF(WARNING, !success) << "Failed to export " |
| 180 << interface_name << "." << method_name; |
| 181 } |
| 182 |
| 183 // Called by dbus:: when the Bluetooth daemon requires a Passkey for |
| 184 // device authentication. |
| 185 void RequestPasskey(dbus::MethodCall* method_call, |
| 186 dbus::ExportedObject::ResponseSender response_sender) { |
| 187 DCHECK(OnOriginThread()); |
| 188 DCHECK(delegate_); |
| 189 |
| 190 dbus::MessageReader reader(method_call); |
| 191 dbus::ObjectPath device_path; |
| 192 if (!reader.PopObjectPath(&device_path)) { |
| 193 LOG(WARNING) << "RequestPasskey called with incorrect paramters: " |
| 194 << method_call->ToString(); |
| 195 return; |
| 196 } |
| 197 |
| 198 Delegate::PasskeyCallback callback = base::Bind( |
| 199 &BluetoothAgentServiceProviderImpl::OnPasskey, |
| 200 weak_ptr_factory_.GetWeakPtr(), |
| 201 method_call, |
| 202 response_sender); |
| 203 |
| 204 delegate_->RequestPasskey(device_path, callback); |
| 205 } |
| 206 |
| 207 // Called by dbus:: when the RequestPasskey method is exported. |
| 208 void RequestPasskeyExported(const std::string& interface_name, |
| 209 const std::string& method_name, |
| 210 bool success) { |
| 211 LOG_IF(WARNING, !success) << "Failed to export " |
| 212 << interface_name << "." << method_name; |
| 213 } |
| 214 |
| 215 // Called by dbus:: when the Bluetooth daemon requires that the user |
| 216 // enter a PIN Code into the remote device so that it may be |
| 217 // authenticated. |
| 218 void DisplayPinCode(dbus::MethodCall* method_call, |
| 219 dbus::ExportedObject::ResponseSender response_sender) { |
| 220 DCHECK(OnOriginThread()); |
| 221 DCHECK(delegate_); |
| 222 |
| 223 dbus::MessageReader reader(method_call); |
| 224 dbus::ObjectPath device_path; |
| 225 std::string pincode; |
| 226 if (!reader.PopObjectPath(&device_path) || |
| 227 !reader.PopString(&pincode)) { |
| 228 LOG(WARNING) << "DisplayPinCode called with incorrect paramters: " |
| 229 << method_call->ToString(); |
| 230 return; |
| 231 } |
| 232 |
| 233 delegate_->DisplayPinCode(device_path, pincode); |
| 234 |
| 235 dbus::Response* response = dbus::Response::FromMethodCall(method_call); |
| 236 response_sender.Run(response); |
| 237 } |
| 238 |
| 239 // Called by dbus:: when the DisplayPinCode method is exported. |
| 240 void DisplayPinCodeExported(const std::string& interface_name, |
| 241 const std::string& method_name, |
| 242 bool success) { |
| 243 LOG_IF(WARNING, !success) << "Failed to export " |
| 244 << interface_name << "." << method_name; |
| 245 } |
| 246 |
| 247 // Called by dbus:: when the Bluetooth daemon requires that the user |
| 248 // enter a Passkey into the remote device so that it may be |
| 249 // authenticated. |
| 250 void DisplayPasskey(dbus::MethodCall* method_call, |
| 251 dbus::ExportedObject::ResponseSender response_sender) { |
| 252 DCHECK(OnOriginThread()); |
| 253 DCHECK(delegate_); |
| 254 |
| 255 dbus::MessageReader reader(method_call); |
| 256 dbus::ObjectPath device_path; |
| 257 uint32 passkey; |
| 258 if (!reader.PopObjectPath(&device_path) || |
| 259 !reader.PopUint32(&passkey)) { |
| 260 LOG(WARNING) << "DisplayPasskey called with incorrect paramters: " |
| 261 << method_call->ToString(); |
| 262 return; |
| 263 } |
| 264 |
| 265 delegate_->DisplayPasskey(device_path, passkey); |
| 266 |
| 267 dbus::Response* response = dbus::Response::FromMethodCall(method_call); |
| 268 response_sender.Run(response); |
| 269 } |
| 270 |
| 271 // Called by dbus:: when the DisplayPasskey method is exported. |
| 272 void DisplayPasskeyExported(const std::string& interface_name, |
| 273 const std::string& method_name, |
| 274 bool success) { |
| 275 LOG_IF(WARNING, !success) << "Failed to export " |
| 276 << interface_name << "." << method_name; |
| 277 } |
| 278 |
| 279 // Called by dbus:: when the Bluetooth daemon requires that the user |
| 280 // confirm that a Passkey is displayed on the screen of the remote |
| 281 // device so that it may be authenticated. |
| 282 void RequestConfirmation( |
| 283 dbus::MethodCall* method_call, |
| 284 dbus::ExportedObject::ResponseSender response_sender) { |
| 285 DCHECK(OnOriginThread()); |
| 286 DCHECK(delegate_); |
| 287 |
| 288 dbus::MessageReader reader(method_call); |
| 289 dbus::ObjectPath device_path; |
| 290 uint32 passkey; |
| 291 if (!reader.PopObjectPath(&device_path) || |
| 292 !reader.PopUint32(&passkey)) { |
| 293 LOG(WARNING) << "RequestConfirmation called with incorrect paramters: " |
| 294 << method_call->ToString(); |
| 295 return; |
| 296 } |
| 297 |
| 298 Delegate::ConfirmationCallback callback = base::Bind( |
| 299 &BluetoothAgentServiceProviderImpl::OnConfirmation, |
| 300 weak_ptr_factory_.GetWeakPtr(), |
| 301 method_call, |
| 302 response_sender); |
| 303 |
| 304 delegate_->RequestConfirmation(device_path, passkey, callback); |
| 305 } |
| 306 |
| 307 // Called by dbus:: when the RequestConfirmation method is exported. |
| 308 void RequestConfirmationExported(const std::string& interface_name, |
| 309 const std::string& method_name, |
| 310 bool success) { |
| 311 LOG_IF(WARNING, !success) << "Failed to export " |
| 312 << interface_name << "." << method_name; |
| 313 } |
| 314 |
| 315 // Called by dbus:: when the Bluetooth daemon requires that the user |
| 316 // confirm that that a remote device is authorized to connect to a service |
| 317 // UUID. |
| 318 void Authorize(dbus::MethodCall* method_call, |
| 319 dbus::ExportedObject::ResponseSender response_sender) { |
| 320 DCHECK(OnOriginThread()); |
| 321 DCHECK(delegate_); |
| 322 |
| 323 dbus::MessageReader reader(method_call); |
| 324 dbus::ObjectPath device_path; |
| 325 std::string uuid; |
| 326 if (!reader.PopObjectPath(&device_path) || |
| 327 !reader.PopString(&uuid)) { |
| 328 LOG(WARNING) << "Authorize called with incorrect paramters: " |
| 329 << method_call->ToString(); |
| 330 return; |
| 331 } |
| 332 |
| 333 Delegate::ConfirmationCallback callback = base::Bind( |
| 334 &BluetoothAgentServiceProviderImpl::OnConfirmation, |
| 335 weak_ptr_factory_.GetWeakPtr(), |
| 336 method_call, |
| 337 response_sender); |
| 338 |
| 339 delegate_->Authorize(device_path, uuid, callback); |
| 340 } |
| 341 |
| 342 // Called by dbus:: when the Authorize method is exported. |
| 343 void AuthorizeExported(const std::string& interface_name, |
| 344 const std::string& method_name, |
| 345 bool success) { |
| 346 LOG_IF(WARNING, !success) << "Failed to export " |
| 347 << interface_name << "." << method_name; |
| 348 } |
| 349 |
| 350 // Called by dbus:: when the Bluetooth daemon requires that the user |
| 351 // confirm that the adapter may change mode. |
| 352 void ConfirmModeChange(dbus::MethodCall* method_call, |
| 353 dbus::ExportedObject::ResponseSender response_sender) { |
| 354 DCHECK(OnOriginThread()); |
| 355 DCHECK(delegate_); |
| 356 |
| 357 dbus::MessageReader reader(method_call); |
| 358 std::string mode_str; |
| 359 if (!reader.PopString(&mode_str)) { |
| 360 LOG(WARNING) << "ConfirmModeChange called with incorrect paramters: " |
| 361 << method_call->ToString(); |
| 362 return; |
| 363 } |
| 364 |
| 365 Delegate::Mode mode; |
| 366 if (mode_str == kModeOff) { |
| 367 mode = Delegate::OFF; |
| 368 } else if (mode_str == kModeConnectable) { |
| 369 mode = Delegate::CONNECTABLE; |
| 370 } else if (mode_str == kModeDiscoverable) { |
| 371 mode = Delegate::DISCOVERABLE; |
| 372 } else { |
| 373 LOG(WARNING) << "ConfirmModeChange called with unknown mode: " |
| 374 << mode_str; |
| 375 return; |
| 376 } |
| 377 |
| 378 Delegate::ConfirmationCallback callback = base::Bind( |
| 379 &BluetoothAgentServiceProviderImpl::OnConfirmation, |
| 380 weak_ptr_factory_.GetWeakPtr(), |
| 381 method_call, |
| 382 response_sender); |
| 383 |
| 384 delegate_->ConfirmModeChange(mode, callback); |
| 385 } |
| 386 |
| 387 // Called by dbus:: when the ConfirmModeChange method is exported. |
| 388 void ConfirmModeChangeExported(const std::string& interface_name, |
| 389 const std::string& method_name, |
| 390 bool success) { |
| 391 LOG_IF(WARNING, !success) << "Failed to export " |
| 392 << interface_name << "." << method_name; |
| 393 } |
| 394 |
| 395 // Called by dbus:: when the request failed before a reply was returned |
| 396 // from the device. |
| 397 void Cancel(dbus::MethodCall* method_call, |
| 398 dbus::ExportedObject::ResponseSender response_sender) { |
| 399 DCHECK(OnOriginThread()); |
| 400 DCHECK(delegate_); |
| 401 |
| 402 delegate_->Cancel(); |
| 403 |
| 404 dbus::Response* response = dbus::Response::FromMethodCall(method_call); |
| 405 response_sender.Run(response); |
| 406 } |
| 407 |
| 408 // Called by dbus:: when the Cancel method is exported. |
| 409 void CancelExported(const std::string& interface_name, |
| 410 const std::string& method_name, |
| 411 bool success) { |
| 412 LOG_IF(WARNING, !success) << "Failed to export " |
| 413 << interface_name << "." << method_name; |
| 414 } |
| 415 |
| 416 // Called by the Delegate to response to a method requesting a PIN code. |
| 417 void OnPinCode(dbus::MethodCall* method_call, |
| 418 dbus::ExportedObject::ResponseSender response_sender, |
| 419 Delegate::Status status, |
| 420 const std::string& pincode) { |
| 421 DCHECK(OnOriginThread()); |
| 422 |
| 423 switch (status) { |
| 424 case Delegate::SUCCESS: { |
| 425 dbus::Response* response = dbus::Response::FromMethodCall(method_call); |
| 426 dbus::MessageWriter writer(response); |
| 427 writer.AppendString(pincode); |
| 428 response_sender.Run(response); |
| 429 break; |
| 430 } |
| 431 case Delegate::REJECTED: { |
| 432 dbus::ErrorResponse* response = dbus::ErrorResponse::FromMethodCall( |
| 433 method_call, bluetooth_agent::kErrorRejected, "rejected"); |
| 434 response_sender.Run(response); |
| 435 break; |
| 436 } |
| 437 case Delegate::CANCELLED: { |
| 438 dbus::ErrorResponse* response = dbus::ErrorResponse::FromMethodCall( |
| 439 method_call, bluetooth_agent::kErrorCanceled, "canceled"); |
| 440 response_sender.Run(response); |
| 441 break; |
| 442 } |
| 443 default: |
| 444 NOTREACHED() << "Unexpected status code from delegate: " << status; |
| 445 } |
| 446 } |
| 447 |
| 448 // Called by the Delegate to response to a method requesting a Passkey. |
| 449 void OnPasskey(dbus::MethodCall* method_call, |
| 450 dbus::ExportedObject::ResponseSender response_sender, |
| 451 Delegate::Status status, |
| 452 uint32 passkey) { |
| 453 DCHECK(OnOriginThread()); |
| 454 |
| 455 switch (status) { |
| 456 case Delegate::SUCCESS: { |
| 457 dbus::Response* response = dbus::Response::FromMethodCall(method_call); |
| 458 dbus::MessageWriter writer(response); |
| 459 writer.AppendUint32(passkey); |
| 460 response_sender.Run(response); |
| 461 break; |
| 462 } |
| 463 case Delegate::REJECTED: { |
| 464 dbus::ErrorResponse* response = dbus::ErrorResponse::FromMethodCall( |
| 465 method_call, bluetooth_agent::kErrorRejected, "rejected"); |
| 466 response_sender.Run(response); |
| 467 break; |
| 468 } |
| 469 case Delegate::CANCELLED: { |
| 470 dbus::ErrorResponse* response = dbus::ErrorResponse::FromMethodCall( |
| 471 method_call, bluetooth_agent::kErrorCanceled, "canceled"); |
| 472 response_sender.Run(response); |
| 473 break; |
| 474 } |
| 475 default: |
| 476 NOTREACHED() << "Unexpected status code from delegate: " << status; |
| 477 } |
| 478 } |
| 479 |
| 480 // Called by the Delegate in response to a method requiring confirmation. |
| 481 void OnConfirmation(dbus::MethodCall* method_call, |
| 482 dbus::ExportedObject::ResponseSender response_sender, |
| 483 Delegate::Status status) { |
| 484 DCHECK(OnOriginThread()); |
| 485 |
| 486 switch (status) { |
| 487 case Delegate::SUCCESS: { |
| 488 dbus::Response* response = dbus::Response::FromMethodCall(method_call); |
| 489 response_sender.Run(response); |
| 490 break; |
| 491 } |
| 492 case Delegate::REJECTED: { |
| 493 dbus::ErrorResponse* response = dbus::ErrorResponse::FromMethodCall( |
| 494 method_call, bluetooth_agent::kErrorRejected, "rejected"); |
| 495 response_sender.Run(response); |
| 496 break; |
| 497 } |
| 498 case Delegate::CANCELLED: { |
| 499 dbus::ErrorResponse* response = dbus::ErrorResponse::FromMethodCall( |
| 500 method_call, bluetooth_agent::kErrorCanceled, "canceled"); |
| 501 response_sender.Run(response); |
| 502 break; |
| 503 } |
| 504 default: |
| 505 NOTREACHED() << "Unexpected status code from delegate: " << status; |
| 506 } |
| 507 } |
| 508 |
| 509 // Weak pointer factory for generating 'this' pointers that might live longer |
| 510 // than we do. |
| 511 base::WeakPtrFactory<BluetoothAgentServiceProviderImpl> weak_ptr_factory_; |
| 512 |
| 513 // Origin thread (i.e. the UI thread in production). |
| 514 base::PlatformThreadId origin_thread_id_; |
| 515 |
| 516 // D-Bus bus object is exported on, not owned by this object and must |
| 517 // outlive it. |
| 518 dbus::Bus* bus_; |
| 519 |
| 520 // All incoming method calls are passed on to the Delegate and a callback |
| 521 // passed to generate the reply. |delegate_| is generally the object that |
| 522 // owns this one, and must outlive it. |
| 523 Delegate* delegate_; |
| 524 |
| 525 // D-Bus object we are exporting, owned by this object. |
| 526 scoped_refptr<dbus::ExportedObject> exported_object_; |
| 527 |
| 528 DISALLOW_COPY_AND_ASSIGN(BluetoothAgentServiceProviderImpl); |
| 529 }; |
| 530 |
| 531 // The BluetoothAgentServiceProvider implementation used on Linux desktop, |
| 532 // which does nothing. |
| 533 class BluetoothAgentServiceProviderStubImpl |
| 534 : public BluetoothAgentServiceProvider { |
| 535 public: |
| 536 explicit BluetoothAgentServiceProviderStubImpl(Delegate* delegate_) { |
| 537 } |
| 538 |
| 539 virtual ~BluetoothAgentServiceProviderStubImpl() { |
| 540 } |
| 541 }; |
| 542 |
| 543 BluetoothAgentServiceProvider::BluetoothAgentServiceProvider() { |
| 544 } |
| 545 |
| 546 BluetoothAgentServiceProvider::~BluetoothAgentServiceProvider() { |
| 547 } |
| 548 |
| 549 // static |
| 550 BluetoothAgentServiceProvider* BluetoothAgentServiceProvider::Create( |
| 551 dbus::Bus* bus, |
| 552 const dbus::ObjectPath& object_path, |
| 553 Delegate* delegate) { |
| 554 if (system::runtime_environment::IsRunningOnChromeOS()) { |
| 555 return new BluetoothAgentServiceProviderImpl(bus, object_path, delegate); |
| 556 } else { |
| 557 return new BluetoothAgentServiceProviderStubImpl(delegate); |
| 558 } |
| 559 } |
| 560 |
| 561 } // namespace chromeos |
OLD | NEW |