| Index: src/FilterEngine.cpp |
| =================================================================== |
| --- a/src/FilterEngine.cpp |
| +++ b/src/FilterEngine.cpp |
| @@ -134,7 +134,8 @@ |
| return GetProperty("url")->AsString() == subscription.GetProperty("url")->AsString(); |
| } |
| -FilterEngine::FilterEngine(JsEnginePtr jsEngine) |
| +FilterEngine::FilterEngine(JsEnginePtr jsEngine, |
| + std::map<std::string, AdblockPlus::JsValuePtr> preconfiguredPrefs) |
| : jsEngine(jsEngine), initialized(false), firstRun(false), updateCheckId(0) |
| { |
| jsEngine->SetEventCallback("init", std::tr1::bind(&FilterEngine::InitDone, |
| @@ -144,6 +145,19 @@ |
| // Lock the JS engine while we are loading scripts, no timeouts should fire |
| // until we are done. |
| const JsContext context(jsEngine); |
| + |
| + // Set the preconfigured prefs |
| + JsValuePtr preconfiguredPrefsObject = jsEngine->NewObject(); |
| + for (std::map<std::string, AdblockPlus::JsValuePtr>::iterator it = |
| + preconfiguredPrefs.begin(); |
| + it != preconfiguredPrefs.end(); it++) |
| + { |
| + preconfiguredPrefsObject->SetProperty(it->first, it->second); |
| + } |
| + JsValuePtr globalJsObject = jsEngine->GetGlobalJsObject(); |
| + globalJsObject->SetProperty("_preconfiguredPrefs", preconfiguredPrefsObject); |
|
Eric
2015/06/10 17:48:16
Apart from initialization (where 'GetGlobalJsObjec
Felix Dahlke
2015/06/11 20:21:13
For the record: I asked for it this way. But Eric'
Oleksandr
2015/06/12 10:47:57
Done.
|
| + |
| + // Load adblockplus scripts |
| for (int i = 0; !jsSources[i].empty(); i += 2) |
| jsEngine->Evaluate(jsSources[i + 1], jsSources[i]); |
| } |