| OLD | NEW |
| 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/common/extensions/permissions/bluetooth_device_permission.h" | 5 #include "chrome/common/extensions/permissions/bluetooth_device_permission.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 bool BluetoothDevicePermission::ManifestEntryForbidden() const { | 33 bool BluetoothDevicePermission::ManifestEntryForbidden() const { |
| 34 return true; | 34 return true; |
| 35 } | 35 } |
| 36 | 36 |
| 37 PermissionMessages BluetoothDevicePermission::GetMessages() const { | 37 PermissionMessages BluetoothDevicePermission::GetMessages() const { |
| 38 DCHECK(HasMessages()); | 38 DCHECK(HasMessages()); |
| 39 PermissionMessages result; | 39 PermissionMessages result; |
| 40 | 40 |
| 41 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter = | 41 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter = |
| 42 device::BluetoothAdapterFactory::GetAdapter(); | 42 device::BluetoothAdapterFactory::MaybeGetAdapter(); |
| 43 | 43 |
| 44 for (std::set<BluetoothDevicePermissionData>::const_iterator i = | 44 for (std::set<BluetoothDevicePermissionData>::const_iterator i = |
| 45 data_set_.begin(); i != data_set_.end(); ++i) { | 45 data_set_.begin(); i != data_set_.end(); ++i) { |
| 46 | 46 |
| 47 const std::string& device_address = i->device_address(); | 47 const std::string& device_address = i->device_address(); |
| 48 string16 device_identifier; | 48 string16 device_identifier; |
| 49 if (bluetooth_adapter) { | 49 if (bluetooth_adapter) { |
| 50 device::BluetoothDevice* device = | 50 device::BluetoothDevice* device = |
| 51 bluetooth_adapter->GetDevice(device_address); | 51 bluetooth_adapter->GetDevice(device_address); |
| 52 if (device) | 52 if (device) |
| 53 device_identifier = device->GetName(); | 53 device_identifier = device->GetName(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 if (device_identifier.length() == 0) { | 56 if (device_identifier.length() == 0) { |
| 57 UTF8ToUTF16(device_address.c_str(), device_address.length(), | 57 UTF8ToUTF16(device_address.c_str(), device_address.length(), |
| 58 &device_identifier); | 58 &device_identifier); |
| 59 } | 59 } |
| 60 | 60 |
| 61 result.push_back(PermissionMessage( | 61 result.push_back(PermissionMessage( |
| 62 PermissionMessage::kBluetoothDevice, | 62 PermissionMessage::kBluetoothDevice, |
| 63 l10n_util::GetStringFUTF16( | 63 l10n_util::GetStringFUTF16( |
| 64 IDS_EXTENSION_PROMPT_WARNING_BLUETOOTH_DEVICE, | 64 IDS_EXTENSION_PROMPT_WARNING_BLUETOOTH_DEVICE, |
| 65 device_identifier))); | 65 device_identifier))); |
| 66 } | 66 } |
| 67 | 67 |
| 68 return result; | 68 return result; |
| 69 } | 69 } |
| 70 | 70 |
| 71 } // namespace extensions | 71 } // namespace extensions |
| OLD | NEW |