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,13 +993,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment ...@@ -993,13 +993,8 @@ 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(
binaryToggle.setChecked( WebsitePreferenceBridge.isCategoryEnabled(browserContextHandle, contentType));
WebsitePreferenceBridge.isAllowLocationEnabled(browserContextHandle));
} else {
binaryToggle.setChecked(
WebsitePreferenceBridge.isCategoryEnabled(browserContextHandle, contentType));
}
} }
private void updateNotificationsSecondaryControls() { private void updateNotificationsSecondaryControls() {
......
...@@ -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;
} }
......
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