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

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: Simplify fragmentArgs. 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,
86 PREF_COOKIES_PERMISSION, 87 PREF_COOKIES_PERMISSION,
87 PREF_FULLSCREEN_PERMISSION, 88 PREF_FULLSCREEN_PERMISSION,
88 PREF_JAVASCRIPT_PERMISSION, 89 PREF_JAVASCRIPT_PERMISSION,
90 PREF_KEYGEN_PERMISSION,
89 PREF_LOCATION_ACCESS, 91 PREF_LOCATION_ACCESS,
90 PREF_MIC_CAPTURE_PERMISSION, 92 PREF_MIC_CAPTURE_PERMISSION,
91 PREF_MIDI_SYSEX_PERMISSION, 93 PREF_MIDI_SYSEX_PERMISSION,
92 PREF_POPUP_PERMISSION, 94 PREF_POPUP_PERMISSION,
93 PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION, 95 PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION,
94 PREF_PUSH_NOTIFICATIONS_PERMISSION, 96 PREF_PUSH_NOTIFICATIONS_PERMISSION,
95 }; 97 };
96 98
97 // The website this page is displaying details about. 99 // The website this page is displaying details about.
98 private Website mSite; 100 private Website mSite;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 merged.setCookieInfo(other.getCookieInfo()); 188 merged.setCookieInfo(other.getCookieInfo());
187 } 189 }
188 if (merged.getFullscreenInfo() == null && other.getFullscreenInf o() != null 190 if (merged.getFullscreenInfo() == null && other.getFullscreenInf o() != null
189 && permissionInfoIsForTopLevelOrigin(other.getFullscreen Info(), origin)) { 191 && permissionInfoIsForTopLevelOrigin(other.getFullscreen Info(), origin)) {
190 merged.setFullscreenInfo(other.getFullscreenInfo()); 192 merged.setFullscreenInfo(other.getFullscreenInfo());
191 } 193 }
192 if (merged.getGeolocationInfo() == null && other.getGeolocationI nfo() != null 194 if (merged.getGeolocationInfo() == null && other.getGeolocationI nfo() != null
193 && permissionInfoIsForTopLevelOrigin(other.getGeolocatio nInfo(), origin)) { 195 && permissionInfoIsForTopLevelOrigin(other.getGeolocatio nInfo(), origin)) {
194 merged.setGeolocationInfo(other.getGeolocationInfo()); 196 merged.setGeolocationInfo(other.getGeolocationInfo());
195 } 197 }
198 if (merged.getKeygenInfo() == null && other.getKeygenInfo() != n ull
199 && permissionInfoIsForTopLevelOrigin(other.getKeygenInfo (), origin)) {
200 merged.setKeygenInfo(other.getKeygenInfo());
201 }
196 if (merged.getMidiInfo() == null && other.getMidiInfo() != null 202 if (merged.getMidiInfo() == null && other.getMidiInfo() != null
197 && permissionInfoIsForTopLevelOrigin(other.getMidiInfo() , origin)) { 203 && permissionInfoIsForTopLevelOrigin(other.getMidiInfo() , origin)) {
198 merged.setMidiInfo(other.getMidiInfo()); 204 merged.setMidiInfo(other.getMidiInfo());
199 } 205 }
200 if (merged.getProtectedMediaIdentifierInfo() == null 206 if (merged.getProtectedMediaIdentifierInfo() == null
201 && other.getProtectedMediaIdentifierInfo() != null 207 && other.getProtectedMediaIdentifierInfo() != null
202 && permissionInfoIsForTopLevelOrigin( 208 && permissionInfoIsForTopLevelOrigin(
203 other.getProtectedMediaIdentifierInfo(), orig in)) { 209 other.getProtectedMediaIdentifierInfo(), orig in)) {
204 merged.setProtectedMediaIdentifierInfo(other.getProtectedMed iaIdentifierInfo()); 210 merged.setProtectedMediaIdentifierInfo(other.getProtectedMed iaIdentifierInfo());
205 } 211 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 preference.setOnPreferenceClickListener(this); 283 preference.setOnPreferenceClickListener(this);
278 } else if (PREF_CAMERA_CAPTURE_PERMISSION.equals(preference.getKey() )) { 284 } else if (PREF_CAMERA_CAPTURE_PERMISSION.equals(preference.getKey() )) {
279 setUpListPreference(preference, mSite.getCameraPermission()); 285 setUpListPreference(preference, mSite.getCameraPermission());
280 } else if (PREF_COOKIES_PERMISSION.equals(preference.getKey())) { 286 } else if (PREF_COOKIES_PERMISSION.equals(preference.getKey())) {
281 setUpListPreference(preference, mSite.getCookiePermission()); 287 setUpListPreference(preference, mSite.getCookiePermission());
282 } else if (PREF_FULLSCREEN_PERMISSION.equals(preference.getKey())) { 288 } else if (PREF_FULLSCREEN_PERMISSION.equals(preference.getKey())) {
283 preference.setEnabled(false); 289 preference.setEnabled(false);
284 setUpListPreference(preference, mSite.getFullscreenPermission()) ; 290 setUpListPreference(preference, mSite.getFullscreenPermission()) ;
285 } else if (PREF_JAVASCRIPT_PERMISSION.equals(preference.getKey())) { 291 } else if (PREF_JAVASCRIPT_PERMISSION.equals(preference.getKey())) {
286 setUpListPreference(preference, mSite.getJavaScriptPermission()) ; 292 setUpListPreference(preference, mSite.getJavaScriptPermission()) ;
293 } else if (PREF_KEYGEN_PERMISSION.equals(preference.getKey())) {
294 setUpListPreference(preference, mSite.getKeygenPermission());
287 } else if (PREF_LOCATION_ACCESS.equals(preference.getKey())) { 295 } else if (PREF_LOCATION_ACCESS.equals(preference.getKey())) {
288 setUpLocationPreference(preference); 296 setUpLocationPreference(preference);
289 } else if (PREF_MIC_CAPTURE_PERMISSION.equals(preference.getKey())) { 297 } else if (PREF_MIC_CAPTURE_PERMISSION.equals(preference.getKey())) {
290 setUpListPreference(preference, mSite.getMicrophonePermission()) ; 298 setUpListPreference(preference, mSite.getMicrophonePermission()) ;
291 } else if (PREF_MIDI_SYSEX_PERMISSION.equals(preference.getKey())) { 299 } else if (PREF_MIDI_SYSEX_PERMISSION.equals(preference.getKey())) {
292 setUpListPreference(preference, mSite.getMidiPermission()); 300 setUpListPreference(preference, mSite.getMidiPermission());
293 } else if (PREF_POPUP_PERMISSION.equals(preference.getKey())) { 301 } else if (PREF_POPUP_PERMISSION.equals(preference.getKey())) {
294 setUpListPreference(preference, mSite.getPopupPermission()); 302 setUpListPreference(preference, mSite.getPopupPermission());
295 } else if (PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION.equals(prefere nce.getKey())) { 303 } else if (PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION.equals(prefere nce.getKey())) {
296 setUpListPreference(preference, mSite.getProtectedMediaIdentifie rPermission()); 304 setUpListPreference(preference, mSite.getProtectedMediaIdentifie rPermission());
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 private int getContentSettingsTypeFromPreferenceKey(String preferenceKey) { 509 private int getContentSettingsTypeFromPreferenceKey(String preferenceKey) {
502 switch (preferenceKey) { 510 switch (preferenceKey) {
503 case PREF_CAMERA_CAPTURE_PERMISSION: 511 case PREF_CAMERA_CAPTURE_PERMISSION:
504 return ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAM ERA; 512 return ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAM ERA;
505 case PREF_COOKIES_PERMISSION: 513 case PREF_COOKIES_PERMISSION:
506 return ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES; 514 return ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES;
507 case PREF_FULLSCREEN_PERMISSION: 515 case PREF_FULLSCREEN_PERMISSION:
508 return ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN; 516 return ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN;
509 case PREF_JAVASCRIPT_PERMISSION: 517 case PREF_JAVASCRIPT_PERMISSION:
510 return ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT; 518 return ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT;
519 case PREF_KEYGEN_PERMISSION:
520 return ContentSettingsType.CONTENT_SETTINGS_TYPE_KEYGEN;
511 case PREF_LOCATION_ACCESS: 521 case PREF_LOCATION_ACCESS:
512 return ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION; 522 return ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION;
513 case PREF_MIC_CAPTURE_PERMISSION: 523 case PREF_MIC_CAPTURE_PERMISSION:
514 return ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ; 524 return ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ;
515 case PREF_MIDI_SYSEX_PERMISSION: 525 case PREF_MIDI_SYSEX_PERMISSION:
516 return ContentSettingsType.CONTENT_SETTINGS_TYPE_MIDI_SYSEX; 526 return ContentSettingsType.CONTENT_SETTINGS_TYPE_MIDI_SYSEX;
517 case PREF_POPUP_PERMISSION: 527 case PREF_POPUP_PERMISSION:
518 return ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS; 528 return ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS;
519 case PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION: 529 case PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION:
520 return ContentSettingsType.CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA _IDENTIFIER; 530 return ContentSettingsType.CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA _IDENTIFIER;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 public boolean onPreferenceChange(Preference preference, Object newValue) { 569 public boolean onPreferenceChange(Preference preference, Object newValue) {
560 ContentSetting permission = ContentSetting.fromString((String) newValue) ; 570 ContentSetting permission = ContentSetting.fromString((String) newValue) ;
561 if (PREF_CAMERA_CAPTURE_PERMISSION.equals(preference.getKey())) { 571 if (PREF_CAMERA_CAPTURE_PERMISSION.equals(preference.getKey())) {
562 mSite.setCameraPermission(permission); 572 mSite.setCameraPermission(permission);
563 } else if (PREF_COOKIES_PERMISSION.equals(preference.getKey())) { 573 } else if (PREF_COOKIES_PERMISSION.equals(preference.getKey())) {
564 mSite.setCookiePermission(permission); 574 mSite.setCookiePermission(permission);
565 } else if (PREF_FULLSCREEN_PERMISSION.equals(preference.getKey())) { 575 } else if (PREF_FULLSCREEN_PERMISSION.equals(preference.getKey())) {
566 mSite.setFullscreenPermission(permission); 576 mSite.setFullscreenPermission(permission);
567 } else if (PREF_JAVASCRIPT_PERMISSION.equals(preference.getKey())) { 577 } else if (PREF_JAVASCRIPT_PERMISSION.equals(preference.getKey())) {
568 mSite.setJavaScriptPermission(permission); 578 mSite.setJavaScriptPermission(permission);
579 } else if (PREF_KEYGEN_PERMISSION.equals(preference.getKey())) {
580 mSite.setKeygenPermission(permission);
569 } else if (PREF_LOCATION_ACCESS.equals(preference.getKey())) { 581 } else if (PREF_LOCATION_ACCESS.equals(preference.getKey())) {
570 mSite.setGeolocationPermission(permission); 582 mSite.setGeolocationPermission(permission);
571 } else if (PREF_MIC_CAPTURE_PERMISSION.equals(preference.getKey())) { 583 } else if (PREF_MIC_CAPTURE_PERMISSION.equals(preference.getKey())) {
572 mSite.setMicrophonePermission(permission); 584 mSite.setMicrophonePermission(permission);
573 } else if (PREF_MIDI_SYSEX_PERMISSION.equals(preference.getKey())) { 585 } else if (PREF_MIDI_SYSEX_PERMISSION.equals(preference.getKey())) {
574 mSite.setMidiPermission(permission); 586 mSite.setMidiPermission(permission);
575 } else if (PREF_POPUP_PERMISSION.equals(preference.getKey())) { 587 } else if (PREF_POPUP_PERMISSION.equals(preference.getKey())) {
576 mSite.setPopupPermission(permission); 588 mSite.setPopupPermission(permission);
577 } else if (PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION.equals(preference. getKey())) { 589 } else if (PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION.equals(preference. getKey())) {
578 mSite.setProtectedMediaIdentifierPermission(permission); 590 mSite.setProtectedMediaIdentifierPermission(permission);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 if (preference != null) screen.removePreference(preference); 623 if (preference != null) screen.removePreference(preference);
612 } 624 }
613 625
614 // Clear the permissions. 626 // Clear the permissions.
615 mSite.setCameraPermission(ContentSetting.DEFAULT); 627 mSite.setCameraPermission(ContentSetting.DEFAULT);
616 mSite.setCookiePermission(ContentSetting.DEFAULT); 628 mSite.setCookiePermission(ContentSetting.DEFAULT);
617 WebsitePreferenceBridge.nativeClearCookieData(mSite.getAddress().getOrig in()); 629 WebsitePreferenceBridge.nativeClearCookieData(mSite.getAddress().getOrig in());
618 mSite.setFullscreenPermission(ContentSetting.DEFAULT); 630 mSite.setFullscreenPermission(ContentSetting.DEFAULT);
619 mSite.setGeolocationPermission(ContentSetting.DEFAULT); 631 mSite.setGeolocationPermission(ContentSetting.DEFAULT);
620 mSite.setJavaScriptPermission(ContentSetting.DEFAULT); 632 mSite.setJavaScriptPermission(ContentSetting.DEFAULT);
633 mSite.setKeygenPermission(ContentSetting.DEFAULT);
621 mSite.setMicrophonePermission(ContentSetting.DEFAULT); 634 mSite.setMicrophonePermission(ContentSetting.DEFAULT);
622 mSite.setMidiPermission(ContentSetting.DEFAULT); 635 mSite.setMidiPermission(ContentSetting.DEFAULT);
623 mSite.setPopupPermission(ContentSetting.DEFAULT); 636 mSite.setPopupPermission(ContentSetting.DEFAULT);
624 mSite.setProtectedMediaIdentifierPermission(ContentSetting.DEFAULT); 637 mSite.setProtectedMediaIdentifierPermission(ContentSetting.DEFAULT);
625 mSite.setPushNotificationPermission(ContentSetting.DEFAULT); 638 mSite.setPushNotificationPermission(ContentSetting.DEFAULT);
626 639
627 // Clear the storage and finish the activity if necessary. 640 // Clear the storage and finish the activity if necessary.
628 if (mSite.getTotalUsage() > 0) { 641 if (mSite.getTotalUsage() > 0) {
629 clearStoredData(); 642 clearStoredData();
630 } else { 643 } else {
631 // Clearing stored data implies popping back to parent menu if there 644 // Clearing stored data implies popping back to parent menu if there
632 // is nothing left to show. Therefore, we only need to explicitly 645 // is nothing left to show. Therefore, we only need to explicitly
633 // close the activity if there's no stored data to begin with. 646 // close the activity if there's no stored data to begin with.
634 getActivity().finish(); 647 getActivity().finish();
635 } 648 }
636 } 649 }
637 } 650 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698