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

Unified Diff: src/GlobalJsObject.cpp

Issue 10862008: Automatically add default filter subscription when necessary. (Closed)
Patch Set: Created May 27, 2013, 2:12 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/FilterEngine.cpp ('k') | src/JsEngine.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/GlobalJsObject.cpp
===================================================================
--- a/src/GlobalJsObject.cpp
+++ b/src/GlobalJsObject.cpp
@@ -84,20 +84,22 @@ namespace
// clearTimeout(), we can save that for later.
return v8::Undefined();
}
v8::Handle<v8::Value> TriggerEventCallback(const v8::Arguments& arguments)
{
AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arguments);
AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments);
- if (converted.size() != 1)
- return v8::ThrowException(v8::String::New("_triggerEvent expects one parameter"));
+ if (converted.size() < 1)
+ return v8::ThrowException(v8::String::New("_triggerEvent expects at least one parameter"));
- jsEngine->TriggerEvent(converted[0]->AsString());
+ std::string eventName = converted.front()->AsString();
+ converted.erase(converted.begin());
+ jsEngine->TriggerEvent(eventName, converted);
return v8::Undefined();
}
}
JsValuePtr GlobalJsObject::Setup(JsEnginePtr jsEngine, const AppInfo& appInfo,
JsValuePtr obj)
{
obj->SetProperty("setTimeout", jsEngine->NewCallback(::SetTimeoutCallback));
« 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