Firefox Sync (Weave)でTabs from Other Computersから開いたタブをツリーにするようにした

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@6685 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2010-06-22 16:50:55 +00:00
parent 6870f26741
commit dd75958b3c
2 changed files with 51 additions and 2 deletions

View File

@ -1176,4 +1176,51 @@ TreeStyleTabService.overrideExtensionsDelayed = function TSTService_overrideExte
);
}
// Firefox Sync (Weave)
// http://www.mozilla.com/en-US/firefox/sync/
if ('gFxWeaveGlue' in window) {
let ns = {};
Components.utils.import('resource://weave/service.js', ns);
let engine = ns.Weave.Engines.get('tabs');
let listener = {
handleEvent : function(aEvent)
{
switch (aEvent.type)
{
case 'TabOpen':
let tab = aEvent.originalTarget
let b = TreeStyleTabService.getTabBrowserFromChild(tab);
if (b.selectedTab.linkedBrowser.currentURI.spec != 'about:sync-tabs')
return;
let uri = tab.getAttribute('label');
if (engine.locallyOpenTabMatchesURL(uri))
return;
for (let [guid, client] in Iterator(engine.getAllClients()))
{
if (client.tabs.some(function({ urlHistory }) {
return urlHistory[0] == uri;
})) {
let parent = b.selectedTab;
window.setTimeout(function() {
if (tab.parentNode && !b.treeStyleTab.getParentTab(tab))
b.treeStyleTab.attachTabTo(tab, parent);
}, 0);
return;
}
}
return;
case 'unload':
window.removeEventListener('TabOpen', this, true);
window.removeEventListener('unload', this, false);
return;
}
}
};
window.addEventListener('TabOpen', listener, true);
window.addEventListener('unload', listener, false);
}
};

View File

@ -4,8 +4,10 @@
Usage:
Components.utils.import('resource://my-modules/namespace.jsm');
var namespace = getNamespaceFor('mylibrary');
if (!namespace.func1) {
namespace.func1 = function() { ... };
namespace.func2 = function() { ... };
}
var EXPORTED_SYMBOLS = ['func1', 'func2'];
var func1 = namespace.func1;
var func2 = namespace.func2;