Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 #include <algorithm> | 18 #include <algorithm> |
19 #include <cctype> | 19 #include <cctype> |
20 #include <functional> | 20 #include <functional> |
21 #include <string> | 21 #include <string> |
22 | 22 |
23 #include <AdblockPlus/LogSystem.h> | |
Andrey Novikov
2013/06/18 11:48:28
Forgot to remove this :(
| |
24 #include <AdblockPlus.h> | 23 #include <AdblockPlus.h> |
25 #include "JsContext.h" | 24 #include "JsContext.h" |
26 #include "Thread.h" | 25 #include "Thread.h" |
27 | 26 |
28 using namespace AdblockPlus; | 27 using namespace AdblockPlus; |
29 | 28 |
30 extern std::string jsSources[]; | 29 extern std::string jsSources[]; |
31 | 30 |
32 Filter::Filter(JsValuePtr value) | 31 Filter::Filter(JsValuePtr value) |
33 : JsValue(value) | 32 : JsValue(value) |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 void FilterEngine::UpdateCheckDone(const std::string& eventName, FilterEngine::U pdaterCallback callback, JsValueList& params) | 273 void FilterEngine::UpdateCheckDone(const std::string& eventName, FilterEngine::U pdaterCallback callback, JsValueList& params) |
275 { | 274 { |
276 jsEngine->RemoveEventCallback(eventName); | 275 jsEngine->RemoveEventCallback(eventName); |
277 | 276 |
278 std::string error(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsSt ring() : ""); | 277 std::string error(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsSt ring() : ""); |
279 callback(error); | 278 callback(error); |
280 } | 279 } |
281 | 280 |
282 void FilterEngine::SetFilterChangeCallback(FilterEngine::FilterChangeCallback ca llback) | 281 void FilterEngine::SetFilterChangeCallback(FilterEngine::FilterChangeCallback ca llback) |
283 { | 282 { |
284 std::string eventName = "filterChange"; | 283 jsEngine->SetEventCallback("filterChange", std::tr1::bind(&FilterEngine::Filte rChanged, |
Wladimir Palant
2013/06/18 15:02:15
The event name isn't dynamic, no real point passin
| |
285 | 284 this, callback, std::tr1::placeholders::_1)); |
286 if (callback == 0) | 285 } |
287 jsEngine->RemoveEventCallback(eventName); | 286 |
288 else | 287 void FilterEngine::RemoveFilterChangeCallback() |
289 jsEngine->SetEventCallback(eventName, std::tr1::bind(&FilterEngine::FilterCh anged, | 288 { |
290 this, eventName, callback, std::tr1::placeholders::_1)); | 289 jsEngine->RemoveEventCallback("filterChange"); |
291 } | 290 } |
292 | 291 |
293 void FilterEngine::FilterChanged(const std::string& eventName, FilterEngine::Fil terChangeCallback callback, JsValueList& params) | 292 void FilterEngine::FilterChanged(FilterEngine::FilterChangeCallback callback, Js ValueList& params) |
294 { | 293 { |
295 AdblockPlus::LogSystemPtr log = jsEngine->GetLogSystem(); | 294 std::string action(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsS tring() : ""); |
Andrey Novikov
2013/06/18 11:48:28
Forgot to remove this :(
| |
296 std::string url(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsStri ng() : ""); | 295 JsValuePtr item(params.size() >= 2 ? params[1] : jsEngine->NewValue(false)); |
297 std::string status(params.size() >= 2 && !params[1]->IsNull() ? params[1]->AsS tring() : ""); | 296 callback(action, item); |
298 int64_t time(params.size() >= 3 && !params[2]->IsNull() ? params[2]->AsInt() : 0); | 297 } |
299 callback(url, status, time); | |
300 } | |
LEFT | RIGHT |