Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1380094 - services/sync changes to support formautofill r=markh
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: BdsrrFOU5ec
  • Loading branch information
Thom Chiovoloni committed Jul 11, 2017
1 parent 8afeb4a commit 7ddc727
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 19 deletions.
6 changes: 5 additions & 1 deletion services/sync/modules/record.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,12 @@ CryptoWrapper.prototype = {
return this.cleartext;
},

cleartextToString() {
return JSON.stringify(this.cleartext);
},

toString: function toString() {
let payload = this.deleted ? "DELETED" : JSON.stringify(this.cleartext);
let payload = this.deleted ? "DELETED" : this.cleartextToString();

return "{ " +
"id: " + this.id + " " +
Expand Down
43 changes: 30 additions & 13 deletions services/sync/modules/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,31 @@ Cu.import("resource://services-sync/status.js");
Cu.import("resource://services-sync/telemetry.js");
Cu.import("resource://services-sync/util.js");

const ENGINE_MODULES = {
Addons: {module: "addons.js", symbol: "AddonsEngine"},
Bookmarks: {module: "bookmarks.js", symbol: "BookmarksEngine"},
Form: {module: "forms.js", symbol: "FormEngine"},
History: {module: "history.js", symbol: "HistoryEngine"},
Password: {module: "passwords.js", symbol: "PasswordEngine"},
Prefs: {module: "prefs.js", symbol: "PrefsEngine"},
Tab: {module: "tabs.js", symbol: "TabEngine"},
ExtensionStorage: {module: "extension-storage.js", symbol: "ExtensionStorageEngine"},
};
function getEngineModules() {
let result = {
Addons: {module: "addons.js", symbol: "AddonsEngine"},
Bookmarks: {module: "bookmarks.js", symbol: "BookmarksEngine"},
Form: {module: "forms.js", symbol: "FormEngine"},
History: {module: "history.js", symbol: "HistoryEngine"},
Password: {module: "passwords.js", symbol: "PasswordEngine"},
Prefs: {module: "prefs.js", symbol: "PrefsEngine"},
Tab: {module: "tabs.js", symbol: "TabEngine"},
ExtensionStorage: {module: "extension-storage.js", symbol: "ExtensionStorageEngine"},
}
if (Svc.Prefs.get("engine.addresses.available", false)) {
result["Addresses"] = {
module: "resource://formautofill/FormAutofillSync.jsm",
symbol: "AddressesEngine",
};
}
if (Svc.Prefs.get("engine.creditcards.available", false)) {
result["CreditCards"] = {
module: "resource://formautofill/FormAutofillSync.jsm",
symbol: "CreditCardsEngine",
};
}
return result;
}

const STORAGE_INFO_TYPES = [INFO_COLLECTIONS,
INFO_COLLECTION_USAGE,
Expand Down Expand Up @@ -355,6 +370,8 @@ Sync11Service.prototype = {
async _registerEngines() {
this.engineManager = new EngineManager(this);

let engineModules = getEngineModules();

let engines = [];
// We allow a pref, which has no default value, to limit the engines
// which are registered. We expect only tests will use this.
Expand All @@ -363,7 +380,7 @@ Sync11Service.prototype = {
this._log.info("Registering custom set of engines", engines);
} else {
// default is all engines.
engines = Object.keys(ENGINE_MODULES);
engines = Object.keys(engineModules);
}

let declined = [];
Expand All @@ -379,11 +396,11 @@ Sync11Service.prototype = {
this.clientsEngine = clientsEngine;

for (let name of engines) {
if (!(name in ENGINE_MODULES)) {
if (!(name in engineModules)) {
this._log.info("Do not know about engine: " + name);
continue;
}
let {module, symbol} = ENGINE_MODULES[name];
let {module, symbol} = engineModules[name];
if (!module.includes(":")) {
module = "resource://services-sync/engines/" + module;
}
Expand Down
3 changes: 2 additions & 1 deletion services/sync/modules/telemetry.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ const EMPTY_UID = "0".repeat(32);

// The set of engines we record telemetry for - any other engines are ignored.
const ENGINES = new Set(["addons", "bookmarks", "clients", "forms", "history",
"passwords", "prefs", "tabs", "extension-storage"]);
"passwords", "prefs", "tabs", "extension-storage",
"addresses", "creditcards"]);

// A regex we can use to replace the profile dir in error messages. We use a
// regexp so we can simply replace all case-insensitive occurences.
Expand Down
13 changes: 13 additions & 0 deletions services/sync/services-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,25 @@ pref("services.sync.scheduler.fxa.singleDeviceInterval", 3600); // 1 hour

pref("services.sync.errorhandler.networkFailureReportTimeout", 1209600); // 2 weeks

// Note that new engines are typically added with a default of disabled, so
// when an existing sync user gets the Firefox upgrade that supports the engine
// it starts as disabled until the user has explicitly opted in.
// The sync "create account" process typically *will* offer these engines, so
// they may be flipped to enabled at that time.
pref("services.sync.engine.addons", true);
pref("services.sync.engine.addresses", false);
pref("services.sync.engine.bookmarks", true);
pref("services.sync.engine.creditcards", false);
pref("services.sync.engine.history", true);
pref("services.sync.engine.passwords", true);
pref("services.sync.engine.prefs", true);
pref("services.sync.engine.tabs", true);
pref("services.sync.engine.tabs.filteredUrls", "^(about:.*|resource:.*|chrome:.*|wyciwyg:.*|file:.*|blob:.*)$");

// The addresses and CC engines might not actually be available at all.
pref("services.sync.engine.addresses.available", false);
pref("services.sync.engine.creditcards.available", false);

// If true, add-on sync ignores changes to the user-enabled flag. This
// allows people to have the same set of add-ons installed across all
// profiles while maintaining different enabled states.
Expand Down Expand Up @@ -58,6 +69,8 @@ pref("services.sync.log.logger.engine.passwords", "Debug");
pref("services.sync.log.logger.engine.prefs", "Debug");
pref("services.sync.log.logger.engine.tabs", "Debug");
pref("services.sync.log.logger.engine.addons", "Debug");
pref("services.sync.log.logger.engine.addresses", "Debug");
pref("services.sync.log.logger.engine.creditcards", "Debug");
pref("services.sync.log.logger.engine.extension-storage", "Debug");
pref("services.sync.log.logger.engine.apps", "Debug");
pref("services.sync.log.logger.identity", "Debug");
Expand Down
8 changes: 4 additions & 4 deletions services/sync/tests/unit/head_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ add_task(async function head_setup() {
// Load mocking/stubbing library, sinon
// docs: http://sinonjs.org/releases/v2.3.2/
Cu.import("resource://gre/modules/Timer.jsm");
const {Loader} = Cu.import("resource://gre/modules/commonjs/toolkit/loader.js", {});
const loader = new Loader.Loader({
var {Loader} = Cu.import("resource://gre/modules/commonjs/toolkit/loader.js", {});
var loader = new Loader.Loader({
paths: {
"": "resource://testing-common/",
},
Expand All @@ -41,8 +41,8 @@ const loader = new Loader.Loader({
clearInterval,
},
});
const require = Loader.Require(loader, {id: ""});
const sinon = require("sinon-2.3.2");
var require = Loader.Require(loader, {id: ""});
var sinon = require("sinon-2.3.2");
// ================================================

XPCOMUtils.defineLazyGetter(this, "SyncPingSchema", function() {
Expand Down

0 comments on commit 7ddc727

Please sign in to comment.