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

Unified Diff: device/nfc/android/java/src/org/chromium/device/nfc/NfcProviderImpl.java

Issue 2865653002: [Device Service] Decouple NFC implementation from //content (Closed)
Patch Set: Rebase Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: device/nfc/android/java/src/org/chromium/device/nfc/NfcProviderImpl.java
diff --git a/device/nfc/android/java/src/org/chromium/device/nfc/NfcProviderImpl.java b/device/nfc/android/java/src/org/chromium/device/nfc/NfcProviderImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..04f19f6eb135ed698caa9e584589353fcb5bd9bf
--- /dev/null
+++ b/device/nfc/android/java/src/org/chromium/device/nfc/NfcProviderImpl.java
@@ -0,0 +1,56 @@
+// 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.
+
+package org.chromium.device.nfc;
+
+import android.content.Context;
+
+import org.chromium.device.nfc.mojom.Nfc;
+import org.chromium.device.nfc.mojom.NfcProvider;
+import org.chromium.mojo.bindings.InterfaceRequest;
+import org.chromium.mojo.system.MojoException;
+import org.chromium.services.service_manager.InterfaceFactory;
+
+/**
+ * Android implementation of the NfcProvider Mojo interface.
+ */
+public class NfcProviderImpl implements NfcProvider {
+ private static final String TAG = "NfcProviderImpl";
+ private Context mContext;
+ private NfcDelegate mDelegate;
+
+ public NfcProviderImpl(Context context, NfcDelegate delegate) {
+ mContext = context;
+ mDelegate = delegate;
+ }
+
+ @Override
+ public void close() {}
+
+ @Override
+ public void onConnectionError(MojoException e) {}
+
+ @Override
+ public void getNfcForHost(int hostId, InterfaceRequest<Nfc> request) {
+ Nfc.MANAGER.bind(new NfcImpl(mContext, hostId, mDelegate), request);
+ }
+
+ /**
+ * A factory for implementations of the NfcProvider interface.
+ */
+ public static class Factory implements InterfaceFactory<NfcProvider> {
+ private Context mContext;
+ private NfcDelegate mDelegate;
+
+ public Factory(Context context, NfcDelegate delegate) {
+ mContext = context;
+ mDelegate = delegate;
+ }
+
+ @Override
+ public NfcProvider createImpl() {
+ return new NfcProviderImpl(mContext, mDelegate);
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698