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.nfc; | 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, |
11 NOT_FOUND, | 11 NOT_FOUND, |
12 INVALID_MESSAGE, | 12 INVALID_MESSAGE, |
13 OPERATION_CANCELLED, | 13 OPERATION_CANCELLED, |
14 TIMER_EXPIRED, | 14 TIMER_EXPIRED, |
15 CANNOT_CANCEL, | 15 CANNOT_CANCEL, |
(...skipping 45 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 // NFCClient interface is used to notify |client| when NFCMessage matches one | |
72 // or more pending watch operations. | |
73 SetClient(NFCClient client); | 71 SetClient(NFCClient client); |
74 | |
75 // Pushes data to NFC device. | |
76 // NFCPushOptions specify timeout and type of device where data should be | |
77 // pushed. If timeout is defined and data is not pushed before timeout is | |
78 // expired, callback with corresponding error is called. | |
79 Push(NFCMessage message, NFCPushOptions? options) => (NFCError? error); | 72 Push(NFCMessage message, NFCPushOptions? options) => (NFCError? error); |
80 | |
81 // Cancels pending push request. | |
82 CancelPush(NFCPushTarget target) => (NFCError? error); | 73 CancelPush(NFCPushTarget target) => (NFCError? error); |
83 | |
84 // Starts watching for nearby NFC devices with data that matches | |
85 // NFCWatchOptions filtering criteria. On success, watch ID is returned. | |
86 Watch(NFCWatchOptions options) => (uint32 id, NFCError? error); | 74 Watch(NFCWatchOptions options) => (uint32 id, NFCError? error); |
87 | |
88 // Cancels watch operation with provided id. | |
89 CancelWatch (uint32 id) => (NFCError? error); | 75 CancelWatch (uint32 id) => (NFCError? error); |
90 | |
91 // Cancels all watch operations. | |
92 CancelAllWatches () => (NFCError? error); | 76 CancelAllWatches () => (NFCError? error); |
93 | |
94 // Suspends all pending NFC operations. Could be used when web page | |
95 // visibility or focus is lost. | |
96 SuspendNFCOperations(); | 77 SuspendNFCOperations(); |
97 | |
98 // Resumes all suspended NFC operations. | |
99 ResumeNFCOperations(); | 78 ResumeNFCOperations(); |
100 }; | 79 }; |
101 | 80 |
102 interface NFCClient { | 81 interface NFCClient { |
103 OnWatch(array<uint32> watchIDs, NFCMessage message); | 82 OnWatch(uint32 id, NFCMessage message); |
104 }; | 83 }; |
OLD | NEW |