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

Delta Between Two Patch Sets: src/GlobalJsObject.cpp

Issue 10420020: Made sure FilterEngine instances are always initialized (Closed)
Left Patch Set: Created May 16, 2013, 2:27 p.m.
Right 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/FilterEngine.cpp ('k') | src/JsEngine.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 87
88 v8::Handle<v8::Value> InitDoneCallback(const v8::Arguments& arguments) 88 v8::Handle<v8::Value> TriggerEventCallback(const v8::Arguments& arguments)
89 { 89 {
90 AdblockPlus::JsEngine::FromArguments(arguments)->InitDone(); 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());
91 return v8::Undefined(); 96 return v8::Undefined();
92 } 97 }
93 } 98 }
94 99
95 JsValuePtr GlobalJsObject::Setup(JsEnginePtr jsEngine, const AppInfo& appInfo, 100 JsValuePtr GlobalJsObject::Setup(JsEnginePtr jsEngine, const AppInfo& appInfo,
96 JsValuePtr obj) 101 JsValuePtr obj)
97 { 102 {
98 obj->SetProperty("setTimeout", jsEngine->NewCallback(::SetTimeoutCallback)); 103 obj->SetProperty("setTimeout", jsEngine->NewCallback(::SetTimeoutCallback));
99 obj->SetProperty("_initDone", jsEngine->NewCallback(::InitDoneCallback)); 104 obj->SetProperty("_triggerEvent", jsEngine->NewCallback(::TriggerEventCallback ));
100 obj->SetProperty("_fileSystem", 105 obj->SetProperty("_fileSystem",
101 FileSystemJsObject::Setup(jsEngine, jsEngine->NewObject())); 106 FileSystemJsObject::Setup(jsEngine, jsEngine->NewObject()));
102 obj->SetProperty("_webRequest", 107 obj->SetProperty("_webRequest",
103 WebRequestJsObject::Setup(jsEngine, jsEngine->NewObject())); 108 WebRequestJsObject::Setup(jsEngine, jsEngine->NewObject()));
104 obj->SetProperty("console", 109 obj->SetProperty("console",
105 ConsoleJsObject::Setup(jsEngine, jsEngine->NewObject())); 110 ConsoleJsObject::Setup(jsEngine, jsEngine->NewObject()));
106 obj->SetProperty("_appInfo", 111 obj->SetProperty("_appInfo",
107 AppInfoJsObject::Setup(jsEngine, appInfo, jsEngine->NewObject())); 112 AppInfoJsObject::Setup(jsEngine, appInfo, jsEngine->NewObject()));
108 return obj; 113 return obj;
109 } 114 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld