chore: remove discouraged base::Passed (#22871)
Closes #12640. Remove discouraged base::Passed from Bind calls.
This commit is contained in:
parent
658f8d0abb
commit
714d6c536f
5 changed files with 60 additions and 43 deletions
|
@ -497,14 +497,19 @@ void OnClientCertificateSelected(
|
|||
}
|
||||
|
||||
#if defined(USE_NSS_CERTS)
|
||||
int ImportIntoCertStore(CertificateManagerModel* model,
|
||||
const base::DictionaryValue& options) {
|
||||
int ImportIntoCertStore(CertificateManagerModel* model, base::Value options) {
|
||||
std::string file_data, cert_path;
|
||||
base::string16 password;
|
||||
net::ScopedCERTCertificateList imported_certs;
|
||||
int rv = -1;
|
||||
options.GetString("certificate", &cert_path);
|
||||
options.GetString("password", &password);
|
||||
|
||||
std::string* cert_path_ptr = options.FindStringKey("certificate");
|
||||
if (cert_path_ptr)
|
||||
cert_path = *cert_path_ptr;
|
||||
|
||||
std::string* pwd = options.FindStringKey("password");
|
||||
if (pwd)
|
||||
password = base::UTF8ToUTF16(*pwd);
|
||||
|
||||
if (!cert_path.empty()) {
|
||||
if (base::ReadFileToString(base::FilePath(cert_path), &file_data)) {
|
||||
|
@ -1071,31 +1076,36 @@ Browser::LoginItemSettings App::GetLoginItemSettings(
|
|||
}
|
||||
|
||||
#if defined(USE_NSS_CERTS)
|
||||
void App::ImportCertificate(const base::DictionaryValue& options,
|
||||
net::CompletionRepeatingCallback callback) {
|
||||
auto browser_context = ElectronBrowserContext::From("", false);
|
||||
if (!certificate_manager_model_) {
|
||||
auto copy = base::DictionaryValue::From(
|
||||
base::Value::ToUniquePtrValue(options.Clone()));
|
||||
CertificateManagerModel::Create(
|
||||
browser_context.get(),
|
||||
base::BindRepeating(&App::OnCertificateManagerModelCreated,
|
||||
base::Unretained(this), base::Passed(©),
|
||||
callback));
|
||||
void App::ImportCertificate(gin_helper::ErrorThrower thrower,
|
||||
base::Value options,
|
||||
net::CompletionOnceCallback callback) {
|
||||
if (!options.is_dict()) {
|
||||
thrower.ThrowTypeError("Expected options to be an object");
|
||||
return;
|
||||
}
|
||||
|
||||
int rv = ImportIntoCertStore(certificate_manager_model_.get(), options);
|
||||
auto browser_context = ElectronBrowserContext::From("", false);
|
||||
if (!certificate_manager_model_) {
|
||||
CertificateManagerModel::Create(
|
||||
browser_context.get(),
|
||||
base::BindOnce(&App::OnCertificateManagerModelCreated,
|
||||
base::Unretained(this), std::move(options),
|
||||
std::move(callback)));
|
||||
return;
|
||||
}
|
||||
|
||||
int rv =
|
||||
ImportIntoCertStore(certificate_manager_model_.get(), std::move(options));
|
||||
std::move(callback).Run(rv);
|
||||
}
|
||||
|
||||
void App::OnCertificateManagerModelCreated(
|
||||
std::unique_ptr<base::DictionaryValue> options,
|
||||
base::Value options,
|
||||
net::CompletionOnceCallback callback,
|
||||
std::unique_ptr<CertificateManagerModel> model) {
|
||||
certificate_manager_model_ = std::move(model);
|
||||
int rv =
|
||||
ImportIntoCertStore(certificate_manager_model_.get(), *(options.get()));
|
||||
ImportIntoCertStore(certificate_manager_model_.get(), std::move(options));
|
||||
std::move(callback).Run(rv);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue