Commit 43d41bed authored by Conley Owens's avatar Conley Owens Committed by Commit Bot

physicalweb: Remove the privacy preference

This change removes the Physical Web privacy preference.

BUG=826540

Change-Id: I5bd06d3df7cb6e03051921a3c6d8d02b2c82b329
Reviewed-on: https://chromium-review.googlesource.com/1024756Reviewed-by: default avatarMatt Reynolds <mattreynolds@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Commit-Queue: Conley Owens <cco3@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553687}
parent 2e8f9e68
......@@ -55,7 +55,6 @@
<string name="help_context_incognito_learn_more">chrome_incognito</string>
<string name="help_context_usage_reports">send_crash_report</string>
<string name="help_context_sad_tab">mobile_awsnap</string>
<string name="help_context_physical_web">physical_web</string>
<string name="help_context_clear_browsing_data">clear_browsing_data</string>
<string name="help_context_change_sync_passphrase">change_sync_passphrase</string>
<!-- TODO(peconn): Add help section. -->
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2015 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. -->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:chrome="http://schemas.android.com/apk/res-auto">
<org.chromium.chrome.browser.preferences.ChromeSwitchPreference
android:key="physical_web_switch"
android:summaryOn="@string/text_on"
android:summaryOff="@string/text_off"
chrome:drawDivider="true" />
<org.chromium.chrome.browser.preferences.TextMessagePreference
android:title="@string/physical_web_pref_description" />
<org.chromium.chrome.browser.preferences.LearnMorePreference
android:key="physical_web_learn_more"
chrome:helpContext="@string/help_context_physical_web" />
<org.chromium.chrome.browser.preferences.ButtonPreference
android:key="physical_web_launch"
android:title="@string/physical_web_launch_button" />
</PreferenceScreen>
......@@ -43,10 +43,6 @@
android:key="contextual_search"
android:title="@string/contextual_search_title"
android:fragment="org.chromium.chrome.browser.preferences.privacy.ContextualSearchPreferenceFragment" />
<Preference
android:key="physical_web"
android:title="@string/physical_web_pref_title"
android:fragment="org.chromium.chrome.browser.preferences.privacy.PhysicalWebPreferenceFragment" />
<Preference
android:key="clear_browsing_data"
android:title="@string/clear_browsing_data_title"
......
......@@ -18,7 +18,6 @@ import org.chromium.base.SysUtils;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.IntentHandler;
import org.chromium.chrome.browser.UrlConstants;
import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.search_engines.TemplateUrlService;
import org.chromium.components.location.LocationUtils;
......@@ -28,9 +27,7 @@ import org.chromium.components.location.LocationUtils;
*/
public class PhysicalWeb {
public static final int OPTIN_NOTIFY_MAX_TRIES = 1;
private static final String PHYSICAL_WEB_SHARING_PREFERENCE = "physical_web_sharing";
private static final String FEATURE_NAME = "PhysicalWeb";
private static final String PHYSICAL_WEB_SHARING_FEATURE_NAME = "PhysicalWebSharing";
private static final int MIN_ANDROID_VERSION = 18;
/**
......@@ -49,36 +46,7 @@ public class PhysicalWeb {
* @return boolean {@code true} if the preference is On.
*/
public static boolean isPhysicalWebPreferenceEnabled() {
return PrivacyPreferencesManager.getInstance().isPhysicalWebEnabled();
}
/**
* Checks whether the Physical Web Sharing feature is enabled.
*
* @return boolean {@code true} if the feature is enabled
*/
public static boolean sharingIsEnabled() {
return ChromeFeatureList.isEnabled(PHYSICAL_WEB_SHARING_FEATURE_NAME);
}
/**
* Checks whether the user has consented to use the Sharing feature.
*
* @return boolean {@code true} if the feature is enabled
*/
public static boolean sharingIsOptedIn() {
return ContextUtils.getAppSharedPreferences()
.getBoolean(PHYSICAL_WEB_SHARING_PREFERENCE, false);
}
/**
* Sets the preference that the user has opted into use the Sharing feature.
*/
public static void setSharingOptedIn() {
ContextUtils.getAppSharedPreferences()
.edit()
.putBoolean(PHYSICAL_WEB_SHARING_PREFERENCE, true)
.apply();
return false;
}
/**
......@@ -88,7 +56,7 @@ public class PhysicalWeb {
* @return boolean {@code true} if onboarding is complete.
*/
public static boolean isOnboarding() {
return PrivacyPreferencesManager.getInstance().isPhysicalWebOnboarding();
return false;
}
/**
......@@ -104,11 +72,6 @@ public class PhysicalWeb {
return;
}
// If this user is in the default state, we need to check if we should enable Physical Web.
if (isOnboarding() && shouldAutoEnablePhysicalWeb()) {
PrivacyPreferencesManager.getInstance().setPhysicalWebEnabled(true);
}
updateScans();
// The PhysicalWebUma call in this method should be called only when the native library
// is loaded. This is always the case on chrome startup.
......
// Copyright 2015 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.chrome.browser.preferences.privacy;
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceFragment;
import org.chromium.base.Log;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.physicalweb.PhysicalWeb;
import org.chromium.chrome.browser.physicalweb.PhysicalWebUma;
import org.chromium.chrome.browser.preferences.ButtonPreference;
import org.chromium.chrome.browser.preferences.ChromeSwitchPreference;
import org.chromium.chrome.browser.preferences.PreferenceUtils;
/**
* Fragment to manage the Physical Web preference and to explain to the user what it does.
*/
public class PhysicalWebPreferenceFragment extends PreferenceFragment {
private static final String TAG = "PhysicalWeb";
private static final String PREF_PHYSICAL_WEB_SWITCH = "physical_web_switch";
private static final String PREF_PHYSICAL_WEB_LAUNCH = "physical_web_launch";
private static final int REQUEST_ID = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PreferenceUtils.addPreferencesFromResource(this, R.xml.physical_web_preferences);
getActivity().setTitle(R.string.physical_web_pref_title);
initPhysicalWebSwitch();
initLaunchButton();
}
private void ensureLocationPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (getActivity().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
Log.d(TAG, "Location permission already granted");
} else {
Log.d(TAG, "Requesting location permission");
requestPermissions(
new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_ID);
}
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[],
int[] grantResults) {
switch (requestCode) {
case REQUEST_ID:
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
PhysicalWebUma.onPrefsLocationGranted();
Log.d(TAG, "Location permission granted");
} else {
PhysicalWebUma.onPrefsLocationDenied();
Log.d(TAG, "Location permission denied");
}
break;
default:
}
PhysicalWeb.updateScans();
}
private void initPhysicalWebSwitch() {
ChromeSwitchPreference physicalWebSwitch =
(ChromeSwitchPreference) findPreference(PREF_PHYSICAL_WEB_SWITCH);
physicalWebSwitch.setChecked(
PrivacyPreferencesManager.getInstance().isPhysicalWebEnabled());
physicalWebSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean enabled = (boolean) newValue;
if (enabled) {
PhysicalWebUma.onPrefsFeatureEnabled();
ensureLocationPermission();
} else {
PhysicalWebUma.onPrefsFeatureDisabled();
}
PrivacyPreferencesManager.getInstance().setPhysicalWebEnabled(enabled);
return true;
}
});
}
private void initLaunchButton() {
ButtonPreference physicalWebLaunch =
(ButtonPreference) findPreference(PREF_PHYSICAL_WEB_LAUNCH);
physicalWebLaunch.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
PhysicalWebUma.onActivityReferral(PhysicalWebUma.PREFERENCE_REFERER);
PhysicalWeb.showUrlList();
return true;
}
});
}
}
......@@ -14,13 +14,11 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import org.chromium.base.SysUtils;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.contextualsearch.ContextualSearchFieldTrial;
import org.chromium.chrome.browser.help.HelpAndFeedback;
import org.chromium.chrome.browser.physicalweb.PhysicalWeb;
import org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference;
import org.chromium.chrome.browser.preferences.ManagedPreferenceDelegate;
import org.chromium.chrome.browser.preferences.PrefServiceBridge;
......@@ -43,7 +41,6 @@ public class PrivacyPreferences extends PreferenceFragment
private static final String PREF_NETWORK_PREDICTIONS = "network_predictions";
private static final String PREF_DO_NOT_TRACK = "do_not_track";
private static final String PREF_USAGE_AND_CRASH_REPORTING = "usage_and_crash_reports";
private static final String PREF_PHYSICAL_WEB = "physical_web";
private static final String PREF_CLEAR_BROWSING_DATA = "clear_browsing_data";
private ManagedPreferenceDelegate mManagedPreferenceDelegate;
......@@ -106,10 +103,6 @@ public class PrivacyPreferences extends PreferenceFragment
safeBrowsingPref.setOnPreferenceChangeListener(this);
safeBrowsingPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
if (!PhysicalWeb.featureIsEnabled() || SysUtils.isLowEndDevice()) {
preferenceScreen.removePreference(findPreference(PREF_PHYSICAL_WEB));
}
updateSummaries();
}
......@@ -195,12 +188,6 @@ public class PrivacyPreferences extends PreferenceFragment
contextualPref.setSummary(isContextualSearchEnabled ? textOn : textOff);
}
Preference physicalWebPref = findPreference(PREF_PHYSICAL_WEB);
if (physicalWebPref != null) {
physicalWebPref.setSummary(privacyPrefManager.isPhysicalWebEnabled()
? textOn : textOff);
}
Preference usageAndCrashPref = findPreference(PREF_USAGE_AND_CRASH_REPORTING);
if (usageAndCrashPref != null) {
usageAndCrashPref.setSummary(
......
......@@ -15,7 +15,6 @@ import org.chromium.base.ContextUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.device.DeviceClassManager;
import org.chromium.chrome.browser.physicalweb.PhysicalWeb;
import org.chromium.chrome.browser.preferences.PrefServiceBridge;
import org.chromium.chrome.browser.survey.SurveyController;
import org.chromium.components.minidump_uploader.util.CrashReportingPermissionManager;
......@@ -29,6 +28,8 @@ public class PrivacyPreferencesManager implements CrashReportingPermissionManage
static final String DEPRECATED_PREF_CRASH_DUMP_UPLOAD_NO_CELLULAR =
"crash_dump_upload_no_cellular";
private static final String DEPRECATED_PREF_CELLULAR_EXPERIMENT = "cellular_experiment";
private static final String DEPRECATED_PREF_PHYSICAL_WEB = "physical_web";
private static final String DEPRECATED_PREF_PHYSICAL_WEB_SHARING = "physical_web_sharing";
public static final String PREF_METRICS_REPORTING = "metrics_reporting";
private static final String PREF_METRICS_IN_SAMPLE = "in_metrics_sample";
......@@ -36,10 +37,6 @@ public class PrivacyPreferencesManager implements CrashReportingPermissionManage
private static final String PREF_BANDWIDTH_OLD = "prefetch_bandwidth";
private static final String PREF_BANDWIDTH_NO_CELLULAR_OLD = "prefetch_bandwidth_no_cellular";
private static final String ALLOW_PRERENDER_OLD = "allow_prefetch";
private static final String PREF_PHYSICAL_WEB = "physical_web";
private static final int PHYSICAL_WEB_OFF = 0;
private static final int PHYSICAL_WEB_ON = 1;
private static final int PHYSICAL_WEB_ONBOARDING = 2;
@SuppressLint("StaticFieldLeak")
private static PrivacyPreferencesManager sInstance;
......@@ -52,6 +49,7 @@ public class PrivacyPreferencesManager implements CrashReportingPermissionManage
mContext = context;
mSharedPreferences = ContextUtils.getAppSharedPreferences();
migratePhysicalWebPreferences();
migrateUsageAndCrashPreferences();
}
......@@ -62,6 +60,14 @@ public class PrivacyPreferencesManager implements CrashReportingPermissionManage
return sInstance;
}
// TODO(https://crbug.com/826540): Remove some time after 4/2019.
public void migratePhysicalWebPreferences() {
SharedPreferences.Editor editor = mSharedPreferences.edit();
editor.remove(DEPRECATED_PREF_PHYSICAL_WEB)
.remove(DEPRECATED_PREF_PHYSICAL_WEB_SHARING)
.apply();
}
public void migrateUsageAndCrashPreferences() {
SharedPreferences.Editor editor = mSharedPreferences.edit();
......@@ -305,37 +311,4 @@ public class PrivacyPreferencesManager implements CrashReportingPermissionManage
return isNetworkAvailable()
&& (isUsageAndCrashReportingPermittedByUser() || isUploadEnabledForTests());
}
/**
* Sets the Physical Web preference, which enables background scanning for bluetooth beacons
* and displays a notification when beacons are found.
*
* @param enabled A boolean indicating whether to notify on nearby beacons.
*/
public void setPhysicalWebEnabled(boolean enabled) {
mSharedPreferences.edit()
.putInt(PREF_PHYSICAL_WEB, enabled ? PHYSICAL_WEB_ON : PHYSICAL_WEB_OFF)
.apply();
PhysicalWeb.updateScans();
}
/**
* Check whether the user is still in the Physical Web onboarding flow.
*
* @return boolean {@code true} if onboarding is not yet complete.
*/
public boolean isPhysicalWebOnboarding() {
int state = mSharedPreferences.getInt(PREF_PHYSICAL_WEB, PHYSICAL_WEB_ONBOARDING);
return (state == PHYSICAL_WEB_ONBOARDING);
}
/**
* Check whether Physical Web is configured to notify on nearby beacons.
*
* @return boolean {@code true} if the feature is enabled.
*/
public boolean isPhysicalWebEnabled() {
int state = mSharedPreferences.getInt(PREF_PHYSICAL_WEB, PHYSICAL_WEB_ONBOARDING);
return (state == PHYSICAL_WEB_ON);
}
}
......@@ -3032,19 +3032,6 @@ However, you aren’t invisible. Going incognito doesn’t hide your browsing fr
Client side certificate selection is not supported by the operating system.
</message>
<!-- Physical Web strings -->
<message name="IDS_PHYSICAL_WEB_PREF_TITLE" desc="Title for Physical Web preference.">
Physical Web
</message>
<message name="IDS_PHYSICAL_WEB_PREF_DESCRIPTION" desc="Description for Physical Web preference">
Discover web pages sent by nearby objects. Chrome gathers web pages associated with objects around you, sends them anonymously to a Google service to find the ones most useful to you, then displays them.
You must have Bluetooth and Location turned on in order to use the Physical Web.
</message>
<message name="IDS_PHYSICAL_WEB_LAUNCH_BUTTON" desc="The label for a button that opens a list of nearby URLs">
See what’s nearby
</message>
<!-- WebUsb Picker UI strings -->
<message name="IDS_USB_CHOOSER_DIALOG_PROMPT" desc="The text that is used to introduce the USB chooser dialog to the user.">
<ph name="SITE">%1$s<ex>https://www.google.com</ex></ph> wants to connect
......
......@@ -1057,7 +1057,6 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/preferences/privacy/ContextualSearchPreferenceFragment.java",
"java/src/org/chromium/chrome/browser/preferences/privacy/DoNotTrackPreference.java",
"java/src/org/chromium/chrome/browser/preferences/privacy/OtherFormsOfHistoryDialogFragment.java",
"java/src/org/chromium/chrome/browser/preferences/privacy/PhysicalWebPreferenceFragment.java",
"java/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferences.java",
"java/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferencesManager.java",
"java/src/org/chromium/chrome/browser/preferences/privacy/UsageAndCrashReportsPreferenceFragment.java",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment