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

Side by Side Diff: src/FilterEngine.cpp

Issue 5739415347396608: Expose extractHostFromURL to API (Closed)
Patch Set: Created April 22, 2014, 7:39 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 | « lib/api.js ('k') | no next file » | 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-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 279
280 void FilterEngine::SetPref(const std::string& pref, JsValuePtr value) 280 void FilterEngine::SetPref(const std::string& pref, JsValuePtr value)
281 { 281 {
282 JsValuePtr func = jsEngine->Evaluate("API.setPref"); 282 JsValuePtr func = jsEngine->Evaluate("API.setPref");
283 JsValueList params; 283 JsValueList params;
284 params.push_back(jsEngine->NewValue(pref)); 284 params.push_back(jsEngine->NewValue(pref));
285 params.push_back(value); 285 params.push_back(value);
286 func->Call(params); 286 func->Call(params);
287 } 287 }
288 288
289 std::string FilterEngine::GetHostFromURL(const std::string& url)
290 {
291 JsValuePtr func = jsEngine->Evaluate("API.getHostFromUrl");
292 JsValueList params;
293 params.push_back(jsEngine->NewValue(url));
294 return func->Call(params)->AsString();
295 }
296
297
289 void FilterEngine::ForceUpdateCheck(FilterEngine::UpdaterCallback callback) 298 void FilterEngine::ForceUpdateCheck(FilterEngine::UpdaterCallback callback)
290 { 299 {
291 std::string eventName = "updateCheckDone"; 300 std::string eventName = "updateCheckDone";
292 eventName += ++updateCheckId; 301 eventName += ++updateCheckId;
293 302
294 jsEngine->SetEventCallback(eventName, std::tr1::bind(&FilterEngine::UpdateChec kDone, 303 jsEngine->SetEventCallback(eventName, std::tr1::bind(&FilterEngine::UpdateChec kDone,
295 this, eventName, callback, std::tr1::placeholders::_1)); 304 this, eventName, callback, std::tr1::placeholders::_1));
296 305
297 JsValuePtr func = jsEngine->Evaluate("API.forceUpdateCheck"); 306 JsValuePtr func = jsEngine->Evaluate("API.forceUpdateCheck");
298 JsValueList params; 307 JsValueList params;
(...skipping 19 matching lines...) Expand all
318 { 327 {
319 jsEngine->RemoveEventCallback("filterChange"); 328 jsEngine->RemoveEventCallback("filterChange");
320 } 329 }
321 330
322 void FilterEngine::FilterChanged(FilterEngine::FilterChangeCallback callback, Js ValueList& params) 331 void FilterEngine::FilterChanged(FilterEngine::FilterChangeCallback callback, Js ValueList& params)
323 { 332 {
324 std::string action(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsS tring() : ""); 333 std::string action(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsS tring() : "");
325 JsValuePtr item(params.size() >= 2 ? params[1] : jsEngine->NewValue(false)); 334 JsValuePtr item(params.size() >= 2 ? params[1] : jsEngine->NewValue(false));
326 callback(action, item); 335 callback(action, item);
327 } 336 }
OLDNEW
« no previous file with comments | « lib/api.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld