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

[CodeHealth] Convert chrome/browser/ui/views/ from base::Bind and base::Callback to Once/Repeating

Bug: 1152282
Change-Id: I05adec0b83f58387694b0443e8bdfc9a1d4ecfa8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2592007Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Commit-Queue: Yi Gu <yigu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837126}
parent b44a91c0
...@@ -34,7 +34,7 @@ class TestCertificateSelector : public chrome::CertificateSelector { ...@@ -34,7 +34,7 @@ class TestCertificateSelector : public chrome::CertificateSelector {
~TestCertificateSelector() override { ~TestCertificateSelector() override {
if (!on_destroy_.is_null()) if (!on_destroy_.is_null())
on_destroy_.Run(); std::move(on_destroy_).Run();
} }
void Init() { void Init() {
...@@ -61,12 +61,14 @@ class TestCertificateSelector : public chrome::CertificateSelector { ...@@ -61,12 +61,14 @@ class TestCertificateSelector : public chrome::CertificateSelector {
using chrome::CertificateSelector::table_model_for_testing; using chrome::CertificateSelector::table_model_for_testing;
void set_on_destroy(base::Closure on_destroy) { on_destroy_ = on_destroy; } void set_on_destroy(base::OnceClosure on_destroy) {
on_destroy_ = std::move(on_destroy);
}
private: private:
bool* accepted_ = nullptr; bool* accepted_ = nullptr;
bool* canceled_ = nullptr; bool* canceled_ = nullptr;
base::Closure on_destroy_; base::OnceClosure on_destroy_;
DISALLOW_COPY_AND_ASSIGN(TestCertificateSelector); DISALLOW_COPY_AND_ASSIGN(TestCertificateSelector);
}; };
......
...@@ -33,7 +33,7 @@ class CertificateViewerDialog : public ui::BaseShellDialogImpl { ...@@ -33,7 +33,7 @@ class CertificateViewerDialog : public ui::BaseShellDialogImpl {
// must ensure the CertificateViewerDialog remains valid until then. // must ensure the CertificateViewerDialog remains valid until then.
void Show(HWND parent, void Show(HWND parent,
net::X509Certificate* cert, net::X509Certificate* cert,
const base::Closure& callback) { base::RepeatingClosure callback) {
if (IsRunningDialogForOwner(parent)) { if (IsRunningDialogForOwner(parent)) {
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback);
return; return;
...@@ -80,10 +80,10 @@ class CertificateViewerDialog : public ui::BaseShellDialogImpl { ...@@ -80,10 +80,10 @@ class CertificateViewerDialog : public ui::BaseShellDialogImpl {
} }
void OnDialogClosed(std::unique_ptr<RunState> run_state, void OnDialogClosed(std::unique_ptr<RunState> run_state,
const base::Closure& callback) { base::OnceClosure callback) {
EndRun(std::move(run_state)); EndRun(std::move(run_state));
// May delete |this|. // May delete |this|.
callback.Run(); std::move(callback).Run();
} }
DISALLOW_COPY_AND_ASSIGN(CertificateViewerDialog); DISALLOW_COPY_AND_ASSIGN(CertificateViewerDialog);
...@@ -95,7 +95,7 @@ void ShowCertificateViewer(content::WebContents* web_contents, ...@@ -95,7 +95,7 @@ void ShowCertificateViewer(content::WebContents* web_contents,
gfx::NativeWindow parent, gfx::NativeWindow parent,
net::X509Certificate* cert) { net::X509Certificate* cert) {
CertificateViewerDialog* dialog = new CertificateViewerDialog; CertificateViewerDialog* dialog = new CertificateViewerDialog;
dialog->Show( dialog->Show(parent->GetHost()->GetAcceleratedWidget(), cert,
parent->GetHost()->GetAcceleratedWidget(), cert, base::BindRepeating(
base::Bind(&base::DeletePointer<CertificateViewerDialog>, dialog)); &base::DeletePointer<CertificateViewerDialog>, dialog));
} }
...@@ -34,7 +34,7 @@ void ShowCreateChromeAppShortcutsDialog( ...@@ -34,7 +34,7 @@ void ShowCreateChromeAppShortcutsDialog(
gfx::NativeWindow parent_window, gfx::NativeWindow parent_window,
Profile* profile, Profile* profile,
const extensions::Extension* app, const extensions::Extension* app,
const base::Callback<void(bool)>& close_callback) { const base::RepeatingCallback<void(bool)>& close_callback) {
constrained_window::CreateBrowserModalDialogViews( constrained_window::CreateBrowserModalDialogViews(
new CreateChromeApplicationShortcutView(profile, app, close_callback), new CreateChromeApplicationShortcutView(profile, app, close_callback),
parent_window)->Show(); parent_window)->Show();
...@@ -44,7 +44,7 @@ void ShowCreateChromeAppShortcutsDialog( ...@@ -44,7 +44,7 @@ void ShowCreateChromeAppShortcutsDialog(
gfx::NativeWindow parent_window, gfx::NativeWindow parent_window,
Profile* profile, Profile* profile,
const std::string& web_app_id, const std::string& web_app_id,
const base::Callback<void(bool)>& close_callback) { const base::RepeatingCallback<void(bool)>& close_callback) {
constrained_window::CreateBrowserModalDialogViews( constrained_window::CreateBrowserModalDialogViews(
new CreateChromeApplicationShortcutView(profile, web_app_id, new CreateChromeApplicationShortcutView(profile, web_app_id,
close_callback), close_callback),
...@@ -57,30 +57,30 @@ void ShowCreateChromeAppShortcutsDialog( ...@@ -57,30 +57,30 @@ void ShowCreateChromeAppShortcutsDialog(
CreateChromeApplicationShortcutView::CreateChromeApplicationShortcutView( CreateChromeApplicationShortcutView::CreateChromeApplicationShortcutView(
Profile* profile, Profile* profile,
const extensions::Extension* app, const extensions::Extension* app,
const base::Callback<void(bool)>& close_callback) const base::RepeatingCallback<void(bool)>& close_callback)
: CreateChromeApplicationShortcutView(profile, close_callback) { : CreateChromeApplicationShortcutView(profile, close_callback) {
// Get shortcut and icon information; needed for creating the shortcut. // Get shortcut and icon information; needed for creating the shortcut.
web_app::GetShortcutInfoForApp( web_app::GetShortcutInfoForApp(
app, profile, app, profile,
base::Bind(&CreateChromeApplicationShortcutView::OnAppInfoLoaded, base::BindRepeating(&CreateChromeApplicationShortcutView::OnAppInfoLoaded,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
CreateChromeApplicationShortcutView::CreateChromeApplicationShortcutView( CreateChromeApplicationShortcutView::CreateChromeApplicationShortcutView(
Profile* profile, Profile* profile,
const std::string& web_app_id, const std::string& web_app_id,
const base::Callback<void(bool)>& close_callback) const base::RepeatingCallback<void(bool)>& close_callback)
: CreateChromeApplicationShortcutView(profile, close_callback) { : CreateChromeApplicationShortcutView(profile, close_callback) {
web_app::WebAppProvider* provider = web_app::WebAppProvider::Get(profile); web_app::WebAppProvider* provider = web_app::WebAppProvider::Get(profile);
provider->os_integration_manager().GetShortcutInfoForApp( provider->os_integration_manager().GetShortcutInfoForApp(
web_app_id, web_app_id,
base::Bind(&CreateChromeApplicationShortcutView::OnAppInfoLoaded, base::BindRepeating(&CreateChromeApplicationShortcutView::OnAppInfoLoaded,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
CreateChromeApplicationShortcutView::CreateChromeApplicationShortcutView( CreateChromeApplicationShortcutView::CreateChromeApplicationShortcutView(
Profile* profile, Profile* profile,
const base::Callback<void(bool)>& close_callback) const base::RepeatingCallback<void(bool)>& close_callback)
: profile_(profile), close_callback_(close_callback) { : profile_(profile), close_callback_(close_callback) {
SetButtonLabel(ui::DIALOG_BUTTON_OK, SetButtonLabel(ui::DIALOG_BUTTON_OK,
l10n_util::GetStringUTF16(IDS_CREATE_SHORTCUTS_COMMIT)); l10n_util::GetStringUTF16(IDS_CREATE_SHORTCUTS_COMMIT));
......
...@@ -31,11 +31,11 @@ class CreateChromeApplicationShortcutView : public views::DialogDelegateView { ...@@ -31,11 +31,11 @@ class CreateChromeApplicationShortcutView : public views::DialogDelegateView {
CreateChromeApplicationShortcutView( CreateChromeApplicationShortcutView(
Profile* profile, Profile* profile,
const extensions::Extension* app, const extensions::Extension* app,
const base::Callback<void(bool)>& close_callback); const base::RepeatingCallback<void(bool)>& close_callback);
CreateChromeApplicationShortcutView( CreateChromeApplicationShortcutView(
Profile* profile, Profile* profile,
const std::string& web_app_id, const std::string& web_app_id,
const base::Callback<void(bool)>& close_callback); const base::RepeatingCallback<void(bool)>& close_callback);
~CreateChromeApplicationShortcutView() override; ~CreateChromeApplicationShortcutView() override;
// Initialize the controls on the dialog. // Initialize the controls on the dialog.
...@@ -48,8 +48,9 @@ class CreateChromeApplicationShortcutView : public views::DialogDelegateView { ...@@ -48,8 +48,9 @@ class CreateChromeApplicationShortcutView : public views::DialogDelegateView {
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
private: private:
CreateChromeApplicationShortcutView(Profile* profile, CreateChromeApplicationShortcutView(
const base::Callback<void(bool)>& cb); Profile* profile,
const base::RepeatingCallback<void(bool)>& cb);
// Creates a new check-box with the given text and checked state. // Creates a new check-box with the given text and checked state.
std::unique_ptr<views::Checkbox> AddCheckbox(const base::string16& text, std::unique_ptr<views::Checkbox> AddCheckbox(const base::string16& text,
...@@ -65,7 +66,7 @@ class CreateChromeApplicationShortcutView : public views::DialogDelegateView { ...@@ -65,7 +66,7 @@ class CreateChromeApplicationShortcutView : public views::DialogDelegateView {
// Profile in which the shortcuts will be created. // Profile in which the shortcuts will be created.
Profile* profile_; Profile* profile_;
base::Callback<void(bool)> close_callback_; base::RepeatingCallback<void(bool)> close_callback_;
// May be null if the platform doesn't support a particular location. // May be null if the platform doesn't support a particular location.
views::Checkbox* desktop_check_box_ = nullptr; views::Checkbox* desktop_check_box_ = nullptr;
......
...@@ -107,7 +107,7 @@ class TaskManagerViewTest : public InProcessBrowserTest { ...@@ -107,7 +107,7 @@ class TaskManagerViewTest : public InProcessBrowserTest {
int FindRowForTab(content::WebContents* tab) { int FindRowForTab(content::WebContents* tab) {
SessionID tab_id = sessions::SessionTabHelper::IdForTab(tab); SessionID tab_id = sessions::SessionTabHelper::IdForTab(tab);
std::unique_ptr<TaskManagerTester> tester = std::unique_ptr<TaskManagerTester> tester =
TaskManagerTester::Create(base::Closure()); TaskManagerTester::Create(base::RepeatingClosure());
for (int i = 0; i < tester->GetRowCount(); ++i) { for (int i = 0; i < tester->GetRowCount(); ++i) {
if (tester->GetTabId(i) == tab_id) if (tester->GetTabId(i) == tab_id)
return i; return i;
...@@ -274,7 +274,7 @@ IN_PROC_BROWSER_TEST_F(TaskManagerViewTest, DISABLED_SelectionConsistency) { ...@@ -274,7 +274,7 @@ IN_PROC_BROWSER_TEST_F(TaskManagerViewTest, DISABLED_SelectionConsistency) {
// Find the three tabs we set up, in TaskManager model order. Because we have // Find the three tabs we set up, in TaskManager model order. Because we have
// not sorted the table yet, this should also be their UI display order. // not sorted the table yet, this should also be their UI display order.
std::unique_ptr<TaskManagerTester> tester = std::unique_ptr<TaskManagerTester> tester =
TaskManagerTester::Create(base::Closure()); TaskManagerTester::Create(base::RepeatingClosure());
std::vector<content::WebContents*> tabs; std::vector<content::WebContents*> tabs;
for (int i = 0; i < tester->GetRowCount(); ++i) { for (int i = 0; i < tester->GetRowCount(); ++i) {
// Filter based on our title. // Filter based on our title.
......
...@@ -87,7 +87,7 @@ class TouchEventHandler : public ui::EventHandler { ...@@ -87,7 +87,7 @@ class TouchEventHandler : public ui::EventHandler {
int max_call_depth_; int max_call_depth_;
int num_touch_presses_; int num_touch_presses_;
int num_pointers_down_; int num_pointers_down_;
base::Closure quit_closure_; base::RepeatingClosure quit_closure_;
bool recursion_enabled_; bool recursion_enabled_;
gfx::Point touch_point_; gfx::Point touch_point_;
DISALLOW_COPY_AND_ASSIGN(TouchEventHandler); DISALLOW_COPY_AND_ASSIGN(TouchEventHandler);
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
UninstallView::UninstallView(int* user_selection, UninstallView::UninstallView(int* user_selection,
const base::Closure& quit_closure) const base::RepeatingClosure& quit_closure)
: confirm_label_(nullptr), : confirm_label_(nullptr),
delete_profile_(nullptr), delete_profile_(nullptr),
change_default_browser_(nullptr), change_default_browser_(nullptr),
......
...@@ -27,7 +27,7 @@ class UninstallView : public views::DialogDelegateView, ...@@ -27,7 +27,7 @@ class UninstallView : public views::DialogDelegateView,
public ui::ComboboxModel { public ui::ComboboxModel {
public: public:
explicit UninstallView(int* user_selection, explicit UninstallView(int* user_selection,
const base::Closure& quit_closure); const base::RepeatingClosure& quit_closure);
~UninstallView() override; ~UninstallView() override;
// Overridden from ui::ComboboxModel: // Overridden from ui::ComboboxModel:
...@@ -49,7 +49,7 @@ class UninstallView : public views::DialogDelegateView, ...@@ -49,7 +49,7 @@ class UninstallView : public views::DialogDelegateView,
views::Combobox* browsers_combo_; views::Combobox* browsers_combo_;
std::unique_ptr<BrowsersMap> browsers_; std::unique_ptr<BrowsersMap> browsers_;
int& user_selection_; int& user_selection_;
base::Closure quit_closure_; base::RepeatingClosure quit_closure_;
DISALLOW_COPY_AND_ASSIGN(UninstallView); DISALLOW_COPY_AND_ASSIGN(UninstallView);
}; };
......
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