OLD | NEW |
1 #include <vector> | 1 #include <vector> |
2 #include <stdexcept> | 2 #include <stdexcept> |
3 | 3 |
4 #include "GlobalJsObject.h" | 4 #include "GlobalJsObject.h" |
| 5 #include "ConsoleJsObject.h" |
| 6 #include "WebRequestJsObject.h" |
5 #include "Thread.h" | 7 #include "Thread.h" |
6 | 8 |
7 using namespace AdblockPlus; | 9 using namespace AdblockPlus; |
8 | 10 |
9 namespace | 11 namespace |
10 { | 12 { |
11 class TimeoutThread : public Thread | 13 class TimeoutThread : public Thread |
12 { | 14 { |
13 public: | 15 public: |
14 TimeoutThread(v8::Isolate* const isolate, const v8::Arguments& arguments) | 16 TimeoutThread(v8::Isolate* const isolate, const v8::Arguments& arguments) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 timeoutThread->Start(); | 81 timeoutThread->Start(); |
80 | 82 |
81 // We should actually return the timer ID here, which could be | 83 // We should actually return the timer ID here, which could be |
82 // used via clearTimeout(). But since we don't seem to need | 84 // used via clearTimeout(). But since we don't seem to need |
83 // clearTimeout(), we can save that for later. | 85 // clearTimeout(), we can save that for later. |
84 return v8::Undefined(); | 86 return v8::Undefined(); |
85 } | 87 } |
86 } | 88 } |
87 | 89 |
88 v8::Handle<v8::ObjectTemplate> GlobalJsObject::Create( | 90 v8::Handle<v8::ObjectTemplate> GlobalJsObject::Create( |
89 ErrorCallback& errorCallback) | 91 ErrorCallback& errorCallback, WebRequest& webRequest) |
90 { | 92 { |
91 const v8::Locker locker(v8::Isolate::GetCurrent()); | 93 const v8::Locker locker(v8::Isolate::GetCurrent()); |
92 v8::HandleScope handleScope; | 94 v8::HandleScope handleScope; |
93 const v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); | 95 const v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); |
94 const v8::Handle<v8::ObjectTemplate> console = | 96 const v8::Handle<v8::ObjectTemplate> console = |
95 AdblockPlus::ConsoleJsObject::Create(errorCallback); | 97 AdblockPlus::ConsoleJsObject::Create(errorCallback); |
96 global->Set(v8::String::New("console"), console); | 98 global->Set(v8::String::New("console"), console); |
97 const v8::Handle<v8::FunctionTemplate> setTimeoutFunction = | 99 const v8::Handle<v8::FunctionTemplate> setTimeoutFunction = |
98 v8::FunctionTemplate::New(SetTimeoutCallback); | 100 v8::FunctionTemplate::New(SetTimeoutCallback); |
99 global->Set(v8::String::New("setTimeout"), setTimeoutFunction); | 101 global->Set(v8::String::New("setTimeout"), setTimeoutFunction); |
| 102 const v8::Handle<v8::ObjectTemplate> request = |
| 103 AdblockPlus::WebRequestJsObject::Create(webRequest); |
| 104 global->Set(v8::String::New("_webRequest"), request); |
100 return handleScope.Close(global); | 105 return handleScope.Close(global); |
101 } | 106 } |
OLD | NEW |