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