| 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; | 5 package org.chromium.chrome.browser; |
| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 import org.chromium.base.ApiCompatibilityUtils; | 47 import org.chromium.base.ApiCompatibilityUtils; |
| 48 import org.chromium.base.CommandLine; | 48 import org.chromium.base.CommandLine; |
| 49 import org.chromium.base.annotations.CalledByNative; | 49 import org.chromium.base.annotations.CalledByNative; |
| 50 import org.chromium.chrome.R; | 50 import org.chromium.chrome.R; |
| 51 import org.chromium.chrome.browser.omnibox.OmniboxUrlEmphasizer; | 51 import org.chromium.chrome.browser.omnibox.OmniboxUrlEmphasizer; |
| 52 import org.chromium.chrome.browser.preferences.PrefServiceBridge; | 52 import org.chromium.chrome.browser.preferences.PrefServiceBridge; |
| 53 import org.chromium.chrome.browser.preferences.Preferences; | 53 import org.chromium.chrome.browser.preferences.Preferences; |
| 54 import org.chromium.chrome.browser.preferences.PreferencesLauncher; | 54 import org.chromium.chrome.browser.preferences.PreferencesLauncher; |
| 55 import org.chromium.chrome.browser.preferences.website.SingleWebsitePreferences; | 55 import org.chromium.chrome.browser.preferences.website.SingleWebsitePreferences; |
| 56 import org.chromium.chrome.browser.profiles.Profile; | 56 import org.chromium.chrome.browser.profiles.Profile; |
| 57 import org.chromium.chrome.browser.ssl.ConnectionSecurity; | |
| 58 import org.chromium.chrome.browser.ssl.ConnectionSecurityLevel; | 57 import org.chromium.chrome.browser.ssl.ConnectionSecurityLevel; |
| 59 import org.chromium.chrome.browser.toolbar.ToolbarModel; | 58 import org.chromium.chrome.browser.ssl.SecurityStateModel; |
| 60 import org.chromium.content.browser.ContentViewCore; | 59 import org.chromium.content.browser.ContentViewCore; |
| 61 import org.chromium.content_public.browser.WebContents; | 60 import org.chromium.content_public.browser.WebContents; |
| 62 import org.chromium.content_public.browser.WebContentsObserver; | 61 import org.chromium.content_public.browser.WebContentsObserver; |
| 63 import org.chromium.ui.base.Clipboard; | 62 import org.chromium.ui.base.Clipboard; |
| 64 import org.chromium.ui.base.DeviceFormFactor; | 63 import org.chromium.ui.base.DeviceFormFactor; |
| 65 import org.chromium.ui.base.WindowAndroid; | 64 import org.chromium.ui.base.WindowAndroid; |
| 66 import org.chromium.ui.base.WindowAndroid.PermissionCallback; | 65 import org.chromium.ui.base.WindowAndroid.PermissionCallback; |
| 67 import org.chromium.ui.interpolators.BakedBezierInterpolator; | 66 import org.chromium.ui.interpolators.BakedBezierInterpolator; |
| 68 | 67 |
| 69 import java.net.URI; | 68 import java.net.URI; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 // parsed. | 258 // parsed. |
| 260 private URI mParsedUrl; | 259 private URI mParsedUrl; |
| 261 | 260 |
| 262 // Whether or not this page is an internal chrome page (e.g. the | 261 // Whether or not this page is an internal chrome page (e.g. the |
| 263 // chrome://settings page). | 262 // chrome://settings page). |
| 264 private boolean mIsInternalPage; | 263 private boolean mIsInternalPage; |
| 265 | 264 |
| 266 // The security level of the page (a valid ConnectionSecurityLevel). | 265 // The security level of the page (a valid ConnectionSecurityLevel). |
| 267 private int mSecurityLevel; | 266 private int mSecurityLevel; |
| 268 | 267 |
| 269 // Whether the security level of the page was deprecated due to SHA-1. | 268 // Whether the security level of the page was downgraded due to SHA-1. |
| 270 private boolean mDeprecatedSHA1Present; | 269 private boolean mDeprecatedSHA1Present; |
| 271 | 270 |
| 271 // Whether the security level of the page was downgraded due to passive mixe
d content. |
| 272 private boolean mPassiveMixedContentPresent; |
| 273 |
| 272 // Whether to use the read-only permissions list. | 274 // Whether to use the read-only permissions list. |
| 273 private boolean mIsReadOnlyDialog; | 275 private boolean mIsReadOnlyDialog; |
| 274 | 276 |
| 275 // Permissions available to be displayed in mPermissionsList. | 277 // Permissions available to be displayed in mPermissionsList. |
| 276 private List<PageInfoPermissionEntry> mDisplayedPermissions; | 278 private List<PageInfoPermissionEntry> mDisplayedPermissions; |
| 277 | 279 |
| 278 /** | 280 /** |
| 279 * Creates the WebsiteSettingsPopup, but does not display it. Also initializ
es the corresponding | 281 * Creates the WebsiteSettingsPopup, but does not display it. Also initializ
es the corresponding |
| 280 * C++ object and saves a pointer to it. | 282 * C++ object and saves a pointer to it. |
| 281 * | 283 * |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 | 417 |
| 416 // Work out the URL and connection message. | 418 // Work out the URL and connection message. |
| 417 mFullUrl = mWebContents.getVisibleUrl(); | 419 mFullUrl = mWebContents.getVisibleUrl(); |
| 418 try { | 420 try { |
| 419 mParsedUrl = new URI(mFullUrl); | 421 mParsedUrl = new URI(mFullUrl); |
| 420 mIsInternalPage = UrlUtilities.isInternalScheme(mParsedUrl); | 422 mIsInternalPage = UrlUtilities.isInternalScheme(mParsedUrl); |
| 421 } catch (URISyntaxException e) { | 423 } catch (URISyntaxException e) { |
| 422 mParsedUrl = null; | 424 mParsedUrl = null; |
| 423 mIsInternalPage = false; | 425 mIsInternalPage = false; |
| 424 } | 426 } |
| 425 mSecurityLevel = ConnectionSecurity.getSecurityLevelForWebContents(mWebC
ontents); | 427 mSecurityLevel = SecurityStateModel.getSecurityLevelForWebContents(mWebC
ontents); |
| 426 mDeprecatedSHA1Present = ToolbarModel.isDeprecatedSHA1Present(mWebConten
ts); | 428 mDeprecatedSHA1Present = SecurityStateModel.isDeprecatedSHA1Present(mWeb
Contents); |
| 429 mPassiveMixedContentPresent = SecurityStateModel.isPassiveMixedContentPr
esent(mWebContents); |
| 427 | 430 |
| 428 SpannableStringBuilder urlBuilder = new SpannableStringBuilder(mFullUrl)
; | 431 SpannableStringBuilder urlBuilder = new SpannableStringBuilder(mFullUrl)
; |
| 429 OmniboxUrlEmphasizer.emphasizeUrl(urlBuilder, mContext.getResources(), m
Profile, | 432 OmniboxUrlEmphasizer.emphasizeUrl(urlBuilder, mContext.getResources(), m
Profile, |
| 430 mSecurityLevel, mIsInternalPage, true, true); | 433 mSecurityLevel, mIsInternalPage, true, true); |
| 431 mUrlTitle.setText(urlBuilder); | 434 mUrlTitle.setText(urlBuilder); |
| 432 | 435 |
| 433 // Set the URL connection message now, and the URL after layout (so it | 436 // Set the URL connection message now, and the URL after layout (so it |
| 434 // can calculate its ideal height). | 437 // can calculate its ideal height). |
| 435 mUrlConnectionMessage.setText(getUrlConnectionMessage()); | 438 mUrlConnectionMessage.setText(getUrlConnectionMessage()); |
| 436 if (isConnectionDetailsLinkVisible()) mUrlConnectionMessage.setOnClickLi
stener(this); | 439 if (isConnectionDetailsLinkVisible()) mUrlConnectionMessage.setOnClickLi
stener(this); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 */ | 502 */ |
| 500 private int getConnectionMessageId(int securityLevel, boolean isInternalPage
) { | 503 private int getConnectionMessageId(int securityLevel, boolean isInternalPage
) { |
| 501 if (isInternalPage) return R.string.page_info_connection_internal_page; | 504 if (isInternalPage) return R.string.page_info_connection_internal_page; |
| 502 | 505 |
| 503 switch (securityLevel) { | 506 switch (securityLevel) { |
| 504 case ConnectionSecurityLevel.NONE: | 507 case ConnectionSecurityLevel.NONE: |
| 505 return R.string.page_info_connection_http; | 508 return R.string.page_info_connection_http; |
| 506 case ConnectionSecurityLevel.SECURE: | 509 case ConnectionSecurityLevel.SECURE: |
| 507 case ConnectionSecurityLevel.EV_SECURE: | 510 case ConnectionSecurityLevel.EV_SECURE: |
| 508 return R.string.page_info_connection_https; | 511 return R.string.page_info_connection_https; |
| 509 case ConnectionSecurityLevel.SECURITY_WARNING: | |
| 510 case ConnectionSecurityLevel.SECURITY_POLICY_WARNING: | |
| 511 return R.string.page_info_connection_mixed; | |
| 512 default: | 512 default: |
| 513 assert false : "Invalid security level specified: " + securityLe
vel; | 513 assert false : "Invalid security level specified: " + securityLe
vel; |
| 514 return R.string.page_info_connection_http; | 514 return R.string.page_info_connection_http; |
| 515 } | 515 } |
| 516 } | 516 } |
| 517 | 517 |
| 518 /** | 518 /** |
| 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 !mIsInternalPage && mSecurityLevel != ConnectionSecurityLevel.NON
E; | 523 return !mIsInternalPage && mSecurityLevel != ConnectionSecurityLevel.NON
E; |
| 524 } | 524 } |
| 525 | 525 |
| 526 /** | 526 /** |
| 527 * Gets the styled connection message to display below the URL. | 527 * Gets the styled connection message to display below the URL. |
| 528 */ | 528 */ |
| 529 private Spannable getUrlConnectionMessage() { | 529 private Spannable getUrlConnectionMessage() { |
| 530 // Display the appropriate connection message. | 530 // Display the appropriate connection message. |
| 531 SpannableStringBuilder messageBuilder = new SpannableStringBuilder(); | 531 SpannableStringBuilder messageBuilder = new SpannableStringBuilder(); |
| 532 if (mDeprecatedSHA1Present) { | 532 if (mDeprecatedSHA1Present) { |
| 533 messageBuilder.append( | 533 messageBuilder.append( |
| 534 mContext.getResources().getString(R.string.page_info_connect
ion_sha1)); | 534 mContext.getResources().getString(R.string.page_info_connect
ion_sha1)); |
| 535 } else if (mSecurityLevel != ConnectionSecurityLevel.SECURITY_ERROR) { | 535 } else if (mPassiveMixedContentPresent) { |
| 536 messageBuilder.append( |
| 537 mContext.getResources().getString(R.string.page_info_connect
ion_mixed)); |
| 538 } else if (mSecurityLevel != ConnectionSecurityLevel.SECURITY_ERROR |
| 539 && mSecurityLevel != ConnectionSecurityLevel.SECURITY_WARNING |
| 540 && mSecurityLevel != ConnectionSecurityLevel.SECURITY_POLICY_WAR
NING) { |
| 536 messageBuilder.append(mContext.getResources().getString( | 541 messageBuilder.append(mContext.getResources().getString( |
| 537 getConnectionMessageId(mSecurityLevel, mIsInternalPage))); | 542 getConnectionMessageId(mSecurityLevel, mIsInternalPage))); |
| 538 } else { | 543 } else { |
| 539 String originToDisplay; | 544 String originToDisplay; |
| 540 try { | 545 try { |
| 541 URI parsedUrl = new URI(mFullUrl); | 546 URI parsedUrl = new URI(mFullUrl); |
| 542 originToDisplay = UrlUtilities.getOriginForDisplay(parsedUrl, fa
lse); | 547 originToDisplay = UrlUtilities.getOriginForDisplay(parsedUrl, fa
lse); |
| 543 } catch (URISyntaxException e) { | 548 } catch (URISyntaxException e) { |
| 544 // The URL is invalid - just display the full URL. | 549 // The URL is invalid - just display the full URL. |
| 545 originToDisplay = mFullUrl; | 550 originToDisplay = mFullUrl; |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 new WebsiteSettingsPopup(activity, profile, webContents); | 972 new WebsiteSettingsPopup(activity, profile, webContents); |
| 968 } | 973 } |
| 969 | 974 |
| 970 private static native long nativeInit(WebsiteSettingsPopup popup, WebContent
s webContents); | 975 private static native long nativeInit(WebsiteSettingsPopup popup, WebContent
s webContents); |
| 971 | 976 |
| 972 private native void nativeDestroy(long nativeWebsiteSettingsPopupAndroid); | 977 private native void nativeDestroy(long nativeWebsiteSettingsPopupAndroid); |
| 973 | 978 |
| 974 private native void nativeOnPermissionSettingChanged(long nativeWebsiteSetti
ngsPopupAndroid, | 979 private native void nativeOnPermissionSettingChanged(long nativeWebsiteSetti
ngsPopupAndroid, |
| 975 int type, int setting); | 980 int type, int setting); |
| 976 } | 981 } |
| OLD | NEW |