| OLD | NEW |
| 1 #include <vector> | 1 #include <vector> |
| 2 #include <stdexcept> | 2 #include <stdexcept> |
| 3 | 3 |
| 4 #include <AdblockPlus/JsEngine.h> | |
| 5 #include <AdblockPlus/JsValue.h> | 4 #include <AdblockPlus/JsValue.h> |
| 6 | 5 |
| 7 #include "AppInfoJsObject.h" | 6 #include "AppInfoJsObject.h" |
| 8 #include "ConsoleJsObject.h" | 7 #include "ConsoleJsObject.h" |
| 9 #include "FileSystemJsObject.h" | 8 #include "FileSystemJsObject.h" |
| 10 #include "GlobalJsObject.h" | 9 #include "GlobalJsObject.h" |
| 11 #include "ConsoleJsObject.h" | 10 #include "ConsoleJsObject.h" |
| 12 #include "WebRequestJsObject.h" | 11 #include "WebRequestJsObject.h" |
| 13 #include "Thread.h" | 12 #include "Thread.h" |
| 14 | 13 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 JsValueList functionArguments; | 46 JsValueList functionArguments; |
| 48 }; | 47 }; |
| 49 | 48 |
| 50 v8::Handle<v8::Value> SetTimeoutCallback(const v8::Arguments& arguments) | 49 v8::Handle<v8::Value> SetTimeoutCallback(const v8::Arguments& arguments) |
| 51 { | 50 { |
| 52 TimeoutThread* timeoutThread; | 51 TimeoutThread* timeoutThread; |
| 53 try | 52 try |
| 54 { | 53 { |
| 55 AdblockPlus::JsValueList converted = | 54 AdblockPlus::JsValueList converted = |
| 56 AdblockPlus::JsEngine::FromArguments(arguments) | 55 AdblockPlus::JsEngine::FromArguments(arguments) |
| 57 .ConvertArguments(arguments); | 56 ->ConvertArguments(arguments); |
| 58 timeoutThread = new TimeoutThread(converted); | 57 timeoutThread = new TimeoutThread(converted); |
| 59 } | 58 } |
| 60 catch (const std::exception& e) | 59 catch (const std::exception& e) |
| 61 { | 60 { |
| 62 return v8::ThrowException(v8::String::New(e.what())); | 61 return v8::ThrowException(v8::String::New(e.what())); |
| 63 } | 62 } |
| 64 timeoutThread->Start(); | 63 timeoutThread->Start(); |
| 65 | 64 |
| 66 // We should actually return the timer ID here, which could be | 65 // We should actually return the timer ID here, which could be |
| 67 // used via clearTimeout(). But since we don't seem to need | 66 // used via clearTimeout(). But since we don't seem to need |
| 68 // clearTimeout(), we can save that for later. | 67 // clearTimeout(), we can save that for later. |
| 69 return v8::Undefined(); | 68 return v8::Undefined(); |
| 70 } | 69 } |
| 71 } | 70 } |
| 72 | 71 |
| 73 JsValuePtr GlobalJsObject::Setup(JsEngine& jsEngine, const AppInfo& appInfo, | 72 JsValuePtr GlobalJsObject::Setup(JsEnginePtr jsEngine, const AppInfo& appInfo, |
| 74 JsValuePtr obj) | 73 JsValuePtr obj) |
| 75 { | 74 { |
| 76 obj->SetProperty("setTimeout", jsEngine.NewCallback(::SetTimeoutCallback)); | 75 obj->SetProperty("setTimeout", jsEngine->NewCallback(::SetTimeoutCallback)); |
| 77 obj->SetProperty("_fileSystem", | 76 obj->SetProperty("_fileSystem", |
| 78 FileSystemJsObject::Setup(jsEngine, jsEngine.NewObject())); | 77 FileSystemJsObject::Setup(jsEngine, jsEngine->NewObject())); |
| 79 obj->SetProperty("_webRequest", | 78 obj->SetProperty("_webRequest", |
| 80 WebRequestJsObject::Setup(jsEngine, jsEngine.NewObject())); | 79 WebRequestJsObject::Setup(jsEngine, jsEngine->NewObject())); |
| 81 obj->SetProperty("console", | 80 obj->SetProperty("console", |
| 82 ConsoleJsObject::Setup(jsEngine, jsEngine.NewObject())); | 81 ConsoleJsObject::Setup(jsEngine, jsEngine->NewObject())); |
| 83 obj->SetProperty("_appInfo", | 82 obj->SetProperty("_appInfo", |
| 84 AppInfoJsObject::Setup(jsEngine, appInfo, jsEngine.NewObject())); | 83 AppInfoJsObject::Setup(jsEngine, appInfo, jsEngine->NewObject())); |
| 85 return obj; | 84 return obj; |
| 86 } | 85 } |
| OLD | NEW |