| 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 "modules/nfc/NFC.h" | 5 #include "modules/nfc/NFC.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 8 #include "bindings/core/v8/V8ArrayBuffer.h" | 8 #include "bindings/core/v8/V8ArrayBuffer.h" |
| 9 #include "bindings/core/v8/V8StringResource.h" | 9 #include "bindings/core/v8/V8StringResource.h" |
| 10 #include "core/dom/DOMArrayBuffer.h" | 10 #include "core/dom/DOMArrayBuffer.h" |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 namespace blink { | 309 namespace blink { |
| 310 namespace { | 310 namespace { |
| 311 | 311 |
| 312 bool isValidTextRecord(const NFCRecord& record) { | 312 bool isValidTextRecord(const NFCRecord& record) { |
| 313 v8::Local<v8::Value> value = record.data().v8Value(); | 313 v8::Local<v8::Value> value = record.data().v8Value(); |
| 314 if (!value->IsString() && | 314 if (!value->IsString() && |
| 315 !(value->IsNumber() && !std::isnan(value.As<v8::Number>()->Value()))) | 315 !(value->IsNumber() && !std::isnan(value.As<v8::Number>()->Value()))) |
| 316 return false; | 316 return false; |
| 317 | 317 |
| 318 if (record.hasMediaType() && | 318 if (record.hasMediaType() && |
| 319 !record.mediaType().startsWith(kPlainTextMimePrefix, TextCaseInsensitive)) | 319 !record.mediaType().startsWith(kPlainTextMimePrefix, |
| 320 TextCaseUnicodeInsensitive)) |
| 320 return false; | 321 return false; |
| 321 | 322 |
| 322 return true; | 323 return true; |
| 323 } | 324 } |
| 324 | 325 |
| 325 bool isValidURLRecord(const NFCRecord& record) { | 326 bool isValidURLRecord(const NFCRecord& record) { |
| 326 if (!record.data().v8Value()->IsString()) | 327 if (!record.data().v8Value()->IsString()) |
| 327 return false; | 328 return false; |
| 328 | 329 |
| 329 blink::V8StringResource<> stringResource = record.data().v8Value(); | 330 blink::V8StringResource<> stringResource = record.data().v8Value(); |
| 330 if (!stringResource.prepare()) | 331 if (!stringResource.prepare()) |
| 331 return false; | 332 return false; |
| 332 | 333 |
| 333 return KURL(KURL(), stringResource).isValid(); | 334 return KURL(KURL(), stringResource).isValid(); |
| 334 } | 335 } |
| 335 | 336 |
| 336 bool isValidJSONRecord(const NFCRecord& record) { | 337 bool isValidJSONRecord(const NFCRecord& record) { |
| 337 v8::Local<v8::Value> value = record.data().v8Value(); | 338 v8::Local<v8::Value> value = record.data().v8Value(); |
| 338 if (!value->IsObject() || value->IsArrayBuffer()) | 339 if (!value->IsObject() || value->IsArrayBuffer()) |
| 339 return false; | 340 return false; |
| 340 | 341 |
| 341 if (record.hasMediaType() && | 342 if (record.hasMediaType() && |
| 342 !record.mediaType().startsWith(kJsonMimePrefix, TextCaseInsensitive)) | 343 !record.mediaType().startsWith(kJsonMimePrefix, TextCaseASCIIInsensitive)) |
| 343 return false; | 344 return false; |
| 344 | 345 |
| 345 return true; | 346 return true; |
| 346 } | 347 } |
| 347 | 348 |
| 348 bool isValidOpaqueRecord(const NFCRecord& record) { | 349 bool isValidOpaqueRecord(const NFCRecord& record) { |
| 349 return record.data().v8Value()->IsArrayBuffer(); | 350 return record.data().v8Value()->IsArrayBuffer(); |
| 350 } | 351 } |
| 351 | 352 |
| 352 bool isValidNFCRecord(const NFCRecord& record) { | 353 bool isValidNFCRecord(const NFCRecord& record) { |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 // TODO(shalamov): Not implemented. | 583 // TODO(shalamov): Not implemented. |
| 583 } | 584 } |
| 584 | 585 |
| 585 DEFINE_TRACE(NFC) { | 586 DEFINE_TRACE(NFC) { |
| 586 PageVisibilityObserver::trace(visitor); | 587 PageVisibilityObserver::trace(visitor); |
| 587 ContextLifecycleObserver::trace(visitor); | 588 ContextLifecycleObserver::trace(visitor); |
| 588 visitor->trace(m_requests); | 589 visitor->trace(m_requests); |
| 589 } | 590 } |
| 590 | 591 |
| 591 } // namespace blink | 592 } // namespace blink |
| OLD | NEW |