Bug 1314563 - Add info for Java to know when the url is in the exception list and show the correct icon r?sebastian
MozReview-Commit-ID: FG6a7mRCzZY
--- a/mobile/android/base/java/org/mozilla/gecko/SiteIdentity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/SiteIdentity.java
@@ -11,16 +11,17 @@ import android.text.TextUtils;
public class SiteIdentity {
private final String LOGTAG = "GeckoSiteIdentity";
private SecurityMode mSecurityMode;
private boolean mSecure;
private MixedMode mMixedModeActive;
private MixedMode mMixedModeDisplay;
private TrackingMode mTrackingMode;
+ private boolean mSecurityException;
private String mHost;
private String mOwner;
private String mSupplemental;
private String mCountry;
private String mVerifier;
private String mOrigin;
// The order of the items here relate to image levels in
@@ -124,30 +125,32 @@ public class SiteIdentity {
}
public SiteIdentity() {
reset();
}
public void resetIdentity() {
mSecurityMode = SecurityMode.UNKNOWN;
+ mSecurityException = false;
mOrigin = null;
mHost = null;
mOwner = null;
mSupplemental = null;
mCountry = null;
mVerifier = null;
mSecure = false;
}
public void reset() {
resetIdentity();
mMixedModeActive = MixedMode.UNKNOWN;
mMixedModeDisplay = MixedMode.UNKNOWN;
mTrackingMode = TrackingMode.UNKNOWN;
+ mSecurityException = false;
}
void update(JSONObject identityData) {
if (identityData == null) {
reset();
return;
}
@@ -182,16 +185,18 @@ public class SiteIdentity {
try {
mOrigin = identityData.getString("origin");
mHost = identityData.optString("host", null);
mOwner = identityData.optString("owner", null);
mSupplemental = identityData.optString("supplemental", null);
mCountry = identityData.optString("country", null);
mVerifier = identityData.optString("verifier", null);
mSecure = identityData.optBoolean("secure", false);
+ mSecurityException = identityData.optBoolean("securityException", false);
+
} catch (Exception e) {
resetIdentity();
}
} catch (Exception e) {
reset();
}
}
@@ -238,12 +243,16 @@ public class SiteIdentity {
public MixedMode getMixedModeActive() {
return mMixedModeActive;
}
public MixedMode getMixedModeDisplay() {
return mMixedModeDisplay;
}
+ public boolean isSecurityException() {
+ return mSecurityException;
+ }
+
public TrackingMode getTrackingMode() {
return mTrackingMode;
}
}
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
@@ -350,26 +350,30 @@ public class ToolbarDisplayLayout extend
final SiteIdentity siteIdentity = tab.getSiteIdentity();
mSiteIdentityPopup.setSiteIdentity(siteIdentity);
final SecurityMode securityMode;
final MixedMode activeMixedMode;
final MixedMode displayMixedMode;
final TrackingMode trackingMode;
+ final boolean securityException;
+
if (siteIdentity == null) {
securityMode = SecurityMode.UNKNOWN;
activeMixedMode = MixedMode.UNKNOWN;
displayMixedMode = MixedMode.UNKNOWN;
trackingMode = TrackingMode.UNKNOWN;
+ securityException = false;
} else {
securityMode = siteIdentity.getSecurityMode();
activeMixedMode = siteIdentity.getMixedModeActive();
displayMixedMode = siteIdentity.getMixedModeDisplay();
trackingMode = siteIdentity.getTrackingMode();
+ securityException = siteIdentity.isSecurityException();
}
// This is a bit tricky, but we have one icon and three potential indicators.
// Default to the identity level
int imageLevel = securityMode.ordinal();
// about: pages should default to having no icon too (the same as SecurityMode.UNKNOWN), however
// SecurityMode.CHROMEUI has a different ordinal - hence we need to manually reset it here.
@@ -378,16 +382,18 @@ public class ToolbarDisplayLayout extend
if (securityMode == SecurityMode.CHROMEUI) {
imageLevel = LEVEL_DEFAULT_GLOBE; // == SecurityMode.UNKNOWN.ordinal()
}
// Check to see if any protection was overridden first
if (AboutPages.isTitlelessAboutPage(tab.getURL())) {
// We always want to just show a search icon on about:home
imageLevel = LEVEL_SEARCH_ICON;
+ } else if (securityException) {
+ imageLevel = LEVEL_WARNING_MINOR;
} else if (trackingMode == TrackingMode.TRACKING_CONTENT_LOADED) {
imageLevel = LEVEL_SHIELD_DISABLED;
} else if (trackingMode == TrackingMode.TRACKING_CONTENT_BLOCKED) {
imageLevel = LEVEL_SHIELD_ENABLED;
} else if (activeMixedMode == MixedMode.MIXED_CONTENT_LOADED) {
imageLevel = LEVEL_LOCK_DISABLED;
} else if (displayMixedMode == MixedMode.MIXED_CONTENT_LOADED) {
imageLevel = LEVEL_WARNING_MINOR;
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -5871,19 +5871,20 @@ var IdentityHandler = {
// something in the default case (bug 432241).
// .hostname can return an empty string in some exceptional cases -
// hasMatchingOverride does not handle that, so avoid calling it.
// Updating the tooltip value in those cases isn't critical.
// FIXME: Fixing bug 646690 would probably makes this check unnecessary
if (this._lastLocation.hostname &&
this._overrideService.hasMatchingOverride(this._lastLocation.hostname,
(this._lastLocation.port || 443),
- iData.cert, {}, {}))
+ iData.cert, {}, {})) {
result.verifier = Strings.browser.GetStringFromName("identity.identified.verified_by_you");
-
+ result.securityException = true;
+ }
return result;
},
/**
* Attempt to provide proper IDN treatment for host names
*/
getEffectiveHost: function getEffectiveHost() {
if (!this._IDNService)