Remove all uses of Zotero.isStandalone

(View diff with -w)
This commit is contained in:
Dan Stillman 2023-07-11 05:34:04 -04:00
parent 4b7a1e8607
commit 8d3f874e64
7 changed files with 245 additions and 316 deletions

View file

@ -982,7 +982,7 @@ Zotero.DataDirectory = {
false, false,
null, null,
// Don't show message in a popup in Standalone if pane isn't ready // Don't show message in a popup in Standalone if pane isn't ready
Zotero.isStandalone true
); );
} }
catch (e) { catch (e) {
@ -1005,7 +1005,7 @@ Zotero.DataDirectory = {
// Clear status line from progress meter // Clear status line from progress meter
try { try {
Zotero.showZoteroPaneProgressMeter("", false, null, Zotero.isStandalone); Zotero.showZoteroPaneProgressMeter("", false, null, true);
} }
catch (e) { catch (e) {
Zotero.logError(e); Zotero.logError(e);

View file

@ -70,16 +70,14 @@ Zotero.Debug = new function () {
this.storing = _store; this.storing = _store;
this.updateEnabled(); this.updateEnabled();
if (Zotero.isStandalone) { // Enable dump() from window (non-XPCOM) scopes when terminal or viewer logging is enabled.
// Enable dump() from window (non-XPCOM) scopes when terminal or viewer logging is enabled. // (These will always go to the terminal, even in viewer mode.)
// (These will always go to the terminal, even in viewer mode.) Zotero.Prefs.set('browser.dom.window.dump.enabled', _console || _consoleViewer || Zotero.test, true);
Zotero.Prefs.set('browser.dom.window.dump.enabled', _console || _consoleViewer || Zotero.test, true);
if (_consoleViewer) {
if (_consoleViewer) { setTimeout(function () {
setTimeout(function () { Zotero.openInViewer("chrome://zotero/content/debugViewer.html");
Zotero.openInViewer("chrome://zotero/content/debugViewer.html"); }, 1000);
}, 1000);
}
} }
} }

View file

@ -949,8 +949,7 @@ Zotero.HTTP = new function() {
* to wait for proxy authentication can wait for that promise. * to wait for proxy authentication can wait for that promise.
*/ */
this.triggerProxyAuth = function () { this.triggerProxyAuth = function () {
if (!Zotero.isStandalone if (!Zotero.Prefs.get("triggerProxyAuthentication")
|| !Zotero.Prefs.get("triggerProxyAuthentication")
|| Zotero.HTTP.browserIsOffline()) { || Zotero.HTTP.browserIsOffline()) {
Zotero.proxyAuthComplete = Zotero.Promise.resolve(); Zotero.proxyAuthComplete = Zotero.Promise.resolve();
return false; return false;

View file

@ -92,8 +92,7 @@ Zotero.Profile = {
/** /**
* Get the path to the Profiles directory of the other app from this one (Firefox or Zotero), * Get the path to the Firefox Profiles directory, which may or may not exist
* which may or may not exist
* *
* @return {String|null} - Path, or null if none due to filesystem location * @return {String|null} - Path, or null if none due to filesystem location
*/ */
@ -103,26 +102,14 @@ Zotero.Profile = {
return null; return null;
} }
if (Zotero.isStandalone) { if (Zotero.isWin) {
if (Zotero.isWin) { dir = OS.Path.join(OS.Path.dirname(dir), "Mozilla", "Firefox");
dir = OS.Path.join(OS.Path.dirname(dir), "Mozilla", "Firefox"); }
} else if (Zotero.isMac) {
else if (Zotero.isMac) { dir = OS.Path.join(dir, "Firefox");
dir = OS.Path.join(dir, "Firefox");
}
else {
dir = OS.Path.join(dir, ".mozilla", "firefox");
}
} }
else { else {
if (Zotero.isWin) { dir = OS.Path.join(dir, ".mozilla", "firefox");
dir = OS.Path.join(OS.Path.dirname(dir), "Zotero", "Zotero");
}
else if (Zotero.isMac) {
dir = OS.Path.join(dir, "Zotero");
} else {
dir = OS.Path.join(dir, ".zotero", "zotero");
}
} }
return OS.Path.join(dir, "Profiles"); return OS.Path.join(dir, "Profiles");

View file

@ -348,7 +348,7 @@ Zotero.Schema = new function(){
}, 250); }, 250);
} }
} }
}.bind(this), Zotero.isStandalone ? 1000 : 0); }.bind(this), 1000);
}); });
return updated; return updated;
@ -928,37 +928,10 @@ Zotero.Schema = new function(){
// Get path to add-on // Get path to add-on
// Synchronous in Standalone var installLocation = Components.classes["@mozilla.org/file/directory_service;1"]
if (Zotero.isStandalone) { .getService(Components.interfaces.nsIProperties)
var installLocation = Components.classes["@mozilla.org/file/directory_service;1"] .get("AChrom", Components.interfaces.nsIFile).parent;
.getService(Components.interfaces.nsIProperties) installLocation.append("omni.ja");
.get("AChrom", Components.interfaces.nsIFile).parent;
installLocation.append("omni.ja");
}
// Asynchronous in Firefox
else {
let resolve, reject;
let promise = new Zotero.Promise(function () {
resolve = arguments[0];
reject = arguments[1];
});
Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonByID(
ZOTERO_CONFIG.GUID,
function (addon) {
try {
installLocation = addon.getResourceURI()
.QueryInterface(Components.interfaces.nsIFileURL).file;
}
catch (e) {
reject(e);
return;
}
resolve();
}
);
await promise;
}
installLocation = installLocation.path; installLocation = installLocation.path;
let initOpts = { fromSchemaUpdate: true }; let initOpts = { fromSchemaUpdate: true };

View file

@ -209,23 +209,9 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
this.platformMajorVersion = parseInt(this.platformVersion.match(/^[0-9]+/)[0]); this.platformMajorVersion = parseInt(this.platformVersion.match(/^[0-9]+/)[0]);
this.isFx = true; this.isFx = true;
this.isClient = true; this.isClient = true;
this.isStandalone = Services.appinfo.ID == ZOTERO_CONFIG['GUID']; this.isStandalone = true;
if (Zotero.isStandalone) { Zotero.version = Services.appinfo.version;
var version = Services.appinfo.version;
}
else {
let deferred = Zotero.Promise.defer();
Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonByID(
ZOTERO_CONFIG.GUID,
function (addon) {
deferred.resolve(addon.version);
}
);
var version = await deferred.promise;
}
Zotero.version = version;
Zotero.isDevBuild = Zotero.version.includes('beta') Zotero.isDevBuild = Zotero.version.includes('beta')
|| Zotero.version.includes('dev') || Zotero.version.includes('dev')
|| Zotero.version.includes('SOURCE'); || Zotero.version.includes('SOURCE');
@ -244,14 +230,21 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
// Browser // Browser
Zotero.browser = "g"; Zotero.browser = "g";
if (this.isWin) {
let branch = Services.prefs.getBranch("toolkit.startup.");
if (branch.getUserPref('recent_crashes') > 2) {
branch.clearUserPref('recent_crashes');
}
}
Zotero.Intl.init(); Zotero.Intl.init();
if (this.restarting) return; if (this.restarting) return;
await Zotero.Prefs.init(); await Zotero.Prefs.init();
Zotero.Debug.init(options && options.forceDebugLog); Zotero.Debug.init(options && options.forceDebugLog);
// Make sure that Zotero Standalone is not running as root // Make sure that Zotero isn't running as root
if(Zotero.isStandalone && !Zotero.isWin) _checkRoot(); if (!Zotero.isWin) _checkRoot();
if (!_checkExecutableLocation()) { if (!_checkExecutableLocation()) {
return; return;
@ -405,7 +398,7 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
return false; return false;
} }
if (Zotero.isStandalone) Zotero.Standalone.init(); Zotero.Standalone.init();
await Zotero.initComplete(); await Zotero.initComplete();
}; };
@ -545,55 +538,53 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
try { try {
// Require >=2.1b3 database to ensure proper locking // Require >=2.1b3 database to ensure proper locking
if (Zotero.isStandalone) { let dbSystemVersion = yield Zotero.Schema.getDBVersion('system');
let dbSystemVersion = yield Zotero.Schema.getDBVersion('system'); if (dbSystemVersion > 0 && dbSystemVersion < 31) {
if (dbSystemVersion > 0 && dbSystemVersion < 31) { var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .createInstance(Components.interfaces.nsIPromptService);
.createInstance(Components.interfaces.nsIPromptService); var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING) + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING) + (ps.BUTTON_POS_2) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_2) * (ps.BUTTON_TITLE_IS_STRING) + ps.BUTTON_POS_2_DEFAULT;
+ ps.BUTTON_POS_2_DEFAULT; var index = ps.confirmEx(
var index = ps.confirmEx( null,
null, Zotero.getString('dataDir.incompatibleDbVersion.title'),
Zotero.getString('dataDir.incompatibleDbVersion.title'), Zotero.getString('dataDir.incompatibleDbVersion.text'),
Zotero.getString('dataDir.incompatibleDbVersion.text'), buttonFlags,
buttonFlags, Zotero.getString('general.useDefault'),
Zotero.getString('general.useDefault'), Zotero.getString('dataDir.chooseNewDataDirectory'),
Zotero.getString('dataDir.chooseNewDataDirectory'), Zotero.getString('general.quit'),
Zotero.getString('general.quit'), null,
null, {}
{} );
var quit = false;
// Default location
if (index == 0) {
Zotero.Prefs.set("useDataDir", false)
Services.startup.quit(
Components.interfaces.nsIAppStartup.eAttemptQuit
| Components.interfaces.nsIAppStartup.eRestart
); );
}
var quit = false; // Select new data directory
else if (index == 1) {
// Default location let dir = yield Zotero.DataDirectory.choose(true);
if (index == 0) { if (!dir) {
Zotero.Prefs.set("useDataDir", false)
Services.startup.quit(
Components.interfaces.nsIAppStartup.eAttemptQuit
| Components.interfaces.nsIAppStartup.eRestart
);
}
// Select new data directory
else if (index == 1) {
let dir = yield Zotero.DataDirectory.choose(true);
if (!dir) {
quit = true;
}
}
else {
quit = true; quit = true;
} }
if (quit) {
Services.startup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit);
}
throw true;
} }
else {
quit = true;
}
if (quit) {
Services.startup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit);
}
throw true;
} }
try { try {

View file

@ -328,10 +328,7 @@ function makeZoteroContext(isConnector) {
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/translate/src/" + rdfXpcomFiles[i] + ".js", zContext.Zotero.RDF, 'utf-8'); subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/translate/src/" + rdfXpcomFiles[i] + ".js", zContext.Zotero.RDF, 'utf-8');
} }
if(isStandalone()) { subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/standalone.js", zContext);
// If isStandalone, load standalone.js
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/standalone.js", zContext, 'utf-8');
}
// add connector-related properties // add connector-related properties
zContext.Zotero.isConnector = isConnector; zContext.Zotero.isConnector = isConnector;
@ -355,74 +352,66 @@ function ZoteroService() {
if (!zContext.Zotero.startupError) { if (!zContext.Zotero.startupError) {
zContext.Zotero.startupError = e.stack || e; zContext.Zotero.startupError = e.stack || e;
} }
if (!isStandalone()) {
throw e;
}
}) })
.then(function () { .then(function () {
if (isStandalone()) { if (zContext.Zotero.startupErrorHandler || zContext.Zotero.startupError) {
if (zContext.Zotero.startupErrorHandler || zContext.Zotero.startupError) { if (zContext.Zotero.startupErrorHandler) {
if (zContext.Zotero.startupErrorHandler) { zContext.Zotero.startupErrorHandler();
zContext.Zotero.startupErrorHandler();
}
else if (zContext.Zotero.startupError) {
// Try to repair the DB on the next startup, in case it helps resolve
// the error
try {
zContext.Zotero.Schema.setIntegrityCheckRequired(true);
}
catch (e) {}
try {
zContext.Zotero.startupError =
zContext.Zotero.Utilities.Internal.filterStack(
zContext.Zotero.startupError
);
}
catch (e) {}
let ps = Cc["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Ci.nsIPromptService);
let buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING);
// Get the stringbundle manually
let errorStr = "Error";
let quitStr = "Quit";
let checkForUpdateStr = "Check for Update";
try {
let src = 'chrome://zotero/locale/zotero.properties';
let stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService);
let stringBundle = stringBundleService.createBundle(src);
errorStr = stringBundle.GetStringFromName('general.error');
checkForUpdateStr = stringBundle.GetStringFromName('general.checkForUpdate');
quitStr = stringBundle.GetStringFromName('general.quit');
}
catch (e) {}
let index = ps.confirmEx(
null,
errorStr,
zContext.Zotero.startupError,
buttonFlags,
checkForUpdateStr,
quitStr,
null,
null,
{}
);
if (index == 0) {
Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
.getService(Components.interfaces.nsIWindowWatcher)
.openWindow(null, 'chrome://mozapps/content/update/updates.xul',
'updateChecker', 'chrome,centerscreen,modal', null);
}
}
zContext.Zotero.Utilities.Internal.quitZotero();
} }
return; else if (zContext.Zotero.startupError) {
// Try to repair the DB on the next startup, in case it helps resolve
// the error
try {
zContext.Zotero.Schema.setIntegrityCheckRequired(true);
}
catch (e) {}
try {
zContext.Zotero.startupError =
zContext.Zotero.Utilities.Internal.filterStack(
zContext.Zotero.startupError
);
}
catch (e) {}
let ps = Cc["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Ci.nsIPromptService);
let buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING);
// Get the stringbundle manually
let errorStr = "Error";
let quitStr = "Quit";
let checkForUpdateStr = "Check for Update";
try {
let src = 'chrome://zotero/locale/zotero.properties';
let stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService);
let stringBundle = stringBundleService.createBundle(src);
errorStr = stringBundle.GetStringFromName('general.error');
checkForUpdateStr = stringBundle.GetStringFromName('general.checkForUpdate');
quitStr = stringBundle.GetStringFromName('general.quit');
}
catch (e) {}
let index = ps.confirmEx(
null,
errorStr,
zContext.Zotero.startupError,
buttonFlags,
checkForUpdateStr,
quitStr,
null,
null,
{}
);
if (index == 0) {
Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
.getService(Components.interfaces.nsIWindowWatcher)
.openWindow(null, 'chrome://mozapps/content/update/updates.xul',
'updateChecker', 'chrome,centerscreen,modal', null);
}
}
zContext.Zotero.Utilities.Internal.quitZotero();
} }
zContext.Zotero.debug("Initialized in "+(Date.now() - start)+" ms");
isFirstLoadThisSession = false;
}); });
let cb; let cb;
@ -457,7 +446,6 @@ function addInitCallback(callback) {
} }
} }
var _isStandalone = null;
/** /**
* Determine whether Zotero Standalone is running * Determine whether Zotero Standalone is running
*/ */
@ -505,11 +493,6 @@ ZoteroCommandLineHandler.prototype = {
zInitOptions.forceDataDir = cmdLine.handleFlagWithParam("datadir", false); zInitOptions.forceDataDir = cmdLine.handleFlagWithParam("datadir", false);
// handler to open Zotero pane at startup in Zotero for Firefox
if (!isStandalone() && cmdLine.handleFlag("ZoteroPaneOpen", false)) {
zInitOptions.openPane = true;
}
if (cmdLine.handleFlag("ZoteroTest", false)) { if (cmdLine.handleFlag("ZoteroTest", false)) {
zInitOptions.test = true; zInitOptions.test = true;
} }
@ -535,126 +518,124 @@ ZoteroCommandLineHandler.prototype = {
zContext.Zotero.Integration.execCommand(agent, command, docId, templateVersion); zContext.Zotero.Integration.execCommand(agent, command, docId, templateVersion);
} }
if(isStandalone()) { var fileToOpen;
var fileToOpen; // Handle zotero:// and file URIs and prevent them from opening a new window
// Handle zotero:// and file URIs and prevent them from opening a new window var param = cmdLine.handleFlagWithParam("url", false);
var param = cmdLine.handleFlagWithParam("url", false); if (param) {
if (param) { cmdLine.preventDefault = true;
cmdLine.preventDefault = true;
var uri = cmdLine.resolveURI(param);
if (uri.schemeIs("zotero")) {
addInitCallback(function (Zotero) {
Zotero.uiReadyPromise
.then(function () {
// Check for existing window and focus it
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser");
if (win) {
win.focus();
win.ZoteroPane.loadURI(uri.spec)
}
});
});
}
// See below
else if (uri.schemeIs("file")) {
Components.utils.import("resource://gre/modules/osfile.jsm")
fileToOpen = OS.Path.fromFileURI(uri.spec)
}
else {
dump(`Not handling URL: ${uri.spec}\n\n`);
}
}
param = cmdLine.handleFlag("debugger", false); var uri = cmdLine.resolveURI(param);
if (param) { if (uri.schemeIs("zotero")) {
try {
let portOrPath = Services.prefs.getBranch('').getIntPref('devtools.debugger.remote-port');
const { DevToolsLoader } = ChromeUtils.import(
"resource://devtools/shared/loader/Loader.jsm"
);
const loader = new DevToolsLoader({
freshCompartment: true,
});
const { DevToolsServer } = loader.require("devtools/server/devtools-server");
const { SocketListener } = loader.require("devtools/shared/security/socket");
if (DevToolsServer.initialized) {
dump("Debugger server already initialized\n\n");
return;
}
DevToolsServer.init();
DevToolsServer.registerAllActors();
DevToolsServer.allowChromeProcess = true;
const socketOptions = { portOrPath };
const listener = new SocketListener(DevToolsServer, socketOptions);
await listener.open();
if (!DevToolsServer.listeningSockets) {
throw new Error("No listening sockets");
}
dump(`Debugger server started on ${portOrPath}\n\n`);
}
catch (e) {
dump(e + "\n\n");
Components.utils.reportError(e);
}
}
// In Fx49-based Mac Standalone, if Zotero is closed, an associated file is launched, and
// Zotero hasn't been opened before, a -file parameter is passed and two main windows open.
// Subsequent file openings when closed result in -url with file:// URLs (converted above)
// and don't result in two windows. Here we prevent the double window.
param = fileToOpen;
if (!param) {
param = cmdLine.handleFlagWithParam("file", false);
if (param && isMac()) {
cmdLine.preventDefault = true;
}
}
if (param) {
addInitCallback(function (Zotero) { addInitCallback(function (Zotero) {
// Wait to handle things that require the UI until after it's loaded
Zotero.uiReadyPromise Zotero.uiReadyPromise
.then(function () { .then(function () {
var file = Zotero.File.pathToFile(param); // Check for existing window and focus it
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
if(file.leafName.substr(-4).toLowerCase() === ".csl" .getService(Components.interfaces.nsIWindowMediator);
|| file.leafName.substr(-8).toLowerCase() === ".csl.txt") { var win = wm.getMostRecentWindow("navigator:browser");
// Install CSL file if (win) {
Zotero.Styles.install({ file: file.path }, file.path); win.focus();
} else { win.ZoteroPane.loadURI(uri.spec)
// Ask before importing
var checkState = {
value: Zotero.Prefs.get('import.createNewCollection.fromFileOpenHandler')
};
if (Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService)
.confirmCheck(null, Zotero.getString('ingester.importFile.title'),
Zotero.getString('ingester.importFile.text', [file.leafName]),
Zotero.getString('ingester.importFile.intoNewCollection'),
checkState)) {
Zotero.Prefs.set(
'import.createNewCollection.fromFileOpenHandler', checkState.value
);
// Perform file import in front window
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var browserWindow = wm.getMostRecentWindow("navigator:browser");
browserWindow.Zotero_File_Interface.importFile({
file,
createNewCollection: checkState.value
});
}
} }
}); });
}); });
} }
// See below
else if (uri.schemeIs("file")) {
Components.utils.import("resource://gre/modules/osfile.jsm")
fileToOpen = OS.Path.fromFileURI(uri.spec)
}
else {
dump(`Not handling URL: ${uri.spec}\n\n`);
}
}
param = cmdLine.handleFlag("debugger", false);
if (param) {
try {
let portOrPath = Services.prefs.getBranch('').getIntPref('devtools.debugger.remote-port');
const { DevToolsLoader } = ChromeUtils.import(
"resource://devtools/shared/loader/Loader.jsm"
);
const loader = new DevToolsLoader({
freshCompartment: true,
});
const { DevToolsServer } = loader.require("devtools/server/devtools-server");
const { SocketListener } = loader.require("devtools/shared/security/socket");
if (DevToolsServer.initialized) {
dump("Debugger server already initialized\n\n");
return;
}
DevToolsServer.init();
DevToolsServer.registerAllActors();
DevToolsServer.allowChromeProcess = true;
const socketOptions = { portOrPath };
const listener = new SocketListener(DevToolsServer, socketOptions);
await listener.open();
if (!DevToolsServer.listeningSockets) {
throw new Error("No listening sockets");
}
dump(`Debugger server started on ${portOrPath}\n\n`);
}
catch (e) {
dump(e + "\n\n");
Components.utils.reportError(e);
}
}
// In Fx49-based Mac Standalone, if Zotero is closed, an associated file is launched, and
// Zotero hasn't been opened before, a -file parameter is passed and two main windows open.
// Subsequent file openings when closed result in -url with file:// URLs (converted above)
// and don't result in two windows. Here we prevent the double window.
param = fileToOpen;
if (!param) {
param = cmdLine.handleFlagWithParam("file", false);
if (param && isMac()) {
cmdLine.preventDefault = true;
}
}
if (param) {
addInitCallback(function (Zotero) {
// Wait to handle things that require the UI until after it's loaded
Zotero.uiReadyPromise
.then(function () {
var file = Zotero.File.pathToFile(param);
if(file.leafName.substr(-4).toLowerCase() === ".csl"
|| file.leafName.substr(-8).toLowerCase() === ".csl.txt") {
// Install CSL file
Zotero.Styles.install({ file: file.path }, file.path);
} else {
// Ask before importing
var checkState = {
value: Zotero.Prefs.get('import.createNewCollection.fromFileOpenHandler')
};
if (Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService)
.confirmCheck(null, Zotero.getString('ingester.importFile.title'),
Zotero.getString('ingester.importFile.text', [file.leafName]),
Zotero.getString('ingester.importFile.intoNewCollection'),
checkState)) {
Zotero.Prefs.set(
'import.createNewCollection.fromFileOpenHandler', checkState.value
);
// Perform file import in front window
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var browserWindow = wm.getMostRecentWindow("navigator:browser");
browserWindow.Zotero_File_Interface.importFile({
file,
createNewCollection: checkState.value
});
}
}
});
});
} }
}, },