| 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 module device; | 5 module device; |
| 6 | 6 |
| 7 enum NFCErrorType { | 7 enum NFCErrorType { |
| 8 SECURITY, | 8 SECURITY, |
| 9 NOT_SUPPORTED, | 9 NOT_SUPPORTED, |
| 10 DEVICE_DISABLED, | 10 DEVICE_DISABLED, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 struct NFCWatchOptions { | 63 struct NFCWatchOptions { |
| 64 string? url; | 64 string? url; |
| 65 NFCRecordTypeFilter? recordFilter; | 65 NFCRecordTypeFilter? recordFilter; |
| 66 string? mediaType; | 66 string? mediaType; |
| 67 NFCWatchMode mode; | 67 NFCWatchMode mode; |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 interface NFC { | 70 interface NFC { |
| 71 SetClient(NFCClient client); | 71 // Pushes data to NFC device. |
| 72 // NFCPushOptions specify timeout and type of device where data should be |
| 73 // pushed. If timeout is defined and data is not pushed before timeout is |
| 74 // expired, callback with corresponding error is called. |
| 72 Push(NFCMessage message, NFCPushOptions? options) => (NFCError? error); | 75 Push(NFCMessage message, NFCPushOptions? options) => (NFCError? error); |
| 76 |
| 77 // Cancels pending push request. |
| 73 CancelPush(NFCPushTarget target) => (NFCError? error); | 78 CancelPush(NFCPushTarget target) => (NFCError? error); |
| 79 |
| 80 // Starts watching for nearby NFC devices with data that matches |
| 81 // NFCWatchOptions filtering criteria. On success, watch ID is returned. |
| 74 Watch(NFCWatchOptions options) => (uint32 id, NFCError? error); | 82 Watch(NFCWatchOptions options) => (uint32 id, NFCError? error); |
| 83 |
| 84 // Cancels watch operation with provided id. |
| 75 CancelWatch (uint32 id) => (NFCError? error); | 85 CancelWatch (uint32 id) => (NFCError? error); |
| 86 |
| 87 // Cancels all watch operations. |
| 76 CancelAllWatches () => (NFCError? error); | 88 CancelAllWatches () => (NFCError? error); |
| 89 |
| 90 // Subscribes to watch events. If multiple watch operations match discovered |
| 91 // NFCMessage, callback is called with array of matched watch IDs. |
| 92 SubscribeToWatchEvents() => (array<uint32> watchIDs, NFCMessage message); |
| 93 |
| 94 // Suspends all pending NFC operations. Could be used when web page |
| 95 // visibility or focus is lost. |
| 77 SuspendNFCOperations(); | 96 SuspendNFCOperations(); |
| 97 |
| 98 // Resumes all suspended NFC operations. |
| 78 ResumeNFCOperations(); | 99 ResumeNFCOperations(); |
| 79 }; | 100 }; |
| 80 | |
| 81 interface NFCClient { | |
| 82 OnWatch(uint32 id, NFCMessage message); | |
| 83 }; | |
| OLD | NEW |