diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 8bd249abfa1..26cce8976a5 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -148,6 +148,14 @@ __defineSetter__("PluralForm", function (val) { return this.PluralForm = val; }); +#ifdef MOZ_SERVICES_SYNC +XPCOMUtils.defineLazyGetter(this, "Weave", function() { + let tmp = {}; + Cu.import("resource://services-sync/service.js", tmp); + return tmp.Weave; +}); +#endif + XPCOMUtils.defineLazyGetter(this, "PopupNotifications", function () { let tmp = {}; Cu.import("resource://gre/modules/PopupNotifications.jsm", tmp); diff --git a/browser/components/nsBrowserGlue.js b/browser/components/nsBrowserGlue.js index 7eccb5226df..0ca39bf8437 100644 --- a/browser/components/nsBrowserGlue.js +++ b/browser/components/nsBrowserGlue.js @@ -380,6 +380,29 @@ BrowserGlue.prototype = { temp.WinTaskbarJumpList.startup(); } #endif +#endif + +#ifdef MOZ_SERVICES_SYNC + // Assume that a non-zero value for services.sync.autoconnectDelay should override + if (Services.prefs.prefHasUserValue("services.sync.autoconnectDelay")) { + let prefDelay = Services.prefs.getIntPref("services.sync.autoconnectDelay"); + + if (prefDelay > 0) + return; + } + + // delays are in seconds + const MAX_DELAY = 300; + let delay = 3; + let enum = Services.wm.getEnumerator("navigator:browser"); + while (enum.hasMoreElements()) { + delay += enum.getNext().gBrowser.tabs.length; + } + delay = delay <= MAX_DELAY ? delay : MAX_DELAY; + + let syncTemp = {}; + Cu.import("resource://services-sync/service.js", syncTemp); + syncTemp.Weave.Service.delayedAutoConnect(delay); #endif },