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

Side by Side Diff: src/plugin/PluginWbPassThrough.cpp

Issue 29331590: Issue #1484 - Make PassthroughAPP a pass-through again (Closed)
Patch Set: Created Nov. 30, 2015, 1:48 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } 226 }
227 227
228 HRESULT WBPassthruSink::OnRead(void* pv, ULONG cb, ULONG* pcbRead) 228 HRESULT WBPassthruSink::OnRead(void* pv, ULONG cb, ULONG* pcbRead)
229 { 229 {
230 if (!pv || !pcbRead) 230 if (!pv || !pcbRead)
231 { 231 {
232 return E_POINTER; 232 return E_POINTER;
233 } 233 }
234 *pcbRead = 0; 234 *pcbRead = 0;
235 235
236 if (PassthroughAPP::CustomSinkStartPolicy<WBPassthru, WBPassthruSink>::GetProt ocol(this)->m_shouldSupplyCustomContent) 236 if (PassthroughAPP::CustomSinkStartPolicy<WbPassthroughProtocol, WBPassthruSin k>::GetProtocol(this)->m_shouldSupplyCustomContent)
237 { 237 {
238 ULONG blockedByABPPageSize = static_cast<ULONG>(g_blockedByABPPage.size()); 238 ULONG blockedByABPPageSize = static_cast<ULONG>(g_blockedByABPPage.size());
239 auto positionGrow = std::min<ULONG>(cb, static_cast<ULONG>(blockedByABPPageS ize - m_currentPositionOfSentPage)); 239 auto positionGrow = std::min<ULONG>(cb, static_cast<ULONG>(blockedByABPPageS ize - m_currentPositionOfSentPage));
240 if (positionGrow == 0) { 240 if (positionGrow == 0) {
241 return S_FALSE; 241 return S_FALSE;
242 } 242 }
243 std::copy(g_blockedByABPPage.begin(), g_blockedByABPPage.begin() + positionG row, 243 std::copy(g_blockedByABPPage.begin(), g_blockedByABPPage.begin() + positionG row,
244 stdext::make_checked_array_iterator(static_cast<char*>(pv), cb)); 244 stdext::make_checked_array_iterator(static_cast<char*>(pv), cb));
245 *pcbRead = positionGrow; 245 *pcbRead = positionGrow;
246 m_currentPositionOfSentPage += positionGrow; 246 m_currentPositionOfSentPage += positionGrow;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 if (m_isCustomResponse) 410 if (m_isCustomResponse)
411 { 411 {
412 // Don't notify the client about aborting of the operation, thus don't call BaseClass::ReportResult. 412 // Don't notify the client about aborting of the operation, thus don't call BaseClass::ReportResult.
413 // Current method is called by the original protocol implementation and we a re intercepting the 413 // Current method is called by the original protocol implementation and we a re intercepting the
414 // call here and eating it, we will call the proper ReportResult later by ou rself. 414 // call here and eating it, we will call the proper ReportResult later by ou rself.
415 return S_OK; 415 return S_OK;
416 } 416 }
417 return BaseClass::ReportResult(hrResult, dwError, szResult); 417 return BaseClass::ReportResult(hrResult, dwError, szResult);
418 } 418 }
419 419
420 420 HRESULT WbPassthroughSinkStartPolicy::OnStart(LPCWSTR szUrl,
421 WBPassthru::WBPassthru() 421 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
422 : m_shouldSupplyCustomContent(false) 422 DWORD grfPI, HANDLE_PTR dwReserved,
423 IInternetProtocol* pTargetProtocol)
423 { 424 {
425 HRESULT hr = BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwRese rved, pTargetProtocol);
426 WBPassthruSink* pSink = GetSink();
427 if (hr == E_ABORT && pSink->m_isCustomResponse)
Oleksandr 2015/12/16 13:33:30 I am actually not even sure we need this clause at
428 {
429 GetProtocol(pSink)->m_shouldSupplyCustomContent = true;
430 pSink->m_spInternetProtocolSink->ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE , L"text/html");
431 pSink->m_spInternetProtocolSink->ReportData(BSCF_FIRSTDATANOTIFICATION, 0, s tatic_cast<ULONG>(g_blockedByABPPage.size()));
432 return S_OK;
433 }
434 return hr;
424 } 435 }
425 436
426 STDMETHODIMP WBPassthru::Start(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink , 437 STDMETHODIMP WbPassthroughProtocol::Start(LPCWSTR szUrl, IInternetProtocolSink * pOIProtSink,
427 IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved) 438 IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved)
428 { 439 {
429 ATLASSERT(m_spInternetProtocol != 0); 440 ATLASSERT(m_spInternetProtocol != 0);
430 if (!m_spInternetProtocol) 441 if (!m_spInternetProtocol)
431 { 442 {
432 return E_UNEXPECTED; 443 return E_UNEXPECTED;
433 } 444 }
434 445
435 return OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, m_spInterne tProtocol); 446 return OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, m_spInterne tProtocol);
436 } 447 }
437 448
438 STDMETHODIMP WBPassthru::Read(/* [in, out] */ void *pv,/* [in] */ ULONG cb,/* [o ut] */ ULONG *pcbRead) 449 STDMETHODIMP WbPassthroughProtocol::Read(/* [in, out] */ void *pv,/* [in] */ ULO NG cb,/* [out] */ ULONG *pcbRead)
439 { 450 {
440 WBPassthruSink* pSink = GetSink(); 451 WBPassthruSink* pSink = GetSink();
441 return pSink->OnRead(pv, cb, pcbRead); 452 return pSink->OnRead(pv, cb, pcbRead);
442 } 453 }
OLDNEW

Powered by Google App Engine
This is Rietveld