| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/bluetooth/BluetoothUUID.h" | 6 #include "modules/bluetooth/BluetoothUUID.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "bindings/core/v8/ScriptRegexp.h" | 9 #include "bindings/core/v8/ScriptRegexp.h" |
| 10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 } | 304 } |
| 305 | 305 |
| 306 if (map->contains(nameStr)) | 306 if (map->contains(nameStr)) |
| 307 return BluetoothUUID::canonicalUUID(map->get(nameStr)); | 307 return BluetoothUUID::canonicalUUID(map->get(nameStr)); |
| 308 | 308 |
| 309 StringBuilder errorMessage; | 309 StringBuilder errorMessage; |
| 310 errorMessage.append("Invalid "); | 310 errorMessage.append("Invalid "); |
| 311 errorMessage.append(attributeType); | 311 errorMessage.append(attributeType); |
| 312 errorMessage.append(" name: '"); | 312 errorMessage.append(" name: '"); |
| 313 errorMessage.append(nameStr); | 313 errorMessage.append(nameStr); |
| 314 errorMessage.append("'."); | 314 errorMessage.append("'. It must be a valid UUID alias (e.g. 0x1234), " |
| 315 "UUID (lowercase hex characters e.g. '00001234-0000-1000-8000-00805f9b34
fb'), " |
| 316 "or recognized standard name from "); |
| 317 switch (attribute) { |
| 318 case GATTAttribute::Service: |
| 319 errorMessage.append("https://developer.bluetooth.org/gatt/services/Pages
/ServicesHome.aspx" |
| 320 " e.g. 'alert_notification'."); |
| 321 break; |
| 322 case GATTAttribute::Characteristic: |
| 323 errorMessage.append("https://developer.bluetooth.org/gatt/characteristic
s/Pages/CharacteristicsHome.aspx" |
| 324 " e.g. 'aerobic_heart_rate_lower_limit'."); |
| 325 break; |
| 326 case GATTAttribute::Descriptor: |
| 327 errorMessage.append("https://developer.bluetooth.org/gatt/descriptors/Pa
ges/DescriptorsHomePage.aspx" |
| 328 " e.g. 'gatt.characteristic_presentation_format'."); |
| 329 break; |
| 330 } |
| 315 // Otherwise, throw a SyntaxError. | 331 // Otherwise, throw a SyntaxError. |
| 316 exceptionState.throwDOMException(SyntaxError, errorMessage.toString()); | 332 exceptionState.throwDOMException(SyntaxError, errorMessage.toString()); |
| 317 return String(); | 333 return String(); |
| 318 } | 334 } |
| 319 | 335 |
| 320 } // namespace | 336 } // namespace |
| 321 | 337 |
| 322 // static | 338 // static |
| 323 String BluetoothUUID::getService(StringOrUnsignedLong name, ExceptionState& exce
ptionState) | 339 String BluetoothUUID::getService(StringOrUnsignedLong name, ExceptionState& exce
ptionState) |
| 324 { | 340 { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 345 appendUnsignedAsHexFixedSize( | 361 appendUnsignedAsHexFixedSize( |
| 346 alias, | 362 alias, |
| 347 builder, 8 /* 8 chars or 32 bits, prefix length */, | 363 builder, 8 /* 8 chars or 32 bits, prefix length */, |
| 348 Lowercase); | 364 Lowercase); |
| 349 | 365 |
| 350 builder.append("-0000-1000-8000-00805f9b34fb"); | 366 builder.append("-0000-1000-8000-00805f9b34fb"); |
| 351 return builder.toString(); | 367 return builder.toString(); |
| 352 } | 368 } |
| 353 | 369 |
| 354 } // namespace blink | 370 } // namespace blink |
| OLD | NEW |