Commit 87fdf1f3 authored by Michele Mancina's avatar Michele Mancina Committed by Commit Bot

[Autofill Assistant] Add information on missing username for the chosen login option

Bug: b/157457785
Change-Id: I405f33df3d48af3a83edfd58ebf6bb8fe29c08fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2390644Reviewed-by: default avatarMathias Carlen <mcarlen@chromium.org>
Commit-Queue: Michele Mancina <micantox@google.com>
Cr-Commit-Position: refs/heads/master@{#804156}
parent 4d594d96
......@@ -1131,6 +1131,10 @@ void CollectUserDataAction::WriteProcessedAction(UserData* user_data,
if (login_details != login_details_map_.end()) {
if (login_details->second->login.has_value()) {
user_data->selected_login_ = *login_details->second->login;
if (login_details->second->login->username.empty()) {
processed_action_proto_->mutable_collect_user_data_result()
->set_login_missing_username(true);
}
}
processed_action_proto_->mutable_collect_user_data_result()
......
......@@ -313,6 +313,50 @@ TEST_F(CollectUserDataActionTest, SelectLogin) {
action.ProcessAction(callback_.Get());
}
TEST_F(CollectUserDataActionTest, SelectLoginMissingUsername) {
ActionProto action_proto;
auto* collect_user_data_proto = action_proto.mutable_collect_user_data();
collect_user_data_proto->set_request_terms_and_conditions(false);
auto* login_details = collect_user_data_proto->mutable_login_details();
auto* login_option = login_details->add_login_options();
login_option->mutable_password_manager();
login_option->set_payload("payload");
ON_CALL(mock_website_login_manager_, OnGetLoginsForUrl(_, _))
.WillByDefault(RunOnceCallback<1>(std::vector<WebsiteLoginManager::Login>{
WebsiteLoginManager::Login(GURL(kFakeUrl), /*username=*/"")}));
// Action should fetch the logins, but not the passwords.
EXPECT_CALL(mock_website_login_manager_, OnGetLoginsForUrl(GURL(kFakeUrl), _))
.Times(1);
EXPECT_CALL(mock_website_login_manager_, OnGetPasswordForLogin(_, _))
.Times(0);
ON_CALL(mock_action_delegate_, CollectUserData(_))
.WillByDefault(
Invoke([this](CollectUserDataOptions* collect_user_data_options) {
user_data_.succeed_ = true;
user_data_.login_choice_identifier_.assign(
collect_user_data_options->login_choices[0].identifier);
std::move(collect_user_data_options->confirm_callback)
.Run(&user_data_, &user_model_);
}));
EXPECT_CALL(
callback_,
Run(Pointee(AllOf(
Property(&ProcessedActionProto::status, ACTION_APPLIED),
Property(
&ProcessedActionProto::collect_user_data_result,
Property(&CollectUserDataResultProto::login_payload, "payload")),
Property(&ProcessedActionProto::collect_user_data_result,
Property(&CollectUserDataResultProto::shown_to_user, true)),
Property(&ProcessedActionProto::collect_user_data_result,
Property(&CollectUserDataResultProto::login_missing_username,
true))))));
CollectUserDataAction action(&mock_action_delegate_, action_proto);
action.ProcessAction(callback_.Get());
}
TEST_F(CollectUserDataActionTest, LoginChoiceAutomaticIfNoOtherOptions) {
ActionProto action_proto;
auto* collect_user_data_proto = action_proto.mutable_collect_user_data();
......
......@@ -543,6 +543,8 @@ message CollectUserDataResultProto {
// Indicates whether the UI was shown to the user. This can be false if
// only the login section was requested and the choice was implicitly made.
optional bool shown_to_user = 16;
// Indicates that the chosen login option was missing the username.
optional bool login_missing_username = 17;
reserved 7, 8;
}
......
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