Chromium Code Reviews| 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/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 void RegisterFieldTrialOverrideByVariationParam( | |
| 36 base::FeatureList* feature_list, | |
| 37 const base::Feature& feature, | |
| 38 const char* trial_name, | |
| 39 const char* variation_param_value, | |
| 40 const base::FeatureList::OverrideState& override_state) { | |
| 41 base::FieldTrial* field_trial = base::FieldTrialList::Find(trial_name); | |
| 42 const std::string update_enabled = | |
| 43 variations::GetVariationParamValue(trial_name, variation_param_value); | |
| 44 if (field_trial && base::StartsWith(update_enabled, "disabled", | |
|
vabr (Chromium)
2016/02/26 09:52:22
nit: I believe calls to this function would be mor
Pritam Nikam
2016/02/26 12:42:23
Acknowledged.
Added a in-line implementation inst
| |
| 45 base::CompareCase::INSENSITIVE_ASCII)) { | |
| 46 feature_list->RegisterFieldTrialOverride(feature.name, override_state, | |
| 47 field_trial); | |
| 48 } | |
| 49 } | |
| 50 | |
| 51 } // namespace | |
| 52 | |
| 15 password_manager::PasswordSyncState GetPasswordSyncState( | 53 password_manager::PasswordSyncState GetPasswordSyncState( |
| 16 const sync_driver::SyncService* sync_service) { | 54 const sync_driver::SyncService* sync_service) { |
| 17 if (sync_service && sync_service->IsFirstSetupComplete() && | 55 if (sync_service && sync_service->IsFirstSetupComplete() && |
| 18 sync_service->IsSyncActive() && | 56 sync_service->IsSyncActive() && |
| 19 sync_service->GetActiveDataTypes().Has(syncer::PASSWORDS)) { | 57 sync_service->GetActiveDataTypes().Has(syncer::PASSWORDS)) { |
| 20 return sync_service->IsUsingSecondaryPassphrase() | 58 return sync_service->IsUsingSecondaryPassphrase() |
| 21 ? password_manager::SYNCING_WITH_CUSTOM_PASSPHRASE | 59 ? password_manager::SYNCING_WITH_CUSTOM_PASSPHRASE |
| 22 : password_manager::SYNCING_NORMAL_ENCRYPTION; | 60 : password_manager::SYNCING_NORMAL_ENCRYPTION; |
| 23 } | 61 } |
| 24 return password_manager::NOT_SYNCING_PASSWORDS; | 62 return password_manager::NOT_SYNCING_PASSWORDS; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 } | 122 } |
| 85 old_vector.weak_clear(); // All owned by |new_vector| by now. | 123 old_vector.weak_clear(); // All owned by |new_vector| by now. |
| 86 return new_vector; | 124 return new_vector; |
| 87 } | 125 } |
| 88 | 126 |
| 89 bool IsLoggingActive(const password_manager::PasswordManagerClient* client) { | 127 bool IsLoggingActive(const password_manager::PasswordManagerClient* client) { |
| 90 const password_manager::LogManager* log_manager = client->GetLogManager(); | 128 const password_manager::LogManager* log_manager = client->GetLogManager(); |
| 91 return log_manager && log_manager->IsLoggingActive(); | 129 return log_manager && log_manager->IsLoggingActive(); |
| 92 } | 130 } |
| 93 | 131 |
| 132 void RegisterFieldTrials(base::FeatureList* feature_list) { | |
|
Pritam Nikam
2016/02/25 16:39:26
I guess I've to move these changes in "fieldtrial_
Pritam Nikam
2016/02/25 16:49:12
"fieldtrial_testing_config_{port}.json"
eg. https
vabr (Chromium)
2016/02/26 09:52:22
This does not sound like a good idea, actually. II
| |
| 133 // affiliation-based-matching: | |
| 134 // * default = on | |
| 135 // * Field trial name = "AffiliationBasedMatching" | |
| 136 // - groups starting with "Disabled" turns the feature off. | |
| 137 // - variation param value with "propagate_password_changes_to_web" turns | |
|
vabr (Chromium)
2016/02/26 09:52:22
Not every value, just the "disabled" value, right?
Pritam Nikam
2016/02/26 12:42:23
Done.
| |
| 138 // the feature off. | |
| 139 // - other groups turn the feature on. | |
| 140 RegisterFieldTrialOverrideByGroup( | |
| 141 feature_list, password_manager::features::kAffiliationBasedMatching, | |
| 142 "AffiliationBasedMatching", "Disabled", | |
| 143 base::FeatureList::OVERRIDE_DISABLE_FEATURE); | |
| 144 | |
| 145 RegisterFieldTrialOverrideByVariationParam( | |
|
vabr (Chromium)
2016/02/26 09:52:22
nit: Maybe it would be more readable to inline thi
Pritam Nikam
2016/02/26 12:42:23
Done.
| |
| 146 feature_list, password_manager::features::kAffiliationBasedMatching, | |
| 147 "AffiliationBasedMatching", "propagate_password_changes_to_web", | |
| 148 base::FeatureList::OVERRIDE_DISABLE_FEATURE); | |
| 149 | |
| 150 // drop-sync-credential | |
| 151 // * default = on | |
| 152 // * Field trial name = "PasswordManagerDropSyncCredential" | |
| 153 // - group "Disabled" turns the feature off. | |
| 154 // - other groups turn the feature on. | |
| 155 RegisterFieldTrialOverrideByGroup( | |
| 156 feature_list, password_manager::features::kDropSyncCredential, | |
| 157 "PasswordManagerDropSyncCredential", "Disabled", | |
| 158 base::FeatureList::OVERRIDE_DISABLE_FEATURE); | |
| 159 | |
| 160 // protect-sync-credential | |
| 161 // * default = off | |
| 162 // * Field trial name = "AutofillSyncCredential" | |
| 163 // - group "DisallowSyncCredentials" turns the feature on. | |
| 164 // - other groups turn the feature off. | |
| 165 RegisterFieldTrialOverrideByGroup( | |
| 166 feature_list, password_manager::features::kProtectSyncCredential, | |
| 167 "AutofillSyncCredential", "DisallowSyncCredentials", | |
| 168 base::FeatureList::OVERRIDE_ENABLE_FEATURE); | |
| 169 | |
| 170 // protect-sync-credential-on-reauth | |
| 171 // * default = off | |
| 172 // * Field trial name = "AutofillSyncCredential" | |
| 173 // - groups "DisallowSyncCredentials" and "DisallowSyncCredentialsForReauth" | |
| 174 // turn the feature on. | |
| 175 // - other groups turn the feature off. | |
| 176 RegisterFieldTrialOverrideByGroup( | |
| 177 feature_list, password_manager::features::kProtectSyncCredentialOnReauth, | |
| 178 "AutofillSyncCredential", "DisallowSyncCredentials", | |
| 179 base::FeatureList::OVERRIDE_ENABLE_FEATURE); | |
| 180 | |
| 181 RegisterFieldTrialOverrideByGroup( | |
| 182 feature_list, password_manager::features::kProtectSyncCredentialOnReauth, | |
| 183 "AutofillSyncCredential", "DisallowSyncCredentialsForReauth", | |
| 184 base::FeatureList::OVERRIDE_ENABLE_FEATURE); | |
| 185 } | |
| 186 | |
| 94 } // namespace password_manager_util | 187 } // namespace password_manager_util |
| OLD | NEW |