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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
Index: components/password_manager/core/browser/password_manager_util.cc
diff --git a/components/password_manager/core/browser/password_manager_util.cc b/components/password_manager/core/browser/password_manager_util.cc
index c4ccce1ecf9632625544c58a052e9ee568ec14bd..6ca4d00c45e3560d3a59a21597786c9c7d1e6519 100644
--- a/components/password_manager/core/browser/password_manager_util.cc
+++ b/components/password_manager/core/browser/password_manager_util.cc
@@ -6,12 +6,34 @@
#include <algorithm>
+#include "base/metrics/field_trial.h"
+#include "base/strings/string_util.h"
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/log_manager.h"
+#include "components/password_manager/core/common/password_manager_features.h"
#include "components/sync_driver/sync_service.h"
+#include "components/variations/variations_associated_data.h"
namespace password_manager_util {
+namespace {
+
+void RegisterFieldTrialOverrideByGroup(
+ base::FeatureList* feature_list,
+ const base::Feature& feature,
+ const char* trial_name,
+ const char* group_name,
+ const base::FeatureList::OverrideState& override_state) {
+ base::FieldTrial* field_trial = base::FieldTrialList::Find(trial_name);
+ if (field_trial && base::StartsWith(field_trial->group_name(), group_name,
+ base::CompareCase::INSENSITIVE_ASCII)) {
+ feature_list->RegisterFieldTrialOverride(feature.name, override_state,
+ field_trial);
+ }
+}
+
+} // namespace
+
password_manager::PasswordSyncState GetPasswordSyncState(
const sync_driver::SyncService* sync_service) {
if (sync_service && sync_service->IsFirstSetupComplete() &&
@@ -91,4 +113,81 @@ bool IsLoggingActive(const password_manager::PasswordManagerClient* client) {
return log_manager && log_manager->IsLoggingActive();
}
+void RegisterFieldTrials(base::FeatureList* feature_list) {
+ // affiliation-based-matching:
+ // * default = on
+ // * Field trial name = "AffiliationBasedMatching"
+ // - groups starting with "Disabled" turns the feature off.
+ // - other groups turn the feature on.
+ // - variation param "propagate_password_changes_to_web" with the value
+ // "disabled" turns the feature off.
+ // - other values for the variation param
+ // "propagate_password_changes_to_web" turn the feature on.
+ const char kAffiliationBasedMatchingTrial[] = "AffiliationBasedMatching";
+ 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.
+
+ RegisterFieldTrialOverrideByGroup(
+ feature_list, password_manager::features::kAffiliationBasedMatching,
+ kAffiliationBasedMatchingTrial, kDisabled,
+ base::FeatureList::OVERRIDE_DISABLE_FEATURE);
+
+ base::FieldTrial* field_trial =
+ base::FieldTrialList::Find(kAffiliationBasedMatchingTrial);
+ const std::string update_enabled = variations::GetVariationParamValue(
+ kAffiliationBasedMatchingTrial, "propagate_password_changes_to_web");
+ if (field_trial && base::StartsWith(update_enabled, kDisabled,
+ base::CompareCase::INSENSITIVE_ASCII)) {
+ feature_list->RegisterFieldTrialOverride(
+ password_manager::features::kAffiliationBasedMatching.name,
+ base::FeatureList::OVERRIDE_DISABLE_FEATURE, field_trial);
+ }
+
+ // drop-sync-credential
+ // * default = on
+ // * Field trial name = "PasswordManagerDropSyncCredential"
+ // - group "Disabled" turns the feature off.
+ // - other groups turn the feature on.
+ RegisterFieldTrialOverrideByGroup(
+ feature_list, password_manager::features::kDropSyncCredential,
+ "PasswordManagerDropSyncCredential", kDisabled,
+ base::FeatureList::OVERRIDE_DISABLE_FEATURE);
+
+ // manager-for-sync-signin
+ // * default = off
+ // * Field trial name = "PasswordManagerStateForSyncSignin"
+ // - group "Disabled" turns the feature off.
+ // - other groups turn the feature on.
+ // TODO(vabr): This feature is obsolete: http://crbug.com/586107
+ RegisterFieldTrialOverrideByGroup(
+ feature_list, password_manager::features::kManagerForSyncSignin,
+ "PasswordManagerStateForSyncSignin", kDisabled,
+ base::FeatureList::OVERRIDE_DISABLE_FEATURE);
+
+ // protect-sync-credential
+ // * default = off
+ // * Field trial name = "AutofillSyncCredential"
+ // - group "DisallowSyncCredentials" turns the feature on.
+ // - other groups turn the feature off.
+ RegisterFieldTrialOverrideByGroup(
+ feature_list, password_manager::features::kProtectSyncCredential,
+ "AutofillSyncCredential", "DisallowSyncCredentials",
+ base::FeatureList::OVERRIDE_ENABLE_FEATURE);
+
+ // protect-sync-credential-on-reauth
+ // * default = off
+ // * Field trial name = "AutofillSyncCredential"
+ // - groups "DisallowSyncCredentials" and "DisallowSyncCredentialsForReauth"
+ // turn the feature on.
+ // - other groups turn the feature off.
+ RegisterFieldTrialOverrideByGroup(
+ feature_list, password_manager::features::kProtectSyncCredentialOnReauth,
+ "AutofillSyncCredential", "DisallowSyncCredentials",
+ base::FeatureList::OVERRIDE_ENABLE_FEATURE);
+
+ RegisterFieldTrialOverrideByGroup(
+ feature_list, password_manager::features::kProtectSyncCredentialOnReauth,
+ "AutofillSyncCredential", "DisallowSyncCredentialsForReauth",
+ base::FeatureList::OVERRIDE_ENABLE_FEATURE);
+}
+
} // namespace password_manager_util

Powered by Google App Engine
This is Rietveld 408576698