зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bug 201013. Move bookmarks transaction manager to bookmarks service.
Fixes also bug 199364 and 200771. r=pch, sr=jag
This commit is contained in:
Родитель
b2e012cf65
Коммит
86a16d7fd5
|
@ -43,6 +43,7 @@
|
|||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIRDFResource;
|
||||
interface nsITransactionManager;
|
||||
|
||||
[scriptable, uuid(a82e9300-e4af-11d2-8fdf-0008c70adc7b)]
|
||||
interface nsIBookmarksService : nsISupports
|
||||
|
@ -89,6 +90,8 @@ interface nsIBookmarksService : nsISupports
|
|||
wstring getLastCharset(in string aURL);
|
||||
|
||||
void importSystemBookmarks(in nsIRDFResource aParentFolder);
|
||||
|
||||
readonly attribute nsITransactionManager transactionManager;
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
|
|
@ -68,8 +68,6 @@ var kWINDOWContractID;
|
|||
var kWINDOWIID;
|
||||
var WINDOWSVC;
|
||||
|
||||
var gBMtxmgr;
|
||||
|
||||
// should be moved in a separate file
|
||||
function initServices()
|
||||
{
|
||||
|
@ -382,13 +380,13 @@ var BookmarksCommand = {
|
|||
|
||||
undoBookmarkTransaction: function ()
|
||||
{
|
||||
gBMtxmgr.undoTransaction();
|
||||
BMSVC.transactionManager.undoTransaction();
|
||||
BookmarksUtils.flushDataSource();
|
||||
},
|
||||
|
||||
redoBookmarkTransaction: function ()
|
||||
{
|
||||
gBMtxmgr.redoTransaction();
|
||||
BMSVC.transactionManager.redoTransaction();
|
||||
BookmarksUtils.flushDataSource();
|
||||
},
|
||||
|
||||
|
@ -676,7 +674,7 @@ var BookmarksCommand = {
|
|||
}
|
||||
var isCancelled = !BookmarksUtils.any(transaction.isValid)
|
||||
if (!isCancelled) {
|
||||
gBMtxmgr.doTransaction(transaction);
|
||||
BMSVC.transactionManager.doTransaction(transaction);
|
||||
BookmarksUtils.flushDataSource();
|
||||
}
|
||||
},
|
||||
|
@ -1297,7 +1295,7 @@ var BookmarksUtils = {
|
|||
SOUND.beep();
|
||||
var isCancelled = !BookmarksUtils.any(transaction.isValid)
|
||||
if (!isCancelled) {
|
||||
gBMtxmgr.doTransaction(transaction)
|
||||
BMSVC.transactionManager.doTransaction(transaction);
|
||||
if (aAction != "move")
|
||||
BookmarksUtils.flushDataSource();
|
||||
}
|
||||
|
@ -1348,7 +1346,7 @@ var BookmarksUtils = {
|
|||
SOUND.beep();
|
||||
var isCancelled = !BookmarksUtils.any(transaction.isValid)
|
||||
if (!isCancelled) {
|
||||
gBMtxmgr.doTransaction(transaction);
|
||||
BMSVC.transactionManager.doTransaction(transaction);
|
||||
BookmarksUtils.flushDataSource();
|
||||
}
|
||||
return !isCancelled;
|
||||
|
@ -1360,7 +1358,7 @@ var BookmarksUtils = {
|
|||
var transaction = new BookmarkMoveTransaction(aAction, aSelection, aTarget);
|
||||
var isCancelled = !BookmarksUtils.any(transaction.isValid);
|
||||
if (!isCancelled) {
|
||||
gBMtxmgr.doTransaction(transaction);
|
||||
BMSVC.transactionManager.doTransaction(transaction);
|
||||
} else
|
||||
SOUND.beep();
|
||||
return !isCancelled;
|
||||
|
@ -1481,35 +1479,6 @@ var BookmarksUtils = {
|
|||
setTimeout(function () {remoteDS.Flush()}, 100);
|
||||
},
|
||||
|
||||
getTransactionManager: function ()
|
||||
{
|
||||
var windows = WINDOWSVC.getEnumerator(null);
|
||||
while(windows.hasMoreElements()) {
|
||||
var w = windows.getNext();
|
||||
if (w.gBMtxmgr)
|
||||
return w.gBMtxmgr;
|
||||
}
|
||||
|
||||
// Create a TransactionManager object:
|
||||
gBMtxmgr = Components.classes["@mozilla.org/transactionmanager;1"]
|
||||
.createInstance(Components.interfaces.nsITransactionManager);
|
||||
if (!gBMtxmgr) {
|
||||
dump("Failed to create the Bookmark Transaction Manager!\n");
|
||||
return null;
|
||||
}
|
||||
this.dispatchTransactionManager();
|
||||
return gBMtxmgr;
|
||||
},
|
||||
|
||||
dispatchTransactionManager: function ()
|
||||
{
|
||||
var windows = WINDOWSVC.getEnumerator(null);
|
||||
while(windows.hasMoreElements()) {
|
||||
var w = windows.getNext();
|
||||
w.gBMtxmgr = gBMtxmgr;
|
||||
}
|
||||
},
|
||||
|
||||
addBookmarkForTabBrowser: function( aTabBrowser, aSelect )
|
||||
{
|
||||
var tabsInfo = [];
|
||||
|
@ -1593,7 +1562,6 @@ var BookmarksUtils = {
|
|||
function BookmarkInsertTransaction (aAction)
|
||||
{
|
||||
this.wrappedJSObject = this;
|
||||
this.txmgr = BookmarksUtils.getTransactionManager();
|
||||
this.type = "insert";
|
||||
this.action = aAction;
|
||||
this.item = null;
|
||||
|
@ -1645,7 +1613,6 @@ BookmarkInsertTransaction.prototype =
|
|||
function BookmarkRemoveTransaction (aAction)
|
||||
{
|
||||
this.wrappedJSObject = this;
|
||||
this.txmgr = BookmarksUtils.getTransactionManager();
|
||||
this.type = "remove";
|
||||
this.action = aAction;
|
||||
this.item = null;
|
||||
|
@ -1697,7 +1664,6 @@ BookmarkRemoveTransaction.prototype =
|
|||
function BookmarkMoveTransaction (aAction, aSelection, aTarget)
|
||||
{
|
||||
this.wrappedJSObject = this;
|
||||
this.txmgr = BookmarksUtils.getTransactionManager();
|
||||
this.type = "move";
|
||||
this.action = aAction;
|
||||
this.selection = aSelection;
|
||||
|
@ -1729,7 +1695,6 @@ BookmarkMoveTransaction.prototype =
|
|||
function BookmarkImportTransaction (aAction)
|
||||
{
|
||||
this.wrappedJSObject = this;
|
||||
this.txmgr = BookmarksUtils.getTransactionManager();
|
||||
this.type = "import";
|
||||
this.action = aAction;
|
||||
this.item = [];
|
||||
|
|
|
@ -63,8 +63,6 @@ function Startup()
|
|||
|
||||
windowNode.setAttribute("title", titleString);
|
||||
|
||||
gBMtxmgr = BookmarksUtils.getTransactionManager();
|
||||
|
||||
document.getElementById("CommandUpdate_Bookmarks").setAttribute("commandupdater","true");
|
||||
bookmarksView.tree.focus();
|
||||
|
||||
|
|
|
@ -908,11 +908,10 @@
|
|||
<implementation>
|
||||
<constructor>
|
||||
// Adding the transaction listener
|
||||
gBMtxmgr = BookmarksUtils.getTransactionManager();
|
||||
gBMtxmgr.AddListener(this.bookmarkTreeTransactionListener)
|
||||
BMSVC.transactionManager.AddListener(this.bookmarkTreeTransactionListener);
|
||||
</constructor>
|
||||
<destructor>
|
||||
gBMtxmgr.RemoveListener(this.bookmarkTreeTransactionListener)
|
||||
BMSVC.transactionManager.RemoveListener(this.bookmarkTreeTransactionListener);
|
||||
</destructor>
|
||||
<field name="clickCount">2</field>
|
||||
</implementation>
|
||||
|
@ -969,9 +968,6 @@
|
|||
</tree>
|
||||
</xbl:content>
|
||||
<implementation>
|
||||
<constructor>
|
||||
gBMtxmgr = BookmarksUtils.getTransactionManager();
|
||||
</constructor>
|
||||
<field name="clickCount">1</field>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
@ -1002,9 +998,6 @@
|
|||
</tree>
|
||||
</xbl:content>
|
||||
<implementation>
|
||||
<constructor>
|
||||
gBMtxmgr = BookmarksUtils.getTransactionManager();
|
||||
</constructor>
|
||||
<field name="clickCount">2</field>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
|
|
@ -44,6 +44,7 @@ REQUIRES = xpcom \
|
|||
webshell \
|
||||
windowwatcher \
|
||||
unicharutil \
|
||||
txmgr \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = nsBookmarksService.cpp
|
||||
|
|
|
@ -1627,6 +1627,9 @@ nsBookmarksService::Init()
|
|||
nsICache::STREAM_BASED, getter_AddRefs(mCacheSession));
|
||||
}
|
||||
|
||||
mTransactionManager = do_CreateInstance(NS_TRANSACTIONMANAGER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
/* create a URL for the string resource file */
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
if (NS_SUCCEEDED(rv = mNetService->NewURI(bookmark_properties, nsnull, nsnull,
|
||||
|
@ -3395,6 +3398,16 @@ nsBookmarksService::HandleSystemBookmarks(nsIRDFNode* aNode)
|
|||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBookmarksService::GetTransactionManager(nsITransactionManager** aTransactionManager)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aTransactionManager);
|
||||
|
||||
NS_ADDREF(*aTransactionManager = mTransactionManager);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIRDFDataSource
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include "nsIIOService.h"
|
||||
#include "nsICacheService.h"
|
||||
#include "nsICacheSession.h"
|
||||
#include "nsITransactionManager.h"
|
||||
|
||||
class nsIOutputStream;
|
||||
|
||||
|
@ -82,6 +83,7 @@ protected:
|
|||
nsCOMPtr<nsIIOService> mNetService;
|
||||
nsCOMPtr<nsICacheService> mCacheService;
|
||||
nsCOMPtr<nsICacheSession> mCacheSession;
|
||||
nsCOMPtr<nsITransactionManager> mTransactionManager;
|
||||
|
||||
PRUint32 htmlSize;
|
||||
PRInt32 mUpdateBatchNest;
|
||||
|
|
|
@ -55,6 +55,7 @@ REQUIRES = xpcom \
|
|||
webshell \
|
||||
appshell \
|
||||
browser \
|
||||
txmgr \
|
||||
$(NULL)
|
||||
|
||||
ifndef MOZ_PHOENIX
|
||||
|
|
Загрузка…
Ссылка в новой задаче