Chromium Code Reviews| Index: components/password_manager/core/browser/password_form_manager.cc |
| diff --git a/components/password_manager/core/browser/password_form_manager.cc b/components/password_manager/core/browser/password_form_manager.cc |
| index f48a559320fb68c48ddd654a4698104abf8967ef..90fd2271eaeb81bee0157a45340e5cad1aab7025 100644 |
| --- a/components/password_manager/core/browser/password_form_manager.cc |
| +++ b/components/password_manager/core/browser/password_form_manager.cc |
| @@ -11,7 +11,9 @@ |
| #include <set> |
| #include <utility> |
| +#include "base/command_line.h" |
| #include "base/memory/ptr_util.h" |
| +#include "base/metrics/field_trial.h" |
| #include "base/metrics/histogram_macros.h" |
| #include "base/strings/string_split.h" |
| #include "base/strings/string_util.h" |
| @@ -19,6 +21,7 @@ |
| #include "components/autofill/core/browser/autofill_manager.h" |
| #include "components/autofill/core/browser/proto/server.pb.h" |
| #include "components/autofill/core/browser/validation.h" |
| +#include "components/autofill/core/common/autofill_switches.h" |
| #include "components/autofill/core/common/password_form.h" |
| #include "components/password_manager/core/browser/affiliation_utils.h" |
| #include "components/password_manager/core/browser/browser_save_password_progress_logger.h" |
| @@ -46,6 +49,10 @@ namespace password_manager { |
| namespace { |
| +// Experiment information |
| +const char kFillOnAccountSelectFieldTrialName[] = "FillOnAccountSelect"; |
| +const char kFillOnAccountSelectFieldTrialEnabledGroup[] = "Enable"; |
| + |
| PasswordForm CopyAndModifySSLValidity(const PasswordForm& orig, |
| bool ssl_valid) { |
| PasswordForm result(orig); |
| @@ -112,6 +119,23 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> SplitFederatedMatches( |
| return federated_matches; |
| } |
| +bool ShouldShowInitialPasswordAccountSuggestions() { |
|
vabr (Chromium)
2016/06/10 14:19:52
Not for this CL, but if you get a chance, it might
jww
2016/06/10 23:06:54
Acknowledged.
|
| + std::string group_name = |
| + base::FieldTrialList::FindFullName(kFillOnAccountSelectFieldTrialName); |
| + |
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + autofill::switches::kDisableFillOnAccountSelect)) { |
| + return false; |
| + } |
| + |
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + autofill::switches::kEnableFillOnAccountSelect)) { |
| + return true; |
| + } |
| + |
| + return group_name == kFillOnAccountSelectFieldTrialEnabledGroup; |
|
vabr (Chromium)
2016/06/10 14:25:23
Could you make this match that kFillOnAccountSelec
jww
2016/06/10 23:06:54
Done.
|
| +} |
| + |
| } // namespace |
| PasswordFormManager::PasswordFormManager( |
| @@ -533,9 +557,21 @@ void PasswordFormManager::ProcessFrameInternal( |
| manager_action_ = kManagerActionNone; |
| else |
| manager_action_ = kManagerActionAutofilled; |
| - password_manager_->Autofill(driver.get(), observed_form_, best_matches_, |
| - federated_matches_, *preferred_match_, |
| - wait_for_username); |
| + if (ShouldShowInitialPasswordAccountSuggestions()) { |
| + // This is for the fill-on-account-select experiment. Instead of autofilling |
| + // found usernames and passwords on load, this instructs the renderer to |
| + // return with any found password forms so a list of password account |
| + // suggestions can be drawn. |
| + password_manager_->ShowInitialPasswordAccountSuggestions( |
| + driver.get(), observed_form_, best_matches_, federated_matches_, |
| + *preferred_match_, wait_for_username); |
| + } else { |
| + // If fill-on-account-select is not enabled, continue will autofilling any |
|
vabr (Chromium)
2016/06/10 14:19:51
typo: will -> with
jww
2016/06/10 23:06:54
Done.
|
| + // password forms as traditionally has been done. |
| + password_manager_->Autofill(driver.get(), observed_form_, best_matches_, |
| + federated_matches_, *preferred_match_, |
| + wait_for_username); |
| + } |
| } |
| void PasswordFormManager::ProcessLoginPrompt() { |