Address bar and suggestions
Chrome's ranked address-bar suggestions for your own field, and the connection security the field shows.
import CefChromium
for try await result in profile.autocomplete.results(for: "swift") {
print(result.suggestions.map(\.text), result.isComplete)
}
Gallery: SuggestionsDemo.
Browser example: Features/AddressBar is a full address field: inline completion, ↑ ↓ selection, Return and Esc.
Suggestions come from profile.autocomplete, which
Bookmarks and history
documents with the stores it ranks from. The field’s security badge and
page info come from the page’s connection security, below.
Connection security
page.connectionSecurity describes how the page shown was loaded, and
changes as the page navigates:
if let security = page.connectionSecurity {
switch security.level {
case .secure: showLock()
case .partiallySecure, .notSecure: showWarning()
case .local: break // the app's scheme, a file, a Chromium page
}
print(security.protocolVersion as Any, security.certificate?.subject.displayName ?? "")
}
level sums up isSecureConnection, the certificateStatus Chromium
found (.dateInvalid, .authorityInvalid, .nameMismatch,
.extendedValidation, …) and whether the page displayedInsecureContent
or ranInsecureContent loaded over HTTP. protocolVersion is the TLS
version, .tls1_2, .tls1_3 or .quic; Chromium’s API gives no cipher
suite. An HTTPS page your own scheme handler serves has no TLS, so it is
.notSecure.
A CefCertificate has its subject and issuer (common name,
organizations, country, …), serialNumber, validFrom and validUntil,
the issuerChain the server sent, the sha256Fingerprint, and the
subjectAlternativeNames it covers. derRepresentation and
secCertificate bridge it to the Security framework, for example to show
the system’s certificate sheet:
import SecurityInterface
if let chain = page.connectionSecurity?.certificate?.secCertificateChain, let window = page.hostWindow {
SFCertificatePanel.shared().beginSheet(for: window, modalDelegate: nil, didEnd: nil,
contextInfo: nil, certificates: chain, showGroup: true)
}
The CefCertificateError that page(_:shouldProceedDespite:) receives
carries the same certificate and its status.