| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 AdblockPlus::GlobalJsObject::Setup(*result, appInfo, global); | 149 AdblockPlus::GlobalJsObject::Setup(*result, appInfo, global); |
| 150 return result; | 150 return result; |
| 151 } | 151 } |
| 152 | 152 |
| 153 AdblockPlus::JsValue AdblockPlus::JsEngine::GetGlobalObject() | 153 AdblockPlus::JsValue AdblockPlus::JsEngine::GetGlobalObject() |
| 154 { | 154 { |
| 155 JsContext context(shared_from_this()); | 155 JsContext context(shared_from_this()); |
| 156 return JsValue(shared_from_this(), context.GetV8Context()->Global()); | 156 return JsValue(shared_from_this(), context.GetV8Context()->Global()); |
| 157 } | 157 } |
| 158 | 158 |
| 159 AdblockPlus::JsValuePtr AdblockPlus::JsEngine::Evaluate(const std::string& sourc
e, | 159 AdblockPlus::JsValue AdblockPlus::JsEngine::Evaluate(const std::string& source, |
| 160 const std::string& filename) | 160 const std::string& filename) |
| 161 { | 161 { |
| 162 const JsContext context(shared_from_this()); | 162 const JsContext context(shared_from_this()); |
| 163 const v8::TryCatch tryCatch; | 163 const v8::TryCatch tryCatch; |
| 164 const v8::Handle<v8::Script> script = CompileScript(GetIsolate(), source, | 164 const v8::Handle<v8::Script> script = CompileScript(GetIsolate(), source, |
| 165 filename); | 165 filename); |
| 166 CheckTryCatch(tryCatch); | 166 CheckTryCatch(tryCatch); |
| 167 v8::Local<v8::Value> result = script->Run(); | 167 v8::Local<v8::Value> result = script->Run(); |
| 168 CheckTryCatch(tryCatch); | 168 CheckTryCatch(tryCatch); |
| 169 return JsValuePtr(new JsValue(shared_from_this(), result)); | 169 return JsValue(shared_from_this(), result); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void AdblockPlus::JsEngine::SetEventCallback(const std::string& eventName, | 172 void AdblockPlus::JsEngine::SetEventCallback(const std::string& eventName, |
| 173 const AdblockPlus::JsEngine::EventCallback& callback) | 173 const AdblockPlus::JsEngine::EventCallback& callback) |
| 174 { | 174 { |
| 175 if (!callback) | 175 if (!callback) |
| 176 { | 176 { |
| 177 RemoveEventCallback(eventName); | 177 RemoveEventCallback(eventName); |
| 178 return; | 178 return; |
| 179 } | 179 } |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 logSystem = val; | 323 logSystem = val; |
| 324 } | 324 } |
| 325 | 325 |
| 326 | 326 |
| 327 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name, | 327 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name, |
| 328 const AdblockPlus::JsValue& value) | 328 const AdblockPlus::JsValue& value) |
| 329 { | 329 { |
| 330 auto global = GetGlobalObject(); | 330 auto global = GetGlobalObject(); |
| 331 global.SetProperty(name, value); | 331 global.SetProperty(name, value); |
| 332 } | 332 } |
| OLD | NEW |