| 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 |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 static_cast<const CComObjectProtSink*>(pProtocolObject)); | 368 static_cast<const CComObjectProtSink*>(pProtocolObject)); |
| 369 return pThis->m_sink.GetContainedObject(); | 369 return pThis->m_sink.GetContainedObject(); |
| 370 } | 370 } |
| 371 | 371 |
| 372 // ===== CustomSinkStartPolicy ===== | 372 // ===== CustomSinkStartPolicy ===== |
| 373 | 373 |
| 374 template <class Protocol, class Sink> | 374 template <class Protocol, class Sink> |
| 375 inline HRESULT CustomSinkStartPolicy<Protocol, Sink>::OnStart(LPCWSTR szUrl, | 375 inline HRESULT CustomSinkStartPolicy<Protocol, Sink>::OnStart(LPCWSTR szUrl, |
| 376 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, | 376 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, |
| 377 DWORD grfPI, HANDLE_PTR dwReserved, | 377 DWORD grfPI, HANDLE_PTR dwReserved, |
| 378 » IInternetProtocol* pTargetProtocol) | 378 » IInternetProtocol* pTargetProtocol) const |
| 379 { | 379 { |
| 380 ATLASSERT(pTargetProtocol != 0); | 380 ATLASSERT(pTargetProtocol != 0); |
| 381 | 381 |
| 382 Sink* pSink = GetSink(static_cast<const Protocol*>(this)); | 382 Sink* pSink = GetSink(static_cast<const Protocol*>(this)); |
| 383 HRESULT hr = pSink->OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, | 383 HRESULT hr = pSink->OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, |
| 384 dwReserved, pTargetProtocol); | 384 dwReserved, pTargetProtocol); |
| 385 | 385 |
| 386 CComPtr<IInternetProtocolSink> spSink; | 386 CComPtr<IInternetProtocolSink> spSink; |
| 387 CComPtr<IInternetBindInfo> spBindInfo; | 387 CComPtr<IInternetBindInfo> spBindInfo; |
| 388 if (SUCCEEDED(hr)) | 388 if (SUCCEEDED(hr)) |
| 389 { | 389 { |
| 390 hr = pSink->QueryInterface(IID_IInternetProtocolSink, reinterpre
t_cast<void**>(&spSink)); | 390 hr = pSink->QueryInterface(IID_IInternetProtocolSink, reinterpre
t_cast<void**>(&spSink)); |
| 391 ATLASSERT(SUCCEEDED(hr) && spSink != 0); | 391 ATLASSERT(SUCCEEDED(hr) && spSink != 0); |
| 392 } | 392 } |
| 393 if (SUCCEEDED(hr)) | 393 if (SUCCEEDED(hr)) |
| 394 { | 394 { |
| 395 hr = pSink->QueryInterface(IID_IInternetBindInfo, reinterpret_ca
st<void**>(&spBindInfo)); | 395 hr = pSink->QueryInterface(IID_IInternetBindInfo, reinterpret_ca
st<void**>(&spBindInfo)); |
| 396 ATLASSERT(SUCCEEDED(hr) && spBindInfo != 0); | 396 ATLASSERT(SUCCEEDED(hr) && spBindInfo != 0); |
| 397 } | 397 } |
| 398 if (SUCCEEDED(hr)) | 398 if (SUCCEEDED(hr)) |
| 399 { | 399 { |
| 400 hr = pTargetProtocol->Start(szUrl, spSink, spBindInfo, grfPI, dw
Reserved); | 400 hr = pTargetProtocol->Start(szUrl, spSink, spBindInfo, grfPI, dw
Reserved); |
| 401 } | 401 } |
| 402 if (E_ABORT == hr && pSink->m_isCustomResponse) | |
| 403 { | |
| 404 static_cast<Protocol*>(this)->m_shouldSupplyCustomContent = true
; | |
| 405 pSink->m_spInternetProtocolSink->ReportProgress(BINDSTATUS_MIMET
YPEAVAILABLE, L"text/html"); | |
| 406 pSink->m_spInternetProtocolSink->ReportData(BSCF_FIRSTDATANOTIFI
CATION, 0, static_cast<ULONG>(g_blockedByABPPage.size())); | |
| 407 return S_OK; | |
| 408 } | |
| 409 return hr; | 402 return hr; |
| 410 } | 403 } |
| 411 | 404 |
| 412 | 405 |
| 413 template <class Protocol, class Sink> | 406 template <class Protocol, class Sink> |
| 414 inline Sink* CustomSinkStartPolicy<Protocol, Sink>::GetSink( | 407 inline Sink* CustomSinkStartPolicy<Protocol, Sink>::GetSink( |
| 415 const Protocol* pProtocol) | 408 const Protocol* pProtocol) |
| 416 { | 409 { |
| 417 return Protocol::ComObjectClass::GetSink(pProtocol); | 410 return Protocol::ComObjectClass::GetSink(pProtocol); |
| 418 } | 411 } |
| 419 | 412 |
| 420 template <class Protocol, class Sink> | 413 template <class Protocol, class Sink> |
| 421 inline Sink* CustomSinkStartPolicy<Protocol, Sink>::GetSink() const | 414 inline Sink* CustomSinkStartPolicy<Protocol, Sink>::GetSink() const |
| 422 { | 415 { |
| 423 return GetSink(static_cast<const Protocol*>(this)); | 416 return GetSink(static_cast<const Protocol*>(this)); |
| 424 } | 417 } |
| 425 | 418 |
| 426 template <class Protocol, class Sink> | 419 template <class Protocol, class Sink> |
| 427 inline Protocol* CustomSinkStartPolicy<Protocol, Sink>::GetProtocol( | 420 inline Protocol* CustomSinkStartPolicy<Protocol, Sink>::GetProtocol( |
| 428 const Sink* pSink) | 421 const Sink* pSink) |
| 429 { | 422 { |
| 430 return Protocol::ComObjectClass::GetProtocol(pSink); | 423 return Protocol::ComObjectClass::GetProtocol(pSink); |
| 431 } | 424 } |
| 432 | 425 |
| 433 } // end namespace PassthroughAPP | 426 } // end namespace PassthroughAPP |
| 434 | 427 |
| 435 #endif // PASSTHROUGHAPP_SINKPOLICY_INL | 428 #endif // PASSTHROUGHAPP_SINKPOLICY_INL |
| OLD | NEW |