Fixed some minor problems with TabEngine; identified places where TabEngine will need to use alternate methods to work on Fennec.
Fixed some minor problems with TabEngine; identified places where TabEngine will need to use alternate methods to work on Fennec.
--- a/services/sync/modules/engines/tabs.js
+++ b/services/sync/modules/engines/tabs.js
@@ -32,30 +32,29 @@
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
const EXPORTED_SYMBOLS = ['TabEngine'];
-const SESSION_STORE_KEY = "weave-tab-sync-id";
-
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://weave/util.js");
Cu.import("resource://weave/async.js");
Cu.import("resource://weave/engines.js");
Cu.import("resource://weave/stores.js");
Cu.import("resource://weave/trackers.js");
Cu.import("resource://weave/constants.js");
Cu.import("resource://weave/type_records/tabs.js");
+Cu.import("resource://weave/engines/clientData.js");
Function.prototype.async = Async.sugar;
function TabEngine() {
this._init();
}
TabEngine.prototype = {
__proto__: SyncEngine.prototype,
@@ -89,21 +88,21 @@ TabStore.prototype = {
_TabStore_init: function TabStore__init() {
dump("Initializing TabStore!!\n");
this._init();
this._readFromFile();
},
get _localClientGUID() {
- return Engines.get("clients").clientID;
+ return Clients.clientID;
},
get _localClientName() {
- return Engines.get("clients").clientName;
+ return Clients.clientName;
},
_writeToFile: function TabStore_writeToFile() {
// use JSON service to serialize the records...
this._log.debug("Writing out to file...");
let file = Utils.getProfileFile(
{path: this._filePath, autoCreate: true});
let jsonObj = {};
@@ -134,16 +133,17 @@ TabStore.prototype = {
this._remoteClients[id].id = id;
}
} catch (e) {
this._log.warn("Failed to load saved tabs file" + e);
}
},
get _sessionStore() {
+ // TODO: sessionStore seems to not exist on Fennec?
let sessionStore = Cc["@mozilla.org/browser/sessionstore;1"].
getService(Ci.nsISessionStore);
this.__defineGetter__("_sessionStore", function() { return sessionStore;});
return this._sessionStore;
},
get _json() {
let json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
@@ -212,17 +212,17 @@ TabStore.prototype = {
if (this._remoteClients[oldId]) {
let record = this._remoteClients[oldId];
record.id = newId;
delete this._remoteClients[oldId];
this._remoteClients[newId] = record;
}
},
- getAllIds: function TabStore_getAllIds() {
+ getAllIDs: function TabStore_getAllIds() {
this._log.debug("getAllIds called.");
let items = {};
items[ this._localClientGUID ] = true;
for (let id in this._remoteClients) {
items[id] = true;
}
return items;
},
@@ -286,17 +286,22 @@ TabTracker.prototype = {
ww.registerNotification(this);
},
observe: function TabTracker_observe(aSubject, aTopic, aData) {
dump("TabTracker spotted window open/close...\n");
let window = aSubject.QueryInterface(Ci.nsIDOMWindow);
// TODO: Not all windows have tabContainers. Fennec windows don't,
// for instance.
- let container = window.getBrowser().tabContainer;
+ if (! window.getBrowser)
+ return;
+ let browser = window.getBrowser();
+ if (! browser.tabContainer)
+ return;
+ let container = browser.tabContainer;
if (aTopic == "domwindowopened") {
container.addEventListener("TabOpen", this.onTabChanged, false);
container.addEventListener("TabClose", this.onTabChanged, false);
} else if (aTopic == "domwindowclosed") {
container.removeEventListener("TabOpen", this.onTabChanged, false);
container.removeEventListener("TabClose", this.onTabChanged, false);
}
},