Commit 500589ce authored by Xida Chen's avatar Xida Chen Committed by Commit Bot

Convert base::Callback in chrome/browser/importer

This is a code health CL, no behavior change is expected.

Bug: 1007635
Change-Id: Id0f79710fb70bdf31ad0959e7b8ab92f22ecdacf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2280201Reviewed-by: default avatarDana Fried <dfried@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Commit-Queue: Xida Chen <xidachen@chromium.org>
Auto-Submit: Xida Chen <xidachen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786097}
parent 05e7ea4b
......@@ -142,8 +142,8 @@ void ExternalProcessImporterHost::ShowWarningDialog() {
DCHECK(!headless_);
importer::ShowImportLockDialog(
parent_window_,
base::Bind(&ExternalProcessImporterHost::OnImportLockDialogEnd,
weak_ptr_factory_.GetWeakPtr()));
base::BindOnce(&ExternalProcessImporterHost::OnImportLockDialogEnd,
weak_ptr_factory_.GetWeakPtr()));
}
void ExternalProcessImporterHost::OnImportLockDialogEnd(bool is_continue) {
......@@ -203,9 +203,10 @@ void ExternalProcessImporterHost::CheckForLoadedModels(uint16_t items) {
if (!writer_->TemplateURLServiceIsLoaded()) {
TemplateURLService* model =
TemplateURLServiceFactory::GetForProfile(profile_);
template_service_subscription_ = model->RegisterOnLoadedCallback(
base::Bind(&ExternalProcessImporterHost::OnTemplateURLServiceLoaded,
weak_ptr_factory_.GetWeakPtr()));
template_service_subscription_ =
model->RegisterOnLoadedCallback(base::BindRepeating(
&ExternalProcessImporterHost::OnTemplateURLServiceLoaded,
weak_ptr_factory_.GetWeakPtr()));
model->Load();
}
}
......
......@@ -14,7 +14,7 @@ namespace importer {
// warning dialog. After closing the dialog, the ImportHost receives a callback
// with the message either to skip the import, or to continue the process.
void ShowImportLockDialog(gfx::NativeWindow parent,
const base::Callback<void(bool)>& callback);
base::OnceCallback<void(bool)> callback);
} // namespace importer
......
......@@ -29,30 +29,31 @@ using base::UserMetricsAction;
namespace importer {
void ShowImportLockDialog(gfx::NativeWindow parent,
const base::Callback<void(bool)>& callback) {
ImportLockDialogView::Show(parent, callback);
base::OnceCallback<void(bool)> callback) {
ImportLockDialogView::Show(parent, std::move(callback));
}
} // namespace importer
// static
void ImportLockDialogView::Show(gfx::NativeWindow parent,
const base::Callback<void(bool)>& callback) {
base::OnceCallback<void(bool)> callback) {
views::DialogDelegate::CreateDialogWidget(
new ImportLockDialogView(callback), NULL, NULL)->Show();
new ImportLockDialogView(std::move(callback)), nullptr, nullptr)
->Show();
base::RecordAction(UserMetricsAction("ImportLockDialogView_Shown"));
}
ImportLockDialogView::ImportLockDialogView(
const base::Callback<void(bool)>& callback)
: callback_(callback) {
base::OnceCallback<void(bool)> callback)
: callback_(std::move(callback)) {
SetButtonLabel(ui::DIALOG_BUTTON_OK,
l10n_util::GetStringUTF16(IDS_IMPORTER_LOCK_OK));
auto done_callback = [](ImportLockDialogView* dialog, bool accepted) {
if (dialog->callback_) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(dialog->callback_, accepted));
FROM_HERE, base::BindOnce(std::move(dialog->callback_), accepted));
}
};
SetAcceptCallback(
......
......@@ -15,10 +15,10 @@
class ImportLockDialogView : public views::DialogDelegateView {
public:
static void Show(gfx::NativeWindow parent,
const base::Callback<void(bool)>& callback);
base::OnceCallback<void(bool)> callback);
private:
explicit ImportLockDialogView(const base::Callback<void(bool)>& callback);
explicit ImportLockDialogView(base::OnceCallback<void(bool)> callback);
~ImportLockDialogView() override;
// views::View:
......@@ -32,7 +32,7 @@ class ImportLockDialogView : public views::DialogDelegateView {
private:
// Called with the result of the dialog.
base::Callback<void(bool)> callback_;
base::OnceCallback<void(bool)> callback_;
DISALLOW_COPY_AND_ASSIGN(ImportLockDialogView);
};
......
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