File indexing completed on 2024-11-17 04:55:16

0001 /*
0002     SPDX-License-Identifier: MPL-2.0
0003 */
0004 
0005 /* Copyright (c) 2015 Brian R. Bondy. Distributed under the MPL2 license.
0006  * This Source Code Form is subject to the terms of the Mozilla Public
0007  * License, v. 2.0. If a copy of the MPL was not distributed with this
0008  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
0009 
0010 #ifndef AD_BLOCK_CLIENT_WRAP_H_
0011 #define AD_BLOCK_CLIENT_WRAP_H_
0012 
0013 #include <node.h>
0014 #include <node_object_wrap.h>
0015 
0016 #include "./ad_block_client.h"
0017 
0018 namespace ad_block_client_wrap {
0019 
0020 /**
0021  * Wraps AdBlockClient for use in Node
0022  */
0023 class AdBlockClientWrap : public AdBlockClient, public node::ObjectWrap {
0024  public:
0025   static void Init(v8::Local<v8::Object> exports);
0026 
0027  private:
0028   AdBlockClientWrap();
0029   virtual ~AdBlockClientWrap();
0030 
0031   static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
0032 
0033   static void Clear(const v8::FunctionCallbackInfo<v8::Value>& args);
0034   static void Parse(const v8::FunctionCallbackInfo<v8::Value>& args);
0035   static void Matches(const v8::FunctionCallbackInfo<v8::Value>& args);
0036   static void Serialize(const v8::FunctionCallbackInfo<v8::Value>& args);
0037   static void Deserialize(const v8::FunctionCallbackInfo<v8::Value>& args);
0038   static void Cleanup(const v8::FunctionCallbackInfo<v8::Value>& args);
0039   static void AddTag(const v8::FunctionCallbackInfo<v8::Value>& args);
0040   static void RemoveTag(const v8::FunctionCallbackInfo<v8::Value>& args);
0041   static void GetParsingStats(const v8::FunctionCallbackInfo<v8::Value>& args);
0042   static void GetMatchingStats(const v8::FunctionCallbackInfo<v8::Value>& args);
0043   static void GetFilters(const v8::FunctionCallbackInfo<v8::Value>& args);
0044   static void GetFingerprint(const v8::FunctionCallbackInfo<v8::Value>& args);
0045   static void EnableBadFingerprintDetection(
0046       const v8::FunctionCallbackInfo<v8::Value>& args);
0047   static void GenerateBadFingerprintsHeader(
0048       const v8::FunctionCallbackInfo<v8::Value>& args);
0049   static void GenerateDefaultManifestFile(
0050       const v8::FunctionCallbackInfo<v8::Value>& args);
0051   static void GenerateRegionalManifestFiles(
0052       const v8::FunctionCallbackInfo<v8::Value>& args);
0053   static void FindMatchingFilters(
0054       const v8::FunctionCallbackInfo<v8::Value>& args);
0055 
0056   static v8::Persistent<v8::Function> constructor;
0057 };
0058 
0059 }  // namespace ad_block_client_wrap
0060 
0061 #endif  // AD_BLOCK_CLIENT_WRAP_H_