Commit 0b108ac1 authored by Christian Dullweber's avatar Christian Dullweber Committed by Commit Bot

Remove ContentSettingExceptionType enum

This enum contains a subset of the values of ContentSettingsType.
As WebsitePermissionFetcher defines which ContentSettingsType are
fetched as ContentSettingsException and which as PermissionInfo, we do
not need this duplicate and the code to convert between types.

Bug: 1103597
Change-Id: I17667e76c5091ed6417795cdba807c78b35a85a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2346425Reviewed-by: default avatarEhimare Okoyomon <eokoyomon@chromium.org>
Reviewed-by: default avatarAndy Paicu <andypaicu@chromium.org>
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798580}
parent 2ecce21d
...@@ -536,20 +536,19 @@ public class WebsitePermissionsFetcherTest { ...@@ -536,20 +536,19 @@ public class WebsitePermissionsFetcherTest {
// Check content setting exception types. // Check content setting exception types.
Assert.assertEquals(Integer.valueOf(ContentSettingValues.DEFAULT), Assert.assertEquals(Integer.valueOf(ContentSettingValues.DEFAULT),
site.getContentSettingPermission(ContentSettingException.Type.COOKIE)); site.getContentSettingPermission(ContentSettingsType.COOKIES));
Assert.assertEquals(Integer.valueOf(ContentSettingValues.DEFAULT), Assert.assertEquals(Integer.valueOf(ContentSettingValues.DEFAULT),
site.getContentSettingPermission(ContentSettingException.Type.POPUP)); site.getContentSettingPermission(ContentSettingsType.POPUPS));
Assert.assertEquals(Integer.valueOf(ContentSettingValues.DEFAULT), Assert.assertEquals(Integer.valueOf(ContentSettingValues.DEFAULT),
site.getContentSettingPermission(ContentSettingException.Type.ADS)); site.getContentSettingPermission(ContentSettingsType.ADS));
Assert.assertEquals(Integer.valueOf(ContentSettingValues.DEFAULT), Assert.assertEquals(Integer.valueOf(ContentSettingValues.DEFAULT),
site.getContentSettingPermission(ContentSettingException.Type.JAVASCRIPT)); site.getContentSettingPermission(ContentSettingsType.JAVASCRIPT));
Assert.assertEquals(Integer.valueOf(ContentSettingValues.DEFAULT), Assert.assertEquals(Integer.valueOf(ContentSettingValues.DEFAULT),
site.getContentSettingPermission(ContentSettingException.Type.SOUND)); site.getContentSettingPermission(ContentSettingsType.SOUND));
Assert.assertEquals(Integer.valueOf(ContentSettingValues.DEFAULT), Assert.assertEquals(Integer.valueOf(ContentSettingValues.DEFAULT),
site.getContentSettingPermission(ContentSettingException.Type.BACKGROUND_SYNC)); site.getContentSettingPermission(ContentSettingsType.BACKGROUND_SYNC));
Assert.assertEquals(Integer.valueOf(ContentSettingValues.DEFAULT), Assert.assertEquals(Integer.valueOf(ContentSettingValues.DEFAULT),
site.getContentSettingPermission( site.getContentSettingPermission(ContentSettingsType.AUTOMATIC_DOWNLOADS));
ContentSettingException.Type.AUTOMATIC_DOWNLOADS));
// Check storage info. // Check storage info.
ArrayList<StorageInfo> storageInfos = new ArrayList<>(site.getStorageInfo()); ArrayList<StorageInfo> storageInfos = new ArrayList<>(site.getStorageInfo());
...@@ -705,26 +704,21 @@ public class WebsitePermissionsFetcherTest { ...@@ -705,26 +704,21 @@ public class WebsitePermissionsFetcherTest {
String googleOrigin = "https://google.com"; String googleOrigin = "https://google.com";
String preferenceSource = "preference"; String preferenceSource = "preference";
ArrayList<Integer> contentSettingExceptionTypes = new ArrayList<>(Arrays.asList( ArrayList<Integer> contentSettingExceptionTypes = new ArrayList<>(
ContentSettingException.Type.ADS, ContentSettingException.Type.AUTOMATIC_DOWNLOADS, Arrays.asList(ContentSettingsType.ADS, ContentSettingsType.AUTOMATIC_DOWNLOADS,
ContentSettingException.Type.BACKGROUND_SYNC, ContentSettingsType.BACKGROUND_SYNC, ContentSettingsType.BLUETOOTH_SCANNING,
ContentSettingException.Type.BLUETOOTH_SCANNING, ContentSettingsType.COOKIES, ContentSettingsType.JAVASCRIPT,
ContentSettingException.Type.COOKIE, ContentSettingException.Type.JAVASCRIPT, ContentSettingsType.POPUPS, ContentSettingsType.SOUND));
ContentSettingException.Type.POPUP, ContentSettingException.Type.SOUND));
Assert.assertEquals(8, ContentSettingException.Type.NUM_ENTRIES);
for (@ContentSettingsType int type : contentSettingExceptionTypes) { for (@ContentSettingsType int type : contentSettingExceptionTypes) {
@ContentSettingsType
int contentSettingsType = ContentSettingException.getContentSettingsType(type);
{ {
ContentSettingException fakeContentSettingException = ContentSettingException fakeContentSettingException = new ContentSettingException(
new ContentSettingException(contentSettingsType, googleOrigin, type, googleOrigin, ContentSettingValues.DEFAULT, preferenceSource);
ContentSettingValues.DEFAULT, preferenceSource);
websitePreferenceBridge.addContentSettingException(fakeContentSettingException); websitePreferenceBridge.addContentSettingException(fakeContentSettingException);
fetcher.fetchPreferencesForCategory( fetcher.fetchPreferencesForCategory(
SiteSettingsCategory.createFromContentSettingsType( SiteSettingsCategory.createFromContentSettingsType(
UNUSED_BROWSER_CONTEXT_HANDLE, contentSettingsType), UNUSED_BROWSER_CONTEXT_HANDLE, type),
(sites) -> { (sites) -> {
Assert.assertEquals(1, sites.size()); Assert.assertEquals(1, sites.size());
...@@ -736,14 +730,13 @@ public class WebsitePermissionsFetcherTest { ...@@ -736,14 +730,13 @@ public class WebsitePermissionsFetcherTest {
// Make sure that the content setting value is updated. // Make sure that the content setting value is updated.
{ {
ContentSettingException fakeContentSettingException = ContentSettingException fakeContentSettingException = new ContentSettingException(
new ContentSettingException(contentSettingsType, googleOrigin, type, googleOrigin, ContentSettingValues.BLOCK, preferenceSource);
ContentSettingValues.BLOCK, preferenceSource);
websitePreferenceBridge.addContentSettingException(fakeContentSettingException); websitePreferenceBridge.addContentSettingException(fakeContentSettingException);
fetcher.fetchPreferencesForCategory( fetcher.fetchPreferencesForCategory(
SiteSettingsCategory.createFromContentSettingsType( SiteSettingsCategory.createFromContentSettingsType(
UNUSED_BROWSER_CONTEXT_HANDLE, contentSettingsType), UNUSED_BROWSER_CONTEXT_HANDLE, type),
(sites) -> { (sites) -> {
Assert.assertEquals(1, sites.size()); Assert.assertEquals(1, sites.size());
...@@ -766,11 +759,8 @@ public class WebsitePermissionsFetcherTest { ...@@ -766,11 +759,8 @@ public class WebsitePermissionsFetcherTest {
String mainSite = "https://a.com"; String mainSite = "https://a.com";
String thirdPartySite = "https://b.com"; String thirdPartySite = "https://b.com";
String preferenceSource = "preference"; String preferenceSource = "preference";
@ContentSettingException.Type
int contentSettingExceptionType = ContentSettingException.Type.COOKIE;
@ContentSettingsType @ContentSettingsType
int contentSettingsType = int contentSettingsType = ContentSettingsType.COOKIES;
ContentSettingException.getContentSettingsType(contentSettingExceptionType);
// Test the advanced exception combinations of: // Test the advanced exception combinations of:
// b.com on a.com // b.com on a.com
...@@ -797,7 +787,7 @@ public class WebsitePermissionsFetcherTest { ...@@ -797,7 +787,7 @@ public class WebsitePermissionsFetcherTest {
Website site = sites.iterator().next(); Website site = sites.iterator().next();
assertContentSettingExceptionEquals(fakeContentSettingException, assertContentSettingExceptionEquals(fakeContentSettingException,
site.getContentSettingException(contentSettingExceptionType)); site.getContentSettingException(contentSettingsType));
}); });
} }
...@@ -816,7 +806,7 @@ public class WebsitePermissionsFetcherTest { ...@@ -816,7 +806,7 @@ public class WebsitePermissionsFetcherTest {
Website site = sites.iterator().next(); Website site = sites.iterator().next();
assertContentSettingExceptionEquals(fakeContentSettingException, assertContentSettingExceptionEquals(fakeContentSettingException,
site.getContentSettingException(contentSettingExceptionType)); site.getContentSettingException(contentSettingsType));
}); });
} }
} }
......
...@@ -73,8 +73,9 @@ public class SingleWebsiteSettingsTest { ...@@ -73,8 +73,9 @@ public class SingleWebsiteSettingsTest {
@Test @Test
@SmallTest @SmallTest
public void testCorrectMapOfPreferenceKeyToContentSettingsType() { public void testCorrectMapOfPreferenceKeyToContentSettingsType() {
SingleWebsiteSettings settings = new SingleWebsiteSettings();
for (String key : SingleWebsiteSettings.PERMISSION_PREFERENCE_KEYS) { for (String key : SingleWebsiteSettings.PERMISSION_PREFERENCE_KEYS) {
Assert.assertEquals(SingleWebsiteSettings.getContentSettingsTypeFromPreferenceKey(key), Assert.assertEquals(settings.getContentSettingsTypeFromPreferenceKey(key),
getCorrectContentSettingsTypeForPreferenceKey(key)); getCorrectContentSettingsTypeForPreferenceKey(key));
} }
} }
......
...@@ -6,42 +6,17 @@ package org.chromium.components.browser_ui.site_settings; ...@@ -6,42 +6,17 @@ package org.chromium.components.browser_ui.site_settings;
import static org.chromium.components.browser_ui.site_settings.WebsitePreferenceBridge.SITE_WILDCARD; import static org.chromium.components.browser_ui.site_settings.WebsitePreferenceBridge.SITE_WILDCARD;
import androidx.annotation.IntDef;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import org.chromium.components.content_settings.ContentSettingValues; import org.chromium.components.content_settings.ContentSettingValues;
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 java.io.Serializable; import java.io.Serializable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/** /**
* Exception information for a given origin. * Exception information for a given origin.
*/ */
public class ContentSettingException implements Serializable { public class ContentSettingException implements Serializable {
@IntDef({Type.ADS, Type.AUTOMATIC_DOWNLOADS, Type.BACKGROUND_SYNC, Type.BLUETOOTH_SCANNING,
Type.COOKIE, Type.JAVASCRIPT, Type.POPUP, Type.SOUND})
@Retention(RetentionPolicy.SOURCE)
public @interface Type {
// Values used to address array index - should be enumerated from 0 and can't have gaps.
// All updates here must also be reflected in {@link #getContentSettingsType(int)
// getContentSettingsType} and {@link SingleWebsiteSettings.PERMISSION_PREFERENCE_KEYS}.
int ADS = 0;
int AUTOMATIC_DOWNLOADS = 1;
int BACKGROUND_SYNC = 2;
int BLUETOOTH_SCANNING = 3;
int COOKIE = 4;
int JAVASCRIPT = 5;
int POPUP = 6;
int SOUND = 7;
/**
* Number of handled exceptions used for calculating array sizes.
*/
int NUM_ENTRIES = 8;
}
private final int mContentSettingType; private final int mContentSettingType;
private final String mPrimaryPattern; private final String mPrimaryPattern;
private final String mSecondaryPattern; private final String mSecondaryPattern;
...@@ -97,33 +72,9 @@ public class ContentSettingException implements Serializable { ...@@ -97,33 +72,9 @@ public class ContentSettingException implements Serializable {
/** /**
* Sets the content setting value for this exception. * Sets the content setting value for this exception.
*/ */
public void setContentSetting(BrowserContextHandle browserContextHandle, public void setContentSetting(
@ContentSettingValues @Nullable Integer value) { BrowserContextHandle browserContextHandle, @ContentSettingValues int value) {
WebsitePreferenceBridge.setContentSettingForPattern(browserContextHandle, WebsitePreferenceBridge.setContentSettingForPattern(browserContextHandle,
mContentSettingType, mPrimaryPattern, mSecondaryPattern, value); mContentSettingType, mPrimaryPattern, mSecondaryPattern, value);
} }
public static @ContentSettingsType int getContentSettingsType(@Type int type) {
switch (type) {
case Type.ADS:
return ContentSettingsType.ADS;
case Type.AUTOMATIC_DOWNLOADS:
return ContentSettingsType.AUTOMATIC_DOWNLOADS;
case Type.BACKGROUND_SYNC:
return ContentSettingsType.BACKGROUND_SYNC;
case Type.BLUETOOTH_SCANNING:
return ContentSettingsType.BLUETOOTH_SCANNING;
case Type.COOKIE:
return ContentSettingsType.COOKIES;
case Type.JAVASCRIPT:
return ContentSettingsType.JAVASCRIPT;
case Type.POPUP:
return ContentSettingsType.POPUPS;
case Type.SOUND:
return ContentSettingsType.SOUND;
default:
assert false;
return ContentSettingsType.DEFAULT;
}
}
} }
...@@ -210,13 +210,11 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment ...@@ -210,13 +210,11 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
getSiteSettingsClient().getBrowserContextHandle(); getSiteSettingsClient().getBrowserContextHandle();
for (@SiteSettingsCategory.Type int i = 0; i < SiteSettingsCategory.Type.NUM_ENTRIES; i++) { for (@SiteSettingsCategory.Type int i = 0; i < SiteSettingsCategory.Type.NUM_ENTRIES; i++) {
if (!mCategory.showSites(i)) continue; if (!mCategory.showSites(i)) continue;
for (@ContentSettingException.Type int j = 0; @ContentSettingValues
j < ContentSettingException.Type.NUM_ENTRIES; j++) { Integer contentSettingPermission = website.site().getContentSettingPermission(
if (ContentSettingException.getContentSettingsType(j) SiteSettingsCategory.contentSettingsType(i));
== SiteSettingsCategory.contentSettingsType(i)) { if (contentSettingPermission != null) {
return ContentSettingValues.BLOCK return ContentSettingValues.BLOCK == contentSettingPermission;
== website.site().getContentSettingPermission(j);
}
} }
for (@PermissionInfo.Type int j = 0; j < PermissionInfo.Type.NUM_ENTRIES; j++) { for (@PermissionInfo.Type int j = 0; j < PermissionInfo.Type.NUM_ENTRIES; j++) {
if (PermissionInfo.getContentSettingsType(j) if (PermissionInfo.getContentSettingsType(j)
......
...@@ -24,10 +24,9 @@ public class SiteDataCleaner { ...@@ -24,10 +24,9 @@ public class SiteDataCleaner {
WebsitePreferenceBridgeJni.get().clearMediaLicenses(browserContextHandle, origin); WebsitePreferenceBridgeJni.get().clearMediaLicenses(browserContextHandle, origin);
// Clear the permissions. // Clear the permissions.
for (@ContentSettingException.Type int type = 0; for (ContentSettingException exception : site.getContentSettingExceptions()) {
type < ContentSettingException.Type.NUM_ENTRIES; type++) { site.setContentSettingPermission(browserContextHandle,
site.setContentSettingPermission( exception.getContentSettingType(), ContentSettingValues.DEFAULT);
browserContextHandle, type, ContentSettingValues.DEFAULT);
} }
for (@PermissionInfo.Type int type = 0; type < PermissionInfo.Type.NUM_ENTRIES; type++) { for (@PermissionInfo.Type int type = 0; type < PermissionInfo.Type.NUM_ENTRIES; type++) {
site.setPermission(browserContextHandle, type, ContentSettingValues.DEFAULT); site.setPermission(browserContextHandle, type, ContentSettingValues.DEFAULT);
......
...@@ -17,34 +17,30 @@ import org.chromium.components.embedder_support.browser_context.BrowserContextHa ...@@ -17,34 +17,30 @@ import org.chromium.components.embedder_support.browser_context.BrowserContextHa
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* Website is a class for storing information about a website and its associated permissions. * Website is a class for storing information about a website and its associated permissions.
*/ */
public class Website implements Serializable { public final class Website implements Serializable {
static final int INVALID_CAMERA_OR_MICROPHONE_ACCESS = 0;
static final int CAMERA_ACCESS_ALLOWED = 1;
static final int MICROPHONE_AND_CAMERA_ACCESS_ALLOWED = 2;
static final int MICROPHONE_ACCESS_ALLOWED = 3;
static final int CAMERA_ACCESS_DENIED = 4;
static final int MICROPHONE_AND_CAMERA_ACCESS_DENIED = 5;
static final int MICROPHONE_ACCESS_DENIED = 6;
private final WebsiteAddress mOrigin; private final WebsiteAddress mOrigin;
private final WebsiteAddress mEmbedder; private final WebsiteAddress mEmbedder;
/** /**
* Indexed by ContentSettingException.Type. * Indexed by ContentSettingsType.
*/ */
private ContentSettingException mContentSettingException[]; private Map<Integer, ContentSettingException> mContentSettingExceptions = new HashMap<>();
/** /**
* Indexed by PermissionInfo.Type. * Indexed by PermissionInfo.Type.
*/ */
private PermissionInfo[] mPermissionInfo; private PermissionInfo[] mPermissionInfo;
private LocalStorageInfo mLocalStorageInfo; private LocalStorageInfo mLocalStorageInfo;
private final List<StorageInfo> mStorageInfo = new ArrayList<StorageInfo>(); private final List<StorageInfo> mStorageInfo = new ArrayList<>();
private int mStorageInfoCallbacksLeft; private int mStorageInfoCallbacksLeft;
// The collection of chooser-based permissions (e.g. USB device access) granted to this site. // The collection of chooser-based permissions (e.g. USB device access) granted to this site.
...@@ -56,8 +52,6 @@ public class Website implements Serializable { ...@@ -56,8 +52,6 @@ public class Website implements Serializable {
mOrigin = origin; mOrigin = origin;
mEmbedder = embedder; mEmbedder = embedder;
mPermissionInfo = new PermissionInfo[PermissionInfo.Type.NUM_ENTRIES]; mPermissionInfo = new PermissionInfo[PermissionInfo.Type.NUM_ENTRIES];
mContentSettingException =
new ContentSettingException[ContentSettingException.Type.NUM_ENTRIES];
} }
public WebsiteAddress getAddress() { public WebsiteAddress getAddress() {
...@@ -164,29 +158,34 @@ public class Website implements Serializable { ...@@ -164,29 +158,34 @@ public class Website implements Serializable {
} }
} }
public Collection<ContentSettingException> getContentSettingExceptions() {
return mContentSettingExceptions.values();
}
/** /**
* Returns the exception info for this Website for specified type. * Returns the exception info for this Website for specified type.
*/ */
public ContentSettingException getContentSettingException( public ContentSettingException getContentSettingException(@ContentSettingsType int type) {
@ContentSettingException.Type int type) { return mContentSettingExceptions.get(type);
return mContentSettingException[type];
} }
/** /**
* Sets the exception info for this Website for specified type. * Sets the exception info for this Website for specified type.
*/ */
public void setContentSettingException( public void setContentSettingException(
@ContentSettingException.Type int type, ContentSettingException exception) { @ContentSettingsType int type, ContentSettingException exception) {
mContentSettingException[type] = exception; mContentSettingExceptions.put(type, exception);
} }
/** /**
* Returns what ContentSettingException governs the setting of specified type. * Returns what ContentSettingException governs the setting of specified type.
*/ */
public @ContentSettingValues @Nullable Integer getContentSettingPermission( public @ContentSettingValues @Nullable Integer getContentSettingPermission(
@ContentSettingException.Type int type) { @ContentSettingsType int type) {
return mContentSettingException[type] != null // TODO(crbug.com/1103597): Merge with getPermission() when both are keyed by
? mContentSettingException[type].getContentSetting() // ContentSettingsType.
return getContentSettingException(type) != null
? getContentSettingException(type).getContentSetting()
: null; : null;
} }
...@@ -194,24 +193,28 @@ public class Website implements Serializable { ...@@ -194,24 +193,28 @@ public class Website implements Serializable {
* Sets the permission. * Sets the permission.
*/ */
public void setContentSettingPermission(BrowserContextHandle browserContextHandle, public void setContentSettingPermission(BrowserContextHandle browserContextHandle,
@ContentSettingException.Type int type, @ContentSettingValues int value) { @ContentSettingsType int type, @ContentSettingValues int value) {
if (type == ContentSettingException.Type.ADS) { // TODO(crbug.com/1103597): Merge with setPermission() when both are keyed by
// ContentSettingsType.
ContentSettingException exception = getContentSettingException(type);
if (type == ContentSettingsType.ADS) {
// It is possible to set the permission without having an existing exception, // It is possible to set the permission without having an existing exception,
// because we can show the BLOCK state even when this permission is set to the // because we can show the BLOCK state even when this permission is set to the
// default. In that case, just set an exception now to BLOCK to enable changing the // default. In that case, just set an exception now to BLOCK to enable changing the
// permission. // permission.
if (mContentSettingException[type] == null) { if (exception == null) {
mContentSettingException[type] = exception = new ContentSettingException(ContentSettingsType.ADS,
new ContentSettingException(ContentSettingsType.ADS, getAddress().getOrigin(), ContentSettingValues.BLOCK, "");
getAddress().getOrigin(), ContentSettingValues.BLOCK, ""); setContentSettingException(type, exception);
} }
} else if (type == ContentSettingException.Type.JAVASCRIPT) { } else if (type == ContentSettingsType.JAVASCRIPT) {
// It is possible to set the permission without having an existing exception, // It is possible to set the permission without having an existing exception,
// because we show the javascript permission in Site Settings if javascript // because we show the javascript permission in Site Settings if javascript
// is blocked by default. // is blocked by default.
if (mContentSettingException[type] == null) { if (exception == null) {
mContentSettingException[type] = new ContentSettingException( exception = new ContentSettingException(
ContentSettingsType.JAVASCRIPT, getAddress().getHost(), value, ""); ContentSettingsType.JAVASCRIPT, getAddress().getHost(), value, "");
setContentSettingException(type, exception);
} }
// It's possible for either action to be emitted. This code path is hit // It's possible for either action to be emitted. This code path is hit
// regardless of whether there was an existing permission or not. // regardless of whether there was an existing permission or not.
...@@ -220,12 +223,13 @@ public class Website implements Serializable { ...@@ -220,12 +223,13 @@ public class Website implements Serializable {
} else { } else {
RecordUserAction.record("JavascriptContentSetting.DisableBy.SiteSettings"); RecordUserAction.record("JavascriptContentSetting.DisableBy.SiteSettings");
} }
} else if (type == ContentSettingException.Type.SOUND) { } else if (type == ContentSettingsType.SOUND) {
// It is possible to set the permission without having an existing exception, // It is possible to set the permission without having an existing exception,
// because we always show the sound permission in Site Settings. // because we always show the sound permission in Site Settings.
if (mContentSettingException[type] == null) { if (exception == null) {
mContentSettingException[type] = new ContentSettingException( exception = new ContentSettingException(
ContentSettingsType.SOUND, getAddress().getHost(), value, ""); ContentSettingsType.SOUND, getAddress().getHost(), value, "");
setContentSettingException(type, exception);
} }
if (value == ContentSettingValues.BLOCK) { if (value == ContentSettingValues.BLOCK) {
RecordUserAction.record("SoundContentSetting.MuteBy.SiteSettings"); RecordUserAction.record("SoundContentSetting.MuteBy.SiteSettings");
...@@ -236,8 +240,8 @@ public class Website implements Serializable { ...@@ -236,8 +240,8 @@ public class Website implements Serializable {
// We want to call setContentSetting even after explicitly setting // We want to call setContentSetting even after explicitly setting
// mContentSettingException above because this will trigger the actual change // mContentSettingException above because this will trigger the actual change
// on the PrefServiceBridge. // on the PrefServiceBridge.
if (mContentSettingException[type] != null) { if (exception != null) {
mContentSettingException[type].setContentSetting(browserContextHandle, value); exception.setContentSetting(browserContextHandle, value);
} }
} }
......
...@@ -285,20 +285,6 @@ public class WebsitePermissionsFetcher { ...@@ -285,20 +285,6 @@ public class WebsitePermissionsFetcher {
} }
private void setException(int contentSettingsType) { private void setException(int contentSettingsType) {
@ContentSettingException.Type
int exceptionType;
for (exceptionType = 0; exceptionType < ContentSettingException.Type.NUM_ENTRIES;
exceptionType++) {
if (contentSettingsType
== ContentSettingException.getContentSettingsType(exceptionType)) {
break;
}
}
assert contentSettingsType
== ContentSettingException.getContentSettingsType(exceptionType)
: "Unexpected content setting type received: "
+ contentSettingsType;
for (ContentSettingException exception : for (ContentSettingException exception :
mWebsitePreferenceBridge.getContentSettingsExceptions( mWebsitePreferenceBridge.getContentSettingsExceptions(
mBrowserContextHandle, contentSettingsType)) { mBrowserContextHandle, contentSettingsType)) {
...@@ -309,7 +295,7 @@ public class WebsitePermissionsFetcher { ...@@ -309,7 +295,7 @@ public class WebsitePermissionsFetcher {
continue; continue;
} }
Website site = findOrCreateSite(address, embedder); Website site = findOrCreateSite(address, embedder);
site.setContentSettingException(exceptionType, exception); site.setContentSettingException(contentSettingsType, exception);
} }
} }
......
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