Bug 944533 - Inflate SiteIdentityPopup on show() and add identity setter (r=margaret)

This commit is contained in:
Lucas Rocha 2014-01-09 14:55:29 +00:00
parent 29fcce52f8
commit ed5a3ca3a4

View File

@ -37,6 +37,8 @@ public class SiteIdentityPopup extends ArrowPopup {
private static final String MIXED_CONTENT_SUPPORT_URL = private static final String MIXED_CONTENT_SUPPORT_URL =
"https://support.mozilla.org/kb/how-does-content-isnt-secure-affect-my-safety"; "https://support.mozilla.org/kb/how-does-content-isnt-secure-affect-my-safety";
private SiteIdentity mSiteIdentity;
private Resources mResources; private Resources mResources;
private LinearLayout mIdentity; private LinearLayout mIdentity;
@ -72,27 +74,31 @@ public class SiteIdentityPopup extends ArrowPopup {
mVerifier = (TextView) mIdentity.findViewById(R.id.verifier); mVerifier = (TextView) mIdentity.findViewById(R.id.verifier);
} }
private void setIdentity(SiteIdentity siteIdentity) { private void updateUi() {
if (siteIdentity.getSecurityMode() == SecurityMode.MIXED_CONTENT_LOADED) { if (!mInflated) {
init();
}
if (mSiteIdentity.getSecurityMode() == SecurityMode.MIXED_CONTENT_LOADED) {
// Hide the identity data if there isn't valid site identity data. // Hide the identity data if there isn't valid site identity data.
// Set some top padding on the popup content to create a of light blue // Set some top padding on the popup content to create a of light blue
// between the popup arrow and the mixed content notification. // between the popup arrow and the mixed content notification.
mContent.setPadding(0, (int) mResources.getDimension(R.dimen.identity_padding_top), 0, 0); mContent.setPadding(0, (int) mResources.getDimension(R.dimen.identity_padding_top), 0, 0);
mIdentity.setVisibility(View.GONE); mIdentity.setVisibility(View.GONE);
} else { } else {
mHost.setText(siteIdentity.getHost()); mHost.setText(mSiteIdentity.getHost());
String owner = siteIdentity.getOwner(); String owner = mSiteIdentity.getOwner();
// Supplemental data is optional. // Supplemental data is optional.
final String supplemental = siteIdentity.getSupplemental(); final String supplemental = mSiteIdentity.getSupplemental();
if (!TextUtils.isEmpty(supplemental)) { if (!TextUtils.isEmpty(supplemental)) {
owner += "\n" + supplemental; owner += "\n" + supplemental;
} }
mOwner.setText(owner); mOwner.setText(owner);
final String verifier = siteIdentity.getVerifier(); final String verifier = mSiteIdentity.getVerifier();
final String encrypted = siteIdentity.getEncrypted(); final String encrypted = mSiteIdentity.getEncrypted();
mVerifier.setText(verifier + "\n" + encrypted); mVerifier.setText(verifier + "\n" + encrypted);
mContent.setPadding(0, 0, 0, 0); mContent.setPadding(0, 0, 0, 0);
@ -140,22 +146,31 @@ public class SiteIdentityPopup extends ArrowPopup {
/* /*
* @param identityData A JSONObject that holds the current tab's identity data. * @param identityData A JSONObject that holds the current tab's identity data.
*/ */
void updateIdentity(SiteIdentity siteIdentity) { void setSiteIdentity(SiteIdentity siteIdentity) {
final SecurityMode mode = siteIdentity.getSecurityMode(); mSiteIdentity = siteIdentity;
}
@Override
public void show() {
if (mSiteIdentity == null) {
Log.e(LOGTAG, "Can't show site identity popup for undefined state");
return;
}
final SecurityMode mode = mSiteIdentity.getSecurityMode();
if (mode == SecurityMode.UNKNOWN) { if (mode == SecurityMode.UNKNOWN) {
Log.e(LOGTAG, "Can't show site identity popup in non-identified state"); Log.e(LOGTAG, "Can't show site identity popup in non-identified state");
return; return;
} }
if (!mInflated) updateUi();
init();
setIdentity(siteIdentity);
if (mode == SecurityMode.MIXED_CONTENT_LOADED || if (mode == SecurityMode.MIXED_CONTENT_LOADED ||
mode == SecurityMode.MIXED_CONTENT_BLOCKED) { mode == SecurityMode.MIXED_CONTENT_BLOCKED) {
addMixedContentNotification(mode == SecurityMode.MIXED_CONTENT_BLOCKED); addMixedContentNotification(mode == SecurityMode.MIXED_CONTENT_BLOCKED);
} }
super.show();
} }
@Override @Override