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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 import org.chromium.base.ApiCompatibilityUtils; | 43 import org.chromium.base.ApiCompatibilityUtils; |
44 import org.chromium.base.annotations.CalledByNative; | 44 import org.chromium.base.annotations.CalledByNative; |
45 import org.chromium.chrome.R; | 45 import org.chromium.chrome.R; |
46 import org.chromium.chrome.browser.omnibox.OmniboxUrlEmphasizer; | 46 import org.chromium.chrome.browser.omnibox.OmniboxUrlEmphasizer; |
47 import org.chromium.chrome.browser.preferences.PrefServiceBridge; | 47 import org.chromium.chrome.browser.preferences.PrefServiceBridge; |
48 import org.chromium.chrome.browser.preferences.Preferences; | 48 import org.chromium.chrome.browser.preferences.Preferences; |
49 import org.chromium.chrome.browser.preferences.PreferencesLauncher; | 49 import org.chromium.chrome.browser.preferences.PreferencesLauncher; |
50 import org.chromium.chrome.browser.preferences.website.SingleWebsitePreferences; | 50 import org.chromium.chrome.browser.preferences.website.SingleWebsitePreferences; |
51 import org.chromium.chrome.browser.profiles.Profile; | 51 import org.chromium.chrome.browser.profiles.Profile; |
| 52 import org.chromium.chrome.browser.ssl.ConnectionSecurity; |
52 import org.chromium.chrome.browser.ssl.ConnectionSecurityLevel; | 53 import org.chromium.chrome.browser.ssl.ConnectionSecurityLevel; |
53 import org.chromium.chrome.browser.ssl.SecurityStateModel; | 54 import org.chromium.chrome.browser.toolbar.ToolbarModel; |
54 import org.chromium.content.browser.ContentViewCore; | 55 import org.chromium.content.browser.ContentViewCore; |
55 import org.chromium.content_public.browser.WebContents; | 56 import org.chromium.content_public.browser.WebContents; |
56 import org.chromium.content_public.browser.WebContentsObserver; | 57 import org.chromium.content_public.browser.WebContentsObserver; |
57 import org.chromium.ui.base.DeviceFormFactor; | 58 import org.chromium.ui.base.DeviceFormFactor; |
58 import org.chromium.ui.base.WindowAndroid; | 59 import org.chromium.ui.base.WindowAndroid; |
59 import org.chromium.ui.base.WindowAndroid.PermissionCallback; | 60 import org.chromium.ui.base.WindowAndroid.PermissionCallback; |
60 import org.chromium.ui.interpolators.BakedBezierInterpolator; | 61 import org.chromium.ui.interpolators.BakedBezierInterpolator; |
61 | 62 |
62 import java.net.URI; | 63 import java.net.URI; |
63 import java.net.URISyntaxException; | 64 import java.net.URISyntaxException; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 // parsed. | 248 // parsed. |
248 private URI mParsedUrl; | 249 private URI mParsedUrl; |
249 | 250 |
250 // Whether or not this page is an internal chrome page (e.g. the | 251 // Whether or not this page is an internal chrome page (e.g. the |
251 // chrome://settings page). | 252 // chrome://settings page). |
252 private boolean mIsInternalPage; | 253 private boolean mIsInternalPage; |
253 | 254 |
254 // The security level of the page (a valid ConnectionSecurityLevel). | 255 // The security level of the page (a valid ConnectionSecurityLevel). |
255 private int mSecurityLevel; | 256 private int mSecurityLevel; |
256 | 257 |
257 // Whether the security level of the page was downgraded due to SHA-1. | 258 // Whether the security level of the page was deprecated due to SHA-1. |
258 private boolean mDeprecatedSHA1Present; | 259 private boolean mDeprecatedSHA1Present; |
259 | 260 |
260 // Whether the security level of the page was downgraded due to passive mixe
d content. | |
261 private boolean mPassiveMixedContentPresent; | |
262 | |
263 // Permissions available to be displayed in mPermissionsList. | 261 // Permissions available to be displayed in mPermissionsList. |
264 private List<PageInfoPermissionEntry> mDisplayedPermissions; | 262 private List<PageInfoPermissionEntry> mDisplayedPermissions; |
265 | 263 |
266 /** | 264 /** |
267 * Creates the WebsiteSettingsPopup, but does not display it. Also initializ
es the corresponding | 265 * Creates the WebsiteSettingsPopup, but does not display it. Also initializ
es the corresponding |
268 * C++ object and saves a pointer to it. | 266 * C++ object and saves a pointer to it. |
269 * | 267 * |
270 * @param context Context which is used for launching a dialog. | 268 * @param context Context which is used for launching a dialog. |
271 * @param webContents The WebContents for which to show Website information.
This information is | 269 * @param webContents The WebContents for which to show Website information.
This information is |
272 * retrieved for the visible entry. | 270 * retrieved for the visible entry. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 | 380 |
383 // Work out the URL and connection message. | 381 // Work out the URL and connection message. |
384 mFullUrl = mWebContents.getVisibleUrl(); | 382 mFullUrl = mWebContents.getVisibleUrl(); |
385 try { | 383 try { |
386 mParsedUrl = new URI(mFullUrl); | 384 mParsedUrl = new URI(mFullUrl); |
387 mIsInternalPage = UrlUtilities.isInternalScheme(mParsedUrl); | 385 mIsInternalPage = UrlUtilities.isInternalScheme(mParsedUrl); |
388 } catch (URISyntaxException e) { | 386 } catch (URISyntaxException e) { |
389 mParsedUrl = null; | 387 mParsedUrl = null; |
390 mIsInternalPage = false; | 388 mIsInternalPage = false; |
391 } | 389 } |
392 mSecurityLevel = SecurityStateModel.getSecurityLevelForWebContents(mWebC
ontents); | 390 mSecurityLevel = ConnectionSecurity.getSecurityLevelForWebContents(mWebC
ontents); |
393 mDeprecatedSHA1Present = SecurityStateModel.isDeprecatedSHA1Present(mWeb
Contents); | 391 mDeprecatedSHA1Present = ToolbarModel.isDeprecatedSHA1Present(mWebConten
ts); |
394 mPassiveMixedContentPresent = SecurityStateModel.isPassiveMixedContentPr
esent(mWebContents); | |
395 | 392 |
396 SpannableStringBuilder urlBuilder = new SpannableStringBuilder(mFullUrl)
; | 393 SpannableStringBuilder urlBuilder = new SpannableStringBuilder(mFullUrl)
; |
397 OmniboxUrlEmphasizer.emphasizeUrl(urlBuilder, mContext.getResources(), m
Profile, | 394 OmniboxUrlEmphasizer.emphasizeUrl(urlBuilder, mContext.getResources(), m
Profile, |
398 mSecurityLevel, mIsInternalPage, true, true); | 395 mSecurityLevel, mIsInternalPage, true, true); |
399 mUrlTitle.setText(urlBuilder); | 396 mUrlTitle.setText(urlBuilder); |
400 | 397 |
401 // Set the URL connection message now, and the URL after layout (so it | 398 // Set the URL connection message now, and the URL after layout (so it |
402 // can calculate its ideal height). | 399 // can calculate its ideal height). |
403 mUrlConnectionMessage.setText(getUrlConnectionMessage()); | 400 mUrlConnectionMessage.setText(getUrlConnectionMessage()); |
404 if (isConnectionDetailsLinkVisible()) mUrlConnectionMessage.setOnClickLi
stener(this); | 401 if (isConnectionDetailsLinkVisible()) mUrlConnectionMessage.setOnClickLi
stener(this); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 */ | 459 */ |
463 private int getConnectionMessageId(int securityLevel, boolean isInternalPage
) { | 460 private int getConnectionMessageId(int securityLevel, boolean isInternalPage
) { |
464 if (isInternalPage) return R.string.page_info_connection_internal_page; | 461 if (isInternalPage) return R.string.page_info_connection_internal_page; |
465 | 462 |
466 switch (securityLevel) { | 463 switch (securityLevel) { |
467 case ConnectionSecurityLevel.NONE: | 464 case ConnectionSecurityLevel.NONE: |
468 return R.string.page_info_connection_http; | 465 return R.string.page_info_connection_http; |
469 case ConnectionSecurityLevel.SECURE: | 466 case ConnectionSecurityLevel.SECURE: |
470 case ConnectionSecurityLevel.EV_SECURE: | 467 case ConnectionSecurityLevel.EV_SECURE: |
471 return R.string.page_info_connection_https; | 468 return R.string.page_info_connection_https; |
| 469 case ConnectionSecurityLevel.SECURITY_WARNING: |
| 470 case ConnectionSecurityLevel.SECURITY_POLICY_WARNING: |
| 471 return R.string.page_info_connection_mixed; |
472 default: | 472 default: |
473 assert false : "Invalid security level specified: " + securityLe
vel; | 473 assert false : "Invalid security level specified: " + securityLe
vel; |
474 return R.string.page_info_connection_http; | 474 return R.string.page_info_connection_http; |
475 } | 475 } |
476 } | 476 } |
477 | 477 |
478 /** | 478 /** |
479 * Whether to show a 'Details' link to the connection info popup. The link i
s only shown for | 479 * Whether to show a 'Details' link to the connection info popup. The link i
s only shown for |
480 * HTTPS connections. | 480 * HTTPS connections. |
481 */ | 481 */ |
482 private boolean isConnectionDetailsLinkVisible() { | 482 private boolean isConnectionDetailsLinkVisible() { |
483 return !mIsInternalPage && mSecurityLevel != ConnectionSecurityLevel.NON
E; | 483 return !mIsInternalPage && mSecurityLevel != ConnectionSecurityLevel.NON
E; |
484 } | 484 } |
485 | 485 |
486 /** | 486 /** |
487 * Gets the styled connection message to display below the URL. | 487 * Gets the styled connection message to display below the URL. |
488 */ | 488 */ |
489 private Spannable getUrlConnectionMessage() { | 489 private Spannable getUrlConnectionMessage() { |
490 // Display the appropriate connection message. | 490 // Display the appropriate connection message. |
491 SpannableStringBuilder messageBuilder = new SpannableStringBuilder(); | 491 SpannableStringBuilder messageBuilder = new SpannableStringBuilder(); |
492 if (mDeprecatedSHA1Present) { | 492 if (mDeprecatedSHA1Present) { |
493 messageBuilder.append( | 493 messageBuilder.append( |
494 mContext.getResources().getString(R.string.page_info_connect
ion_sha1)); | 494 mContext.getResources().getString(R.string.page_info_connect
ion_sha1)); |
495 } else if (mPassiveMixedContentPresent) { | 495 } else if (mSecurityLevel != ConnectionSecurityLevel.SECURITY_ERROR) { |
496 messageBuilder.append( | |
497 mContext.getResources().getString(R.string.page_info_connect
ion_mixed)); | |
498 } else if (mSecurityLevel != ConnectionSecurityLevel.SECURITY_ERROR | |
499 && mSecurityLevel != ConnectionSecurityLevel.SECURITY_WARNING | |
500 && mSecurityLevel != ConnectionSecurityLevel.SECURITY_POLICY_WAR
NING) { | |
501 messageBuilder.append(mContext.getResources().getString( | 496 messageBuilder.append(mContext.getResources().getString( |
502 getConnectionMessageId(mSecurityLevel, mIsInternalPage))); | 497 getConnectionMessageId(mSecurityLevel, mIsInternalPage))); |
503 } else { | 498 } else { |
504 String originToDisplay; | 499 String originToDisplay; |
505 try { | 500 try { |
506 URI parsedUrl = new URI(mFullUrl); | 501 URI parsedUrl = new URI(mFullUrl); |
507 originToDisplay = UrlUtilities.getOriginForDisplay(parsedUrl, fa
lse); | 502 originToDisplay = UrlUtilities.getOriginForDisplay(parsedUrl, fa
lse); |
508 } catch (URISyntaxException e) { | 503 } catch (URISyntaxException e) { |
509 // The URL is invalid - just display the full URL. | 504 // The URL is invalid - just display the full URL. |
510 originToDisplay = mFullUrl; | 505 originToDisplay = mFullUrl; |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 new WebsiteSettingsPopup(activity, profile, webContents); | 855 new WebsiteSettingsPopup(activity, profile, webContents); |
861 } | 856 } |
862 | 857 |
863 private static native long nativeInit(WebsiteSettingsPopup popup, WebContent
s webContents); | 858 private static native long nativeInit(WebsiteSettingsPopup popup, WebContent
s webContents); |
864 | 859 |
865 private native void nativeDestroy(long nativeWebsiteSettingsPopupAndroid); | 860 private native void nativeDestroy(long nativeWebsiteSettingsPopupAndroid); |
866 | 861 |
867 private native void nativeOnPermissionSettingChanged(long nativeWebsiteSetti
ngsPopupAndroid, | 862 private native void nativeOnPermissionSettingChanged(long nativeWebsiteSetti
ngsPopupAndroid, |
868 int type, int setting); | 863 int type, int setting); |
869 } | 864 } |
OLD | NEW |