Skip to content

Commit

Permalink
[FastCheckout] Remove external actions delegate.
Browse files Browse the repository at this point in the history
Bug: 1385669,1334642
Change-Id: I8882b93c65eeccc37382bc9fdfc28ab91ebdd957
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4037717
Reviewed-by: Wolfgang Billenstein <bwolfgang@google.com>
Commit-Queue: Norge Vizcay <vizcay@google.com>
Reviewed-by: Jan Keitel <jkeitel@google.com>
Cr-Commit-Position: refs/heads/main@{#1075233}
  • Loading branch information
norgevz authored and Chromium LUCI CQ committed Nov 23, 2022
1 parent 3b68b32 commit ca04d7a
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 363 deletions.
2 changes: 0 additions & 2 deletions chrome/browser/BUILD.gn
Expand Up @@ -3016,8 +3016,6 @@ static_library("browser") {
"fast_checkout/fast_checkout_client.h",
"fast_checkout/fast_checkout_client_impl.cc",
"fast_checkout/fast_checkout_client_impl.h",
"fast_checkout/fast_checkout_external_action_delegate.cc",
"fast_checkout/fast_checkout_external_action_delegate.h",
"fast_checkout/fast_checkout_tab_helper.cc",
"fast_checkout/fast_checkout_tab_helper.h",
"feature_guide/notifications/android/feature_notification_guide_bridge.cc",
Expand Down
12 changes: 1 addition & 11 deletions chrome/browser/fast_checkout/fast_checkout_client_impl.cc
Expand Up @@ -7,7 +7,6 @@
#include "base/feature_list.h"
#include "base/metrics/histogram_functions.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/fast_checkout/fast_checkout_external_action_delegate.h"
#include "chrome/browser/fast_checkout/fast_checkout_features.h"
#include "chrome/browser/profiles/profile.h"
#include "components/autofill/content/browser/content_autofill_driver.h"
Expand Down Expand Up @@ -92,9 +91,6 @@ bool FastCheckoutClientImpl::Start(
delegate_ = std::move(delegate);
personal_data_manager_observation_.Observe(GetPersonalDataManager());

fast_checkout_external_action_delegate_ =
CreateFastCheckoutExternalActionDelegate();

SetShouldSuppressKeyboard(true);

fast_checkout_controller_ = CreateFastCheckoutController();
Expand Down Expand Up @@ -197,11 +193,6 @@ bool FastCheckoutClientImpl::IsRunning() const {
return is_running_;
}

std::unique_ptr<FastCheckoutExternalActionDelegate>
FastCheckoutClientImpl::CreateFastCheckoutExternalActionDelegate() {
return std::make_unique<FastCheckoutExternalActionDelegate>();
}

std::unique_ptr<FastCheckoutController>
FastCheckoutClientImpl::CreateFastCheckoutController() {
return std::make_unique<FastCheckoutControllerImpl>(&GetWebContents(), this);
Expand All @@ -217,8 +208,7 @@ void FastCheckoutClientImpl::OnHidden() {
void FastCheckoutClientImpl::OnOptionsSelected(
std::unique_ptr<autofill::AutofillProfile> selected_profile,
std::unique_ptr<autofill::CreditCard> selected_credit_card) {
fast_checkout_external_action_delegate_->SetOptionsSelected(
*selected_profile, *selected_credit_card);
// TODO(crbug.com/1334642): Signal that FC options have been selected.
OnHidden();
}

Expand Down
11 changes: 0 additions & 11 deletions chrome/browser/fast_checkout/fast_checkout_client_impl.h
Expand Up @@ -13,8 +13,6 @@
#include "content/public/browser/web_contents_user_data.h"
#include "url/gurl.h"

class FastCheckoutExternalActionDelegate;

namespace autofill {
class LogManager;
}
Expand Down Expand Up @@ -64,10 +62,6 @@ class FastCheckoutClientImpl
protected:
explicit FastCheckoutClientImpl(content::WebContents* web_contents);

// Creates the external action delegate.
virtual std::unique_ptr<FastCheckoutExternalActionDelegate>
CreateFastCheckoutExternalActionDelegate();

// Creates the UI controller.
virtual std::unique_ptr<FastCheckoutController>
CreateFastCheckoutController();
Expand Down Expand Up @@ -104,11 +98,6 @@ class FastCheckoutClientImpl
// Delegate for the surface being shown.
base::WeakPtr<autofill::FastCheckoutDelegate> delegate_;

// The delegate is responsible for handling protos received from backend DSL
// actions.
std::unique_ptr<FastCheckoutExternalActionDelegate>
fast_checkout_external_action_delegate_;

// Fast Checkout UI Controller. Responsible for showing the bottomsheet and
// handling user selections.
std::unique_ptr<FastCheckoutController> fast_checkout_controller_;
Expand Down
40 changes: 0 additions & 40 deletions chrome/browser/fast_checkout/fast_checkout_client_impl_unittest.cc
Expand Up @@ -15,7 +15,6 @@
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/fast_checkout/fast_checkout_external_action_delegate.h"
#include "chrome/browser/fast_checkout/fast_checkout_features.h"
#include "chrome/browser/ui/fast_checkout/fast_checkout_controller.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
Expand Down Expand Up @@ -143,19 +142,6 @@ class MockFastCheckoutDelegate : public autofill::FastCheckoutDelegate {
base::WeakPtrFactory<MockFastCheckoutDelegate> weak_factory_{this};
};

class MockFastCheckoutExternalActionDelegate
: public FastCheckoutExternalActionDelegate {
public:
MockFastCheckoutExternalActionDelegate() = default;
~MockFastCheckoutExternalActionDelegate() override = default;

MOCK_METHOD(void,
SetOptionsSelected,
(const AutofillProfile& selected_profile,
const CreditCard& selected_credit_card),
(override));
};

class TestFastCheckoutClientImpl : public FastCheckoutClientImpl {
public:
static TestFastCheckoutClientImpl* CreateForWebContents(
Expand All @@ -174,20 +160,8 @@ class TestFastCheckoutClientImpl : public FastCheckoutClientImpl {
fast_checkout_controller_ = std::move(fast_checkout_controller);
}

std::unique_ptr<FastCheckoutExternalActionDelegate>
CreateFastCheckoutExternalActionDelegate() override {
return std::move(external_action_delegate_);
}

void InjectFastCheckoutExternalActionDelegate(
std::unique_ptr<FastCheckoutExternalActionDelegate>
external_action_delegate) {
external_action_delegate_ = std::move(external_action_delegate);
}

private:
std::unique_ptr<FastCheckoutController> fast_checkout_controller_;
std::unique_ptr<FastCheckoutExternalActionDelegate> external_action_delegate_;
};

// static
Expand Down Expand Up @@ -223,13 +197,6 @@ class FastCheckoutClientImplTest : public ChromeRenderViewHostTestHarness {
test_client_->InjectFastCheckoutController(
std::move(fast_checkout_controller));

// Prepare the FastCheckoutExternalActionDelegate.
auto external_action_delegate =
std::make_unique<MockFastCheckoutExternalActionDelegate>();
external_action_delegate_ = external_action_delegate.get();
test_client_->InjectFastCheckoutExternalActionDelegate(
std::move(external_action_delegate));

// Prepare the FastCheckoutDelegate.
autofill_driver_ = std::make_unique<MockAutofillDriver>();
fast_checkout_delegate_ =
Expand All @@ -256,10 +223,6 @@ class FastCheckoutClientImplTest : public ChromeRenderViewHostTestHarness {
return fast_checkout_controller_;
}

MockFastCheckoutExternalActionDelegate* external_action_delegate() {
return external_action_delegate_;
}

MockAutofillDriver* autofill_driver() { return autofill_driver_.get(); }

base::WeakPtr<MockFastCheckoutDelegate> delegate() {
Expand All @@ -271,7 +234,6 @@ class FastCheckoutClientImplTest : public ChromeRenderViewHostTestHarness {
base::HistogramTester histogram_tester_;

raw_ptr<MockFastCheckoutController> fast_checkout_controller_;
raw_ptr<MockFastCheckoutExternalActionDelegate> external_action_delegate_;
std::unique_ptr<MockAutofillDriver> autofill_driver_;
std::unique_ptr<MockFastCheckoutDelegate> fast_checkout_delegate_;
raw_ptr<TestFastCheckoutClientImpl> test_client_;
Expand Down Expand Up @@ -542,8 +504,6 @@ TEST_F(FastCheckoutClientImplTest, OnDismiss_WhenIsRunning_CancelsTheRun) {

TEST_F(FastCheckoutClientImplTest,
OnOptionsSelected_MovesSelectionsToExternalActionDelegate) {
EXPECT_CALL(*external_action_delegate(), SetOptionsSelected);

// Starting the run successfully starts keyboard suppression.
EXPECT_CALL(*autofill_driver(), SetShouldSuppressKeyboard(true));
EXPECT_TRUE(fast_checkout_client()->Start(delegate(), GURL(kUrl)));
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit ca04d7a

Please sign in to comment.