OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.physicalweb; | 5 package org.chromium.chrome.browser.physicalweb; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 | 8 |
| 9 import org.chromium.base.ContextUtils; |
9 import org.chromium.base.Log; | 10 import org.chromium.base.Log; |
10 import org.chromium.chrome.browser.ChromeApplication; | 11 import org.chromium.chrome.browser.ChromeApplication; |
11 | 12 |
12 /** | 13 /** |
13 * The Client that harvests URLs from BLE signals. | 14 * The Client that harvests URLs from BLE signals. |
14 * This class is designed to scan URSs from Bluetooth Low Energy beacons. | 15 * This class is designed to scan URSs from Bluetooth Low Energy beacons. |
15 * This class is currently an empty implementation and must be extended by a | 16 * This class is currently an empty implementation and must be extended by a |
16 * subclass. | 17 * subclass. |
17 */ | 18 */ |
18 public class PhysicalWebBleClient { | 19 public class PhysicalWebBleClient { |
19 private static PhysicalWebBleClient sInstance = null; | 20 private static PhysicalWebBleClient sInstance = null; |
20 private static final String TAG = "PhysicalWeb"; | 21 private static final String TAG = "PhysicalWeb"; |
21 | 22 |
22 /** | 23 /** |
23 * Get a singleton instance of this class. | 24 * Get a singleton instance of this class. |
24 * @param chromeApplication An instance of {@link ChromeApplication}, used t
o get the | |
25 * appropriate PhysicalWebBleClient implementation. | |
26 * @return an instance of this class (or subclass) as decided by the | 25 * @return an instance of this class (or subclass) as decided by the |
27 * application parameter | 26 * application parameter |
28 */ | 27 */ |
29 public static PhysicalWebBleClient getInstance(ChromeApplication chromeAppli
cation) { | 28 public static PhysicalWebBleClient getInstance() { |
30 if (sInstance == null) { | 29 if (sInstance == null) { |
31 sInstance = chromeApplication.createPhysicalWebBleClient(); | 30 sInstance = ((ChromeApplication) ContextUtils.getApplicationContext(
)) |
| 31 .createPhysicalWebBleClient(); |
32 } | 32 } |
33 return sInstance; | 33 return sInstance; |
34 } | 34 } |
35 | 35 |
36 /** | 36 /** |
37 * Begin a background subscription to URLs broadcasted from BLE beacons. | 37 * Begin a background subscription to URLs broadcasted from BLE beacons. |
38 * This currently does nothing and should be overridden by a subclass. | 38 * This currently does nothing and should be overridden by a subclass. |
39 * @param callback Callback to be run when subscription task is done, regard
less of whether it | 39 * @param callback Callback to be run when subscription task is done, regard
less of whether it |
40 * is successful. | 40 * is successful. |
41 */ | 41 */ |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 85 } |
86 | 86 |
87 /** | 87 /** |
88 * Cancel a foreground subscription to URLs broadcasted from BLE beacons. | 88 * Cancel a foreground subscription to URLs broadcasted from BLE beacons. |
89 * This currently does nothing and should be overridden by a subclass. | 89 * This currently does nothing and should be overridden by a subclass. |
90 */ | 90 */ |
91 void foregroundUnsubscribe() { | 91 void foregroundUnsubscribe() { |
92 Log.d(TAG, "foreground unsubscribing in empty client"); | 92 Log.d(TAG, "foreground unsubscribing in empty client"); |
93 } | 93 } |
94 } | 94 } |
OLD | NEW |