| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.pageinfo; | 5 package org.chromium.chrome.browser.pageinfo; |
| 6 | 6 |
| 7 import android.animation.Animator; | 7 import android.animation.Animator; |
| 8 import android.animation.AnimatorListenerAdapter; | 8 import android.animation.AnimatorListenerAdapter; |
| 9 import android.animation.AnimatorSet; | 9 import android.animation.AnimatorSet; |
| 10 import android.animation.ObjectAnimator; | 10 import android.animation.ObjectAnimator; |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 * Whether to show a 'Details' link to the connection info popup. The link i
s only shown for | 519 * Whether to show a 'Details' link to the connection info popup. The link i
s only shown for |
| 520 * HTTPS connections. | 520 * HTTPS connections. |
| 521 */ | 521 */ |
| 522 private boolean isConnectionDetailsLinkVisible() { | 522 private boolean isConnectionDetailsLinkVisible() { |
| 523 return mContentPublisher == null && !isShowingOfflinePage() && mParsedUr
l != null | 523 return mContentPublisher == null && !isShowingOfflinePage() && mParsedUr
l != null |
| 524 && mParsedUrl.getScheme() != null | 524 && mParsedUrl.getScheme() != null |
| 525 && mParsedUrl.getScheme().equals(UrlConstants.HTTPS_SCHE
ME); | 525 && mParsedUrl.getScheme().equals(UrlConstants.HTTPS_SCHE
ME); |
| 526 } | 526 } |
| 527 | 527 |
| 528 private boolean hasAndroidPermission(int contentSettingType) { | 528 private boolean hasAndroidPermission(int contentSettingType) { |
| 529 String androidPermission = PrefServiceBridge.getAndroidPermissionForCont
entSetting( | 529 String[] androidPermissions = |
| 530 contentSettingType); | 530 PrefServiceBridge.getAndroidPermissionsForContentSetting(content
SettingType); |
| 531 return androidPermission == null || mWindowAndroid.hasPermission(android
Permission); | 531 if (androidPermissions == null) return true; |
| 532 for (int i = 0; i < androidPermissions.length; i++) { |
| 533 if (!mWindowAndroid.hasPermission(androidPermissions[i])) { |
| 534 return false; |
| 535 } |
| 536 } |
| 537 return true; |
| 532 } | 538 } |
| 533 | 539 |
| 534 /** | 540 /** |
| 535 * Adds a new row for the given permission. | 541 * Adds a new row for the given permission. |
| 536 * | 542 * |
| 537 * @param name The title of the permission to display to the user. | 543 * @param name The title of the permission to display to the user. |
| 538 * @param type The ContentSettingsType of the permission. | 544 * @param type The ContentSettingsType of the permission. |
| 539 * @param currentSettingValue The ContentSetting value of the currently sele
cted setting. | 545 * @param currentSettingValue The ContentSetting value of the currently sele
cted setting. |
| 540 */ | 546 */ |
| 541 @CalledByNative | 547 @CalledByNative |
| (...skipping 30 matching lines...) Expand all Loading... |
| 572 // permission_intent_override or permission_type. | 578 // permission_intent_override or permission_type. |
| 573 LocationUtils locationUtils = LocationUtils.getInstance(); | 579 LocationUtils locationUtils = LocationUtils.getInstance(); |
| 574 if (permission.type == ContentSettingsType.CONTENT_SETTINGS_TYPE_GEO
LOCATION | 580 if (permission.type == ContentSettingsType.CONTENT_SETTINGS_TYPE_GEO
LOCATION |
| 575 && !locationUtils.isSystemLocationSettingEnabled()) { | 581 && !locationUtils.isSystemLocationSettingEnabled()) { |
| 576 warningTextResource = R.string.page_info_android_location_blocke
d; | 582 warningTextResource = R.string.page_info_android_location_blocke
d; |
| 577 permissionRow.setTag(R.id.permission_intent_override, | 583 permissionRow.setTag(R.id.permission_intent_override, |
| 578 locationUtils.getSystemLocationSettingsIntent()); | 584 locationUtils.getSystemLocationSettingsIntent()); |
| 579 } else if (!hasAndroidPermission(permission.type)) { | 585 } else if (!hasAndroidPermission(permission.type)) { |
| 580 warningTextResource = R.string.page_info_android_permission_bloc
ked; | 586 warningTextResource = R.string.page_info_android_permission_bloc
ked; |
| 581 permissionRow.setTag(R.id.permission_type, | 587 permissionRow.setTag(R.id.permission_type, |
| 582 PrefServiceBridge.getAndroidPermissionForContentSetting(
permission.type)); | 588 PrefServiceBridge.getAndroidPermissionsForContentSetting
(permission.type)); |
| 583 } | 589 } |
| 584 | 590 |
| 585 if (warningTextResource != 0) { | 591 if (warningTextResource != 0) { |
| 586 TextView permissionUnavailable = (TextView) permissionRow.findVi
ewById( | 592 TextView permissionUnavailable = (TextView) permissionRow.findVi
ewById( |
| 587 R.id.website_settings_permission_unavailable_message); | 593 R.id.website_settings_permission_unavailable_message); |
| 588 permissionUnavailable.setVisibility(View.VISIBLE); | 594 permissionUnavailable.setVisibility(View.VISIBLE); |
| 589 permissionUnavailable.setText(warningTextResource); | 595 permissionUnavailable.setText(warningTextResource); |
| 590 | 596 |
| 591 permissionIcon.setImageResource(R.drawable.exclamation_triangle)
; | 597 permissionIcon.setImageResource(R.drawable.exclamation_triangle)
; |
| 592 permissionIcon.setColorFilter(ApiCompatibilityUtils.getColor( | 598 permissionIcon.setColorFilter(ApiCompatibilityUtils.getColor( |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 WebsiteSettingsAction.WEBSITE_SETTINGS_SECURITY_
DETAILS_OPENED); | 771 WebsiteSettingsAction.WEBSITE_SETTINGS_SECURITY_
DETAILS_OPENED); |
| 766 ConnectionInfoPopup.show(mContext, mTab.getWebContents()
); | 772 ConnectionInfoPopup.show(mContext, mTab.getWebContents()
); |
| 767 } | 773 } |
| 768 } | 774 } |
| 769 }); | 775 }); |
| 770 } else if (view.getId() == R.id.website_settings_permission_row) { | 776 } else if (view.getId() == R.id.website_settings_permission_row) { |
| 771 final Object intentOverride = view.getTag(R.id.permission_intent_ove
rride); | 777 final Object intentOverride = view.getTag(R.id.permission_intent_ove
rride); |
| 772 | 778 |
| 773 if (intentOverride == null && mWindowAndroid != null) { | 779 if (intentOverride == null && mWindowAndroid != null) { |
| 774 // Try and immediately request missing Android permissions where
possible. | 780 // Try and immediately request missing Android permissions where
possible. |
| 775 final String permissionType = (String) view.getTag(R.id.permissi
on_type); | 781 final String[] permissionType = (String[]) view.getTag(R.id.perm
ission_type); |
| 776 if (mWindowAndroid.canRequestPermission(permissionType)) { | 782 for (int i = 0; i < permissionType.length; i++) { |
| 777 final String[] permissionRequest = new String[] {permissionT
ype}; | 783 if (!mWindowAndroid.canRequestPermission(permissionType[i]))
continue; |
| 778 mWindowAndroid.requestPermissions(permissionRequest, new Per
missionCallback() { | 784 |
| 785 // If any permissions can be requested, attempt to request t
hem all. |
| 786 mWindowAndroid.requestPermissions(permissionType, new Permis
sionCallback() { |
| 779 @Override | 787 @Override |
| 780 public void onRequestPermissionsResult( | 788 public void onRequestPermissionsResult( |
| 781 String[] permissions, int[] grantResults) { | 789 String[] permissions, int[] grantResults) { |
| 782 if (grantResults.length > 0 | 790 boolean allGranted = true; |
| 783 && grantResults[0] == PackageManager.PERMISS
ION_GRANTED) { | 791 for (int i = 0; i < grantResults.length; i++) { |
| 784 updatePermissionDisplay(); | 792 if (grantResults[i] != PackageManager.PERMISSION
_GRANTED) { |
| 793 allGranted = false; |
| 794 break; |
| 795 } |
| 785 } | 796 } |
| 797 if (allGranted) updatePermissionDisplay(); |
| 786 } | 798 } |
| 787 }); | 799 }); |
| 788 return; | 800 return; |
| 789 } | 801 } |
| 790 } | 802 } |
| 791 | 803 |
| 792 runAfterDismiss(new Runnable() { | 804 runAfterDismiss(new Runnable() { |
| 793 @Override | 805 @Override |
| 794 public void run() { | 806 public void run() { |
| 795 Intent settingsIntent; | 807 Intent settingsIntent; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 new WebsiteSettingsPopup(activity, tab, offlinePageCreationDate, content
Publisher); | 972 new WebsiteSettingsPopup(activity, tab, offlinePageCreationDate, content
Publisher); |
| 961 } | 973 } |
| 962 | 974 |
| 963 private static native long nativeInit(WebsiteSettingsPopup popup, WebContent
s webContents); | 975 private static native long nativeInit(WebsiteSettingsPopup popup, WebContent
s webContents); |
| 964 | 976 |
| 965 private native void nativeDestroy(long nativeWebsiteSettingsPopupAndroid); | 977 private native void nativeDestroy(long nativeWebsiteSettingsPopupAndroid); |
| 966 | 978 |
| 967 private native void nativeRecordWebsiteSettingsAction( | 979 private native void nativeRecordWebsiteSettingsAction( |
| 968 long nativeWebsiteSettingsPopupAndroid, int action); | 980 long nativeWebsiteSettingsPopupAndroid, int action); |
| 969 } | 981 } |
| OLD | NEW |