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

Side by Side Diff: src/GlobalJsObject.cpp

Issue 10862008: Automatically add default filter subscription when necessary. (Closed)
Patch Set: Created May 27, 2013, 2:12 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
« 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 87
88 v8::Handle<v8::Value> TriggerEventCallback(const v8::Arguments& arguments) 88 v8::Handle<v8::Value> TriggerEventCallback(const v8::Arguments& arguments)
89 { 89 {
90 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arg uments); 90 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arg uments);
91 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments); 91 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments);
92 if (converted.size() != 1) 92 if (converted.size() < 1)
93 return v8::ThrowException(v8::String::New("_triggerEvent expects one param eter")); 93 return v8::ThrowException(v8::String::New("_triggerEvent expects at least one parameter"));
94 94
95 jsEngine->TriggerEvent(converted[0]->AsString()); 95 std::string eventName = converted.front()->AsString();
96 converted.erase(converted.begin());
97 jsEngine->TriggerEvent(eventName, converted);
96 return v8::Undefined(); 98 return v8::Undefined();
97 } 99 }
98 } 100 }
99 101
100 JsValuePtr GlobalJsObject::Setup(JsEnginePtr jsEngine, const AppInfo& appInfo, 102 JsValuePtr GlobalJsObject::Setup(JsEnginePtr jsEngine, const AppInfo& appInfo,
101 JsValuePtr obj) 103 JsValuePtr obj)
102 { 104 {
103 obj->SetProperty("setTimeout", jsEngine->NewCallback(::SetTimeoutCallback)); 105 obj->SetProperty("setTimeout", jsEngine->NewCallback(::SetTimeoutCallback));
104 obj->SetProperty("_triggerEvent", jsEngine->NewCallback(::TriggerEventCallback )); 106 obj->SetProperty("_triggerEvent", jsEngine->NewCallback(::TriggerEventCallback ));
105 obj->SetProperty("_fileSystem", 107 obj->SetProperty("_fileSystem",
106 FileSystemJsObject::Setup(jsEngine, jsEngine->NewObject())); 108 FileSystemJsObject::Setup(jsEngine, jsEngine->NewObject()));
107 obj->SetProperty("_webRequest", 109 obj->SetProperty("_webRequest",
108 WebRequestJsObject::Setup(jsEngine, jsEngine->NewObject())); 110 WebRequestJsObject::Setup(jsEngine, jsEngine->NewObject()));
109 obj->SetProperty("console", 111 obj->SetProperty("console",
110 ConsoleJsObject::Setup(jsEngine, jsEngine->NewObject())); 112 ConsoleJsObject::Setup(jsEngine, jsEngine->NewObject()));
111 obj->SetProperty("_appInfo", 113 obj->SetProperty("_appInfo",
112 AppInfoJsObject::Setup(jsEngine, appInfo, jsEngine->NewObject())); 114 AppInfoJsObject::Setup(jsEngine, appInfo, jsEngine->NewObject()));
113 return obj; 115 return obj;
114 } 116 }
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