summaryrefslogtreecommitdiff
path: root/browser/extensions/formautofill
diff options
context:
space:
mode:
Diffstat (limited to 'browser/extensions/formautofill')
-rw-r--r--browser/extensions/formautofill/.eslintrc.js474
-rw-r--r--browser/extensions/formautofill/bootstrap.js12
-rw-r--r--browser/extensions/formautofill/content/FormAutofillContent.jsm134
-rw-r--r--browser/extensions/formautofill/content/FormAutofillParent.jsm173
-rw-r--r--browser/extensions/formautofill/content/ProfileStorage.jsm251
-rw-r--r--browser/extensions/formautofill/install.rdf.in32
-rw-r--r--browser/extensions/formautofill/jar.mn7
-rw-r--r--browser/extensions/formautofill/moz.build18
8 files changed, 0 insertions, 1101 deletions
diff --git a/browser/extensions/formautofill/.eslintrc.js b/browser/extensions/formautofill/.eslintrc.js
deleted file mode 100644
index ec89029e55..0000000000
--- a/browser/extensions/formautofill/.eslintrc.js
+++ /dev/null
@@ -1,474 +0,0 @@
-"use strict";
-
-module.exports = { // eslint-disable-line no-undef
- "extends": "../../.eslintrc.js",
-
- "globals": {
- "Components": true,
- "dump": true,
- "TextDecoder": false,
- "TextEncoder": false,
- },
-
- "rules": {
- // Rules from the mozilla plugin
- "mozilla/balanced-listeners": "error",
- "mozilla/no-aArgs": "warn",
- "mozilla/no-cpows-in-tests": "warn",
- "mozilla/var-only-at-top-level": "warn",
-
- "valid-jsdoc": ["error", {
- "prefer": {
- "return": "returns",
- },
- "preferType": {
- "Boolean": "boolean",
- "Number": "number",
- "String": "string",
- "bool": "boolean",
- },
- "requireParamDescription": false,
- "requireReturn": false,
- "requireReturnDescription": false,
- }],
-
- // Braces only needed for multi-line arrow function blocks
- // "arrow-body-style": ["error", "as-needed"],
-
- // Require spacing around =>
- "arrow-spacing": "error",
-
- // Always require spacing around a single line block
- "block-spacing": "warn",
-
- // Forbid spaces inside the square brackets of array literals.
- "array-bracket-spacing": ["error", "never"],
-
- // Forbid spaces inside the curly brackets of object literals.
- "object-curly-spacing": ["error", "never"],
-
- // No space padding in parentheses
- "space-in-parens": ["error", "never"],
-
- // Enforce one true brace style (opening brace on the same line) and avoid
- // start and end braces on the same line.
- "brace-style": ["error", "1tbs", {"allowSingleLine": true}],
-
- // No space before always a space after a comma
- "comma-spacing": ["error", {"before": false, "after": true}],
-
- // Commas at the end of the line not the start
- "comma-style": "error",
-
- // Don't require spaces around computed properties
- "computed-property-spacing": ["warn", "never"],
-
- // Functions are not required to consistently return something or nothing
- "consistent-return": "off",
-
- // Require braces around blocks that start a new line
- "curly": ["error", "all"],
-
- // Always require a trailing EOL
- "eol-last": "error",
-
- // Require function* name()
- "generator-star-spacing": ["error", {"before": false, "after": true}],
-
- // Two space indent
- "indent": ["error", 2, {"SwitchCase": 1}],
-
- // Space after colon not before in property declarations
- "key-spacing": ["error", {"beforeColon": false, "afterColon": true, "mode": "minimum"}],
-
- // Require spaces before and after finally, catch, etc.
- "keyword-spacing": "error",
-
- // Unix linebreaks
- "linebreak-style": ["error", "unix"],
-
- // Always require parenthesis for new calls
- "new-parens": "error",
-
- // Use [] instead of Array()
- "no-array-constructor": "error",
-
- // No duplicate arguments in function declarations
- "no-dupe-args": "error",
-
- // No duplicate keys in object declarations
- "no-dupe-keys": "error",
-
- // No duplicate cases in switch statements
- "no-duplicate-case": "error",
-
- // If an if block ends with a return no need for an else block
- // "no-else-return": "error",
-
- // Disallow empty statements. This will report an error for:
- // try { something(); } catch (e) {}
- // but will not report it for:
- // try { something(); } catch (e) { /* Silencing the error because ...*/ }
- // which is a valid use case.
- "no-empty": "error",
-
- // No empty character classes in regex
- "no-empty-character-class": "error",
-
- // Disallow empty destructuring
- "no-empty-pattern": "error",
-
- // No assiging to exception variable
- "no-ex-assign": "error",
-
- // No using !! where casting to boolean is already happening
- "no-extra-boolean-cast": "warn",
-
- // No double semicolon
- "no-extra-semi": "error",
-
- // No overwriting defined functions
- "no-func-assign": "error",
-
- // No invalid regular expresions
- "no-invalid-regexp": "error",
-
- // No odd whitespace characters
- "no-irregular-whitespace": "error",
-
- // No single if block inside an else block
- "no-lonely-if": "warn",
-
- // No mixing spaces and tabs in indent
- "no-mixed-spaces-and-tabs": ["error", "smart-tabs"],
-
- // Disallow use of multiple spaces (sometimes used to align const values,
- // array or object items, etc.). It's hard to maintain and doesn't add that
- // much benefit.
- "no-multi-spaces": "warn",
-
- // No reassigning native JS objects
- "no-native-reassign": "error",
-
- // No (!foo in bar)
- "no-negated-in-lhs": "error",
-
- // Nested ternary statements are confusing
- "no-nested-ternary": "error",
-
- // Use {} instead of new Object()
- "no-new-object": "error",
-
- // No Math() or JSON()
- "no-obj-calls": "error",
-
- // No octal literals
- "no-octal": "error",
-
- // No redeclaring variables
- "no-redeclare": "error",
-
- // No unnecessary comparisons
- "no-self-compare": "error",
-
- // No spaces between function name and parentheses
- "no-spaced-func": "warn",
-
- // No trailing whitespace
- "no-trailing-spaces": "error",
-
- // Error on newline where a semicolon is needed
- "no-unexpected-multiline": "error",
-
- // No unreachable statements
- "no-unreachable": "error",
-
- // No expressions where a statement is expected
- "no-unused-expressions": "error",
-
- // No declaring variables that are never used
- "no-unused-vars": ["error", {"args": "none", "varsIgnorePattern": "^(Cc|Ci|Cr|Cu|EXPORTED_SYMBOLS)$"}],
-
- // No using variables before defined
- "no-use-before-define": "error",
-
- // No using with
- "no-with": "error",
-
- // Always require semicolon at end of statement
- "semi": ["error", "always"],
-
- // Require space before blocks
- "space-before-blocks": "error",
-
- // Never use spaces before function parentheses
- "space-before-function-paren": ["error", {"anonymous": "never", "named": "never"}],
-
- // Require spaces around operators, except for a|"off".
- "space-infix-ops": ["error", {"int32Hint": true}],
-
- // ++ and -- should not need spacing
- "space-unary-ops": ["warn", {"nonwords": false}],
-
- // No comparisons to NaN
- "use-isnan": "error",
-
- // Only check typeof against valid results
- "valid-typeof": "error",
-
- // Disallow using variables outside the blocks they are defined (especially
- // since only let and const are used, see "no-var").
- "block-scoped-var": "error",
-
- // Allow trailing commas for easy list extension. Having them does not
- // impair readability, but also not required either.
- "comma-dangle": ["error", "always-multiline"],
-
- // Warn about cyclomatic complexity in functions.
- "complexity": "warn",
-
- // Don't warn for inconsistent naming when capturing this (not so important
- // with auto-binding fat arrow functions).
- // "consistent-this": ["error", "self"],
-
- // Don't require a default case in switch statements. Avoid being forced to
- // add a bogus default when you know all possible cases are handled.
- "default-case": "off",
-
- // Enforce dots on the next line with property name.
- "dot-location": ["error", "property"],
-
- // Encourage the use of dot notation whenever possible.
- "dot-notation": "error",
-
- // Allow using == instead of ===, in the interest of landing something since
- // the devtools codebase is split on convention here.
- "eqeqeq": "off",
-
- // Don't require function expressions to have a name.
- // This makes the code more verbose and hard to read. Our engine already
- // does a fantastic job assigning a name to the function, which includes
- // the enclosing function name, and worst case you have a line number that
- // you can just look up.
- "func-names": "off",
-
- // Allow use of function declarations and expressions.
- "func-style": "off",
-
- // Don't enforce the maximum depth that blocks can be nested. The complexity
- // rule is a better rule to check this.
- "max-depth": "off",
-
- // Maximum length of a line.
- // Disabled because we exceed this in too many places.
- "max-len": ["off", 80],
-
- // Maximum depth callbacks can be nested.
- "max-nested-callbacks": ["error", 4],
-
- // Don't limit the number of parameters that can be used in a function.
- "max-params": "off",
-
- // Don't limit the maximum number of statement allowed in a function. We
- // already have the complexity rule that's a better measurement.
- "max-statements": "off",
-
- // Don't require a capital letter for constructors, only check if all new
- // operators are followed by a capital letter. Don't warn when capitalized
- // functions are used without the new operator.
- "new-cap": ["off", {"capIsNew": false}],
-
- // Allow use of bitwise operators.
- "no-bitwise": "off",
-
- // Disallow use of arguments.caller or arguments.callee.
- "no-caller": "error",
-
- // Disallow the catch clause parameter name being the same as a variable in
- // the outer scope, to avoid confusion.
- "no-catch-shadow": "off",
-
- // Disallow assignment in conditional expressions.
- "no-cond-assign": "error",
-
- // Disallow using the console API.
- "no-console": "error",
-
- // Allow using constant expressions in conditions like while (true)
- "no-constant-condition": "off",
-
- // Allow use of the continue statement.
- "no-continue": "off",
-
- // Disallow control characters in regular expressions.
- "no-control-regex": "error",
-
- // Disallow use of debugger.
- "no-debugger": "error",
-
- // Disallow deletion of variables (deleting properties is fine).
- "no-delete-var": "error",
-
- // Allow division operators explicitly at beginning of regular expression.
- "no-div-regex": "off",
-
- // Disallow use of eval(). We have other APIs to evaluate code in content.
- "no-eval": "error",
-
- // Disallow adding to native types
- "no-extend-native": "error",
-
- // Disallow unnecessary function binding.
- "no-extra-bind": "error",
-
- // Allow unnecessary parentheses, as they may make the code more readable.
- "no-extra-parens": "off",
-
- // Disallow fallthrough of case statements, except if there is a comment.
- "no-fallthrough": "error",
-
- // Allow the use of leading or trailing decimal points in numeric literals.
- "no-floating-decimal": "off",
-
- // Allow comments inline after code.
- "no-inline-comments": "off",
-
- // Disallow use of labels for anything other then loops and switches.
- "no-labels": ["error", {"allowLoop": true}],
-
- // Disallow use of multiline strings (use template strings instead).
- "no-multi-str": "warn",
-
- // Disallow multiple empty lines.
- "no-multiple-empty-lines": ["warn", {"max": 2}],
-
- // Allow reassignment of function parameters.
- "no-param-reassign": "off",
-
- // Allow string concatenation with __dirname and __filename (not a node env).
- "no-path-concat": "off",
-
- // Allow use of unary operators, ++ and --.
- "no-plusplus": "off",
-
- // Allow using process.env (not a node environment).
- "no-process-env": "off",
-
- // Allow using process.exit (not a node environment).
- "no-process-exit": "off",
-
- // Disallow usage of __proto__ property.
- "no-proto": "error",
-
- // Disallow multiple spaces in a regular expression literal.
- "no-regex-spaces": "error",
-
- // Allow reserved words being used as object literal keys.
- "no-reserved-keys": "off",
-
- // Don't restrict usage of specified node modules (not a node environment).
- "no-restricted-modules": "off",
-
- // Disallow use of assignment in return statement. It is preferable for a
- // single line of code to have only one easily predictable effect.
- "no-return-assign": "error",
-
- // Don't warn about declaration of variables already declared in the outer scope.
- "no-shadow": "off",
-
- // Disallow shadowing of names such as arguments.
- "no-shadow-restricted-names": "error",
-
- // Allow use of synchronous methods (not a node environment).
- "no-sync": "off",
-
- // Allow the use of ternary operators.
- "no-ternary": "off",
-
- // Disallow throwing literals (eg. throw "error" instead of
- // throw new Error("error")).
- "no-throw-literal": "error",
-
- // Disallow use of undeclared variables unless mentioned in a /* global */
- // block. Note that globals from head.js are automatically imported in tests
- // by the import-headjs-globals rule form the mozilla eslint plugin.
- "no-undef": "error",
-
- // Allow dangling underscores in identifiers (for privates).
- "no-underscore-dangle": "off",
-
- // Allow use of undefined variable.
- "no-undefined": "off",
-
- // Disallow the use of Boolean literals in conditional expressions.
- "no-unneeded-ternary": "error",
-
- // We use var-only-at-top-level instead of no-var as we allow top level
- // vars.
- "no-var": "off",
-
- // Allow using TODO/FIXME comments.
- "no-warning-comments": "off",
-
- // Don't require method and property shorthand syntax for object literals.
- // We use this in the code a lot, but not consistently, and this seems more
- // like something to check at code review time.
- "object-shorthand": "off",
-
- // Allow more than one variable declaration per function.
- "one-var": "off",
-
- // Disallow padding within blocks.
- "padded-blocks": ["warn", "never"],
-
- // Don't require quotes around object literal property names.
- "quote-props": "off",
-
- // Double quotes should be used.
- "quotes": ["warn", "double", {"avoidEscape": true, "allowTemplateLiterals": true}],
-
- // Require use of the second argument for parseInt().
- "radix": "error",
-
- // Enforce spacing after semicolons.
- "semi-spacing": ["error", {"before": false, "after": true}],
-
- // Don't require to sort variables within the same declaration block.
- // Anyway, one-var is disabled.
- "sort-vars": "off",
-
- // Require a space immediately following the // in a line comment.
- "spaced-comment": ["error", "always"],
-
- // Require "use strict" to be defined globally in the script.
- "strict": ["error", "global"],
-
- // Allow vars to be declared anywhere in the scope.
- "vars-on-top": "off",
-
- // Don't require immediate function invocation to be wrapped in parentheses.
- "wrap-iife": "off",
-
- // Don't require regex literals to be wrapped in parentheses (which
- // supposedly prevent them from being mistaken for division operators).
- "wrap-regex": "off",
-
- // Disallow Yoda conditions (where literal value comes first).
- "yoda": "error",
-
- // disallow use of eval()-like methods
- "no-implied-eval": "error",
-
- // Disallow function or variable declarations in nested blocks
- "no-inner-declarations": "error",
-
- // Disallow usage of __iterator__ property
- "no-iterator": "error",
-
- // Disallow labels that share a name with a variable
- "no-label-var": "error",
-
- // Disallow creating new instances of String, Number, and Boolean
- "no-new-wrappers": "error",
- },
-};
diff --git a/browser/extensions/formautofill/bootstrap.js b/browser/extensions/formautofill/bootstrap.js
deleted file mode 100644
index 0b3f355bd4..0000000000
--- a/browser/extensions/formautofill/bootstrap.js
+++ /dev/null
@@ -1,12 +0,0 @@
-/* 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/. */
-
-"use strict";
-
-/* exported startup, shutdown, install, uninstall */
-
-function startup() {}
-function shutdown() {}
-function install() {}
-function uninstall() {}
diff --git a/browser/extensions/formautofill/content/FormAutofillContent.jsm b/browser/extensions/formautofill/content/FormAutofillContent.jsm
deleted file mode 100644
index bde3975808..0000000000
--- a/browser/extensions/formautofill/content/FormAutofillContent.jsm
+++ /dev/null
@@ -1,134 +0,0 @@
-/* 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/. */
-
-/*
- * Implements a service used by DOM content to request Form Autofill.
- */
-
-"use strict";
-
-const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
-
-/**
- * Handles profile autofill for a DOM Form element.
- * @param {HTMLFormElement} form Form that need to be auto filled
- */
-function FormAutofillHandler(form) {
- this.form = form;
- this.fieldDetails = [];
-}
-
-FormAutofillHandler.prototype = {
- /**
- * DOM Form element to which this object is attached.
- */
- form: null,
-
- /**
- * Array of collected data about relevant form fields. Each item is an object
- * storing the identifying details of the field and a reference to the
- * originally associated element from the form.
- *
- * The "section", "addressType", "contactType", and "fieldName" values are
- * used to identify the exact field when the serializable data is received
- * from the backend. There cannot be multiple fields which have
- * the same exact combination of these values.
- *
- * A direct reference to the associated element cannot be sent to the user
- * interface because processing may be done in the parent process.
- */
- fieldDetails: null,
-
- /**
- * Returns information from the form about fields that can be autofilled, and
- * populates the fieldDetails array on this object accordingly.
- *
- * @returns {Array<Object>} Serializable data structure that can be sent to the user
- * interface, or null if the operation failed because the constraints
- * on the allowed fields were not honored.
- */
- collectFormFields() {
- let autofillData = [];
-
- for (let element of this.form.elements) {
- // Query the interface and exclude elements that cannot be autocompleted.
- if (!(element instanceof Ci.nsIDOMHTMLInputElement)) {
- continue;
- }
-
- // Exclude elements to which no autocomplete field has been assigned.
- let info = element.getAutocompleteInfo();
- if (!info.fieldName || ["on", "off"].includes(info.fieldName)) {
- continue;
- }
-
- // Store the association between the field metadata and the element.
- if (this.fieldDetails.some(f => f.section == info.section &&
- f.addressType == info.addressType &&
- f.contactType == info.contactType &&
- f.fieldName == info.fieldName)) {
- // A field with the same identifier already exists.
- return null;
- }
-
- let inputFormat = {
- section: info.section,
- addressType: info.addressType,
- contactType: info.contactType,
- fieldName: info.fieldName,
- };
- // Clone the inputFormat for caching the fields and elements together
- let formatWithElement = Object.assign({}, inputFormat);
-
- inputFormat.index = autofillData.length;
- autofillData.push(inputFormat);
-
- formatWithElement.element = element;
- this.fieldDetails.push(formatWithElement);
- }
-
- return autofillData;
- },
-
- /**
- * Processes form fields that can be autofilled, and populates them with the
- * data provided by backend.
- *
- * @param {Array<Object>} autofillResult
- * Data returned by the user interface.
- * [{
- * section: Value originally provided to the user interface.
- * addressType: Value originally provided to the user interface.
- * contactType: Value originally provided to the user interface.
- * fieldName: Value originally provided to the user interface.
- * value: String with which the field should be updated.
- * index: Index to match the input in fieldDetails
- * }],
- * }
- */
- autofillFormFields(autofillResult) {
- for (let field of autofillResult) {
- // Get the field details, if it was processed by the user interface.
- let fieldDetail = this.fieldDetails[field.index];
-
- // Avoid the invalid value set
- if (!fieldDetail || !field.value) {
- continue;
- }
-
- let info = fieldDetail.element.getAutocompleteInfo();
- if (field.section != info.section ||
- field.addressType != info.addressType ||
- field.contactType != info.contactType ||
- field.fieldName != info.fieldName) {
- Cu.reportError("Autocomplete tokens mismatched");
- continue;
- }
-
- fieldDetail.element.setUserInput(field.value);
- }
- },
-};
-
-this.EXPORTED_SYMBOLS = ["FormAutofillHandler"];
diff --git a/browser/extensions/formautofill/content/FormAutofillParent.jsm b/browser/extensions/formautofill/content/FormAutofillParent.jsm
deleted file mode 100644
index bdfe0f478b..0000000000
--- a/browser/extensions/formautofill/content/FormAutofillParent.jsm
+++ /dev/null
@@ -1,173 +0,0 @@
-/* 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/. */
-
-/*
- * Implements a service used to access storage and communicate with content.
- *
- * A "fields" array is used to communicate with FormAutofillContent. Each item
- * represents a single input field in the content page as well as its
- * @autocomplete properties. The schema is as below. Please refer to
- * FormAutofillContent.jsm for more details.
- *
- * [
- * {
- * section,
- * addressType,
- * contactType,
- * fieldName,
- * value,
- * index
- * },
- * {
- * // ...
- * }
- * ]
- */
-
-/* exported FormAutofillParent */
-
-"use strict";
-
-const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
-XPCOMUtils.defineLazyModuleGetter(this, "OS",
- "resource://gre/modules/osfile.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "ProfileStorage",
- "resource://formautofill/ProfileStorage.jsm");
-
-const PROFILE_JSON_FILE_NAME = "autofill-profiles.json";
-
-let FormAutofillParent = {
- _profileStore: null,
-
- /**
- * Initializes ProfileStorage and registers the message handler.
- */
- init: function() {
- let storePath =
- OS.Path.join(OS.Constants.Path.profileDir, PROFILE_JSON_FILE_NAME);
-
- this._profileStore = new ProfileStorage(storePath);
- this._profileStore.initialize();
-
- let mm = Cc["@mozilla.org/globalmessagemanager;1"]
- .getService(Ci.nsIMessageListenerManager);
- mm.addMessageListener("FormAutofill:PopulateFieldValues", this);
- },
-
- /**
- * Handles the message coming from FormAutofillContent.
- *
- * @param {string} message.name The name of the message.
- * @param {object} message.data The data of the message.
- * @param {nsIFrameMessageManager} message.target Caller's message manager.
- */
- receiveMessage: function({name, data, target}) {
- switch (name) {
- case "FormAutofill:PopulateFieldValues":
- this._populateFieldValues(data, target);
- break;
- }
- },
-
- /**
- * Returns the instance of ProfileStorage. To avoid syncing issues, anyone
- * who needs to access the profile should request the instance by this instead
- * of creating a new one.
- *
- * @returns {ProfileStorage}
- */
- getProfileStore: function() {
- return this._profileStore;
- },
-
- /**
- * Uninitializes FormAutofillParent. This is for testing only.
- *
- * @private
- */
- _uninit: function() {
- if (this._profileStore) {
- this._profileStore._saveImmediately();
- this._profileStore = null;
- }
-
- let mm = Cc["@mozilla.org/globalmessagemanager;1"]
- .getService(Ci.nsIMessageListenerManager);
- mm.removeMessageListener("FormAutofill:PopulateFieldValues", this);
- },
-
- /**
- * Populates the field values and notifies content to fill in. Exception will
- * be thrown if there's no matching profile.
- *
- * @private
- * @param {string} data.guid
- * Indicates which profile to populate
- * @param {Fields} data.fields
- * The "fields" array collected from content.
- * @param {nsIFrameMessageManager} target
- * Content's message manager.
- */
- _populateFieldValues({guid, fields}, target) {
- this._profileStore.notifyUsed(guid);
- this._fillInFields(this._profileStore.get(guid), fields);
- target.sendAsyncMessage("FormAutofill:fillForm", {fields});
- },
-
- /**
- * Transforms a word with hyphen into camel case.
- * (e.g. transforms "address-type" into "addressType".)
- *
- * @private
- * @param {string} str The original string with hyphen.
- * @returns {string} The camel-cased output string.
- */
- _camelCase(str) {
- return str.toLowerCase().replace(/-([a-z])/g, s => s[1].toUpperCase());
- },
-
- /**
- * Get the corresponding value from the specified profile according to a valid
- * @autocomplete field name.
- *
- * Note that the field name doesn't need to match the property name defined in
- * Profile object. This method can transform the raw data to fulfill it. (e.g.
- * inputting "country-name" as "fieldName" will get a full name transformed
- * from the country code that is recorded in "country" field.)
- *
- * @private
- * @param {Profile} profile The specified profile.
- * @param {string} fieldName A valid @autocomplete field name.
- * @returns {string} The corresponding value. Returns "undefined" if there's
- * no matching field.
- */
- _getDataByFieldName(profile, fieldName) {
- let key = this._camelCase(fieldName);
-
- // TODO: Transform the raw profile data to fulfill "fieldName" here.
-
- return profile[key];
- },
-
- /**
- * Fills in the "fields" array by the specified profile.
- *
- * @private
- * @param {Profile} profile The specified profile to fill in.
- * @param {Fields} fields The "fields" array collected from content.
- */
- _fillInFields(profile, fields) {
- for (let field of fields) {
- let value = this._getDataByFieldName(profile, field.fieldName);
- if (value !== undefined) {
- field.value = value;
- }
- }
- },
-};
-
-this.EXPORTED_SYMBOLS = ["FormAutofillParent"];
diff --git a/browser/extensions/formautofill/content/ProfileStorage.jsm b/browser/extensions/formautofill/content/ProfileStorage.jsm
deleted file mode 100644
index 843177d4eb..0000000000
--- a/browser/extensions/formautofill/content/ProfileStorage.jsm
+++ /dev/null
@@ -1,251 +0,0 @@
-/* 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/. */
-
-/*
- * Implements an interface of the storage of Form Autofill.
- *
- * The data is stored in JSON format, without indentation, using UTF-8 encoding.
- * With indentation applied, the file would look like this:
- *
- * {
- * version: 1,
- * profiles: [
- * {
- * guid, // 12 character...
- *
- * // profile
- * organization, // Company
- * streetAddress, // (Multiline)
- * addressLevel2, // City/Town
- * addressLevel1, // Province (Standardized code if possible)
- * postalCode,
- * country, // ISO 3166
- * tel,
- * email,
- *
- * // metadata
- * timeCreated, // in ms
- * timeLastUsed, // in ms
- * timeLastModified, // in ms
- * timesUsed
- * },
- * {
- * // ...
- * }
- * ]
- * }
- */
-
-"use strict";
-
-const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/Task.jsm");
-
-XPCOMUtils.defineLazyModuleGetter(this, "JSONFile",
- "resource://gre/modules/JSONFile.jsm");
-
-XPCOMUtils.defineLazyServiceGetter(this, "gUUIDGenerator",
- "@mozilla.org/uuid-generator;1",
- "nsIUUIDGenerator");
-
-const SCHEMA_VERSION = 1;
-
-// Name-related fields will be handled in follow-up bugs due to the complexity.
-const VALID_FIELDS = [
- "organization",
- "streetAddress",
- "addressLevel2",
- "addressLevel1",
- "postalCode",
- "country",
- "tel",
- "email",
-];
-
-function ProfileStorage(path) {
- this._path = path;
-}
-
-ProfileStorage.prototype = {
- /**
- * Loads the profile data from file to memory.
- *
- * @returns {Promise}
- * @resolves When the operation finished successfully.
- * @rejects JavaScript exception.
- */
- initialize() {
- this._store = new JSONFile({
- path: this._path,
- dataPostProcessor: this._dataPostProcessor.bind(this),
- });
- return this._store.load();
- },
-
- /**
- * Adds a new profile.
- *
- * @param {Profile} profile
- * The new profile for saving.
- */
- add(profile) {
- this._store.ensureDataReady();
-
- let profileToSave = this._normalizeProfile(profile);
-
- profileToSave.guid = gUUIDGenerator.generateUUID().toString()
- .replace(/[{}-]/g, "").substring(0, 12);
-
- // Metadata
- let now = Date.now();
- profileToSave.timeCreated = now;
- profileToSave.timeLastModified = now;
- profileToSave.timeLastUsed = 0;
- profileToSave.timesUsed = 0;
-
- this._store.data.profiles.push(profileToSave);
-
- this._store.saveSoon();
- },
-
- /**
- * Update the specified profile.
- *
- * @param {string} guid
- * Indicates which profile to update.
- * @param {Profile} profile
- * The new profile used to overwrite the old one.
- */
- update(guid, profile) {
- this._store.ensureDataReady();
-
- let profileFound = this._findByGUID(guid);
- if (!profileFound) {
- throw new Error("No matching profile.");
- }
-
- let profileToUpdate = this._normalizeProfile(profile);
- for (let field of VALID_FIELDS) {
- if (profileToUpdate[field] !== undefined) {
- profileFound[field] = profileToUpdate[field];
- } else {
- delete profileFound[field];
- }
- }
-
- profileFound.timeLastModified = Date.now();
-
- this._store.saveSoon();
- },
-
- /**
- * Notifies the stroage of the use of the specified profile, so we can update
- * the metadata accordingly.
- *
- * @param {string} guid
- * Indicates which profile to be notified.
- */
- notifyUsed(guid) {
- this._store.ensureDataReady();
-
- let profileFound = this._findByGUID(guid);
- if (!profileFound) {
- throw new Error("No matching profile.");
- }
-
- profileFound.timesUsed++;
- profileFound.timeLastUsed = Date.now();
-
- this._store.saveSoon();
- },
-
- /**
- * Removes the specified profile. No error occurs if the profile isn't found.
- *
- * @param {string} guid
- * Indicates which profile to remove.
- */
- remove(guid) {
- this._store.ensureDataReady();
-
- this._store.data.profiles =
- this._store.data.profiles.filter(profile => profile.guid != guid);
- this._store.saveSoon();
- },
-
- /**
- * Returns the profile with the specified GUID.
- *
- * @param {string} guid
- * Indicates which profile to retrieve.
- * @returns {Profile}
- * A clone of the profile.
- */
- get(guid) {
- this._store.ensureDataReady();
-
- let profileFound = this._findByGUID(guid);
- if (!profileFound) {
- throw new Error("No matching profile.");
- }
-
- // Profile is cloned to avoid accidental modifications from outside.
- return this._clone(profileFound);
- },
-
- /**
- * Returns all profiles.
- *
- * @returns {Array.<Profile>}
- * An array containing clones of all profiles.
- */
- getAll() {
- this._store.ensureDataReady();
-
- // Profiles are cloned to avoid accidental modifications from outside.
- return this._store.data.profiles.map(this._clone);
- },
-
- _clone(profile) {
- return Object.assign({}, profile);
- },
-
- _findByGUID(guid) {
- return this._store.data.profiles.find(profile => profile.guid == guid);
- },
-
- _normalizeProfile(profile) {
- let result = {};
- for (let key in profile) {
- if (!VALID_FIELDS.includes(key)) {
- throw new Error(`"${key}" is not a valid field.`);
- }
- if (typeof profile[key] !== "string" &&
- typeof profile[key] !== "number") {
- throw new Error(`"${key}" contains invalid data type.`);
- }
-
- result[key] = profile[key];
- }
- return result;
- },
-
- _dataPostProcessor(data) {
- data.version = SCHEMA_VERSION;
- if (!data.profiles) {
- data.profiles = [];
- }
- return data;
- },
-
- // For test only.
- _saveImmediately() {
- return this._store._save();
- },
-};
-
-this.EXPORTED_SYMBOLS = ["ProfileStorage"];
diff --git a/browser/extensions/formautofill/install.rdf.in b/browser/extensions/formautofill/install.rdf.in
deleted file mode 100644
index 5e34051ba0..0000000000
--- a/browser/extensions/formautofill/install.rdf.in
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0"?>
-<!-- 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/. -->
-
-#filter substitution
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
- <Description about="urn:mozilla:install-manifest">
- <em:id>formautofill@mozilla.org</em:id>
- <em:version>1.0</em:version>
- <em:type>2</em:type>
- <em:bootstrap>true</em:bootstrap>
- <em:multiprocessCompatible>true</em:multiprocessCompatible>
-
- <!-- Target Application this extension can install into,
- with minimum and maximum supported versions. -->
- <em:targetApplication>
- <Description>
- <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
- <em:minVersion>@MOZ_APP_VERSION@</em:minVersion>
- <em:maxVersion>@MOZ_APP_MAXVERSION@</em:maxVersion>
- </Description>
- </em:targetApplication>
-
- <!-- Front End MetaData -->
- <em:name>Form Autofill</em:name>
- <em:description>Autofill forms with saved profiles</em:description>
- </Description>
-</RDF>
diff --git a/browser/extensions/formautofill/jar.mn b/browser/extensions/formautofill/jar.mn
deleted file mode 100644
index 0cba721ef3..0000000000
--- a/browser/extensions/formautofill/jar.mn
+++ /dev/null
@@ -1,7 +0,0 @@
-# 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/.
-
-[features/formautofill@mozilla.org] chrome.jar:
-% resource formautofill %content/
- content/ (content/*)
diff --git a/browser/extensions/formautofill/moz.build b/browser/extensions/formautofill/moz.build
deleted file mode 100644
index abcc659eed..0000000000
--- a/browser/extensions/formautofill/moz.build
+++ /dev/null
@@ -1,18 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION']
-DEFINES['MOZ_APP_MAXVERSION'] = CONFIG['MOZ_APP_MAXVERSION']
-
-FINAL_TARGET_FILES.features['formautofill@mozilla.org'] += [
- 'bootstrap.js'
-]
-
-FINAL_TARGET_PP_FILES.features['formautofill@mozilla.org'] += [
- 'install.rdf.in'
-]
-
-JAR_MANIFESTS += ['jar.mn']