Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/GlobalJsObject.cpp

Issue 10198022: Pass application data into libadblockplus (Closed)
Patch Set: Created April 12, 2013, 1:23 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 #include <vector> 1 #include <vector>
2 #include <stdexcept> 2 #include <stdexcept>
3 3
4 #include "AppInfoJsObject.h"
4 #include "GlobalJsObject.h" 5 #include "GlobalJsObject.h"
5 #include "ConsoleJsObject.h" 6 #include "ConsoleJsObject.h"
6 #include "WebRequestJsObject.h" 7 #include "WebRequestJsObject.h"
7 #include "Thread.h" 8 #include "Thread.h"
8 9
9 using namespace AdblockPlus; 10 using namespace AdblockPlus;
10 11
11 namespace 12 namespace
12 { 13 {
13 class TimeoutThread : public Thread 14 class TimeoutThread : public Thread
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 timeoutThread->Start(); 82 timeoutThread->Start();
82 83
83 // We should actually return the timer ID here, which could be 84 // We should actually return the timer ID here, which could be
84 // used via clearTimeout(). But since we don't seem to need 85 // used via clearTimeout(). But since we don't seem to need
85 // clearTimeout(), we can save that for later. 86 // clearTimeout(), we can save that for later.
86 return v8::Undefined(); 87 return v8::Undefined();
87 } 88 }
88 } 89 }
89 90
90 v8::Handle<v8::ObjectTemplate> GlobalJsObject::Create( 91 v8::Handle<v8::ObjectTemplate> GlobalJsObject::Create(
91 ErrorCallback& errorCallback, WebRequest& webRequest) 92 const AppInfo& appInfo, ErrorCallback& errorCallback, WebRequest& webRequest)
92 { 93 {
93 const v8::Locker locker(v8::Isolate::GetCurrent()); 94 const v8::Locker locker(v8::Isolate::GetCurrent());
94 v8::HandleScope handleScope; 95 v8::HandleScope handleScope;
95 const v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); 96 const v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
96 const v8::Handle<v8::ObjectTemplate> console = 97 const v8::Handle<v8::ObjectTemplate> console =
97 AdblockPlus::ConsoleJsObject::Create(errorCallback); 98 AdblockPlus::ConsoleJsObject::Create(errorCallback);
98 global->Set(v8::String::New("console"), console); 99 global->Set(v8::String::New("console"), console);
99 const v8::Handle<v8::FunctionTemplate> setTimeoutFunction = 100 const v8::Handle<v8::FunctionTemplate> setTimeoutFunction =
100 v8::FunctionTemplate::New(SetTimeoutCallback); 101 v8::FunctionTemplate::New(SetTimeoutCallback);
101 global->Set(v8::String::New("setTimeout"), setTimeoutFunction); 102 global->Set(v8::String::New("setTimeout"), setTimeoutFunction);
103 const v8::Handle<v8::ObjectTemplate> info = AppInfoJsObject::Create(appInfo);
104 global->Set(v8::String::New("_appInfo"), info);
102 const v8::Handle<v8::ObjectTemplate> request = 105 const v8::Handle<v8::ObjectTemplate> request =
103 AdblockPlus::WebRequestJsObject::Create(webRequest); 106 AdblockPlus::WebRequestJsObject::Create(webRequest);
104 global->Set(v8::String::New("_webRequest"), request); 107 global->Set(v8::String::New("_webRequest"), request);
105 return handleScope.Close(global); 108 return handleScope.Close(global);
106 } 109 }
OLDNEW
« lib/info.js ('K') | « src/GlobalJsObject.h ('k') | src/JsEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld