Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: components/password_manager/sync/browser/sync_credentials_filter.cc

Issue 1668523002: [Password Manager] Switch password manager code to use the Feature framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresses the review inputs. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 std::string group_name =
92 base::FieldTrialList::FindFullName("AutofillSyncCredential"); 92 base::FieldTrialList::FindFullName("AutofillSyncCredential");
93 93
94 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 94 bool protect_sync_credential_enabled =
95 if (command_line->HasSwitch(switches::kAllowAutofillSyncCredential)) 95 base::FeatureList::IsEnabled(features::kProtectSyncCredential);
96 return ALLOW_SYNC_CREDENTIALS; 96 bool protect_sync_credential_on_reauth_enabled =
97 if (command_line->HasSwitch( 97 base::FeatureList::IsEnabled(features::kProtectSyncCredentialOnReauth);
98 switches::kDisallowAutofillSyncCredentialForReauth)) { 98 bool protect_sync_credential_disabled =
99 return DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; 99 password_manager_util::IsFeatureDisabledFromCommandLine(
100 features::kProtectSyncCredential);
101 bool protect_sync_credential_on_reauth_disabled =
102 password_manager_util::IsFeatureDisabledFromCommandLine(
103 features::kProtectSyncCredentialOnReauth);
104
105 if (protect_sync_credential_enabled &&
106 protect_sync_credential_on_reauth_enabled) {
107 // Both the features are enabled, do not ever fill the sync credential.
108 return DISALLOW_SYNC_CREDENTIALS;
109 } 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.
110 // Only 'protect-sync-credential-on-reauth' feature is kept disabled. This
111 // is "illegal", emit a warning and do not ever fill the sync credential.
112 LOG(WARNING) << "This is illegal! Feature "
113 "'protect-sync-credential-on-reauth' cannot be kept "
114 "disabled if 'protect-sync-credential' feature is enabled. "
115 "We shall not ever fill the sync credential is such cases.";
116 return DISALLOW_SYNC_CREDENTIALS;
100 } 117 }
101 if (command_line->HasSwitch(switches::kDisallowAutofillSyncCredential)) 118
102 return DISALLOW_SYNC_CREDENTIALS; 119 if (protect_sync_credential_disabled) {
120 if (protect_sync_credential_on_reauth_disabled) {
121 // Both the features are disabled, fill the sync credential everywhere.
122 return ALLOW_SYNC_CREDENTIALS;
123 } else if (protect_sync_credential_on_reauth_enabled) {
124 // Only 'protect-sync-credential-on-reauth' feature is kept enabled, fill
125 // the sync credential everywhere but on reauth.
126 return DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH;
127 }
128 }
103 129
104 if (group_name == "DisallowSyncCredentialsForReauth") 130 if (group_name == "DisallowSyncCredentialsForReauth")
105 return DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; 131 return DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH;
132
106 if (group_name == "DisallowSyncCredentials") 133 if (group_name == "DisallowSyncCredentials")
107 return DISALLOW_SYNC_CREDENTIALS; 134 return DISALLOW_SYNC_CREDENTIALS;
108 135
109 // Allow by default. 136 // Allow by default.
110 return ALLOW_SYNC_CREDENTIALS; 137 return ALLOW_SYNC_CREDENTIALS;
111 } 138 }
112 139
113 } // namespace password_manager 140 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698