summaryrefslogtreecommitdiff
path: root/chromium/content/browser/android/nfc_host.h
blob: 047232aa65644355f3c45fc5462e02f61eab563d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_ANDROID_NFC_HOST_H_
#define CONTENT_BROWSER_ANDROID_NFC_HOST_H_

#include "base/android/jni_android.h"
#include "content/public/browser/web_contents.h"
#include "services/device/public/interfaces/nfc_provider.mojom.h"

namespace content {

// On Android, NFC requires the Activity associated with the context in order to
// access the NFC system APIs. NFCHost provides this functionality by mapping
// NFC context IDs to the WebContents associated with those IDs.
class NFCHost {
 public:
  explicit NFCHost(WebContents* web_contents);
  ~NFCHost();

  void GetNFC(device::mojom::NFCRequest request);

 private:
  // This instance's ID (passed to the NFC implementation via |nfc_provider_|
  // and used from the implementation to map back to this object).
  int id_;

  // The WebContents that owns this instance.
  WebContents* web_contents_;

  device::mojom::NFCProviderPtr nfc_provider_;

  base::android::ScopedJavaGlobalRef<jobject> java_nfc_host_;

  DISALLOW_COPY_AND_ASSIGN(NFCHost);
};

}  // namespace content

#endif  // CONTENT_BROWSER_ANDROID_NFC_HOST_H_