summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-10-06 12:12:53 +0100
committerSteve Block <steveblock@google.com>2011-10-10 10:21:50 +0100
commit08a6f0ce422a7cc35a9a27a0823b1ad604d70f48 (patch)
tree0ab26fd296dfe8bf08f01a9ce495e168483b47b5 /src
parent90ff868cf3b30fed8ba8e84f7a37fc44de07aec4 (diff)
downloadpackages_apps_Browser-08a6f0ce422a7cc35a9a27a0823b1ad604d70f48.zip
packages_apps_Browser-08a6f0ce422a7cc35a9a27a0823b1ad604d70f48.tar.gz
packages_apps_Browser-08a6f0ce422a7cc35a9a27a0823b1ad604d70f48.tar.bz2
When a page's main resource uses an invalid SSL certificate, reflect this in 'Page Info'
This requires us to keep track of the SslError, if present, for the main resource. Also remove some superfluous initializations. Bug: 5248376 Change-Id: I09b09990c58c8ef10220638ab2b10640692ae801
Diffstat (limited to 'src')
-rw-r--r--src/com/android/browser/PageDialogsHandler.java4
-rw-r--r--src/com/android/browser/Tab.java26
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);
}
}