Removal of tab page counter code. Fixes #759
This commit is contained in:
parent
17f2781e07
commit
c69f37a2de
4 changed files with 1 additions and 78 deletions
|
@ -7,7 +7,6 @@ module.exports = {
|
||||||
"badge": true,
|
"badge": true,
|
||||||
"backgroundLogic": true,
|
"backgroundLogic": true,
|
||||||
"identityState": true,
|
"identityState": true,
|
||||||
"messageHandler": true,
|
"messageHandler": true
|
||||||
"tabPageCounter": true
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
"js/background/badge.js",
|
"js/background/badge.js",
|
||||||
"js/background/identityState.js",
|
"js/background/identityState.js",
|
||||||
"js/background/messageHandler.js",
|
"js/background/messageHandler.js",
|
||||||
"js/background/tabPageCounter.js",
|
|
||||||
"js/backdround/init.js"
|
"js/backdround/init.js"
|
||||||
]
|
]
|
||||||
-->
|
-->
|
||||||
|
@ -20,7 +19,6 @@
|
||||||
<script type="text/javascript" src="badge.js"></script>
|
<script type="text/javascript" src="badge.js"></script>
|
||||||
<script type="text/javascript" src="identityState.js"></script>
|
<script type="text/javascript" src="identityState.js"></script>
|
||||||
<script type="text/javascript" src="messageHandler.js"></script>
|
<script type="text/javascript" src="messageHandler.js"></script>
|
||||||
<script type="text/javascript" src="tabPageCounter.js"></script>
|
|
||||||
<script type="text/javascript" src="init.js"></script>
|
<script type="text/javascript" src="init.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -88,20 +88,17 @@ const messageHandler = {
|
||||||
if (tab.id === -1) {
|
if (tab.id === -1) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
tabPageCounter.initTabCounter(tab);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
browser.tabs.onRemoved.addListener((tabId) => {
|
browser.tabs.onRemoved.addListener((tabId) => {
|
||||||
if (tabId === -1) {
|
if (tabId === -1) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
tabPageCounter.sendTabCountAndDelete(tabId);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
browser.tabs.onActivated.addListener((info) => {
|
browser.tabs.onActivated.addListener((info) => {
|
||||||
assignManager.removeContextMenu();
|
assignManager.removeContextMenu();
|
||||||
browser.tabs.get(info.tabId).then((tab) => {
|
browser.tabs.get(info.tabId).then((tab) => {
|
||||||
tabPageCounter.initTabCounter(tab);
|
|
||||||
assignManager.calculateContextMenu(tab);
|
assignManager.calculateContextMenu(tab);
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -112,20 +109,6 @@ const messageHandler = {
|
||||||
this.onFocusChangedCallback(windowId);
|
this.onFocusChangedCallback(windowId);
|
||||||
});
|
});
|
||||||
|
|
||||||
browser.idle.onStateChanged.addListener((newState) => {
|
|
||||||
browser.tabs.query({}).then(tabs => {
|
|
||||||
for (let tab of tabs) { // eslint-disable-line prefer-const
|
|
||||||
if (newState === "idle") {
|
|
||||||
tabPageCounter.sendTabCountAndDelete(tab.id, "user-went-idle");
|
|
||||||
} else if (newState === "active" && tab.active) {
|
|
||||||
tabPageCounter.initTabCounter(tab);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).catch(e => {
|
|
||||||
throw e;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
browser.webRequest.onCompleted.addListener((details) => {
|
browser.webRequest.onCompleted.addListener((details) => {
|
||||||
if (details.frameId !== 0 || details.tabId === -1) {
|
if (details.frameId !== 0 || details.tabId === -1) {
|
||||||
return {};
|
return {};
|
||||||
|
@ -133,7 +116,6 @@ const messageHandler = {
|
||||||
assignManager.removeContextMenu();
|
assignManager.removeContextMenu();
|
||||||
|
|
||||||
browser.tabs.get(details.tabId).then((tab) => {
|
browser.tabs.get(details.tabId).then((tab) => {
|
||||||
tabPageCounter.incrementTabCount(tab);
|
|
||||||
assignManager.calculateContextMenu(tab);
|
assignManager.calculateContextMenu(tab);
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -160,7 +142,6 @@ const messageHandler = {
|
||||||
badge.displayBrowserActionBadge(currentWindow.incognito);
|
badge.displayBrowserActionBadge(currentWindow.incognito);
|
||||||
browser.tabs.query({active: true, windowId}).then((tabs) => {
|
browser.tabs.query({active: true, windowId}).then((tabs) => {
|
||||||
if (tabs && tabs[0]) {
|
if (tabs && tabs[0]) {
|
||||||
tabPageCounter.initTabCounter(tabs[0]);
|
|
||||||
assignManager.calculateContextMenu(tabs[0]);
|
assignManager.calculateContextMenu(tabs[0]);
|
||||||
}
|
}
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
const tabPageCounter = {
|
|
||||||
counters: {},
|
|
||||||
|
|
||||||
initTabCounter(tab) {
|
|
||||||
if (tab.id in this.counters) {
|
|
||||||
if (!("activity" in this.counters[tab.id])) {
|
|
||||||
this.counters[tab.id].activity = {
|
|
||||||
"cookieStoreId": tab.cookieStoreId,
|
|
||||||
"pageRequests": 0
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (!("tab" in this.counters[tab.id])) {
|
|
||||||
this.counters[tab.id].tab = {
|
|
||||||
"cookieStoreId": tab.cookieStoreId,
|
|
||||||
"pageRequests": 0
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.counters[tab.id] = {};
|
|
||||||
this.counters[tab.id].tab = {
|
|
||||||
"cookieStoreId": tab.cookieStoreId,
|
|
||||||
"pageRequests": 0
|
|
||||||
};
|
|
||||||
this.counters[tab.id].activity = {
|
|
||||||
"cookieStoreId": tab.cookieStoreId,
|
|
||||||
"pageRequests": 0
|
|
||||||
};
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
sendTabCountAndDelete(tabId, why = "user-closed-tab") {
|
|
||||||
if (!(this.counters[tabId])) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (why === "user-closed-tab" && this.counters[tabId].tab) {
|
|
||||||
// When we send the ping because the user closed the tab,
|
|
||||||
// delete both the 'tab' and 'activity' counters
|
|
||||||
delete this.counters[tabId];
|
|
||||||
} else if (why === "user-went-idle" && this.counters[tabId].activity) {
|
|
||||||
// When we send the ping because the user went idle,
|
|
||||||
// only reset the 'activity' counter
|
|
||||||
this.counters[tabId].activity = {
|
|
||||||
"cookieStoreId": this.counters[tabId].tab.cookieStoreId,
|
|
||||||
"pageRequests": 0
|
|
||||||
};
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
incrementTabCount(tab) {
|
|
||||||
this.initTabCounter(tab);
|
|
||||||
this.counters[tab.id].tab.pageRequests++;
|
|
||||||
this.counters[tab.id].activity.pageRequests++;
|
|
||||||
}
|
|
||||||
};
|
|
Loading…
Add table
Reference in a new issue