Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/FilterEngine.cpp

Issue 5653480979038208: Issue 2325 - Add a way to set settings in libadblockplus for FRP and automatic updates (Closed)
Patch Set: Created April 17, 2015, 3:54 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« lib/updater.js ('K') | « lib/updater.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 params.push_back(shared_from_this()); 127 params.push_back(shared_from_this());
128 JsValuePtr result = func->Call(params); 128 JsValuePtr result = func->Call(params);
129 return result->AsBool(); 129 return result->AsBool();
130 } 130 }
131 131
132 bool Subscription::operator==(const Subscription& subscription) const 132 bool Subscription::operator==(const Subscription& subscription) const
133 { 133 {
134 return GetProperty("url")->AsString() == subscription.GetProperty("url")->AsSt ring(); 134 return GetProperty("url")->AsString() == subscription.GetProperty("url")->AsSt ring();
135 } 135 }
136 136
137 FilterEngine::FilterEngine(JsEnginePtr jsEngine) 137 FilterEngine::FilterEngine(JsEnginePtr jsEngine, bool firstRunDisabled, bool aut oUpdatesDisabled)
138 : jsEngine(jsEngine), initialized(false), firstRun(false), updateCheckId(0) 138 : jsEngine(jsEngine), initialized(false), firstRun(false), updateCheckId(0)
139 { 139 {
140 jsEngine->SetEventCallback("init", std::tr1::bind(&FilterEngine::InitDone, 140 jsEngine->SetEventCallback("init", std::tr1::bind(&FilterEngine::InitDone,
141 this, std::tr1::placeholders::_1)); 141 this, std::tr1::placeholders::_1));
142 142
143 { 143 {
144 // Lock the JS engine while we are loading scripts, no timeouts should fire 144 // Lock the JS engine while we are loading scripts, no timeouts should fire
145 // until we are done. 145 // until we are done.
146 const JsContext context(jsEngine); 146 const JsContext context(jsEngine);
147 jsEngine->Evaluate(std::string("var firstRunDisabled = ") + (firstRunDisable d ? "true;" : "false;"));
sergei 2015/04/21 12:35:24 Would it be better to add them at least as members
Eric 2015/05/15 19:36:13 Not particularly. Application info is a descriptio
148 jsEngine->Evaluate(std::string("var autoupdatesDisabled = ") + (autoUpdatesD isabled ? "true;" : "false;"));
Eric 2015/05/15 19:36:13 My suggestion to use name value pairs would change
149
147 for (int i = 0; !jsSources[i].empty(); i += 2) 150 for (int i = 0; !jsSources[i].empty(); i += 2)
148 jsEngine->Evaluate(jsSources[i + 1], jsSources[i]); 151 jsEngine->Evaluate(jsSources[i + 1], jsSources[i]);
149 } 152 }
150 153
151 // TODO: This should really be implemented via a conditional variable 154 // TODO: This should really be implemented via a conditional variable
152 while (!initialized) 155 while (!initialized)
153 ::Sleep(10); 156 ::Sleep(10);
154 } 157 }
155 158
156 namespace 159 namespace
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 } 418 }
416 419
417 int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2) 420 int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2)
418 { 421 {
419 JsValueList params; 422 JsValueList params;
420 params.push_back(jsEngine->NewValue(v1)); 423 params.push_back(jsEngine->NewValue(v1));
421 params.push_back(jsEngine->NewValue(v2)); 424 params.push_back(jsEngine->NewValue(v2));
422 JsValuePtr func = jsEngine->Evaluate("API.compareVersions"); 425 JsValuePtr func = jsEngine->Evaluate("API.compareVersions");
423 return func->Call(params)->AsInt(); 426 return func->Call(params)->AsInt();
424 } 427 }
OLDNEW
« lib/updater.js ('K') | « lib/updater.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld