| OLD | NEW |
| 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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arg
uments); | 56 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arg
uments); |
| 57 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments); | 57 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments); |
| 58 if (converted.size() < 1) | 58 if (converted.size() < 1) |
| 59 { | 59 { |
| 60 v8::Isolate* isolate = arguments.GetIsolate(); | 60 v8::Isolate* isolate = arguments.GetIsolate(); |
| 61 return v8::ThrowException(Utils::ToV8String(isolate, | 61 return v8::ThrowException(Utils::ToV8String(isolate, |
| 62 "_triggerEvent expects at least one parameter")); | 62 "_triggerEvent expects at least one parameter")); |
| 63 } | 63 } |
| 64 std::string eventName = converted.front().AsString(); | 64 std::string eventName = converted.front().AsString(); |
| 65 converted.erase(converted.cbegin()); | 65 converted.erase(converted.cbegin()); |
| 66 jsEngine->TriggerEvent(eventName, converted); | 66 jsEngine->TriggerEvent(eventName, move(converted)); |
| 67 return v8::Undefined(); | 67 return v8::Undefined(); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 JsValue& GlobalJsObject::Setup(JsEngine& jsEngine, const AppInfo& appInfo, | 71 JsValue& GlobalJsObject::Setup(JsEngine& jsEngine, const AppInfo& appInfo, |
| 72 JsValue& obj) | 72 JsValue& obj) |
| 73 { | 73 { |
| 74 obj.SetProperty("setTimeout", jsEngine.NewCallback(::SetTimeoutCallback)); | 74 obj.SetProperty("setTimeout", jsEngine.NewCallback(::SetTimeoutCallback)); |
| 75 obj.SetProperty("_triggerEvent", jsEngine.NewCallback(::TriggerEventCallback))
; | 75 obj.SetProperty("_triggerEvent", jsEngine.NewCallback(::TriggerEventCallback))
; |
| 76 auto value = jsEngine.NewObject(); | 76 auto value = jsEngine.NewObject(); |
| 77 obj.SetProperty("_fileSystem", FileSystemJsObject::Setup(jsEngine, value)); | 77 obj.SetProperty("_fileSystem", FileSystemJsObject::Setup(jsEngine, value)); |
| 78 value = jsEngine.NewObject(); | 78 value = jsEngine.NewObject(); |
| 79 obj.SetProperty("_webRequest", WebRequestJsObject::Setup(jsEngine, value)); | 79 obj.SetProperty("_webRequest", WebRequestJsObject::Setup(jsEngine, value)); |
| 80 value = jsEngine.NewObject(); | 80 value = jsEngine.NewObject(); |
| 81 obj.SetProperty("console", ConsoleJsObject::Setup(jsEngine, value)); | 81 obj.SetProperty("console", ConsoleJsObject::Setup(jsEngine, value)); |
| 82 value = jsEngine.NewObject(); | 82 value = jsEngine.NewObject(); |
| 83 obj.SetProperty("_appInfo", AppInfoJsObject::Setup(appInfo, value)); | 83 obj.SetProperty("_appInfo", AppInfoJsObject::Setup(appInfo, value)); |
| 84 return obj; | 84 return obj; |
| 85 } | 85 } |
| OLD | NEW |