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