feat: provide the frame URL with permission requests and checks (#18757)

* feat: provide the frame URL with permission requests and checks

Also provides a handy isMainFrame property to determine if it is an
iframe making the request

* chore: refactor to use base::Value

* chore: use Set<Type>Key over SetPath
This commit is contained in:
Samuel Attard 2019-06-13 11:11:43 -07:00 committed by GitHub
parent 7c76d0e34a
commit ac02ab9fde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 21 deletions

View file

@ -188,12 +188,13 @@ int AtomPermissionManager::RequestPermissionsWithDetails(
const auto callback =
base::BindRepeating(&AtomPermissionManager::OnPermissionResponse,
base::Unretained(this), request_id, i);
if (details == nullptr) {
request_handler_.Run(web_contents, permission, callback,
base::DictionaryValue());
} else {
request_handler_.Run(web_contents, permission, callback, *details);
}
auto mutable_details =
details == nullptr ? base::DictionaryValue() : details->Clone();
mutable_details.SetStringKey(
"requestingUrl", render_frame_host->GetLastCommittedURL().spec());
mutable_details.SetBoolKey("isMainFrame",
render_frame_host->GetParent() == nullptr);
request_handler_.Run(web_contents, permission, callback, mutable_details);
}
return request_id;
@ -246,8 +247,14 @@ bool AtomPermissionManager::CheckPermissionWithDetails(
}
auto* web_contents =
content::WebContents::FromRenderFrameHost(render_frame_host);
auto mutable_details =
details == nullptr ? base::DictionaryValue() : details->Clone();
mutable_details.SetStringKey("requestingUrl",
render_frame_host->GetLastCommittedURL().spec());
mutable_details.SetBoolKey("isMainFrame",
render_frame_host->GetParent() == nullptr);
return check_handler_.Run(web_contents, permission, requesting_origin,
*details);
mutable_details);
}
blink::mojom::PermissionStatus