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

Side by Side Diff: src/GlobalJsObject.cpp

Issue 10420020: Made sure FilterEngine instances are always initialized (Closed)
Patch Set: Using a generic messaging mechanism Created May 23, 2013, 6:35 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/FilterEngine.cpp ('k') | src/JsEngine.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 { 77 {
78 return v8::ThrowException(v8::String::New(e.what())); 78 return v8::ThrowException(v8::String::New(e.what()));
79 } 79 }
80 timeoutThread->Start(); 80 timeoutThread->Start();
81 81
82 // We should actually return the timer ID here, which could be 82 // We should actually return the timer ID here, which could be
83 // used via clearTimeout(). But since we don't seem to need 83 // used via clearTimeout(). But since we don't seem to need
84 // clearTimeout(), we can save that for later. 84 // clearTimeout(), we can save that for later.
85 return v8::Undefined(); 85 return v8::Undefined();
86 } 86 }
87
88 v8::Handle<v8::Value> TriggerEventCallback(const v8::Arguments& arguments)
89 {
90 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arg uments);
91 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments);
92 if (converted.size() != 1)
93 return v8::ThrowException(v8::String::New("_triggerEvent expects one param eter"));
94
95 jsEngine->TriggerEvent(converted[0]->AsString());
96 return v8::Undefined();
97 }
87 } 98 }
88 99
89 JsValuePtr GlobalJsObject::Setup(JsEnginePtr jsEngine, const AppInfo& appInfo, 100 JsValuePtr GlobalJsObject::Setup(JsEnginePtr jsEngine, const AppInfo& appInfo,
90 JsValuePtr obj) 101 JsValuePtr obj)
91 { 102 {
92 obj->SetProperty("setTimeout", jsEngine->NewCallback(::SetTimeoutCallback)); 103 obj->SetProperty("setTimeout", jsEngine->NewCallback(::SetTimeoutCallback));
104 obj->SetProperty("_triggerEvent", jsEngine->NewCallback(::TriggerEventCallback ));
93 obj->SetProperty("_fileSystem", 105 obj->SetProperty("_fileSystem",
94 FileSystemJsObject::Setup(jsEngine, jsEngine->NewObject())); 106 FileSystemJsObject::Setup(jsEngine, jsEngine->NewObject()));
95 obj->SetProperty("_webRequest", 107 obj->SetProperty("_webRequest",
96 WebRequestJsObject::Setup(jsEngine, jsEngine->NewObject())); 108 WebRequestJsObject::Setup(jsEngine, jsEngine->NewObject()));
97 obj->SetProperty("console", 109 obj->SetProperty("console",
98 ConsoleJsObject::Setup(jsEngine, jsEngine->NewObject())); 110 ConsoleJsObject::Setup(jsEngine, jsEngine->NewObject()));
99 obj->SetProperty("_appInfo", 111 obj->SetProperty("_appInfo",
100 AppInfoJsObject::Setup(jsEngine, appInfo, jsEngine->NewObject())); 112 AppInfoJsObject::Setup(jsEngine, appInfo, jsEngine->NewObject()));
101 return obj; 113 return obj;
102 } 114 }
OLDNEW
« no previous file with comments | « src/FilterEngine.cpp ('k') | src/JsEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld