Skip to content

Commit

Permalink
chore: cancel active pending requests if denied
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere authored and electron-bot committed Feb 9, 2022
1 parent 571a6ff commit d9ea5b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
3 changes: 3 additions & 0 deletions shell/browser/api/electron_api_web_contents.cc
Expand Up @@ -1403,6 +1403,9 @@ void WebContents::RequestExclusivePointerAccess(
if (allowed) {
exclusive_access_manager_->mouse_lock_controller()->RequestToLockMouse(
web_contents, user_gesture, last_unlocked_by_target);
} else {
web_contents->GotResponseToLockMouseRequest(
blink::mojom::PointerLockResult::kPermissionDenied);
}
}

Expand Down
14 changes: 2 additions & 12 deletions shell/browser/web_contents_permission_helper.cc
Expand Up @@ -43,16 +43,6 @@ void MediaAccessAllowed(const content::MediaStreamRequest& request,
controller.Deny(blink::mojom::MediaStreamRequestResult::PERMISSION_DENIED);
}

void OnPointerLockResponse(
base::OnceCallback<void(content::WebContents*, bool, bool, bool)> callback,
content::WebContents* web_contents,
bool user_gesture,
bool last_unlocked_by_target,
bool allowed) {
std::move(callback).Run(web_contents, user_gesture, last_unlocked_by_target,
allowed);
}

void OnPermissionResponse(base::OnceCallback<void(bool)> callback,
blink::mojom::PermissionStatus status) {
if (status == blink::mojom::PermissionStatus::GRANTED)
Expand Down Expand Up @@ -162,8 +152,8 @@ void WebContentsPermissionHelper::RequestPointerLockPermission(
callback) {
RequestPermission(
static_cast<content::PermissionType>(PermissionType::POINTER_LOCK),
base::BindOnce(&OnPointerLockResponse, std::move(callback), web_contents_,
user_gesture, last_unlocked_by_target),
base::BindOnce(std::move(callback), web_contents_, user_gesture,
last_unlocked_by_target),
user_gesture);
}

Expand Down

0 comments on commit d9ea5b7

Please sign in to comment.