OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef DEVICE_NFC_NFC_TAG_TECHNOLOGY_H_ | 5 #ifndef DEVICE_NFC_NFC_TAG_TECHNOLOGY_H_ |
6 #define DEVICE_NFC_NFC_TAG_TECHNOLOGY_H_ | 6 #define DEVICE_NFC_NFC_TAG_TECHNOLOGY_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "device/nfc/nfc_ndef_record.h" | 9 #include "device/nfc/nfc_ndef_record.h" |
10 | 10 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 virtual void RecordReceived(NfcTag* tag, const NfcNdefRecord* record) {} | 86 virtual void RecordReceived(NfcTag* tag, const NfcNdefRecord* record) {} |
87 }; | 87 }; |
88 | 88 |
89 // Adds and removes observers for events on this NFC tag. If monitoring | 89 // Adds and removes observers for events on this NFC tag. If monitoring |
90 // multiple tags, check the |tag| parameter of observer methods to determine | 90 // multiple tags, check the |tag| parameter of observer methods to determine |
91 // which tag is issuing the event. | 91 // which tag is issuing the event. |
92 virtual void AddObserver(Observer* observer) = 0; | 92 virtual void AddObserver(Observer* observer) = 0; |
93 virtual void RemoveObserver(Observer* observer) = 0; | 93 virtual void RemoveObserver(Observer* observer) = 0; |
94 | 94 |
95 // NfcTagTechnology override. | 95 // NfcTagTechnology override. |
96 virtual bool IsSupportedByTag() const OVERRIDE; | 96 virtual bool IsSupportedByTag() const override; |
97 | 97 |
98 // Returns all NDEF records that were received from the tag in the form of an | 98 // Returns all NDEF records that were received from the tag in the form of an |
99 // NDEF message. If the returned NDEF message contains no records, this only | 99 // NDEF message. If the returned NDEF message contains no records, this only |
100 // means that no records have yet been received from the tag. Users should | 100 // means that no records have yet been received from the tag. Users should |
101 // use this method in conjunction with the NfcTag::Observer::RecordsReceived | 101 // use this method in conjunction with the NfcTag::Observer::RecordsReceived |
102 // method to be notified when the records are ready. | 102 // method to be notified when the records are ready. |
103 virtual const NfcNdefMessage& GetNdefMessage() const = 0; | 103 virtual const NfcNdefMessage& GetNdefMessage() const = 0; |
104 | 104 |
105 // Writes the given NDEF message to the underlying tag, overwriting any | 105 // Writes the given NDEF message to the underlying tag, overwriting any |
106 // existing NDEF message on it. On success, |callback| will be invoked. On | 106 // existing NDEF message on it. On success, |callback| will be invoked. On |
107 // failure, |error_callback| will be invoked. This method can fail, if the | 107 // failure, |error_callback| will be invoked. This method can fail, if the |
108 // underlying tag does not support NDEF as a technology. | 108 // underlying tag does not support NDEF as a technology. |
109 virtual void WriteNdef(const NfcNdefMessage& message, | 109 virtual void WriteNdef(const NfcNdefMessage& message, |
110 const base::Closure& callback, | 110 const base::Closure& callback, |
111 const ErrorCallback& error_callback) = 0; | 111 const ErrorCallback& error_callback) = 0; |
112 | 112 |
113 protected: | 113 protected: |
114 // Constructs a technology instance, where |tag| is the NFC tag that this | 114 // Constructs a technology instance, where |tag| is the NFC tag that this |
115 // instance will operate on. | 115 // instance will operate on. |
116 explicit NfcNdefTagTechnology(NfcTag* tag); | 116 explicit NfcNdefTagTechnology(NfcTag* tag); |
117 | 117 |
118 DISALLOW_COPY_AND_ASSIGN(NfcNdefTagTechnology); | 118 DISALLOW_COPY_AND_ASSIGN(NfcNdefTagTechnology); |
119 }; | 119 }; |
120 | 120 |
121 } // namespace device | 121 } // namespace device |
122 | 122 |
123 #endif // DEVICE_NFC_NFC_TAG_TECHNOLOGY_H_ | 123 #endif // DEVICE_NFC_NFC_TAG_TECHNOLOGY_H_ |
OLD | NEW |