Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: third_party/WebKit/Source/modules/nfc/NFC.cpp

Issue 2595543003: Rename toV8(...) function in Blink to ToV8(...). (Closed)
Patch Set: Rebasing... Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 case device::nfc::mojom::blink::NFCRecordType::OPAQUE_RECORD: 479 case device::nfc::mojom::blink::NFCRecordType::OPAQUE_RECORD:
480 return "opaque"; 480 return "opaque";
481 case device::nfc::mojom::blink::NFCRecordType::EMPTY: 481 case device::nfc::mojom::blink::NFCRecordType::EMPTY:
482 return "empty"; 482 return "empty";
483 } 483 }
484 484
485 NOTREACHED(); 485 NOTREACHED();
486 return String(); 486 return String();
487 } 487 }
488 488
489 v8::Local<v8::Value> toV8( 489 v8::Local<v8::Value> ToV8(
490 ScriptState* scriptState, 490 ScriptState* scriptState,
491 const device::nfc::mojom::blink::NFCRecordPtr& record) { 491 const device::nfc::mojom::blink::NFCRecordPtr& record) {
492 switch (record->record_type) { 492 switch (record->record_type) {
493 case device::nfc::mojom::blink::NFCRecordType::TEXT: 493 case device::nfc::mojom::blink::NFCRecordType::TEXT:
494 case device::nfc::mojom::blink::NFCRecordType::URL: 494 case device::nfc::mojom::blink::NFCRecordType::URL:
495 case device::nfc::mojom::blink::NFCRecordType::JSON: { 495 case device::nfc::mojom::blink::NFCRecordType::JSON: {
496 String stringData; 496 String stringData;
497 if (!record->data.isEmpty()) { 497 if (!record->data.isEmpty()) {
498 stringData = String::fromUTF8WithLatin1Fallback( 498 stringData = String::fromUTF8WithLatin1Fallback(
499 static_cast<unsigned char*>(&record->data.front()), 499 static_cast<unsigned char*>(&record->data.front()),
(...skipping 15 matching lines...) Expand all
515 return jsonObject; 515 return jsonObject;
516 } 516 }
517 517
518 return string; 518 return string;
519 } 519 }
520 520
521 case device::nfc::mojom::blink::NFCRecordType::OPAQUE_RECORD: { 521 case device::nfc::mojom::blink::NFCRecordType::OPAQUE_RECORD: {
522 if (!record->data.isEmpty()) { 522 if (!record->data.isEmpty()) {
523 DOMArrayBuffer* buffer = DOMArrayBuffer::create( 523 DOMArrayBuffer* buffer = DOMArrayBuffer::create(
524 static_cast<void*>(&record->data.front()), record->data.size()); 524 static_cast<void*>(&record->data.front()), record->data.size());
525 return toV8(buffer, scriptState->context()->Global(), 525 return ToV8(buffer, scriptState->context()->Global(),
526 scriptState->isolate()); 526 scriptState->isolate());
527 } 527 }
528 528
529 return v8::Null(scriptState->isolate()); 529 return v8::Null(scriptState->isolate());
530 } 530 }
531 531
532 case device::nfc::mojom::blink::NFCRecordType::EMPTY: 532 case device::nfc::mojom::blink::NFCRecordType::EMPTY:
533 return v8::Null(scriptState->isolate()); 533 return v8::Null(scriptState->isolate());
534 } 534 }
535 535
536 NOTREACHED(); 536 NOTREACHED();
537 return v8::Local<v8::Value>(); 537 return v8::Local<v8::Value>();
538 } 538 }
539 539
540 NFCRecord toNFCRecord(ScriptState* scriptState, 540 NFCRecord toNFCRecord(ScriptState* scriptState,
541 const device::nfc::mojom::blink::NFCRecordPtr& record) { 541 const device::nfc::mojom::blink::NFCRecordPtr& record) {
542 NFCRecord nfcRecord; 542 NFCRecord nfcRecord;
543 nfcRecord.setMediaType(record->media_type); 543 nfcRecord.setMediaType(record->media_type);
544 nfcRecord.setRecordType(toNFCRecordType(record->record_type)); 544 nfcRecord.setRecordType(toNFCRecordType(record->record_type));
545 nfcRecord.setData(ScriptValue(scriptState, toV8(scriptState, record))); 545 nfcRecord.setData(ScriptValue(scriptState, ToV8(scriptState, record)));
546 return nfcRecord; 546 return nfcRecord;
547 } 547 }
548 548
549 NFCMessage toNFCMessage( 549 NFCMessage toNFCMessage(
550 ScriptState* scriptState, 550 ScriptState* scriptState,
551 const device::nfc::mojom::blink::NFCMessagePtr& message) { 551 const device::nfc::mojom::blink::NFCMessagePtr& message) {
552 NFCMessage nfcMessage; 552 NFCMessage nfcMessage;
553 nfcMessage.setURL(message->url); 553 nfcMessage.setURL(message->url);
554 blink::HeapVector<NFCRecord> records; 554 blink::HeapVector<NFCRecord> records;
555 for (size_t i = 0; i < message->data.size(); ++i) 555 for (size_t i = 0; i < message->data.size(); ++i)
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 } 815 }
816 816
817 DEFINE_TRACE(NFC) { 817 DEFINE_TRACE(NFC) {
818 PageVisibilityObserver::trace(visitor); 818 PageVisibilityObserver::trace(visitor);
819 ContextLifecycleObserver::trace(visitor); 819 ContextLifecycleObserver::trace(visitor);
820 visitor->trace(m_requests); 820 visitor->trace(m_requests);
821 visitor->trace(m_callbacks); 821 visitor->trace(m_callbacks);
822 } 822 }
823 823
824 } // namespace blink 824 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698