зеркало из https://github.com/mozilla/gecko-dev.git
43 строки
1004 B
JavaScript
43 строки
1004 B
JavaScript
const {actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm");
|
|
const {ASRouter} = ChromeUtils.import("resource://activity-stream/lib/ASRouter.jsm");
|
|
|
|
/**
|
|
* @class ASRouterFeed - Connects ASRouter singleton (see above) to Activity Stream's
|
|
* store so that it can use the RemotePageManager.
|
|
*/
|
|
class ASRouterFeed {
|
|
constructor(options = {}) {
|
|
this.router = options.router || ASRouter;
|
|
}
|
|
|
|
async enable() {
|
|
if (!this.router.initialized) {
|
|
await this.router.init(
|
|
this.store._messageChannel.channel,
|
|
this.store.dbStorage.getDbTable("snippets"),
|
|
this.store.dispatch
|
|
);
|
|
}
|
|
}
|
|
|
|
disable() {
|
|
if (this.router.initialized) {
|
|
this.router.uninit();
|
|
}
|
|
}
|
|
|
|
onAction(action) {
|
|
switch (action.type) {
|
|
case at.INIT:
|
|
this.enable();
|
|
break;
|
|
case at.UNINIT:
|
|
this.disable();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
this.ASRouterFeed = ASRouterFeed;
|
|
|
|
const EXPORTED_SYMBOLS = ["ASRouterFeed"];
|