| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 package org.chromium.chrome.browser.nfc; | 5 package org.chromium.chrome.browser.nfc; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; |
| 7 import android.app.Activity; | 8 import android.app.Activity; |
| 8 import android.nfc.NdefMessage; | 9 import android.nfc.NdefMessage; |
| 9 import android.nfc.NdefRecord; | 10 import android.nfc.NdefRecord; |
| 10 import android.nfc.NfcAdapter.CreateNdefMessageCallback; | 11 import android.nfc.NfcAdapter.CreateNdefMessageCallback; |
| 11 import android.nfc.NfcAdapter.OnNdefPushCompleteCallback; | 12 import android.nfc.NfcAdapter.OnNdefPushCompleteCallback; |
| 12 import android.nfc.NfcEvent; | 13 import android.nfc.NfcEvent; |
| 13 import android.os.Build; | 14 import android.os.Build; |
| 14 import android.os.Handler; | 15 import android.os.Handler; |
| 15 import android.os.Looper; | 16 import android.os.Looper; |
| 16 import android.text.TextUtils; | 17 import android.text.TextUtils; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 47 Status(String result) { | 48 Status(String result) { |
| 48 assert result != null; | 49 assert result != null; |
| 49 this.result = result; | 50 this.result = result; |
| 50 this.errorStrID = null; | 51 this.errorStrID = null; |
| 51 } | 52 } |
| 52 } | 53 } |
| 53 | 54 |
| 54 // In ICS returning null from createNdefMessage will cause beam to send our
market | 55 // In ICS returning null from createNdefMessage will cause beam to send our
market |
| 55 // link so we need to hook to the return from the beam overlay to display th
e error. | 56 // link so we need to hook to the return from the beam overlay to display th
e error. |
| 56 // But in SDK_INT >= 16, beam won't activate, so the hook wouldn't go off. (
b/5943350) | 57 // But in SDK_INT >= 16, beam won't activate, so the hook wouldn't go off. (
b/5943350) |
| 58 // TODO(crbug.com/635567): Fix this properly. |
| 59 @SuppressLint("ObsoleteSdkInt") |
| 57 private static final boolean NFC_BUGS_ACTIVE = Build.VERSION.SDK_INT < 16; | 60 private static final boolean NFC_BUGS_ACTIVE = Build.VERSION.SDK_INT < 16; |
| 58 | 61 |
| 59 // Arbitrarily chosen interval to delay toast to allow NFC animations to fin
ish | 62 // Arbitrarily chosen interval to delay toast to allow NFC animations to fin
ish |
| 60 // and our app to return to foreground. | 63 // and our app to return to foreground. |
| 61 private static final int TOAST_ERROR_DELAY_MS = 400; | 64 private static final int TOAST_ERROR_DELAY_MS = 400; |
| 62 | 65 |
| 63 private final Activity mActivity; | 66 private final Activity mActivity; |
| 64 private final BeamProvider mProvider; | 67 private final BeamProvider mProvider; |
| 65 | 68 |
| 66 // We use this to delay the error message in ICS because it would be hidden
behind | 69 // We use this to delay the error message in ICS because it would be hidden
behind |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 if (TextUtils.isEmpty(url)) return false; | 147 if (TextUtils.isEmpty(url)) return false; |
| 145 try { | 148 try { |
| 146 String urlProtocol = (new URL(url)).getProtocol(); | 149 String urlProtocol = (new URL(url)).getProtocol(); |
| 147 return (UrlConstants.HTTP_SCHEME.equals(urlProtocol) | 150 return (UrlConstants.HTTP_SCHEME.equals(urlProtocol) |
| 148 || UrlConstants.HTTPS_SCHEME.equals(urlProtocol)); | 151 || UrlConstants.HTTPS_SCHEME.equals(urlProtocol)); |
| 149 } catch (MalformedURLException e) { | 152 } catch (MalformedURLException e) { |
| 150 return false; | 153 return false; |
| 151 } | 154 } |
| 152 } | 155 } |
| 153 } | 156 } |
| OLD | NEW |