summaryrefslogtreecommitdiff
path: root/chromium/components/browser_ui/site_settings
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/browser_ui/site_settings')
-rw-r--r--chromium/components/browser_ui/site_settings/DEPS1
-rw-r--r--chromium/components/browser_ui/site_settings/android/BUILD.gn8
-rw-r--r--chromium/components/browser_ui/site_settings/android/java/res/drawable/settings_bluetooth.xml5
-rw-r--r--chromium/components/browser_ui/site_settings/android/java/res/xml/site_settings_preferences.xml46
-rw-r--r--chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java10
-rw-r--r--chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/PermissionInfo.java45
-rw-r--r--chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java35
-rw-r--r--chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java61
-rw-r--r--chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettings.java7
-rw-r--r--chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsCategory.java21
-rw-r--r--chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsPrefClient.java7
-rw-r--r--chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsPreference.java36
-rw-r--r--chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java43
-rw-r--r--chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreference.java14
-rw-r--r--chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java55
-rw-r--r--chromium/components/browser_ui/site_settings/android/javatests/src/org/chromium/components/browser_ui/site_settings/WebsiteAddressTest.java2
-rw-r--r--chromium/components/browser_ui/site_settings/android/site_settings_feature_list.cc1
-rw-r--r--chromium/components/browser_ui/site_settings/android/storage_info_fetcher.cc17
-rw-r--r--chromium/components/browser_ui/site_settings/android/website_preference_bridge.cc18
19 files changed, 263 insertions, 169 deletions
diff --git a/chromium/components/browser_ui/site_settings/DEPS b/chromium/components/browser_ui/site_settings/DEPS
index 29ca6c45af1..62df9f80480 100644
--- a/chromium/components/browser_ui/site_settings/DEPS
+++ b/chromium/components/browser_ui/site_settings/DEPS
@@ -7,6 +7,7 @@ include_rules = [
"+components/embedder_support/android",
"+components/location/android",
"+components/permissions",
+ "+components/prefs/android",
"+components/subresource_filter/android",
"+components/url_formatter/android",
"+components/user_prefs",
diff --git a/chromium/components/browser_ui/site_settings/android/BUILD.gn b/chromium/components/browser_ui/site_settings/android/BUILD.gn
index 894e9a34438..64150f04e4c 100644
--- a/chromium/components/browser_ui/site_settings/android/BUILD.gn
+++ b/chromium/components/browser_ui/site_settings/android/BUILD.gn
@@ -65,7 +65,6 @@ android_library("java") {
"java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsFeatureList.java",
"java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsHelpClient.java",
"java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsPrefClient.java",
- "java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsPreference.java",
"java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsPreferenceFragment.java",
"java/src/org/chromium/components/browser_ui/site_settings/StorageInfo.java",
"java/src/org/chromium/components/browser_ui/site_settings/TriStateSiteSettingsPreference.java",
@@ -89,8 +88,10 @@ android_library("java") {
"//components/embedder_support/android:util_java",
"//components/location/android:location_java",
"//components/permissions/android:java",
+ "//components/prefs/android:java",
"//components/subresource_filter/android:java",
"//components/url_formatter/android:url_formatter_java",
+ "//components/user_prefs/android:java",
"//content/public/android:content_java",
"//services/device/public/java:device_feature_list_java",
"//third_party/android_deps:android_support_v7_appcompat_java",
@@ -98,6 +99,8 @@ android_library("java") {
"//ui/android:ui_full_java",
"//ui/android:ui_utils_java",
]
+ srcjar_deps =
+ [ "//components/content_settings/android:java_pref_names_srcjar" ]
}
android_library("javatests") {
@@ -105,7 +108,9 @@ android_library("javatests") {
sources = [ "javatests/src/org/chromium/components/browser_ui/site_settings/WebsiteAddressTest.java" ]
deps = [
":java",
+ "//base:base_java",
"//base:base_java_test_support",
+ "//third_party/junit",
]
}
@@ -182,6 +187,7 @@ android_resources("java_resources") {
"java/res/drawable-xxxhdpi/settings_usb.png",
"java/res/drawable-xxxhdpi/web_asset.png",
"java/res/drawable/ic_person_24dp.xml",
+ "java/res/drawable/settings_bluetooth.xml",
"java/res/layout/add_site_dialog.xml",
"java/res/layout/clear_data_dialog.xml",
"java/res/layout/clear_storage.xml",
diff --git a/chromium/components/browser_ui/site_settings/android/java/res/drawable/settings_bluetooth.xml b/chromium/components/browser_ui/site_settings/android/java/res/drawable/settings_bluetooth.xml
new file mode 100644
index 00000000000..0fe09abbbc9
--- /dev/null
+++ b/chromium/components/browser_ui/site_settings/android/java/res/drawable/settings_bluetooth.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
+ <path android:pathData="M0 0h24v24H0z"/>
+ <path android:fillColor="@color/default_icon_color_secondary_dark" android:pathData="M17.71 7.71L12 2h-1v7.59L6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 11 14.41V22h1l5.71-5.71-4.3-4.29 4.3-4.29zM13 5.83l1.88 1.88L13 9.59V5.83zm1.88 10.46L13 18.17v-3.76l1.88 1.88z"/>
+</vector>
diff --git a/chromium/components/browser_ui/site_settings/android/java/res/xml/site_settings_preferences.xml b/chromium/components/browser_ui/site_settings/android/java/res/xml/site_settings_preferences.xml
index 9f20c01689b..b9b237e08e1 100644
--- a/chromium/components/browser_ui/site_settings/android/java/res/xml/site_settings_preferences.xml
+++ b/chromium/components/browser_ui/site_settings/android/java/res/xml/site_settings_preferences.xml
@@ -7,94 +7,98 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- All sites -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="all_sites"
android:title="@string/all_sites"
android:icon="@drawable/settings_all_sites"
app:iconTint="@color/default_icon_color" />
<!-- Cookies -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:key="cookies"
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings" />
<!-- Location -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="device_location" />
<!-- Camera -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="camera" />
<!-- Microphone -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="microphone" />
<!-- Sensors -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="sensors" />
<!-- Notifications -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="notifications" />
<!-- JavaScript -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="javascript" />
<!-- Popups -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="popups" />
<!-- Ads -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="ads" />
<!-- Background sync -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="background_sync" />
<!-- Automatic Downloads -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="automatic_downloads" />
<!-- Protected content -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="protected_content" />
<!-- Sound -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="sound" />
<!-- Storage -->
<!-- TODO(finnur): Move this over to the new Usage screen, once it exists. -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="use_storage"
android:title="@string/website_settings_storage"
android:icon="@drawable/settings_storage"
app:iconTint="@color/default_icon_color" />
<!-- NFC -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="nfc" />
<!-- USB -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="usb" />
<!-- Clipboard API -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="clipboard" />
+ <!-- Bluetooth -->
+ <org.chromium.components.browser_ui.settings.IconPreference
+ android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
+ android:key="bluetooth" />
<!-- Bluetooth Scanning -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="bluetooth_scanning" />
<!-- VR -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="virtual_reality" />
<!-- AR -->
- <org.chromium.components.browser_ui.site_settings.SiteSettingsPreference
+ <org.chromium.components.browser_ui.settings.IconPreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="augmented_reality" />
</PreferenceScreen>
diff --git a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java
index a8471043b22..89b1ee327c6 100644
--- a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java
+++ b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java
@@ -118,6 +118,16 @@ public class ContentSettingsResources {
R.string.background_sync_permission_title, ContentSettingValues.ALLOW,
ContentSettingValues.BLOCK,
R.string.website_settings_category_allowed_recommended, 0));
+ localMap.put(ContentSettingsType.BLUETOOTH_CHOOSER_DATA,
+ new ResourceItem(R.drawable.settings_bluetooth, 0, 0, ContentSettingValues.ASK,
+ ContentSettingValues.BLOCK, 0, 0));
+ localMap.put(ContentSettingsType.BLUETOOTH_GUARD,
+ new ResourceItem(R.drawable.settings_bluetooth,
+ R.string.website_settings_bluetooth,
+ R.string.website_settings_bluetooth, ContentSettingValues.ASK,
+ ContentSettingValues.BLOCK,
+ R.string.website_settings_category_bluetooth_ask,
+ R.string.website_settings_category_bluetooth_blocked));
localMap.put(ContentSettingsType.BLUETOOTH_SCANNING,
new ResourceItem(R.drawable.ic_bluetooth_searching_black_24dp,
R.string.website_settings_bluetooth_scanning,
diff --git a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/PermissionInfo.java b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/PermissionInfo.java
index 488c062dc20..8f11649a727 100644
--- a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/PermissionInfo.java
+++ b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/PermissionInfo.java
@@ -20,7 +20,7 @@ import java.lang.annotation.RetentionPolicy;
*/
public class PermissionInfo implements Serializable {
@IntDef({Type.AUGMENTED_REALITY, Type.CAMERA, Type.CLIPBOARD, Type.GEOLOCATION, Type.MICROPHONE,
- Type.MIDI, Type.NOTIFICATION, Type.PROTECTED_MEDIA_IDENTIFIER, Type.SENSORS,
+ Type.MIDI, Type.NFC, Type.NOTIFICATION, Type.PROTECTED_MEDIA_IDENTIFIER, Type.SENSORS,
Type.VIRTUAL_REALITY})
@Retention(RetentionPolicy.SOURCE)
public @interface Type {
@@ -45,15 +45,22 @@ public class PermissionInfo implements Serializable {
}
private final boolean mIsIncognito;
+ private final boolean mIsEmbargoed;
private final String mEmbedder;
private final String mOrigin;
private final @Type int mType;
public PermissionInfo(@Type int type, String origin, String embedder, boolean isIncognito) {
+ this(type, origin, embedder, isIncognito, false);
+ }
+
+ public PermissionInfo(@Type int type, String origin, String embedder, boolean isIncognito,
+ boolean isEmbargoed) {
mOrigin = origin;
mEmbedder = embedder;
mIsIncognito = isIncognito;
mType = type;
+ mIsEmbargoed = isEmbargoed;
}
public @Type int getType() {
@@ -76,6 +83,10 @@ public class PermissionInfo implements Serializable {
return mEmbedder != null ? mEmbedder : mOrigin;
}
+ public boolean isEmbargoed() {
+ return mIsEmbargoed;
+ }
+
/**
* Returns the ContentSetting value for this origin.
*/
@@ -205,4 +216,36 @@ public class PermissionInfo implements Serializable {
return ContentSettingsType.DEFAULT;
}
}
+
+ /**
+ * If conversion is not possible, method returns null.
+ */
+ public static @Type Integer getPermissionInfoType(@ContentSettingsType int type) {
+ switch (type) {
+ case ContentSettingsType.AR:
+ return Type.AUGMENTED_REALITY;
+ case ContentSettingsType.MEDIASTREAM_CAMERA:
+ return Type.CAMERA;
+ case ContentSettingsType.CLIPBOARD_READ_WRITE:
+ return Type.CLIPBOARD;
+ case ContentSettingsType.GEOLOCATION:
+ return Type.GEOLOCATION;
+ case ContentSettingsType.MEDIASTREAM_MIC:
+ return Type.MICROPHONE;
+ case ContentSettingsType.MIDI_SYSEX:
+ return Type.MIDI;
+ case ContentSettingsType.NFC:
+ return Type.NFC;
+ case ContentSettingsType.NOTIFICATIONS:
+ return Type.NOTIFICATION;
+ case ContentSettingsType.PROTECTED_MEDIA_IDENTIFIER:
+ return Type.PROTECTED_MEDIA_IDENTIFIER;
+ case ContentSettingsType.SENSORS:
+ return Type.SENSORS;
+ case ContentSettingsType.VR:
+ return Type.VIRTUAL_REALITY;
+ default:
+ return null;
+ }
+ }
}
diff --git a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java
index 68503a37405..6ab6038f9c0 100644
--- a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java
+++ b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java
@@ -6,6 +6,8 @@ package org.chromium.components.browser_ui.site_settings;
import static org.chromium.components.browser_ui.settings.SearchUtils.handleSearchNavigation;
import static org.chromium.components.browser_ui.site_settings.WebsitePreferenceBridge.SITE_WILDCARD;
+import static org.chromium.components.content_settings.PrefNames.BLOCK_THIRD_PARTY_COOKIES;
+import static org.chromium.components.content_settings.PrefNames.COOKIE_CONTROLS_MODE;
import android.content.Context;
import android.content.DialogInterface;
@@ -53,6 +55,8 @@ import org.chromium.components.content_settings.ContentSettingsType;
import org.chromium.components.content_settings.CookieControlsMode;
import org.chromium.components.embedder_support.browser_context.BrowserContextHandle;
import org.chromium.components.embedder_support.util.UrlUtilities;
+import org.chromium.components.prefs.PrefService;
+import org.chromium.components.user_prefs.UserPrefs;
import org.chromium.ui.widget.Toast;
import java.util.ArrayList;
@@ -518,6 +522,7 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
public boolean onPreferenceChange(Preference preference, Object newValue) {
BrowserContextHandle browserContextHandle =
getSiteSettingsClient().getBrowserContextHandle();
+ PrefService prefService = UserPrefs.get(browserContextHandle);
if (BINARY_TOGGLE_KEY.equals(preference.getKey())) {
assert !mCategory.isManaged();
@@ -551,7 +556,7 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
setCookieSettingsPreference((CookieSettingsState) newValue);
getInfoForOrigins();
} else if (THIRD_PARTY_COOKIES_TOGGLE_KEY.equals(preference.getKey())) {
- getPrefs().setBlockThirdPartyCookies((boolean) newValue);
+ prefService.setBoolean(BLOCK_THIRD_PARTY_COOKIES, (boolean) newValue);
} else if (NOTIFICATIONS_VIBRATE_TOGGLE_KEY.equals(preference.getKey())) {
getPrefs().setNotificationsVibrateEnabled((boolean) newValue);
} else if (NOTIFICATIONS_QUIET_UI_TOGGLE_KEY.equals(preference.getKey())) {
@@ -595,8 +600,10 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
WebsitePreferenceBridge.setCategoryEnabled(
getSiteSettingsClient().getBrowserContextHandle(), ContentSettingsType.COOKIES,
allowCookies);
- getPrefs().setCookieControlsMode(mode);
- getPrefs().setBlockThirdPartyCookies(mode == CookieControlsMode.BLOCK_THIRD_PARTY);
+ PrefService prefService = UserPrefs.get(getSiteSettingsClient().getBrowserContextHandle());
+ prefService.setInteger(COOKIE_CONTROLS_MODE, mode);
+ prefService.setBoolean(
+ BLOCK_THIRD_PARTY_COOKIES, mode == CookieControlsMode.BLOCK_THIRD_PARTY);
}
private boolean cookieSettingsExceptionShouldBlock() {
@@ -865,7 +872,7 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
for (Website site : sites) {
for (ChosenObjectInfo info : site.getChosenObjectInfo()) {
if (mSearch == null || mSearch.isEmpty()
- || info.getName().toLowerCase().contains(mSearch)) {
+ || info.getName().toLowerCase(Locale.getDefault()).contains(mSearch)) {
Pair<ArrayList<ChosenObjectInfo>, ArrayList<Website>> entry =
objects.get(info.getObject());
if (entry == null) {
@@ -890,8 +897,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
extras.putString(EXTRA_TITLE, getActivity().getTitle().toString());
extras.putSerializable(ChosenObjectSettings.EXTRA_OBJECT_INFOS, entry.first);
extras.putSerializable(ChosenObjectSettings.EXTRA_SITES, entry.second);
- preference.setIcon(
- ContentSettingsResources.getIcon(mCategory.getContentSettingsType()));
+ preference.setIcon(SettingsUtils.getTintedIcon(getActivity(),
+ ContentSettingsResources.getIcon(mCategory.getContentSettingsType())));
preference.setTitle(entry.first.get(0).getName());
preference.setFragment(ChosenObjectSettings.class.getCanonicalName());
getPreferenceScreen().addPreference(preference);
@@ -1016,7 +1023,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
}
// Only show the link that explains protected content settings when needed.
- if (mCategory.showSites(SiteSettingsCategory.Type.PROTECTED_MEDIA)) {
+ if (mCategory.showSites(SiteSettingsCategory.Type.PROTECTED_MEDIA)
+ && getSiteSettingsClient().getSiteSettingsHelpClient().isHelpAndFeedbackEnabled()) {
explainProtectedMediaKey.setOnPreferenceClickListener(preference -> {
getSiteSettingsClient()
.getSiteSettingsHelpClient()
@@ -1075,10 +1083,12 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
new FourStateCookieSettingsPreference.Params();
params.allowCookies = WebsitePreferenceBridge.isCategoryEnabled(
getSiteSettingsClient().getBrowserContextHandle(), ContentSettingsType.COOKIES);
- params.blockThirdPartyCookies = getPrefs().getBlockThirdPartyCookies();
- params.cookieControlsMode = getPrefs().getCookieControlsMode();
+ PrefService prefService = UserPrefs.get(getSiteSettingsClient().getBrowserContextHandle());
+ params.blockThirdPartyCookies = prefService.getBoolean(BLOCK_THIRD_PARTY_COOKIES);
+ params.cookieControlsMode = prefService.getInteger(COOKIE_CONTROLS_MODE);
params.cookiesContentSettingEnforced = mCategory.isManaged();
- params.thirdPartyBlockingEnforced = getPrefs().isBlockThirdPartyCookiesManaged();
+ params.thirdPartyBlockingEnforced =
+ prefService.isManagedPreference(BLOCK_THIRD_PARTY_COOKIES);
fourStateCookieToggle.setState(params);
}
@@ -1125,14 +1135,15 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
ChromeBaseCheckBoxPreference thirdPartyCookiesPref =
(ChromeBaseCheckBoxPreference) getPreferenceScreen().findPreference(
THIRD_PARTY_COOKIES_TOGGLE_KEY);
- thirdPartyCookiesPref.setChecked(getPrefs().getBlockThirdPartyCookies());
+ PrefService prefService = UserPrefs.get(getSiteSettingsClient().getBrowserContextHandle());
+ thirdPartyCookiesPref.setChecked(prefService.getBoolean(BLOCK_THIRD_PARTY_COOKIES));
thirdPartyCookiesPref.setEnabled(WebsitePreferenceBridge.isCategoryEnabled(
getSiteSettingsClient().getBrowserContextHandle(), ContentSettingsType.COOKIES));
thirdPartyCookiesPref.setManagedPreferenceDelegate(new ForwardingManagedPreferenceDelegate(
getSiteSettingsClient().getManagedPreferenceDelegate()) {
@Override
public boolean isPreferenceControlledByPolicy(Preference preference) {
- return getPrefs().isBlockThirdPartyCookiesManaged();
+ return prefService.isManagedPreference(BLOCK_THIRD_PARTY_COOKIES);
}
});
}
diff --git a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java
index edcf1a9ebb9..c1a5bb603e6 100644
--- a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java
+++ b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java
@@ -350,7 +350,9 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
} else if (i == ContentSettingException.Type.JAVASCRIPT) {
setUpJavascriptPreference(preference);
} else {
- setUpListPreference(preference, mSite.getContentSettingPermission(i));
+ // ContentSettingException can not be embargoed.
+ setUpListPreference(preference, mSite.getContentSettingPermission(i),
+ false /* isEmbargoed */);
}
return;
}
@@ -362,17 +364,23 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
if (i == PermissionInfo.Type.GEOLOCATION) {
setUpLocationPreference(preference);
} else if (i == PermissionInfo.Type.NOTIFICATION) {
- setUpNotificationsPreference(preference);
+ setUpNotificationsPreference(
+ preference, isPermissionEmbargoed(PermissionInfo.Type.NOTIFICATION));
} else {
setUpListPreference(preference,
mSite.getPermission(
- getSiteSettingsClient().getBrowserContextHandle(), i));
+ getSiteSettingsClient().getBrowserContextHandle(), i),
+ isPermissionEmbargoed(i));
}
return;
}
}
}
+ private boolean isPermissionEmbargoed(@PermissionInfo.Type int type) {
+ return mSite.getPermissionInfo(type) != null && mSite.getPermissionInfo(type).isEmbargoed();
+ }
+
private void setUpClearDataPreference(ClearWebsiteStorage preference) {
long usage = mSite.getTotalUsage();
if (usage > 0) {
@@ -452,7 +460,7 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
});
}
- private void setUpNotificationsPreference(Preference preference) {
+ private void setUpNotificationsPreference(Preference preference, boolean isEmbargoed) {
WebappSettingsClient client = getSiteSettingsClient().getWebappSettingsClient();
Origin origin = Origin.create(mSite.getAddress().getOrigin());
if (origin != null) {
@@ -482,14 +490,15 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
getPreferenceScreen().removePreference(preference);
return;
}
-
String overrideSummary;
if (isPermissionControlledByDSE(ContentSettingsType.NOTIFICATIONS)) {
overrideSummary = getString(value != null && value == ContentSettingValues.ALLOW
? R.string.website_settings_permissions_allow_dse
: R.string.website_settings_permissions_block_dse);
} else {
- overrideSummary = getString(ContentSettingsResources.getSiteSummary(value));
+ overrideSummary = isEmbargoed
+ ? getString(R.string.automatically_blocked)
+ : getString(ContentSettingsResources.getSiteSummary(value));
}
// On Android O this preference is read-only, so we replace the existing pref with a
@@ -503,7 +512,7 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
return true;
});
} else {
- setUpListPreference(preference, value);
+ setUpListPreference(preference, value, isEmbargoed);
if (isPermissionControlledByDSE(ContentSettingsType.NOTIFICATIONS) && value != null) {
updatePreferenceForDSESetting(preference);
}
@@ -512,14 +521,9 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
// This is implemented as a public utility function to better facilitate testing.
public void launchOsChannelSettingsFromPreference(Preference preference) {
- final boolean blockedByEmbargo =
- (WebsitePreferenceBridgeJni.get().isNotificationEmbargoedForOrigin(
- getSiteSettingsClient().getBrowserContextHandle(),
- mSite.getAddress().getOrigin()));
-
// There is no notification channel if the origin is merely embargoed. Create it
// just-in-time if the user tries to change to setting.
- if (blockedByEmbargo) {
+ if (isPermissionEmbargoed(PermissionInfo.Type.NOTIFICATION)) {
mSite.setPermission(getSiteSettingsClient().getBrowserContextHandle(),
PermissionInfo.Type.NOTIFICATION, ContentSettingValues.BLOCK);
}
@@ -567,7 +571,7 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
findPreference(PERMISSION_PREFERENCE_KEYS[PermissionInfo.Type.NOTIFICATION
+ ContentSettingException.Type.NUM_ENTRIES]);
if (notificationsPreference != null) {
- setUpNotificationsPreference(notificationsPreference);
+ setUpNotificationsPreference(notificationsPreference, false /* isEmbargoed */);
}
// To ensure UMA receives notification revocations, we detect if the setting has changed
@@ -608,7 +612,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
new ChromeImageViewPreference(getStyledContext());
preference.setKey(CHOOSER_PERMISSION_PREFERENCE_KEY);
- preference.setIcon(ContentSettingsResources.getIcon(info.getContentSettingsType()));
+ preference.setIcon(SettingsUtils.getTintedIcon(getActivity(),
+ ContentSettingsResources.getIcon(info.getContentSettingsType())));
preference.setOrder(maxPermissionOrder);
preference.setTitle(info.getName());
preference.setImageView(R.drawable.ic_delete_white_24dp,
@@ -745,8 +750,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
* @param preference The ListPreference to initialize.
* @param value The value to initialize it to.
*/
- private void setUpListPreference(
- Preference preference, @ContentSettingValues @Nullable Integer value) {
+ private void setUpListPreference(Preference preference,
+ @ContentSettingValues @Nullable Integer value, boolean isEmbargoed) {
if (value == null) {
getPreferenceScreen().removePreference(preference);
return;
@@ -764,12 +769,12 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
getString(ContentSettingsResources.getSiteSummary(ContentSettingValues.BLOCK));
listPreference.setEntryValues(keys);
listPreference.setEntries(descriptions);
+ listPreference.setOnPreferenceChangeListener(this);
+ listPreference.setSummary(isEmbargoed ? getString(R.string.automatically_blocked) : "%s");
// TODO(crbug.com/735110): Figure out if this is the correct thing to do - here we are
// effectively treating non-ALLOW values as BLOCK.
int index = (value == ContentSettingValues.ALLOW ? 0 : 1);
listPreference.setValueIndex(index);
- listPreference.setOnPreferenceChangeListener(this);
- listPreference.setSummary("%s");
}
/**
@@ -803,7 +808,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
@Nullable
Integer permission = mSite.getPermission(
getSiteSettingsClient().getBrowserContextHandle(), PermissionInfo.Type.GEOLOCATION);
- setUpListPreference(preference, permission);
+ setUpListPreference(
+ preference, permission, isPermissionEmbargoed(PermissionInfo.Type.GEOLOCATION));
if (isPermissionControlledByDSE(ContentSettingsType.GEOLOCATION) && permission != null) {
updatePreferenceForDSESetting(preference);
}
@@ -823,7 +829,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
? ContentSettingValues.ALLOW
: ContentSettingValues.BLOCK;
}
- setUpListPreference(preference, currentValue);
+ // Not possible to embargo SOUND.
+ setUpListPreference(preference, currentValue, false /* isEmbargoed */);
}
private void setUpJavascriptPreference(Preference preference) {
@@ -839,7 +846,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
ContentSettingsType.JAVASCRIPT)) {
currentValue = ContentSettingValues.BLOCK;
}
- setUpListPreference(preference, currentValue);
+ // Not possible to embargo JAVASCRIPT.
+ setUpListPreference(preference, currentValue, false /* isEmbargoed */);
}
/**
@@ -852,7 +860,7 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
private void setUpAdsPreference(Preference preference) {
// Do not show the setting if the category is not enabled.
if (!SiteSettingsCategory.adsCategoryEnabled()) {
- setUpListPreference(preference, null);
+ setUpListPreference(preference, null, false);
return;
}
// If the ad blocker is activated, then this site will have ads blocked unless there is an
@@ -867,7 +875,7 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
// If the site is not considered a candidate for blocking, do the standard thing and remove
// the preference.
if (permission == null && !activated) {
- setUpListPreference(preference, null);
+ setUpListPreference(preference, null, false);
return;
}
@@ -880,7 +888,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
? ContentSettingValues.ALLOW
: ContentSettingValues.BLOCK;
}
- setUpListPreference(preference, permission);
+ // Not possible to embargo ADS.
+ setUpListPreference(preference, permission, false /* isEmbargoed */);
// The subresource filter permission has a custom BLOCK string.
ListPreference listPreference = (ListPreference) preference;
@@ -935,6 +944,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
public boolean onPreferenceChange(Preference preference, Object newValue) {
@ContentSettingValues
int permission = ContentSetting.fromString((String) newValue);
+ // Embargoed permission preserves summary. Refresh it manually.
+ preference.setSummary("%s");
BrowserContextHandle browserContextHandle =
getSiteSettingsClient().getBrowserContextHandle();
for (int i = 0; i < PERMISSION_PREFERENCE_KEYS.length; i++) {
diff --git a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettings.java b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettings.java
index a03499bd5ac..2c75d1125f0 100644
--- a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettings.java
+++ b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettings.java
@@ -4,6 +4,8 @@
package org.chromium.components.browser_ui.site_settings;
+import static org.chromium.components.content_settings.PrefNames.BLOCK_THIRD_PARTY_COOKIES;
+
import android.os.Bundle;
import androidx.preference.Preference;
@@ -12,6 +14,7 @@ import org.chromium.components.browser_ui.settings.SettingsUtils;
import org.chromium.components.browser_ui.site_settings.SiteSettingsCategory.Type;
import org.chromium.components.content_settings.ContentSettingValues;
import org.chromium.components.embedder_support.browser_context.BrowserContextHandle;
+import org.chromium.components.user_prefs.UserPrefs;
/**
* The main Site Settings screen, which shows all the site settings categories: All sites, Location,
@@ -96,9 +99,7 @@ public class SiteSettings
// Show 'disabled' message when permission is not granted in Android.
p.setSummary(ContentSettingsResources.getCategorySummary(contentType, false));
} else if (Type.COOKIES == prefCategory && checked
- && getSiteSettingsClient()
- .getSiteSettingsPrefClient()
- .getBlockThirdPartyCookies()) {
+ && UserPrefs.get(browserContextHandle).getBoolean(BLOCK_THIRD_PARTY_COOKIES)) {
p.setSummary(ContentSettingsResources.getCookieAllowedExceptThirdPartySummary());
} else if (Type.DEVICE_LOCATION == prefCategory && checked
&& WebsitePreferenceBridge.isLocationAllowedByPolicy(browserContextHandle)) {
diff --git a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsCategory.java b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsCategory.java
index f38e075c2a1..ae11552e0ed 100644
--- a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsCategory.java
+++ b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsCategory.java
@@ -39,10 +39,10 @@ import java.lang.annotation.RetentionPolicy;
*/
public class SiteSettingsCategory {
@IntDef({Type.ALL_SITES, Type.ADS, Type.AUGMENTED_REALITY, Type.AUTOMATIC_DOWNLOADS,
- Type.BACKGROUND_SYNC, Type.BLUETOOTH_SCANNING, Type.CAMERA, Type.CLIPBOARD,
- Type.COOKIES, Type.DEVICE_LOCATION, Type.JAVASCRIPT, Type.MICROPHONE, Type.NFC,
- Type.NOTIFICATIONS, Type.POPUPS, Type.PROTECTED_MEDIA, Type.SENSORS, Type.SOUND,
- Type.USB, Type.VIRTUAL_REALITY, Type.USE_STORAGE})
+ Type.BACKGROUND_SYNC, Type.BLUETOOTH, Type.BLUETOOTH_SCANNING, Type.CAMERA,
+ Type.CLIPBOARD, Type.COOKIES, Type.DEVICE_LOCATION, Type.JAVASCRIPT, Type.MICROPHONE,
+ Type.NFC, Type.NOTIFICATIONS, Type.POPUPS, Type.PROTECTED_MEDIA, Type.SENSORS,
+ Type.SOUND, Type.USB, Type.VIRTUAL_REALITY, Type.USE_STORAGE})
@Retention(RetentionPolicy.SOURCE)
public @interface Type {
// Values used to address array index - should be enumerated from 0 and can't have gaps.
@@ -67,12 +67,13 @@ public class SiteSettingsCategory {
int SENSORS = 16;
int SOUND = 17;
int USB = 18;
- int VIRTUAL_REALITY = 19;
- int USE_STORAGE = 20; // Always last as it should appear in the UI at the bottom.
+ int BLUETOOTH = 19;
+ int VIRTUAL_REALITY = 20;
+ int USE_STORAGE = 21; // Always last as it should appear in the UI at the bottom.
/**
* Number of handled categories used for calculating array sizes.
*/
- int NUM_ENTRIES = 21;
+ int NUM_ENTRIES = 22;
}
private final BrowserContextHandle mBrowserContextHandle;
@@ -156,6 +157,8 @@ public class SiteSettingsCategory {
return ContentSettingsType.AUTOMATIC_DOWNLOADS;
case Type.BACKGROUND_SYNC:
return ContentSettingsType.BACKGROUND_SYNC;
+ case Type.BLUETOOTH:
+ return ContentSettingsType.BLUETOOTH_GUARD;
case Type.BLUETOOTH_SCANNING:
return ContentSettingsType.BLUETOOTH_SCANNING;
case Type.CAMERA:
@@ -201,6 +204,8 @@ public class SiteSettingsCategory {
switch (type) {
case ContentSettingsType.USB_GUARD:
return ContentSettingsType.USB_CHOOSER_DATA;
+ case ContentSettingsType.BLUETOOTH_GUARD:
+ return ContentSettingsType.BLUETOOTH_CHOOSER_DATA;
default:
return -1; // Conversion unavailable.
}
@@ -221,6 +226,8 @@ public class SiteSettingsCategory {
return "automatic_downloads";
case Type.BACKGROUND_SYNC:
return "background_sync";
+ case Type.BLUETOOTH:
+ return "bluetooth";
case Type.BLUETOOTH_SCANNING:
return "bluetooth_scanning";
case Type.CAMERA:
diff --git a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsPrefClient.java b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsPrefClient.java
index ab24de08ddb..605da219084 100644
--- a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsPrefClient.java
+++ b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsPrefClient.java
@@ -12,13 +12,6 @@ package org.chromium.components.browser_ui.site_settings;
*/
// TODO(crbug.com/1071603): Remove this once PrefServiceBridge is componentized.
public interface SiteSettingsPrefClient {
- boolean getBlockThirdPartyCookies();
- void setBlockThirdPartyCookies(boolean newValue);
- boolean isBlockThirdPartyCookiesManaged();
-
- int getCookieControlsMode();
- void setCookieControlsMode(int newValue);
-
boolean getEnableQuietNotificationPermissionUi();
void setEnableQuietNotificationPermissionUi(boolean newValue);
void clearEnableNotificationPermissionUi();
diff --git a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsPreference.java b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsPreference.java
deleted file mode 100644
index 0e642c7943d..00000000000
--- a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsPreference.java
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2016 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.components.browser_ui.site_settings;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.ImageView;
-
-import androidx.core.view.ViewCompat;
-import androidx.preference.PreferenceViewHolder;
-
-import org.chromium.components.browser_ui.settings.ChromeBasePreference;
-
-/**
- * A custom preference for drawing Site Settings entries.
- */
-public class SiteSettingsPreference extends ChromeBasePreference {
- /**
- * Constructor for inflating from XML.
- */
- public SiteSettingsPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- public void onBindViewHolder(PreferenceViewHolder holder) {
- super.onBindViewHolder(holder);
-
- int padding = getContext().getResources().getDimensionPixelSize(R.dimen.pref_icon_padding);
- ImageView icon = (ImageView) holder.findViewById(android.R.id.icon);
- ViewCompat.setPaddingRelative(
- icon, padding, icon.getPaddingTop(), 0, icon.getPaddingBottom());
- }
-}
diff --git a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java
index f6ba7418ff3..bddd75f7b38 100644
--- a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java
+++ b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java
@@ -131,21 +131,37 @@ public class WebsitePermissionsFetcher {
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.CLIPBOARD));
// Sensors permission is per-origin.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.SENSORS));
+
+ // There are two Bluetooth related permissions: Bluetooth scanning and
+ // Bluetooth guard.
+ //
+ // The Bluetooth Scanning permission controls access to the Web Bluetooth
+ // Scanning API, which enables sites to scan for and receive events for
+ // advertisement packets received from nearby Bluetooth devices.
CommandLine commandLine = CommandLine.getInstance();
if (commandLine.hasSwitch(ContentSwitches.ENABLE_EXPERIMENTAL_WEB_PLATFORM_FEATURES)) {
// Bluetooth scanning permission is per-origin.
queue.add(new ExceptionInfoFetcher(ContentSettingsType.BLUETOOTH_SCANNING));
}
+ // The Bluetooth guard permission controls access to the Web Bluetooth
+ // API, which enables sites to request access to connect to specific
+ // Bluetooth devices. Users are presented with a chooser prompt in which
+ // they must select the Bluetooth device that they would like to allow
+ // the site to connect to. Therefore, this permission also displays a
+ // list of permitted Bluetooth devices that each site can connect to.
+ if (ContentFeatureList.isEnabled(
+ ContentFeatureList.WEB_BLUETOOTH_NEW_PERMISSIONS_BACKEND)) {
+ // Bluetooth device permission is per-origin and per-embedder.
+ queue.add(new ChooserExceptionInfoFetcher(ContentSettingsType.BLUETOOTH_GUARD));
+ }
if (ContentFeatureList.isEnabled(ContentFeatureList.WEB_NFC)) {
// NFC permission is per-origin and per-embedder.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.NFC));
}
- if (ContentFeatureList.isEnabled(ContentFeatureList.WEBXR_PERMISSIONS_API)) {
- // VIRTUAL_REALITY permission is per-origin and per-embedder.
- queue.add(new PermissionInfoFetcher(PermissionInfo.Type.VIRTUAL_REALITY));
- // AR permission is per-origin and per-embedder.
- queue.add(new PermissionInfoFetcher(PermissionInfo.Type.AUGMENTED_REALITY));
- }
+ // VIRTUAL_REALITY permission is per-origin and per-embedder.
+ queue.add(new PermissionInfoFetcher(PermissionInfo.Type.VIRTUAL_REALITY));
+ // AR permission is per-origin and per-embedder.
+ queue.add(new PermissionInfoFetcher(PermissionInfo.Type.AUGMENTED_REALITY));
queue.add(new PermissionsAvailableCallbackRunner(callback));
@@ -215,6 +231,9 @@ public class WebsitePermissionsFetcher {
} else if (category.showSites(SiteSettingsCategory.Type.USB)) {
// USB device permission is per-origin.
queue.add(new ChooserExceptionInfoFetcher(ContentSettingsType.USB_GUARD));
+ } else if (category.showSites(SiteSettingsCategory.Type.BLUETOOTH)) {
+ // Bluetooth device permission is per-origin.
+ queue.add(new ChooserExceptionInfoFetcher(ContentSettingsType.BLUETOOTH_GUARD));
} else if (category.showSites(SiteSettingsCategory.Type.CLIPBOARD)) {
// Clipboard permission is per-origin.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.CLIPBOARD));
@@ -233,15 +252,11 @@ public class WebsitePermissionsFetcher {
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.NFC));
}
} else if (category.showSites(SiteSettingsCategory.Type.VIRTUAL_REALITY)) {
- if (ContentFeatureList.isEnabled(ContentFeatureList.WEBXR_PERMISSIONS_API)) {
- // VIRTUAL_REALITY permission is per-origin and per-embedder.
- queue.add(new PermissionInfoFetcher(PermissionInfo.Type.VIRTUAL_REALITY));
- }
+ // VIRTUAL_REALITY permission is per-origin and per-embedder.
+ queue.add(new PermissionInfoFetcher(PermissionInfo.Type.VIRTUAL_REALITY));
} else if (category.showSites(SiteSettingsCategory.Type.AUGMENTED_REALITY)) {
- if (ContentFeatureList.isEnabled(ContentFeatureList.WEBXR_PERMISSIONS_API)) {
- // AUGMENTED_REALITY permission is per-origin and per-embedder.
- queue.add(new PermissionInfoFetcher(PermissionInfo.Type.AUGMENTED_REALITY));
- }
+ // AUGMENTED_REALITY permission is per-origin and per-embedder.
+ queue.add(new PermissionInfoFetcher(PermissionInfo.Type.AUGMENTED_REALITY));
}
queue.add(new PermissionsAvailableCallbackRunner(callback));
queue.next();
diff --git a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreference.java b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreference.java
index a307e6550f1..71b2b84ec8b 100644
--- a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreference.java
+++ b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreference.java
@@ -86,8 +86,18 @@ class WebsitePreference extends ChromeImageViewPreference {
private void refresh() {
setTitle(mSite.getTitle());
- if (mSite.getEmbedder() == null) return;
-
+ if (mSite.getEmbedder() == null) {
+ @PermissionInfo.Type
+ Integer permissionInfoType =
+ PermissionInfo.getPermissionInfoType(mCategory.getContentSettingsType());
+ PermissionInfo permissionInfo = null;
+ if (permissionInfoType != null
+ && (permissionInfo = mSite.getPermissionInfo(permissionInfoType)) != null
+ && permissionInfo.isEmbargoed()) {
+ setSummary(getContext().getString(R.string.automatically_blocked));
+ }
+ return;
+ }
String subtitleText;
if (mSite.representsThirdPartiesOnSite()) {
subtitleText = getContext().getString(
diff --git a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java
index f8c470922aa..b40b44ea050 100644
--- a/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java
+++ b/chromium/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java
@@ -77,7 +77,7 @@ public class WebsitePreferenceBridge {
}
private static void insertInfoIntoList(@PermissionInfo.Type int type,
- ArrayList<PermissionInfo> list, String origin, String embedder) {
+ ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
if (type == PermissionInfo.Type.CAMERA || type == PermissionInfo.Type.MICROPHONE) {
for (PermissionInfo info : list) {
if (info.getOrigin().equals(origin) && info.getEmbedder().equals(embedder)) {
@@ -85,67 +85,69 @@ public class WebsitePreferenceBridge {
}
}
}
- list.add(new PermissionInfo(type, origin, embedder, false));
+ list.add(new PermissionInfo(type, origin, embedder, false, isEmbargoed));
}
@CalledByNative
private static void insertArInfoIntoList(
- ArrayList<PermissionInfo> list, String origin, String embedder) {
- insertInfoIntoList(PermissionInfo.Type.AUGMENTED_REALITY, list, origin, embedder);
+ ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
+ insertInfoIntoList(
+ PermissionInfo.Type.AUGMENTED_REALITY, list, origin, embedder, isEmbargoed);
}
@CalledByNative
private static void insertCameraInfoIntoList(
- ArrayList<PermissionInfo> list, String origin, String embedder) {
- insertInfoIntoList(PermissionInfo.Type.CAMERA, list, origin, embedder);
+ ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
+ insertInfoIntoList(PermissionInfo.Type.CAMERA, list, origin, embedder, isEmbargoed);
}
@CalledByNative
private static void insertClipboardInfoIntoList(
- ArrayList<PermissionInfo> list, String origin, String embedder) {
- insertInfoIntoList(PermissionInfo.Type.CLIPBOARD, list, origin, embedder);
+ ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
+ insertInfoIntoList(PermissionInfo.Type.CLIPBOARD, list, origin, embedder, isEmbargoed);
}
@CalledByNative
private static void insertGeolocationInfoIntoList(
- ArrayList<PermissionInfo> list, String origin, String embedder) {
- insertInfoIntoList(PermissionInfo.Type.GEOLOCATION, list, origin, embedder);
+ ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
+ insertInfoIntoList(PermissionInfo.Type.GEOLOCATION, list, origin, embedder, isEmbargoed);
}
@CalledByNative
private static void insertMicrophoneInfoIntoList(
- ArrayList<PermissionInfo> list, String origin, String embedder) {
- insertInfoIntoList(PermissionInfo.Type.MICROPHONE, list, origin, embedder);
+ ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
+ insertInfoIntoList(PermissionInfo.Type.MICROPHONE, list, origin, embedder, isEmbargoed);
}
@CalledByNative
private static void insertMidiInfoIntoList(
- ArrayList<PermissionInfo> list, String origin, String embedder) {
- insertInfoIntoList(PermissionInfo.Type.MIDI, list, origin, embedder);
+ ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
+ insertInfoIntoList(PermissionInfo.Type.MIDI, list, origin, embedder, isEmbargoed);
}
@CalledByNative
private static void insertNfcInfoIntoList(
- ArrayList<PermissionInfo> list, String origin, String embedder) {
- insertInfoIntoList(PermissionInfo.Type.NFC, list, origin, embedder);
+ ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
+ insertInfoIntoList(PermissionInfo.Type.NFC, list, origin, embedder, isEmbargoed);
}
@CalledByNative
private static void insertNotificationIntoList(
- ArrayList<PermissionInfo> list, String origin, String embedder) {
- insertInfoIntoList(PermissionInfo.Type.NOTIFICATION, list, origin, embedder);
+ ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
+ insertInfoIntoList(PermissionInfo.Type.NOTIFICATION, list, origin, embedder, isEmbargoed);
}
@CalledByNative
private static void insertProtectedMediaIdentifierInfoIntoList(
- ArrayList<PermissionInfo> list, String origin, String embedder) {
- insertInfoIntoList(PermissionInfo.Type.PROTECTED_MEDIA_IDENTIFIER, list, origin, embedder);
+ ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
+ insertInfoIntoList(PermissionInfo.Type.PROTECTED_MEDIA_IDENTIFIER, list, origin, embedder,
+ isEmbargoed);
}
@CalledByNative
private static void insertSensorsInfoIntoList(
- ArrayList<PermissionInfo> list, String origin, String embedder) {
- insertInfoIntoList(PermissionInfo.Type.SENSORS, list, origin, embedder);
+ ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
+ insertInfoIntoList(PermissionInfo.Type.SENSORS, list, origin, embedder, isEmbargoed);
}
@CalledByNative
@@ -156,8 +158,9 @@ public class WebsitePreferenceBridge {
@CalledByNative
private static void insertVrInfoIntoList(
- ArrayList<PermissionInfo> list, String origin, String embedder) {
- insertInfoIntoList(PermissionInfo.Type.VIRTUAL_REALITY, list, origin, embedder);
+ ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
+ insertInfoIntoList(
+ PermissionInfo.Type.VIRTUAL_REALITY, list, origin, embedder, isEmbargoed);
}
@CalledByNative
@@ -354,6 +357,7 @@ public class WebsitePreferenceBridge {
switch (contentSettingsType) {
case ContentSettingsType.ADS:
+ case ContentSettingsType.BLUETOOTH_GUARD:
case ContentSettingsType.BLUETOOTH_SCANNING:
case ContentSettingsType.JAVASCRIPT:
case ContentSettingsType.POPUPS:
@@ -422,6 +426,9 @@ public class WebsitePreferenceBridge {
case ContentSettingsType.POPUPS:
// Returns true if websites are allowed to request permission to access USB devices.
case ContentSettingsType.USB_GUARD:
+ // Returns true if websites are allowed to request permission to access Bluetooth
+ // devices.
+ case ContentSettingsType.BLUETOOTH_GUARD:
case ContentSettingsType.BLUETOOTH_SCANNING:
return isContentSettingEnabled(browserContextHandle, contentSettingsType);
case ContentSettingsType.AR:
diff --git a/chromium/components/browser_ui/site_settings/android/javatests/src/org/chromium/components/browser_ui/site_settings/WebsiteAddressTest.java b/chromium/components/browser_ui/site_settings/android/javatests/src/org/chromium/components/browser_ui/site_settings/WebsiteAddressTest.java
index a799614c5a5..bf9d8e381a7 100644
--- a/chromium/components/browser_ui/site_settings/android/javatests/src/org/chromium/components/browser_ui/site_settings/WebsiteAddressTest.java
+++ b/chromium/components/browser_ui/site_settings/android/javatests/src/org/chromium/components/browser_ui/site_settings/WebsiteAddressTest.java
@@ -4,7 +4,7 @@
package org.chromium.components.browser_ui.site_settings;
-import android.support.test.filters.SmallTest;
+import androidx.test.filters.SmallTest;
import org.junit.Assert;
import org.junit.Before;
diff --git a/chromium/components/browser_ui/site_settings/android/site_settings_feature_list.cc b/chromium/components/browser_ui/site_settings/android/site_settings_feature_list.cc
index ce85744a8b5..70c94e7c417 100644
--- a/chromium/components/browser_ui/site_settings/android/site_settings_feature_list.cc
+++ b/chromium/components/browser_ui/site_settings/android/site_settings_feature_list.cc
@@ -4,6 +4,7 @@
#include "base/android/jni_string.h"
#include "base/feature_list.h"
+#include "base/notreached.h"
#include "base/stl_util.h"
#include "components/browser_ui/site_settings/android/features.h"
diff --git a/chromium/components/browser_ui/site_settings/android/storage_info_fetcher.cc b/chromium/components/browser_ui/site_settings/android/storage_info_fetcher.cc
index f11a27d6198..14ff1dfe39c 100644
--- a/chromium/components/browser_ui/site_settings/android/storage_info_fetcher.cc
+++ b/chromium/components/browser_ui/site_settings/android/storage_info_fetcher.cc
@@ -5,7 +5,6 @@
#include "components/browser_ui/site_settings/android/storage_info_fetcher.h"
#include "base/bind.h"
-#include "base/task/post_task.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
@@ -33,8 +32,8 @@ void StorageInfoFetcher::FetchStorageInfo(FetchCallback fetch_callback) {
// QuotaManager must be called on IO thread, but the callback must then be
// called on the UI thread.
- base::PostTask(
- FROM_HERE, {BrowserThread::IO},
+ content::GetIOThreadTaskRunner({})->PostTask(
+ FROM_HERE,
base::BindOnce(
&StorageInfoFetcher::GetUsageInfo, this,
base::BindOnce(&StorageInfoFetcher::OnGetUsageInfoInternal, this)));
@@ -49,8 +48,8 @@ void StorageInfoFetcher::ClearStorage(const std::string& host,
clear_callback_ = std::move(clear_callback);
type_to_delete_ = type;
- base::PostTask(
- FROM_HERE, {BrowserThread::IO},
+ content::GetIOThreadTaskRunner({})->PostTask(
+ FROM_HERE,
base::BindOnce(
&storage::QuotaManager::DeleteHostData, quota_manager_, host, type,
storage::AllQuotaClientTypes(),
@@ -68,8 +67,8 @@ void StorageInfoFetcher::OnGetUsageInfoInternal(
entries_ = std::move(entries);
- base::PostTask(FROM_HERE, {BrowserThread::UI},
- base::BindOnce(&StorageInfoFetcher::OnFetchCompleted, this));
+ content::GetUIThreadTaskRunner({})->PostTask(
+ FROM_HERE, base::BindOnce(&StorageInfoFetcher::OnFetchCompleted, this));
}
void StorageInfoFetcher::OnFetchCompleted() {
@@ -86,8 +85,8 @@ void StorageInfoFetcher::OnUsageClearedInternal(
quota_manager_->ResetUsageTracker(type_to_delete_);
- base::PostTask(
- FROM_HERE, {BrowserThread::UI},
+ content::GetUIThreadTaskRunner({})->PostTask(
+ FROM_HERE,
base::BindOnce(&StorageInfoFetcher::OnClearCompleted, this, code));
}
diff --git a/chromium/components/browser_ui/site_settings/android/website_preference_bridge.cc b/chromium/components/browser_ui/site_settings/android/website_preference_bridge.cc
index 8f279ee726e..bfc9188b16c 100644
--- a/chromium/components/browser_ui/site_settings/android/website_preference_bridge.cc
+++ b/chromium/components/browser_ui/site_settings/android/website_preference_bridge.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <jni.h>
#include <algorithm>
#include <string>
#include <vector>
@@ -125,7 +126,8 @@ typedef void (*InfoListInsertionFunction)(
JNIEnv*,
const base::android::JavaRef<jobject>&,
const base::android::JavaRef<jstring>&,
- const base::android::JavaRef<jstring>&);
+ const base::android::JavaRef<jstring>&,
+ jboolean);
void GetOrigins(JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle,
@@ -166,7 +168,8 @@ void GetOrigins(JNIEnv* env,
jembedder = ConvertUTF8ToJavaString(env, embedder);
seen_origins.push_back(origin);
- insertionFunc(env, list, ConvertOriginToJavaString(env, origin), jembedder);
+ insertionFunc(env, list, ConvertOriginToJavaString(env, origin), jembedder,
+ /*is_embargoed=*/false);
}
// Add any origins which have a default content setting value (thus skipped
@@ -188,7 +191,7 @@ void GetOrigins(JNIEnv* env,
.content_setting == CONTENT_SETTING_BLOCK) {
seen_origins.push_back(origin);
insertionFunc(env, list, ConvertOriginToJavaString(env, origin),
- jembedder);
+ jembedder, /*is_embargoed=*/true);
}
}
}
@@ -1039,7 +1042,8 @@ static jboolean JNI_WebsitePreferenceBridge_IsContentSettingEnabled(
type == ContentSettingsType::ADS ||
type == ContentSettingsType::CLIPBOARD_READ_WRITE ||
type == ContentSettingsType::USB_GUARD ||
- type == ContentSettingsType::BLUETOOTH_SCANNING);
+ type == ContentSettingsType::BLUETOOTH_SCANNING ||
+ type == ContentSettingsType::BLUETOOTH_GUARD);
return GetBooleanForContentSetting(jbrowser_context_handle, type);
}
@@ -1057,12 +1061,14 @@ static void JNI_WebsitePreferenceBridge_SetContentSettingEnabled(
type == ContentSettingsType::POPUPS ||
type == ContentSettingsType::ADS ||
type == ContentSettingsType::USB_GUARD ||
- type == ContentSettingsType::BLUETOOTH_SCANNING);
+ type == ContentSettingsType::BLUETOOTH_SCANNING ||
+ type == ContentSettingsType::BLUETOOTH_GUARD);
ContentSetting value = CONTENT_SETTING_BLOCK;
if (allow) {
if (type == ContentSettingsType::USB_GUARD ||
- type == ContentSettingsType::BLUETOOTH_SCANNING) {
+ type == ContentSettingsType::BLUETOOTH_SCANNING ||
+ type == ContentSettingsType::BLUETOOTH_GUARD) {
value = CONTENT_SETTING_ASK;
} else {
value = CONTENT_SETTING_ALLOW;