Commit 8ec81248 authored by Jordan Oroshiba's avatar Jordan Oroshiba Committed by Commit Bot

Removal of PermissionInfo.Type and replacing it with ContentSettingTypes

PermissionInfo.Type contained a subset of ContentSettingTypes. Since both
this and the previously existing ContentSettingException.Type needed to
be translated to and from ContentSettingType for save, these intermediary
types only created more obfuscation of what is happening in the code.

Bug: 1103597
Change-Id: Ie8bb7dbf388c48042291e1d2cb403299c35cefad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2340878
Commit-Queue: Jordan Oroshiba <oroshiba@google.com>
Reviewed-by: default avatarFinnur Thorarinsson <finnur@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarEhimare Okoyomon <eokoyomon@chromium.org>
Reviewed-by: default avatarChristian Dullweber <dullweber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806162}
parent 24c91f76
...@@ -216,7 +216,6 @@ chrome_junit_test_java_sources = [ ...@@ -216,7 +216,6 @@ chrome_junit_test_java_sources = [
"junit/src/org/chromium/chrome/browser/signin/SigninUtilsStartActivityTest.java", "junit/src/org/chromium/chrome/browser/signin/SigninUtilsStartActivityTest.java",
"junit/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerDelegateTest.java", "junit/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerDelegateTest.java",
"junit/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerMediatorTest.java", "junit/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerMediatorTest.java",
"junit/src/org/chromium/chrome/browser/site_settings/SingleWebsiteSettingsTest.java",
"junit/src/org/chromium/chrome/browser/status_indicator/StatusIndicatorMediatorTest.java", "junit/src/org/chromium/chrome/browser/status_indicator/StatusIndicatorMediatorTest.java",
"junit/src/org/chromium/chrome/browser/suggestions/SuggestionsImageFetcherTest.java", "junit/src/org/chromium/chrome/browser/suggestions/SuggestionsImageFetcherTest.java",
"junit/src/org/chromium/chrome/browser/suggestions/tile/TileGroupUnitTest.java", "junit/src/org/chromium/chrome/browser/suggestions/tile/TileGroupUnitTest.java",
......
...@@ -418,7 +418,7 @@ public class GeolocationHeader { ...@@ -418,7 +418,7 @@ public class GeolocationHeader {
static @ContentSettingValues @Nullable Integer locationContentSettingForUrl( static @ContentSettingValues @Nullable Integer locationContentSettingForUrl(
Profile profile, Uri uri) { Profile profile, Uri uri) {
PermissionInfo locationSettings = new PermissionInfo( PermissionInfo locationSettings = new PermissionInfo(
PermissionInfo.Type.GEOLOCATION, uri.toString(), null, profile.isOffTheRecord()); ContentSettingsType.GEOLOCATION, uri.toString(), null, profile.isOffTheRecord());
return locationSettings.getContentSetting(profile); return locationSettings.getContentSetting(profile);
} }
......
...@@ -502,13 +502,13 @@ public class SearchEngineAdapter extends BaseAdapter ...@@ -502,13 +502,13 @@ public class SearchEngineAdapter extends BaseAdapter
Profile profile = Profile.getLastUsedRegularProfile(); Profile profile = Profile.getLastUsedRegularProfile();
PermissionInfo settings = PermissionInfo settings =
new PermissionInfo(PermissionInfo.Type.NOTIFICATION, url, null, false); new PermissionInfo(ContentSettingsType.NOTIFICATIONS, url, null, false);
boolean notificationsAllowed = boolean notificationsAllowed =
settings.getContentSetting(profile) == ContentSettingValues.ALLOW settings.getContentSetting(profile) == ContentSettingValues.ALLOW
&& WebsitePreferenceBridge.isPermissionControlledByDSE( && WebsitePreferenceBridge.isPermissionControlledByDSE(
profile, ContentSettingsType.NOTIFICATIONS, url); profile, ContentSettingsType.NOTIFICATIONS, url);
settings = new PermissionInfo(PermissionInfo.Type.GEOLOCATION, url, null, false); settings = new PermissionInfo(ContentSettingsType.GEOLOCATION, url, null, false);
boolean locationAllowed = settings.getContentSetting(profile) == ContentSettingValues.ALLOW boolean locationAllowed = settings.getContentSetting(profile) == ContentSettingValues.ALLOW
&& WebsitePreferenceBridge.isPermissionControlledByDSE( && WebsitePreferenceBridge.isPermissionControlledByDSE(
profile, ContentSettingsType.GEOLOCATION, url); profile, ContentSettingsType.GEOLOCATION, url);
...@@ -565,7 +565,7 @@ public class SearchEngineAdapter extends BaseAdapter ...@@ -565,7 +565,7 @@ public class SearchEngineAdapter extends BaseAdapter
if (url.isEmpty()) return false; if (url.isEmpty()) return false;
PermissionInfo locationSettings = PermissionInfo locationSettings =
new PermissionInfo(PermissionInfo.Type.GEOLOCATION, url, null, false); new PermissionInfo(ContentSettingsType.GEOLOCATION, url, null, false);
return locationSettings.getContentSetting(Profile.getLastUsedRegularProfile()) return locationSettings.getContentSetting(Profile.getLastUsedRegularProfile())
== ContentSettingValues.ALLOW; == ContentSettingValues.ALLOW;
} }
......
...@@ -27,6 +27,7 @@ import org.chromium.chrome.test.util.InfoBarTestAnimationListener; ...@@ -27,6 +27,7 @@ import org.chromium.chrome.test.util.InfoBarTestAnimationListener;
import org.chromium.chrome.test.util.browser.LocationSettingsTestUtil; import org.chromium.chrome.test.util.browser.LocationSettingsTestUtil;
import org.chromium.components.browser_ui.site_settings.PermissionInfo; import org.chromium.components.browser_ui.site_settings.PermissionInfo;
import org.chromium.components.content_settings.ContentSettingValues; import org.chromium.components.content_settings.ContentSettingValues;
import org.chromium.components.content_settings.ContentSettingsType;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.browser.test.util.Criteria; import org.chromium.content_public.browser.test.util.Criteria;
import org.chromium.content_public.browser.test.util.CriteriaHelper; import org.chromium.content_public.browser.test.util.CriteriaHelper;
...@@ -93,7 +94,7 @@ public class PermissionUpdateInfobarTest { ...@@ -93,7 +94,7 @@ public class PermissionUpdateInfobarTest {
@Override @Override
public PermissionInfo call() { public PermissionInfo call() {
return new PermissionInfo( return new PermissionInfo(
PermissionInfo.Type.GEOLOCATION, locationUrl, null, false); ContentSettingsType.GEOLOCATION, locationUrl, null, false);
} }
}); });
......
...@@ -29,6 +29,7 @@ import org.chromium.chrome.test.util.InfoBarTestAnimationListener; ...@@ -29,6 +29,7 @@ import org.chromium.chrome.test.util.InfoBarTestAnimationListener;
import org.chromium.chrome.test.util.InfoBarUtil; import org.chromium.chrome.test.util.InfoBarUtil;
import org.chromium.components.browser_ui.site_settings.PermissionInfo; import org.chromium.components.browser_ui.site_settings.PermissionInfo;
import org.chromium.components.content_settings.ContentSettingValues; import org.chromium.components.content_settings.ContentSettingValues;
import org.chromium.components.content_settings.ContentSettingsType;
import org.chromium.content_public.browser.UiThreadTaskTraits; import org.chromium.content_public.browser.UiThreadTaskTraits;
import org.chromium.net.test.EmbeddedTestServer; import org.chromium.net.test.EmbeddedTestServer;
...@@ -52,7 +53,7 @@ public class SearchGeolocationDisclosureInfoBarTest { ...@@ -52,7 +53,7 @@ public class SearchGeolocationDisclosureInfoBarTest {
mTestServer = EmbeddedTestServer.createAndStartServer(InstrumentationRegistry.getContext()); mTestServer = EmbeddedTestServer.createAndStartServer(InstrumentationRegistry.getContext());
// Simulate the DSE being granted location (the test server isn't set to be the DSE). // Simulate the DSE being granted location (the test server isn't set to be the DSE).
PermissionInfo locationSettings = new PermissionInfo( PermissionInfo locationSettings = new PermissionInfo(
PermissionInfo.Type.GEOLOCATION, mTestServer.getURL(SEARCH_PAGE), null, false); ContentSettingsType.GEOLOCATION, mTestServer.getURL(SEARCH_PAGE), null, false);
PostTask.runOrPostTask(UiThreadTaskTraits.DEFAULT, PostTask.runOrPostTask(UiThreadTaskTraits.DEFAULT,
() ()
-> locationSettings.setContentSetting( -> locationSettings.setContentSetting(
......
...@@ -15,6 +15,7 @@ import org.chromium.components.browser_ui.notifications.MockNotificationManagerP ...@@ -15,6 +15,7 @@ import org.chromium.components.browser_ui.notifications.MockNotificationManagerP
import org.chromium.components.browser_ui.notifications.MockNotificationManagerProxy.NotificationEntry; import org.chromium.components.browser_ui.notifications.MockNotificationManagerProxy.NotificationEntry;
import org.chromium.components.browser_ui.site_settings.PermissionInfo; import org.chromium.components.browser_ui.site_settings.PermissionInfo;
import org.chromium.components.content_settings.ContentSettingValues; import org.chromium.components.content_settings.ContentSettingValues;
import org.chromium.components.content_settings.ContentSettingsType;
import org.chromium.content_public.browser.test.util.Criteria; import org.chromium.content_public.browser.test.util.Criteria;
import org.chromium.content_public.browser.test.util.CriteriaHelper; import org.chromium.content_public.browser.test.util.CriteriaHelper;
import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.content_public.browser.test.util.TestThreadUtils;
...@@ -55,7 +56,7 @@ public class NotificationTestRule extends ChromeTabbedActivityTestRule { ...@@ -55,7 +56,7 @@ public class NotificationTestRule extends ChromeTabbedActivityTestRule {
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
// The notification content setting does not consider the embedder origin. // The notification content setting does not consider the embedder origin.
PermissionInfo notificationInfo = PermissionInfo notificationInfo =
new PermissionInfo(PermissionInfo.Type.NOTIFICATION, origin, "", false); new PermissionInfo(ContentSettingsType.NOTIFICATIONS, origin, "", false);
notificationInfo.setContentSetting(Profile.getLastUsedRegularProfile(), setting); notificationInfo.setContentSetting(Profile.getLastUsedRegularProfile(), setting);
}); });
......
...@@ -36,6 +36,7 @@ import org.chromium.components.browser_ui.notifications.NotificationManagerProxy ...@@ -36,6 +36,7 @@ import org.chromium.components.browser_ui.notifications.NotificationManagerProxy
import org.chromium.components.browser_ui.notifications.NotificationManagerProxyImpl; import org.chromium.components.browser_ui.notifications.NotificationManagerProxyImpl;
import org.chromium.components.browser_ui.site_settings.PermissionInfo; import org.chromium.components.browser_ui.site_settings.PermissionInfo;
import org.chromium.components.content_settings.ContentSettingValues; import org.chromium.components.content_settings.ContentSettingValues;
import org.chromium.components.content_settings.ContentSettingsType;
import org.chromium.content_public.browser.test.NativeLibraryTestUtils; import org.chromium.content_public.browser.test.NativeLibraryTestUtils;
import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.content_public.browser.test.util.TestThreadUtils;
...@@ -196,7 +197,7 @@ public class SiteChannelsManagerTest { ...@@ -196,7 +197,7 @@ public class SiteChannelsManagerTest {
@SmallTest @SmallTest
public void testBlockingPermissionInIncognitoCreatesNoChannels() { public void testBlockingPermissionInIncognitoCreatesNoChannels() {
PermissionInfo info = new PermissionInfo( PermissionInfo info = new PermissionInfo(
PermissionInfo.Type.NOTIFICATION, "https://example-incognito.com", null, true); ContentSettingsType.NOTIFICATIONS, "https://example-incognito.com", null, true);
TestThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() ()
-> info.setContentSetting( -> info.setContentSetting(
......
...@@ -27,6 +27,7 @@ import org.chromium.chrome.test.ChromeActivityTestRule; ...@@ -27,6 +27,7 @@ import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.components.browser_ui.site_settings.PermissionInfo; import org.chromium.components.browser_ui.site_settings.PermissionInfo;
import org.chromium.components.content_settings.ContentSettingValues; import org.chromium.components.content_settings.ContentSettingValues;
import org.chromium.components.content_settings.ContentSettingsType;
import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.content_public.browser.test.util.TestThreadUtils;
/** /**
...@@ -152,7 +153,7 @@ public class GeolocationHeaderTest { ...@@ -152,7 +153,7 @@ public class GeolocationHeaderTest {
final long locationTime, final boolean shouldBeNull) { final long locationTime, final boolean shouldBeNull) {
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
PermissionInfo infoHttps = PermissionInfo infoHttps =
new PermissionInfo(PermissionInfo.Type.GEOLOCATION, SEARCH_URL_1, null, false); new PermissionInfo(ContentSettingsType.GEOLOCATION, SEARCH_URL_1, null, false);
infoHttps.setContentSetting(Profile.getLastUsedRegularProfile(), httpsPermission); infoHttps.setContentSetting(Profile.getLastUsedRegularProfile(), httpsPermission);
String header = GeolocationHeader.getGeoHeader( String header = GeolocationHeader.getGeoHeader(
SEARCH_URL_1, mActivityTestRule.getActivity().getActivityTab()); SEARCH_URL_1, mActivityTestRule.getActivity().getActivityTab());
......
...@@ -30,6 +30,7 @@ import org.chromium.components.browser_ui.settings.ManagedPreferenceDelegate; ...@@ -30,6 +30,7 @@ import org.chromium.components.browser_ui.settings.ManagedPreferenceDelegate;
import org.chromium.components.browser_ui.site_settings.PermissionInfo; import org.chromium.components.browser_ui.site_settings.PermissionInfo;
import org.chromium.components.browser_ui.site_settings.WebsitePreferenceBridgeJni; import org.chromium.components.browser_ui.site_settings.WebsitePreferenceBridgeJni;
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.search_engines.TemplateUrl; import org.chromium.components.search_engines.TemplateUrl;
import org.chromium.components.search_engines.TemplateUrlService; import org.chromium.components.search_engines.TemplateUrlService;
import org.chromium.components.search_engines.TemplateUrlService.LoadListener; import org.chromium.components.search_engines.TemplateUrlService.LoadListener;
...@@ -238,7 +239,7 @@ public class SearchEngineSettingsTest { ...@@ -238,7 +239,7 @@ public class SearchEngineSettingsTest {
private @ContentSettingValues int locationPermissionForSearchEngine(String keyword) { private @ContentSettingValues int locationPermissionForSearchEngine(String keyword) {
String url = TemplateUrlServiceFactory.get().getSearchEngineUrlFromTemplateUrl(keyword); String url = TemplateUrlServiceFactory.get().getSearchEngineUrlFromTemplateUrl(keyword);
PermissionInfo locationSettings = PermissionInfo locationSettings =
new PermissionInfo(PermissionInfo.Type.GEOLOCATION, url, null, false); new PermissionInfo(ContentSettingsType.GEOLOCATION, url, null, false);
@ContentSettingValues @ContentSettingValues
int locationPermission = int locationPermission =
locationSettings.getContentSetting(Profile.getLastUsedRegularProfile()); locationSettings.getContentSetting(Profile.getLastUsedRegularProfile());
......
...@@ -24,6 +24,7 @@ import org.chromium.chrome.test.util.browser.Features.EnableFeatures; ...@@ -24,6 +24,7 @@ import org.chromium.chrome.test.util.browser.Features.EnableFeatures;
import org.chromium.components.browser_ui.site_settings.PermissionInfo; import org.chromium.components.browser_ui.site_settings.PermissionInfo;
import org.chromium.components.browser_ui.site_settings.WebsitePreferenceBridgeJni; import org.chromium.components.browser_ui.site_settings.WebsitePreferenceBridgeJni;
import org.chromium.components.content_settings.ContentSettingValues; import org.chromium.components.content_settings.ContentSettingValues;
import org.chromium.components.content_settings.ContentSettingsType;
import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.content_public.browser.test.util.TestThreadUtils;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
...@@ -52,7 +53,7 @@ public class PermissionInfoTest { ...@@ -52,7 +53,7 @@ public class PermissionInfoTest {
private void setGeolocation( private void setGeolocation(
String origin, String embedder, @ContentSettingValues int setting, boolean incognito) { String origin, String embedder, @ContentSettingValues int setting, boolean incognito) {
PermissionInfo info = PermissionInfo info =
new PermissionInfo(PermissionInfo.Type.GEOLOCATION, origin, embedder, incognito); new PermissionInfo(ContentSettingsType.GEOLOCATION, origin, embedder, incognito);
TestThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> info.setContentSetting(getProfile(incognito), setting)); () -> info.setContentSetting(getProfile(incognito), setting));
} }
...@@ -61,7 +62,7 @@ public class PermissionInfoTest { ...@@ -61,7 +62,7 @@ public class PermissionInfoTest {
String origin, String embedder, boolean incognito) throws ExecutionException { String origin, String embedder, boolean incognito) throws ExecutionException {
return TestThreadUtils.runOnUiThreadBlocking(() -> { return TestThreadUtils.runOnUiThreadBlocking(() -> {
PermissionInfo info = new PermissionInfo( PermissionInfo info = new PermissionInfo(
PermissionInfo.Type.GEOLOCATION, origin, embedder, incognito); ContentSettingsType.GEOLOCATION, origin, embedder, incognito);
return info.getContentSetting(getProfile(incognito)); return info.getContentSetting(getProfile(incognito));
}); });
} }
...@@ -69,7 +70,7 @@ public class PermissionInfoTest { ...@@ -69,7 +70,7 @@ public class PermissionInfoTest {
private void setNotifications( private void setNotifications(
String origin, String embedder, @ContentSettingValues int setting, boolean incognito) { String origin, String embedder, @ContentSettingValues int setting, boolean incognito) {
PermissionInfo info = PermissionInfo info =
new PermissionInfo(PermissionInfo.Type.NOTIFICATION, origin, embedder, incognito); new PermissionInfo(ContentSettingsType.NOTIFICATIONS, origin, embedder, incognito);
TestThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> info.setContentSetting(getProfile(incognito), setting)); () -> info.setContentSetting(getProfile(incognito), setting));
} }
...@@ -78,7 +79,7 @@ public class PermissionInfoTest { ...@@ -78,7 +79,7 @@ public class PermissionInfoTest {
String origin, String embedder, boolean incognito) throws ExecutionException { String origin, String embedder, boolean incognito) throws ExecutionException {
return TestThreadUtils.runOnUiThreadBlocking(() -> { return TestThreadUtils.runOnUiThreadBlocking(() -> {
PermissionInfo info = new PermissionInfo( PermissionInfo info = new PermissionInfo(
PermissionInfo.Type.NOTIFICATION, origin, embedder, incognito); ContentSettingsType.NOTIFICATIONS, origin, embedder, incognito);
return info.getContentSetting(getProfile(incognito)); return info.getContentSetting(getProfile(incognito));
}); });
} }
......
// Copyright 2020 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.chrome.browser.site_settings;
import androidx.test.filters.SmallTest;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.BaseRobolectricTestRunner;
import org.chromium.components.browser_ui.site_settings.SingleWebsiteSettings;
import org.chromium.components.content_settings.ContentSettingsType;
/**
* Tests the functionality of the SingleWebsiteSettings.java page.
*/
@RunWith(BaseRobolectricTestRunner.class)
public class SingleWebsiteSettingsTest {
private @ContentSettingsType int getCorrectContentSettingsTypeForPreferenceKey(
String preferenceKey) {
switch (preferenceKey) {
case "ads_permission_list":
return ContentSettingsType.ADS;
case "automatic_downloads_permission_list":
return ContentSettingsType.AUTOMATIC_DOWNLOADS;
case "background_sync_permission_list":
return ContentSettingsType.BACKGROUND_SYNC;
case "bluetooth_scanning_permission_list":
return ContentSettingsType.BLUETOOTH_SCANNING;
case "cookies_permission_list":
return ContentSettingsType.COOKIES;
case "javascript_permission_list":
return ContentSettingsType.JAVASCRIPT;
case "popup_permission_list":
return ContentSettingsType.POPUPS;
case "sound_permission_list":
return ContentSettingsType.SOUND;
case "ar_permission_list":
return ContentSettingsType.AR;
case "camera_permission_list":
return ContentSettingsType.MEDIASTREAM_CAMERA;
case "clipboard_permission_list":
return ContentSettingsType.CLIPBOARD_READ_WRITE;
case "location_access_list":
return ContentSettingsType.GEOLOCATION;
case "microphone_permission_list":
return ContentSettingsType.MEDIASTREAM_MIC;
case "midi_sysex_permission_list":
return ContentSettingsType.MIDI_SYSEX;
case "nfc_permission_list":
return ContentSettingsType.NFC;
case "push_notifications_list":
return ContentSettingsType.NOTIFICATIONS;
case "protected_media_identifier_permission_list":
return ContentSettingsType.PROTECTED_MEDIA_IDENTIFIER;
case "sensors_permission_list":
return ContentSettingsType.SENSORS;
case "vr_permission_list":
return ContentSettingsType.VR;
default:
Assert.fail("Preference key not in list.");
return ContentSettingsType.DEFAULT;
}
}
/**
* Tests that the order of SingleWebsiteSettings.PERMISSION_PREFERENCE_KEYS matches the enums it
* comes from.
*/
@Test
@SmallTest
public void testCorrectMapOfPreferenceKeyToContentSettingsType() {
SingleWebsiteSettings settings = new SingleWebsiteSettings();
for (String key : SingleWebsiteSettings.PERMISSION_PREFERENCE_KEYS) {
Assert.assertEquals(settings.getContentSettingsTypeFromPreferenceKey(key),
getCorrectContentSettingsTypeForPreferenceKey(key));
}
}
}
\ No newline at end of file
...@@ -200,13 +200,13 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment ...@@ -200,13 +200,13 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
if (contentSettingPermission != null) { if (contentSettingPermission != null) {
return ContentSettingValues.BLOCK == contentSettingPermission; return ContentSettingValues.BLOCK == contentSettingPermission;
} }
for (@PermissionInfo.Type int j = 0; j < PermissionInfo.Type.NUM_ENTRIES; j++) {
if (PermissionInfo.getContentSettingsType(j) PermissionInfo permissionInfo =
== SiteSettingsCategory.contentSettingsType(i)) { website.site().getPermissionInfo(SiteSettingsCategory.contentSettingsType(i));
return j != PermissionInfo.Type.MIDI if (permissionInfo != null) {
&& ContentSettingValues.BLOCK return permissionInfo.getContentSettingsType() != ContentSettingsType.MIDI_SYSEX
== website.site().getPermission(browserContextHandle, j); && ContentSettingValues.BLOCK
} == permissionInfo.getContentSetting(browserContextHandle);
} }
} }
return false; return false;
......
...@@ -28,8 +28,9 @@ public class SiteDataCleaner { ...@@ -28,8 +28,9 @@ public class SiteDataCleaner {
site.setContentSettingPermission(browserContextHandle, site.setContentSettingPermission(browserContextHandle,
exception.getContentSettingType(), ContentSettingValues.DEFAULT); exception.getContentSettingType(), ContentSettingValues.DEFAULT);
} }
for (@PermissionInfo.Type int type = 0; type < PermissionInfo.Type.NUM_ENTRIES; type++) { for (PermissionInfo info : site.getPermissionInfos()) {
site.setPermission(browserContextHandle, type, ContentSettingValues.DEFAULT); site.setPermission(browserContextHandle, info.getContentSettingsType(),
ContentSettingValues.DEFAULT);
} }
for (ChosenObjectInfo info : site.getChosenObjectInfo()) { for (ChosenObjectInfo info : site.getChosenObjectInfo()) {
......
...@@ -35,9 +35,9 @@ public final class Website implements Serializable { ...@@ -35,9 +35,9 @@ public final class Website implements Serializable {
private Map<Integer, ContentSettingException> mContentSettingExceptions = new HashMap<>(); private Map<Integer, ContentSettingException> mContentSettingExceptions = new HashMap<>();
/** /**
* Indexed by PermissionInfo.Type. * Indexed by ContentSettingsType.
*/ */
private PermissionInfo[] mPermissionInfo; private Map<Integer, PermissionInfo> mPermissionInfos = new HashMap<>();
private LocalStorageInfo mLocalStorageInfo; private LocalStorageInfo mLocalStorageInfo;
private final List<StorageInfo> mStorageInfo = new ArrayList<>(); private final List<StorageInfo> mStorageInfo = new ArrayList<>();
...@@ -50,7 +50,6 @@ public final class Website implements Serializable { ...@@ -50,7 +50,6 @@ public final class Website implements Serializable {
public Website(WebsiteAddress origin, WebsiteAddress embedder) { public Website(WebsiteAddress origin, WebsiteAddress embedder) {
mOrigin = origin; mOrigin = origin;
mEmbedder = embedder; mEmbedder = embedder;
mPermissionInfo = new PermissionInfo[PermissionInfo.Type.NUM_ENTRIES];
} }
public WebsiteAddress getAddress() { public WebsiteAddress getAddress() {
...@@ -119,12 +118,19 @@ public final class Website implements Serializable { ...@@ -119,12 +118,19 @@ public final class Website implements Serializable {
return MathUtils.compareLongs(to.getTotalUsage(), getTotalUsage()); return MathUtils.compareLongs(to.getTotalUsage(), getTotalUsage());
} }
/**
* @return Collection of PermissionInfos stored for the site.
*/
public Collection<PermissionInfo> getPermissionInfos() {
return mPermissionInfos.values();
}
/** /**
* @return PermissionInfo with permission details of specified type * @return PermissionInfo with permission details of specified type
* (Camera, Clipboard, etc.). * (Camera, Clipboard, etc.).
*/ */
public PermissionInfo getPermissionInfo(@PermissionInfo.Type int type) { public PermissionInfo getPermissionInfo(@ContentSettingsType int type) {
return mPermissionInfo[type]; return mPermissionInfos.get(type);
} }
/** /**
...@@ -132,7 +138,7 @@ public final class Website implements Serializable { ...@@ -132,7 +138,7 @@ public final class Website implements Serializable {
* (Camera, Clipboard, etc.). * (Camera, Clipboard, etc.).
*/ */
public void setPermissionInfo(PermissionInfo info) { public void setPermissionInfo(PermissionInfo info) {
mPermissionInfo[info.getType()] = info; mPermissionInfos.put(info.getContentSettingsType(), info);
} }
/** /**
...@@ -140,7 +146,7 @@ public final class Website implements Serializable { ...@@ -140,7 +146,7 @@ public final class Website implements Serializable {
* (Camera, Clipboard, etc.). * (Camera, Clipboard, etc.).
*/ */
public @ContentSettingValues @Nullable Integer getPermission( public @ContentSettingValues @Nullable Integer getPermission(
BrowserContextHandle browserContextHandle, @PermissionInfo.Type int type) { BrowserContextHandle browserContextHandle, @ContentSettingsType int type) {
return getPermissionInfo(type) != null return getPermissionInfo(type) != null
? getPermissionInfo(type).getContentSetting(browserContextHandle) ? getPermissionInfo(type).getContentSetting(browserContextHandle)
: null; : null;
...@@ -151,7 +157,7 @@ public final class Website implements Serializable { ...@@ -151,7 +157,7 @@ public final class Website implements Serializable {
* (Camera, Clipboard, etc.). * (Camera, Clipboard, etc.).
*/ */
public void setPermission(BrowserContextHandle browserContextHandle, public void setPermission(BrowserContextHandle browserContextHandle,
@PermissionInfo.Type int type, @ContentSettingValues int value) { @ContentSettingsType int type, @ContentSettingValues int value) {
if (getPermissionInfo(type) != null) { if (getPermissionInfo(type) != null) {
getPermissionInfo(type).setContentSetting(browserContextHandle, value); getPermissionInfo(type).setContentSetting(browserContextHandle, value);
} }
......
...@@ -95,9 +95,9 @@ public class WebsitePermissionsFetcher { ...@@ -95,9 +95,9 @@ public class WebsitePermissionsFetcher {
TaskQueue queue = new TaskQueue(); TaskQueue queue = new TaskQueue();
// Populate features from more specific to less specific. // Populate features from more specific to less specific.
// Geolocation lookup permission is per-origin and per-embedder. // Geolocation lookup permission is per-origin and per-embedder.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.GEOLOCATION)); queue.add(new PermissionInfoFetcher(ContentSettingsType.GEOLOCATION));
// Midi sysex access permission is per-origin and per-embedder. // Midi sysex access permission is per-origin and per-embedder.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.MIDI)); queue.add(new PermissionInfoFetcher(ContentSettingsType.MIDI_SYSEX));
// Cookies are stored per-host. // Cookies are stored per-host.
queue.add(new ExceptionInfoFetcher(ContentSettingsType.COOKIES)); queue.add(new ExceptionInfoFetcher(ContentSettingsType.COOKIES));
// Local storage info is per-origin. // Local storage info is per-origin.
...@@ -114,13 +114,13 @@ public class WebsitePermissionsFetcher { ...@@ -114,13 +114,13 @@ public class WebsitePermissionsFetcher {
// Sound exceptions are host-based patterns. // Sound exceptions are host-based patterns.
queue.add(new ExceptionInfoFetcher(ContentSettingsType.SOUND)); queue.add(new ExceptionInfoFetcher(ContentSettingsType.SOUND));
// Protected media identifier permission is per-origin and per-embedder. // Protected media identifier permission is per-origin and per-embedder.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.PROTECTED_MEDIA_IDENTIFIER)); queue.add(new PermissionInfoFetcher(ContentSettingsType.PROTECTED_MEDIA_IDENTIFIER));
// Notification permission is per-origin. // Notification permission is per-origin.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.NOTIFICATION)); queue.add(new PermissionInfoFetcher(ContentSettingsType.NOTIFICATIONS));
// Camera capture permission is per-origin and per-embedder. // Camera capture permission is per-origin and per-embedder.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.CAMERA)); queue.add(new PermissionInfoFetcher(ContentSettingsType.MEDIASTREAM_CAMERA));
// Micropohone capture permission is per-origin and per-embedder. // Micropohone capture permission is per-origin and per-embedder.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.MICROPHONE)); queue.add(new PermissionInfoFetcher(ContentSettingsType.MEDIASTREAM_MIC));
// Background sync permission is per-origin. // Background sync permission is per-origin.
queue.add(new ExceptionInfoFetcher(ContentSettingsType.BACKGROUND_SYNC)); queue.add(new ExceptionInfoFetcher(ContentSettingsType.BACKGROUND_SYNC));
// Automatic Downloads permission is per-origin. // Automatic Downloads permission is per-origin.
...@@ -128,9 +128,9 @@ public class WebsitePermissionsFetcher { ...@@ -128,9 +128,9 @@ public class WebsitePermissionsFetcher {
// USB device permission is per-origin and per-embedder. // USB device permission is per-origin and per-embedder.
queue.add(new ChooserExceptionInfoFetcher(ContentSettingsType.USB_GUARD)); queue.add(new ChooserExceptionInfoFetcher(ContentSettingsType.USB_GUARD));
// Clipboard info is per-origin. // Clipboard info is per-origin.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.CLIPBOARD)); queue.add(new PermissionInfoFetcher(ContentSettingsType.CLIPBOARD_READ_WRITE));
// Sensors permission is per-origin. // Sensors permission is per-origin.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.SENSORS)); queue.add(new PermissionInfoFetcher(ContentSettingsType.SENSORS));
// There are two Bluetooth related permissions: Bluetooth scanning and // There are two Bluetooth related permissions: Bluetooth scanning and
// Bluetooth guard. // Bluetooth guard.
...@@ -156,12 +156,12 @@ public class WebsitePermissionsFetcher { ...@@ -156,12 +156,12 @@ public class WebsitePermissionsFetcher {
} }
if (ContentFeatureList.isEnabled(ContentFeatureList.WEB_NFC)) { if (ContentFeatureList.isEnabled(ContentFeatureList.WEB_NFC)) {
// NFC permission is per-origin and per-embedder. // NFC permission is per-origin and per-embedder.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.NFC)); queue.add(new PermissionInfoFetcher(ContentSettingsType.NFC));
} }
// VIRTUAL_REALITY permission is per-origin and per-embedder. // VIRTUAL_REALITY permission is per-origin and per-embedder.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.VIRTUAL_REALITY)); queue.add(new PermissionInfoFetcher(ContentSettingsType.VR));
// AR permission is per-origin and per-embedder. // AR permission is per-origin and per-embedder.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.AUGMENTED_REALITY)); queue.add(new PermissionInfoFetcher(ContentSettingsType.AR));
queue.add(new PermissionsAvailableCallbackRunner(callback)); queue.add(new PermissionsAvailableCallbackRunner(callback));
...@@ -188,7 +188,7 @@ public class WebsitePermissionsFetcher { ...@@ -188,7 +188,7 @@ public class WebsitePermissionsFetcher {
// Populate features from more specific to less specific. // Populate features from more specific to less specific.
if (category.showSites(SiteSettingsCategory.Type.DEVICE_LOCATION)) { if (category.showSites(SiteSettingsCategory.Type.DEVICE_LOCATION)) {
// Geolocation lookup permission is per-origin and per-embedder. // Geolocation lookup permission is per-origin and per-embedder.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.GEOLOCATION)); queue.add(new PermissionInfoFetcher(ContentSettingsType.GEOLOCATION));
} else if (category.showSites(SiteSettingsCategory.Type.COOKIES)) { } else if (category.showSites(SiteSettingsCategory.Type.COOKIES)) {
// Cookies exceptions are patterns. // Cookies exceptions are patterns.
queue.add(new ExceptionInfoFetcher(ContentSettingsType.COOKIES)); queue.add(new ExceptionInfoFetcher(ContentSettingsType.COOKIES));
...@@ -199,10 +199,10 @@ public class WebsitePermissionsFetcher { ...@@ -199,10 +199,10 @@ public class WebsitePermissionsFetcher {
queue.add(new WebStorageInfoFetcher()); queue.add(new WebStorageInfoFetcher());
} else if (category.showSites(SiteSettingsCategory.Type.CAMERA)) { } else if (category.showSites(SiteSettingsCategory.Type.CAMERA)) {
// Camera capture permission is per-origin and per-embedder. // Camera capture permission is per-origin and per-embedder.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.CAMERA)); queue.add(new PermissionInfoFetcher(ContentSettingsType.MEDIASTREAM_CAMERA));
} else if (category.showSites(SiteSettingsCategory.Type.MICROPHONE)) { } else if (category.showSites(SiteSettingsCategory.Type.MICROPHONE)) {
// Micropohone capture permission is per-origin and per-embedder. // Micropohone capture permission is per-origin and per-embedder.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.MICROPHONE)); queue.add(new PermissionInfoFetcher(ContentSettingsType.MEDIASTREAM_MIC));
} else if (category.showSites(SiteSettingsCategory.Type.POPUPS)) { } else if (category.showSites(SiteSettingsCategory.Type.POPUPS)) {
// Popup exceptions are host-based patterns (unless we start // Popup exceptions are host-based patterns (unless we start
// synchronizing popup exceptions with desktop Chrome.) // synchronizing popup exceptions with desktop Chrome.)
...@@ -218,7 +218,7 @@ public class WebsitePermissionsFetcher { ...@@ -218,7 +218,7 @@ public class WebsitePermissionsFetcher {
queue.add(new ExceptionInfoFetcher(ContentSettingsType.SOUND)); queue.add(new ExceptionInfoFetcher(ContentSettingsType.SOUND));
} else if (category.showSites(SiteSettingsCategory.Type.NOTIFICATIONS)) { } else if (category.showSites(SiteSettingsCategory.Type.NOTIFICATIONS)) {
// Push notification permission is per-origin. // Push notification permission is per-origin.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.NOTIFICATION)); queue.add(new PermissionInfoFetcher(ContentSettingsType.NOTIFICATIONS));
} else if (category.showSites(SiteSettingsCategory.Type.BACKGROUND_SYNC)) { } else if (category.showSites(SiteSettingsCategory.Type.BACKGROUND_SYNC)) {
// Background sync info is per-origin. // Background sync info is per-origin.
queue.add(new ExceptionInfoFetcher(ContentSettingsType.BACKGROUND_SYNC)); queue.add(new ExceptionInfoFetcher(ContentSettingsType.BACKGROUND_SYNC));
...@@ -227,7 +227,7 @@ public class WebsitePermissionsFetcher { ...@@ -227,7 +227,7 @@ public class WebsitePermissionsFetcher {
queue.add(new ExceptionInfoFetcher(ContentSettingsType.AUTOMATIC_DOWNLOADS)); queue.add(new ExceptionInfoFetcher(ContentSettingsType.AUTOMATIC_DOWNLOADS));
} else if (category.showSites(SiteSettingsCategory.Type.PROTECTED_MEDIA)) { } else if (category.showSites(SiteSettingsCategory.Type.PROTECTED_MEDIA)) {
// Protected media identifier permission is per-origin and per-embedder. // Protected media identifier permission is per-origin and per-embedder.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.PROTECTED_MEDIA_IDENTIFIER)); queue.add(new PermissionInfoFetcher(ContentSettingsType.PROTECTED_MEDIA_IDENTIFIER));
} else if (category.showSites(SiteSettingsCategory.Type.USB)) { } else if (category.showSites(SiteSettingsCategory.Type.USB)) {
// USB device permission is per-origin. // USB device permission is per-origin.
queue.add(new ChooserExceptionInfoFetcher(ContentSettingsType.USB_GUARD)); queue.add(new ChooserExceptionInfoFetcher(ContentSettingsType.USB_GUARD));
...@@ -236,10 +236,10 @@ public class WebsitePermissionsFetcher { ...@@ -236,10 +236,10 @@ public class WebsitePermissionsFetcher {
queue.add(new ChooserExceptionInfoFetcher(ContentSettingsType.BLUETOOTH_GUARD)); queue.add(new ChooserExceptionInfoFetcher(ContentSettingsType.BLUETOOTH_GUARD));
} else if (category.showSites(SiteSettingsCategory.Type.CLIPBOARD)) { } else if (category.showSites(SiteSettingsCategory.Type.CLIPBOARD)) {
// Clipboard permission is per-origin. // Clipboard permission is per-origin.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.CLIPBOARD)); queue.add(new PermissionInfoFetcher(ContentSettingsType.CLIPBOARD_READ_WRITE));
} else if (category.showSites(SiteSettingsCategory.Type.SENSORS)) { } else if (category.showSites(SiteSettingsCategory.Type.SENSORS)) {
// Sensors permission is per-origin. // Sensors permission is per-origin.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.SENSORS)); queue.add(new PermissionInfoFetcher(ContentSettingsType.SENSORS));
} else if (category.showSites(SiteSettingsCategory.Type.BLUETOOTH_SCANNING)) { } else if (category.showSites(SiteSettingsCategory.Type.BLUETOOTH_SCANNING)) {
CommandLine commandLine = CommandLine.getInstance(); CommandLine commandLine = CommandLine.getInstance();
if (commandLine.hasSwitch(ContentSwitches.ENABLE_EXPERIMENTAL_WEB_PLATFORM_FEATURES)) { if (commandLine.hasSwitch(ContentSwitches.ENABLE_EXPERIMENTAL_WEB_PLATFORM_FEATURES)) {
...@@ -249,14 +249,14 @@ public class WebsitePermissionsFetcher { ...@@ -249,14 +249,14 @@ public class WebsitePermissionsFetcher {
} else if (category.showSites(SiteSettingsCategory.Type.NFC)) { } else if (category.showSites(SiteSettingsCategory.Type.NFC)) {
if (ContentFeatureList.isEnabled(ContentFeatureList.WEB_NFC)) { if (ContentFeatureList.isEnabled(ContentFeatureList.WEB_NFC)) {
// NFC permission is per-origin and per-embedder. // NFC permission is per-origin and per-embedder.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.NFC)); queue.add(new PermissionInfoFetcher(ContentSettingsType.NFC));
} }
} else if (category.showSites(SiteSettingsCategory.Type.VIRTUAL_REALITY)) { } else if (category.showSites(SiteSettingsCategory.Type.VIRTUAL_REALITY)) {
// VIRTUAL_REALITY permission is per-origin and per-embedder. // VIRTUAL_REALITY permission is per-origin and per-embedder.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.VIRTUAL_REALITY)); queue.add(new PermissionInfoFetcher(ContentSettingsType.VR));
} else if (category.showSites(SiteSettingsCategory.Type.AUGMENTED_REALITY)) { } else if (category.showSites(SiteSettingsCategory.Type.AUGMENTED_REALITY)) {
// AUGMENTED_REALITY permission is per-origin and per-embedder. // AUGMENTED_REALITY permission is per-origin and per-embedder.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.AUGMENTED_REALITY)); queue.add(new PermissionInfoFetcher(ContentSettingsType.AR));
} }
queue.add(new PermissionsAvailableCallbackRunner(callback)); queue.add(new PermissionsAvailableCallbackRunner(callback));
queue.next(); queue.next();
...@@ -333,9 +333,9 @@ public class WebsitePermissionsFetcher { ...@@ -333,9 +333,9 @@ public class WebsitePermissionsFetcher {
} }
private class PermissionInfoFetcher extends Task { private class PermissionInfoFetcher extends Task {
final @PermissionInfo.Type int mType; final @ContentSettingsType int mType;
public PermissionInfoFetcher(@PermissionInfo.Type int type) { public PermissionInfoFetcher(@ContentSettingsType int type) {
mType = type; mType = type;
} }
...@@ -345,7 +345,7 @@ public class WebsitePermissionsFetcher { ...@@ -345,7 +345,7 @@ public class WebsitePermissionsFetcher {
mWebsitePreferenceBridge.getPermissionInfo(mBrowserContextHandle, mType)) { mWebsitePreferenceBridge.getPermissionInfo(mBrowserContextHandle, mType)) {
String origin = info.getOrigin(); String origin = info.getOrigin();
if (origin == null) continue; if (origin == null) continue;
String embedder = mType == PermissionInfo.Type.SENSORS ? null : info.getEmbedder(); String embedder = mType == ContentSettingsType.SENSORS ? null : info.getEmbedder();
findOrCreateSite(origin, embedder).setPermissionInfo(info); findOrCreateSite(origin, embedder).setPermissionInfo(info);
} }
} }
......
...@@ -87,13 +87,9 @@ class WebsitePreference extends ChromeImageViewPreference { ...@@ -87,13 +87,9 @@ class WebsitePreference extends ChromeImageViewPreference {
setTitle(mSite.getTitle()); setTitle(mSite.getTitle());
if (mSite.getEmbedder() == null) { if (mSite.getEmbedder() == null) {
@PermissionInfo.Type PermissionInfo permissionInfo =
Integer permissionInfoType = mSite.getPermissionInfo(mCategory.getContentSettingsType());
PermissionInfo.getPermissionInfoType(mCategory.getContentSettingsType()); if (permissionInfo != null && permissionInfo.isEmbargoed()) {
PermissionInfo permissionInfo = null;
if (permissionInfoType != null
&& (permissionInfo = mSite.getPermissionInfo(permissionInfoType)) != null
&& permissionInfo.isEmbargoed()) {
setSummary(getContext().getString(R.string.automatically_blocked)); setSummary(getContext().getString(R.string.automatically_blocked));
} }
return; return;
......
...@@ -34,38 +34,38 @@ public class WebsitePreferenceBridge { ...@@ -34,38 +34,38 @@ public class WebsitePreferenceBridge {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<PermissionInfo> getPermissionInfo( public List<PermissionInfo> getPermissionInfo(
BrowserContextHandle browserContextHandle, @PermissionInfo.Type int type) { BrowserContextHandle browserContextHandle, @ContentSettingsType int type) {
ArrayList<PermissionInfo> list = new ArrayList<PermissionInfo>(); ArrayList<PermissionInfo> list = new ArrayList<PermissionInfo>();
// Camera, Location & Microphone can be managed by the custodian // Camera, Location & Microphone can be managed by the custodian
// of a supervised account or by enterprise policy. // of a supervised account or by enterprise policy.
if (type == PermissionInfo.Type.AUGMENTED_REALITY) { if (type == ContentSettingsType.AR) {
WebsitePreferenceBridgeJni.get().getArOrigins(browserContextHandle, list); WebsitePreferenceBridgeJni.get().getArOrigins(browserContextHandle, list);
} else if (type == PermissionInfo.Type.CAMERA) { } else if (type == ContentSettingsType.MEDIASTREAM_CAMERA) {
boolean managedOnly = !isCameraUserModifiable(browserContextHandle); boolean managedOnly = !isCameraUserModifiable(browserContextHandle);
WebsitePreferenceBridgeJni.get().getCameraOrigins( WebsitePreferenceBridgeJni.get().getCameraOrigins(
browserContextHandle, list, managedOnly); browserContextHandle, list, managedOnly);
} else if (type == PermissionInfo.Type.CLIPBOARD) { } else if (type == ContentSettingsType.CLIPBOARD_READ_WRITE) {
WebsitePreferenceBridgeJni.get().getClipboardOrigins(browserContextHandle, list); WebsitePreferenceBridgeJni.get().getClipboardOrigins(browserContextHandle, list);
} else if (type == PermissionInfo.Type.GEOLOCATION) { } else if (type == ContentSettingsType.GEOLOCATION) {
boolean managedOnly = !isAllowLocationUserModifiable(browserContextHandle); boolean managedOnly = !isAllowLocationUserModifiable(browserContextHandle);
WebsitePreferenceBridgeJni.get().getGeolocationOrigins( WebsitePreferenceBridgeJni.get().getGeolocationOrigins(
browserContextHandle, list, managedOnly); browserContextHandle, list, managedOnly);
} else if (type == PermissionInfo.Type.MICROPHONE) { } else if (type == ContentSettingsType.MEDIASTREAM_MIC) {
boolean managedOnly = !isMicUserModifiable(browserContextHandle); boolean managedOnly = !isMicUserModifiable(browserContextHandle);
WebsitePreferenceBridgeJni.get().getMicrophoneOrigins( WebsitePreferenceBridgeJni.get().getMicrophoneOrigins(
browserContextHandle, list, managedOnly); browserContextHandle, list, managedOnly);
} else if (type == PermissionInfo.Type.MIDI) { } else if (type == ContentSettingsType.MIDI_SYSEX) {
WebsitePreferenceBridgeJni.get().getMidiOrigins(browserContextHandle, list); WebsitePreferenceBridgeJni.get().getMidiOrigins(browserContextHandle, list);
} else if (type == PermissionInfo.Type.NFC) { } else if (type == ContentSettingsType.NFC) {
WebsitePreferenceBridgeJni.get().getNfcOrigins(browserContextHandle, list); WebsitePreferenceBridgeJni.get().getNfcOrigins(browserContextHandle, list);
} else if (type == PermissionInfo.Type.NOTIFICATION) { } else if (type == ContentSettingsType.NOTIFICATIONS) {
WebsitePreferenceBridgeJni.get().getNotificationOrigins(browserContextHandle, list); WebsitePreferenceBridgeJni.get().getNotificationOrigins(browserContextHandle, list);
} else if (type == PermissionInfo.Type.PROTECTED_MEDIA_IDENTIFIER) { } else if (type == ContentSettingsType.PROTECTED_MEDIA_IDENTIFIER) {
WebsitePreferenceBridgeJni.get().getProtectedMediaIdentifierOrigins( WebsitePreferenceBridgeJni.get().getProtectedMediaIdentifierOrigins(
browserContextHandle, list); browserContextHandle, list);
} else if (type == PermissionInfo.Type.SENSORS) { } else if (type == ContentSettingsType.SENSORS) {
WebsitePreferenceBridgeJni.get().getSensorsOrigins(browserContextHandle, list); WebsitePreferenceBridgeJni.get().getSensorsOrigins(browserContextHandle, list);
} else if (type == PermissionInfo.Type.VIRTUAL_REALITY) { } else if (type == ContentSettingsType.VR) {
WebsitePreferenceBridgeJni.get().getVrOrigins(browserContextHandle, list); WebsitePreferenceBridgeJni.get().getVrOrigins(browserContextHandle, list);
} else { } else {
assert false; assert false;
...@@ -73,9 +73,10 @@ public class WebsitePreferenceBridge { ...@@ -73,9 +73,10 @@ public class WebsitePreferenceBridge {
return list; return list;
} }
private static void insertInfoIntoList(@PermissionInfo.Type int type, private static void insertInfoIntoList(@ContentSettingsType int type,
ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) { ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
if (type == PermissionInfo.Type.CAMERA || type == PermissionInfo.Type.MICROPHONE) { if (type == ContentSettingsType.MEDIASTREAM_CAMERA
|| type == ContentSettingsType.MEDIASTREAM_MIC) {
for (PermissionInfo info : list) { for (PermissionInfo info : list) {
if (info.getOrigin().equals(origin) && info.getEmbedder().equals(embedder)) { if (info.getOrigin().equals(origin) && info.getEmbedder().equals(embedder)) {
return; return;
...@@ -88,63 +89,65 @@ public class WebsitePreferenceBridge { ...@@ -88,63 +89,65 @@ public class WebsitePreferenceBridge {
@CalledByNative @CalledByNative
private static void insertArInfoIntoList( private static void insertArInfoIntoList(
ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) { ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
insertInfoIntoList( insertInfoIntoList(ContentSettingsType.AR, list, origin, embedder, isEmbargoed);
PermissionInfo.Type.AUGMENTED_REALITY, list, origin, embedder, isEmbargoed);
} }
@CalledByNative @CalledByNative
private static void insertCameraInfoIntoList( private static void insertCameraInfoIntoList(
ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) { ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
insertInfoIntoList(PermissionInfo.Type.CAMERA, list, origin, embedder, isEmbargoed); insertInfoIntoList(
ContentSettingsType.MEDIASTREAM_CAMERA, list, origin, embedder, isEmbargoed);
} }
@CalledByNative @CalledByNative
private static void insertClipboardInfoIntoList( private static void insertClipboardInfoIntoList(
ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) { ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
insertInfoIntoList(PermissionInfo.Type.CLIPBOARD, list, origin, embedder, isEmbargoed); insertInfoIntoList(
ContentSettingsType.CLIPBOARD_READ_WRITE, list, origin, embedder, isEmbargoed);
} }
@CalledByNative @CalledByNative
private static void insertGeolocationInfoIntoList( private static void insertGeolocationInfoIntoList(
ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) { ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
insertInfoIntoList(PermissionInfo.Type.GEOLOCATION, list, origin, embedder, isEmbargoed); insertInfoIntoList(ContentSettingsType.GEOLOCATION, list, origin, embedder, isEmbargoed);
} }
@CalledByNative @CalledByNative
private static void insertMicrophoneInfoIntoList( private static void insertMicrophoneInfoIntoList(
ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) { ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
insertInfoIntoList(PermissionInfo.Type.MICROPHONE, list, origin, embedder, isEmbargoed); insertInfoIntoList(
ContentSettingsType.MEDIASTREAM_MIC, list, origin, embedder, isEmbargoed);
} }
@CalledByNative @CalledByNative
private static void insertMidiInfoIntoList( private static void insertMidiInfoIntoList(
ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) { ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
insertInfoIntoList(PermissionInfo.Type.MIDI, list, origin, embedder, isEmbargoed); insertInfoIntoList(ContentSettingsType.MIDI_SYSEX, list, origin, embedder, isEmbargoed);
} }
@CalledByNative @CalledByNative
private static void insertNfcInfoIntoList( private static void insertNfcInfoIntoList(
ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) { ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
insertInfoIntoList(PermissionInfo.Type.NFC, list, origin, embedder, isEmbargoed); insertInfoIntoList(ContentSettingsType.NFC, list, origin, embedder, isEmbargoed);
} }
@CalledByNative @CalledByNative
private static void insertNotificationIntoList( private static void insertNotificationIntoList(
ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) { ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
insertInfoIntoList(PermissionInfo.Type.NOTIFICATION, list, origin, embedder, isEmbargoed); insertInfoIntoList(ContentSettingsType.NOTIFICATIONS, list, origin, embedder, isEmbargoed);
} }
@CalledByNative @CalledByNative
private static void insertProtectedMediaIdentifierInfoIntoList( private static void insertProtectedMediaIdentifierInfoIntoList(
ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) { ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
insertInfoIntoList(PermissionInfo.Type.PROTECTED_MEDIA_IDENTIFIER, list, origin, embedder, insertInfoIntoList(ContentSettingsType.PROTECTED_MEDIA_IDENTIFIER, list, origin, embedder,
isEmbargoed); isEmbargoed);
} }
@CalledByNative @CalledByNative
private static void insertSensorsInfoIntoList( private static void insertSensorsInfoIntoList(
ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) { ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
insertInfoIntoList(PermissionInfo.Type.SENSORS, list, origin, embedder, isEmbargoed); insertInfoIntoList(ContentSettingsType.SENSORS, list, origin, embedder, isEmbargoed);
} }
@CalledByNative @CalledByNative
...@@ -156,8 +159,7 @@ public class WebsitePreferenceBridge { ...@@ -156,8 +159,7 @@ public class WebsitePreferenceBridge {
@CalledByNative @CalledByNative
private static void insertVrInfoIntoList( private static void insertVrInfoIntoList(
ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) { ArrayList<PermissionInfo> list, String origin, String embedder, boolean isEmbargoed) {
insertInfoIntoList( insertInfoIntoList(ContentSettingsType.VR, list, origin, embedder, isEmbargoed);
PermissionInfo.Type.VIRTUAL_REALITY, list, origin, embedder, isEmbargoed);
} }
@CalledByNative @CalledByNative
......
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