Index: src/JsEngine.cpp |
=================================================================== |
--- a/src/JsEngine.cpp |
+++ b/src/JsEngine.cpp |
@@ -16,6 +16,7 @@ |
*/ |
#include <AdblockPlus.h> |
+#include "FileSystemJsObject.h" |
#include "GlobalJsObject.h" |
#include "JsContext.h" |
#include "JsEngineInternal.h" |
@@ -111,14 +112,21 @@ |
const v8::Context::Scope contextScope(GetContextAsLocal()); |
auto globalObject = GetGlobalObject(); |
// Timeout |
- auto propertyName = AdblockPlus::Utils::ToV8String(GetIsolate(), "setTimeout"); |
- globalObject->Set(propertyName, MakeCallback(::CallbackForSetTimeout)); |
+ globalObject->Set(ToV8String("setTimeout"), MakeCallback(::CallbackForSetTimeout)); |
// Web request |
auto auxiliaryObject = v8::Object::New(); |
- propertyName = AdblockPlus::Utils::ToV8String(GetIsolate(), "GET"); |
- auxiliaryObject->Set(propertyName, MakeCallback(::GETCallback)); |
- propertyName = AdblockPlus::Utils::ToV8String(GetIsolate(), "_webRequest"); |
- globalObject->Set(propertyName, auxiliaryObject); |
+ auxiliaryObject->Set(ToV8String("GET"), MakeCallback(::GETCallback)); |
+ globalObject->Set(ToV8String("_webRequest"), auxiliaryObject); |
+ // File system I/O |
+ auxiliaryObject = v8::Object::New(); |
+ auxiliaryObject->Set(ToV8String("read"), MakeCallback(::ReadCallback)); |
+ auxiliaryObject->Set(ToV8String("write"), MakeCallback(::WriteCallback)); |
+ auxiliaryObject->Set(ToV8String("move"), MakeCallback(::MoveCallback)); |
+ auxiliaryObject->Set(ToV8String("remove"), MakeCallback(::RemoveCallback)); |
+ auxiliaryObject->Set(ToV8String("stat"), MakeCallback(::StatCallback)); |
+ auxiliaryObject->Set(ToV8String("resolve"), MakeCallback(::ResolveCallback)); |
+ globalObject->Set(ToV8String("_fileSystem"), auxiliaryObject); |
+ |
// TODO: Move the rest of the global object initializations here |
} |
@@ -305,6 +313,11 @@ |
return static_cast<JsEngineInternal*>(v8::Local<v8::External>::Cast(arguments.Data())->Value()); |
} |
+v8::Local<v8::String> JsEngineInternal::ToV8String(const std::string& s) |
+{ |
+ return AdblockPlus::Utils::ToV8String(GetIsolate(), s); |
+} |
+ |
AdblockPlus::JsValueList AdblockPlus::JsEngine::ConvertArguments(const v8::Arguments& arguments) |
{ |
const JsContext context(shared_from_this()); |