summaryrefslogtreecommitdiffstats
path: root/toolkit/components/satchel/integrations/FirefoxRelayUtils.sys.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/satchel/integrations/FirefoxRelayUtils.sys.mjs')
-rw-r--r--toolkit/components/satchel/integrations/FirefoxRelayUtils.sys.mjs23
1 files changed, 23 insertions, 0 deletions
diff --git a/toolkit/components/satchel/integrations/FirefoxRelayUtils.sys.mjs b/toolkit/components/satchel/integrations/FirefoxRelayUtils.sys.mjs
new file mode 100644
index 0000000000..0dfb2a969d
--- /dev/null
+++ b/toolkit/components/satchel/integrations/FirefoxRelayUtils.sys.mjs
@@ -0,0 +1,23 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+import { LoginHelper } from "resource://gre/modules/LoginHelper.sys.mjs";
+
+export const FirefoxRelayUtils = {
+ isRelayInterestedField(input) {
+ return (
+ FirefoxRelayUtils.relayIsAvailableOrEnabled &&
+ (LoginHelper.isInferredEmailField(input) ||
+ LoginHelper.isInferredUsernameField(input))
+ );
+ },
+
+ relayIsAvailableOrEnabled() {
+ const value = Services.prefs.getStringPref(
+ "signon.firefoxRelay.feature",
+ undefined
+ );
+ return ["available", "offered", "enabled"].includes(value);
+ },
+};