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

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: 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..b97dddfad18386073e1e83134a7ba1fe17a84b2c 100644
--- a/components/password_manager/core/browser/password_manager_util.cc
+++ b/components/password_manager/core/browser/password_manager_util.cc
@@ -6,12 +6,50 @@
#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);
+ }
+}
+
+void RegisterFieldTrialOverrideByVariationParam(
+ base::FeatureList* feature_list,
+ const base::Feature& feature,
+ const char* trial_name,
+ const char* variation_param_value,
+ const base::FeatureList::OverrideState& override_state) {
+ base::FieldTrial* field_trial = base::FieldTrialList::Find(trial_name);
+ const std::string update_enabled =
+ variations::GetVariationParamValue(trial_name, variation_param_value);
+ 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
+ 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 +129,59 @@ bool IsLoggingActive(const password_manager::PasswordManagerClient* client) {
return log_manager && log_manager->IsLoggingActive();
}
+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
+ // affiliation-based-matching:
+ // * default = on
+ // * Field trial name = "AffiliationBasedMatching"
+ // - groups starting with "Disabled" turns the feature off.
+ // - 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.
+ // the feature off.
+ // - other groups turn the feature on.
+ RegisterFieldTrialOverrideByGroup(
+ feature_list, password_manager::features::kAffiliationBasedMatching,
+ "AffiliationBasedMatching", "Disabled",
+ base::FeatureList::OVERRIDE_DISABLE_FEATURE);
+
+ 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.
+ feature_list, password_manager::features::kAffiliationBasedMatching,
+ "AffiliationBasedMatching", "propagate_password_changes_to_web",
+ base::FeatureList::OVERRIDE_DISABLE_FEATURE);
+
+ // 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", "Disabled",
+ 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