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 { ...@@ -64,7 +64,7 @@ class ExtensionPlatformKeysService : public KeyedService {
// certificates were requested and are not null. // certificates were requested and are not null.
virtual void Select(const std::string& extension_id, virtual void Select(const std::string& extension_id,
const net::CertificateList& certs, const net::CertificateList& certs,
const CertificateSelectedCallback& callback, CertificateSelectedCallback callback,
content::WebContents* web_contents, content::WebContents* web_contents,
content::BrowserContext* context) = 0; content::BrowserContext* context) = 0;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/platform_keys/extension_platform_keys_service_factory.h" #include "chrome/browser/chromeos/platform_keys/extension_platform_keys_service_factory.h"
#include <memory> #include <memory>
#include <utility>
#include "base/bind.h" #include "base/bind.h"
#include "base/callback.h" #include "base/callback.h"
...@@ -39,7 +40,7 @@ class DefaultSelectDelegate ...@@ -39,7 +40,7 @@ class DefaultSelectDelegate
void Select(const std::string& extension_id, void Select(const std::string& extension_id,
const net::CertificateList& certs, const net::CertificateList& certs,
const CertificateSelectedCallback& callback, CertificateSelectedCallback callback,
content::WebContents* web_contents, content::WebContents* web_contents,
content::BrowserContext* context) override { content::BrowserContext* context) override {
CHECK(web_contents); CHECK(web_contents);
...@@ -47,21 +48,21 @@ class DefaultSelectDelegate ...@@ -47,21 +48,21 @@ class DefaultSelectDelegate
extensions::ExtensionRegistry::Get(context)->GetExtensionById( extensions::ExtensionRegistry::Get(context)->GetExtensionById(
extension_id, extensions::ExtensionRegistry::ENABLED); extension_id, extensions::ExtensionRegistry::ENABLED);
if (!extension) { if (!extension) {
callback.Run(nullptr /* no certificate selected */); std::move(callback).Run(nullptr /* no certificate selected */);
return; return;
} }
ShowPlatformKeysCertificateSelector( ShowPlatformKeysCertificateSelector(
web_contents, extension->short_name(), certs, web_contents, extension->short_name(), certs,
// Don't call |callback| once this delegate is destructed, thus use a // Don't call |callback| once this delegate is destructed, thus use a
// WeakPtr. // WeakPtr.
base::Bind(&DefaultSelectDelegate::SelectedCertificate, base::BindOnce(&DefaultSelectDelegate::SelectedCertificate,
weak_factory_.GetWeakPtr(), callback)); weak_factory_.GetWeakPtr(), std::move(callback)));
} }
void SelectedCertificate( void SelectedCertificate(
const CertificateSelectedCallback& callback, CertificateSelectedCallback callback,
const scoped_refptr<net::X509Certificate>& selected_cert) { const scoped_refptr<net::X509Certificate>& selected_cert) {
callback.Run(selected_cert); std::move(callback).Run(selected_cert);
} }
private: private:
......
...@@ -252,7 +252,7 @@ class TestSelectDelegate ...@@ -252,7 +252,7 @@ class TestSelectDelegate
void Select(const std::string& extension_id, void Select(const std::string& extension_id,
const net::CertificateList& certs, const net::CertificateList& certs,
const CertificateSelectedCallback& callback, CertificateSelectedCallback callback,
content::WebContents* web_contents, content::WebContents* web_contents,
content::BrowserContext* context) override { content::BrowserContext* context) override {
ASSERT_TRUE(web_contents); ASSERT_TRUE(web_contents);
...@@ -269,7 +269,7 @@ class TestSelectDelegate ...@@ -269,7 +269,7 @@ class TestSelectDelegate
} }
if (certs_to_select_.size() > 1) if (certs_to_select_.size() > 1)
certs_to_select_.pop_back(); certs_to_select_.pop_back();
callback.Run(selection); std::move(callback).Run(selection);
} }
private: private:
......
...@@ -22,7 +22,7 @@ typedef std::vector<scoped_refptr<X509Certificate>> CertificateList; ...@@ -22,7 +22,7 @@ typedef std::vector<scoped_refptr<X509Certificate>> CertificateList;
namespace chromeos { namespace chromeos {
typedef base::Callback<void( typedef base::OnceCallback<void(
const scoped_refptr<net::X509Certificate>& selected_certificate)> const scoped_refptr<net::X509Certificate>& selected_certificate)>
CertificateSelectedCallback; CertificateSelectedCallback;
...@@ -37,7 +37,7 @@ void ShowPlatformKeysCertificateSelector( ...@@ -37,7 +37,7 @@ void ShowPlatformKeysCertificateSelector(
content::WebContents* web_contents, content::WebContents* web_contents,
const std::string& extension_id, const std::string& extension_id,
const net::CertificateList& certificates, const net::CertificateList& certificates,
const CertificateSelectedCallback& callback); CertificateSelectedCallback callback);
} // namespace chromeos } // namespace chromeos
......
...@@ -56,12 +56,12 @@ net::ClientCertIdentityList CertificateListToIdentityList( ...@@ -56,12 +56,12 @@ net::ClientCertIdentityList CertificateListToIdentityList(
PlatformKeysCertificateSelector::PlatformKeysCertificateSelector( PlatformKeysCertificateSelector::PlatformKeysCertificateSelector(
const net::CertificateList& certificates, const net::CertificateList& certificates,
const std::string& extension_name, const std::string& extension_name,
const CertificateSelectedCallback& callback, CertificateSelectedCallback callback,
content::WebContents* web_contents) content::WebContents* web_contents)
: CertificateSelector(CertificateListToIdentityList(certificates), : CertificateSelector(CertificateListToIdentityList(certificates),
web_contents), web_contents),
extension_name_(extension_name), extension_name_(extension_name),
callback_(callback) { callback_(std::move(callback)) {
DCHECK(!callback_.is_null()); DCHECK(!callback_.is_null());
SetCancelCallback(base::BindOnce( SetCancelCallback(base::BindOnce(
[](PlatformKeysCertificateSelector* dialog) { [](PlatformKeysCertificateSelector* dialog) {
...@@ -103,11 +103,10 @@ void ShowPlatformKeysCertificateSelector( ...@@ -103,11 +103,10 @@ void ShowPlatformKeysCertificateSelector(
content::WebContents* web_contents, content::WebContents* web_contents,
const std::string& extension_name, const std::string& extension_name,
const net::CertificateList& certificates, const net::CertificateList& certificates,
const base::Callback<void(const scoped_refptr<net::X509Certificate>&)>& CertificateSelectedCallback callback) {
callback) {
PlatformKeysCertificateSelector* selector = PlatformKeysCertificateSelector* selector =
new PlatformKeysCertificateSelector(certificates, extension_name, new PlatformKeysCertificateSelector(certificates, extension_name,
callback, web_contents); std::move(callback), web_contents);
selector->Init(); selector->Init();
selector->Show(); selector->Show();
} }
......
...@@ -29,7 +29,7 @@ class PlatformKeysCertificateSelector : public chrome::CertificateSelector { ...@@ -29,7 +29,7 @@ class PlatformKeysCertificateSelector : public chrome::CertificateSelector {
// |callback| must not be null. // |callback| must not be null.
PlatformKeysCertificateSelector(const net::CertificateList& certificates, PlatformKeysCertificateSelector(const net::CertificateList& certificates,
const std::string& extension_name, const std::string& extension_name,
const CertificateSelectedCallback& callback, CertificateSelectedCallback callback,
content::WebContents* web_contents); content::WebContents* web_contents);
~PlatformKeysCertificateSelector() override; ~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