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