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

@ -442,11 +442,6 @@ void Session::SetCertVerifyProc(v8::Local<v8::Value> val,
void Session::SetPermissionRequestHandler(v8::Local<v8::Value> val,
mate::Arguments* args) {
using StatusCallback =
base::RepeatingCallback<void(blink::mojom::PermissionStatus)>;
using RequestHandler =
base::Callback<void(content::WebContents*, content::PermissionType,
StatusCallback, const base::DictionaryValue&)>;
auto* permission_manager = static_cast<AtomPermissionManager*>(
browser_context()->GetPermissionControllerDelegate());
if (val->IsNull()) {
@ -454,16 +449,17 @@ void Session::SetPermissionRequestHandler(v8::Local<v8::Value> val,
AtomPermissionManager::RequestHandler());
return;
}
auto handler = std::make_unique<RequestHandler>();
auto handler = std::make_unique<AtomPermissionManager::RequestHandler>();
if (!mate::ConvertFromV8(args->isolate(), val, handler.get())) {
args->ThrowError("Must pass null or function");
return;
}
permission_manager->SetPermissionRequestHandler(base::BindRepeating(
[](RequestHandler* handler, content::WebContents* web_contents,
[](AtomPermissionManager::RequestHandler* handler,
content::WebContents* web_contents,
content::PermissionType permission_type,
AtomPermissionManager::StatusCallback callback,
const base::DictionaryValue& details) {
const base::Value& details) {
handler->Run(web_contents, permission_type,
base::AdaptCallbackForRepeating(std::move(callback)),
details);