Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleWebsitePreferences.java

Issue 1432573002: Adding <keygen> Content Setting (Android UI) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@keygen_ui
Patch Set: Fixing android typos. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.content.Context; 7 import android.content.Context;
8 import android.content.DialogInterface; 8 import android.content.DialogInterface;
9 import android.content.res.Resources; 9 import android.content.res.Resources;
10 import android.graphics.PorterDuff; 10 import android.graphics.PorterDuff;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 "os_permissions_warning_divider"; 63 "os_permissions_warning_divider";
64 // Actions at the top (if adding new, see hasUsagePreferences below): 64 // Actions at the top (if adding new, see hasUsagePreferences below):
65 public static final String PREF_CLEAR_DATA = "clear_data"; 65 public static final String PREF_CLEAR_DATA = "clear_data";
66 // Buttons: 66 // Buttons:
67 public static final String PREF_RESET_SITE = "reset_site_button"; 67 public static final String PREF_RESET_SITE = "reset_site_button";
68 // Website permissions (if adding new, see hasPermissionsPreferences and res etSite below): 68 // Website permissions (if adding new, see hasPermissionsPreferences and res etSite below):
69 public static final String PREF_CAMERA_CAPTURE_PERMISSION = "camera_permissi on_list"; 69 public static final String PREF_CAMERA_CAPTURE_PERMISSION = "camera_permissi on_list";
70 public static final String PREF_COOKIES_PERMISSION = "cookies_permission_lis t"; 70 public static final String PREF_COOKIES_PERMISSION = "cookies_permission_lis t";
71 public static final String PREF_FULLSCREEN_PERMISSION = "fullscreen_permissi on_list"; 71 public static final String PREF_FULLSCREEN_PERMISSION = "fullscreen_permissi on_list";
72 public static final String PREF_JAVASCRIPT_PERMISSION = "javascript_permissi on_list"; 72 public static final String PREF_JAVASCRIPT_PERMISSION = "javascript_permissi on_list";
73 public static final String PREF_KEYGEN_PERMISSION = "keygen_permission_list" ;
73 public static final String PREF_LOCATION_ACCESS = "location_access_list"; 74 public static final String PREF_LOCATION_ACCESS = "location_access_list";
74 public static final String PREF_MIC_CAPTURE_PERMISSION = "microphone_permiss ion_list"; 75 public static final String PREF_MIC_CAPTURE_PERMISSION = "microphone_permiss ion_list";
75 public static final String PREF_MIDI_SYSEX_PERMISSION = "midi_sysex_permissi on_list"; 76 public static final String PREF_MIDI_SYSEX_PERMISSION = "midi_sysex_permissi on_list";
76 public static final String PREF_POPUP_PERMISSION = "popup_permission_list"; 77 public static final String PREF_POPUP_PERMISSION = "popup_permission_list";
77 public static final String PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION = 78 public static final String PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION =
78 "protected_media_identifier_permission_list"; 79 "protected_media_identifier_permission_list";
79 public static final String PREF_PUSH_NOTIFICATIONS_PERMISSION = 80 public static final String PREF_PUSH_NOTIFICATIONS_PERMISSION =
80 "push_notifications_list"; 81 "push_notifications_list";
81 82
82 // All permissions from the permissions preference category must be listed h ere. 83 // All permissions from the permissions preference category must be listed h ere.
83 // TODO(mvanouwerkerk): Use this array in more places to reduce verbosity. 84 // TODO(mvanouwerkerk): Use this array in more places to reduce verbosity.
84 private static final String[] PERMISSION_PREFERENCE_KEYS = { 85 private static final String[] PERMISSION_PREFERENCE_KEYS = {
85 PREF_CAMERA_CAPTURE_PERMISSION, 86 PREF_CAMERA_CAPTURE_PERMISSION, PREF_COOKIES_PERMISSION, PREF_FULLSC REEN_PERMISSION,
86 PREF_COOKIES_PERMISSION, 87 PREF_JAVASCRIPT_PERMISSION, PREF_KEYGEN_PERMISSION, PREF_LOCATION_AC CESS,
87 PREF_FULLSCREEN_PERMISSION, 88 PREF_MIC_CAPTURE_PERMISSION, PREF_MIDI_SYSEX_PERMISSION, PREF_POPUP_ PERMISSION,
88 PREF_JAVASCRIPT_PERMISSION, 89 PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION, PREF_PUSH_NOTIFICATIONS_ PERMISSION,
Finnur 2015/12/11 17:53:05 Was this done by the git format command? I think t
svaldez 2015/12/11 18:13:10 Done.
89 PREF_LOCATION_ACCESS,
90 PREF_MIC_CAPTURE_PERMISSION,
91 PREF_MIDI_SYSEX_PERMISSION,
92 PREF_POPUP_PERMISSION,
93 PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION,
94 PREF_PUSH_NOTIFICATIONS_PERMISSION,
95 }; 90 };
96 91
97 // The website this page is displaying details about. 92 // The website this page is displaying details about.
98 private Website mSite; 93 private Website mSite;
99 94
100 // The address of the site we want to display. Used only if EXTRA_ADDRESS is provided. 95 // The address of the site we want to display. Used only if EXTRA_ADDRESS is provided.
101 private WebsiteAddress mSiteAddress; 96 private WebsiteAddress mSiteAddress;
102 97
103 private class SingleWebsitePermissionsPopulator 98 private class SingleWebsitePermissionsPopulator
104 implements WebsitePermissionsFetcher.WebsitePermissionsCallback { 99 implements WebsitePermissionsFetcher.WebsitePermissionsCallback {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 merged.setCookieInfo(other.getCookieInfo()); 181 merged.setCookieInfo(other.getCookieInfo());
187 } 182 }
188 if (merged.getFullscreenInfo() == null && other.getFullscreenInf o() != null 183 if (merged.getFullscreenInfo() == null && other.getFullscreenInf o() != null
189 && permissionInfoIsForTopLevelOrigin(other.getFullscreen Info(), origin)) { 184 && permissionInfoIsForTopLevelOrigin(other.getFullscreen Info(), origin)) {
190 merged.setFullscreenInfo(other.getFullscreenInfo()); 185 merged.setFullscreenInfo(other.getFullscreenInfo());
191 } 186 }
192 if (merged.getGeolocationInfo() == null && other.getGeolocationI nfo() != null 187 if (merged.getGeolocationInfo() == null && other.getGeolocationI nfo() != null
193 && permissionInfoIsForTopLevelOrigin(other.getGeolocatio nInfo(), origin)) { 188 && permissionInfoIsForTopLevelOrigin(other.getGeolocatio nInfo(), origin)) {
194 merged.setGeolocationInfo(other.getGeolocationInfo()); 189 merged.setGeolocationInfo(other.getGeolocationInfo());
195 } 190 }
191 if (merged.getKeygenInfo() == null && other.getKeygenInfo() != n ull
192 && permissionInfoIsForTopLevelOrigin(other.getKeygenInfo (), origin)) {
193 merged.setKeygenInfo(other.getKeygenInfo());
194 }
196 if (merged.getMidiInfo() == null && other.getMidiInfo() != null 195 if (merged.getMidiInfo() == null && other.getMidiInfo() != null
197 && permissionInfoIsForTopLevelOrigin(other.getMidiInfo() , origin)) { 196 && permissionInfoIsForTopLevelOrigin(other.getMidiInfo() , origin)) {
198 merged.setMidiInfo(other.getMidiInfo()); 197 merged.setMidiInfo(other.getMidiInfo());
199 } 198 }
200 if (merged.getProtectedMediaIdentifierInfo() == null 199 if (merged.getProtectedMediaIdentifierInfo() == null
201 && other.getProtectedMediaIdentifierInfo() != null 200 && other.getProtectedMediaIdentifierInfo() != null
202 && permissionInfoIsForTopLevelOrigin( 201 && permissionInfoIsForTopLevelOrigin(
203 other.getProtectedMediaIdentifierInfo(), orig in)) { 202 other.getProtectedMediaIdentifierInfo(), orig in)) {
204 merged.setProtectedMediaIdentifierInfo(other.getProtectedMed iaIdentifierInfo()); 203 merged.setProtectedMediaIdentifierInfo(other.getProtectedMed iaIdentifierInfo());
205 } 204 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 preference.setOnPreferenceClickListener(this); 276 preference.setOnPreferenceClickListener(this);
278 } else if (PREF_CAMERA_CAPTURE_PERMISSION.equals(preference.getKey() )) { 277 } else if (PREF_CAMERA_CAPTURE_PERMISSION.equals(preference.getKey() )) {
279 setUpListPreference(preference, mSite.getCameraPermission()); 278 setUpListPreference(preference, mSite.getCameraPermission());
280 } else if (PREF_COOKIES_PERMISSION.equals(preference.getKey())) { 279 } else if (PREF_COOKIES_PERMISSION.equals(preference.getKey())) {
281 setUpListPreference(preference, mSite.getCookiePermission()); 280 setUpListPreference(preference, mSite.getCookiePermission());
282 } else if (PREF_FULLSCREEN_PERMISSION.equals(preference.getKey())) { 281 } else if (PREF_FULLSCREEN_PERMISSION.equals(preference.getKey())) {
283 preference.setEnabled(false); 282 preference.setEnabled(false);
284 setUpListPreference(preference, mSite.getFullscreenPermission()) ; 283 setUpListPreference(preference, mSite.getFullscreenPermission()) ;
285 } else if (PREF_JAVASCRIPT_PERMISSION.equals(preference.getKey())) { 284 } else if (PREF_JAVASCRIPT_PERMISSION.equals(preference.getKey())) {
286 setUpListPreference(preference, mSite.getJavaScriptPermission()) ; 285 setUpListPreference(preference, mSite.getJavaScriptPermission()) ;
286 } else if (PREF_KEYGEN_PERMISSION.equals(preference.getKey())) {
287 setUpListPreference(preference, mSite.getKeygenPermission());
287 } else if (PREF_LOCATION_ACCESS.equals(preference.getKey())) { 288 } else if (PREF_LOCATION_ACCESS.equals(preference.getKey())) {
288 setUpLocationPreference(preference); 289 setUpLocationPreference(preference);
289 } else if (PREF_MIC_CAPTURE_PERMISSION.equals(preference.getKey())) { 290 } else if (PREF_MIC_CAPTURE_PERMISSION.equals(preference.getKey())) {
290 setUpListPreference(preference, mSite.getMicrophonePermission()) ; 291 setUpListPreference(preference, mSite.getMicrophonePermission()) ;
291 } else if (PREF_MIDI_SYSEX_PERMISSION.equals(preference.getKey())) { 292 } else if (PREF_MIDI_SYSEX_PERMISSION.equals(preference.getKey())) {
292 setUpListPreference(preference, mSite.getMidiPermission()); 293 setUpListPreference(preference, mSite.getMidiPermission());
293 } else if (PREF_POPUP_PERMISSION.equals(preference.getKey())) { 294 } else if (PREF_POPUP_PERMISSION.equals(preference.getKey())) {
294 setUpListPreference(preference, mSite.getPopupPermission()); 295 setUpListPreference(preference, mSite.getPopupPermission());
295 } else if (PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION.equals(prefere nce.getKey())) { 296 } else if (PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION.equals(prefere nce.getKey())) {
296 setUpListPreference(preference, mSite.getProtectedMediaIdentifie rPermission()); 297 setUpListPreference(preference, mSite.getProtectedMediaIdentifie rPermission());
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 private int getContentSettingsTypeFromPreferenceKey(String preferenceKey) { 502 private int getContentSettingsTypeFromPreferenceKey(String preferenceKey) {
502 switch (preferenceKey) { 503 switch (preferenceKey) {
503 case PREF_CAMERA_CAPTURE_PERMISSION: 504 case PREF_CAMERA_CAPTURE_PERMISSION:
504 return ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAM ERA; 505 return ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAM ERA;
505 case PREF_COOKIES_PERMISSION: 506 case PREF_COOKIES_PERMISSION:
506 return ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES; 507 return ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES;
507 case PREF_FULLSCREEN_PERMISSION: 508 case PREF_FULLSCREEN_PERMISSION:
508 return ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN; 509 return ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN;
509 case PREF_JAVASCRIPT_PERMISSION: 510 case PREF_JAVASCRIPT_PERMISSION:
510 return ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT; 511 return ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT;
512 case PREF_KEYGEN_PERMISSION:
513 return ContentSettingsType.CONTENT_SETTINGS_TYPE_KEYGEN;
511 case PREF_LOCATION_ACCESS: 514 case PREF_LOCATION_ACCESS:
512 return ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION; 515 return ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION;
513 case PREF_MIC_CAPTURE_PERMISSION: 516 case PREF_MIC_CAPTURE_PERMISSION:
514 return ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ; 517 return ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ;
515 case PREF_MIDI_SYSEX_PERMISSION: 518 case PREF_MIDI_SYSEX_PERMISSION:
516 return ContentSettingsType.CONTENT_SETTINGS_TYPE_MIDI_SYSEX; 519 return ContentSettingsType.CONTENT_SETTINGS_TYPE_MIDI_SYSEX;
517 case PREF_POPUP_PERMISSION: 520 case PREF_POPUP_PERMISSION:
518 return ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS; 521 return ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS;
519 case PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION: 522 case PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION:
520 return ContentSettingsType.CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA _IDENTIFIER; 523 return ContentSettingsType.CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA _IDENTIFIER;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 public boolean onPreferenceChange(Preference preference, Object newValue) { 560 public boolean onPreferenceChange(Preference preference, Object newValue) {
558 ContentSetting permission = ContentSetting.fromString((String) newValue) ; 561 ContentSetting permission = ContentSetting.fromString((String) newValue) ;
559 if (PREF_CAMERA_CAPTURE_PERMISSION.equals(preference.getKey())) { 562 if (PREF_CAMERA_CAPTURE_PERMISSION.equals(preference.getKey())) {
560 mSite.setCameraPermission(permission); 563 mSite.setCameraPermission(permission);
561 } else if (PREF_COOKIES_PERMISSION.equals(preference.getKey())) { 564 } else if (PREF_COOKIES_PERMISSION.equals(preference.getKey())) {
562 mSite.setCookiePermission(permission); 565 mSite.setCookiePermission(permission);
563 } else if (PREF_FULLSCREEN_PERMISSION.equals(preference.getKey())) { 566 } else if (PREF_FULLSCREEN_PERMISSION.equals(preference.getKey())) {
564 mSite.setFullscreenPermission(permission); 567 mSite.setFullscreenPermission(permission);
565 } else if (PREF_JAVASCRIPT_PERMISSION.equals(preference.getKey())) { 568 } else if (PREF_JAVASCRIPT_PERMISSION.equals(preference.getKey())) {
566 mSite.setJavaScriptPermission(permission); 569 mSite.setJavaScriptPermission(permission);
570 } else if (PREF_KEYGEN_PERMISSION.equals(preference.getKey())) {
571 mSite.setKeygenPermission(permission);
567 } else if (PREF_LOCATION_ACCESS.equals(preference.getKey())) { 572 } else if (PREF_LOCATION_ACCESS.equals(preference.getKey())) {
568 mSite.setGeolocationPermission(permission); 573 mSite.setGeolocationPermission(permission);
569 } else if (PREF_MIC_CAPTURE_PERMISSION.equals(preference.getKey())) { 574 } else if (PREF_MIC_CAPTURE_PERMISSION.equals(preference.getKey())) {
570 mSite.setMicrophonePermission(permission); 575 mSite.setMicrophonePermission(permission);
571 } else if (PREF_MIDI_SYSEX_PERMISSION.equals(preference.getKey())) { 576 } else if (PREF_MIDI_SYSEX_PERMISSION.equals(preference.getKey())) {
572 mSite.setMidiPermission(permission); 577 mSite.setMidiPermission(permission);
573 } else if (PREF_POPUP_PERMISSION.equals(preference.getKey())) { 578 } else if (PREF_POPUP_PERMISSION.equals(preference.getKey())) {
574 mSite.setPopupPermission(permission); 579 mSite.setPopupPermission(permission);
575 } else if (PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION.equals(preference. getKey())) { 580 } else if (PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION.equals(preference. getKey())) {
576 mSite.setProtectedMediaIdentifierPermission(permission); 581 mSite.setProtectedMediaIdentifierPermission(permission);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 if (preference != null) screen.removePreference(preference); 614 if (preference != null) screen.removePreference(preference);
610 } 615 }
611 616
612 // Clear the permissions. 617 // Clear the permissions.
613 mSite.setCameraPermission(ContentSetting.DEFAULT); 618 mSite.setCameraPermission(ContentSetting.DEFAULT);
614 mSite.setCookiePermission(ContentSetting.DEFAULT); 619 mSite.setCookiePermission(ContentSetting.DEFAULT);
615 WebsitePreferenceBridge.nativeClearCookieData(mSite.getAddress().getOrig in()); 620 WebsitePreferenceBridge.nativeClearCookieData(mSite.getAddress().getOrig in());
616 mSite.setFullscreenPermission(ContentSetting.DEFAULT); 621 mSite.setFullscreenPermission(ContentSetting.DEFAULT);
617 mSite.setGeolocationPermission(ContentSetting.DEFAULT); 622 mSite.setGeolocationPermission(ContentSetting.DEFAULT);
618 mSite.setJavaScriptPermission(ContentSetting.DEFAULT); 623 mSite.setJavaScriptPermission(ContentSetting.DEFAULT);
624 mSite.setKeygenPermission(ContentSetting.DEFAULT);
619 mSite.setMicrophonePermission(ContentSetting.DEFAULT); 625 mSite.setMicrophonePermission(ContentSetting.DEFAULT);
620 mSite.setMidiPermission(ContentSetting.DEFAULT); 626 mSite.setMidiPermission(ContentSetting.DEFAULT);
621 mSite.setPopupPermission(ContentSetting.DEFAULT); 627 mSite.setPopupPermission(ContentSetting.DEFAULT);
622 mSite.setProtectedMediaIdentifierPermission(ContentSetting.DEFAULT); 628 mSite.setProtectedMediaIdentifierPermission(ContentSetting.DEFAULT);
623 mSite.setPushNotificationPermission(ContentSetting.DEFAULT); 629 mSite.setPushNotificationPermission(ContentSetting.DEFAULT);
624 630
625 // Clear the storage and finish the activity if necessary. 631 // Clear the storage and finish the activity if necessary.
626 if (mSite.getTotalUsage() > 0) { 632 if (mSite.getTotalUsage() > 0) {
627 clearStoredData(); 633 clearStoredData();
628 } else { 634 } else {
629 // Clearing stored data implies popping back to parent menu if there 635 // Clearing stored data implies popping back to parent menu if there
630 // is nothing left to show. Therefore, we only need to explicitly 636 // is nothing left to show. Therefore, we only need to explicitly
631 // close the activity if there's no stored data to begin with. 637 // close the activity if there's no stored data to begin with.
632 getActivity().finish(); 638 getActivity().finish();
633 } 639 }
634 } 640 }
635 } 641 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698