Chromium Code Reviews| Index: components/password_manager/content/browser/credential_manager_impl.cc |
| diff --git a/components/password_manager/content/browser/credential_manager_impl.cc b/components/password_manager/content/browser/credential_manager_impl.cc |
| index 2b93023d44a65918ded02bf99e64eea2523aaea4..5fe96361ac3e87d76da0f310b28a567f89a75591 100644 |
| --- a/components/password_manager/content/browser/credential_manager_impl.cc |
| +++ b/components/password_manager/content/browser/credential_manager_impl.cc |
| @@ -22,7 +22,6 @@ |
| #include "components/password_manager/core/browser/password_manager_metrics_util.h" |
| #include "components/password_manager/core/browser/password_manager_util.h" |
| #include "components/password_manager/core/browser/password_store.h" |
| -#include "components/password_manager/core/common/credential_manager_types.h" |
| #include "components/password_manager/core/common/password_manager_pref_names.h" |
| #include "content/public/browser/web_contents.h" |
| @@ -146,19 +145,30 @@ void CredentialManagerImpl::RequireUserMediation( |
| pending_require_user_mediation_->AddOrigin(GetSynthesizedFormForOrigin()); |
| } |
| -void CredentialManagerImpl::Get(bool zero_click_only, |
| +void CredentialManagerImpl::Get(mojom::CredentialMediationRequirement mediation, |
| bool include_passwords, |
| const std::vector<GURL>& federations, |
| GetCallback callback) { |
| using metrics_util::LogCredentialManagerGetResult; |
| - metrics_util::CredentialManagerGetMediation mediation_status = |
| - zero_click_only ? metrics_util::CREDENTIAL_MANAGER_GET_UNMEDIATED |
| - : metrics_util::CREDENTIAL_MANAGER_GET_MEDIATED; |
| + |
| + mediation_ = [mediation]() { |
| + switch (mediation) { |
| + case mojom::CredentialMediationRequirement::SILENT: |
| + return CredentialMediationRequirement::SILENT; |
| + case mojom::CredentialMediationRequirement::OPTIONAL: |
| + return CredentialMediationRequirement::OPTIONAL; |
| + case mojom::CredentialMediationRequirement::REQUIRED: |
| + return CredentialMediationRequirement::REQUIRED; |
| + } |
| + NOTREACHED(); |
| + return CredentialMediationRequirement::OPTIONAL; |
| + }(); |
|
vasilii
2017/05/18 12:34:03
Ideally it should go away.
jdoerrie
2017/05/18 14:57:24
Done.
|
| + |
| PasswordStore* store = GetPasswordStore(); |
| if (password_manager_util::IsLoggingActive(client_)) { |
| CredentialManagerLogger(client_->GetLogManager()) |
| - .LogRequestCredential(web_contents()->GetLastCommittedURL(), |
| - zero_click_only, federations); |
| + .LogRequestCredential(web_contents()->GetLastCommittedURL(), mediation_, |
| + federations); |
| } |
| if (pending_request_ || !store) { |
| // Callback error. |
| @@ -168,7 +178,7 @@ void CredentialManagerImpl::Get(bool zero_click_only, |
| : mojom::CredentialManagerError::PASSWORDSTOREUNAVAILABLE, |
| base::nullopt); |
| LogCredentialManagerGetResult(metrics_util::CREDENTIAL_MANAGER_GET_REJECTED, |
| - mediation_status); |
| + mediation_); |
| return; |
| } |
| @@ -179,23 +189,23 @@ void CredentialManagerImpl::Get(bool zero_click_only, |
| std::move(callback).Run(mojom::CredentialManagerError::SUCCESS, |
| CredentialInfo()); |
| LogCredentialManagerGetResult(metrics_util::CREDENTIAL_MANAGER_GET_NONE, |
| - mediation_status); |
| + mediation_); |
| return; |
| } |
| // Return an empty credential if zero-click is required but disabled. |
| - if (zero_click_only && !IsZeroClickAllowed()) { |
| + if (mediation_ == CredentialMediationRequirement::SILENT && |
| + !IsZeroClickAllowed()) { |
| // Callback with empty credential info. |
| std::move(callback).Run(mojom::CredentialManagerError::SUCCESS, |
| CredentialInfo()); |
| LogCredentialManagerGetResult( |
| - metrics_util::CREDENTIAL_MANAGER_GET_NONE_ZERO_CLICK_OFF, |
| - mediation_status); |
| + metrics_util::CREDENTIAL_MANAGER_GET_NONE_ZERO_CLICK_OFF, mediation_); |
| return; |
| } |
| pending_request_.reset(new CredentialManagerPendingRequestTask( |
| this, base::Bind(&RunMojoGetCallback, base::Passed(&callback)), |
| - zero_click_only, include_passwords, federations)); |
| + mediation_, include_passwords, federations)); |
| // This will result in a callback to |
| // PendingRequestTask::OnGetPasswordStoreResults(). |
| GetPasswordStore()->GetLogins(GetSynthesizedFormForOrigin(), |
| @@ -253,14 +263,12 @@ void CredentialManagerImpl::SendPasswordForm( |
| base::RecordAction( |
| base::UserMetricsAction("CredentialManager_AccountChooser_Accepted")); |
| metrics_util::LogCredentialManagerGetResult( |
| - metrics_util::CREDENTIAL_MANAGER_GET_ACCOUNT_CHOOSER, |
| - metrics_util::CREDENTIAL_MANAGER_GET_MEDIATED); |
| + metrics_util::CREDENTIAL_MANAGER_GET_ACCOUNT_CHOOSER, mediation_); |
| } else { |
| base::RecordAction( |
| base::UserMetricsAction("CredentialManager_AccountChooser_Dismissed")); |
| metrics_util::LogCredentialManagerGetResult( |
| - metrics_util::CREDENTIAL_MANAGER_GET_NONE, |
| - metrics_util::CREDENTIAL_MANAGER_GET_MEDIATED); |
| + metrics_util::CREDENTIAL_MANAGER_GET_NONE, mediation_); |
| } |
| SendCredential(send_callback, info); |
| } |