Files
iOS/Sources/App/Frontend/WebView/WebViewController+Onboarding.swift
Bruno Pantaleão Gonçalves a20ae2f593 Prevent unnecessary location access popup when https context (#4468)
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->
2026-04-02 12:00:40 +02:00

52 lines
2.3 KiB
Swift

import Shared
import SwiftUI
import UIKit
// MARK: - Onboarding & Security Level
extension WebViewController {
/// If user has not chosen 'Most secure' or 'Less secure' local access yet, this triggers a screen for decision
func checkForLocalSecurityLevelDecisionNeeded() {
let connection = server.info.connection
if Current.location.permissionStatus == .notDetermined, connection.hasNonHTTPSURLOptions {
Current.Log.verbose("User has not decided location permission yet")
showOnboardingPermissions(steps: OnboardingPermissionsNavigationViewModel.StepID.updateLocationPermission)
} else if connection.connectionAccessSecurityLevel == .undefined, !connection.hasOnlyHTTPSURLOptions {
Current.Log.verbose("User has not decided local access security level yet")
showOnboardingPermissions(
steps: OnboardingPermissionsNavigationViewModel.StepID
.updateLocalAccessSecurityLevelPreference
)
} else if connection.hasOnlyHTTPSURLOptions {
Current.Log.verbose("Skipping local access security level decision because all configured URLs use HTTPS")
} else {
Current.Log
.verbose(
"User decided \(connection.connectionAccessSecurityLevel) for local access security level"
)
}
}
func showOnboardingPermissions(steps: [OnboardingPermissionsNavigationViewModel.StepID]) {
let controller = NavigationView {
OnboardingPermissionsNavigationView(onboardingServer: server, steps: steps)
.toolbar {
ToolbarItem(placement: .topBarLeading) {
CloseButton { [weak self] in
self?.dismiss(animated: true)
}
}
}
.onDisappear { [weak self] in
self?.refresh()
}
}.navigationViewStyle(.stack).embeddedInHostingController()
// Prevent controller on being dismissed on swipe down
controller.isModalInPresentation = true
controller.view.tag = WebViewControllerOverlayedViewTags.onboardingPermissions.rawValue
presentOverlayController(controller: controller, animated: true)
}
}