Skip to content

Commit

Permalink
add tab host parameter to callbacks of learningEnabled and calls of i…
Browse files Browse the repository at this point in the history
…sLearningEnabled
  • Loading branch information
ablanathtanalba committed Oct 3, 2020
1 parent 06fc1e9 commit 7010c79
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -930,10 +930,10 @@ Badger.prototype = {
* and if tab_id is for an incognito window,
* is learning in incognito windows enabled?
*/
isLearningEnabled(tab_id) {
isLearningEnabled(tab_id, tab_host) {
return (
this.getSettings().getItem("learnLocally") &&
incognito.learningEnabled(tab_id)
incognito.learningEnabled(tab_id, tab_host)
);
},

Expand Down
7 changes: 1 addition & 6 deletions src/js/heuristicblocking.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ HeuristicBlocker.prototype = {
*/
heuristicBlockingAccounting: function (details, check_for_cookie_share) {
// ignore requests that are outside a tabbed window
if (details.tabId < 0 || !badger.isLearningEnabled(details.tabId)) {
if (details.tabId < 0 || !badger.isLearningEnabled(details.tabId, details.url)) {
return {};
}

Expand All @@ -122,11 +122,6 @@ HeuristicBlocker.prototype = {

let tab_origin = self.tabOrigins[details.tabId];

// ignore localhosts
if (window.isPrivateDomain(tab_origin)) {
return {};
}

// ignore first-party requests
if (!tab_origin || !utils.isThirdPartyDomain(request_origin, tab_origin)) {
return {};
Expand Down
6 changes: 3 additions & 3 deletions src/js/webrequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function onBeforeRequest(details) {
});

// if this is a heuristically- (not user-) blocked domain
if (action == constants.BLOCK && incognito.learningEnabled(tab_id)) {
if (action == constants.BLOCK && incognito.learningEnabled(tab_id, tab_host)) {
// check for DNT policy asynchronously
setTimeout(function () {
badger.checkForDNTPolicy(request_host);
Expand Down Expand Up @@ -966,7 +966,7 @@ function dispatcher(request, sender, sendResponse) {
frame_host = window.extractHostFromURL(request.frameUrl);

sendResponse(frame_host &&
badger.isLearningEnabled(sender.tab.id) &&
badger.isLearningEnabled(sender.tab.id, tab_host) &&
badger.isPrivacyBadgerEnabled(tab_host) &&
utils.isThirdPartyDomain(frame_host, tab_host));

Expand All @@ -977,7 +977,7 @@ function dispatcher(request, sender, sendResponse) {
let tab_host = window.extractHostFromURL(sender.tab.url);

sendResponse(
badger.isLearningEnabled(sender.tab.id) &&
badger.isLearningEnabled(sender.tab.id, tab_host) &&
badger.isPrivacyBadgerEnabled(tab_host));

break;
Expand Down

0 comments on commit 7010c79

Please sign in to comment.