Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.preferences.website; | 5 package org.chromium.chrome.browser.preferences.website; |
| 6 | 6 |
| 7 import android.os.Build; | 7 import android.os.Build; |
| 8 import android.os.Bundle; | 8 import android.os.Bundle; |
| 9 import android.preference.Preference; | 9 import android.preference.Preference; |
| 10 import android.preference.Preference.OnPreferenceClickListener; | 10 import android.preference.Preference.OnPreferenceClickListener; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 public class SiteSettingsPreferences extends PreferenceFragment | 27 public class SiteSettingsPreferences extends PreferenceFragment |
| 28 implements OnPreferenceClickListener { | 28 implements OnPreferenceClickListener { |
| 29 // The keys for each category shown on the Site Settings page. | 29 // The keys for each category shown on the Site Settings page. |
| 30 static final String ALL_SITES_KEY = "all_sites"; | 30 static final String ALL_SITES_KEY = "all_sites"; |
| 31 static final String CAMERA_KEY = "camera"; | 31 static final String CAMERA_KEY = "camera"; |
| 32 static final String COOKIES_KEY = "cookies"; | 32 static final String COOKIES_KEY = "cookies"; |
| 33 static final String FULLSCREEN_KEY = "fullscreen"; | 33 static final String FULLSCREEN_KEY = "fullscreen"; |
| 34 static final String LOCATION_KEY = "device_location"; | 34 static final String LOCATION_KEY = "device_location"; |
| 35 static final String MICROPHONE_KEY = "microphone"; | 35 static final String MICROPHONE_KEY = "microphone"; |
| 36 static final String JAVASCRIPT_KEY = "javascript"; | 36 static final String JAVASCRIPT_KEY = "javascript"; |
| 37 static final String KEYGEN_KEY = "keygen"; | |
| 37 static final String BLOCK_POPUPS_KEY = "block_popups"; | 38 static final String BLOCK_POPUPS_KEY = "block_popups"; |
| 38 static final String NOTIFICATIONS_KEY = "notifications"; | 39 static final String NOTIFICATIONS_KEY = "notifications"; |
| 39 static final String POPUPS_KEY = "popups"; | 40 static final String POPUPS_KEY = "popups"; |
| 40 static final String PROTECTED_CONTENT_KEY = "protected_content"; | 41 static final String PROTECTED_CONTENT_KEY = "protected_content"; |
| 41 static final String STORAGE_KEY = "use_storage"; | 42 static final String STORAGE_KEY = "use_storage"; |
| 42 | 43 |
| 43 @Override | 44 @Override |
| 44 public void onCreate(Bundle savedInstanceState) { | 45 public void onCreate(Bundle savedInstanceState) { |
| 45 super.onCreate(savedInstanceState); | 46 super.onCreate(savedInstanceState); |
| 46 addPreferencesFromResource(R.xml.site_settings_preferences); | 47 addPreferencesFromResource(R.xml.site_settings_preferences); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 59 } else if (COOKIES_KEY.equals(key)) { | 60 } else if (COOKIES_KEY.equals(key)) { |
| 60 return ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES; | 61 return ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES; |
| 61 } else if (FULLSCREEN_KEY.equals(key)) { | 62 } else if (FULLSCREEN_KEY.equals(key)) { |
| 62 return ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN; | 63 return ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN; |
| 63 } else if (LOCATION_KEY.equals(key)) { | 64 } else if (LOCATION_KEY.equals(key)) { |
| 64 return ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION; | 65 return ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION; |
| 65 } else if (MICROPHONE_KEY.equals(key)) { | 66 } else if (MICROPHONE_KEY.equals(key)) { |
| 66 return ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC; | 67 return ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC; |
| 67 } else if (JAVASCRIPT_KEY.equals(key)) { | 68 } else if (JAVASCRIPT_KEY.equals(key)) { |
| 68 return ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT; | 69 return ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT; |
| 70 } else if (KEYGEN_KEY.equals(key)) { | |
| 71 return ContentSettingsType.CONTENT_SETTINGS_TYPE_KEYGEN; | |
| 69 } else if (NOTIFICATIONS_KEY.equals(key)) { | 72 } else if (NOTIFICATIONS_KEY.equals(key)) { |
| 70 return ContentSettingsType.CONTENT_SETTINGS_TYPE_NOTIFICATIONS; | 73 return ContentSettingsType.CONTENT_SETTINGS_TYPE_NOTIFICATIONS; |
| 71 } else if (POPUPS_KEY.equals(key)) { | 74 } else if (POPUPS_KEY.equals(key)) { |
| 72 return ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS; | 75 return ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS; |
| 73 } else if (PROTECTED_CONTENT_KEY.equals(key)) { | 76 } else if (PROTECTED_CONTENT_KEY.equals(key)) { |
| 74 return ContentSettingsType.CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDE NTIFIER; | 77 return ContentSettingsType.CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDE NTIFIER; |
| 75 } | 78 } |
| 76 return -1; | 79 return -1; |
| 77 } | 80 } |
| 78 | 81 |
| 79 private void updatePreferenceStates() { | 82 private void updatePreferenceStates() { |
| 80 PrefServiceBridge prefServiceBridge = PrefServiceBridge.getInstance(); | 83 PrefServiceBridge prefServiceBridge = PrefServiceBridge.getInstance(); |
| 81 | 84 |
| 82 // Preferences that navigate to Website Settings. | 85 // Preferences that navigate to Website Settings. |
| 83 List<String> websitePrefs = new ArrayList<String>(); | 86 List<String> websitePrefs = new ArrayList<String>(); |
| 84 websitePrefs.add(LOCATION_KEY); | 87 websitePrefs.add(LOCATION_KEY); |
| 85 if (Build.VERSION.SDK_INT >= 19) { | 88 if (Build.VERSION.SDK_INT >= 19) { |
| 86 websitePrefs.add(PROTECTED_CONTENT_KEY); | 89 websitePrefs.add(PROTECTED_CONTENT_KEY); |
| 87 } | 90 } |
| 88 websitePrefs.add(COOKIES_KEY); | 91 websitePrefs.add(COOKIES_KEY); |
| 89 websitePrefs.add(CAMERA_KEY); | 92 websitePrefs.add(CAMERA_KEY); |
| 90 websitePrefs.add(FULLSCREEN_KEY); | 93 websitePrefs.add(FULLSCREEN_KEY); |
| 91 websitePrefs.add(JAVASCRIPT_KEY); | 94 websitePrefs.add(JAVASCRIPT_KEY); |
| 95 websitePrefs.add(KEYGEN_KEY); | |
| 92 websitePrefs.add(MICROPHONE_KEY); | 96 websitePrefs.add(MICROPHONE_KEY); |
| 93 websitePrefs.add(NOTIFICATIONS_KEY); | 97 websitePrefs.add(NOTIFICATIONS_KEY); |
| 94 websitePrefs.add(POPUPS_KEY); | 98 websitePrefs.add(POPUPS_KEY); |
| 95 // Initialize the summary and icon for all preferences that have an | 99 // Initialize the summary and icon for all preferences that have an |
| 96 // associated content settings entry. | 100 // associated content settings entry. |
| 97 for (String prefName : websitePrefs) { | 101 for (String prefName : websitePrefs) { |
| 98 Preference p = findPreference(prefName); | 102 Preference p = findPreference(prefName); |
| 99 boolean checked = false; | 103 boolean checked = false; |
| 100 if (LOCATION_KEY.equals(prefName)) { | 104 if (LOCATION_KEY.equals(prefName)) { |
| 101 checked = LocationSettings.getInstance().areAllLocationSettingsE nabled(); | 105 checked = LocationSettings.getInstance().areAllLocationSettingsE nabled(); |
| 102 } else if (CAMERA_KEY.equals(prefName)) { | 106 } else if (CAMERA_KEY.equals(prefName)) { |
| 103 checked = PrefServiceBridge.getInstance().isCameraEnabled(); | 107 checked = PrefServiceBridge.getInstance().isCameraEnabled(); |
| 104 } else if (JAVASCRIPT_KEY.equals(prefName)) { | 108 } else if (JAVASCRIPT_KEY.equals(prefName)) { |
| 105 checked = PrefServiceBridge.getInstance().javaScriptEnabled(); | 109 checked = PrefServiceBridge.getInstance().javaScriptEnabled(); |
| 110 } else if (KEYGEN_KEY.equals(prefName)) { | |
| 111 checked = PrefServiceBridge.getInstance().keygenEnabled(); | |
|
Finnur
2015/11/05 20:44:41
I don't think you need any of these changes either
svaldez
2015/11/10 15:25:02
Done.
| |
| 106 } else if (MICROPHONE_KEY.equals(prefName)) { | 112 } else if (MICROPHONE_KEY.equals(prefName)) { |
| 107 checked = PrefServiceBridge.getInstance().isMicEnabled(); | 113 checked = PrefServiceBridge.getInstance().isMicEnabled(); |
| 108 } else if (PROTECTED_CONTENT_KEY.equals(prefName)) { | 114 } else if (PROTECTED_CONTENT_KEY.equals(prefName)) { |
| 109 checked = PrefServiceBridge.getInstance().isProtectedMediaIdenti fierEnabled(); | 115 checked = PrefServiceBridge.getInstance().isProtectedMediaIdenti fierEnabled(); |
| 110 } else if (COOKIES_KEY.equals(prefName)) { | 116 } else if (COOKIES_KEY.equals(prefName)) { |
| 111 checked = PrefServiceBridge.getInstance().isAcceptCookiesEnabled (); | 117 checked = PrefServiceBridge.getInstance().isAcceptCookiesEnabled (); |
| 112 } else if (NOTIFICATIONS_KEY.equals(prefName)) { | 118 } else if (NOTIFICATIONS_KEY.equals(prefName)) { |
| 113 checked = PrefServiceBridge.getInstance().isPushNotificationsEna bled(); | 119 checked = PrefServiceBridge.getInstance().isPushNotificationsEna bled(); |
| 114 } else if (POPUPS_KEY.equals(prefName)) { | 120 } else if (POPUPS_KEY.equals(prefName)) { |
| 115 checked = PrefServiceBridge.getInstance().popupsEnabled(); | 121 checked = PrefServiceBridge.getInstance().popupsEnabled(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 | 154 |
| 149 @Override | 155 @Override |
| 150 public boolean onPreferenceClick(Preference preference) { | 156 public boolean onPreferenceClick(Preference preference) { |
| 151 preference.getExtras().putString( | 157 preference.getExtras().putString( |
| 152 SingleCategoryPreferences.EXTRA_CATEGORY, preference.getKey()); | 158 SingleCategoryPreferences.EXTRA_CATEGORY, preference.getKey()); |
| 153 preference.getExtras().putString(SingleCategoryPreferences.EXTRA_TITLE, | 159 preference.getExtras().putString(SingleCategoryPreferences.EXTRA_TITLE, |
| 154 preference.getTitle().toString()); | 160 preference.getTitle().toString()); |
| 155 return false; | 161 return false; |
| 156 } | 162 } |
| 157 } | 163 } |
| OLD | NEW |