| Left: | ||
| Right: | 
| OLD | NEW | 
|---|---|
| 1 #include <vector> | 1 #include <vector> | 
| 2 #include <stdexcept> | 2 #include <stdexcept> | 
| 3 | 3 | 
| 4 #include <AdblockPlus/JsEngine.h> | 4 #include <AdblockPlus/JsEngine.h> | 
| 5 #include <AdblockPlus/JsValue.h> | 5 #include <AdblockPlus/JsValue.h> | 
| 6 | 6 | 
| 7 #include "AppInfoJsObject.h" | 7 #include "AppInfoJsObject.h" | 
| 8 #include "ConsoleJsObject.h" | 8 #include "ConsoleJsObject.h" | 
| 9 #include "FileSystemJsObject.h" | 9 #include "FileSystemJsObject.h" | 
| 10 #include "GlobalJsObject.h" | 10 #include "GlobalJsObject.h" | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 } | 63 } | 
| 64 timeoutThread->Start(); | 64 timeoutThread->Start(); | 
| 65 | 65 | 
| 66 // We should actually return the timer ID here, which could be | 66 // We should actually return the timer ID here, which could be | 
| 67 // used via clearTimeout(). But since we don't seem to need | 67 // used via clearTimeout(). But since we don't seem to need | 
| 68 // clearTimeout(), we can save that for later. | 68 // clearTimeout(), we can save that for later. | 
| 69 return v8::Undefined(); | 69 return v8::Undefined(); | 
| 70 } | 70 } | 
| 71 } | 71 } | 
| 72 | 72 | 
| 73 v8::Handle<v8::ObjectTemplate> GlobalJsObject::Create( | 73 JsValuePtr GlobalJsObject::Setup(JsEngine& jsEngine, const AppInfo& appInfo, | 
| 74 const AppInfo& appInfo, JsEngine& jsEngine) | 74 JsValuePtr obj) | 
| 75 { | 75 { | 
| 76 const v8::Locker locker(v8::Isolate::GetCurrent()); | 76 obj->SetProperty("setTimeout", jsEngine.NewCallback(::SetTimeoutCallback)); | 
| 77 v8::HandleScope handleScope; | 77 obj->SetProperty("_fileSystem", | 
| 78 const v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); | 78 FileSystemJsObject::Setup(jsEngine, jsEngine.NewObject())); | 
| 
 
Felix Dahlke
2013/04/18 12:46:50
Why pass a new object in? Seems to make more sense
 
Wladimir Palant
2013/04/18 13:29:33
Merely for consistency. GlobaJsObject::Setup() can
 
 | |
| 79 const v8::Handle<v8::FunctionTemplate> setTimeoutFunction = | 79 obj->SetProperty("_webRequest", | 
| 80 v8::FunctionTemplate::New(SetTimeoutCallback, | 80 WebRequestJsObject::Setup(jsEngine, jsEngine.NewObject())); | 
| 81 v8::External::New(&jsEngine)); | 81 obj->SetProperty("console", | 
| 82 global->Set(v8::String::New("setTimeout"), setTimeoutFunction); | 82 ConsoleJsObject::Setup(jsEngine, jsEngine.NewObject())); | 
| 83 const v8::Handle<v8::ObjectTemplate> fileSystemObject = | 83 obj->SetProperty("_appInfo", | 
| 84 FileSystemJsObject::Create(jsEngine); | 84 AppInfoJsObject::Setup(jsEngine, appInfo, jsEngine.NewObject())); | 
| 85 global->Set(v8::String::New("_fileSystem"), fileSystemObject); | 85 return obj; | 
| 86 const v8::Handle<v8::ObjectTemplate> webRequestObject = | |
| 87 WebRequestJsObject::Create(jsEngine); | |
| 88 global->Set(v8::String::New("_webRequest"), webRequestObject); | |
| 89 const v8::Handle<v8::ObjectTemplate> consoleObject = | |
| 90 ConsoleJsObject::Create(jsEngine); | |
| 91 global->Set(v8::String::New("console"), consoleObject); | |
| 92 const v8::Handle<v8::ObjectTemplate> appInfoObject = | |
| 93 AppInfoJsObject::Create(appInfo); | |
| 94 global->Set(v8::String::New("_appInfo"), appInfoObject); | |
| 95 return handleScope.Close(global); | |
| 96 } | 86 } | 
| OLD | NEW |