File tree Expand file tree Collapse file tree 3 files changed +28
-10
lines changed Expand file tree Collapse file tree 3 files changed +28
-10
lines changed Original file line number Diff line number Diff line change @@ -938,15 +938,26 @@ Badger.prototype = {
938
938
) ;
939
939
} ,
940
940
941
+ /**
942
+ * Is community learning generally enabled,
943
+ * and is tab_id in a regular (not incognito) window?
944
+ */
945
+ isCommunityLearningEnabled ( tab_id ) {
946
+ return (
947
+ this . getSettings ( ) . getItem ( "shareLearning" ) &&
948
+ ! incognito . isIncognito ( tab_id )
949
+ ) ;
950
+ } ,
951
+
941
952
/**
942
953
* Is any kind of learning (local or community) enabled on this tab?
943
954
*
944
955
* TODO: should community learning happen in incognito tabs?
945
956
*/
946
957
isLearningEnabled ( tab_id ) {
947
958
return (
948
- this . getSettings ( ) . getItem ( "shareLearning" ) ||
949
- this . isLocalLearningEnabled ( tab_id )
959
+ this . isLocalLearningEnabled ( tab_id ) ||
960
+ this . isCommunityLearningEnabled ( tab_id )
950
961
) ;
951
962
} ,
952
963
Original file line number Diff line number Diff line change @@ -328,7 +328,7 @@ HeuristicBlocker.prototype = {
328
328
}
329
329
330
330
// If community learning is enabled, queue up a request to the EFF server
331
- if ( badger . getSettings ( ) . getItem ( "shareLearning" ) ) {
331
+ if ( badger . isCommunityLearningEnabled ( tab_id ) ) {
332
332
let page_fqdn = ( new URI ( this . tabUrls [ tab_id ] ) ) . host ;
333
333
this . shareTrackerInfo ( page_fqdn , tracker_fqdn , tracker_type ) ;
334
334
}
Original file line number Diff line number Diff line change @@ -25,23 +25,30 @@ function startListeners() {
25
25
chrome . tabs . onRemoved . addListener ( onRemovedListener ) ;
26
26
}
27
27
28
+ function isIncognito ( tab_id ) {
29
+ // if we don't have incognito data for whatever reason,
30
+ // default to "true"
31
+ if ( ! tabs . hasOwnProperty ( tab_id ) ) {
32
+ return true ;
33
+ }
34
+ // else, do not learn in incognito tabs
35
+ return tabs [ tab_id ] ;
36
+ }
37
+
28
38
function learningEnabled ( tab_id ) {
29
39
if ( badger . getSettings ( ) . getItem ( "learnInIncognito" ) ) {
30
40
// treat all pages as if they're not incognito
31
41
return true ;
32
42
}
33
- // if we don't have incognito data for whatever reason,
34
- // default to disabled
35
- if ( ! tabs . hasOwnProperty ( tab_id ) ) {
36
- return false ;
37
- }
38
- // else, do not learn in incognito tabs
39
- return ! tabs [ tab_id ] ;
43
+
44
+ // otherwise, return true if this tab is _not_ incognito
45
+ return ! isIncognito ( tab_id ) ;
40
46
}
41
47
42
48
/************************************** exports */
43
49
let exports = {
44
50
learningEnabled,
51
+ isIncognito,
45
52
startListeners,
46
53
} ;
47
54
return exports ;
You can’t perform that action at this time.
0 commit comments