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/core/browser/password_manager_util.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 Vaclav's inputs. Created 4 years, 9 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/core/browser/password_manager_util.h" 5 #include "components/password_manager/core/browser/password_manager_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/metrics/field_trial.h"
10 #include "base/strings/string_util.h"
9 #include "components/autofill/core/common/password_form.h" 11 #include "components/autofill/core/common/password_form.h"
10 #include "components/password_manager/core/browser/log_manager.h" 12 #include "components/password_manager/core/browser/log_manager.h"
13 #include "components/password_manager/core/common/password_manager_features.h"
11 #include "components/sync_driver/sync_service.h" 14 #include "components/sync_driver/sync_service.h"
15 #include "components/variations/variations_associated_data.h"
12 16
13 namespace password_manager_util { 17 namespace password_manager_util {
14 18
19 namespace {
20
21 void RegisterFieldTrialOverrideByGroup(
22 base::FeatureList* feature_list,
23 const base::Feature& feature,
24 const char* trial_name,
25 const char* group_name,
26 const base::FeatureList::OverrideState& override_state) {
27 base::FieldTrial* field_trial = base::FieldTrialList::Find(trial_name);
28 if (field_trial && base::StartsWith(field_trial->group_name(), group_name,
29 base::CompareCase::INSENSITIVE_ASCII)) {
30 feature_list->RegisterFieldTrialOverride(feature.name, override_state,
31 field_trial);
32 }
33 }
34
35 } // namespace
36
15 password_manager::PasswordSyncState GetPasswordSyncState( 37 password_manager::PasswordSyncState GetPasswordSyncState(
16 const sync_driver::SyncService* sync_service) { 38 const sync_driver::SyncService* sync_service) {
17 if (sync_service && sync_service->IsFirstSetupComplete() && 39 if (sync_service && sync_service->IsFirstSetupComplete() &&
18 sync_service->IsSyncActive() && 40 sync_service->IsSyncActive() &&
19 sync_service->GetActiveDataTypes().Has(syncer::PASSWORDS)) { 41 sync_service->GetActiveDataTypes().Has(syncer::PASSWORDS)) {
20 return sync_service->IsUsingSecondaryPassphrase() 42 return sync_service->IsUsingSecondaryPassphrase()
21 ? password_manager::SYNCING_WITH_CUSTOM_PASSPHRASE 43 ? password_manager::SYNCING_WITH_CUSTOM_PASSPHRASE
22 : password_manager::SYNCING_NORMAL_ENCRYPTION; 44 : password_manager::SYNCING_NORMAL_ENCRYPTION;
23 } 45 }
24 return password_manager::NOT_SYNCING_PASSWORDS; 46 return password_manager::NOT_SYNCING_PASSWORDS;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } 106 }
85 old_vector.weak_clear(); // All owned by |new_vector| by now. 107 old_vector.weak_clear(); // All owned by |new_vector| by now.
86 return new_vector; 108 return new_vector;
87 } 109 }
88 110
89 bool IsLoggingActive(const password_manager::PasswordManagerClient* client) { 111 bool IsLoggingActive(const password_manager::PasswordManagerClient* client) {
90 const password_manager::LogManager* log_manager = client->GetLogManager(); 112 const password_manager::LogManager* log_manager = client->GetLogManager();
91 return log_manager && log_manager->IsLoggingActive(); 113 return log_manager && log_manager->IsLoggingActive();
92 } 114 }
93 115
116 void RegisterFieldTrials(base::FeatureList* feature_list) {
117 // affiliation-based-matching:
118 // * default = on
119 // * Field trial name = "AffiliationBasedMatching"
120 // - groups starting with "Disabled" turns the feature off.
121 // - other groups turn the feature on.
122 // - variation param "propagate_password_changes_to_web" with the value
123 // "disabled" turns the feature off.
124 // - other values for the variation param
125 // "propagate_password_changes_to_web" turn the feature on.
126 const char kAffiliationBasedMatchingTrial[] = "AffiliationBasedMatching";
127 const char kDisabled[] = "Disabled";
vabr (Chromium) 2016/02/26 12:54:42 nit: Just hard-code the string. kDisabled and "Dis
Pritam Nikam 2016/02/26 14:10:29 Done.
128
129 RegisterFieldTrialOverrideByGroup(
130 feature_list, password_manager::features::kAffiliationBasedMatching,
131 kAffiliationBasedMatchingTrial, kDisabled,
132 base::FeatureList::OVERRIDE_DISABLE_FEATURE);
133
134 base::FieldTrial* field_trial =
135 base::FieldTrialList::Find(kAffiliationBasedMatchingTrial);
136 const std::string update_enabled = variations::GetVariationParamValue(
137 kAffiliationBasedMatchingTrial, "propagate_password_changes_to_web");
138 if (field_trial && base::StartsWith(update_enabled, kDisabled,
139 base::CompareCase::INSENSITIVE_ASCII)) {
140 feature_list->RegisterFieldTrialOverride(
141 password_manager::features::kAffiliationBasedMatching.name,
142 base::FeatureList::OVERRIDE_DISABLE_FEATURE, field_trial);
143 }
144
145 // drop-sync-credential
146 // * default = on
147 // * Field trial name = "PasswordManagerDropSyncCredential"
148 // - group "Disabled" turns the feature off.
149 // - other groups turn the feature on.
150 RegisterFieldTrialOverrideByGroup(
151 feature_list, password_manager::features::kDropSyncCredential,
152 "PasswordManagerDropSyncCredential", kDisabled,
153 base::FeatureList::OVERRIDE_DISABLE_FEATURE);
154
155 // manager-for-sync-signin
156 // * default = off
157 // * Field trial name = "PasswordManagerStateForSyncSignin"
158 // - group "Disabled" turns the feature off.
159 // - other groups turn the feature on.
160 // TODO(vabr): This feature is obsolete: http://crbug.com/586107
161 RegisterFieldTrialOverrideByGroup(
162 feature_list, password_manager::features::kManagerForSyncSignin,
163 "PasswordManagerStateForSyncSignin", kDisabled,
164 base::FeatureList::OVERRIDE_DISABLE_FEATURE);
165
166 // protect-sync-credential
167 // * default = off
168 // * Field trial name = "AutofillSyncCredential"
169 // - group "DisallowSyncCredentials" turns the feature on.
170 // - other groups turn the feature off.
171 RegisterFieldTrialOverrideByGroup(
172 feature_list, password_manager::features::kProtectSyncCredential,
173 "AutofillSyncCredential", "DisallowSyncCredentials",
174 base::FeatureList::OVERRIDE_ENABLE_FEATURE);
175
176 // protect-sync-credential-on-reauth
177 // * default = off
178 // * Field trial name = "AutofillSyncCredential"
179 // - groups "DisallowSyncCredentials" and "DisallowSyncCredentialsForReauth"
180 // turn the feature on.
181 // - other groups turn the feature off.
182 RegisterFieldTrialOverrideByGroup(
183 feature_list, password_manager::features::kProtectSyncCredentialOnReauth,
184 "AutofillSyncCredential", "DisallowSyncCredentials",
185 base::FeatureList::OVERRIDE_ENABLE_FEATURE);
186
187 RegisterFieldTrialOverrideByGroup(
188 feature_list, password_manager::features::kProtectSyncCredentialOnReauth,
189 "AutofillSyncCredential", "DisallowSyncCredentialsForReauth",
190 base::FeatureList::OVERRIDE_ENABLE_FEATURE);
191 }
192
94 } // namespace password_manager_util 193 } // namespace password_manager_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698