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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/nfc/BeamController.java

Issue 615213003: Upstream NFC beam URL sharing code and add it to ChromeShell. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Start using uma :D Created 6 years, 2 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
OLDNEW
(Empty)
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.nfc;
6
7 import android.app.Activity;
8 import android.nfc.NfcAdapter;
9 import android.util.Log;
10
11 /**
12 * Initializes Android Beam (sharing URL via NFC) for devices that have NFC. If user taps their
13 * device with another Beam capable device, then Chrome gets the current URL, fi lters for security
14 * and returns the result to Android.
15 */
16 public final class BeamController {
17 /**
18 * If the device has NFC, construct a BeamCallback and pass it to Android.
19 *
20 * @param activity Activity that is sending out beam messages.
21 * @param provider Provider that returns the URL that should be shared.
22 */
23 public static void registerForBeam(final Activity activity, final BeamProvid er provider) {
24 final NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(activity);
25 if (nfcAdapter == null) return;
26 try {
27 final BeamCallback beamCallback = new BeamCallback(activity, provide r);
28 nfcAdapter.setNdefPushMessageCallback(beamCallback, activity);
29 nfcAdapter.setOnNdefPushCompleteCallback(beamCallback, activity);
30 } catch (IllegalStateException e) {
31 Log.w("BeamController", "NFC registration failure. Can't retry, givi ng up.");
32 }
33 }
34 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698