Chromium Code Reviews| Index: components/password_manager/sync/browser/sync_credentials_filter.cc |
| diff --git a/components/password_manager/sync/browser/sync_credentials_filter.cc b/components/password_manager/sync/browser/sync_credentials_filter.cc |
| index 7e9699dd10940ab0c8d8f31b005654ad5a27a863..71e84030a88a1db659e0465cca116468a3d7f892 100644 |
| --- a/components/password_manager/sync/browser/sync_credentials_filter.cc |
| +++ b/components/password_manager/sync/browser/sync_credentials_filter.cc |
| @@ -6,12 +6,12 @@ |
| #include <algorithm> |
| -#include "base/command_line.h" |
| #include "base/macros.h" |
| #include "base/metrics/field_trial.h" |
| #include "base/metrics/histogram_macros.h" |
| #include "base/metrics/user_metrics.h" |
| -#include "components/password_manager/core/common/password_manager_switches.h" |
| +#include "components/password_manager/core/browser/password_manager_util.h" |
| +#include "components/password_manager/core/common/password_manager_features.h" |
| #include "components/password_manager/sync/browser/password_sync_util.h" |
| #include "google_apis/gaia/gaia_urls.h" |
| #include "net/base/url_util.h" |
| @@ -91,18 +91,45 @@ SyncCredentialsFilter::GetAutofillForSyncCredentialsState() { |
| std::string group_name = |
| base::FieldTrialList::FindFullName("AutofillSyncCredential"); |
| - base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| - if (command_line->HasSwitch(switches::kAllowAutofillSyncCredential)) |
| - return ALLOW_SYNC_CREDENTIALS; |
| - if (command_line->HasSwitch( |
| - switches::kDisallowAutofillSyncCredentialForReauth)) { |
| - return DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; |
| - } |
| - if (command_line->HasSwitch(switches::kDisallowAutofillSyncCredential)) |
| + bool protect_sync_credential_enabled = |
| + base::FeatureList::IsEnabled(features::kProtectSyncCredential); |
| + bool protect_sync_credential_on_reauth_enabled = |
| + base::FeatureList::IsEnabled(features::kProtectSyncCredentialOnReauth); |
| + bool protect_sync_credential_disabled = |
| + password_manager_util::IsFeatureDisabledFromCommandLine( |
| + features::kProtectSyncCredential); |
| + bool protect_sync_credential_on_reauth_disabled = |
| + password_manager_util::IsFeatureDisabledFromCommandLine( |
| + features::kProtectSyncCredentialOnReauth); |
| + |
| + if (protect_sync_credential_enabled && |
| + protect_sync_credential_on_reauth_enabled) { |
| + // Both the features are enabled, do not ever fill the sync credential. |
| return DISALLOW_SYNC_CREDENTIALS; |
| + } else if (protect_sync_credential_on_reauth_disabled) { |
|
Bernhard Bauer
2016/02/11 11:12:40
You don't need an else if you return in the branch
Pritam Nikam
2016/02/25 14:16:06
Done.
|
| + // Only 'protect-sync-credential-on-reauth' feature is kept disabled. This |
| + // is "illegal", emit a warning and do not ever fill the sync credential. |
| + LOG(WARNING) << "This is illegal! Feature " |
| + "'protect-sync-credential-on-reauth' cannot be kept " |
| + "disabled if 'protect-sync-credential' feature is enabled. " |
| + "We shall not ever fill the sync credential is such cases."; |
| + return DISALLOW_SYNC_CREDENTIALS; |
| + } |
| + |
| + if (protect_sync_credential_disabled) { |
| + if (protect_sync_credential_on_reauth_disabled) { |
| + // Both the features are disabled, fill the sync credential everywhere. |
| + return ALLOW_SYNC_CREDENTIALS; |
| + } else if (protect_sync_credential_on_reauth_enabled) { |
| + // Only 'protect-sync-credential-on-reauth' feature is kept enabled, fill |
| + // the sync credential everywhere but on reauth. |
| + return DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; |
| + } |
| + } |
| if (group_name == "DisallowSyncCredentialsForReauth") |
| return DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; |
| + |
| if (group_name == "DisallowSyncCredentials") |
| return DISALLOW_SYNC_CREDENTIALS; |