Skip to content

Commit

Permalink
Made mojom::PasswordManagerDriver::ShowTouchToFill android-only
Browse files Browse the repository at this point in the history
TouchToFill is an Android-only feature.
This patch hide ShowTouchToFill() behind |BUILDFLAG(IS_ANDROID)|.

Bug: 1299430
Change-Id: I652ea13929f8864c4f8477fcb1d561ca2ae88d2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3626449
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Mustafa Emre Acer <meacer@chromium.org>
Reviewed-by: Maxim Kolosovskiy <kolos@chromium.org>
Commit-Queue: DongJun Kim <deejay@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1001133}
  • Loading branch information
deejay-kim-naver authored and Chromium LUCI CQ committed May 9, 2022
1 parent 2309aee commit 3800141
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,10 @@ bool ChromePasswordManagerClient::PromptUserToChooseCredentials(
#endif
}

#if BUILDFLAG(IS_ANDROID)
void ChromePasswordManagerClient::ShowTouchToFill(
PasswordManagerDriver* driver,
autofill::mojom::SubmissionReadinessState submission_readiness) {
#if BUILDFLAG(IS_ANDROID)
std::vector<TouchToFillWebAuthnCredential> webauthn_credentials;
if (GetWebAuthnCredentialsDelegate() &&
GetWebAuthnCredentialsDelegate()->IsWebAuthnAutofillEnabled()) {
Expand All @@ -450,10 +450,8 @@ void ChromePasswordManagerClient::ShowTouchToFill(
driver->GetLastCommittedURL().DeprecatedGetOriginAsURL()))
.GetCredentials(),
webauthn_credentials, driver->AsWeakPtr(), submission_readiness);
#endif
}

#if BUILDFLAG(IS_ANDROID)
void ChromePasswordManagerClient::OnPasswordSelected(
const std::u16string& text) {
password_reuse_detection_manager_.OnPaste(text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ class ChromePasswordManagerClient
std::vector<std::unique_ptr<password_manager::PasswordForm>> local_forms,
const url::Origin& origin,
CredentialsCallback callback) override;
#if BUILDFLAG(IS_ANDROID)
void ShowTouchToFill(
password_manager::PasswordManagerDriver* driver,
autofill::mojom::SubmissionReadinessState submission_readiness) override;

#if BUILDFLAG(IS_ANDROID)
// Notifies `PasswordReuseDetectionManager` about passwords selected from
// AllPasswordsBottomSheet.
void OnPasswordSelected(const std::u16string& text) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4324,10 +4324,12 @@ class MockPrerenderPasswordManagerDriver
int options,
const gfx::RectF& bounds),
(override));
#if BUILDFLAG(IS_ANDROID)
MOCK_METHOD(void,
ShowTouchToFill,
(autofill::mojom::SubmissionReadinessState),
(override));
#endif
MOCK_METHOD(void,
CheckSafeBrowsingReputation,
(const GURL& form_action, const GURL& frame_url),
Expand Down Expand Up @@ -4393,11 +4395,13 @@ class MockPrerenderPasswordManagerDriver
impl_->ShowPasswordSuggestions(text_direction, typed_username,
options, bounds);
});
#if BUILDFLAG(IS_ANDROID)
ON_CALL(*this, ShowTouchToFill)
.WillByDefault([this](autofill::mojom::SubmissionReadinessState
submission_readiness) {
impl_->ShowTouchToFill(submission_readiness);
});
#endif
ON_CALL(*this, CheckSafeBrowsingReputation)
.WillByDefault([this](const GURL& form_action, const GURL& frame_url) {
impl_->CheckSafeBrowsingReputation(form_action, frame_url);
Expand Down
2 changes: 2 additions & 0 deletions chrome/renderer/autofill/fake_mojo_password_manager_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ class FakeMojoPasswordManagerDriver
(const autofill::FormData&),
(override));

#if BUILDFLAG(IS_ANDROID)
MOCK_METHOD(void,
ShowTouchToFill,
(autofill::mojom::SubmissionReadinessState),
(override));
#endif

MOCK_METHOD(void,
ShowPasswordSuggestions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1777,13 +1777,10 @@ TEST_F(PasswordAutofillAgentTest, TryToShowTouchToFillUsername) {
EXPECT_EQ(WebAutofillState::kPreviewed, username_element_.GetAutofillState());
EXPECT_EQ(WebAutofillState::kPreviewed, password_element_.GetAutofillState());

// TODO(crbug.com/1299430): Consider to disable |ShowTouchToFill| on Desktop.
#if BUILDFLAG(IS_ANDROID)
EXPECT_CALL(
fake_driver_,
ShowTouchToFill(autofill::mojom::SubmissionReadinessState::kEmptyFields));
#else
EXPECT_CALL(fake_driver_, ShowTouchToFill);
#endif
base::RunLoop().RunUntilIdle();
}
Expand All @@ -1796,13 +1793,10 @@ TEST_F(PasswordAutofillAgentTest, TryToShowTouchToFillPassword) {
EXPECT_TRUE(password_autofill_agent_->ShouldSuppressKeyboard());
EXPECT_EQ(WebAutofillState::kPreviewed, password_element_.GetAutofillState());

// TODO(crbug.com/1299430): Consider to disable |ShowTouchToFill| on Desktop.
#if BUILDFLAG(IS_ANDROID)
EXPECT_CALL(
fake_driver_,
ShowTouchToFill(autofill::mojom::SubmissionReadinessState::kEmptyFields));
#else
EXPECT_CALL(fake_driver_, ShowTouchToFill);
#endif
base::RunLoop().RunUntilIdle();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ interface PasswordManagerDriver {

// Instructs the browser to show the Touch To Fill UI and whether the form is
// ready for submission after filling.
[EnableIf=is_android]
ShowTouchToFill(SubmissionReadinessState submission_readiness);

// Checks the safe browsing reputation of the website where the focused
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,11 +590,13 @@ class PasswordAutofillAgent::DeferringPasswordManagerDriver
DeferMsg(&mojom::PasswordManagerDriver::ShowPasswordSuggestions,
text_direction, typed_username, options, bounds);
}
#if BUILDFLAG(IS_ANDROID)
void ShowTouchToFill(
mojom::SubmissionReadinessState submission_readiness) override {
DeferMsg(&mojom::PasswordManagerDriver::ShowTouchToFill,
submission_readiness);
}
#endif
void CheckSafeBrowsingReputation(const GURL& form_action,
const GURL& frame_url) override {
DeferMsg(&mojom::PasswordManagerDriver::CheckSafeBrowsingReputation,
Expand Down Expand Up @@ -1036,6 +1038,8 @@ bool PasswordAutofillAgent::ShouldSuppressKeyboard() {
return touch_to_fill_state_ == TouchToFillState::kIsShowing;
}

// TODO(crbug.com/1299430): Disable |TryToShowTouchToFill| and
// |touch_to_fill_state_| on Desktop.
bool PasswordAutofillAgent::TryToShowTouchToFill(
const WebFormControlElement& control_element) {
if (touch_to_fill_state_ != TouchToFillState::kShouldShow)
Expand Down Expand Up @@ -1071,8 +1075,6 @@ bool PasswordAutofillAgent::TryToShowTouchToFill(

focused_input_element_ = input_element;

// TODO(crbug.com/1299430): Consider to disable |TryToShowTouchToFill| and
// |ShowTouchToFill| on Desktop.
#if BUILDFLAG(IS_ANDROID)
WebFormElement form = password_element.Form();
std::unique_ptr<FormData> form_data =
Expand All @@ -1082,9 +1084,6 @@ bool PasswordAutofillAgent::TryToShowTouchToFill(
form_data ? CalculateSubmissionReadiness(*form_data, username_element,
password_element)
: mojom::SubmissionReadinessState::kNoInformation);
#else
GetPasswordManagerDriver().ShowTouchToFill(
mojom::SubmissionReadinessState::kNoInformation);
#endif

touch_to_fill_state_ = TouchToFillState::kIsShowing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ class FakeContentPasswordManagerDriver : public mojom::PasswordManagerDriver {
int options,
const gfx::RectF& bounds) override {}

#if BUILDFLAG(IS_ANDROID)
void ShowTouchToFill(
autofill::mojom::SubmissionReadinessState submission_readiness) override {
}
#endif

void RecordSavePasswordProgress(const std::string& log) override {
called_record_save_ = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,13 +401,15 @@ void ContentPasswordManagerDriver::ShowPasswordSuggestions(
TransformToRootCoordinates(render_frame_host_, bounds));
}

#if BUILDFLAG(IS_ANDROID)
void ContentPasswordManagerDriver::ShowTouchToFill(
autofill::mojom::SubmissionReadinessState submission_readiness) {
if (!password_manager::bad_message::CheckFrameNotPrerendering(
render_frame_host_))
return;
client_->ShowTouchToFill(this, submission_readiness);
}
#endif

void ContentPasswordManagerDriver::CheckSafeBrowsingReputation(
const GURL& form_action,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ class ContentPasswordManagerDriver
const std::u16string& typed_username,
int options,
const gfx::RectF& bounds) override;
#if BUILDFLAG(IS_ANDROID)
void ShowTouchToFill(
autofill::mojom::SubmissionReadinessState submission_readiness) override;
#endif
void CheckSafeBrowsingReputation(const GURL& form_action,
const GURL& frame_url) override;
void FocusedInputChanged(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ bool PasswordManagerClient::IsFillingFallbackEnabled(const GURL& url) const {
return true;
}

#if BUILDFLAG(IS_ANDROID)
void PasswordManagerClient::ShowTouchToFill(
PasswordManagerDriver* driver,
autofill::mojom::SubmissionReadinessState submission_readiness) {}

void PasswordManagerClient::OnPasswordSelected(const std::u16string& text) {}
#endif

scoped_refptr<device_reauth::BiometricAuthenticator>
PasswordManagerClient::GetBiometricAuthenticator() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class PasswordManagerClient {
const url::Origin& origin,
CredentialsCallback callback) = 0;

#if BUILDFLAG(IS_ANDROID)
// Instructs the client to show the Touch To Fill UI.
virtual void ShowTouchToFill(
PasswordManagerDriver* driver,
Expand All @@ -194,6 +195,7 @@ class PasswordManagerClient {
// Informs `PasswordReuseDetectionManager` about reused passwords selected
// from the AllPasswordsBottomSheet.
virtual void OnPasswordSelected(const std::u16string& text);
#endif

// Returns a pointer to a BiometricAuthenticator. Might be null if
// BiometricAuthentication is not available for a given platform.
Expand Down
4 changes: 4 additions & 0 deletions weblayer/browser/password_manager_driver_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,13 @@ class PasswordManagerDriverFactory::PasswordManagerDriver
const std::u16string& typed_username,
int options,
const gfx::RectF& bounds) override {}

#if BUILDFLAG(IS_ANDROID)
void ShowTouchToFill(
autofill::mojom::SubmissionReadinessState submission_readiness) override {
}
#endif

void CheckSafeBrowsingReputation(const GURL& form_action,
const GURL& frame_url) override {}
void FocusedInputChanged(
Expand Down

0 comments on commit 3800141

Please sign in to comment.