---
title: "Address bar and suggestions"
description: "Chrome's ranked address-bar suggestions for your own field, and the connection security the field shows."
---

```swift
import CefChromium

for try await result in profile.autocomplete.results(for: "swift") {
    print(result.suggestions.map(\.text), result.isComplete)
}
```

Gallery: [`SuggestionsDemo`](https://github.com/Rajaniraiyn/CefSwift/blob/main/Examples/Sources/Gallery/Demos/SuggestionsDemo.swift).
Browser example: [`Features/AddressBar`](https://github.com/Rajaniraiyn/CefSwift/tree/main/Examples/Sources/Browser/Features/AddressBar) is a full address field: inline completion, ↑ ↓ selection, Return and Esc.

Suggestions come from `profile.autocomplete`, which
[Bookmarks and history](/browser/bookmarks-history#bookmarks-history-and-suggestions)
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:

```swift
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:

```swift
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`.
