Commit ecd41d32 authored by Yi Gu's avatar Yi Gu Committed by Chromium LUCI CQ

[CodeHealth] Convert c/b/ui chromeos from base::Bind and base::Callback to Once/Repeating

Bug: 1148570, 1152282
Change-Id: If44349170f9670f080fc04a8ad4c18fa041a4392
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2593549
Commit-Queue: Yi Gu <yigu@chromium.org>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837156}
parent 2b4a3bc2
......@@ -64,7 +64,7 @@ class ExtensionPlatformKeysService : public KeyedService {
// certificates were requested and are not null.
virtual void Select(const std::string& extension_id,
const net::CertificateList& certs,
const CertificateSelectedCallback& callback,
CertificateSelectedCallback callback,
content::WebContents* web_contents,
content::BrowserContext* context) = 0;
......
......@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/platform_keys/extension_platform_keys_service_factory.h"
#include <memory>
#include <utility>
#include "base/bind.h"
#include "base/callback.h"
......@@ -39,7 +40,7 @@ class DefaultSelectDelegate
void Select(const std::string& extension_id,
const net::CertificateList& certs,
const CertificateSelectedCallback& callback,
CertificateSelectedCallback callback,
content::WebContents* web_contents,
content::BrowserContext* context) override {
CHECK(web_contents);
......@@ -47,21 +48,21 @@ class DefaultSelectDelegate
extensions::ExtensionRegistry::Get(context)->GetExtensionById(
extension_id, extensions::ExtensionRegistry::ENABLED);
if (!extension) {
callback.Run(nullptr /* no certificate selected */);
std::move(callback).Run(nullptr /* no certificate selected */);
return;
}
ShowPlatformKeysCertificateSelector(
web_contents, extension->short_name(), certs,
// Don't call |callback| once this delegate is destructed, thus use a
// WeakPtr.
base::Bind(&DefaultSelectDelegate::SelectedCertificate,
weak_factory_.GetWeakPtr(), callback));
base::BindOnce(&DefaultSelectDelegate::SelectedCertificate,
weak_factory_.GetWeakPtr(), std::move(callback)));
}
void SelectedCertificate(
const CertificateSelectedCallback& callback,
CertificateSelectedCallback callback,
const scoped_refptr<net::X509Certificate>& selected_cert) {
callback.Run(selected_cert);
std::move(callback).Run(selected_cert);
}
private:
......
......@@ -252,7 +252,7 @@ class TestSelectDelegate
void Select(const std::string& extension_id,
const net::CertificateList& certs,
const CertificateSelectedCallback& callback,
CertificateSelectedCallback callback,
content::WebContents* web_contents,
content::BrowserContext* context) override {
ASSERT_TRUE(web_contents);
......@@ -269,7 +269,7 @@ class TestSelectDelegate
}
if (certs_to_select_.size() > 1)
certs_to_select_.pop_back();
callback.Run(selection);
std::move(callback).Run(selection);
}
private:
......
......@@ -22,7 +22,7 @@ typedef std::vector<scoped_refptr<X509Certificate>> CertificateList;
namespace chromeos {
typedef base::Callback<void(
typedef base::OnceCallback<void(
const scoped_refptr<net::X509Certificate>& selected_certificate)>
CertificateSelectedCallback;
......@@ -37,7 +37,7 @@ void ShowPlatformKeysCertificateSelector(
content::WebContents* web_contents,
const std::string& extension_id,
const net::CertificateList& certificates,
const CertificateSelectedCallback& callback);
CertificateSelectedCallback callback);
} // namespace chromeos
......
......@@ -56,12 +56,12 @@ net::ClientCertIdentityList CertificateListToIdentityList(
PlatformKeysCertificateSelector::PlatformKeysCertificateSelector(
const net::CertificateList& certificates,
const std::string& extension_name,
const CertificateSelectedCallback& callback,
CertificateSelectedCallback callback,
content::WebContents* web_contents)
: CertificateSelector(CertificateListToIdentityList(certificates),
web_contents),
extension_name_(extension_name),
callback_(callback) {
callback_(std::move(callback)) {
DCHECK(!callback_.is_null());
SetCancelCallback(base::BindOnce(
[](PlatformKeysCertificateSelector* dialog) {
......@@ -103,11 +103,10 @@ void ShowPlatformKeysCertificateSelector(
content::WebContents* web_contents,
const std::string& extension_name,
const net::CertificateList& certificates,
const base::Callback<void(const scoped_refptr<net::X509Certificate>&)>&
callback) {
CertificateSelectedCallback callback) {
PlatformKeysCertificateSelector* selector =
new PlatformKeysCertificateSelector(certificates, extension_name,
callback, web_contents);
std::move(callback), web_contents);
selector->Init();
selector->Show();
}
......
......@@ -29,7 +29,7 @@ class PlatformKeysCertificateSelector : public chrome::CertificateSelector {
// |callback| must not be null.
PlatformKeysCertificateSelector(const net::CertificateList& certificates,
const std::string& extension_name,
const CertificateSelectedCallback& callback,
CertificateSelectedCallback callback,
content::WebContents* web_contents);
~PlatformKeysCertificateSelector() override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment