For #5073: View Site Cert
parent
4fec12b127
commit
7c00a1ad6b
|
@ -158,7 +158,8 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
|
|||
title = session.title,
|
||||
isSecured = session.securityInfo.secure,
|
||||
sitePermissions = sitePermissions,
|
||||
gravity = getAppropriateLayoutGravity()
|
||||
gravity = getAppropriateLayoutGravity(),
|
||||
certificateName = session.securityInfo.issuer
|
||||
)
|
||||
nav(R.id.browserFragment, directions)
|
||||
}
|
||||
|
|
|
@ -164,7 +164,8 @@ class ExternalAppBrowserFragment : BaseBrowserFragment(), UserInteractionHandler
|
|||
title = session.title,
|
||||
isSecured = session.securityInfo.secure,
|
||||
sitePermissions = sitePermissions,
|
||||
gravity = getAppropriateLayoutGravity()
|
||||
gravity = getAppropriateLayoutGravity(),
|
||||
certificateName = session.securityInfo.issuer
|
||||
)
|
||||
nav(R.id.externalAppBrowserFragment, directions)
|
||||
}
|
||||
|
|
|
@ -71,18 +71,20 @@ class QuickSettingsFragmentStore(
|
|||
* @param isSecured [Boolean] whether the connection is secured (TLS) or not.
|
||||
* @param permissions [SitePermissions]? list of website permissions and their status.
|
||||
* @param settings [Settings] application settings.
|
||||
* @param certificateName [String] the certificate name of the current web page.
|
||||
*/
|
||||
@Suppress("LongParameterList")
|
||||
fun createStore(
|
||||
context: Context,
|
||||
websiteUrl: String,
|
||||
websiteTitle: String,
|
||||
certificateName: String,
|
||||
isSecured: Boolean,
|
||||
permissions: SitePermissions?,
|
||||
settings: Settings
|
||||
) = QuickSettingsFragmentStore(
|
||||
QuickSettingsFragmentState(
|
||||
webInfoState = createWebsiteInfoState(websiteUrl, websiteTitle, isSecured),
|
||||
webInfoState = createWebsiteInfoState(websiteUrl, websiteTitle, isSecured, certificateName),
|
||||
websitePermissionsState = createWebsitePermissionState(
|
||||
context,
|
||||
permissions,
|
||||
|
@ -104,13 +106,14 @@ class QuickSettingsFragmentStore(
|
|||
fun createWebsiteInfoState(
|
||||
websiteUrl: String,
|
||||
websiteTitle: String,
|
||||
isSecured: Boolean
|
||||
isSecured: Boolean,
|
||||
certificateName: String
|
||||
): WebsiteInfoState {
|
||||
val (stringRes, iconRes, colorRes) = when (isSecured) {
|
||||
true -> getSecuredWebsiteUiValues
|
||||
false -> getInsecureWebsiteUiValues
|
||||
}
|
||||
return WebsiteInfoState(websiteUrl, websiteTitle, stringRes, iconRes, colorRes)
|
||||
return WebsiteInfoState(websiteUrl, websiteTitle, stringRes, iconRes, colorRes, certificateName)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -230,7 +233,8 @@ data class WebsiteInfoState(
|
|||
val websiteTitle: String,
|
||||
@StringRes val securityInfoRes: Int,
|
||||
@DrawableRes val iconRes: Int,
|
||||
@ColorRes val iconTintRes: Int
|
||||
@ColorRes val iconTintRes: Int,
|
||||
val certificateName: String
|
||||
) : State
|
||||
|
||||
/**
|
||||
|
|
|
@ -65,7 +65,8 @@ class QuickSettingsSheetDialogFragment : AppCompatDialogFragment() {
|
|||
websiteTitle = args.title,
|
||||
isSecured = args.isSecured,
|
||||
permissions = args.sitePermissions,
|
||||
settings = Settings.getInstance(context)
|
||||
settings = Settings.getInstance(context),
|
||||
certificateName = args.certificateName
|
||||
)
|
||||
|
||||
quickSettingsController = DefaultQuickSettingsController(
|
||||
|
|
|
@ -39,6 +39,7 @@ class WebsiteInfoView(
|
|||
bindUrl(state.websiteUrl)
|
||||
bindTitle(state.websiteTitle)
|
||||
bindSecurityInfo(state.securityInfoRes, state.iconRes, state.iconTintRes)
|
||||
bindCertificateName(state.certificateName)
|
||||
}
|
||||
|
||||
private fun bindUrl(url: String) {
|
||||
|
@ -49,6 +50,11 @@ class WebsiteInfoView(
|
|||
view.title.text = title
|
||||
}
|
||||
|
||||
private fun bindCertificateName(cert: String) {
|
||||
val certificateLabel = view.context.getString(R.string.verified_by) + " " + cert
|
||||
view.certificateInfo.text = certificateLabel
|
||||
}
|
||||
|
||||
private fun bindSecurityInfo(
|
||||
@StringRes securityInfoRes: Int,
|
||||
@DrawableRes iconRes: Int,
|
||||
|
|
|
@ -34,7 +34,22 @@
|
|||
style="@style/QuickSettingsText.Icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
android:paddingTop="8dp"
|
||||
tools:drawableStart="@drawable/mozac_ic_lock"
|
||||
tools:drawableTint="@color/photonGreen50"
|
||||
tools:text="Secure connection" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/certificateInfo"
|
||||
style="@style/QuickSettingsSmallText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:paddingTop="0dp"
|
||||
android:paddingBottom="2dp"
|
||||
tools:text="Verified By:" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -612,6 +612,10 @@
|
|||
android:name="gravity"
|
||||
android:defaultValue="80"
|
||||
app:argType="integer" />
|
||||
<argument
|
||||
android:name="certificateName"
|
||||
android:defaultValue=" "
|
||||
app:argType="string" />
|
||||
<action
|
||||
android:id="@+id/action_quickSettingsSheetDialogFragment_to_SitePermissionsManagePhoneFeature"
|
||||
app:destination="@id/SitePermissionsManagePhoneFeature"
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
<dimen name="tp_onboarding_triangle_height">16dp</dimen>
|
||||
|
||||
<!--Quick Settings-->
|
||||
<dimen name="quicksettings_item_height">46dp</dimen>
|
||||
<dimen name="quicksettings_item_height">28dp</dimen>
|
||||
<dimen name="tracking_protection_item_height">48dp</dimen>
|
||||
|
||||
<dimen name="design_quick_action_sheet_peek_height_min">64dp</dimen>
|
||||
|
|
|
@ -1199,4 +1199,6 @@
|
|||
|
||||
<!-- Bookmark deletion confirmation -->
|
||||
<string name="bookmark_deletion_confirmation">Are you sure you want to delete this bookmark?</string>
|
||||
<!-- text shown before the issuer name to indicate who its verified by -->
|
||||
<string name="verified_by">Verified By:</string>
|
||||
</resources>
|
||||
|
|
|
@ -294,6 +294,15 @@
|
|||
<item name="android:layout_alignParentStart">true</item>
|
||||
</style>
|
||||
|
||||
<style name="QuickSettingsSmallText">
|
||||
<item name="android:textColor">@color/photonGrey60</item>
|
||||
<item name="android:textSize">12sp</item>
|
||||
<item name="android:paddingStart">48dp</item>
|
||||
<item name="android:paddingEnd">16dp</item>
|
||||
<item name="android:gravity">top</item>
|
||||
<item name="android:layout_alignParentStart">true</item>
|
||||
</style>
|
||||
|
||||
<style name="QuickSettingsText.Icon">
|
||||
<item name="android:drawablePadding">8dp</item>
|
||||
</style>
|
||||
|
|
|
@ -57,7 +57,7 @@ class QuickSettingsFragmentStoreTest {
|
|||
val permissions = mockk<SitePermissions>(relaxed = true)
|
||||
|
||||
val store = QuickSettingsFragmentStore.createStore(
|
||||
context, "url", "Hello", true, permissions, settings
|
||||
context, "url", "Hello", "issuer", true, permissions, settings
|
||||
)
|
||||
|
||||
assertAll {
|
||||
|
@ -72,9 +72,10 @@ class QuickSettingsFragmentStoreTest {
|
|||
fun `createWebsiteInfoState constructs a WebsiteInfoState with the right values for a secure connection`() {
|
||||
val websiteUrl = "https://host.com/page1"
|
||||
val websiteTitle = "Hello"
|
||||
val certificateIssuer = "issuer"
|
||||
val securedStatus = true
|
||||
|
||||
val state = QuickSettingsFragmentStore.createWebsiteInfoState(websiteUrl, websiteTitle, securedStatus)
|
||||
val state = QuickSettingsFragmentStore.createWebsiteInfoState(websiteUrl, websiteTitle, securedStatus, certificateIssuer)
|
||||
|
||||
assertAll {
|
||||
assertThat(state).isNotNull()
|
||||
|
@ -90,9 +91,10 @@ class QuickSettingsFragmentStoreTest {
|
|||
fun `createWebsiteInfoState constructs a WebsiteInfoState with the right values for an insecure connection`() {
|
||||
val websiteUrl = "https://host.com/page1"
|
||||
val websiteTitle = "Hello"
|
||||
val certificateIssuer = "issuer"
|
||||
val securedStatus = false
|
||||
|
||||
val state = QuickSettingsFragmentStore.createWebsiteInfoState(websiteUrl, websiteTitle, securedStatus)
|
||||
val state = QuickSettingsFragmentStore.createWebsiteInfoState(websiteUrl, websiteTitle, securedStatus, certificateIssuer)
|
||||
|
||||
assertAll {
|
||||
assertThat(state).isNotNull()
|
||||
|
|
Loading…
Reference in New Issue