OLD | NEW |
1 #include <map> | 1 #include <map> |
2 #include <AdblockPlus.h> | 2 #include <AdblockPlus.h> |
3 #include "WebRequestJsObject.h" | 3 #include "WebRequestJsObject.h" |
4 #include "Thread.h" | 4 #include "Thread.h" |
5 | 5 |
6 namespace | 6 namespace |
7 { | 7 { |
8 std::string fromV8String(v8::Handle<v8::Value> value) | 8 std::string fromV8String(v8::Handle<v8::Value> value) |
9 { | 9 { |
10 v8::String::Utf8Value stringValue(value); | 10 v8::String::Utf8Value stringValue(value); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 69 } |
70 | 70 |
71 void Run() | 71 void Run() |
72 { | 72 { |
73 AdblockPlus::ServerResponse result = webRequest->GET(url, headers); | 73 AdblockPlus::ServerResponse result = webRequest->GET(url, headers); |
74 | 74 |
75 const v8::Locker locker(isolate); | 75 const v8::Locker locker(isolate); |
76 const v8::HandleScope handleScope; | 76 const v8::HandleScope handleScope; |
77 const v8::Context::Scope contextScope(context); | 77 const v8::Context::Scope contextScope(context); |
78 v8::Local<v8::Object> resultObject = v8::Object::New(); | 78 v8::Local<v8::Object> resultObject = v8::Object::New(); |
| 79 resultObject->Set(v8::String::New("status"), v8::Number::New(result.status
)); |
79 resultObject->Set(v8::String::New("responseStatus"), v8::Integer::New(resu
lt.responseStatus)); | 80 resultObject->Set(v8::String::New("responseStatus"), v8::Integer::New(resu
lt.responseStatus)); |
80 resultObject->Set(v8::String::New("responseText"), toV8String(result.respo
nseText)); | 81 resultObject->Set(v8::String::New("responseText"), toV8String(result.respo
nseText)); |
81 | 82 |
82 v8::Local<v8::Object> headersObject = v8::Object::New(); | 83 v8::Local<v8::Object> headersObject = v8::Object::New(); |
83 for (AdblockPlus::HeadersList::iterator it = result.responseHeaders.begin(
); | 84 for (AdblockPlus::HeadersList::iterator it = result.responseHeaders.begin(
); |
84 it != result.responseHeaders.end(); ++it) | 85 it != result.responseHeaders.end(); ++it) |
85 { | 86 { |
86 headersObject->Set(toV8String(it->first), toV8String(it->second)); | 87 headersObject->Set(toV8String(it->first), toV8String(it->second)); |
87 } | 88 } |
88 resultObject->Set(v8::String::New("responseHeaders"), headersObject); | 89 resultObject->Set(v8::String::New("responseHeaders"), headersObject); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 AdblockPlus::WebRequest& webRequest) | 125 AdblockPlus::WebRequest& webRequest) |
125 { | 126 { |
126 v8::HandleScope handleScope; | 127 v8::HandleScope handleScope; |
127 const v8::Handle<v8::ObjectTemplate> request = v8::ObjectTemplate::New(); | 128 const v8::Handle<v8::ObjectTemplate> request = v8::ObjectTemplate::New(); |
128 const v8::Handle<v8::FunctionTemplate> getFunction = | 129 const v8::Handle<v8::FunctionTemplate> getFunction = |
129 v8::FunctionTemplate::New(::GETCallback, | 130 v8::FunctionTemplate::New(::GETCallback, |
130 v8::External::New(&webRequest)); | 131 v8::External::New(&webRequest)); |
131 request->Set(v8::String::New("GET"), getFunction); | 132 request->Set(v8::String::New("GET"), getFunction); |
132 return handleScope.Close(request); | 133 return handleScope.Close(request); |
133 } | 134 } |
OLD | NEW |