diff options
| author | Kaloyan Chehlarski <kaloyan.chehlarski@qt.io> | 2025-12-10 16:00:37 +0100 |
|---|---|---|
| committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2025-12-16 22:34:04 +0100 |
| commit | a2a80c119338dcc3c5bccef91f73cc6e55b3e606 (patch) | |
| tree | 3175dcf118c3259b690a80c354e442b66ec4aea5 /src/core | |
| parent | b9649b2537522371b5dfe55b5d60a6fcc0d23445 (diff) | |
Following the Chromium 140 integration, there was a mismatch
between the origin that was stored in the permanent store, and
the one Chromium queried when setting a permission for a custom URL
scheme with no base origin (e.g. "qrc://filename.html"). Specifically,
we would store "qrc://", but Chromium would look up "qrc:". Since
the lookup is text-based, the permission query would always return ASK.
This commit adds conversions to url::Origin before storing
and retrieving the permission, which makes the results equal again.
Pick-to: 6.11
Change-Id: I929c63d4395ec4382f1f93590ca3528b7562e2e6
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/permission_manager_qt.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp index 502f4deb9..7a7f24b67 100644 --- a/src/core/permission_manager_qt.cpp +++ b/src/core/permission_manager_qt.cpp @@ -469,8 +469,15 @@ QList<QWebEnginePermission> PermissionManagerQt::listPermissions( Q_ASSERT(origin.isEmpty() || permissionType == QWebEnginePermission::PermissionType::Unsupported); QList<QWebEnginePermission> returnList; - const GURL gorigin = toGurl(origin).DeprecatedGetOriginAsURL(); - const std::string originSpec = gorigin.spec(); + const GURL gorigin = toGurl(origin); + std::string originString = url::Origin::Create(gorigin).Serialize(); + + if (originString == "null") { + // Origin::Serialize() returns "null" for empty URLs. + // Set originString to empty string so we don't have to do + // string comparisons for every permission in the loop below. + originString.clear(); + } if (!origin.isEmpty() && !gorigin.is_valid()) return returnList; @@ -495,7 +502,7 @@ QList<QWebEnginePermission> PermissionManagerQt::listPermissions( Q_ASSERT(prefDict); for (auto &&entry : *prefDict) { - if (!originSpec.empty() && entry.first != originSpec) + if (!originString.empty() && entry.first != originString) continue; auto *pvt = new QWebEnginePermissionPrivate( @@ -695,7 +702,7 @@ blink::mojom::PermissionStatus PermissionManagerQt::GetPermissionStatus( const auto *permissionsDict = pref->GetValue()->GetIfDict(); Q_ASSERT(permissionsDict); - const auto requestedPermission = permissionsDict->FindBool(requesting_origin.DeprecatedGetOriginAsURL().spec()); + const auto requestedPermission = permissionsDict->FindBool(url::Origin::Create(requesting_origin).Serialize()); if (!requestedPermission) return blink::mojom::PermissionStatus::ASK; // Origin is not in the current permission type's database @@ -790,7 +797,7 @@ void PermissionManagerQt::ResetPermission( return; ScopedDictPrefUpdate updater(m_prefService.get(), permissionTypeString(permissionType)); - updater.Get().Remove(requesting_origin.spec()); + updater.Get().Remove(url::Origin::Create(requesting_origin).Serialize()); } blink::mojom::PermissionStatus PermissionManagerQt::getTransientPermissionStatus( @@ -829,7 +836,7 @@ void PermissionManagerQt::setPersistentPermission( return; ScopedDictPrefUpdate updater(m_prefService.get(), permissionTypeString(permissionTypeQt)); - updater.Get().Set(requesting_origin.spec(), granted); + updater.Get().Set(url::Origin::Create(requesting_origin).Serialize(), granted); m_prefService->SchedulePendingLossyWrites(); } |
