| 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-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 | 
|   11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the |   11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|   12  * GNU General Public License for more details. |   12  * GNU General Public License for more details. | 
|   13  * |   13  * | 
|   14  * You should have received a copy of the GNU General Public License |   14  * You should have received a copy of the GNU General Public License | 
|   15  * along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. |   15  * along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. | 
|   16  */ |   16  */ | 
|   17  |   17  | 
|   18 #pragma once |   18 #pragma once | 
|   19 #include <cstdint> |   19 #include <cstdint> | 
|   20 #include <AdblockPlus/FilterEngine.h> |   20 #include <AdblockPlus/FilterEngine.h> | 
|   21 #include "ProtocolCF.h" |   21 #include "ProtocolCF.h" | 
|   22 #include "ProtocolImpl.h" |   22 #include "ProtocolImpl.h" | 
|   23 #define IE_MAX_URL_LENGTH 2048 |   23 #define IE_MAX_URL_LENGTH 2048 | 
|   24  |   24  | 
|   25 class WBPassthruSink : |   25 class WBPassthruSink : | 
|   26 »       public PassthroughAPP::CInternetProtocolSinkWithSP<WBPassthruSink, CComM
     ultiThreadModel>, |   26   public PassthroughAPP::CInternetProtocolSinkWithSP<WBPassthruSink, CComMultiTh
     readModel>, | 
|   27 »       public IHttpNegotiate |   27   public IHttpNegotiate | 
|   28 { |   28 { | 
|   29 »       typedef PassthroughAPP::CInternetProtocolSinkWithSP<WBPassthruSink, CCom
     MultiThreadModel> BaseClass; |   29   typedef PassthroughAPP::CInternetProtocolSinkWithSP<WBPassthruSink, CComMultiT
     hreadModel> BaseClass; | 
|   30  |   30  | 
|   31 public: |   31 public: | 
|   32 »       WBPassthruSink(); |   32   WBPassthruSink(); | 
|   33  |   33  | 
|   34 »       uint64_t m_currentPositionOfSentPage; |   34   uint64_t m_currentPositionOfSentPage; | 
|   35 »       CComPtr<IInternetProtocol> m_pTargetProtocol; |   35   CComPtr<IInternetProtocol> m_pTargetProtocol; | 
|   36 »       AdblockPlus::FilterEngine::ContentType m_contentType; |   36   AdblockPlus::FilterEngine::ContentType m_contentType; | 
|   37 »       std::wstring m_boundDomain; |   37   std::wstring m_boundDomain; | 
|   38 »       bool m_isCustomResponse; |   38   bool m_isCustomResponse; | 
|   39  |   39  | 
|   40 »       AdblockPlus::FilterEngine::ContentType GetContentTypeFromMimeType(const 
     CString& mimeType); |   40 private: | 
|   41 »       AdblockPlus::FilterEngine::ContentType GetContentTypeFromURL(const std::
     wstring& src); |   41   AdblockPlus::FilterEngine::ContentType GetContentTypeFromMimeType(const std::w
     string& mimeType); | 
|   42 »       AdblockPlus::FilterEngine::ContentType GetContentType(const CString& mim
     eType, const std::wstring& domain, const std::wstring& src); |   42   AdblockPlus::FilterEngine::ContentType GetContentTypeFromURL(const std::wstrin
     g& src); | 
|   43 »       bool IsFlashRequest(const wchar_t* const* additionalHeaders); |   43   AdblockPlus::FilterEngine::ContentType GetContentType(const std::wstring& mime
     Type, const std::wstring& domain, const std::wstring& src); | 
 |   44   bool IsFlashRequest(const wchar_t* const* additionalHeaders); | 
 |   45  | 
|   44 public: |   46 public: | 
|   45 »       BEGIN_COM_MAP(WBPassthruSink) |   47   BEGIN_COM_MAP(WBPassthruSink) | 
|   46 »       »       COM_INTERFACE_ENTRY(IHttpNegotiate) |   48     COM_INTERFACE_ENTRY(IHttpNegotiate) | 
|   47 »       »       COM_INTERFACE_ENTRY_CHAIN(BaseClass) |   49     COM_INTERFACE_ENTRY_CHAIN(BaseClass) | 
|   48 »       END_COM_MAP() |   50   END_COM_MAP() | 
|   49  |   51  | 
|   50 »       BEGIN_SERVICE_MAP(WBPassthruSink) |   52   BEGIN_SERVICE_MAP(WBPassthruSink) | 
|   51 »       »       SERVICE_ENTRY(IID_IHttpNegotiate) |   53     SERVICE_ENTRY(IID_IHttpNegotiate) | 
|   52 »       END_SERVICE_MAP() |   54   END_SERVICE_MAP() | 
|   53  |   55  | 
|   54 »       STDMETHODIMP BeginningTransaction( |   56   STDMETHODIMP BeginningTransaction( | 
|   55 »       »       /* [in] */ LPCWSTR szURL, |   57     /* [in] */ LPCWSTR szURL, | 
|   56 »       »       /* [in] */ LPCWSTR szHeaders, |   58     /* [in] */ LPCWSTR szHeaders, | 
|   57 »       »       /* [in] */ DWORD dwReserved, |   59     /* [in] */ DWORD dwReserved, | 
|   58 »       »       /* [out] */ LPWSTR *pszAdditionalHeaders); |   60     /* [out] */ LPWSTR *pszAdditionalHeaders); | 
|   59  |   61  | 
|   60 »       STDMETHODIMP OnResponse( |   62   STDMETHODIMP OnResponse( | 
|   61 »       »       /* [in] */ DWORD dwResponseCode, |   63     /* [in] */ DWORD dwResponseCode, | 
|   62 »       »       /* [in] */ LPCWSTR szResponseHeaders, |   64     /* [in] */ LPCWSTR szResponseHeaders, | 
|   63 »       »       /* [in] */ LPCWSTR szRequestHeaders, |   65     /* [in] */ LPCWSTR szRequestHeaders, | 
|   64 »       »       /* [out] */ LPWSTR *pszAdditionalRequestHeaders); |   66     /* [out] */ LPWSTR *pszAdditionalRequestHeaders); | 
|   65  |   67  | 
|   66 »       HRESULT OnStart(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink, |   68   HRESULT OnStart(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink, | 
|   67 »       »       IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserv
     ed, |   69     IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved, | 
|   68 »       »       IInternetProtocol* pTargetProtocol, bool& handled); |   70     IInternetProtocol* pTargetProtocol, bool& handled); | 
|   69 »       HRESULT OnRead(void *pv, ULONG cb, ULONG* pcbRead); |  | 
|   70  |   71  | 
|   71 »       STDMETHODIMP ReportProgress( |   72   HRESULT OnRead(void *pv, ULONG cb, ULONG* pcbRead); | 
|   72 »       »       /* [in] */ ULONG ulStatusCode, |  | 
|   73 »       »       /* [in] */ LPCWSTR szStatusText); |  | 
|   74  |   73  | 
|   75 »       STDMETHODIMP ReportResult( |   74   STDMETHODIMP ReportProgress( | 
|   76 »       »       /* [in] */ HRESULT hrResult, |   75     /* [in] */ ULONG ulStatusCode, | 
|   77 »       »       /* [in] */ DWORD dwError, |   76     /* [in] */ LPCWSTR szStatusText); | 
|   78 »       »       /* [in] */ LPCWSTR szResult); |  | 
|   79  |   77  | 
|   80 »       STDMETHODIMP Switch( |   78   STDMETHODIMP ReportResult( | 
|   81 »       »       /* [in] */ PROTOCOLDATA *pProtocolData); |   79     /* [in] */ HRESULT hrResult, | 
 |   80     /* [in] */ DWORD dwError, | 
 |   81     /* [in] */ LPCWSTR szResult); | 
 |   82  | 
 |   83   STDMETHODIMP Switch( | 
 |   84     /* [in] */ PROTOCOLDATA *pProtocolData); | 
|   82 }; |   85 }; | 
|   83  |   86  | 
|   84 class WBPassthru; |   87 class WBPassthru; | 
|   85 typedef PassthroughAPP::CustomSinkStartPolicy<WBPassthru, WBPassthruSink> WBStar
     tPolicy; |   88 typedef PassthroughAPP::CustomSinkStartPolicy<WBPassthru, WBPassthruSink> WBStar
     tPolicy; | 
|   86  |   89  | 
|   87 class WBPassthru : public PassthroughAPP::CInternetProtocol<WBStartPolicy> |   90 class WBPassthru : public PassthroughAPP::CInternetProtocol<WBStartPolicy> | 
|   88 { |   91 { | 
|   89   typedef PassthroughAPP::CInternetProtocol<WBStartPolicy> BaseClass; |   92   typedef PassthroughAPP::CInternetProtocol<WBStartPolicy> BaseClass; | 
|   90 public: |   93 public: | 
|   91   WBPassthru(); |   94   WBPassthru(); | 
|   92   // IInternetProtocolRoot |   95   // IInternetProtocolRoot | 
|   93   STDMETHODIMP Start(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink, |   96   STDMETHODIMP Start(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink, | 
|   94     IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved) override
     ; |   97     IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved) override
     ; | 
|   95  |   98  | 
|   96   //IInternetProtocol |   99   // IInternetProtocol | 
|   97   STDMETHODIMP Read(/* [in, out] */ void *pv,/* [in] */ ULONG cb,/* [out] */ ULO
     NG *pcbRead) override; |  100   STDMETHODIMP Read(/* [in, out] */ void *pv,/* [in] */ ULONG cb,/* [out] */ ULO
     NG *pcbRead) override; | 
|   98  |  101  | 
|   99   bool m_shouldSupplyCustomContent; |  102   bool m_shouldSupplyCustomContent; | 
|  100 }; |  103 }; | 
| OLD | NEW |