Index: components/password_manager/core/browser/affiliation_utils.cc |
diff --git a/components/password_manager/core/browser/affiliation_utils.cc b/components/password_manager/core/browser/affiliation_utils.cc |
index 23de0888f10eb74166816650c07644adf92f40bc..4f57b861b7d682e188ca10c34974e806a6dfd044 100644 |
--- a/components/password_manager/core/browser/affiliation_utils.cc |
+++ b/components/password_manager/core/browser/affiliation_utils.cc |
@@ -8,8 +8,11 @@ |
#include <ostream> |
#include "base/base64.h" |
+#include "base/command_line.h" |
+#include "base/metrics/field_trial.h" |
#include "base/strings/string_piece.h" |
#include "base/strings/string_util.h" |
+#include "components/password_manager/core/common/password_manager_switches.h" |
#include "net/base/escape.h" |
#include "url/third_party/mozilla/url_parse.h" |
#include "url/url_canon_stdstring.h" |
@@ -285,4 +288,17 @@ bool AreEquivalenceClassesEqual(const AffiliatedFacets& a, |
return std::equal(a_sorted.begin(), a_sorted.end(), b_sorted.begin()); |
} |
+bool IsAffiliationBasedMatchingEnabled(const base::CommandLine& command_line) { |
+ // Note: It is important to always query the field trial state, to ensure that |
vabr (Chromium)
2015/02/04 11:04:06
This is much clearer now!
|
+ // UMA reports the correct group. |
+ const std::string group_name = |
+ base::FieldTrialList::FindFullName("AffiliationBasedMatching"); |
+ |
+ if (command_line.HasSwitch(switches::kDisableAffiliationBasedMatching)) |
+ return false; |
+ if (command_line.HasSwitch(switches::kEnableAffiliationBasedMatching)) |
+ return true; |
+ return StartsWithASCII(group_name, "Enabled", /*case_sensitive=*/false); |
+} |
+ |
} // namespace password_manager |