Bug 1249594 - Show name of owner (EV certificate) in URL bar if available. r=mcomella

MozReview-Commit-ID: 8A15R9KoBh

--HG--
extra : rebase_source : 59a0fe809a17c764fefe6d9f7485055ac0e20212
extra : histedit_source : 4ade7f4b3f05d15ed6c488f465a2bf0e67f4957a
This commit is contained in:
Sebastian Kaspari 2016-02-21 14:32:31 +01:00
Родитель 563b958a1e
Коммит 68e3eac5a1
3 изменённых файлов: 42 добавлений и 5 удалений

Просмотреть файл

@ -20,6 +20,7 @@ public class SiteIdentity {
private String mHost; private String mHost;
private String mOwner; private String mOwner;
private String mSupplemental; private String mSupplemental;
private String mCountry;
private String mVerifier; private String mVerifier;
private String mOrigin; private String mOrigin;
@ -133,6 +134,7 @@ public class SiteIdentity {
mHost = null; mHost = null;
mOwner = null; mOwner = null;
mSupplemental = null; mSupplemental = null;
mCountry = null;
mVerifier = null; mVerifier = null;
mSecure = false; mSecure = false;
mLoginInsecure = false; mLoginInsecure = false;
@ -184,6 +186,7 @@ public class SiteIdentity {
mHost = identityData.optString("host", null); mHost = identityData.optString("host", null);
mOwner = identityData.optString("owner", null); mOwner = identityData.optString("owner", null);
mSupplemental = identityData.optString("supplemental", null); mSupplemental = identityData.optString("supplemental", null);
mCountry = identityData.optString("country", null);
mVerifier = identityData.optString("verifier", null); mVerifier = identityData.optString("verifier", null);
mSecure = identityData.optBoolean("secure", false); mSecure = identityData.optBoolean("secure", false);
} catch (Exception e) { } catch (Exception e) {
@ -210,10 +213,22 @@ public class SiteIdentity {
return mOwner; return mOwner;
} }
public boolean hasOwner() {
return !TextUtils.isEmpty(mOwner);
}
public String getSupplemental() { public String getSupplemental() {
return mSupplemental; return mSupplemental;
} }
public String getCountry() {
return mCountry;
}
public boolean hasCountry() {
return !TextUtils.isEmpty(mCountry);
}
public String getVerifier() { public String getVerifier() {
return mVerifier; return mVerifier;
} }

Просмотреть файл

@ -30,7 +30,9 @@ import android.content.Context;
import android.os.SystemClock; import android.os.SystemClock;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.text.Spannable; import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.style.ForegroundColorSpan; import android.text.style.ForegroundColorSpan;
@ -267,7 +269,23 @@ public class ToolbarDisplayLayout extends ThemedLinearLayout {
// will read the content description to obtain the full URL for performing assertions. // will read the content description to obtain the full URL for performing assertions.
setContentDescription(strippedURL); setContentDescription(strippedURL);
if (!TextUtils.isEmpty(baseDomain)) { final SiteIdentity siteIdentity = tab.getSiteIdentity();
if (siteIdentity.hasOwner()) {
final String title;
if (siteIdentity.hasCountry()) {
title = String.format("%s (%s)", siteIdentity.getOwner(), siteIdentity.getCountry());
} else {
title = siteIdentity.getOwner();
}
final int color = ContextCompat.getColor(getContext(), R.color.affirmative_green);
final SpannableString spannable = new SpannableString(title);
spannable.setSpan(new ForegroundColorSpan(color), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
setTitle(spannable);
} else if (!TextUtils.isEmpty(baseDomain)) {
setTitle(baseDomain); setTitle(baseDomain);
} else { } else {
setTitle(strippedURL); setTitle(strippedURL);

Просмотреть файл

@ -6376,14 +6376,18 @@ var IdentityHandler = {
// Build an appropriate supplemental block out of whatever location data we have // Build an appropriate supplemental block out of whatever location data we have
let supplemental = ""; let supplemental = "";
if (iData.city) if (iData.city) {
supplemental += iData.city + "\n"; supplemental += iData.city + "\n";
if (iData.state && iData.country) }
if (iData.state && iData.country) {
supplemental += Strings.browser.formatStringFromName("identity.identified.state_and_country", [iData.state, iData.country], 2); supplemental += Strings.browser.formatStringFromName("identity.identified.state_and_country", [iData.state, iData.country], 2);
else if (iData.state) // State only result.country = iData.country;
} else if (iData.state) { // State only
supplemental += iData.state; supplemental += iData.state;
else if (iData.country) // Country only } else if (iData.country) { // Country only
supplemental += iData.country; supplemental += iData.country;
result.country = iData.country;
}
result.supplemental = supplemental; result.supplemental = supplemental;
return result; return result;