use base::Owned instead of base::Passed for repeating handler
This commit is contained in:
parent
6c6555c13c
commit
6f0524d87f
1 changed files with 14 additions and 9 deletions
|
@ -457,23 +457,28 @@ void Session::SetPermissionRequestHandler(v8::Local<v8::Value> val,
|
||||||
using RequestHandler =
|
using RequestHandler =
|
||||||
base::Callback<void(content::WebContents*, content::PermissionType,
|
base::Callback<void(content::WebContents*, content::PermissionType,
|
||||||
StatusCallback, const base::DictionaryValue&)>;
|
StatusCallback, const base::DictionaryValue&)>;
|
||||||
RequestHandler handler;
|
auto* permission_manager = static_cast<AtomPermissionManager*>(
|
||||||
if (!(val->IsNull() || mate::ConvertFromV8(args->isolate(), val, &handler))) {
|
browser_context()->GetPermissionControllerDelegate());
|
||||||
|
if (val->IsNull()) {
|
||||||
|
permission_manager->SetPermissionRequestHandler(
|
||||||
|
AtomPermissionManager::RequestHandler());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto handler = std::make_unique<RequestHandler>();
|
||||||
|
if (!mate::ConvertFromV8(args->isolate(), val, handler.get())) {
|
||||||
args->ThrowError("Must pass null or function");
|
args->ThrowError("Must pass null or function");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto* permission_manager = static_cast<AtomPermissionManager*>(
|
|
||||||
browser_context()->GetPermissionControllerDelegate());
|
|
||||||
permission_manager->SetPermissionRequestHandler(base::BindRepeating(
|
permission_manager->SetPermissionRequestHandler(base::BindRepeating(
|
||||||
[](const RequestHandler& handler, content::WebContents* web_contents,
|
[](RequestHandler* handler, content::WebContents* web_contents,
|
||||||
content::PermissionType permission_type,
|
content::PermissionType permission_type,
|
||||||
AtomPermissionManager::StatusCallback callback,
|
AtomPermissionManager::StatusCallback callback,
|
||||||
const base::DictionaryValue& details) {
|
const base::DictionaryValue& details) {
|
||||||
handler.Run(web_contents, permission_type,
|
handler->Run(web_contents, permission_type,
|
||||||
base::AdaptCallbackForRepeating(std::move(callback)),
|
base::AdaptCallbackForRepeating(std::move(callback)),
|
||||||
details);
|
details);
|
||||||
},
|
},
|
||||||
base::Passed(std::move(handler))));
|
base::Owned(std::move(handler))));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::SetPermissionCheckHandler(v8::Local<v8::Value> val,
|
void Session::SetPermissionCheckHandler(v8::Local<v8::Value> val,
|
||||||
|
|
Loading…
Reference in a new issue