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 org.chromium.chrome.R; | 7 import org.chromium.chrome.R; |
| 8 import org.chromium.chrome.browser.ContentSettingsType; | 8 import org.chromium.chrome.browser.ContentSettingsType; |
| 9 | 9 |
| 10 /** | 10 /** |
| 11 * A class with utility functions that get the appropriate string and icon resou rces for the | 11 * A class with utility functions that get the appropriate string and icon resou rces for the |
| 12 * Android UI that allows managing content settings. | 12 * Android UI that allows managing content settings. |
| 13 */ | 13 */ |
| 14 public class ContentSettingsResources { | 14 public class ContentSettingsResources { |
| 15 /** | 15 /** |
| 16 * Returns the resource id of the icon for a content type. | 16 * Returns the resource id of the icon for a content type. |
| 17 */ | 17 */ |
| 18 public static int getIcon(int contentType) { | 18 public static int getIcon(int contentType) { |
| 19 switch (contentType) { | 19 switch (contentType) { |
| 20 case ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES: | 20 case ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES: |
| 21 return R.drawable.permission_cookie; | 21 return R.drawable.permission_cookie; |
| 22 case ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN: | 22 case ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN: |
| 23 return R.drawable.permission_fullscreen; | 23 return R.drawable.permission_fullscreen; |
| 24 case ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION: | 24 case ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 25 return R.drawable.permission_location; | 25 return R.drawable.permission_location; |
| 26 case ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT: | 26 case ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT: |
| 27 return R.drawable.permission_javascript; | 27 return R.drawable.permission_javascript; |
| 28 case ContentSettingsType.CONTENT_SETTINGS_TYPE_KEYGEN: | |
| 29 return R.drawable.permission_javascript; | |
| 28 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: | 30 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: |
| 29 return R.drawable.permission_camera; | 31 return R.drawable.permission_camera; |
| 30 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: | 32 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: |
| 31 return R.drawable.permission_mic; | 33 return R.drawable.permission_mic; |
| 32 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MIDI_SYSEX: | 34 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MIDI_SYSEX: |
| 33 return R.drawable.permission_midi; | 35 return R.drawable.permission_midi; |
| 34 case ContentSettingsType.CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 36 case ContentSettingsType.CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 35 return R.drawable.permission_push_notification; | 37 return R.drawable.permission_push_notification; |
| 36 case ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS: | 38 case ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS: |
| 37 return R.drawable.permission_popups; | 39 return R.drawable.permission_popups; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 49 public static int getTitle(int contentType) { | 51 public static int getTitle(int contentType) { |
| 50 switch (contentType) { | 52 switch (contentType) { |
| 51 case ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES: | 53 case ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES: |
| 52 return R.string.cookies_title; | 54 return R.string.cookies_title; |
| 53 case ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN: | 55 case ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN: |
| 54 return R.string.website_settings_fullscreen; | 56 return R.string.website_settings_fullscreen; |
| 55 case ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION: | 57 case ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 56 return R.string.website_settings_device_location; | 58 return R.string.website_settings_device_location; |
| 57 case ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT: | 59 case ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT: |
| 58 return R.string.javascript_permission_title; | 60 return R.string.javascript_permission_title; |
| 61 case ContentSettingsType.CONTENT_SETTINGS_TYPE_KEYGEN: | |
| 62 return R.string.keygen_permission_title; | |
| 59 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: | 63 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: |
| 60 return R.string.website_settings_use_camera; | 64 return R.string.website_settings_use_camera; |
| 61 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: | 65 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: |
| 62 return R.string.website_settings_use_mic; | 66 return R.string.website_settings_use_mic; |
| 63 case ContentSettingsType.CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 67 case ContentSettingsType.CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 64 return R.string.push_notifications_permission_title; | 68 return R.string.push_notifications_permission_title; |
| 65 case ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS: | 69 case ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS: |
| 66 return R.string.popup_permission_title; | 70 return R.string.popup_permission_title; |
| 67 case ContentSettingsType.CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENT IFIER: | 71 case ContentSettingsType.CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENT IFIER: |
| 68 return org.chromium.chrome.R.string.protected_content; | 72 return org.chromium.chrome.R.string.protected_content; |
| 69 default: | 73 default: |
| 70 return 0; | 74 return 0; |
| 71 } | 75 } |
| 72 } | 76 } |
| 73 | 77 |
| 74 /** | 78 /** |
| 75 * Returns the resource id of the title explanation, shown on the Website De tails page for | 79 * Returns the resource id of the title explanation, shown on the Website De tails page for |
| 76 * a content type. | 80 * a content type. |
| 77 */ | 81 */ |
| 78 public static int getExplanation(int contentType) { | 82 public static int getExplanation(int contentType) { |
| 79 switch (contentType) { | 83 switch (contentType) { |
| 80 case ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES: | 84 case ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES: |
| 81 return R.string.cookies_title; | 85 return R.string.cookies_title; |
| 82 case ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN: | 86 case ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN: |
| 83 return R.string.fullscreen_permission_title; | 87 return R.string.fullscreen_permission_title; |
| 84 case ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION: | 88 case ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 85 return R.string.geolocation_permission_title; | 89 return R.string.geolocation_permission_title; |
| 86 case ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT: | 90 case ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT: |
| 87 return R.string.javascript_permission_title; | 91 return R.string.javascript_permission_title; |
| 92 case ContentSettingsType.CONTENT_SETTINGS_TYPE_KEYGEN: | |
| 93 return R.string.keygen_permission_title; | |
| 88 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: | 94 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: |
| 89 return R.string.camera_permission_title; | 95 return R.string.camera_permission_title; |
| 90 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: | 96 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: |
| 91 return R.string.mic_permission_title; | 97 return R.string.mic_permission_title; |
| 92 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MIDI_SYSEX: | 98 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MIDI_SYSEX: |
| 93 return R.string.midi_sysex_permission_title; | 99 return R.string.midi_sysex_permission_title; |
| 94 case ContentSettingsType.CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 100 case ContentSettingsType.CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 95 return R.string.push_notifications_permission_title; | 101 return R.string.push_notifications_permission_title; |
| 96 case ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS: | 102 case ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS: |
| 97 return R.string.popup_permission_title; | 103 return R.string.popup_permission_title; |
| 98 default: | 104 default: |
| 99 return 0; | 105 return 0; |
| 100 } | 106 } |
| 101 } | 107 } |
| 102 | 108 |
| 103 /** | 109 /** |
| 104 * Returns which ContentSetting the global default is set to, when enabled. | 110 * Returns which ContentSetting the global default is set to, when enabled. |
| 105 * Either Ask/Allow. Not required unless this entry describes a settings | 111 * Either Ask/Allow. Not required unless this entry describes a settings |
| 106 * that appears on the Site Settings page and has a global toggle. | 112 * that appears on the Site Settings page and has a global toggle. |
| 107 */ | 113 */ |
| 108 public static ContentSetting getDefaultEnabledValue(int contentType) { | 114 public static ContentSetting getDefaultEnabledValue(int contentType) { |
| 109 switch (contentType) { | 115 switch (contentType) { |
| 110 case ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES: | 116 case ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES: |
| 111 case ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN: | 117 case ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN: |
| 112 case ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT: | 118 case ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT: |
| 119 case ContentSettingsType.CONTENT_SETTINGS_TYPE_KEYGEN: | |
|
Finnur
2015/11/05 20:44:41
If you only want to show the permission in site de
svaldez
2015/11/10 15:25:01
Done.
| |
| 113 case ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS: | 120 case ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS: |
| 114 return ContentSetting.ALLOW; | 121 return ContentSetting.ALLOW; |
| 115 case ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION: | 122 case ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 116 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: | 123 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: |
| 117 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: | 124 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: |
| 118 case ContentSettingsType.CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 125 case ContentSettingsType.CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 119 case ContentSettingsType.CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENT IFIER: | 126 case ContentSettingsType.CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENT IFIER: |
| 120 return ContentSetting.ASK; | 127 return ContentSetting.ASK; |
| 121 default: | 128 default: |
| 122 return null; | 129 return null; |
| 123 } | 130 } |
| 124 } | 131 } |
| 125 | 132 |
| 126 /** | 133 /** |
| 127 * Returns which ContentSetting the global default is set to, when disabled. | 134 * Returns which ContentSetting the global default is set to, when disabled. |
| 128 * Usually Block. Not required unless this entry describes a settings | 135 * Usually Block. Not required unless this entry describes a settings |
| 129 * that appears on the Site Settings page and has a global toggle. | 136 * that appears on the Site Settings page and has a global toggle. |
| 130 */ | 137 */ |
| 131 public static ContentSetting getDefaultDisabledValue(int contentType) { | 138 public static ContentSetting getDefaultDisabledValue(int contentType) { |
| 132 switch (contentType) { | 139 switch (contentType) { |
| 133 case ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN: | 140 case ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN: |
| 134 return ContentSetting.ASK; | 141 return ContentSetting.ASK; |
| 135 case ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES: | 142 case ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES: |
| 136 case ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION: | 143 case ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 137 case ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT: | 144 case ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT: |
| 145 case ContentSettingsType.CONTENT_SETTINGS_TYPE_KEYGEN: | |
|
Finnur
2015/11/05 20:44:41
Ditto.
svaldez
2015/11/10 15:25:02
Done.
| |
| 138 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: | 146 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: |
| 139 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: | 147 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: |
| 140 case ContentSettingsType.CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 148 case ContentSettingsType.CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 141 case ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS: | 149 case ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS: |
| 142 case ContentSettingsType.CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENT IFIER: | 150 case ContentSettingsType.CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENT IFIER: |
| 143 return ContentSetting.BLOCK; | 151 return ContentSetting.BLOCK; |
| 144 default: | 152 default: |
| 145 return null; | 153 return null; |
| 146 } | 154 } |
| 147 } | 155 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 } | 216 } |
| 209 } | 217 } |
| 210 | 218 |
| 211 /** | 219 /** |
| 212 * Returns the summary (resource id) to show when the content type is disabl ed. | 220 * Returns the summary (resource id) to show when the content type is disabl ed. |
| 213 */ | 221 */ |
| 214 public static int getDisabledSummary(int contentType) { | 222 public static int getDisabledSummary(int contentType) { |
| 215 switch (contentType) { | 223 switch (contentType) { |
| 216 case ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN: | 224 case ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN: |
| 217 return R.string.website_settings_category_ask_first_recommended; | 225 return R.string.website_settings_category_ask_first_recommended; |
| 226 case ContentSettingsType.CONTENT_SETTINGS_TYPE_KEYGEN: | |
|
Finnur
2015/11/05 20:44:41
Ditto (I think)...
svaldez
2015/11/10 15:25:02
Done.
| |
| 218 case ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS: | 227 case ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS: |
| 219 return R.string.website_settings_category_blocked_recommended; | 228 return R.string.website_settings_category_blocked_recommended; |
| 220 default: | 229 default: |
| 221 return getCategorySummary(getDefaultDisabledValue(contentType)); | 230 return getCategorySummary(getDefaultDisabledValue(contentType)); |
| 222 } | 231 } |
| 223 } | 232 } |
| 224 | 233 |
| 225 /** | 234 /** |
| 226 * Returns the summary for Geolocation content settings when it is set to 'A llow' (by policy). | 235 * Returns the summary for Geolocation content settings when it is set to 'A llow' (by policy). |
| 227 */ | 236 */ |
| 228 public static int getGeolocationAllowedSummary() { | 237 public static int getGeolocationAllowedSummary() { |
| 229 return R.string.website_settings_category_allowed; | 238 return R.string.website_settings_category_allowed; |
| 230 } | 239 } |
| 231 | 240 |
| 232 /** | 241 /** |
| 233 * Returns the summary for Cookie content settings when it is allowed | 242 * Returns the summary for Cookie content settings when it is allowed |
| 234 * except for those from third party sources. | 243 * except for those from third party sources. |
| 235 */ | 244 */ |
| 236 public static int getCookieAllowedExceptThirdPartySummary() { | 245 public static int getCookieAllowedExceptThirdPartySummary() { |
| 237 return R.string.website_settings_category_allowed_except_third_party; | 246 return R.string.website_settings_category_allowed_except_third_party; |
| 238 } | 247 } |
| 239 } | 248 } |
| OLD | NEW |