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

Side by Side Diff: device/nfc/nfc.mojom

Issue 1486043002: [webnfc] Implement push method for Android nfc mojo service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@step_6_add_mojo_service_CL
Patch Set: Move WindowAndroidChangedObserver to other observers in content layer Created 4 years, 4 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
« no previous file with comments | « device/nfc/nfc.gyp ('k') | third_party/WebKit/LayoutTests/nfc/resources/nfc-helpers.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 module device.nfc; 5 module device.nfc;
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,
16 IO_ERROR 16 IO_ERROR
17 }; 17 };
18 18
19 enum NFCRecordType { 19 enum NFCRecordType {
20 EMPTY, 20 EMPTY,
21 TEXT, 21 TEXT,
22 URL, 22 URL,
23 JSON, 23 JSON,
24 OPAQUE_RECORD 24 OPAQUE_RECORD
25 }; 25 };
26 26
27 enum NFCPushTarget { 27 enum NFCPushTarget {
28 // The target of a push operation must be the NFC tag.
28 TAG, 29 TAG,
30 // The target of a push operation must be the NFC peer (device to device).
29 PEER, 31 PEER,
32 // The target of a push operation must be either NFC tag or peer.
30 ANY 33 ANY
31 }; 34 };
32 35
33 enum NFCWatchMode { 36 enum NFCWatchMode {
37 // Restricts scope of the watch operation. Only Web NFC messages must be
38 // used by matching algorithm.
34 WEBNFC_ONLY, 39 WEBNFC_ONLY,
40 // Allows performing watch operation for all NFC messages. For example, NFC
41 // tags with valid NDEF messages.
35 ANY 42 ANY
36 }; 43 };
37 44
38 struct NFCError { 45 struct NFCError {
39 NFCErrorType error_type; 46 NFCErrorType error_type;
40 }; 47 };
41 48
42 struct NFCRecord { 49 struct NFCRecord {
43 NFCRecordType recordType; 50 // The type of NFCRecord.
44 string? mediaType; 51 NFCRecordType record_type;
52
53 // Represents the IANA media type of the NFCRecord data field.
54 string? media_type;
55
56 // Payload of the NFCRecord.
45 array<uint8> data; 57 array<uint8> data;
46 }; 58 };
47 59
48 struct NFCMessage { 60 struct NFCMessage {
61 // The body of the NFCMessage is a collection of NFCRecord objects.
49 array<NFCRecord> data; 62 array<NFCRecord> data;
63
64 // The |url| field is an ASCII serialized origin, optionally followed by a URL
65 // path. It represents Web NFC id, that can be used for matching Web NFC
66 // content with the filter specified by |url| field in NFCWatchOptions.
50 string? url; 67 string? url;
51 }; 68 };
52 69
53 struct NFCPushOptions { 70 struct NFCPushOptions {
71 // The target of the push operation.
54 NFCPushTarget target; 72 NFCPushTarget target;
73
74 // The timeout for the push operation, in milliseconds.
55 double timeout; 75 double timeout;
56 bool ignoreRead; 76
77 // If the property is true, the push operation will suspend active watchers
78 // until its completion.
79 bool ignore_read;
57 }; 80 };
58 81
59 struct NFCRecordTypeFilter { 82 struct NFCRecordTypeFilter {
60 NFCRecordType recordType; 83 NFCRecordType record_type;
61 }; 84 };
62 85
63 struct NFCWatchOptions { 86 struct NFCWatchOptions {
87 // Defines filtering constraint for NFC messages with specified |url|.
64 string? url; 88 string? url;
65 NFCRecordTypeFilter? recordFilter; 89
66 string? mediaType; 90 // Defines filtering constraint for NFC records with specified record type.
91 NFCRecordTypeFilter? record_filter;
92
93 // Defines media type filtering constraint.
94 string? media_type;
95
96 // Defines mode of watch operation.
67 NFCWatchMode mode; 97 NFCWatchMode mode;
68 }; 98 };
69 99
70 interface NFC { 100 interface NFC {
71 // NFCClient interface is used to notify |client| when NFCMessage matches one 101 // NFCClient interface is used to notify |client| when NFCMessage matches one
72 // or more pending watch operations. 102 // or more pending watch operations.
73 SetClient(NFCClient client); 103 SetClient(NFCClient client);
74 104
75 // Pushes data to NFC device. 105 // Pushes data to NFC device.
76 // NFCPushOptions specify timeout and type of device where data should be 106 // 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 107 // pushed. If timeout is defined and data is not pushed before timeout is
78 // expired, callback with corresponding error is called. 108 // expired, callback with corresponding error is called.
79 Push(NFCMessage message, NFCPushOptions? options) => (NFCError? error); 109 Push(NFCMessage message, NFCPushOptions? options) => (NFCError? error);
80 110
81 // Cancels pending push request. 111 // Cancels pending push request.
82 CancelPush(NFCPushTarget target) => (NFCError? error); 112 CancelPush(NFCPushTarget target) => (NFCError? error);
83 113
84 // Starts watching for nearby NFC devices with data that matches 114 // Starts watching for nearby NFC devices with data that matches
85 // NFCWatchOptions filtering criteria. On success, watch ID is returned. 115 // NFCWatchOptions filtering criteria. On success, watch id is returned.
86 Watch(NFCWatchOptions options) => (uint32 id, NFCError? error); 116 Watch(NFCWatchOptions options) => (uint32 id, NFCError? error);
87 117
88 // Cancels watch operation with provided id. 118 // Cancels watch operation with provided id.
89 CancelWatch (uint32 id) => (NFCError? error); 119 CancelWatch (uint32 id) => (NFCError? error);
90 120
91 // Cancels all watch operations. 121 // Cancels all watch operations.
92 CancelAllWatches () => (NFCError? error); 122 CancelAllWatches () => (NFCError? error);
93 123
94 // Suspends all pending NFC operations. Could be used when web page 124 // Suspends all pending NFC operations. Could be used when web page
95 // visibility or focus is lost. 125 // visibility or focus is lost.
96 SuspendNFCOperations(); 126 SuspendNFCOperations();
97 127
98 // Resumes all suspended NFC operations. 128 // Resumes all suspended NFC operations.
99 ResumeNFCOperations(); 129 ResumeNFCOperations();
100 }; 130 };
101 131
102 interface NFCClient { 132 interface NFCClient {
103 OnWatch(array<uint32> watchIDs, NFCMessage message); 133 OnWatch(array<uint32> watch_ids, NFCMessage message);
104 }; 134 };
OLDNEW
« no previous file with comments | « device/nfc/nfc.gyp ('k') | third_party/WebKit/LayoutTests/nfc/resources/nfc-helpers.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698