Commit a4b285eb authored by engedy's avatar engedy Committed by Commit bot

Add flag to enable/disable affiliaton based matching.

BUG=437865

Review URL: https://codereview.chromium.org/898553002

Cr-Commit-Position: refs/heads/master@{#314545}
parent b5cf67f5
...@@ -6300,6 +6300,12 @@ Keep your key file in a safe place. You will need it to create new versions of y ...@@ -6300,6 +6300,12 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_FLAGS_ENABLE_SAVE_PASSOWRD_ON_IN_PAGE_NAVIGATION_DESCRIPTION" desc="Description of the flag to enable showing of password save prompt on in-page navigations"> <message name="IDS_FLAGS_ENABLE_SAVE_PASSOWRD_ON_IN_PAGE_NAVIGATION_DESCRIPTION" desc="Description of the flag to enable showing of password save prompt on in-page navigations">
Enable showing of the password prompt on in-page navigations. This allows for saving passwords on more pages but might sometimes trigger the prompt on unsuccessful login attempts. Enable showing of the password prompt on in-page navigations. This allows for saving passwords on more pages but might sometimes trigger the prompt on unsuccessful login attempts.
</message> </message>
<message name="IDS_FLAGS_ENABLE_AFFILIATION_BASED_MATCHING_NAME" desc="Name of the flag to enable affiliation based matching, so that credentials stored for an Android application will also be considered matches for, and be filled into corresponding websites (so-called 'affiliated' websites).">
Enable affiliation based matching in password manager.
</message>
<message name="IDS_FLAGS_ENABLE_AFFILIATION_BASED_MATCHING_DESCRIPTION" desc="Description of the flag to enable affiliation based matching, so that credentials stored for an Android application will also be considered matches for, and be filled into corresponding websites (so-called 'affiliated' websites).">
Allow credentials stored for Android applications to be filled into corresponding websites.
</message>
<message name="IDS_FLAGS_AUTOFILL_SYNC_CREDENTIAL_NAME" desc="Name of the flag specifying how the browser will handle autofilling the users sync credential."> <message name="IDS_FLAGS_AUTOFILL_SYNC_CREDENTIAL_NAME" desc="Name of the flag specifying how the browser will handle autofilling the users sync credential.">
Autofill sync credential Autofill sync credential
</message> </message>
......
...@@ -1037,6 +1037,15 @@ const Experiment kExperiments[] = { ...@@ -1037,6 +1037,15 @@ const Experiment kExperiments[] = {
SINGLE_VALUE_TYPE( SINGLE_VALUE_TYPE(
autofill::switches::kEnablePasswordSaveOnInPageNavigation) autofill::switches::kEnablePasswordSaveOnInPageNavigation)
}, },
{
"enable-affiliation-based-matching",
IDS_FLAGS_ENABLE_AFFILIATION_BASED_MATCHING_NAME,
IDS_FLAGS_ENABLE_AFFILIATION_BASED_MATCHING_DESCRIPTION,
kOsWin | kOsLinux | kOsCrOS | kOsMac | kOsAndroid,
ENABLE_DISABLE_VALUE_TYPE(
password_manager::switches::kEnableAffiliationBasedMatching,
password_manager::switches::kDisableAffiliationBasedMatching)
},
{ {
"enable-deferred-image-decoding", "enable-deferred-image-decoding",
IDS_FLAGS_ENABLE_DEFERRED_IMAGE_DECODING_NAME, IDS_FLAGS_ENABLE_DEFERRED_IMAGE_DECODING_NAME,
......
...@@ -8,8 +8,11 @@ ...@@ -8,8 +8,11 @@
#include <ostream> #include <ostream>
#include "base/base64.h" #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_piece.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "components/password_manager/core/common/password_manager_switches.h"
#include "net/base/escape.h" #include "net/base/escape.h"
#include "url/third_party/mozilla/url_parse.h" #include "url/third_party/mozilla/url_parse.h"
#include "url/url_canon_stdstring.h" #include "url/url_canon_stdstring.h"
...@@ -285,4 +288,17 @@ bool AreEquivalenceClassesEqual(const AffiliatedFacets& a, ...@@ -285,4 +288,17 @@ bool AreEquivalenceClassesEqual(const AffiliatedFacets& a,
return std::equal(a_sorted.begin(), a_sorted.end(), b_sorted.begin()); 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
// 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 } // namespace password_manager
...@@ -53,6 +53,10 @@ ...@@ -53,6 +53,10 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "url/url_parse.h" #include "url/url_parse.h"
namespace base {
class CommandLine;
} // namespace base
namespace password_manager { namespace password_manager {
// Encapsulates a facet URI in canonical form. // Encapsulates a facet URI in canonical form.
...@@ -161,6 +165,11 @@ struct AffiliatedFacetsWithUpdateTime { ...@@ -161,6 +165,11 @@ struct AffiliatedFacetsWithUpdateTime {
bool AreEquivalenceClassesEqual(const AffiliatedFacets& a, bool AreEquivalenceClassesEqual(const AffiliatedFacets& a,
const AffiliatedFacets& b); const AffiliatedFacets& b);
// Returns whether or not affiliation based matching is enabled, either via
// command line flags or field trials. The command line flag, if present, always
// takes precedence.
bool IsAffiliationBasedMatchingEnabled(const base::CommandLine& command_line);
// For logging use only. // For logging use only.
std::ostream& operator<<(std::ostream& os, const FacetURI& facet_uri); std::ostream& operator<<(std::ostream& os, const FacetURI& facet_uri);
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
#include "components/password_manager/core/browser/affiliation_utils.h" #include "components/password_manager/core/browser/affiliation_utils.h"
#include "base/command_line.h"
#include "base/metrics/field_trial.h"
#include "components/password_manager/core/common/password_manager_switches.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "url/url_constants.h" #include "url/url_constants.h"
...@@ -192,4 +195,44 @@ TEST(AffiliationUtilsTest, NotEqualEquivalenceClasses) { ...@@ -192,4 +195,44 @@ TEST(AffiliationUtilsTest, NotEqualEquivalenceClasses) {
EXPECT_FALSE(AreEquivalenceClassesEqual(c, b)); EXPECT_FALSE(AreEquivalenceClassesEqual(c, b));
} }
TEST(AffiliationUtilsTest, IsAffiliationBasedMatchingEnabled) {
const char kFieldTrialName[] = "AffiliationBasedMatching";
struct {
const char* field_trial_group;
const char* command_line_switch;
bool expected_enabled;
} kTestCases[] = {
{"", "", false},
{"", switches::kEnableAffiliationBasedMatching, true},
{"", switches::kDisableAffiliationBasedMatching, false},
{"garbage value", "", false},
{"disabled", "", false},
{"disabled2", "", false},
{"Disabled", "", false},
{"Disabled", switches::kDisableAffiliationBasedMatching, false},
{"Disabled", switches::kEnableAffiliationBasedMatching, true},
{"enabled", "", true},
{"enabled2", "", true},
{"Enabled", "", true},
{"Enabled", switches::kDisableAffiliationBasedMatching, false},
{"Enabled", switches::kEnableAffiliationBasedMatching, true}};
for (const auto& test_case : kTestCases) {
SCOPED_TRACE(testing::Message("Command line = ")
<< test_case.command_line_switch);
SCOPED_TRACE(testing::Message("Group name = ")
<< test_case.field_trial_group);
base::FieldTrialList field_trials(NULL);
base::FieldTrialList::CreateFieldTrial(kFieldTrialName,
test_case.field_trial_group);
base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
command_line.AppendSwitch(test_case.command_line_switch);
EXPECT_EQ(test_case.expected_enabled,
IsAffiliationBasedMatchingEnabled(command_line));
}
}
} // namespace password_manager } // namespace password_manager
...@@ -11,6 +11,12 @@ namespace switches { ...@@ -11,6 +11,12 @@ namespace switches {
// Force the password manager to allow sync credentials to be autofilled. // Force the password manager to allow sync credentials to be autofilled.
const char kAllowAutofillSyncCredential[] = "allow-autofill-sync-credential"; const char kAllowAutofillSyncCredential[] = "allow-autofill-sync-credential";
// Disable affiliation based matching, so that credentials stored for an Android
// application will not be considered matches for, and will not be filled into
// corresponding Web applications.
const char kDisableAffiliationBasedMatching[] =
"disable-affiliation-based-matching";
// Disable dropping the credential used to sync passwords. // Disable dropping the credential used to sync passwords.
const char kDisableDropSyncCredential[] = "disable-drop-sync-credential"; const char kDisableDropSyncCredential[] = "disable-drop-sync-credential";
...@@ -30,6 +36,12 @@ const char kDisallowAutofillSyncCredential[] = ...@@ -30,6 +36,12 @@ const char kDisallowAutofillSyncCredential[] =
const char kDisallowAutofillSyncCredentialForReauth[] = const char kDisallowAutofillSyncCredentialForReauth[] =
"disallow-autofill-sync-credential-for-reauth"; "disallow-autofill-sync-credential-for-reauth";
// Enable affiliation based matching, so that credentials stored for an Android
// application will also be considered matches for, and be filled into
// corresponding Web applications.
const char kEnableAffiliationBasedMatching[] =
"enable-affiliation-based-matching";
// Disables the save-password prompt. Passwords are then saved automatically, // Disables the save-password prompt. Passwords are then saved automatically,
// without asking the user. // without asking the user.
const char kEnableAutomaticPasswordSaving[] = const char kEnableAutomaticPasswordSaving[] =
......
...@@ -13,11 +13,13 @@ namespace switches { ...@@ -13,11 +13,13 @@ namespace switches {
// alongside the definition of their values in the .cc file. // alongside the definition of their values in the .cc file.
extern const char kAllowAutofillSyncCredential[]; extern const char kAllowAutofillSyncCredential[];
extern const char kDisableAffiliationBasedMatching[];
extern const char kDisableDropSyncCredential[]; extern const char kDisableDropSyncCredential[];
extern const char kDisableManagerForSyncSignin[]; extern const char kDisableManagerForSyncSignin[];
extern const char kDisablePasswordLink[]; extern const char kDisablePasswordLink[];
extern const char kDisallowAutofillSyncCredential[]; extern const char kDisallowAutofillSyncCredential[];
extern const char kDisallowAutofillSyncCredentialForReauth[]; extern const char kDisallowAutofillSyncCredentialForReauth[];
extern const char kEnableAffiliationBasedMatching[];
extern const char kEnableAutomaticPasswordSaving[]; extern const char kEnableAutomaticPasswordSaving[];
extern const char kEnableDropSyncCredential[]; extern const char kEnableDropSyncCredential[];
extern const char kEnableManagerForSyncSignin[]; extern const char kEnableManagerForSyncSignin[];
......
...@@ -50872,6 +50872,7 @@ To add a new entry, add it with any value and run test to compute valid value. ...@@ -50872,6 +50872,7 @@ To add a new entry, add it with any value and run test to compute valid value.
<int value="-158549277" label="enable-embeddedsearch-api"/> <int value="-158549277" label="enable-embeddedsearch-api"/>
<int value="-158197254" label="enable-credential-manager-api"/> <int value="-158197254" label="enable-credential-manager-api"/>
<int value="-147283486" label="enable-network-portal-notification"/> <int value="-147283486" label="enable-network-portal-notification"/>
<int value="-146552997" label="enable-affiliation-based-matching"/>
<int value="-102537270" label="extension-content-verification"/> <int value="-102537270" label="extension-content-verification"/>
<int value="-99781021" label="disable-roboto-font-ui"/> <int value="-99781021" label="disable-roboto-font-ui"/>
<int value="-88822940" label="ssl-version-min"/> <int value="-88822940" label="ssl-version-min"/>
...@@ -50889,6 +50890,7 @@ To add a new entry, add it with any value and run test to compute valid value. ...@@ -50889,6 +50890,7 @@ To add a new entry, add it with any value and run test to compute valid value.
Command-line flag doesn't start with two dashes. Command-line flag doesn't start with two dashes.
</int> </int>
<int value="27507364" label="apps-keep-chrome-alive"/> <int value="27507364" label="apps-keep-chrome-alive"/>
<int value="37024318" label="disable-affiliation-based-matching"/>
<int value="48159177" label="reduced-referrer-granularity"/> <int value="48159177" label="reduced-referrer-granularity"/>
<int value="61205887" label="enable-text-input-focus-manager"/> <int value="61205887" label="enable-text-input-focus-manager"/>
<int value="79503461" label="disable-account-consistency"/> <int value="79503461" label="disable-account-consistency"/>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment