Commit 1a1d5d8e authored by Christian Dullweber's avatar Christian Dullweber Committed by Commit Bot

Remove redundant methods from WebsitePreferenceBridge

There are lots of setting specific methods in WebsitePreferenceBridge
that have no special logic. Merge them into one method.

Change-Id: I402b529b2ac702922e52e9910e4d6f454406627d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2410409
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Reviewed-by: default avatarEhimare Okoyomon <eokoyomon@chromium.org>
Reviewed-by: default avatarKamila Hasanbega <hkamila@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808807}
parent 1cbb2557
...@@ -9,6 +9,7 @@ import android.content.Context; ...@@ -9,6 +9,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import org.chromium.components.content_settings.ContentSettingsType;
import org.chromium.components.embedder_support.browser_context.BrowserContextHandle; import org.chromium.components.embedder_support.browser_context.BrowserContextHandle;
import org.chromium.components.location.LocationUtils; import org.chromium.components.location.LocationUtils;
...@@ -35,8 +36,10 @@ public class LocationCategory extends SiteSettingsCategory { ...@@ -35,8 +36,10 @@ public class LocationCategory extends SiteSettingsCategory {
// The only time we don't want to show location as blocked in system is when Chrome also // The only time we don't want to show location as blocked in system is when Chrome also
// blocks Location by policy (because then turning it on in the system isn't going to // blocks Location by policy (because then turning it on in the system isn't going to
// turn on location in Chrome). // turn on location in Chrome).
return WebsitePreferenceBridge.isAllowLocationEnabled(getBrowserContextHandle()) return WebsitePreferenceBridge.isContentSettingEnabled(
|| WebsitePreferenceBridge.isAllowLocationUserModifiable(getBrowserContextHandle()); getBrowserContextHandle(), ContentSettingsType.GEOLOCATION)
|| WebsitePreferenceBridge.isContentSettingUserModifiable(
getBrowserContextHandle(), ContentSettingsType.GEOLOCATION);
} }
@Override @Override
......
...@@ -993,14 +993,9 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment ...@@ -993,14 +993,9 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
getSiteSettingsClient().getManagedPreferenceDelegate())); getSiteSettingsClient().getManagedPreferenceDelegate()));
// Set the checked value. // Set the checked value.
if (mCategory.showSites(SiteSettingsCategory.Type.DEVICE_LOCATION)) {
binaryToggle.setChecked(
WebsitePreferenceBridge.isAllowLocationEnabled(browserContextHandle));
} else {
binaryToggle.setChecked( binaryToggle.setChecked(
WebsitePreferenceBridge.isCategoryEnabled(browserContextHandle, contentType)); WebsitePreferenceBridge.isCategoryEnabled(browserContextHandle, contentType));
} }
}
private void updateNotificationsSecondaryControls() { private void updateNotificationsSecondaryControls() {
BrowserContextHandle browserContextHandle = BrowserContextHandle browserContextHandle =
......
...@@ -307,24 +307,16 @@ public class SiteSettingsCategory { ...@@ -307,24 +307,16 @@ public class SiteSettingsCategory {
* custodian of a supervised account. * custodian of a supervised account.
*/ */
public boolean isManaged() { public boolean isManaged() {
if (showSites(Type.AUTOMATIC_DOWNLOADS)) { // TODO(dullweber): Why do we check some permissions for managed state and some for user
return WebsitePreferenceBridge.isAutomaticDownloadsManaged(getBrowserContextHandle()); // modifiability and some not at all?
} else if (showSites(Type.BACKGROUND_SYNC)) { if (showSites(Type.AUTOMATIC_DOWNLOADS) || showSites(Type.BACKGROUND_SYNC)
return WebsitePreferenceBridge.isBackgroundSyncManaged(getBrowserContextHandle()); || showSites(Type.JAVASCRIPT) || showSites(Type.POPUPS)) {
} else if (showSites(Type.COOKIES)) { return WebsitePreferenceBridge.isContentSettingManaged(
return !WebsitePreferenceBridge.isAcceptCookiesUserModifiable( getBrowserContextHandle(), getContentSettingsType());
getBrowserContextHandle()); } else if (showSites(Type.COOKIES) || showSites(Type.DEVICE_LOCATION)
} else if (showSites(Type.DEVICE_LOCATION)) { || showSites(Type.CAMERA) || showSites(Type.MICROPHONE)) {
return !WebsitePreferenceBridge.isAllowLocationUserModifiable( return !WebsitePreferenceBridge.isContentSettingUserModifiable(
getBrowserContextHandle()); getBrowserContextHandle(), getContentSettingsType());
} else if (showSites(Type.JAVASCRIPT)) {
return WebsitePreferenceBridge.javaScriptManaged(getBrowserContextHandle());
} else if (showSites(Type.CAMERA)) {
return !WebsitePreferenceBridge.isCameraUserModifiable(getBrowserContextHandle());
} else if (showSites(Type.MICROPHONE)) {
return !WebsitePreferenceBridge.isMicUserModifiable(getBrowserContextHandle());
} else if (showSites(Type.POPUPS)) {
return WebsitePreferenceBridge.isPopupsManaged(getBrowserContextHandle());
} }
return false; return false;
} }
...@@ -334,16 +326,11 @@ public class SiteSettingsCategory { ...@@ -334,16 +326,11 @@ public class SiteSettingsCategory {
* enterprise admin) of the account if the account is supervised. * enterprise admin) of the account if the account is supervised.
*/ */
public boolean isManagedByCustodian() { public boolean isManagedByCustodian() {
if (showSites(Type.COOKIES)) { // TODO(dullweber): Why do we only check these types?
return WebsitePreferenceBridge.isAcceptCookiesManagedByCustodian( if (showSites(Type.COOKIES) || showSites(Type.DEVICE_LOCATION) || showSites(Type.CAMERA)
getBrowserContextHandle()); || showSites(Type.MICROPHONE)) {
} else if (showSites(Type.DEVICE_LOCATION)) { return WebsitePreferenceBridge.isContentSettingManagedByCustodian(
return WebsitePreferenceBridge.isAllowLocationManagedByCustodian( getBrowserContextHandle(), getContentSettingsType());
getBrowserContextHandle());
} else if (showSites(Type.CAMERA)) {
return WebsitePreferenceBridge.isCameraManagedByCustodian(getBrowserContextHandle());
} else if (showSites(Type.MICROPHONE)) {
return WebsitePreferenceBridge.isMicManagedByCustodian(getBrowserContextHandle());
} }
return false; return false;
} }
......
...@@ -41,19 +41,19 @@ public class WebsitePreferenceBridge { ...@@ -41,19 +41,19 @@ public class WebsitePreferenceBridge {
if (type == ContentSettingsType.AR) { if (type == ContentSettingsType.AR) {
WebsitePreferenceBridgeJni.get().getArOrigins(browserContextHandle, list); WebsitePreferenceBridgeJni.get().getArOrigins(browserContextHandle, list);
} else if (type == ContentSettingsType.MEDIASTREAM_CAMERA) { } else if (type == ContentSettingsType.MEDIASTREAM_CAMERA) {
boolean managedOnly = !isCameraUserModifiable(browserContextHandle); boolean managedOnly = !isContentSettingUserModifiable(browserContextHandle, type);
WebsitePreferenceBridgeJni.get().getCameraOrigins( WebsitePreferenceBridgeJni.get().getCameraOrigins(
browserContextHandle, list, managedOnly); browserContextHandle, list, managedOnly);
} else if (type == ContentSettingsType.CLIPBOARD_READ_WRITE) { } else if (type == ContentSettingsType.CLIPBOARD_READ_WRITE) {
WebsitePreferenceBridgeJni.get().getClipboardOrigins(browserContextHandle, list); WebsitePreferenceBridgeJni.get().getClipboardOrigins(browserContextHandle, list);
} else if (type == ContentSettingsType.GEOLOCATION) { } else if (type == ContentSettingsType.GEOLOCATION) {
boolean managedOnly = !isAllowLocationUserModifiable(browserContextHandle); boolean managedOnly = !isContentSettingUserModifiable(browserContextHandle, type);
WebsitePreferenceBridgeJni.get().getGeolocationOrigins( WebsitePreferenceBridgeJni.get().getGeolocationOrigins(
browserContextHandle, list, managedOnly); browserContextHandle, list, managedOnly);
} else if (type == ContentSettingsType.IDLE_DETECTION) { } else if (type == ContentSettingsType.IDLE_DETECTION) {
WebsitePreferenceBridgeJni.get().getIdleDetectionOrigins(browserContextHandle, list); WebsitePreferenceBridgeJni.get().getIdleDetectionOrigins(browserContextHandle, list);
} else if (type == ContentSettingsType.MEDIASTREAM_MIC) { } else if (type == ContentSettingsType.MEDIASTREAM_MIC) {
boolean managedOnly = !isMicUserModifiable(browserContextHandle); boolean managedOnly = !isContentSettingUserModifiable(browserContextHandle, type);
WebsitePreferenceBridgeJni.get().getMicrophoneOrigins( WebsitePreferenceBridgeJni.get().getMicrophoneOrigins(
browserContextHandle, list, managedOnly); browserContextHandle, list, managedOnly);
} else if (type == ContentSettingsType.MIDI_SYSEX) { } else if (type == ContentSettingsType.MIDI_SYSEX) {
...@@ -238,8 +238,8 @@ public class WebsitePreferenceBridge { ...@@ -238,8 +238,8 @@ public class WebsitePreferenceBridge {
*/ */
@CalledByNative @CalledByNative
private static void insertChosenObjectInfoIntoList(ArrayList<ChosenObjectInfo> list, private static void insertChosenObjectInfoIntoList(ArrayList<ChosenObjectInfo> list,
int contentSettingsType, String origin, String embedder, String name, String object, @ContentSettingsType int contentSettingsType, String origin, String embedder,
boolean isManaged) { String name, String object, boolean isManaged) {
list.add(new ChosenObjectInfo( list.add(new ChosenObjectInfo(
contentSettingsType, origin, embedder, name, object, isManaged)); contentSettingsType, origin, embedder, name, object, isManaged));
} }
...@@ -266,8 +266,8 @@ public class WebsitePreferenceBridge { ...@@ -266,8 +266,8 @@ public class WebsitePreferenceBridge {
@CalledByNative @CalledByNative
private static void addContentSettingExceptionToList(ArrayList<ContentSettingException> list, private static void addContentSettingExceptionToList(ArrayList<ContentSettingException> list,
int contentSettingsType, String primaryPattern, String secondaryPattern, @ContentSettingsType int contentSettingsType, String primaryPattern,
int contentSetting, String source) { String secondaryPattern, int contentSetting, String source) {
ContentSettingException exception = new ContentSettingException( ContentSettingException exception = new ContentSettingException(
contentSettingsType, primaryPattern, secondaryPattern, contentSetting, source); contentSettingsType, primaryPattern, secondaryPattern, contentSetting, source);
list.add(exception); list.add(exception);
...@@ -277,8 +277,8 @@ public class WebsitePreferenceBridge { ...@@ -277,8 +277,8 @@ public class WebsitePreferenceBridge {
* Returns whether a particular content setting type is enabled. * Returns whether a particular content setting type is enabled.
* @param contentSettingsType The content setting type to check. * @param contentSettingsType The content setting type to check.
*/ */
public static boolean isContentSettingEnabled( public static boolean isContentSettingEnabled(BrowserContextHandle browserContextHandle,
BrowserContextHandle browserContextHandle, int contentSettingsType) { @ContentSettingsType int contentSettingsType) {
return WebsitePreferenceBridgeJni.get().isContentSettingEnabled( return WebsitePreferenceBridgeJni.get().isContentSettingEnabled(
browserContextHandle, contentSettingsType); browserContextHandle, contentSettingsType);
} }
...@@ -287,56 +287,39 @@ public class WebsitePreferenceBridge { ...@@ -287,56 +287,39 @@ public class WebsitePreferenceBridge {
* @return Whether a particular content setting type is managed by policy. * @return Whether a particular content setting type is managed by policy.
* @param contentSettingsType The content setting type to check. * @param contentSettingsType The content setting type to check.
*/ */
public static boolean isContentSettingManaged( public static boolean isContentSettingManaged(BrowserContextHandle browserContextHandle,
BrowserContextHandle browserContextHandle, int contentSettingsType) { @ContentSettingsType int contentSettingsType) {
return WebsitePreferenceBridgeJni.get().isContentSettingManaged( return WebsitePreferenceBridgeJni.get().isContentSettingManaged(
browserContextHandle, contentSettingsType); browserContextHandle, contentSettingsType);
} }
/** /**
* Sets a default value for content setting type. * @return Whether a particular content setting type is managed by custodian.
* @param contentSettingsType The content setting type to check. * @param contentSettingsType The content setting type to check.
* @param enabled Whether the default value should be disabled or enabled.
*/
public static void setContentSettingEnabled(
BrowserContextHandle browserContextHandle, int contentSettingsType, boolean enabled) {
WebsitePreferenceBridgeJni.get().setContentSettingEnabled(
browserContextHandle, contentSettingsType, enabled);
}
/**
* @return Whether JavaScript is managed by policy.
*/ */
public static boolean javaScriptManaged(BrowserContextHandle browserContextHandle) { public static boolean isContentSettingManagedByCustodian(
return isContentSettingManaged(browserContextHandle, ContentSettingsType.JAVASCRIPT); BrowserContextHandle browserContextHandle,
} @ContentSettingsType int contentSettingsType) {
return WebsitePreferenceBridgeJni.get().isContentSettingManagedByCustodian(
/** browserContextHandle, contentSettingsType);
* @return true if background sync is managed by policy.
*/
public static boolean isBackgroundSyncManaged(BrowserContextHandle browserContextHandle) {
return isContentSettingManaged(browserContextHandle, ContentSettingsType.BACKGROUND_SYNC);
}
/**
* @return true if automatic downloads is managed by policy.
*/
public static boolean isAutomaticDownloadsManaged(BrowserContextHandle browserContextHandle) {
return isContentSettingManaged(
browserContextHandle, ContentSettingsType.AUTOMATIC_DOWNLOADS);
} }
/** /**
* @return Whether the setting to allow popups is configured by policy * Sets a default value for content setting type.
* @param contentSettingsType The content setting type to check.
* @param enabled Whether the default value should be disabled or enabled.
*/ */
public static boolean isPopupsManaged(BrowserContextHandle browserContextHandle) { public static void setContentSettingEnabled(BrowserContextHandle browserContextHandle,
return isContentSettingManaged(browserContextHandle, ContentSettingsType.POPUPS); @ContentSettingsType int contentSettingsType, boolean enabled) {
WebsitePreferenceBridgeJni.get().setContentSettingEnabled(
browserContextHandle, contentSettingsType, enabled);
} }
/** /**
* Whether the setting type requires tri-state (Allowed/Ask/Blocked) setting. * Whether the setting type requires tri-state (Allowed/Ask/Blocked) setting.
*/ */
public static boolean requiresTriStateContentSetting(int contentSettingsType) { public static boolean requiresTriStateContentSetting(
@ContentSettingsType int contentSettingsType) {
switch (contentSettingsType) { switch (contentSettingsType) {
case ContentSettingsType.PROTECTED_MEDIA_IDENTIFIER: case ContentSettingsType.PROTECTED_MEDIA_IDENTIFIER:
return true; return true;
...@@ -349,127 +332,24 @@ public class WebsitePreferenceBridge { ...@@ -349,127 +332,24 @@ public class WebsitePreferenceBridge {
* Whether the setting type requires four-state * Whether the setting type requires four-state
* (Allow/BlockThirdPartyIncognito/BlockThirdParty/Block) setting. * (Allow/BlockThirdPartyIncognito/BlockThirdParty/Block) setting.
*/ */
public static boolean requiresFourStateContentSetting(int contentSettingsType) { public static boolean requiresFourStateContentSetting(
@ContentSettingsType int contentSettingsType) {
return contentSettingsType == ContentSettingsType.COOKIES; return contentSettingsType == ContentSettingsType.COOKIES;
} }
/** /**
* Sets the preferences on whether to enable/disable given setting. * Sets the preferences on whether to enable/disable given setting.
*/ */
public static void setCategoryEnabled( public static void setCategoryEnabled(BrowserContextHandle browserContextHandle,
BrowserContextHandle browserContextHandle, int contentSettingsType, boolean allow) { @ContentSettingsType int contentSettingsType, boolean allow) {
assert !requiresTriStateContentSetting(contentSettingsType); assert !requiresTriStateContentSetting(contentSettingsType);
switch (contentSettingsType) {
case ContentSettingsType.ADS:
case ContentSettingsType.BLUETOOTH_GUARD:
case ContentSettingsType.BLUETOOTH_SCANNING:
case ContentSettingsType.IDLE_DETECTION:
case ContentSettingsType.JAVASCRIPT:
case ContentSettingsType.POPUPS:
case ContentSettingsType.USB_GUARD:
setContentSettingEnabled(browserContextHandle, contentSettingsType, allow); setContentSettingEnabled(browserContextHandle, contentSettingsType, allow);
break;
case ContentSettingsType.AR:
WebsitePreferenceBridgeJni.get().setArEnabled(browserContextHandle, allow);
break;
case ContentSettingsType.AUTOMATIC_DOWNLOADS:
WebsitePreferenceBridgeJni.get().setAutomaticDownloadsEnabled(
browserContextHandle, allow);
break;
case ContentSettingsType.BACKGROUND_SYNC:
WebsitePreferenceBridgeJni.get().setBackgroundSyncEnabled(
browserContextHandle, allow);
break;
case ContentSettingsType.CLIPBOARD_READ_WRITE:
WebsitePreferenceBridgeJni.get().setClipboardEnabled(browserContextHandle, allow);
break;
case ContentSettingsType.COOKIES:
WebsitePreferenceBridgeJni.get().setAllowCookiesEnabled(
browserContextHandle, allow);
break;
case ContentSettingsType.GEOLOCATION:
WebsitePreferenceBridgeJni.get().setAllowLocationEnabled(
browserContextHandle, allow);
break;
case ContentSettingsType.MEDIASTREAM_CAMERA:
WebsitePreferenceBridgeJni.get().setCameraEnabled(browserContextHandle, allow);
break;
case ContentSettingsType.MEDIASTREAM_MIC:
WebsitePreferenceBridgeJni.get().setMicEnabled(browserContextHandle, allow);
break;
case ContentSettingsType.NFC:
WebsitePreferenceBridgeJni.get().setNfcEnabled(browserContextHandle, allow);
break;
case ContentSettingsType.NOTIFICATIONS:
WebsitePreferenceBridgeJni.get().setNotificationsEnabled(
browserContextHandle, allow);
break;
case ContentSettingsType.SENSORS:
WebsitePreferenceBridgeJni.get().setSensorsEnabled(browserContextHandle, allow);
break;
case ContentSettingsType.SOUND:
WebsitePreferenceBridgeJni.get().setSoundEnabled(browserContextHandle, allow);
break;
case ContentSettingsType.VR:
WebsitePreferenceBridgeJni.get().setVrEnabled(browserContextHandle, allow);
break;
default:
assert false;
}
} }
public static boolean isCategoryEnabled( public static boolean isCategoryEnabled(BrowserContextHandle browserContextHandle,
BrowserContextHandle browserContextHandle, int contentSettingsType) { @ContentSettingsType int contentSettingsType) {
assert !requiresTriStateContentSetting(contentSettingsType); assert !requiresTriStateContentSetting(contentSettingsType);
switch (contentSettingsType) {
case ContentSettingsType.ADS:
case ContentSettingsType.CLIPBOARD_READ_WRITE:
// Returns true if websites are allowed to detect when the user is using their
// device.
case ContentSettingsType.IDLE_DETECTION:
// Returns true if JavaScript is enabled. It may return the temporary value set by
// {@link #setJavaScriptEnabled}. The default is true.
case ContentSettingsType.JAVASCRIPT:
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); return isContentSettingEnabled(browserContextHandle, contentSettingsType);
case ContentSettingsType.AR:
return WebsitePreferenceBridgeJni.get().getArEnabled(browserContextHandle);
case ContentSettingsType.AUTOMATIC_DOWNLOADS:
return WebsitePreferenceBridgeJni.get().getAutomaticDownloadsEnabled(
browserContextHandle);
case ContentSettingsType.BACKGROUND_SYNC:
return WebsitePreferenceBridgeJni.get().getBackgroundSyncEnabled(
browserContextHandle);
case ContentSettingsType.COOKIES:
return WebsitePreferenceBridgeJni.get().getAcceptCookiesEnabled(
browserContextHandle);
case ContentSettingsType.MEDIASTREAM_CAMERA:
return WebsitePreferenceBridgeJni.get().getCameraEnabled(browserContextHandle);
case ContentSettingsType.MEDIASTREAM_MIC:
return WebsitePreferenceBridgeJni.get().getMicEnabled(browserContextHandle);
case ContentSettingsType.NFC:
return WebsitePreferenceBridgeJni.get().getNfcEnabled(browserContextHandle);
case ContentSettingsType.NOTIFICATIONS:
return WebsitePreferenceBridgeJni.get().getNotificationsEnabled(
browserContextHandle);
case ContentSettingsType.SENSORS:
return WebsitePreferenceBridgeJni.get().getSensorsEnabled(browserContextHandle);
case ContentSettingsType.SOUND:
return WebsitePreferenceBridgeJni.get().getSoundEnabled(browserContextHandle);
case ContentSettingsType.VR:
return WebsitePreferenceBridgeJni.get().getVrEnabled(browserContextHandle);
default:
assert false;
return false;
}
} }
/** /**
...@@ -479,8 +359,8 @@ public class WebsitePreferenceBridge { ...@@ -479,8 +359,8 @@ public class WebsitePreferenceBridge {
* @param contentSettingsType The settings type to get setting for. * @param contentSettingsType The settings type to get setting for.
* @return The ContentSetting for |contentSettingsType|. * @return The ContentSetting for |contentSettingsType|.
*/ */
public static int getContentSetting( public static int getContentSetting(BrowserContextHandle browserContextHandle,
BrowserContextHandle browserContextHandle, int contentSettingsType) { @ContentSettingsType int contentSettingsType) {
return WebsitePreferenceBridgeJni.get().getContentSetting( return WebsitePreferenceBridgeJni.get().getContentSetting(
browserContextHandle, contentSettingsType); browserContextHandle, contentSettingsType);
} }
...@@ -488,30 +368,12 @@ public class WebsitePreferenceBridge { ...@@ -488,30 +368,12 @@ public class WebsitePreferenceBridge {
/** /**
* @param setting New ContentSetting to set for |contentSettingsType|. * @param setting New ContentSetting to set for |contentSettingsType|.
*/ */
public static void setContentSetting( public static void setContentSetting(BrowserContextHandle browserContextHandle,
BrowserContextHandle browserContextHandle, int contentSettingsType, int setting) { @ContentSettingsType int contentSettingsType, int setting) {
WebsitePreferenceBridgeJni.get().setContentSetting( WebsitePreferenceBridgeJni.get().setContentSetting(
browserContextHandle, contentSettingsType, setting); browserContextHandle, contentSettingsType, setting);
} }
/**
* @return Whether cookies acceptance is modifiable by the user
*/
public static boolean isAcceptCookiesUserModifiable(BrowserContextHandle browserContextHandle) {
return WebsitePreferenceBridgeJni.get().getAcceptCookiesUserModifiable(
browserContextHandle);
}
/**
* @return Whether cookies acceptance is configured by the user's custodian
* (for supervised users).
*/
public static boolean isAcceptCookiesManagedByCustodian(
BrowserContextHandle browserContextHandle) {
return WebsitePreferenceBridgeJni.get().getAcceptCookiesManagedByCustodian(
browserContextHandle);
}
/** /**
* Some Google-affiliated domains are not allowed to delete cookies for supervised accounts. * Some Google-affiliated domains are not allowed to delete cookies for supervised accounts.
* *
...@@ -523,13 +385,6 @@ public class WebsitePreferenceBridge { ...@@ -523,13 +385,6 @@ public class WebsitePreferenceBridge {
browserContextHandle, origin); browserContextHandle, origin);
} }
/**
* @return Whether geolocation information can be shared with content.
*/
public static boolean isAllowLocationEnabled(BrowserContextHandle browserContextHandle) {
return WebsitePreferenceBridgeJni.get().getAllowLocationEnabled(browserContextHandle);
}
/** /**
* @return Whether geolocation information access is set to be shared with all sites, by policy. * @return Whether geolocation information access is set to be shared with all sites, by policy.
*/ */
...@@ -537,60 +392,21 @@ public class WebsitePreferenceBridge { ...@@ -537,60 +392,21 @@ public class WebsitePreferenceBridge {
return WebsitePreferenceBridgeJni.get().getLocationAllowedByPolicy(browserContextHandle); return WebsitePreferenceBridgeJni.get().getLocationAllowedByPolicy(browserContextHandle);
} }
/**
* @return Whether the location preference is modifiable by the user.
*/
public static boolean isAllowLocationUserModifiable(BrowserContextHandle browserContextHandle) {
return WebsitePreferenceBridgeJni.get().getAllowLocationUserModifiable(
browserContextHandle);
}
/**
* @return Whether the location preference is
* being managed by the custodian of the supervised account.
*/
public static boolean isAllowLocationManagedByCustodian(
BrowserContextHandle browserContextHandle) {
return WebsitePreferenceBridgeJni.get().getAllowLocationManagedByCustodian(
browserContextHandle);
}
/** /**
* @return Whether location is enabled system-wide and the Chrome location setting is enabled. * @return Whether location is enabled system-wide and the Chrome location setting is enabled.
*/ */
public static boolean areAllLocationSettingsEnabled(BrowserContextHandle browserContextHandle) { public static boolean areAllLocationSettingsEnabled(BrowserContextHandle browserContextHandle) {
return isAllowLocationEnabled(browserContextHandle) return isContentSettingEnabled(browserContextHandle, ContentSettingsType.GEOLOCATION)
&& LocationUtils.getInstance().isSystemLocationSettingEnabled(); && LocationUtils.getInstance().isSystemLocationSettingEnabled();
} }
/**
* @return Whether the camera/microphone permission is managed
* by the custodian of the supervised account.
*/
public static boolean isCameraManagedByCustodian(BrowserContextHandle browserContextHandle) {
return WebsitePreferenceBridgeJni.get().getCameraManagedByCustodian(browserContextHandle);
}
/** /**
* @return Whether the camera permission is editable by the user. * @return Whether the camera permission is editable by the user.
*/ */
public static boolean isCameraUserModifiable(BrowserContextHandle browserContextHandle) { public static boolean isContentSettingUserModifiable(BrowserContextHandle browserContextHandle,
return WebsitePreferenceBridgeJni.get().getCameraUserModifiable(browserContextHandle); @ContentSettingsType int contentSettingsType) {
} return WebsitePreferenceBridgeJni.get().isContentSettingUserModifiable(
browserContextHandle, contentSettingsType);
/**
* @return Whether the microphone permission is managed by the custodian of
* the supervised account.
*/
public static boolean isMicManagedByCustodian(BrowserContextHandle browserContextHandle) {
return WebsitePreferenceBridgeJni.get().getMicManagedByCustodian(browserContextHandle);
}
/**
* @return Whether the microphone permission is editable by the user.
*/
public static boolean isMicUserModifiable(BrowserContextHandle browserContextHandle) {
return WebsitePreferenceBridgeJni.get().getMicUserModifiable(browserContextHandle);
} }
public static void setContentSettingForPattern(BrowserContextHandle browserContextHandle, public static void setContentSettingForPattern(BrowserContextHandle browserContextHandle,
...@@ -624,7 +440,6 @@ public class WebsitePreferenceBridge { ...@@ -624,7 +440,6 @@ public class WebsitePreferenceBridge {
void getNfcOrigins(BrowserContextHandle browserContextHandle, Object list); void getNfcOrigins(BrowserContextHandle browserContextHandle, Object list);
void getProtectedMediaIdentifierOrigins( void getProtectedMediaIdentifierOrigins(
BrowserContextHandle browserContextHandle, Object list); BrowserContextHandle browserContextHandle, Object list);
boolean getNfcEnabled(BrowserContextHandle browserContextHandle);
void getSensorsOrigins(BrowserContextHandle browserContextHandle, Object list); void getSensorsOrigins(BrowserContextHandle browserContextHandle, Object list);
void getVrOrigins(BrowserContextHandle browserContextHandle, Object list); void getVrOrigins(BrowserContextHandle browserContextHandle, Object list);
int getArSettingForOrigin( int getArSettingForOrigin(
...@@ -706,46 +521,17 @@ public class WebsitePreferenceBridge { ...@@ -706,46 +521,17 @@ public class WebsitePreferenceBridge {
void setContentSettingEnabled( void setContentSettingEnabled(
BrowserContextHandle browserContextHandle, int contentSettingType, boolean allow); BrowserContextHandle browserContextHandle, int contentSettingType, boolean allow);
void getContentSettingsExceptions(BrowserContextHandle browserContextHandle, void getContentSettingsExceptions(BrowserContextHandle browserContextHandle,
int contentSettingsType, List<ContentSettingException> list); @ContentSettingsType int contentSettingsType, List<ContentSettingException> list);
void setContentSettingForPattern(BrowserContextHandle browserContextHandle, void setContentSettingForPattern(BrowserContextHandle browserContextHandle,
int contentSettingType, String primaryPattern, String secondaryPattern, int contentSettingType, String primaryPattern, String secondaryPattern,
int setting); int setting);
int getContentSetting(BrowserContextHandle browserContextHandle, int contentSettingType); int getContentSetting(BrowserContextHandle browserContextHandle, int contentSettingType);
void setContentSetting( void setContentSetting(
BrowserContextHandle browserContextHandle, int contentSettingType, int setting); BrowserContextHandle browserContextHandle, int contentSettingType, int setting);
boolean getAcceptCookiesEnabled(BrowserContextHandle browserContextHandle); boolean isContentSettingUserModifiable(
boolean getAcceptCookiesUserModifiable(BrowserContextHandle browserContextHandle); BrowserContextHandle browserContextHandle, int contentSettingType);
boolean getAcceptCookiesManagedByCustodian(BrowserContextHandle browserContextHandle); boolean isContentSettingManagedByCustodian(
boolean getArEnabled(BrowserContextHandle browserContextHandle); BrowserContextHandle browserContextHandle, int contentSettingType);
boolean getAutomaticDownloadsEnabled(BrowserContextHandle browserContextHandle);
boolean getBackgroundSyncEnabled(BrowserContextHandle browserContextHandle);
boolean getAllowLocationUserModifiable(BrowserContextHandle browserContextHandle);
boolean getLocationAllowedByPolicy(BrowserContextHandle browserContextHandle); boolean getLocationAllowedByPolicy(BrowserContextHandle browserContextHandle);
boolean getAllowLocationManagedByCustodian(BrowserContextHandle browserContextHandle);
boolean getCameraEnabled(BrowserContextHandle browserContextHandle);
void setCameraEnabled(BrowserContextHandle browserContextHandle, boolean enabled);
boolean getCameraUserModifiable(BrowserContextHandle browserContextHandle);
boolean getCameraManagedByCustodian(BrowserContextHandle browserContextHandle);
boolean getMicEnabled(BrowserContextHandle browserContextHandle);
void setMicEnabled(BrowserContextHandle browserContextHandle, boolean enabled);
boolean getMicUserModifiable(BrowserContextHandle browserContextHandle);
boolean getMicManagedByCustodian(BrowserContextHandle browserContextHandle);
boolean getSensorsEnabled(BrowserContextHandle browserContextHandle);
boolean getSoundEnabled(BrowserContextHandle browserContextHandle);
boolean getVrEnabled(BrowserContextHandle browserContextHandle);
void setAutomaticDownloadsEnabled(
BrowserContextHandle browserContextHandle, boolean enabled);
void setAllowCookiesEnabled(BrowserContextHandle browserContextHandle, boolean enabled);
void setArEnabled(BrowserContextHandle browserContextHandle, boolean enabled);
void setBackgroundSyncEnabled(BrowserContextHandle browserContextHandle, boolean enabled);
void setClipboardEnabled(BrowserContextHandle browserContextHandle, boolean enabled);
boolean getAllowLocationEnabled(BrowserContextHandle browserContextHandle);
boolean getNotificationsEnabled(BrowserContextHandle browserContextHandle);
void setAllowLocationEnabled(BrowserContextHandle browserContextHandle, boolean enabled);
void setNotificationsEnabled(BrowserContextHandle browserContextHandle, boolean enabled);
void setNfcEnabled(BrowserContextHandle browserContextHandle, boolean enabled);
void setSensorsEnabled(BrowserContextHandle browserContextHandle, boolean enabled);
void setSoundEnabled(BrowserContextHandle browserContextHandle, boolean enabled);
void setVrEnabled(BrowserContextHandle browserContextHandle, boolean enabled);
} }
} }
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "base/json/json_writer.h" #include "base/json/json_writer.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/metrics/user_metrics.h" #include "base/metrics/user_metrics.h"
#include "base/notreached.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "components/browser_ui/site_settings/android/site_settings_jni_headers/WebsitePreferenceBridge_jni.h" #include "components/browser_ui/site_settings/android/site_settings_jni_headers/WebsitePreferenceBridge_jni.h"
#include "components/browser_ui/site_settings/android/storage_info_fetcher.h" #include "components/browser_ui/site_settings/android/storage_info_fetcher.h"
...@@ -28,6 +29,7 @@ ...@@ -28,6 +29,7 @@
#include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/browser/uma_util.h" #include "components/content_settings/core/browser/uma_util.h"
#include "components/content_settings/core/common/content_settings.h" #include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/embedder_support/android/browser_context/browser_context_handle.h" #include "components/embedder_support/android/browser_context/browser_context_handle.h"
#include "components/permissions/chooser_context_base.h" #include "components/permissions/chooser_context_base.h"
#include "components/permissions/permission_decision_auto_blocker.h" #include "components/permissions/permission_decision_auto_blocker.h"
...@@ -1064,16 +1066,7 @@ static jboolean JNI_WebsitePreferenceBridge_IsContentSettingEnabled( ...@@ -1064,16 +1066,7 @@ static jboolean JNI_WebsitePreferenceBridge_IsContentSettingEnabled(
int content_settings_type) { int content_settings_type) {
ContentSettingsType type = ContentSettingsType type =
static_cast<ContentSettingsType>(content_settings_type); static_cast<ContentSettingsType>(content_settings_type);
// Before we migrate functions over to this central function, we must verify
// that the functionality provided below is correct.
DCHECK(type == ContentSettingsType::JAVASCRIPT ||
type == ContentSettingsType::POPUPS ||
type == ContentSettingsType::ADS ||
type == ContentSettingsType::CLIPBOARD_READ_WRITE ||
type == ContentSettingsType::USB_GUARD ||
type == ContentSettingsType::IDLE_DETECTION ||
type == ContentSettingsType::BLUETOOTH_SCANNING ||
type == ContentSettingsType::BLUETOOTH_GUARD);
return GetBooleanForContentSetting(jbrowser_context_handle, type); return GetBooleanForContentSetting(jbrowser_context_handle, type);
} }
...@@ -1085,24 +1078,45 @@ static void JNI_WebsitePreferenceBridge_SetContentSettingEnabled( ...@@ -1085,24 +1078,45 @@ static void JNI_WebsitePreferenceBridge_SetContentSettingEnabled(
ContentSettingsType type = ContentSettingsType type =
static_cast<ContentSettingsType>(content_settings_type); static_cast<ContentSettingsType>(content_settings_type);
// Before we migrate functions over to this central function, we must verify if (type == ContentSettingsType::SOUND) {
// that the new category supports ALLOW/BLOCK pairs and, if not, handle them. if (allow) {
DCHECK(type == ContentSettingsType::JAVASCRIPT || base::RecordAction(base::UserMetricsAction(
type == ContentSettingsType::POPUPS || "SoundContentSetting.UnmuteBy.DefaultSwitch"));
type == ContentSettingsType::ADS || } else {
type == ContentSettingsType::USB_GUARD || base::RecordAction(
type == ContentSettingsType::IDLE_DETECTION || base::UserMetricsAction("SoundContentSetting.MuteBy.DefaultSwitch"));
type == ContentSettingsType::BLUETOOTH_SCANNING || }
type == ContentSettingsType::BLUETOOTH_GUARD); }
ContentSetting value = CONTENT_SETTING_BLOCK; ContentSetting value = CONTENT_SETTING_BLOCK;
if (allow) { if (allow) {
if (type == ContentSettingsType::USB_GUARD || switch (type) {
type == ContentSettingsType::BLUETOOTH_SCANNING || case ContentSettingsType::AR:
type == ContentSettingsType::BLUETOOTH_GUARD) { case ContentSettingsType::AUTOMATIC_DOWNLOADS:
case ContentSettingsType::BLUETOOTH_GUARD:
case ContentSettingsType::BLUETOOTH_SCANNING:
case ContentSettingsType::CLIPBOARD_READ_WRITE:
case ContentSettingsType::GEOLOCATION:
case ContentSettingsType::IDLE_DETECTION:
case ContentSettingsType::MEDIASTREAM_CAMERA:
case ContentSettingsType::MEDIASTREAM_MIC:
case ContentSettingsType::NFC:
case ContentSettingsType::NOTIFICATIONS:
case ContentSettingsType::USB_GUARD:
case ContentSettingsType::VR:
value = CONTENT_SETTING_ASK; value = CONTENT_SETTING_ASK;
} else { break;
case ContentSettingsType::ADS:
case ContentSettingsType::BACKGROUND_SYNC:
case ContentSettingsType::COOKIES:
case ContentSettingsType::JAVASCRIPT:
case ContentSettingsType::POPUPS:
case ContentSettingsType::SENSORS:
case ContentSettingsType::SOUND:
value = CONTENT_SETTING_ALLOW; value = CONTENT_SETTING_ALLOW;
break;
default:
NOTREACHED() << static_cast<int>(type); // Not supported on Android.
} }
} }
...@@ -1171,88 +1185,22 @@ static void JNI_WebsitePreferenceBridge_SetContentSetting( ...@@ -1171,88 +1185,22 @@ static void JNI_WebsitePreferenceBridge_SetContentSetting(
static_cast<ContentSetting>(setting)); static_cast<ContentSetting>(setting));
} }
static jboolean JNI_WebsitePreferenceBridge_GetArEnabled( static jboolean JNI_WebsitePreferenceBridge_IsContentSettingUserModifiable(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle) {
return GetBooleanForContentSetting(jbrowser_context_handle,
ContentSettingsType::AR);
}
static jboolean JNI_WebsitePreferenceBridge_GetVrEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle) {
return GetBooleanForContentSetting(jbrowser_context_handle,
ContentSettingsType::VR);
}
static jboolean JNI_WebsitePreferenceBridge_GetAcceptCookiesEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle) {
return GetBooleanForContentSetting(jbrowser_context_handle,
ContentSettingsType::COOKIES);
}
static jboolean JNI_WebsitePreferenceBridge_GetAcceptCookiesUserModifiable(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle) {
return IsContentSettingUserModifiable(jbrowser_context_handle,
ContentSettingsType::COOKIES);
}
static jboolean JNI_WebsitePreferenceBridge_GetAcceptCookiesManagedByCustodian(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle) {
return IsContentSettingManagedByCustodian(jbrowser_context_handle,
ContentSettingsType::COOKIES);
}
static jboolean JNI_WebsitePreferenceBridge_GetNfcEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle) {
return GetBooleanForContentSetting(jbrowser_context_handle,
ContentSettingsType::NFC);
}
static jboolean JNI_WebsitePreferenceBridge_GetSensorsEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle) {
return GetBooleanForContentSetting(jbrowser_context_handle,
ContentSettingsType::SENSORS);
}
static jboolean JNI_WebsitePreferenceBridge_GetSoundEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle) {
return GetBooleanForContentSetting(jbrowser_context_handle,
ContentSettingsType::SOUND);
}
static jboolean JNI_WebsitePreferenceBridge_GetBackgroundSyncEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle) {
return GetBooleanForContentSetting(jbrowser_context_handle,
ContentSettingsType::BACKGROUND_SYNC);
}
static jboolean JNI_WebsitePreferenceBridge_GetAutomaticDownloadsEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle) {
return GetBooleanForContentSetting(jbrowser_context_handle,
ContentSettingsType::AUTOMATIC_DOWNLOADS);
}
static jboolean JNI_WebsitePreferenceBridge_GetNotificationsEnabled(
JNIEnv* env, JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle) { const JavaParamRef<jobject>& jbrowser_context_handle,
return GetBooleanForContentSetting(jbrowser_context_handle, int content_settings_type) {
ContentSettingsType::NOTIFICATIONS); return IsContentSettingUserModifiable(
jbrowser_context_handle,
static_cast<ContentSettingsType>(content_settings_type));
} }
static jboolean JNI_WebsitePreferenceBridge_GetAllowLocationEnabled( static jboolean JNI_WebsitePreferenceBridge_IsContentSettingManagedByCustodian(
JNIEnv* env, JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle) { const JavaParamRef<jobject>& jbrowser_context_handle,
return GetBooleanForContentSetting(jbrowser_context_handle, int content_settings_type) {
ContentSettingsType::GEOLOCATION); return IsContentSettingManagedByCustodian(
jbrowser_context_handle,
static_cast<ContentSettingsType>(content_settings_type));
} }
static jboolean JNI_WebsitePreferenceBridge_GetLocationAllowedByPolicy( static jboolean JNI_WebsitePreferenceBridge_GetLocationAllowedByPolicy(
...@@ -1266,196 +1214,3 @@ static jboolean JNI_WebsitePreferenceBridge_GetLocationAllowedByPolicy( ...@@ -1266,196 +1214,3 @@ static jboolean JNI_WebsitePreferenceBridge_GetLocationAllowedByPolicy(
nullptr) == CONTENT_SETTING_ALLOW; nullptr) == CONTENT_SETTING_ALLOW;
} }
static jboolean JNI_WebsitePreferenceBridge_GetAllowLocationUserModifiable(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle) {
return IsContentSettingUserModifiable(jbrowser_context_handle,
ContentSettingsType::GEOLOCATION);
}
static jboolean JNI_WebsitePreferenceBridge_GetAllowLocationManagedByCustodian(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle) {
return IsContentSettingManagedByCustodian(jbrowser_context_handle,
ContentSettingsType::GEOLOCATION);
}
static void JNI_WebsitePreferenceBridge_SetArEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle,
jboolean allow) {
GetHostContentSettingsMap(jbrowser_context_handle)
->SetDefaultContentSetting(
ContentSettingsType::AR,
allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK);
}
static void JNI_WebsitePreferenceBridge_SetClipboardEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle,
jboolean allow) {
GetHostContentSettingsMap(jbrowser_context_handle)
->SetDefaultContentSetting(
ContentSettingsType::CLIPBOARD_READ_WRITE,
allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK);
}
static void JNI_WebsitePreferenceBridge_SetNfcEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle,
jboolean allow) {
GetHostContentSettingsMap(jbrowser_context_handle)
->SetDefaultContentSetting(
ContentSettingsType::NFC,
allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK);
}
static void JNI_WebsitePreferenceBridge_SetVrEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle,
jboolean allow) {
GetHostContentSettingsMap(jbrowser_context_handle)
->SetDefaultContentSetting(
ContentSettingsType::VR,
allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK);
}
static void JNI_WebsitePreferenceBridge_SetSensorsEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle,
jboolean allow) {
GetHostContentSettingsMap(jbrowser_context_handle)
->SetDefaultContentSetting(
ContentSettingsType::SENSORS,
allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK);
}
static void JNI_WebsitePreferenceBridge_SetSoundEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle,
jboolean allow) {
GetHostContentSettingsMap(jbrowser_context_handle)
->SetDefaultContentSetting(
ContentSettingsType::SOUND,
allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK);
if (allow) {
base::RecordAction(
base::UserMetricsAction("SoundContentSetting.UnmuteBy.DefaultSwitch"));
} else {
base::RecordAction(
base::UserMetricsAction("SoundContentSetting.MuteBy.DefaultSwitch"));
}
}
static void JNI_WebsitePreferenceBridge_SetAllowCookiesEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle,
jboolean allow) {
GetHostContentSettingsMap(jbrowser_context_handle)
->SetDefaultContentSetting(
ContentSettingsType::COOKIES,
allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK);
}
static void JNI_WebsitePreferenceBridge_SetBackgroundSyncEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle,
jboolean allow) {
GetHostContentSettingsMap(jbrowser_context_handle)
->SetDefaultContentSetting(
ContentSettingsType::BACKGROUND_SYNC,
allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK);
}
static void JNI_WebsitePreferenceBridge_SetAutomaticDownloadsEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle,
jboolean allow) {
GetHostContentSettingsMap(jbrowser_context_handle)
->SetDefaultContentSetting(
ContentSettingsType::AUTOMATIC_DOWNLOADS,
allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK);
}
static void JNI_WebsitePreferenceBridge_SetAllowLocationEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle,
jboolean is_enabled) {
GetHostContentSettingsMap(jbrowser_context_handle)
->SetDefaultContentSetting(
ContentSettingsType::GEOLOCATION,
is_enabled ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK);
}
static void JNI_WebsitePreferenceBridge_SetCameraEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle,
jboolean allow) {
GetHostContentSettingsMap(jbrowser_context_handle)
->SetDefaultContentSetting(
ContentSettingsType::MEDIASTREAM_CAMERA,
allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK);
}
static void JNI_WebsitePreferenceBridge_SetMicEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle,
jboolean allow) {
GetHostContentSettingsMap(jbrowser_context_handle)
->SetDefaultContentSetting(
ContentSettingsType::MEDIASTREAM_MIC,
allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK);
}
static void JNI_WebsitePreferenceBridge_SetNotificationsEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle,
jboolean allow) {
GetHostContentSettingsMap(jbrowser_context_handle)
->SetDefaultContentSetting(
ContentSettingsType::NOTIFICATIONS,
allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK);
}
static jboolean JNI_WebsitePreferenceBridge_GetCameraEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle) {
return GetBooleanForContentSetting(jbrowser_context_handle,
ContentSettingsType::MEDIASTREAM_CAMERA);
}
static jboolean JNI_WebsitePreferenceBridge_GetCameraUserModifiable(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle) {
return IsContentSettingUserModifiable(
jbrowser_context_handle, ContentSettingsType::MEDIASTREAM_CAMERA);
}
static jboolean JNI_WebsitePreferenceBridge_GetCameraManagedByCustodian(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle) {
return IsContentSettingManagedByCustodian(
jbrowser_context_handle, ContentSettingsType::MEDIASTREAM_CAMERA);
}
static jboolean JNI_WebsitePreferenceBridge_GetMicEnabled(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle) {
return GetBooleanForContentSetting(jbrowser_context_handle,
ContentSettingsType::MEDIASTREAM_MIC);
}
static jboolean JNI_WebsitePreferenceBridge_GetMicUserModifiable(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle) {
return IsContentSettingUserModifiable(jbrowser_context_handle,
ContentSettingsType::MEDIASTREAM_MIC);
}
static jboolean JNI_WebsitePreferenceBridge_GetMicManagedByCustodian(
JNIEnv* env,
const JavaParamRef<jobject>& jbrowser_context_handle) {
return IsContentSettingManagedByCustodian(
jbrowser_context_handle, ContentSettingsType::MEDIASTREAM_MIC);
}
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