diff options
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/browser/PageDialogsHandler.java | 4 | ||||
-rw-r--r-- | src/com/android/browser/Tab.java | 26 |
2 files changed, 23 insertions, 7 deletions
diff --git a/src/com/android/browser/PageDialogsHandler.java b/src/com/android/browser/PageDialogsHandler.java index 89c2745..013eaf1 100644 --- a/src/com/android/browser/PageDialogsHandler.java +++ b/src/com/android/browser/PageDialogsHandler.java @@ -244,9 +244,7 @@ public class PageDialogsHandler { } mSSLCertificateView = tab; - // TODO: We should pass the certificate error for the page's main - // resource, if present. See http://b/5248376. - mSSLCertificateDialog = createSslCertificateDialog(cert, null) + mSSLCertificateDialog = createSslCertificateDialog(cert, tab.getSslCertificateError()) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java index f2aa529..f6658a6 100644 --- a/src/com/android/browser/Tab.java +++ b/src/com/android/browser/Tab.java @@ -210,9 +210,11 @@ class Tab implements PictureListener { String mOriginalUrl; String mTitle; SecurityState mSecurityState; + // This is non-null only when mSecurityState is SECURITY_STATE_BAD_CERTIFICATE. + SslError mSslCertificateError; Bitmap mFavicon; - boolean mIsBookmarkedSite = false; - boolean mIncognito = false; + boolean mIsBookmarkedSite; + boolean mIncognito; PageState(Context c, boolean incognito) { mIncognito = incognito; @@ -223,14 +225,12 @@ class Tab implements PictureListener { mOriginalUrl = mUrl = ""; mTitle = c.getString(R.string.new_tab); } - mFavicon = null; mSecurityState = SecurityState.SECURITY_STATE_NOT_SECURE; } PageState(Context c, boolean incognito, String url, Bitmap favicon) { mIncognito = incognito; mOriginalUrl = mUrl = url; - mTitle = null; if (URLUtil.isHttpsUrl(url)) { mSecurityState = SecurityState.SECURITY_STATE_SECURE; } else { @@ -925,6 +925,7 @@ class Tab implements PictureListener { // In case we stop when loading an HTTPS page from an HTTP page // but before a provisional load occurred mCurrentState.mSecurityState = SecurityState.SECURITY_STATE_NOT_SECURE; + mCurrentState.mSslCertificateError = null; } mCurrentState.mIncognito = view.isPrivateBrowsingEnabled(); } @@ -1905,8 +1906,13 @@ class Tab implements PictureListener { return mErrorConsole; } + /** + * Sets the security state, clears the SSL certificate error and informs + * the controller. + */ private void setSecurityState(SecurityState securityState) { mCurrentState.mSecurityState = securityState; + mCurrentState.mSslCertificateError = null; mWebViewController.onUpdatedSecurityState(this); } @@ -1917,6 +1923,15 @@ class Tab implements PictureListener { return mCurrentState.mSecurityState; } + /** + * Gets the SSL certificate error, if any, for the page's main resource. + * This is only non-null when the security state is + * SECURITY_STATE_BAD_CERTIFICATE. + */ + SslError getSslCertificateError() { + return mCurrentState.mSslCertificateError; + } + int getLoadProgress() { if (mInPageLoad) { return mPageLoadProgress; @@ -2271,7 +2286,10 @@ class Tab implements PictureListener { if (error.getUrl().equals(mCurrentState.mUrl)) { // The security state should currently be SECURITY_STATE_SECURE. setSecurityState(SecurityState.SECURITY_STATE_BAD_CERTIFICATE); + mCurrentState.mSslCertificateError = error; } else if (getSecurityState() == SecurityState.SECURITY_STATE_SECURE) { + // The page's main resource is secure and this error is for a + // sub-resource. setSecurityState(SecurityState.SECURITY_STATE_MIXED); } } |