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;
import android.content.Intent;
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.location.LocationUtils;
......@@ -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
// blocks Location by policy (because then turning it on in the system isn't going to
// turn on location in Chrome).
return WebsitePreferenceBridge.isAllowLocationEnabled(getBrowserContextHandle())
|| WebsitePreferenceBridge.isAllowLocationUserModifiable(getBrowserContextHandle());
return WebsitePreferenceBridge.isContentSettingEnabled(
getBrowserContextHandle(), ContentSettingsType.GEOLOCATION)
|| WebsitePreferenceBridge.isContentSettingUserModifiable(
getBrowserContextHandle(), ContentSettingsType.GEOLOCATION);
}
@Override
......
......@@ -993,14 +993,9 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
getSiteSettingsClient().getManagedPreferenceDelegate()));
// Set the checked value.
if (mCategory.showSites(SiteSettingsCategory.Type.DEVICE_LOCATION)) {
binaryToggle.setChecked(
WebsitePreferenceBridge.isAllowLocationEnabled(browserContextHandle));
} else {
binaryToggle.setChecked(
WebsitePreferenceBridge.isCategoryEnabled(browserContextHandle, contentType));
}
}
private void updateNotificationsSecondaryControls() {
BrowserContextHandle browserContextHandle =
......
......@@ -307,24 +307,16 @@ public class SiteSettingsCategory {
* custodian of a supervised account.
*/
public boolean isManaged() {
if (showSites(Type.AUTOMATIC_DOWNLOADS)) {
return WebsitePreferenceBridge.isAutomaticDownloadsManaged(getBrowserContextHandle());
} else if (showSites(Type.BACKGROUND_SYNC)) {
return WebsitePreferenceBridge.isBackgroundSyncManaged(getBrowserContextHandle());
} else if (showSites(Type.COOKIES)) {
return !WebsitePreferenceBridge.isAcceptCookiesUserModifiable(
getBrowserContextHandle());
} else if (showSites(Type.DEVICE_LOCATION)) {
return !WebsitePreferenceBridge.isAllowLocationUserModifiable(
getBrowserContextHandle());
} 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());
// TODO(dullweber): Why do we check some permissions for managed state and some for user
// modifiability and some not at all?
if (showSites(Type.AUTOMATIC_DOWNLOADS) || showSites(Type.BACKGROUND_SYNC)
|| showSites(Type.JAVASCRIPT) || showSites(Type.POPUPS)) {
return WebsitePreferenceBridge.isContentSettingManaged(
getBrowserContextHandle(), getContentSettingsType());
} else if (showSites(Type.COOKIES) || showSites(Type.DEVICE_LOCATION)
|| showSites(Type.CAMERA) || showSites(Type.MICROPHONE)) {
return !WebsitePreferenceBridge.isContentSettingUserModifiable(
getBrowserContextHandle(), getContentSettingsType());
}
return false;
}
......@@ -334,16 +326,11 @@ public class SiteSettingsCategory {
* enterprise admin) of the account if the account is supervised.
*/
public boolean isManagedByCustodian() {
if (showSites(Type.COOKIES)) {
return WebsitePreferenceBridge.isAcceptCookiesManagedByCustodian(
getBrowserContextHandle());
} else if (showSites(Type.DEVICE_LOCATION)) {
return WebsitePreferenceBridge.isAllowLocationManagedByCustodian(
getBrowserContextHandle());
} else if (showSites(Type.CAMERA)) {
return WebsitePreferenceBridge.isCameraManagedByCustodian(getBrowserContextHandle());
} else if (showSites(Type.MICROPHONE)) {
return WebsitePreferenceBridge.isMicManagedByCustodian(getBrowserContextHandle());
// TODO(dullweber): Why do we only check these types?
if (showSites(Type.COOKIES) || showSites(Type.DEVICE_LOCATION) || showSites(Type.CAMERA)
|| showSites(Type.MICROPHONE)) {
return WebsitePreferenceBridge.isContentSettingManagedByCustodian(
getBrowserContextHandle(), getContentSettingsType());
}
return false;
}
......
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