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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java

Issue 2755003003: Add Interstitial for user consent (Closed)
Patch Set: Matts Nits 1 Created 3 years, 9 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
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.annotation.TargetApi; 7 import android.annotation.TargetApi;
8 import android.bluetooth.BluetoothAdapter; 8 import android.bluetooth.BluetoothAdapter;
9 import android.bluetooth.BluetoothManager; 9 import android.bluetooth.BluetoothManager;
10 import android.content.Context; 10 import android.content.Context;
11 import android.content.Intent; 11 import android.content.Intent;
12 import android.content.SharedPreferences; 12 import android.content.SharedPreferences;
13 import android.net.Uri; 13 import android.net.Uri;
14 import android.os.Build; 14 import android.os.Build;
15 15
16 import org.chromium.base.ContextUtils; 16 import org.chromium.base.ContextUtils;
17 import org.chromium.chrome.browser.ChromeFeatureList; 17 import org.chromium.chrome.browser.ChromeFeatureList;
18 import org.chromium.chrome.browser.IntentHandler; 18 import org.chromium.chrome.browser.IntentHandler;
19 import org.chromium.chrome.browser.UrlConstants; 19 import org.chromium.chrome.browser.UrlConstants;
20 import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager ; 20 import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager ;
21 import org.chromium.chrome.browser.profiles.Profile; 21 import org.chromium.chrome.browser.profiles.Profile;
22 import org.chromium.chrome.browser.search_engines.TemplateUrlService; 22 import org.chromium.chrome.browser.search_engines.TemplateUrlService;
23 import org.chromium.components.location.LocationUtils; 23 import org.chromium.components.location.LocationUtils;
24 24
25 /** 25 /**
26 * This class provides the basic interface to the Physical Web feature. 26 * This class provides the basic interface to the Physical Web feature.
27 */ 27 */
28 public class PhysicalWeb { 28 public class PhysicalWeb {
29 public static final int OPTIN_NOTIFY_MAX_TRIES = 1; 29 public static final int OPTIN_NOTIFY_MAX_TRIES = 1;
30 private static final String PHYSICAL_WEB_SHARING_PREFERENCE = "physical_web_ sharing";
30 private static final String PREF_PHYSICAL_WEB_NOTIFY_COUNT = "physical_web_n otify_count"; 31 private static final String PREF_PHYSICAL_WEB_NOTIFY_COUNT = "physical_web_n otify_count";
31 private static final String FEATURE_NAME = "PhysicalWeb"; 32 private static final String FEATURE_NAME = "PhysicalWeb";
32 private static final String PHYSICAL_WEB_SHARING_FEATURE_NAME = "PhysicalWeb Sharing"; 33 private static final String PHYSICAL_WEB_SHARING_FEATURE_NAME = "PhysicalWeb Sharing";
33 private static final int MIN_ANDROID_VERSION = 18; 34 private static final int MIN_ANDROID_VERSION = 18;
34 35
35 /** 36 /**
36 * Evaluates whether the environment is one in which the Physical Web should 37 * Evaluates whether the environment is one in which the Physical Web should
37 * be enabled. 38 * be enabled.
38 * @return true if the PhysicalWeb should be enabled 39 * @return true if the PhysicalWeb should be enabled
39 */ 40 */
(...skipping 14 matching lines...) Expand all
54 /** 55 /**
55 * Checks whether the Physical Web Sharing feature is enabled. 56 * Checks whether the Physical Web Sharing feature is enabled.
56 * 57 *
57 * @return boolean {@code true} if the feature is enabled 58 * @return boolean {@code true} if the feature is enabled
58 */ 59 */
59 public static boolean sharingIsEnabled() { 60 public static boolean sharingIsEnabled() {
60 return ChromeFeatureList.isEnabled(PHYSICAL_WEB_SHARING_FEATURE_NAME); 61 return ChromeFeatureList.isEnabled(PHYSICAL_WEB_SHARING_FEATURE_NAME);
61 } 62 }
62 63
63 /** 64 /**
65 * Checks whether the user has consented to use the Sharing feature.
66 *
67 * @return boolean {@code true} if the feature is enabled
68 */
69 public static boolean sharingIsOptedIn() {
70 SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences();
71 return sharedPrefs.getBoolean(PHYSICAL_WEB_SHARING_PREFERENCE, false);
72 }
73
74 /**
75 * Sets the preference that the user has opted into use the Sharing feature.
76 */
77 public static void setSharingOptedIn() {
78 ContextUtils.getAppSharedPreferences()
79 .edit()
80 .putBoolean(PHYSICAL_WEB_SHARING_PREFERENCE, true)
81 .apply();
82 }
83
84 /**
64 * Checks whether the Physical Web onboard flow is active and the user has 85 * Checks whether the Physical Web onboard flow is active and the user has
65 * not yet elected to either enable or decline the feature. 86 * not yet elected to either enable or decline the feature.
66 * 87 *
67 * @return boolean {@code true} if onboarding is complete. 88 * @return boolean {@code true} if onboarding is complete.
68 */ 89 */
69 public static boolean isOnboarding() { 90 public static boolean isOnboarding() {
70 return PrivacyPreferencesManager.getInstance().isPhysicalWebOnboarding() ; 91 return PrivacyPreferencesManager.getInstance().isPhysicalWebOnboarding() ;
71 } 92 }
72 93
73 /** 94 /**
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 */ 196 */
176 @TargetApi(Build.VERSION_CODES.LOLLIPOP) 197 @TargetApi(Build.VERSION_CODES.LOLLIPOP)
177 public static boolean hasBleAdvertiseCapability() { 198 public static boolean hasBleAdvertiseCapability() {
178 Context context = ContextUtils.getApplicationContext(); 199 Context context = ContextUtils.getApplicationContext();
179 BluetoothManager bluetoothManager = 200 BluetoothManager bluetoothManager =
180 (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SE RVICE); 201 (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SE RVICE);
181 BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter(); 202 BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();
182 return bluetoothAdapter != null && bluetoothAdapter.getBluetoothLeAdvert iser() != null; 203 return bluetoothAdapter != null && bluetoothAdapter.getBluetoothLeAdvert iser() != null;
183 } 204 }
184 } 205 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698