| Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleWebsitePreferences.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleWebsitePreferences.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleWebsitePreferences.java
|
| index 807fb6e23162617af36407926fc5a448efdfd17d..31bd7c056e943f05e2eed2ea75b0ad16b174b1fa 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleWebsitePreferences.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleWebsitePreferences.java
|
| @@ -52,33 +52,34 @@ public class SingleWebsitePreferences extends PreferenceFragment
|
| // Buttons:
|
| public static final String PREF_RESET_SITE = "reset_site_button";
|
| // Website permissions (if adding new, see hasPermissionsPreferences and resetSite below):
|
| + public static final String PREF_CAMERA_CAPTURE_PERMISSION = "camera_permission_list";
|
| public static final String PREF_COOKIES_PERMISSION = "cookies_permission_list";
|
| public static final String PREF_FULLSCREEN_PERMISSION = "fullscreen_permission_list";
|
| public static final String PREF_IMAGES_PERMISSION = "images_permission_list";
|
| public static final String PREF_JAVASCRIPT_PERMISSION = "javascript_permission_list";
|
| public static final String PREF_LOCATION_ACCESS = "location_access_list";
|
| + public static final String PREF_MIC_CAPTURE_PERMISSION = "microphone_permission_list";
|
| public static final String PREF_MIDI_SYSEX_PERMISSION = "midi_sysex_permission_list";
|
| public static final String PREF_POPUP_PERMISSION = "popup_permission_list";
|
| public static final String PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION =
|
| "protected_media_identifier_permission_list";
|
| public static final String PREF_PUSH_NOTIFICATIONS_PERMISSION =
|
| "push_notifications_list";
|
| - public static final String PREF_VOICE_AND_VIDEO_CAPTURE_PERMISSION =
|
| - "voice_and_video_capture_permission_list";
|
|
|
| // All permissions from the permissions preference category must be listed here.
|
| // TODO(mvanouwerkerk): Use this array in more places to reduce verbosity.
|
| private static final String[] PERMISSION_PREFERENCE_KEYS = {
|
| + PREF_CAMERA_CAPTURE_PERMISSION,
|
| PREF_COOKIES_PERMISSION,
|
| PREF_FULLSCREEN_PERMISSION,
|
| PREF_IMAGES_PERMISSION,
|
| PREF_JAVASCRIPT_PERMISSION,
|
| PREF_LOCATION_ACCESS,
|
| + PREF_MIC_CAPTURE_PERMISSION,
|
| PREF_MIDI_SYSEX_PERMISSION,
|
| PREF_POPUP_PERMISSION,
|
| PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION,
|
| PREF_PUSH_NOTIFICATIONS_PERMISSION,
|
| - PREF_VOICE_AND_VIDEO_CAPTURE_PERMISSION
|
| };
|
|
|
| // The website this page is displaying details about.
|
| @@ -195,13 +196,18 @@ public class SingleWebsitePreferences extends PreferenceFragment
|
| other.getPushNotificationInfo(), origin)) {
|
| merged.setPushNotificationInfo(other.getPushNotificationInfo());
|
| }
|
| - if (merged.getVoiceAndVideoCaptureInfo() == null
|
| - && other.getVoiceAndVideoCaptureInfo() != null) {
|
| - if (origin.equals(other.getVoiceAndVideoCaptureInfo().getOrigin())
|
| - && (origin.equals(other.getVoiceAndVideoCaptureInfo().getEmbedderSafe())
|
| - || "*".equals(other.getVoiceAndVideoCaptureInfo()
|
| - .getEmbedderSafe()))) {
|
| - merged.setVoiceAndVideoCaptureInfo(other.getVoiceAndVideoCaptureInfo());
|
| + if (merged.getCameraInfo() == null && other.getCameraInfo() != null) {
|
| + if (origin.equals(other.getCameraInfo().getOrigin())
|
| + && (origin.equals(other.getCameraInfo().getEmbedderSafe())
|
| + || "*".equals(other.getCameraInfo().getEmbedderSafe()))) {
|
| + merged.setCameraInfo(other.getCameraInfo());
|
| + }
|
| + }
|
| + if (merged.getMicrophoneInfo() == null && other.getMicrophoneInfo() != null) {
|
| + if (origin.equals(other.getMicrophoneInfo().getOrigin())
|
| + && (origin.equals(other.getMicrophoneInfo().getEmbedderSafe())
|
| + || "*".equals(other.getMicrophoneInfo().getEmbedderSafe()))) {
|
| + merged.setMicrophoneInfo(other.getMicrophoneInfo());
|
| }
|
| }
|
| if (merged.getLocalStorageInfo() == null
|
| @@ -259,6 +265,8 @@ public class SingleWebsitePreferences extends PreferenceFragment
|
| }
|
| } else if (PREF_RESET_SITE.equals(preference.getKey())) {
|
| preference.setOnPreferenceClickListener(this);
|
| + } else if (PREF_CAMERA_CAPTURE_PERMISSION.equals(preference.getKey())) {
|
| + setUpListPreference(preference, mSite.getCameraPermission());
|
| } else if (PREF_COOKIES_PERMISSION.equals(preference.getKey())) {
|
| setUpListPreference(preference, mSite.getCookiePermission());
|
| } else if (PREF_FULLSCREEN_PERMISSION.equals(preference.getKey())) {
|
| @@ -269,6 +277,8 @@ public class SingleWebsitePreferences extends PreferenceFragment
|
| setUpListPreference(preference, mSite.getJavaScriptPermission());
|
| } else if (PREF_LOCATION_ACCESS.equals(preference.getKey())) {
|
| setUpListPreference(preference, mSite.getGeolocationPermission());
|
| + } else if (PREF_MIC_CAPTURE_PERMISSION.equals(preference.getKey())) {
|
| + setUpListPreference(preference, mSite.getMicrophonePermission());
|
| } else if (PREF_MIDI_SYSEX_PERMISSION.equals(preference.getKey())) {
|
| setUpListPreference(preference, mSite.getMidiPermission());
|
| } else if (PREF_POPUP_PERMISSION.equals(preference.getKey())) {
|
| @@ -277,8 +287,6 @@ public class SingleWebsitePreferences extends PreferenceFragment
|
| setUpListPreference(preference, mSite.getProtectedMediaIdentifierPermission());
|
| } else if (PREF_PUSH_NOTIFICATIONS_PERMISSION.equals(preference.getKey())) {
|
| setUpListPreference(preference, mSite.getPushNotificationPermission());
|
| - } else if (PREF_VOICE_AND_VIDEO_CAPTURE_PERMISSION.equals(preference.getKey())) {
|
| - configureVoiceAndVideoPreference(preference);
|
| }
|
| }
|
|
|
| @@ -346,6 +354,8 @@ public class SingleWebsitePreferences extends PreferenceFragment
|
|
|
| private int getContentSettingsTypeFromPreferenceKey(String preferenceKey) {
|
| switch (preferenceKey) {
|
| + case PREF_CAMERA_CAPTURE_PERMISSION:
|
| + return ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA;
|
| case PREF_COOKIES_PERMISSION:
|
| return ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES;
|
| case PREF_FULLSCREEN_PERMISSION:
|
| @@ -356,6 +366,8 @@ public class SingleWebsitePreferences extends PreferenceFragment
|
| return ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT;
|
| case PREF_LOCATION_ACCESS:
|
| return ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION;
|
| + case PREF_MIC_CAPTURE_PERMISSION:
|
| + return ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC;
|
| case PREF_MIDI_SYSEX_PERMISSION:
|
| return ContentSettingsType.CONTENT_SETTINGS_TYPE_MIDI_SYSEX;
|
| case PREF_POPUP_PERMISSION:
|
| @@ -364,53 +376,11 @@ public class SingleWebsitePreferences extends PreferenceFragment
|
| return ContentSettingsType.CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER;
|
| case PREF_PUSH_NOTIFICATIONS_PERMISSION:
|
| return ContentSettingsType.CONTENT_SETTINGS_TYPE_NOTIFICATIONS;
|
| - case PREF_VOICE_AND_VIDEO_CAPTURE_PERMISSION:
|
| - return ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM;
|
| default:
|
| return 0;
|
| }
|
| }
|
|
|
| - /**
|
| - * Based on the type of media allowed or denied for this website, the title and summary
|
| - * of the CheckBoxPreference will change. If this website has no media related permission, then
|
| - * the preference will be removed.
|
| - * @param preference CheckboxPreference whose title and summary will be set.
|
| - */
|
| - private void configureVoiceAndVideoPreference(Preference preference) {
|
| - ContentSetting voice = mSite.getVoiceCapturePermission();
|
| - ContentSetting video = mSite.getVideoCapturePermission();
|
| - if (voice == null && video == null) {
|
| - getPreferenceScreen().removePreference(preference);
|
| - return;
|
| - }
|
| -
|
| - int mediaAccessType = mSite.getMediaAccessType();
|
| - switch (mediaAccessType) {
|
| - case Website.CAMERA_ACCESS_ALLOWED:
|
| - case Website.CAMERA_ACCESS_DENIED:
|
| - preference.setTitle(R.string.video_permission_title);
|
| - break;
|
| - case Website.MICROPHONE_ACCESS_ALLOWED:
|
| - case Website.MICROPHONE_ACCESS_DENIED:
|
| - preference.setTitle(R.string.voice_permission_title);
|
| - break;
|
| - case Website.MICROPHONE_AND_CAMERA_ACCESS_ALLOWED:
|
| - case Website.MICROPHONE_AND_CAMERA_ACCESS_DENIED:
|
| - preference.setTitle(R.string.voice_and_video_permission_title);
|
| - break;
|
| - case Website.INVALID_CAMERA_OR_MICROPHONE_ACCESS:
|
| - default:
|
| - getPreferenceScreen().removePreference(preference);
|
| - }
|
| - setUpListPreference(
|
| - preference, mediaAccessType == Website.CAMERA_ACCESS_ALLOWED
|
| - || mediaAccessType == Website.MICROPHONE_ACCESS_ALLOWED
|
| - || mediaAccessType == Website.MICROPHONE_AND_CAMERA_ACCESS_ALLOWED
|
| - ? ContentSetting.ALLOW :
|
| - ContentSetting.BLOCK);
|
| - }
|
| -
|
| @Override
|
| public void onClick(DialogInterface dialog, int which) {
|
| clearStoredData();
|
| @@ -439,46 +409,13 @@ public class SingleWebsitePreferences extends PreferenceFragment
|
| }
|
| }
|
|
|
| - private void setVoiceAndVideoCaptureSetting(ContentSetting value) {
|
| - int mediaAccessType = mSite.getMediaAccessType();
|
| - if (value == ContentSetting.ALLOW) {
|
| - switch (mediaAccessType) {
|
| - case Website.CAMERA_ACCESS_DENIED:
|
| - mSite.setVideoCapturePermission(ContentSetting.ALLOW);
|
| - break;
|
| - case Website.MICROPHONE_ACCESS_DENIED:
|
| - mSite.setVoiceCapturePermission(ContentSetting.ALLOW);
|
| - break;
|
| - case Website.MICROPHONE_AND_CAMERA_ACCESS_DENIED:
|
| - mSite.setVideoCapturePermission(ContentSetting.ALLOW);
|
| - mSite.setVoiceCapturePermission(ContentSetting.ALLOW);
|
| - break;
|
| - default:
|
| - assert false;
|
| - }
|
| - } else {
|
| - switch (mediaAccessType) {
|
| - case Website.CAMERA_ACCESS_ALLOWED:
|
| - mSite.setVideoCapturePermission(ContentSetting.BLOCK);
|
| - break;
|
| - case Website.MICROPHONE_ACCESS_ALLOWED:
|
| - mSite.setVoiceCapturePermission(ContentSetting.BLOCK);
|
| - break;
|
| - case Website.MICROPHONE_AND_CAMERA_ACCESS_ALLOWED:
|
| - mSite.setVideoCapturePermission(ContentSetting.BLOCK);
|
| - mSite.setVoiceCapturePermission(ContentSetting.BLOCK);
|
| - break;
|
| - default:
|
| - assert false;
|
| - }
|
| - }
|
| - }
|
| -
|
| @Override
|
| public boolean onPreferenceChange(Preference preference, Object newValue) {
|
| ContentSetting permission =
|
| ContentSetting.fromString((String) newValue);
|
| - if (PREF_COOKIES_PERMISSION.equals(preference.getKey())) {
|
| + if (PREF_CAMERA_CAPTURE_PERMISSION.equals(preference.getKey())) {
|
| + mSite.setCameraPermission(permission);
|
| + } else if (PREF_COOKIES_PERMISSION.equals(preference.getKey())) {
|
| mSite.setCookiePermission(permission);
|
| } else if (PREF_FULLSCREEN_PERMISSION.equals(preference.getKey())) {
|
| mSite.setFullscreenPermission(permission);
|
| @@ -488,6 +425,8 @@ public class SingleWebsitePreferences extends PreferenceFragment
|
| mSite.setJavaScriptPermission(permission);
|
| } else if (PREF_LOCATION_ACCESS.equals(preference.getKey())) {
|
| mSite.setGeolocationPermission(permission);
|
| + } else if (PREF_MIC_CAPTURE_PERMISSION.equals(preference.getKey())) {
|
| + mSite.setMicrophonePermission(permission);
|
| } else if (PREF_MIDI_SYSEX_PERMISSION.equals(preference.getKey())) {
|
| mSite.setMidiPermission(permission);
|
| } else if (PREF_POPUP_PERMISSION.equals(preference.getKey())) {
|
| @@ -496,8 +435,6 @@ public class SingleWebsitePreferences extends PreferenceFragment
|
| mSite.setProtectedMediaIdentifierPermission(permission);
|
| } else if (PREF_PUSH_NOTIFICATIONS_PERMISSION.equals(preference.getKey())) {
|
| mSite.setPushNotificationPermission(permission);
|
| - } else if (PREF_VOICE_AND_VIDEO_CAPTURE_PERMISSION.equals(preference.getKey())) {
|
| - setVoiceAndVideoCaptureSetting(permission);
|
| } else {
|
| return true;
|
| }
|
| @@ -536,18 +473,18 @@ public class SingleWebsitePreferences extends PreferenceFragment
|
| }
|
|
|
| // Clear the permissions.
|
| + mSite.setCameraPermission(null);
|
| mSite.setCookiePermission(null);
|
| WebsitePreferenceBridge.nativeClearCookieData(mSite.getAddress().getOrigin());
|
| mSite.setFullscreenPermission(null);
|
| mSite.setGeolocationPermission(null);
|
| mSite.setImagesPermission(null);
|
| mSite.setJavaScriptPermission(null);
|
| + mSite.setMicrophonePermission(null);
|
| mSite.setMidiPermission(null);
|
| mSite.setPopupPermission(null);
|
| mSite.setProtectedMediaIdentifierPermission(null);
|
| mSite.setPushNotificationPermission(null);
|
| - mSite.setVideoCapturePermission(null);
|
| - mSite.setVoiceCapturePermission(null);
|
|
|
| // Clear the storage and finish the activity if necessary.
|
| if (mSite.getTotalUsage() > 0) {
|
|
|