Skip to content

Commit

Permalink
[Autofill] Added ContentAutofillRouter skeleton.
Browse files Browse the repository at this point in the history
This CL adds the ContentAutofillRouter class without any side effects.

A ContentAutofillRouter instance is owned by
ContentAutofillDriverFactory (1 per WebContents), and
ContentAutofillDrivers hold a weak reference to it.

The event handlers of ContentAutofillDriver pass the event to
ContentAutofillRouter, which passes them back to – for now – the same
ContentAutofillDriver.

Bug: 1187842
Change-Id: I8daaf179bb943f1b91e3bcda877ed33e6f2594b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2879511
Commit-Queue: Christoph Schwering <schwering@google.com>
Reviewed-by: Dominic Battré <battre@chromium.org>
Reviewed-by: Evan Stade <estade@chromium.org>
Reviewed-by: Matthias Körber <koerber@google.com>
Cr-Commit-Position: refs/heads/master@{#892042}
  • Loading branch information
schwering authored and Chromium LUCI CQ committed Jun 14, 2021
1 parent 7db0246 commit 4aec5c0
Show file tree
Hide file tree
Showing 24 changed files with 1,126 additions and 188 deletions.
24 changes: 17 additions & 7 deletions chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "chrome/test/base/testing_profile.h"
#include "components/autofill/content/browser/content_autofill_driver.h"
#include "components/autofill/content/browser/content_autofill_driver_factory.h"
#include "components/autofill/content/browser/content_autofill_router.h"
#include "components/autofill/core/browser/autofill_external_delegate.h"
#include "components/autofill/core/browser/autofill_manager.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
Expand Down Expand Up @@ -75,11 +76,14 @@ class MockAutofillClient : public autofill::TestAutofillClient {

class MockAutofillDriver : public ContentAutofillDriver {
public:
MockAutofillDriver(content::RenderFrameHost* rfh, MockAutofillClient* client)
MockAutofillDriver(content::RenderFrameHost* rfh,
MockAutofillClient* client,
ContentAutofillRouter* router)
: ContentAutofillDriver(
rfh,
client,
kAppLocale,
router,
kDownloadState,
AutofillManager::AutofillManagerFactoryCallback()) {}

Expand Down Expand Up @@ -226,8 +230,7 @@ static constexpr absl::optional<int> kNoSelection;
class AutofillPopupControllerUnitTest : public ChromeRenderViewHostTestHarness {
public:
AutofillPopupControllerUnitTest()
: autofill_client_(new MockAutofillClient()),
autofill_popup_controller_(nullptr) {}
: autofill_client_(std::make_unique<MockAutofillClient>()) {}
~AutofillPopupControllerUnitTest() override = default;

void SetUp() override {
Expand All @@ -246,6 +249,10 @@ class AutofillPopupControllerUnitTest : public ChromeRenderViewHostTestHarness {
autofill_popup_controller_->DoHide();

external_delegate_.reset();
autofill_manager_.reset();
autofill_driver_.reset();
autofill_router_.reset();

ChromeRenderViewHostTestHarness::TearDown();
}

Expand Down Expand Up @@ -278,9 +285,12 @@ class AutofillPopupControllerUnitTest : public ChromeRenderViewHostTestHarness {

protected:
std::unique_ptr<MockAutofillClient> autofill_client_;
std::unique_ptr<ContentAutofillRouter> autofill_router_;
std::unique_ptr<NiceMock<MockAutofillDriver>> autofill_driver_;
std::unique_ptr<MockBrowserAutofillManager> autofill_manager_;
std::unique_ptr<NiceMock<MockAutofillExternalDelegate>> external_delegate_;
std::unique_ptr<NiceMock<MockAutofillPopupView>> autofill_popup_view_;
NiceMock<TestAutofillPopupController>* autofill_popup_controller_;
NiceMock<TestAutofillPopupController>* autofill_popup_controller_ = nullptr;
};

#if !BUILDFLAG(IS_CHROMEOS_ASH)
Expand All @@ -297,17 +307,17 @@ class AutofillPopupControllerAccessibilityUnitTest

std::unique_ptr<NiceMock<MockAutofillExternalDelegate>>
CreateExternalDelegate() override {
autofill_router_ = std::make_unique<ContentAutofillRouter>();
autofill_driver_ = std::make_unique<NiceMock<MockAutofillDriver>>(
web_contents()->GetMainFrame(), autofill_client_.get());
web_contents()->GetMainFrame(), autofill_client_.get(),
autofill_router_.get());
autofill_manager_ = std::make_unique<MockBrowserAutofillManager>(
autofill_driver_.get(), autofill_client_.get());
return std::make_unique<NiceMock<MockAutofillExternalDelegate>>(
autofill_manager_.get(), autofill_driver_.get());
}

protected:
std::unique_ptr<MockBrowserAutofillManager> autofill_manager_;
std::unique_ptr<NiceMock<MockAutofillDriver>> autofill_driver_;
content::testing::ScopedContentAXModeSetter accessibility_mode_setter_;
};
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,12 @@ AutofillProvider* AndroidAutofillManager::GetAutofillProvider() {
return nullptr;
}

void AndroidAutofillManager::SendFormDataToRenderer(
int query_id,
AutofillDriver::RendererFormDataAction action,
const FormData& form) {
driver()->SendFormDataToRenderer(query_id, action, form,
form.main_frame_origin, {});
}

} // namespace autofill
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class AndroidAutofillManager : public AutofillManager {

bool has_server_prediction() const { return has_server_prediction_; }

// Send the |form| to the renderer for the specified |action|.
void SendFormDataToRenderer(int query_id,
AutofillDriver::RendererFormDataAction action,
const FormData& form);

protected:
AndroidAutofillManager(
AutofillDriver* driver,
Expand Down
3 changes: 3 additions & 0 deletions components/autofill/content/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ static_library("browser") {
"content_autofill_driver.h",
"content_autofill_driver_factory.cc",
"content_autofill_driver_factory.h",
"content_autofill_router.cc",
"content_autofill_router.h",
"key_press_handler_manager.cc",
"key_press_handler_manager.h",
"risk/fingerprint.cc",
Expand Down Expand Up @@ -47,6 +49,7 @@ static_library("browser") {
"//services/device/public/mojom",
"//services/service_manager/public/cpp",
"//sql",
"//third_party/abseil-cpp:absl",
"//ui/base",
"//ui/display",
"//ui/gfx",
Expand Down

0 comments on commit 4aec5c0

Please sign in to comment.