nts.ID("{74b89fb0-f200-4ae8-a3ec-dd164117f6de}"), QueryInterface: ChromeUtils.generateQI([ "nsIObserver", "nsISupportsWeakReference", ]), get Weave() { const { Weave } = ChromeUtils.importESModule( "resource://services-sync/main.sys.mjs" ); return Weave; }, ensureLoaded() { // Side-effect of accessing the service is that it is instantiated. this.Weave.Service; }, whenLoaded() { if (this.ready) { return Promise.resolve(); } let onReadyPromise = new Promise(resolve => { Services.obs.addObserver(function onReady() { Services.obs.removeObserver(onReady, "weave:service:ready"); resolve(); }, "weave:service:ready"); }); this.ensureLoaded(); return onReadyPromise; }, init() { // Force Weave service to load if it hasn't triggered from overlays this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); this.timer.initWithCallback( { notify: () => { let isConfigured = false; // We only load more if it looks like Sync is configured. if (this.enabled) { // We have an associated FxAccount. So, do a more thorough check. // This will import a number of modules and thus increase memory // accordingly. We could potentially copy code performed by // this check into this file if our above code is yielding too // many false positives. var { Weave } = ChromeUtils.importESModule( "resource://services-sync/main.sys.mjs" ); isConfigured = Weave.Status.checkSetup() != lazy.CLIENT_NOT_CONFIGURED; } if (isConfigured) { this.ensureLoaded(); } }, }, 10000, Ci.nsITimer.TYPE_ONE_SHOT ); }, /** * Whether Sync appears to be enabled. * * This returns true if we have an associated FxA account and Sync is enabled. * * It does *not* perform a robust check to see if the client is working. * For that, you'll want to check Weave.Status.checkSetup(). */ get enabled() { return ( !!lazy.syncUsername && Services.prefs.getBoolPref("identity.fxaccounts.enabled") ); }, }; export function AboutWeaveLog() {} AboutWeaveLog.prototype = { classID: Components.ID("{d28f8a0b-95da-48f4-b712-caf37097be41}"), QueryInterface: ChromeUtils.generateQI([ "nsIAboutModule", "nsISupportsWeakReference", ]), getURIFlags() { return 0; }, newChannel(aURI, aLoadInfo) { let dir = lazy.FileUtils.getDir("ProfD", ["weave", "logs"]); try { dir.create(Ci.nsIFile.DIRECTORY_TYPE, lazy.FileUtils.PERMS_DIRECTORY); } catch (ex) { if (ex.result != Cr.NS_ERROR_FILE_ALREADY_EXISTS) { throw ex; } // Ignore the exception due to a directory that already exists. } let uri = Services.io.newFileURI(dir); let channel = Services.io.newChannelFromURIWithLoadInfo(uri, aLoadInfo); channel.originalURI = aURI; // Ensure that the about page has the same privileges as a regular directory // view. That way links to files can be opened. make sure we use the correct // origin attributes when creating the principal for accessing the // about:sync-log data. let principal = Services.scriptSecurityManager.createContentPrincipal( uri, aLoadInfo.originAttributes ); channel.owner = principal; return channel; }, }; PK