Bug 211652 bookmarks.js fails on QueryInterface for nsIBookmarksService

r=caillon sr=bz
This commit is contained in:
timeless%mozdev.org 2007-05-05 04:36:29 +00:00
Родитель 98b45943a9
Коммит 9993a1ae48
3 изменённых файлов: 21 добавлений и 13 удалений

Просмотреть файл

@ -97,20 +97,28 @@ function initServices()
kPREFContractID = "@mozilla.org/preferences-service;1"; kPREFContractID = "@mozilla.org/preferences-service;1";
kPREFIID = Components.interfaces.nsIPrefService; kPREFIID = Components.interfaces.nsIPrefService;
PREF = Components.classes[kPREFContractID].getService(kPREFIID) try {
.getBranch(null); PREF = Components.classes[kPREFContractID].getService(kPREFIID)
.getBranch(null);
} catch (e) {}
kSOUNDContractID = "@mozilla.org/sound;1"; kSOUNDContractID = "@mozilla.org/sound;1";
kSOUNDIID = Components.interfaces.nsISound; kSOUNDIID = Components.interfaces.nsISound;
SOUND = Components.classes[kSOUNDContractID].createInstance(kSOUNDIID); try {
SOUND = Components.classes[kSOUNDContractID].createInstance(kSOUNDIID);
} catch (e) {}
kWINDOWContractID = "@mozilla.org/appshell/window-mediator;1"; kWINDOWContractID = "@mozilla.org/appshell/window-mediator;1";
kWINDOWIID = Components.interfaces.nsIWindowMediator; kWINDOWIID = Components.interfaces.nsIWindowMediator;
WINDOWSVC = Components.classes[kWINDOWContractID].getService(kWINDOWIID); try {
WINDOWSVC = Components.classes[kWINDOWContractID].getService(kWINDOWIID);
} catch (e) {}
kDSContractID = "@mozilla.org/widget/dragservice;1"; kDSContractID = "@mozilla.org/widget/dragservice;1";
kDSIID = Components.interfaces.nsIDragService; kDSIID = Components.interfaces.nsIDragService;
DS = Components.classes[kDSContractID].getService(kDSIID); try {
DS = Components.classes[kDSContractID].getService(kDSIID);
} catch (e) {}
} }
function initBMService() function initBMService()
@ -1309,7 +1317,7 @@ var BookmarksUtils = {
transaction.index[i] = RDFC.IndexOf(aSelection.item[i]); transaction.index[i] = RDFC.IndexOf(aSelection.item[i]);
} }
} }
if (aAction != "move" && !BookmarksUtils.all(transaction.isValid)) if (SOUND && aAction != "move" && !BookmarksUtils.all(transaction.isValid))
SOUND.beep(); SOUND.beep();
var isCancelled = !BookmarksUtils.any(transaction.isValid); var isCancelled = !BookmarksUtils.any(transaction.isValid);
if (!isCancelled) { if (!isCancelled) {
@ -1354,7 +1362,7 @@ var BookmarksUtils = {
transaction.parent[i] = aSelection.parent[i]; transaction.parent[i] = aSelection.parent[i];
} }
} }
if (!BookmarksUtils.all(transaction.isValid)) if (SOUND && !BookmarksUtils.all(transaction.isValid))
SOUND.beep(); SOUND.beep();
var isCancelled = !BookmarksUtils.any(transaction.isValid); var isCancelled = !BookmarksUtils.any(transaction.isValid);
if (!isCancelled) { if (!isCancelled) {
@ -1371,7 +1379,7 @@ var BookmarksUtils = {
var isCancelled = !BookmarksUtils.any(transaction.isValid); var isCancelled = !BookmarksUtils.any(transaction.isValid);
if (!isCancelled) { if (!isCancelled) {
BMSVC.transactionManager.doTransaction(transaction); BMSVC.transactionManager.doTransaction(transaction);
} else } else if (SOUND)
SOUND.beep(); SOUND.beep();
return !isCancelled; return !isCancelled;
}, },

Просмотреть файл

@ -447,7 +447,7 @@
<parameter name="aReverse"/> <parameter name="aReverse"/>
<body><![CDATA[ <body><![CDATA[
var confirmed; var confirmed;
if (PREF.getBoolPref("browser.bookmarks.confirm_sorting")) { if (PREF && PREF.getBoolPref("browser.bookmarks.confirm_sorting")) {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService); .getService(Components.interfaces.nsIPromptService);
var title = BookmarksUtils.getLocaleString("confirm_sorting_title"); var title = BookmarksUtils.getLocaleString("confirm_sorting_title");
@ -572,7 +572,7 @@
mOuter: this, mOuter: this,
canDropOn: function(index) canDropOn: function(index)
{ {
var dragSession = DS.getCurrentSession(); var dragSession = DS && DS.getCurrentSession();
if (!dragSession) if (!dragSession)
return false; return false;
var selection = BookmarksUtils.getSelectionFromXferData(dragSession); var selection = BookmarksUtils.getSelectionFromXferData(dragSession);
@ -580,7 +580,7 @@
}, },
canDropBeforeAfter: function(index, before) canDropBeforeAfter: function(index, before)
{ {
var dragSession = DS.getCurrentSession(); var dragSession = DS && DS.getCurrentSession();
if (!dragSession) if (!dragSession)
return false; return false;
var selection = BookmarksUtils.getSelectionFromXferData(dragSession); var selection = BookmarksUtils.getSelectionFromXferData(dragSession);
@ -595,7 +595,7 @@
}, },
onDrop: function(row, orientation) onDrop: function(row, orientation)
{ {
var dragSession = DS.getCurrentSession(); var dragSession = DS && DS.getCurrentSession();
if (!dragSession) if (!dragSession)
return; return;
var selection = BookmarksUtils.getSelectionFromXferData(dragSession); var selection = BookmarksUtils.getSelectionFromXferData(dragSession);

Просмотреть файл

@ -79,7 +79,7 @@ function find()
function findMostRecentWindow(aType, aURI, aParam) function findMostRecentWindow(aType, aURI, aParam)
{ {
var topWindow = WINDOWSVC.getMostRecentWindow(aType); var topWindow = WINDOWSVC && WINDOWSVC.getMostRecentWindow(aType);
if (!topWindow) gCreatingNewWindow = true; if (!topWindow) gCreatingNewWindow = true;
return topWindow || openDialog("chrome://communicator/content/bookmarks/bookmarksManager.xul", return topWindow || openDialog("chrome://communicator/content/bookmarks/bookmarksManager.xul",
"", "chrome,all,dialog=no", aParam); "", "chrome,all,dialog=no", aParam);