OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/password_manager/sync/browser/sync_credentials_filter.h" | 5 #include "components/password_manager/sync/browser/sync_credentials_filter.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | |
10 #include "base/macros.h" | 9 #include "base/macros.h" |
11 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
12 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
13 #include "base/metrics/user_metrics.h" | 12 #include "base/metrics/user_metrics.h" |
14 #include "components/password_manager/core/common/password_manager_switches.h" | 13 #include "components/password_manager/core/browser/password_manager_util.h" |
| 14 #include "components/password_manager/core/common/password_manager_features.h" |
15 #include "components/password_manager/sync/browser/password_sync_util.h" | 15 #include "components/password_manager/sync/browser/password_sync_util.h" |
16 #include "google_apis/gaia/gaia_urls.h" | 16 #include "google_apis/gaia/gaia_urls.h" |
17 #include "net/base/url_util.h" | 17 #include "net/base/url_util.h" |
18 | 18 |
19 using autofill::PasswordForm; | 19 using autofill::PasswordForm; |
20 | 20 |
21 namespace password_manager { | 21 namespace password_manager { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 void SyncCredentialsFilter::ReportFormUsed( | 82 void SyncCredentialsFilter::ReportFormUsed( |
83 const autofill::PasswordForm& form) const { | 83 const autofill::PasswordForm& form) const { |
84 base::RecordAction( | 84 base::RecordAction( |
85 base::UserMetricsAction("PasswordManager_SyncCredentialUsed")); | 85 base::UserMetricsAction("PasswordManager_SyncCredentialUsed")); |
86 } | 86 } |
87 | 87 |
88 // static | 88 // static |
89 SyncCredentialsFilter::AutofillForSyncCredentialsState | 89 SyncCredentialsFilter::AutofillForSyncCredentialsState |
90 SyncCredentialsFilter::GetAutofillForSyncCredentialsState() { | 90 SyncCredentialsFilter::GetAutofillForSyncCredentialsState() { |
91 std::string group_name = | 91 bool protect_sync_credential_enabled = |
92 base::FieldTrialList::FindFullName("AutofillSyncCredential"); | 92 base::FeatureList::IsEnabled(features::kProtectSyncCredential); |
| 93 bool protect_sync_credential_on_reauth_enabled = |
| 94 base::FeatureList::IsEnabled(features::kProtectSyncCredentialOnReauth); |
93 | 95 |
94 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 96 if (protect_sync_credential_enabled) { |
95 if (command_line->HasSwitch(switches::kAllowAutofillSyncCredential)) | 97 if (protect_sync_credential_on_reauth_enabled) { |
96 return ALLOW_SYNC_CREDENTIALS; | 98 // Both the features are enabled, do not ever fill the sync credential. |
97 if (command_line->HasSwitch( | 99 return DISALLOW_SYNC_CREDENTIALS; |
98 switches::kDisallowAutofillSyncCredentialForReauth)) { | 100 } |
| 101 |
| 102 // Only 'protect-sync-credential-on-reauth' feature is kept disabled. This |
| 103 // is "illegal", emit a warning and do not ever fill the sync credential. |
| 104 LOG(WARNING) << "This is illegal! Feature " |
| 105 "'protect-sync-credential-on-reauth' cannot be kept " |
| 106 "disabled if 'protect-sync-credential' feature is enabled. " |
| 107 "We shall not ever fill the sync credential is such cases."; |
| 108 return DISALLOW_SYNC_CREDENTIALS; |
| 109 } |
| 110 |
| 111 if (protect_sync_credential_on_reauth_enabled) { |
| 112 // Only 'protect-sync-credential-on-reauth' feature is kept enabled, fill |
| 113 // the sync credential everywhere but on reauth. |
99 return DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; | 114 return DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; |
100 } | 115 } |
101 if (command_line->HasSwitch(switches::kDisallowAutofillSyncCredential)) | |
102 return DISALLOW_SYNC_CREDENTIALS; | |
103 | 116 |
104 if (group_name == "DisallowSyncCredentialsForReauth") | 117 // Both the features are disabled, fill the sync credential everywhere. |
105 return DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; | |
106 if (group_name == "DisallowSyncCredentials") | |
107 return DISALLOW_SYNC_CREDENTIALS; | |
108 | |
109 // Allow by default. | |
110 return ALLOW_SYNC_CREDENTIALS; | 118 return ALLOW_SYNC_CREDENTIALS; |
111 } | 119 } |
112 | 120 |
113 } // namespace password_manager | 121 } // namespace password_manager |
OLD | NEW |