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

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

Bug: 1152282
Change-Id: Ia563632254d82745e7a6be86c1811239b40d8c35
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2592191Reviewed-by: default avatarCollin Baker <collinbaker@chromium.org>
Commit-Queue: Yi Gu <yigu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837183}
parent a7c84fb2
......@@ -8,7 +8,7 @@
#include "ui/views/view.h"
OmniboxMouseEnterExitHandler::OmniboxMouseEnterExitHandler(
base::Closure enter_exit_callback)
base::RepeatingClosure enter_exit_callback)
: enter_exit_callback_(enter_exit_callback) {}
OmniboxMouseEnterExitHandler::~OmniboxMouseEnterExitHandler() {
......
......@@ -24,7 +24,8 @@ class OmniboxMouseEnterExitHandler : public ui::EventHandler {
public:
// |enter_exit_callback| is called whenever one of the observed Views get a
// mouse-enter or mouse-exit event.
explicit OmniboxMouseEnterExitHandler(base::Closure enter_exit_callback);
explicit OmniboxMouseEnterExitHandler(
base::RepeatingClosure enter_exit_callback);
OmniboxMouseEnterExitHandler(const OmniboxMouseEnterExitHandler&) = delete;
OmniboxMouseEnterExitHandler& operator=(const OmniboxMouseEnterExitHandler&) =
delete;
......@@ -38,7 +39,7 @@ class OmniboxMouseEnterExitHandler : public ui::EventHandler {
// This is called whenever one of the |observed_views_| has a mouse-enter or
// mouse-exit event.
const base::Closure enter_exit_callback_;
const base::RepeatingClosure enter_exit_callback_;
// These are the Views for which we are observing mouse-enter or mouse-exit
// events. This instance must outlive all of these Views, since these are
......
......@@ -45,8 +45,8 @@ class DummyEvent : public ui::Event {
// this SheetView's RequestFocus() is called.
class SheetView : public views::View, public views::FocusTraversable {
public:
explicit SheetView(
const base::Callback<void(bool*)>& enter_key_accelerator_callback)
explicit SheetView(const base::RepeatingCallback<void(bool*)>&
enter_key_accelerator_callback)
: enter_key_accelerator_callback_(enter_key_accelerator_callback) {
if (enter_key_accelerator_callback_)
AddAccelerator(enter_key_accelerator_);
......@@ -126,7 +126,7 @@ class SheetView : public views::View, public views::FocusTraversable {
/*cycle=*/true,
/*accessibility_mode=*/false);
ui::Accelerator enter_key_accelerator_{ui::VKEY_RETURN, ui::EF_NONE};
base::Callback<void(bool*)> enter_key_accelerator_callback_;
base::RepeatingCallback<void(bool*)> enter_key_accelerator_callback_;
};
// A scroll view that displays a separator on the bounds where content is
......@@ -210,10 +210,10 @@ std::unique_ptr<views::View> PaymentRequestSheetController::CreateView() {
std::unique_ptr<views::View> footer = CreateFooterView();
auto view = std::make_unique<SheetView>(
primary_button_
? base::Bind(
? base::BindRepeating(
&PaymentRequestSheetController::PerformPrimaryButtonAction,
weak_ptr_factory_.GetWeakPtr())
: base::Callback<void(bool*)>());
: base::RepeatingCallback<void(bool*)>());
DialogViewID sheet_id;
if (GetSheetId(&sheet_id))
......
......@@ -140,7 +140,7 @@ ShippingAddressEditorViewController::GetComboboxModelForType(
case autofill::ADDRESS_HOME_COUNTRY: {
auto model = std::make_unique<autofill::CountryComboboxModel>();
model->SetCountries(*state()->GetPersonalDataManager(),
base::Callback<bool(const std::string&)>(),
base::RepeatingCallback<bool(const std::string&)>(),
state()->GetApplicationLocale());
if (model->countries().size() != countries_.size())
UpdateCountries(model.get());
......@@ -377,8 +377,9 @@ void ShippingAddressEditorViewController::UpdateCountries(
autofill::CountryComboboxModel* model) {
autofill::CountryComboboxModel local_model;
if (!model) {
local_model.SetCountries(*state()->GetPersonalDataManager(),
base::Callback<bool(const std::string&)>(),
local_model.SetCountries(
*state()->GetPersonalDataManager(),
base::RepeatingCallback<bool(const std::string&)>(),
state()->GetApplicationLocale());
model = &local_model;
}
......
......@@ -918,7 +918,7 @@ class TryChromeDialog::ModalShowDelegate : public TryChromeDialog::Delegate {
public:
// Constructs the updater with a closure to be run after the dialog is closed
// to break out of the modal run loop.
explicit ModalShowDelegate(base::Closure quit_closure)
explicit ModalShowDelegate(base::RepeatingClosure quit_closure)
: quit_closure_(std::move(quit_closure)) {}
~ModalShowDelegate() override = default;
......@@ -930,7 +930,7 @@ class TryChromeDialog::ModalShowDelegate : public TryChromeDialog::Delegate {
void InteractionComplete() override;
private:
base::Closure quit_closure_;
base::RepeatingClosure quit_closure_;
installer::ExperimentStorage storage_;
// The time at which the toast was shown; used for computing the action delay.
......@@ -1014,8 +1014,9 @@ TryChromeDialog::~TryChromeDialog() {
void TryChromeDialog::ShowDialogAsync() {
DCHECK_CALLED_ON_VALID_SEQUENCE(my_sequence_checker_);
endsession_observer_ = std::make_unique<gfx::SingletonHwndObserver>(
base::Bind(&TryChromeDialog::OnWindowMessage, base::Unretained(this)));
endsession_observer_ =
std::make_unique<gfx::SingletonHwndObserver>(base::BindRepeating(
&TryChromeDialog::OnWindowMessage, base::Unretained(this)));
context_->Initialize(base::BindOnce(&TryChromeDialog::OnContextInitialized,
base::Unretained(this)));
......
......@@ -145,9 +145,6 @@ class TryChromeDialog : public views::WidgetObserver, public ui::EventHandler {
std::unique_ptr<Context> context_;
// A closure to run when the interaction has completed.
base::Closure on_complete_;
// The pessimistic result that will prevent launching Chrome.
Result result_ = NOT_NOW;
......
......@@ -156,7 +156,7 @@ class TryChromeDialogBrowserTestBase : public InProcessBrowserTest {
const int group_;
::testing::NiceMock<MockDelegate> delegate_;
std::unique_ptr<TryChromeDialog> dialog_;
base::Closure quit_closure_;
base::RepeatingClosure quit_closure_;
DISALLOW_COPY_AND_ASSIGN(TryChromeDialogBrowserTestBase);
};
......
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