Merged revisions 3306,3309 from 1.0 branch via svnmerge

This commit is contained in:
Dan Stillman 2008-09-01 06:09:56 +00:00
parent a2e1a83de7
commit d662466ff6
3 changed files with 21 additions and 88 deletions

View file

@ -647,41 +647,41 @@ function ChromeExtensionHandler() {
// Proxy annotation icons
if (id.match(/^annotation.*\.(png|html|css|gif)$/)) {
var chromeURL = 'chrome://zotero/skin/' + id;
var file = Zotero.convertChromeURLToFile(chromeURL);
if (!file.exists()) {
Zotero.debug(file.path + " not found");
Components.utils.reportError(file.path + " not found");
return _errorChannel("File not found");
}
var ios = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService);
var uri = ios.newURI(chromeURL, null, null);
var chromeReg = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
.getService(Components.interfaces.nsIChromeRegistry);
var fileURI = chromeReg.convertChromeURL(uri);
}
else {
return _errorChannel("Attachment id not an integer");
}
}
if (!file) {
if (!fileURI) {
var item = Zotero.Items.get(id);
if (!item) {
return _errorChannel("Item not found");
}
var file = item.getFile();
}
if (!file) {
return _errorChannel("File not found");
}
if (fileName) {
file = file.parent;
file.append(fileName);
if (!file.exists()) {
if (!file) {
return _errorChannel("File not found");
}
if (fileName) {
file = file.parent;
file.append(fileName);
if (!file.exists()) {
return _errorChannel("File not found");
}
}
}
var ph = Components.classes["@mozilla.org/network/protocol;1?name=file"].
createInstance(Components.interfaces.nsIFileProtocolHandler);
var fileURI = ph.newFileURI(file);
if (!fileURI) {
var fileURI = ph.newFileURI(file);
}
var channel = ioService.newChannelFromURI(fileURI);
return channel;
}