fix: pointer lock escape handling (#32369)

This commit is contained in:
Shelley Vohr 2022-02-09 10:40:50 +01:00 committed by GitHub
parent 841d223b3b
commit ac1d426c51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 25 deletions

View file

@ -43,17 +43,6 @@ void MediaAccessAllowed(const content::MediaStreamRequest& request,
controller.Deny(blink::mojom::MediaStreamRequestResult::PERMISSION_DENIED);
}
void OnPointerLockResponse(content::WebContents* web_contents, bool allowed) {
if (web_contents) {
if (allowed)
web_contents->GotResponseToLockMouseRequest(
blink::mojom::PointerLockResult::kSuccess);
else
web_contents->GotResponseToLockMouseRequest(
blink::mojom::PointerLockResult::kPermissionDenied);
}
}
void OnPermissionResponse(base::OnceCallback<void(bool)> callback,
blink::mojom::PermissionStatus status) {
if (status == blink::mojom::PermissionStatus::GRANTED)
@ -157,10 +146,15 @@ void WebContentsPermissionHelper::RequestWebNotificationPermission(
}
void WebContentsPermissionHelper::RequestPointerLockPermission(
bool user_gesture) {
bool user_gesture,
bool last_unlocked_by_target,
base::OnceCallback<void(content::WebContents*, bool, bool, bool)>
callback) {
RequestPermission(
static_cast<content::PermissionType>(PermissionType::POINTER_LOCK),
base::BindOnce(&OnPointerLockResponse, web_contents_), user_gesture);
base::BindOnce(std::move(callback), web_contents_, user_gesture,
last_unlocked_by_target),
user_gesture);
}
void WebContentsPermissionHelper::RequestOpenExternalPermission(