OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/bluetooth/bluetooth_private_api.h" | 5 #include "extensions/browser/api/bluetooth/bluetooth_private_api.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/strings/string_piece.h" |
13 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
14 #include "device/bluetooth/bluetooth_adapter.h" | 15 #include "device/bluetooth/bluetooth_adapter.h" |
15 #include "device/bluetooth/bluetooth_adapter_factory.h" | 16 #include "device/bluetooth/bluetooth_adapter_factory.h" |
16 #include "device/bluetooth/bluetooth_common.h" | 17 #include "device/bluetooth/bluetooth_common.h" |
17 #include "device/bluetooth/bluetooth_discovery_session.h" | 18 #include "device/bluetooth/bluetooth_discovery_session.h" |
18 #include "extensions/browser/api/bluetooth/bluetooth_api.h" | 19 #include "extensions/browser/api/bluetooth/bluetooth_api.h" |
19 #include "extensions/browser/api/bluetooth/bluetooth_api_pairing_delegate.h" | 20 #include "extensions/browser/api/bluetooth/bluetooth_api_pairing_delegate.h" |
20 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" | 21 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" |
21 #include "extensions/common/api/bluetooth_private.h" | 22 #include "extensions/common/api/bluetooth_private.h" |
22 | 23 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 pending_properties_.erase(property); | 224 pending_properties_.erase(property); |
224 failed_properties_.insert(property); | 225 failed_properties_.insert(property); |
225 if (pending_properties_.empty() && parsed_) | 226 if (pending_properties_.empty() && parsed_) |
226 SendError(); | 227 SendError(); |
227 } | 228 } |
228 | 229 |
229 void BluetoothPrivateSetAdapterStateFunction::SendError() { | 230 void BluetoothPrivateSetAdapterStateFunction::SendError() { |
230 DCHECK(pending_properties_.empty()); | 231 DCHECK(pending_properties_.empty()); |
231 DCHECK(!failed_properties_.empty()); | 232 DCHECK(!failed_properties_.empty()); |
232 | 233 |
233 std::vector<std::string> failed_vector; | 234 std::vector<base::StringPiece> failed_vector(failed_properties_.begin(), |
234 std::copy(failed_properties_.begin(), failed_properties_.end(), | 235 failed_properties_.end()); |
235 std::back_inserter(failed_vector)); | |
236 | 236 |
237 std::vector<std::string> replacements(1); | 237 std::vector<std::string> replacements(1); |
238 replacements[0] = base::JoinString(failed_vector, ", "); | 238 replacements[0] = base::JoinString(failed_vector, ", "); |
239 std::string error = base::ReplaceStringPlaceholders(kSetAdapterPropertyError, | 239 std::string error = base::ReplaceStringPlaceholders(kSetAdapterPropertyError, |
240 replacements, nullptr); | 240 replacements, nullptr); |
241 SetError(error); | 241 SetError(error); |
242 SendResponse(false); | 242 SendResponse(false); |
243 } | 243 } |
244 | 244 |
245 //////////////////////////////////////////////////////////////////////////////// | 245 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 device::BluetoothDevice::ConnectErrorCode error) { | 596 device::BluetoothDevice::ConnectErrorCode error) { |
597 SetError(kPairingFailed); | 597 SetError(kPairingFailed); |
598 SendResponse(false); | 598 SendResponse(false); |
599 } | 599 } |
600 | 600 |
601 //////////////////////////////////////////////////////////////////////////////// | 601 //////////////////////////////////////////////////////////////////////////////// |
602 | 602 |
603 } // namespace api | 603 } // namespace api |
604 | 604 |
605 } // namespace extensions | 605 } // namespace extensions |
OLD | NEW |