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() { ...@@ -142,8 +142,8 @@ void ExternalProcessImporterHost::ShowWarningDialog() {
DCHECK(!headless_); DCHECK(!headless_);
importer::ShowImportLockDialog( importer::ShowImportLockDialog(
parent_window_, parent_window_,
base::Bind(&ExternalProcessImporterHost::OnImportLockDialogEnd, base::BindOnce(&ExternalProcessImporterHost::OnImportLockDialogEnd,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
void ExternalProcessImporterHost::OnImportLockDialogEnd(bool is_continue) { void ExternalProcessImporterHost::OnImportLockDialogEnd(bool is_continue) {
...@@ -203,9 +203,10 @@ void ExternalProcessImporterHost::CheckForLoadedModels(uint16_t items) { ...@@ -203,9 +203,10 @@ void ExternalProcessImporterHost::CheckForLoadedModels(uint16_t items) {
if (!writer_->TemplateURLServiceIsLoaded()) { if (!writer_->TemplateURLServiceIsLoaded()) {
TemplateURLService* model = TemplateURLService* model =
TemplateURLServiceFactory::GetForProfile(profile_); TemplateURLServiceFactory::GetForProfile(profile_);
template_service_subscription_ = model->RegisterOnLoadedCallback( template_service_subscription_ =
base::Bind(&ExternalProcessImporterHost::OnTemplateURLServiceLoaded, model->RegisterOnLoadedCallback(base::BindRepeating(
weak_ptr_factory_.GetWeakPtr())); &ExternalProcessImporterHost::OnTemplateURLServiceLoaded,
weak_ptr_factory_.GetWeakPtr()));
model->Load(); model->Load();
} }
} }
......
...@@ -14,7 +14,7 @@ namespace importer { ...@@ -14,7 +14,7 @@ namespace importer {
// warning dialog. After closing the dialog, the ImportHost receives a callback // warning dialog. After closing the dialog, the ImportHost receives a callback
// with the message either to skip the import, or to continue the process. // with the message either to skip the import, or to continue the process.
void ShowImportLockDialog(gfx::NativeWindow parent, void ShowImportLockDialog(gfx::NativeWindow parent,
const base::Callback<void(bool)>& callback); base::OnceCallback<void(bool)> callback);
} // namespace importer } // namespace importer
......
...@@ -29,30 +29,31 @@ using base::UserMetricsAction; ...@@ -29,30 +29,31 @@ using base::UserMetricsAction;
namespace importer { namespace importer {
void ShowImportLockDialog(gfx::NativeWindow parent, void ShowImportLockDialog(gfx::NativeWindow parent,
const base::Callback<void(bool)>& callback) { base::OnceCallback<void(bool)> callback) {
ImportLockDialogView::Show(parent, callback); ImportLockDialogView::Show(parent, std::move(callback));
} }
} // namespace importer } // namespace importer
// static // static
void ImportLockDialogView::Show(gfx::NativeWindow parent, void ImportLockDialogView::Show(gfx::NativeWindow parent,
const base::Callback<void(bool)>& callback) { base::OnceCallback<void(bool)> callback) {
views::DialogDelegate::CreateDialogWidget( views::DialogDelegate::CreateDialogWidget(
new ImportLockDialogView(callback), NULL, NULL)->Show(); new ImportLockDialogView(std::move(callback)), nullptr, nullptr)
->Show();
base::RecordAction(UserMetricsAction("ImportLockDialogView_Shown")); base::RecordAction(UserMetricsAction("ImportLockDialogView_Shown"));
} }
ImportLockDialogView::ImportLockDialogView( ImportLockDialogView::ImportLockDialogView(
const base::Callback<void(bool)>& callback) base::OnceCallback<void(bool)> callback)
: callback_(callback) { : callback_(std::move(callback)) {
SetButtonLabel(ui::DIALOG_BUTTON_OK, SetButtonLabel(ui::DIALOG_BUTTON_OK,
l10n_util::GetStringUTF16(IDS_IMPORTER_LOCK_OK)); l10n_util::GetStringUTF16(IDS_IMPORTER_LOCK_OK));
auto done_callback = [](ImportLockDialogView* dialog, bool accepted) { auto done_callback = [](ImportLockDialogView* dialog, bool accepted) {
if (dialog->callback_) { if (dialog->callback_) {
base::ThreadTaskRunnerHandle::Get()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(dialog->callback_, accepted)); FROM_HERE, base::BindOnce(std::move(dialog->callback_), accepted));
} }
}; };
SetAcceptCallback( SetAcceptCallback(
......
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
class ImportLockDialogView : public views::DialogDelegateView { class ImportLockDialogView : public views::DialogDelegateView {
public: public:
static void Show(gfx::NativeWindow parent, static void Show(gfx::NativeWindow parent,
const base::Callback<void(bool)>& callback); base::OnceCallback<void(bool)> callback);
private: private:
explicit ImportLockDialogView(const base::Callback<void(bool)>& callback); explicit ImportLockDialogView(base::OnceCallback<void(bool)> callback);
~ImportLockDialogView() override; ~ImportLockDialogView() override;
// views::View: // views::View:
...@@ -32,7 +32,7 @@ class ImportLockDialogView : public views::DialogDelegateView { ...@@ -32,7 +32,7 @@ class ImportLockDialogView : public views::DialogDelegateView {
private: private:
// Called with the result of the dialog. // Called with the result of the dialog.
base::Callback<void(bool)> callback_; base::OnceCallback<void(bool)> callback_;
DISALLOW_COPY_AND_ASSIGN(ImportLockDialogView); 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