Commit f9eeec11 authored by jdufault's avatar jdufault Committed by Commit bot

Enable PIN configuration settings.

BUG=603217
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:closure_compilation;master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2150763002
Cr-Commit-Position: refs/heads/master@{#407296}
parent c253d05a
...@@ -1386,6 +1386,12 @@ Press any key to continue exploring. ...@@ -1386,6 +1386,12 @@ Press any key to continue exploring.
<message name="IDS_FLAGS_FULLSCREEN_APP_LIST_DESCRIPTION" desc="Description for the flag to enable experimental fullscreen app list."> <message name="IDS_FLAGS_FULLSCREEN_APP_LIST_DESCRIPTION" desc="Description for the flag to enable experimental fullscreen app list.">
The app-list will appear as fullscreen mode when it's in touch view mode. This flag does nothing outside of the mode. The app-list will appear as fullscreen mode when it's in touch view mode. This flag does nothing outside of the mode.
</message> </message>
<message name="IDS_FLAGS_QUICK_UNLOCK_PIN" desc="Title of the flag used to enable quick unlock pin.">
Quick Unlock (PIN)
</message>
<message name="IDS_FLAGS_QUICK_UNLOCK_PIN_DESCRIPTION" desc="Description of the flag used to enable quick unlock pin.">
Enabling PIN quick unlock allows you to use a PIN to unlock your Chromebook on the lock screen after you have signed into your device.
</message>
<message name="IDS_FLAGS_STORAGE_MANAGER_NAME" desc="Description for the flag to enable experimental storage manager."> <message name="IDS_FLAGS_STORAGE_MANAGER_NAME" desc="Description for the flag to enable experimental storage manager.">
Storage manager Storage manager
</message> </message>
......
...@@ -2015,6 +2015,9 @@ const FeatureEntry kFeatureEntries[] = { ...@@ -2015,6 +2015,9 @@ const FeatureEntry kFeatureEntries[] = {
IDS_FLAGS_FILES_QUICK_VIEW_DESCRIPTION, kOsCrOS, IDS_FLAGS_FILES_QUICK_VIEW_DESCRIPTION, kOsCrOS,
ENABLE_DISABLE_VALUE_TYPE(chromeos::switches::kEnableFilesQuickView, ENABLE_DISABLE_VALUE_TYPE(chromeos::switches::kEnableFilesQuickView,
chromeos::switches::kDisableFilesQuickView)}, chromeos::switches::kDisableFilesQuickView)},
{"quick-unlock-pin", IDS_FLAGS_QUICK_UNLOCK_PIN,
IDS_FLAGS_QUICK_UNLOCK_PIN_DESCRIPTION, kOsCrOS,
FEATURE_VALUE_TYPE(features::kQuickUnlockPin)},
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
{"multi-instance-merge-tabs", IDS_FLAGS_MULTI_INSTANCE_MERGE_TABS_NAME, {"multi-instance-merge-tabs", IDS_FLAGS_MULTI_INSTANCE_MERGE_TABS_NAME,
......
...@@ -7,10 +7,10 @@ ...@@ -7,10 +7,10 @@
#include "chrome/browser/chromeos/extensions/quick_unlock_private/quick_unlock_private_api.h" #include "chrome/browser/chromeos/extensions/quick_unlock_private/quick_unlock_private_api.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "chrome/browser/chromeos/login/quick_unlock/pin_storage.h" #include "chrome/browser/chromeos/login/quick_unlock/pin_storage.h"
#include "chrome/browser/chromeos/login/quick_unlock/pin_storage_factory.h" #include "chrome/browser/chromeos/login/quick_unlock/pin_storage_factory.h"
#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h"
#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
#include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
#include "chrome/browser/extensions/extension_api_unittest.h" #include "chrome/browser/extensions/extension_api_unittest.h"
...@@ -62,6 +62,8 @@ class QuickUnlockPrivateUnitTest : public ExtensionApiUnittest { ...@@ -62,6 +62,8 @@ class QuickUnlockPrivateUnitTest : public ExtensionApiUnittest {
void SetUp() override { void SetUp() override {
ExtensionApiUnittest::SetUp(); ExtensionApiUnittest::SetUp();
EnableQuickUnlockForTesting();
// Setup a primary user. // Setup a primary user.
auto test_account = AccountId::FromUserEmail(kTestUserEmail); auto test_account = AccountId::FromUserEmail(kTestUserEmail);
fake_user_manager_->AddUser(test_account); fake_user_manager_->AddUser(test_account);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/base64.h" #include "base/base64.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chromeos/login/auth/key.h" #include "chromeos/login/auth/key.h"
#include "components/pref_registry/pref_registry_syncable.h" #include "components/pref_registry/pref_registry_syncable.h"
...@@ -104,8 +105,13 @@ std::string PinStorage::PinSecret() const { ...@@ -104,8 +105,13 @@ std::string PinStorage::PinSecret() const {
} }
bool PinStorage::IsPinAuthenticationAvailable() const { bool PinStorage::IsPinAuthenticationAvailable() const {
return IsPinSet() && unlock_attempt_count() < kMaximumUnlockAttempts && const bool exceeded_unlock_attempts =
HasStrongAuth() && TimeSinceLastStrongAuth() < kStrongAuthTimeout; unlock_attempt_count() >= kMaximumUnlockAttempts;
const bool has_strong_auth =
HasStrongAuth() && TimeSinceLastStrongAuth() < kStrongAuthTimeout;
return IsQuickUnlockEnabled() && IsPinSet() && has_strong_auth &&
!exceeded_unlock_attempts;
} }
bool PinStorage::TryAuthenticatePin(const std::string& pin) { bool PinStorage::TryAuthenticatePin(const std::string& pin) {
......
...@@ -21,11 +21,6 @@ class PinStorageTestApi; ...@@ -21,11 +21,6 @@ class PinStorageTestApi;
namespace chromeos { namespace chromeos {
// TODO(jdufault): Figure out the UX we want on the lock screen when there are
// multiple users. We will be storing either global or per-user unlock state. If
// we end up storing global unlock state, we can pull the unlock attempt and
// strong-auth code out of this class.
class PinStorage : public KeyedService { class PinStorage : public KeyedService {
public: public:
// TODO(jdufault): Pull these values in from policy. See crbug.com/612271. // TODO(jdufault): Pull these values in from policy. See crbug.com/612271.
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "chrome/browser/chromeos/login/quick_unlock/pin_storage.h" #include "chrome/browser/chromeos/login/quick_unlock/pin_storage.h"
#include "chrome/browser/chromeos/login/quick_unlock/pin_storage_factory.h" #include "chrome/browser/chromeos/login/quick_unlock/pin_storage_factory.h"
#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
...@@ -15,6 +15,10 @@ namespace { ...@@ -15,6 +15,10 @@ namespace {
class PinStorageUnitTest : public testing::Test { class PinStorageUnitTest : public testing::Test {
protected: protected:
PinStorageUnitTest() : profile_(new TestingProfile()) {} PinStorageUnitTest() : profile_(new TestingProfile()) {}
~PinStorageUnitTest() override {}
// testing::Test:
void SetUp() override { chromeos::EnableQuickUnlockForTesting(); }
std::unique_ptr<TestingProfile> profile_; std::unique_ptr<TestingProfile> profile_;
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h"
#include "base/feature_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/common/chrome_features.h"
namespace chromeos {
namespace {
bool enable_for_testing_ = false;
} // namespace
bool IsQuickUnlockEnabled() {
if (enable_for_testing_)
return true;
// TODO(jdufault): Implement a proper policy check. For now, just disable if
// the device is enterprise enrolled. See crbug.com/612271.
if (g_browser_process->platform_part()
->browser_policy_connector_chromeos()
->IsEnterpriseManaged()) {
return false;
}
// Enable quick unlock only if the switch is present.
return base::FeatureList::IsEnabled(features::kQuickUnlockPin);
}
void EnableQuickUnlockForTesting() {
enable_for_testing_ = true;
}
} // namespace chromeos
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_QUICK_UNLOCK_UTILS_H_
#define CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_QUICK_UNLOCK_UTILS_H_
namespace chromeos {
// Returns true if quick unlock is allowed by policy and the feature flag is
// present.
bool IsQuickUnlockEnabled();
// Forcibly enable quick-unlock for testing.
void EnableQuickUnlockForTesting();
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_QUICK_UNLOCK_UTILS_H_
...@@ -163,7 +163,7 @@ ...@@ -163,7 +163,7 @@
<!-- TODO(jdufault): Disable navigating to /quickUnlock/* if pin is <!-- TODO(jdufault): Disable navigating to /quickUnlock/* if pin is
disabled. --> disabled. -->
<template is="dom-if" if=[[quickUnlockAllowed_]]> <template is="dom-if" if=[[quickUnlockEnabled_]]>
<div class="settings-box"> <div class="settings-box">
<paper-button on-tap="onQuickUnlockTap_" class="primary-button"> <paper-button on-tap="onQuickUnlockTap_" class="primary-button">
$i18n{quickUnlockTitle} $i18n{quickUnlockTitle}
......
...@@ -64,10 +64,11 @@ Polymer({ ...@@ -64,10 +64,11 @@ Polymer({
* True if quick unlock settings should be displayed on this machine. * True if quick unlock settings should be displayed on this machine.
* @private * @private
*/ */
quickUnlockAllowed_: { quickUnlockEnabled_: {
type: Boolean, type: Boolean,
// TODO(jdufault): Get a real value via quickUnlockPrivate API. value: function() {
value: false, return loadTimeData.getBoolean('quickUnlockEnabled');
},
readOnly: true, readOnly: true,
}, },
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "grit/settings_resources_map.h" #include "grit/settings_resources_map.h"
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h"
#include "chrome/browser/ui/webui/settings/chromeos/change_picture_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/change_picture_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.h"
...@@ -104,6 +105,9 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui, const GURL& url) ...@@ -104,6 +105,9 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui, const GURL& url)
profile); profile);
if (easy_unlock_handler) if (easy_unlock_handler)
AddSettingsPageUIHandler(easy_unlock_handler); AddSettingsPageUIHandler(easy_unlock_handler);
html_source->AddBoolean("quickUnlockEnabled",
chromeos::IsQuickUnlockEnabled());
#endif #endif
AddSettingsPageUIHandler(AboutHandler::Create(html_source, profile)); AddSettingsPageUIHandler(AboutHandler::Create(html_source, profile));
......
...@@ -513,12 +513,14 @@ ...@@ -513,12 +513,14 @@
'browser/chromeos/login/proxy_settings_dialog.h', 'browser/chromeos/login/proxy_settings_dialog.h',
'browser/chromeos/login/reauth_stats.cc', 'browser/chromeos/login/reauth_stats.cc',
'browser/chromeos/login/reauth_stats.h', 'browser/chromeos/login/reauth_stats.h',
'browser/chromeos/login/quick_unlock/quick_unlock_notification_controller.cc',
'browser/chromeos/login/quick_unlock/quick_unlock_notification_controller.h',
'browser/chromeos/login/quick_unlock/pin_storage.cc', 'browser/chromeos/login/quick_unlock/pin_storage.cc',
'browser/chromeos/login/quick_unlock/pin_storage.h', 'browser/chromeos/login/quick_unlock/pin_storage.h',
'browser/chromeos/login/quick_unlock/pin_storage_factory.cc', 'browser/chromeos/login/quick_unlock/pin_storage_factory.cc',
'browser/chromeos/login/quick_unlock/pin_storage_factory.h', 'browser/chromeos/login/quick_unlock/pin_storage_factory.h',
'browser/chromeos/login/quick_unlock/quick_unlock_notification_controller.cc',
'browser/chromeos/login/quick_unlock/quick_unlock_notification_controller.h',
'browser/chromeos/login/quick_unlock/quick_unlock_utils.cc',
'browser/chromeos/login/quick_unlock/quick_unlock_utils.h',
'browser/chromeos/login/saml/saml_offline_signin_limiter.cc', 'browser/chromeos/login/saml/saml_offline_signin_limiter.cc',
'browser/chromeos/login/saml/saml_offline_signin_limiter.h', 'browser/chromeos/login/saml/saml_offline_signin_limiter.h',
'browser/chromeos/login/saml/saml_offline_signin_limiter_factory.cc', 'browser/chromeos/login/saml/saml_offline_signin_limiter_factory.cc',
......
...@@ -99,6 +99,10 @@ const base::Feature kSyzyasanDeferredFree{"SyzyasanDeferredFree", ...@@ -99,6 +99,10 @@ const base::Feature kSyzyasanDeferredFree{"SyzyasanDeferredFree",
// Enables or disables the opt-in IME menu in the language settings page. // Enables or disables the opt-in IME menu in the language settings page.
const base::Feature kOptInImeMenu{"OptInImeMenu", const base::Feature kOptInImeMenu{"OptInImeMenu",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
// Enables or disables PIN quick unlock settings integration.
const base::Feature kQuickUnlockPin{"QuickUnlockPin",
base::FEATURE_DISABLED_BY_DEFAULT};
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
} // namespace features } // namespace features
...@@ -61,6 +61,8 @@ extern const base::Feature kSyzyasanDeferredFree; ...@@ -61,6 +61,8 @@ extern const base::Feature kSyzyasanDeferredFree;
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
extern const base::Feature kOptInImeMenu; extern const base::Feature kOptInImeMenu;
extern const base::Feature kQuickUnlockPin;
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
// DON'T ADD RANDOM STUFF HERE. Put it in the main section above in // DON'T ADD RANDOM STUFF HERE. Put it in the main section above in
......
...@@ -81895,6 +81895,7 @@ To add a new entry, add it with any value and run test to compute valid value. ...@@ -81895,6 +81895,7 @@ To add a new entry, add it with any value and run test to compute valid value.
<int value="-1319688939" label="ignore-gpu-blacklist"/> <int value="-1319688939" label="ignore-gpu-blacklist"/>
<int value="-1302904242" label="enable-navigation-tracing"/> <int value="-1302904242" label="enable-navigation-tracing"/>
<int value="-1285021473" label="save-page-as-mhtml"/> <int value="-1285021473" label="save-page-as-mhtml"/>
<int value="-1276912933" label="enable-quick-unlock-pin"/>
<int value="-1271563519" label="enable-appcontainer"/> <int value="-1271563519" label="enable-appcontainer"/>
<int value="-1269084216" label="ash-md"/> <int value="-1269084216" label="ash-md"/>
<int value="-1268836676" label="disable-out-of-process-pdf"/> <int value="-1268836676" label="disable-out-of-process-pdf"/>
...@@ -82014,6 +82015,7 @@ To add a new entry, add it with any value and run test to compute valid value. ...@@ -82014,6 +82015,7 @@ To add a new entry, add it with any value and run test to compute valid value.
<int value="-488779992" label="blink-settings"/> <int value="-488779992" label="blink-settings"/>
<int value="-478462945" label="enable-ephemeral-apps"/> <int value="-478462945" label="enable-ephemeral-apps"/>
<int value="-475049740" label="disable-vr-shell"/> <int value="-475049740" label="disable-vr-shell"/>
<int value="-474322576" label="disable-quick-unlock-pin"/>
<int value="-462205750" label="enable-service-worker-sync"/> <int value="-462205750" label="enable-service-worker-sync"/>
<int value="-455203267" label="use_new_features_summary"/> <int value="-455203267" label="use_new_features_summary"/>
<int value="-430360431" label="disable-password-generation"/> <int value="-430360431" label="disable-password-generation"/>
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