@@ -12,11 +12,21 @@ import { nextIdle } from '../core/decorators';
12
12
import pacemaker from '../core/services/pacemaker' ;
13
13
import { fetchJSON , fetchText , fetchTypedArray } from '../core/http' ;
14
14
import persistentMapFactory from '../core/persistence/map' ;
15
+ import { isMobile , isFirefox , isChromium , isEdge } from '../core/platform' ;
15
16
16
17
import logger from './logger' ;
17
18
import config from './config' ;
18
19
import getEnabledRegions from './regions' ;
19
20
21
+ const ENV = new Map ( [
22
+ [ 'ext_ghostery' , true ] ,
23
+ [ 'cap_html_filtering' , isFirefox ] ,
24
+ [ 'env_firefox' , isFirefox ] ,
25
+ [ 'env_chromium' , isChromium ] ,
26
+ [ 'env_edge' , isEdge ] ,
27
+ [ 'env_mobile' , isMobile ] ,
28
+ ] ) ;
29
+
20
30
/**
21
31
* Manages the adblocker WebExtensionEngine state. It allows to initialize, update,
22
32
* cache and reload the engine. It takes care of fetching and using the
@@ -329,7 +339,7 @@ export default class EngineManager {
329
339
// updated and `false` otherwise.
330
340
timer = this . stopwatch ( 'update engine (update)' , 'adblocker' ) ;
331
341
const cumulativeDiff = AdblockerLib . mergeDiffs ( diffs ) ;
332
- let updated = this . engine . updateFromDiff ( cumulativeDiff ) ;
342
+ let updated = this . engine . updateFromDiff ( cumulativeDiff , ENV ) ;
333
343
timer . stop ( ) ;
334
344
335
345
if ( updated === true ) {
@@ -384,6 +394,7 @@ export default class EngineManager {
384
394
timer = this . stopwatch ( 'deserialize engine from cache' , 'adblocker' ) ;
385
395
try {
386
396
this . engine = AdblockerLib . WebExtensionBlocker . deserialize ( serialized ) ;
397
+ this . engine . updateEnv ( ENV ) ;
387
398
} catch ( ex ) {
388
399
// In case there is a mismatch between the version of the code
389
400
// and the serialization format of the engine on disk, we might
@@ -429,6 +440,7 @@ export default class EngineManager {
429
440
timer = this . stopwatch ( 'deserialize remote engine' , 'adblocker' ) ;
430
441
try {
431
442
this . engine = AdblockerLib . WebExtensionBlocker . deserialize ( serialized ) ;
443
+ this . engine . updateEnv ( ENV ) ;
432
444
} catch ( ex ) {
433
445
logger . error ( 'exception while loading remote engine' , ex ) ;
434
446
return null ;
0 commit comments