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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/WebsiteSettingsPopup.java

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

Powered by Google App Engine
This is Rietveld 408576698