Commit 85048dc6 authored by Milica Selakovic's avatar Milica Selakovic Committed by Commit Bot

Suppressing Password Manager UI while Autofill assistant is running

This CL introducing 2 modes of collaboration between Password Manager
and Autofill Assistant (who handles form submissions, whether to show prompts or not).

Change-Id: I0394efa077060af2b6783add8a935658de8ee935

Bug: 1063347
Change-Id: I0394efa077060af2b6783add8a935658de8ee935
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2110231
Commit-Queue: Milica Selakovic <selakovic@google.com>
Reviewed-by: default avatarVadym Doroshenko <dvadym@chromium.org>
Reviewed-by: default avatarMaxim Kolosovskiy <kolos@chromium.org>
Reviewed-by: default avatarSandro Maggi <sandromaggi@google.com>
Reviewed-by: default avatarClemens Arbesser <arbesser@google.com>
Cr-Commit-Position: refs/heads/master@{#753187}
parent fe714ec4
...@@ -199,6 +199,11 @@ void ClientAndroid::TransferUITo( ...@@ -199,6 +199,11 @@ void ClientAndroid::TransferUITo(
// From this point on, the UIController, in ui_ptr, is either transferred or // From this point on, the UIController, in ui_ptr, is either transferred or
// deleted. // deleted.
GetPasswordManagerClient()
->GetPasswordManager()
->set_autofill_assistance_mode(
password_manager::AutofillAssistantMode::kNotRunning);
if (!jother_web_contents) if (!jother_web_contents)
return; return;
...@@ -433,6 +438,11 @@ void ClientAndroid::AttachUI( ...@@ -433,6 +438,11 @@ void ClientAndroid::AttachUI(
ui_controller_android_->Attach(web_contents_, this, controller_.get()); ui_controller_android_->Attach(web_contents_, this, controller_.get());
} }
GetPasswordManagerClient()
->GetPasswordManager()
->set_autofill_assistance_mode(
password_manager::AutofillAssistantMode::kManuallyCuratedScript);
} }
void ClientAndroid::DestroyUI() { void ClientAndroid::DestroyUI() {
...@@ -532,6 +542,11 @@ void ClientAndroid::Shutdown(Metrics::DropOutReason reason) { ...@@ -532,6 +542,11 @@ void ClientAndroid::Shutdown(Metrics::DropOutReason reason) {
if (!controller_) if (!controller_)
return; return;
GetPasswordManagerClient()
->GetPasswordManager()
->set_autofill_assistance_mode(
password_manager::AutofillAssistantMode::kNotRunning);
if (ui_controller_android_ && ui_controller_android_->IsAttached()) if (ui_controller_android_ && ui_controller_android_->IsAttached())
DestroyUI(); DestroyUI();
......
...@@ -828,6 +828,9 @@ void PasswordManager::OnPasswordFormsRendered( ...@@ -828,6 +828,9 @@ void PasswordManager::OnPasswordFormsRendered(
} }
void PasswordManager::OnLoginSuccessful() { void PasswordManager::OnLoginSuccessful() {
if (autofill_assistant_mode_ == AutofillAssistantMode::kManuallyCuratedScript)
return;
std::unique_ptr<BrowserSavePasswordProgressLogger> logger; std::unique_ptr<BrowserSavePasswordProgressLogger> logger;
if (password_manager_util::IsLoggingActive(client_)) { if (password_manager_util::IsLoggingActive(client_)) {
logger.reset( logger.reset(
......
...@@ -35,7 +35,7 @@ class PrefRegistrySyncable; ...@@ -35,7 +35,7 @@ class PrefRegistrySyncable;
namespace autofill { namespace autofill {
struct FormData; struct FormData;
class FormStructure; class FormStructure;
} } // namespace autofill
namespace password_manager { namespace password_manager {
...@@ -47,6 +47,18 @@ class PasswordFormManager; ...@@ -47,6 +47,18 @@ class PasswordFormManager;
class PasswordManagerMetricsRecorder; class PasswordManagerMetricsRecorder;
struct PossibleUsernameData; struct PossibleUsernameData;
// Define the modes of collaboration between Password Manager and Autofill
// Assistant (who handles form submissions, whether to show prompts or not).
enum class AutofillAssistantMode {
// Autofill Assistant is not running. Password Manager operates in the regular
// mode - it handles submissions and shows prompts.
kNotRunning = 0,
// Autofill Assistant runs a manually curated script. The password manager
// is basically off - it does not handle submissions and therefore does not
// show prompts. The script does all the work instead.
kManuallyCuratedScript
};
// Per-tab password manager. Handles creation and management of UI elements, // Per-tab password manager. Handles creation and management of UI elements,
// receiving password form data from the renderer and managing the password // receiving password form data from the renderer and managing the password
// database through the PasswordStore. // database through the PasswordStore.
...@@ -179,6 +191,11 @@ class PasswordManager : public FormSubmissionObserver { ...@@ -179,6 +191,11 @@ class PasswordManager : public FormSubmissionObserver {
// Notifies that Credential Management API function store() is called. // Notifies that Credential Management API function store() is called.
void NotifyStorePasswordCalled(); void NotifyStorePasswordCalled();
void set_autofill_assistance_mode(
AutofillAssistantMode autofill_assistant_mode) {
autofill_assistant_mode_ = autofill_assistant_mode;
}
#if defined(OS_IOS) #if defined(OS_IOS)
// TODO(https://crbug.com/866444): Use these methods instead olds ones when // TODO(https://crbug.com/866444): Use these methods instead olds ones when
// the old parser is gone. // the old parser is gone.
...@@ -354,6 +371,11 @@ class PasswordManager : public FormSubmissionObserver { ...@@ -354,6 +371,11 @@ class PasswordManager : public FormSubmissionObserver {
base::Optional<PossibleUsernameData> possible_username_; base::Optional<PossibleUsernameData> possible_username_;
// By default Autofill Assistant is not running. Password Manager handles
// submissions and shows prompts.
AutofillAssistantMode autofill_assistant_mode_ =
AutofillAssistantMode::kNotRunning;
DISALLOW_COPY_AND_ASSIGN(PasswordManager); DISALLOW_COPY_AND_ASSIGN(PasswordManager);
}; };
......
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