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

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

Powered by Google App Engine
This is Rietveld 408576698