Commit abffce1e authored by Renato Silva's avatar Renato Silva Committed by Commit Bot

PIN Auto Submit - Extend Quick Unlock API

Extend the Quick Unlock Private API to support two additional methods
- setPinAutosubmitEnabled
- canAuthenticatePin

setPinAutosubmitEnabled will allow Chrome OS settings to control the
PIN auto submit behaviour. canAuthenticatePin is a simple method that
checks whether it is still possible to authenticate using a PIN.
This only adds the skeleton for the extension and does not call any
code yet. It only returns with false for now.

Bug: 1107367
Change-Id: I0c961b2d2cf236e05b9bf959603d4e4a459b6f88
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2306040
Commit-Queue: Renato Silva <rrsilva@google.com>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Reviewed-by: default avatarJun Mukai <mukai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791720}
parent b7c2cdd8
...@@ -339,6 +339,78 @@ QuickUnlockPrivateSetLockScreenEnabledFunction::Run() { ...@@ -339,6 +339,78 @@ QuickUnlockPrivateSetLockScreenEnabledFunction::Run() {
quick_unlock_private::SetLockScreenEnabled::Results::Create())); quick_unlock_private::SetLockScreenEnabled::Results::Create()));
} }
// quickUnlockPrivate.setPinAutosubmitEnabled
QuickUnlockPrivateSetPinAutosubmitEnabledFunction::
QuickUnlockPrivateSetPinAutosubmitEnabledFunction()
: chrome_details_(this) {}
QuickUnlockPrivateSetPinAutosubmitEnabledFunction::
~QuickUnlockPrivateSetPinAutosubmitEnabledFunction() = default;
ExtensionFunction::ResponseAction
QuickUnlockPrivateSetPinAutosubmitEnabledFunction::Run() {
auto params =
quick_unlock_private::SetPinAutosubmitEnabled::Params::Create(*args_);
AuthToken* auth_token = GetActiveProfileAuthToken(browser_context());
if (!auth_token)
return RespondNow(Error(kAuthTokenExpired));
if (params->token != auth_token->Identifier())
return RespondNow(Error(kAuthTokenInvalid));
Profile* profile = GetActiveProfile(browser_context());
user_manager::User* user =
chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
chromeos::quick_unlock::PinBackend::GetInstance()->SetPinAutoSubmitEnabled(
user->GetAccountId(), params->pin, params->enabled,
base::BindOnce(&QuickUnlockPrivateSetPinAutosubmitEnabledFunction::
HandleSetPinAutoSubmitResult,
this));
return RespondLater();
}
void QuickUnlockPrivateSetPinAutosubmitEnabledFunction::
HandleSetPinAutoSubmitResult(bool result) {
Respond(ArgumentList(
quick_unlock_private::SetPinAutosubmitEnabled::Results::Create(result)));
}
// quickUnlockPrivate.canAuthenticatePin
QuickUnlockPrivateCanAuthenticatePinFunction::
QuickUnlockPrivateCanAuthenticatePinFunction()
: chrome_details_(this) {}
QuickUnlockPrivateCanAuthenticatePinFunction::
~QuickUnlockPrivateCanAuthenticatePinFunction() = default;
ExtensionFunction::ResponseAction
QuickUnlockPrivateCanAuthenticatePinFunction::Run() {
AuthToken* auth_token = GetActiveProfileAuthToken(browser_context());
if (!auth_token)
return RespondNow(Error(kAuthTokenExpired));
Profile* profile = GetActiveProfile(browser_context());
user_manager::User* user =
chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
chromeos::quick_unlock::PinBackend::GetInstance()->CanAuthenticate(
user->GetAccountId(),
base::BindOnce(&QuickUnlockPrivateCanAuthenticatePinFunction::
HandleCanAuthenticateResult,
this));
return RespondLater();
}
void QuickUnlockPrivateCanAuthenticatePinFunction::HandleCanAuthenticateResult(
bool result) {
Respond(ArgumentList(
quick_unlock_private::CanAuthenticatePin::Results::Create(result)));
}
// quickUnlockPrivate.getAvailableModes // quickUnlockPrivate.getAvailableModes
QuickUnlockPrivateGetAvailableModesFunction:: QuickUnlockPrivateGetAvailableModesFunction::
......
...@@ -85,6 +85,47 @@ class QuickUnlockPrivateSetLockScreenEnabledFunction ...@@ -85,6 +85,47 @@ class QuickUnlockPrivateSetLockScreenEnabledFunction
DISALLOW_COPY_AND_ASSIGN(QuickUnlockPrivateSetLockScreenEnabledFunction); DISALLOW_COPY_AND_ASSIGN(QuickUnlockPrivateSetLockScreenEnabledFunction);
}; };
class QuickUnlockPrivateSetPinAutosubmitEnabledFunction
: public ExtensionFunction {
public:
QuickUnlockPrivateSetPinAutosubmitEnabledFunction();
DECLARE_EXTENSION_FUNCTION("quickUnlockPrivate.setPinAutosubmitEnabled",
QUICKUNLOCKPRIVATE_SETPINAUTOSUBMITENABLED)
protected:
~QuickUnlockPrivateSetPinAutosubmitEnabledFunction() override;
// ExtensionFunction overrides.
ResponseAction Run() override;
private:
void HandleSetPinAutoSubmitResult(bool result);
ChromeExtensionFunctionDetails chrome_details_;
DISALLOW_COPY_AND_ASSIGN(QuickUnlockPrivateSetPinAutosubmitEnabledFunction);
};
class QuickUnlockPrivateCanAuthenticatePinFunction : public ExtensionFunction {
public:
QuickUnlockPrivateCanAuthenticatePinFunction();
DECLARE_EXTENSION_FUNCTION("quickUnlockPrivate.canAuthenticatePin",
QUICKUNLOCKPRIVATE_CANAUTHENTICATEPIN)
protected:
~QuickUnlockPrivateCanAuthenticatePinFunction() override;
// ExtensionFunction overrides.
ResponseAction Run() override;
private:
void HandleCanAuthenticateResult(bool result);
ChromeExtensionFunctionDetails chrome_details_;
DISALLOW_COPY_AND_ASSIGN(QuickUnlockPrivateCanAuthenticatePinFunction);
};
class QuickUnlockPrivateGetAvailableModesFunction : public ExtensionFunction { class QuickUnlockPrivateGetAvailableModesFunction : public ExtensionFunction {
public: public:
QuickUnlockPrivateGetAvailableModesFunction(); QuickUnlockPrivateGetAvailableModesFunction();
......
...@@ -78,6 +78,23 @@ namespace quickUnlockPrivate { ...@@ -78,6 +78,23 @@ namespace quickUnlockPrivate {
boolean enabled, boolean enabled,
optional VoidResultCallback onComplete); optional VoidResultCallback onComplete);
// Sets the PIN auto submit enabled state. NOTE: The PIN autosubmit state is
// reflected in the pin_unlock_autosubmit_enabled pref, which can be read
// but not written using the settings_private API (which also provides
// policy information). This API must be used to change the pref.
// |token|: The authentication token.
// |pin|: The PIN of the logged in user.
// |enabled|: Whether to enable PIN auto submit.
// |onComplete|: Called with true if the quick unlock state was updated,
// false otherwise. The update is treated as a single atomic operation.
static void setPinAutosubmitEnabled(DOMString token,
DOMString pin,
boolean enabled,
BooleanResultCallback onComplete);
// Tests wether it is currently possible to authenticate using PIN.
static void canAuthenticatePin(BooleanResultCallback onComplete);
// Returns the set of quick unlock modes that are available for the user to // Returns the set of quick unlock modes that are available for the user to
// use. Some quick unlock modes may be disabled by policy. // use. Some quick unlock modes may be disabled by policy.
static void getAvailableModes(ModesCallback onComplete); static void getAvailableModes(ModesCallback onComplete);
......
...@@ -1549,6 +1549,8 @@ enum HistogramValue { ...@@ -1549,6 +1549,8 @@ enum HistogramValue {
AUTOTESTPRIVATE_DISABLEAUTOMATION = 1486, AUTOTESTPRIVATE_DISABLEAUTOMATION = 1486,
INPUT_IME_SETASSISTIVEWINDOWBUTTONHIGHLIGHTED = 1487, INPUT_IME_SETASSISTIVEWINDOWBUTTONHIGHLIGHTED = 1487,
CERTIFICATEPROVIDER_REPORTSIGNATURE = 1488, CERTIFICATEPROVIDER_REPORTSIGNATURE = 1488,
QUICKUNLOCKPRIVATE_SETPINAUTOSUBMITENABLED = 1489,
QUICKUNLOCKPRIVATE_CANAUTHENTICATEPIN = 1490,
// Last entry: Add new entries above, then run: // Last entry: Add new entries above, then run:
// python tools/metrics/histograms/update_extension_histograms.py // python tools/metrics/histograms/update_extension_histograms.py
ENUM_BOUNDARY ENUM_BOUNDARY
......
...@@ -24048,6 +24048,8 @@ Called by update_extension_histograms.py.--> ...@@ -24048,6 +24048,8 @@ Called by update_extension_histograms.py.-->
<int value="1486" label="AUTOTESTPRIVATE_DISABLEAUTOMATION"/> <int value="1486" label="AUTOTESTPRIVATE_DISABLEAUTOMATION"/>
<int value="1487" label="INPUT_IME_SETASSISTIVEWINDOWBUTTONHIGHLIGHTED"/> <int value="1487" label="INPUT_IME_SETASSISTIVEWINDOWBUTTONHIGHLIGHTED"/>
<int value="1488" label="CERTIFICATEPROVIDER_REPORTSIGNATURE"/> <int value="1488" label="CERTIFICATEPROVIDER_REPORTSIGNATURE"/>
<int value="1489" label="QUICKUNLOCKPRIVATE_SETPINAUTOSUBMITENABLED"/>
<int value="1490" label="QUICKUNLOCKPRIVATE_CANAUTHENTICATEPIN"/>
</enum> </enum>
<enum name="ExtensionIconState"> <enum name="ExtensionIconState">
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