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

Side by Side Diff: src/JsEngine.cpp

Issue 5653480979038208: Issue 2325 - Add a way to set settings in libadblockplus for FRP and automatic updates (Closed)
Patch Set: Address more comments Created June 22, 2015, 7:45 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') | test/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 <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::New(const AppInfo& appInfo) 73 AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::New(const AppInfo& appInfo)
74 { 74 {
75 V8Initializer::Init(); 75 V8Initializer::Init();
76 JsEnginePtr result(new JsEngine()); 76 JsEnginePtr result(new JsEngine());
77 77
78 const v8::Locker locker(result->isolate); 78 const v8::Locker locker(result->isolate);
79 const v8::HandleScope handleScope; 79 const v8::HandleScope handleScope;
80 80
81 result->context.reset(result->isolate, v8::Context::New(result->isolate)); 81 result->context.reset(result->isolate, v8::Context::New(result->isolate));
82
82 v8::Local<v8::Object> globalContext = v8::Local<v8::Context>::New( 83 v8::Local<v8::Object> globalContext = v8::Local<v8::Context>::New(
83 result->isolate, result->context)->Global(); 84 result->isolate, result->context)->Global();
84 AdblockPlus::GlobalJsObject::Setup(result, appInfo, 85 result->globalJsObject = JsValuePtr(new JsValue(result, globalContext));
85 JsValuePtr(new JsValue(result, globalContext))); 86
87 AdblockPlus::GlobalJsObject::Setup(result, appInfo, result->globalJsObject);
86 return result; 88 return result;
87 } 89 }
88 90
89 AdblockPlus::JsValuePtr AdblockPlus::JsEngine::Evaluate(const std::string& sourc e, 91 AdblockPlus::JsValuePtr AdblockPlus::JsEngine::Evaluate(const std::string& sourc e,
90 const std::string& filename) 92 const std::string& filename)
91 { 93 {
92 const JsContext context(shared_from_this()); 94 const JsContext context(shared_from_this());
93 const v8::TryCatch tryCatch; 95 const v8::TryCatch tryCatch;
94 const v8::Handle<v8::Script> script = CompileScript(isolate, source, 96 const v8::Handle<v8::Script> script = CompileScript(isolate, source,
95 filename); 97 filename);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 return logSystem; 222 return logSystem;
221 } 223 }
222 224
223 void AdblockPlus::JsEngine::SetLogSystem(AdblockPlus::LogSystemPtr val) 225 void AdblockPlus::JsEngine::SetLogSystem(AdblockPlus::LogSystemPtr val)
224 { 226 {
225 if (!val) 227 if (!val)
226 throw std::runtime_error("LogSystem cannot be null"); 228 throw std::runtime_error("LogSystem cannot be null");
227 229
228 logSystem = val; 230 logSystem = val;
229 } 231 }
232
233
234 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name,
235 AdblockPlus::JsValuePtr value)
236 {
237 if (!globalJsObject)
238 throw std::runtime_error("Global object cannot be null");
239
240 globalJsObject->SetProperty(name, value);
241 }
OLDNEW
« no previous file with comments | « src/FilterEngine.cpp ('k') | test/JsEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld