Commit 93c3b06a authored by Renato Silva's avatar Renato Silva Committed by Commit Bot

Move PIN auto submit feature flag into chromeos

PIN auto submit is only available on Chrome OS and the feature
should be in the chromeos namespace.

Bug: 1075994
Change-Id: Idd199abb2baf6ac88d10762e22735fe42d46e656
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2362965
Commit-Queue: Renato Silva <rrsilva@google.com>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799851}
parent dd3e9b01
......@@ -36,6 +36,7 @@
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "chromeos/constants/chromeos_features.h"
#include "chromeos/cryptohome/mock_homedir_methods.h"
#include "chromeos/cryptohome/system_salt_getter.h"
#include "chromeos/dbus/cryptohome/fake_cryptohome_client.h"
......@@ -165,8 +166,8 @@ class QuickUnlockPrivateUnitTest
void SetUp() override {
// Enable/disable PIN auto submit
auto param = GetParam();
feature_list_.InitWithFeatureState(features::kQuickUnlockPinAutosubmit,
std::get<1>(param));
feature_list_.InitWithFeatureState(
features::kQuickUnlockPinAutosubmit, std::get<1>(param));
CryptohomeClient::InitializeFake();
if (std::get<0>(param) == TestType::kCryptohome) {
......@@ -1062,7 +1063,8 @@ TEST_P(QuickUnlockPrivateUnitTest, PinAutosubmitClearLengthOnUiUpdate) {
// Checks that the feature flag correctly prevents all actions.
TEST_P(QuickUnlockPrivateUnitTest, PinAutosubmitFeatureGuard) {
const bool feature_enabled = IsAutosubmitFeatureEnabled();
EXPECT_EQ(quick_unlock::IsPinAutosubmitFeatureEnabled(), feature_enabled);
EXPECT_EQ(features::IsPinAutosubmitFeatureEnabled(),
feature_enabled);
}
// Tests that the backfill operation sets a user value for the auto submit pref
......
......@@ -18,6 +18,7 @@
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "chromeos/constants/chromeos_features.h"
#include "components/account_id/account_id.h"
#include "components/keep_alive_registry/keep_alive_types.h"
#include "components/keep_alive_registry/scoped_keep_alive.h"
......@@ -209,7 +210,7 @@ void PinBackend::SetPinAutoSubmitEnabled(const AccountId& account_id,
BoolCallback did_set) {
// Immediate false if the PIN length isn't supported, or when the feature
// isdisabled.
if (!IsPinAutosubmitFeatureEnabled() ||
if (!features::IsPinAutosubmitFeatureEnabled() ||
pin.length() > kPinAutosubmitMaxPinLength) {
PostResponse(std::move(did_set), false);
return;
......@@ -335,7 +336,7 @@ bool PinBackend::ShouldUseCryptohome(const AccountId& account_id) {
}
int PinBackend::GetExposedPinLength(const AccountId& account_id) {
if (!IsPinAutosubmitFeatureEnabled()) {
if (!features::IsPinAutosubmitFeatureEnabled()) {
// Clear the exposed length if the feature was disabled.
user_manager::known_user::SetUserPinLength(account_id, 0);
return 0;
......@@ -404,7 +405,7 @@ PrefService* PinBackend::PrefService(const AccountId& account_id) {
void PinBackend::UpdatePinAutosubmitOnSet(const AccountId& account_id,
size_t pin_length) {
if (!IsPinAutosubmitFeatureEnabled())
if (!features::IsPinAutosubmitFeatureEnabled())
return;
// A PIN is being set when the auto submit feature is present. This user
......@@ -429,7 +430,7 @@ void PinBackend::UpdatePinAutosubmitOnSet(const AccountId& account_id,
}
void PinBackend::UpdatePinAutosubmitOnRemove(const AccountId& account_id) {
if (!IsPinAutosubmitFeatureEnabled())
if (!features::IsPinAutosubmitFeatureEnabled())
return;
user_manager::known_user::SetUserPinLength(account_id, 0);
PrefService(account_id)->ClearPref(prefs::kPinUnlockAutosubmitEnabled);
......@@ -438,7 +439,7 @@ void PinBackend::UpdatePinAutosubmitOnRemove(const AccountId& account_id) {
void PinBackend::UpdatePinAutosubmitOnSuccessfulTryAuth(
const AccountId& account_id,
size_t pin_length) {
if (!IsPinAutosubmitFeatureEnabled())
if (!features::IsPinAutosubmitFeatureEnabled())
return;
// Backfill the auto submit preference if the PIN that was authenticated was
......@@ -454,8 +455,8 @@ void PinBackend::UpdatePinAutosubmitOnSuccessfulTryAuth(
void PinBackend::PinAutosubmitBackfill(const AccountId& account_id,
size_t pin_length) {
if (!IsPinAutosubmitBackfillFeatureEnabled() ||
!IsPinAutosubmitFeatureEnabled()) {
if (!features::IsPinAutosubmitBackfillFeatureEnabled() ||
!features::IsPinAutosubmitFeatureEnabled()) {
return;
}
......
......@@ -16,6 +16,7 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chromeos/constants/chromeos_features.h"
#include "chromeos/constants/chromeos_switches.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
......@@ -87,8 +88,9 @@ void RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(prefs::kPinUnlockWeakPinsAllowed, true);
// Register as true by default only when the feature is enabled.
registry->RegisterBooleanPref(prefs::kPinUnlockAutosubmitEnabled,
IsPinAutosubmitFeatureEnabled());
registry->RegisterBooleanPref(
prefs::kPinUnlockAutosubmitEnabled,
features::IsPinAutosubmitFeatureEnabled());
}
bool IsPinDisabledByPolicy(PrefService* pref_service) {
......@@ -157,22 +159,13 @@ bool IsFingerprintEnabled(Profile* profile) {
return false;
// Enable fingerprint unlock only if the switch is present.
return base::FeatureList::IsEnabled(features::kQuickUnlockFingerprint);
return base::FeatureList::IsEnabled(::features::kQuickUnlockFingerprint);
}
void EnabledForTesting(bool state) {
enable_for_testing_ = state;
}
bool IsPinAutosubmitFeatureEnabled() {
return base::FeatureList::IsEnabled(features::kQuickUnlockPinAutosubmit);
}
bool IsPinAutosubmitBackfillFeatureEnabled() {
return base::FeatureList::IsEnabled(
features::kQuickUnlockPinAutosubmitBackfill);
}
void DisablePinByPolicyForTesting(bool disable) {
disable_pin_by_policy_for_testing_ = disable;
}
......
......@@ -62,10 +62,6 @@ void EnabledForTesting(bool state);
// Returns true if EnableForTesting() was previously called.
bool IsEnabledForTesting();
// Feature flag for PIN auto submit.
bool IsPinAutosubmitFeatureEnabled();
bool IsPinAutosubmitBackfillFeatureEnabled();
// Forcibly disable PIN for testing purposes.
void DisablePinByPolicyForTesting(bool disable);
......
......@@ -460,9 +460,8 @@ void AddLockScreenPageStrings(content::WebUIDataSource* html_source,
html_source->AddBoolean("quickUnlockEnabled",
chromeos::quick_unlock::IsPinEnabled(pref_service));
html_source->AddBoolean(
"quickUnlockPinAutosubmitFeatureEnabled",
chromeos::quick_unlock::IsPinAutosubmitFeatureEnabled());
html_source->AddBoolean("quickUnlockPinAutosubmitFeatureEnabled",
chromeos::features::IsPinAutosubmitFeatureEnabled());
html_source->AddBoolean(
"quickUnlockDisabledByPolicy",
chromeos::quick_unlock::IsPinDisabledByPolicy(pref_service));
......
......@@ -626,16 +626,6 @@ const base::Feature kPushMessagingBackgroundMode{
// Enables or disables fingerprint quick unlock.
const base::Feature kQuickUnlockFingerprint{"QuickUnlockFingerprint",
base::FEATURE_DISABLED_BY_DEFAULT};
// Controls whether the PIN auto submit feature is enabled.
const base::Feature kQuickUnlockPinAutosubmit{
"QuickUnlockPinAutosubmit", base::FEATURE_DISABLED_BY_DEFAULT};
// TODO(crbug.com/1104164) - Remove this once most
// users have their preferences backfilled.
// Controls whether the PIN auto submit backfill operation should be performed.
const base::Feature kQuickUnlockPinAutosubmitBackfill{
"QuickUnlockPinAutosubmitBackfill", base::FEATURE_ENABLED_BY_DEFAULT};
#endif
// Enables using quiet prompts for notification permission requests.
......
......@@ -411,14 +411,6 @@ extern const base::Feature kPushMessagingBackgroundMode;
#if defined(OS_CHROMEOS)
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kQuickUnlockFingerprint;
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kQuickUnlockPinAutosubmit;
// TODO(crbug.com/1104164) - Remove this once most
// users have their preferences backfilled.
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kQuickUnlockPinAutosubmitBackfill;
#endif
COMPONENT_EXPORT(CHROME_FEATURES)
......
......@@ -1118,7 +1118,7 @@ var OSSettingsPeoplePageLockScreenTest = class extends OSSettingsBrowserTest {
/** @override */
get featureList() {
return {enabled: ['features::kQuickUnlockPinAutosubmit']};
return {enabled: ['chromeos::features::kQuickUnlockPinAutosubmit']};
}
/** @override */
......@@ -1199,7 +1199,7 @@ var OSSettingsPeoplePagePinAutosubmitDialogTest =
/** @override */
get featureList() {
return {enabled: ['features::kQuickUnlockPinAutosubmit']};
return {enabled: ['chromeos::features::kQuickUnlockPinAutosubmit']};
}
/** @override */
......
......@@ -398,6 +398,16 @@ const base::Feature kQuickAnswersSubToggle{"QuickAnswersSubToggle",
const base::Feature kQuickAnswersTranslation{"QuickAnswersTranslation",
base::FEATURE_DISABLED_BY_DEFAULT};
// Controls whether the PIN auto submit feature is enabled.
const base::Feature kQuickUnlockPinAutosubmit{
"QuickUnlockPinAutosubmit", base::FEATURE_DISABLED_BY_DEFAULT};
// TODO(crbug.com/1104164) - Remove this once most
// users have their preferences backfilled.
// Controls whether the PIN auto submit backfill operation should be performed.
const base::Feature kQuickUnlockPinAutosubmitBackfill{
"QuickUnlockPinAutosubmitBackfill", base::FEATURE_ENABLED_BY_DEFAULT};
// Enables or disables Release Notes on Chrome OS.
const base::Feature kReleaseNotes{"ReleaseNotes",
base::FEATURE_ENABLED_BY_DEFAULT};
......@@ -592,6 +602,14 @@ bool IsPhoneHubEnabled() {
return base::FeatureList::IsEnabled(kPhoneHub);
}
bool IsPinAutosubmitFeatureEnabled() {
return base::FeatureList::IsEnabled(kQuickUnlockPinAutosubmit);
}
bool IsPinAutosubmitBackfillFeatureEnabled() {
return base::FeatureList::IsEnabled(kQuickUnlockPinAutosubmitBackfill);
}
bool IsQuickAnswersDogfood() {
return base::FeatureList::IsEnabled(kQuickAnswersDogfood);
}
......
......@@ -174,6 +174,12 @@ extern const base::Feature kQuickAnswersSubToggle;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kQuickAnswersTranslation;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kQuickUnlockPinAutosubmit;
// TODO(crbug.com/1104164) - Remove this once most
// users have their preferences backfilled.
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kQuickUnlockPinAutosubmitBackfill;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kReleaseNotes;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kReleaseNotesNotification;
......@@ -248,6 +254,9 @@ COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsClipboardHistoryEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsOobeScreensPriorityEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsParentalControlsSettingsEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsPhoneHubEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsPinAutosubmitFeatureEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
bool IsPinAutosubmitBackfillFeatureEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsQuickAnswersDogfood();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsQuickAnswersEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsQuickAnswersRichUiEnabled();
......
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