Commit 29e5ffa2 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: Ib5c3905e9a06926701be42fcf7913392a380657f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2592011Reviewed-by: default avatarCaroline Rising <corising@chromium.org>
Commit-Queue: Yi Gu <yigu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837821}
parent 032f0903
...@@ -267,8 +267,8 @@ class DragStartWaiter : public aura::client::DragDropClient { ...@@ -267,8 +267,8 @@ class DragStartWaiter : public aura::client::DragDropClient {
suppress_passing_of_start_drag_further_ = true; suppress_passing_of_start_drag_further_ = true;
} }
void PostTaskWhenDragStarts(const base::Closure& callback) { void PostTaskWhenDragStarts(base::OnceClosure callback) {
callback_to_run_inside_drag_and_drop_message_loop_ = callback; callback_to_run_inside_drag_and_drop_message_loop_ = std::move(callback);
} }
// aura::client::DragDropClient overrides: // aura::client::DragDropClient overrides:
...@@ -334,7 +334,7 @@ class DragStartWaiter : public aura::client::DragDropClient { ...@@ -334,7 +334,7 @@ class DragStartWaiter : public aura::client::DragDropClient {
content::WebContents* web_contents_; content::WebContents* web_contents_;
scoped_refptr<content::MessageLoopRunner> message_loop_runner_; scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
aura::client::DragDropClient* old_client_; aura::client::DragDropClient* old_client_;
base::Closure callback_to_run_inside_drag_and_drop_message_loop_; base::OnceClosure callback_to_run_inside_drag_and_drop_message_loop_;
bool suppress_passing_of_start_drag_further_; bool suppress_passing_of_start_drag_further_;
// Data captured during the first intercepted StartDragAndDrop call. // Data captured during the first intercepted StartDragAndDrop call.
...@@ -1081,10 +1081,10 @@ IN_PROC_BROWSER_TEST_P(DragAndDropBrowserTest, MAYBE_DragImageBetweenFrames) { ...@@ -1081,10 +1081,10 @@ IN_PROC_BROWSER_TEST_P(DragAndDropBrowserTest, MAYBE_DragImageBetweenFrames) {
// Start the drag in the left frame. // Start the drag in the left frame.
DragStartWaiter drag_start_waiter(web_contents()); DragStartWaiter drag_start_waiter(web_contents());
drag_start_waiter.PostTaskWhenDragStarts( drag_start_waiter.PostTaskWhenDragStarts(
base::Bind(&DragAndDropBrowserTest::DragImageBetweenFrames_Step2, base::BindOnce(&DragAndDropBrowserTest::DragImageBetweenFrames_Step2,
base::Unretained(this), base::Unretained(&state))); base::Unretained(this), base::Unretained(&state)));
state.dragstart_event_waiter.reset( state.dragstart_event_waiter =
new DOMDragEventWaiter("dragstart", left_frame())); std::make_unique<DOMDragEventWaiter>("dragstart", left_frame());
EXPECT_TRUE(SimulateMouseDownAndDragStartInLeftFrame()); EXPECT_TRUE(SimulateMouseDownAndDragStartInLeftFrame());
// The next step of the test (DragImageBetweenFrames_Step2) runs inside the // The next step of the test (DragImageBetweenFrames_Step2) runs inside the
...@@ -1291,9 +1291,9 @@ IN_PROC_BROWSER_TEST_P(DragAndDropBrowserTest, ...@@ -1291,9 +1291,9 @@ IN_PROC_BROWSER_TEST_P(DragAndDropBrowserTest,
// Start the drag in the left frame. // Start the drag in the left frame.
DragStartWaiter drag_start_waiter(web_contents()); DragStartWaiter drag_start_waiter(web_contents());
drag_start_waiter.PostTaskWhenDragStarts( drag_start_waiter.PostTaskWhenDragStarts(base::BindOnce(
base::Bind(&DragAndDropBrowserTest::DragImageFromDisappearingFrame_Step2, &DragAndDropBrowserTest::DragImageFromDisappearingFrame_Step2,
base::Unretained(this), base::Unretained(&state))); base::Unretained(this), base::Unretained(&state)));
EXPECT_TRUE(SimulateMouseDownAndDragStartInLeftFrame()); EXPECT_TRUE(SimulateMouseDownAndDragStartInLeftFrame());
// The next step of the test (DragImageFromDisappearingFrame_Step2) runs // The next step of the test (DragImageFromDisappearingFrame_Step2) runs
...@@ -1404,8 +1404,8 @@ IN_PROC_BROWSER_TEST_P(DragAndDropBrowserTest, MAYBE_CrossSiteDrag) { ...@@ -1404,8 +1404,8 @@ IN_PROC_BROWSER_TEST_P(DragAndDropBrowserTest, MAYBE_CrossSiteDrag) {
// Start the drag in the left frame. // Start the drag in the left frame.
DragStartWaiter drag_start_waiter(web_contents()); DragStartWaiter drag_start_waiter(web_contents());
drag_start_waiter.PostTaskWhenDragStarts( drag_start_waiter.PostTaskWhenDragStarts(
base::Bind(&DragAndDropBrowserTest::CrossSiteDrag_Step2, base::BindOnce(&DragAndDropBrowserTest::CrossSiteDrag_Step2,
base::Unretained(this), base::Unretained(&state))); base::Unretained(this), base::Unretained(&state)));
EXPECT_TRUE(SimulateMouseDownAndDragStartInLeftFrame()); EXPECT_TRUE(SimulateMouseDownAndDragStartInLeftFrame());
// The next step of the test (CrossSiteDrag_Step2) runs inside the // The next step of the test (CrossSiteDrag_Step2) runs inside the
......
...@@ -35,7 +35,7 @@ class FirstRunDialog : public views::DialogDelegateView { ...@@ -35,7 +35,7 @@ class FirstRunDialog : public views::DialogDelegateView {
views::Checkbox* make_default_ = nullptr; views::Checkbox* make_default_ = nullptr;
views::Checkbox* report_crashes_ = nullptr; views::Checkbox* report_crashes_ = nullptr;
base::Closure quit_runloop_; base::RepeatingClosure quit_runloop_;
DISALLOW_COPY_AND_ASSIGN(FirstRunDialog); DISALLOW_COPY_AND_ASSIGN(FirstRunDialog);
}; };
......
...@@ -18,7 +18,7 @@ class ImportLockDialogViewBrowserTest : public DialogBrowserTest { ...@@ -18,7 +18,7 @@ class ImportLockDialogViewBrowserTest : public DialogBrowserTest {
// DialogBrowserTest: // DialogBrowserTest:
void ShowUi(const std::string& name) override { void ShowUi(const std::string& name) override {
gfx::NativeWindow native_window = browser()->window()->GetNativeWindow(); gfx::NativeWindow native_window = browser()->window()->GetNativeWindow();
ImportLockDialogView::Show(native_window, base::Callback<void(bool)>()); ImportLockDialogView::Show(native_window, base::OnceCallback<void(bool)>());
} }
private: private:
......
...@@ -101,8 +101,8 @@ void PwaInstallView::UpdateImpl() { ...@@ -101,8 +101,8 @@ void PwaInstallView::UpdateImpl() {
FeaturePromoTextReplacements::WithString( FeaturePromoTextReplacements::WithString(
webapps::AppBannerManager::GetInstallableWebAppName( webapps::AppBannerManager::GetInstallableWebAppName(
web_contents)), web_contents)),
base::Bind(&PwaInstallView::OnIphClosed, base::BindOnce(&PwaInstallView::OnIphClosed,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
} }
SetVisible(is_probably_promotable || PWAConfirmationBubbleView::IsShowing()); SetVisible(is_probably_promotable || PWAConfirmationBubbleView::IsShowing());
......
...@@ -324,9 +324,11 @@ class PageInfoBubbleViewBrowserTest : public DialogBrowserTest { ...@@ -324,9 +324,11 @@ class PageInfoBubbleViewBrowserTest : public DialogBrowserTest {
->GetMainFrame() ->GetMainFrame()
->ExecuteJavaScriptForTests( ->ExecuteJavaScriptForTests(
base::ASCIIToUTF16(js), base::ASCIIToUTF16(js),
base::BindOnce([](const base::Closure& quit_callback, base::BindOnce(
base::Value result) { quit_callback.Run(); }, [](base::OnceClosure quit_callback, base::Value result) {
run_loop.QuitClosure())); std::move(quit_callback).Run();
},
run_loop.QuitClosure()));
run_loop.Run(); run_loop.Run();
} }
......
...@@ -176,8 +176,8 @@ PermissionSelectorRow::PermissionSelectorRow( ...@@ -176,8 +176,8 @@ PermissionSelectorRow::PermissionSelectorRow(
// Create the menu model. // Create the menu model.
menu_model_ = std::make_unique<PermissionMenuModel>( menu_model_ = std::make_unique<PermissionMenuModel>(
profile, url, permission, profile, url, permission,
base::Bind(&PermissionSelectorRow::PermissionChanged, base::BindRepeating(&PermissionSelectorRow::PermissionChanged,
base::Unretained(this))); base::Unretained(this)));
// Create the permission combobox. // Create the permission combobox.
InitializeComboboxView(layout, permission); InitializeComboboxView(layout, permission);
......
...@@ -210,9 +210,9 @@ class ProfilePickerCreationFlowBrowserTest : public ProfilePickerTestBase { ...@@ -210,9 +210,9 @@ class ProfilePickerCreationFlowBrowserTest : public ProfilePickerTestBase {
create_services_subscription_ = create_services_subscription_ =
BrowserContextDependencyManager::GetInstance() BrowserContextDependencyManager::GetInstance()
->RegisterCreateServicesCallbackForTesting( ->RegisterCreateServicesCallbackForTesting(
base::Bind(&ProfilePickerCreationFlowBrowserTest:: base::BindRepeating(&ProfilePickerCreationFlowBrowserTest::
OnWillCreateBrowserContextServices, OnWillCreateBrowserContextServices,
base::Unretained(this))); base::Unretained(this)));
} }
virtual void OnWillCreateBrowserContextServices( virtual void OnWillCreateBrowserContextServices(
......
...@@ -428,9 +428,9 @@ class InlineLoginHelperBrowserTest : public InProcessBrowserTest { ...@@ -428,9 +428,9 @@ class InlineLoginHelperBrowserTest : public InProcessBrowserTest {
create_services_subscription_ = create_services_subscription_ =
BrowserContextDependencyManager::GetInstance() BrowserContextDependencyManager::GetInstance()
->RegisterCreateServicesCallbackForTesting( ->RegisterCreateServicesCallbackForTesting(
base::Bind(&InlineLoginHelperBrowserTest:: base::BindRepeating(&InlineLoginHelperBrowserTest::
OnWillCreateBrowserContextServices, OnWillCreateBrowserContextServices,
base::Unretained(this))); base::Unretained(this)));
} }
void OnWillCreateBrowserContextServices(content::BrowserContext* context) { void OnWillCreateBrowserContextServices(content::BrowserContext* context) {
...@@ -742,7 +742,7 @@ class InlineLoginUISafeIframeBrowserTest : public InProcessBrowserTest { ...@@ -742,7 +742,7 @@ class InlineLoginUISafeIframeBrowserTest : public InProcessBrowserTest {
private: private:
void SetUp() override { void SetUp() override {
embedded_test_server()->RegisterRequestHandler( embedded_test_server()->RegisterRequestHandler(
base::Bind(&EmptyHtmlResponseHandler)); base::BindRepeating(&EmptyHtmlResponseHandler));
// Don't spin up the IO thread yet since no threads are allowed while // Don't spin up the IO thread yet since no threads are allowed while
// spawning sandbox host process. See crbug.com/322732. // spawning sandbox host process. See crbug.com/322732.
......
...@@ -50,9 +50,6 @@ class ToolbarActionView : public views::MenuButton, ...@@ -50,9 +50,6 @@ class ToolbarActionView : public views::MenuButton,
~Delegate() override {} ~Delegate() override {}
}; };
// Callback type used for testing.
using ContextMenuCallback = base::Callback<void(ToolbarActionView*)>;
ToolbarActionView(ToolbarActionViewController* view_controller, ToolbarActionView(ToolbarActionViewController* view_controller,
Delegate* delegate); Delegate* delegate);
ToolbarActionView(const ToolbarActionView&) = delete; ToolbarActionView(const ToolbarActionView&) = delete;
......
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