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: rebase only Created Dec. 22, 2015, 2:28 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
« no previous file with comments | « src/plugin/PluginWbPassThrough.h ('k') | src/plugin/passthroughapp/SinkPolicy.h » ('j') | 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 <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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 227 }
228 228
229 HRESULT WBPassthruSink::OnRead(void* pv, ULONG cb, ULONG* pcbRead) 229 HRESULT WBPassthruSink::OnRead(void* pv, ULONG cb, ULONG* pcbRead)
230 { 230 {
231 if (!pv || !pcbRead) 231 if (!pv || !pcbRead)
232 { 232 {
233 return E_POINTER; 233 return E_POINTER;
234 } 234 }
235 *pcbRead = 0; 235 *pcbRead = 0;
236 236
237 if (PassthroughAPP::CustomSinkStartPolicy<WBPassthru, WBPassthruSink>::GetProt ocol(this)->m_shouldSupplyCustomContent) 237 if (PassthroughAPP::CustomSinkStartPolicy<WbPassthroughProtocol, WBPassthruSin k>::GetProtocol(this)->m_shouldSupplyCustomContent)
238 { 238 {
239 ULONG blockedByABPPageSize = static_cast<ULONG>(g_blockedByABPPage.size()); 239 ULONG blockedByABPPageSize = static_cast<ULONG>(g_blockedByABPPage.size());
240 auto positionGrow = std::min<ULONG>(cb, static_cast<ULONG>(blockedByABPPageS ize - m_currentPositionOfSentPage)); 240 auto positionGrow = std::min<ULONG>(cb, static_cast<ULONG>(blockedByABPPageS ize - m_currentPositionOfSentPage));
241 if (positionGrow == 0) { 241 if (positionGrow == 0) {
242 return S_FALSE; 242 return S_FALSE;
243 } 243 }
244 std::copy(g_blockedByABPPage.begin(), g_blockedByABPPage.begin() + positionG row, 244 std::copy(g_blockedByABPPage.begin(), g_blockedByABPPage.begin() + positionG row,
245 stdext::make_checked_array_iterator(static_cast<char*>(pv), cb)); 245 stdext::make_checked_array_iterator(static_cast<char*>(pv), cb));
246 *pcbRead = positionGrow; 246 *pcbRead = positionGrow;
247 m_currentPositionOfSentPage += positionGrow; 247 m_currentPositionOfSentPage += positionGrow;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 if (m_isCustomResponse) 411 if (m_isCustomResponse)
412 { 412 {
413 // Don't notify the client about aborting of the operation, thus don't call BaseClass::ReportResult. 413 // Don't notify the client about aborting of the operation, thus don't call BaseClass::ReportResult.
414 // Current method is called by the original protocol implementation and we a re intercepting the 414 // Current method is called by the original protocol implementation and we a re intercepting the
415 // call here and eating it, we will call the proper ReportResult later by ou rself. 415 // call here and eating it, we will call the proper ReportResult later by ou rself.
416 return S_OK; 416 return S_OK;
417 } 417 }
418 return BaseClass::ReportResult(hrResult, dwError, szResult); 418 return BaseClass::ReportResult(hrResult, dwError, szResult);
419 } 419 }
420 420
421 421 HRESULT WbPassthroughSinkStartPolicy::OnStart(LPCWSTR szUrl,
422 WBPassthru::WBPassthru() 422 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
423 : m_shouldSupplyCustomContent(false) 423 DWORD grfPI, HANDLE_PTR dwReserved,
424 IInternetProtocol* pTargetProtocol)
424 { 425 {
426 HRESULT hr = BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwRese rved, pTargetProtocol);
427 WBPassthruSink* pSink = GetSink();
428 if (hr == E_ABORT && pSink->m_isCustomResponse)
429 {
430 GetProtocol(pSink)->m_shouldSupplyCustomContent = true;
431 pSink->m_spInternetProtocolSink->ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE , L"text/html");
432 pSink->m_spInternetProtocolSink->ReportData(BSCF_FIRSTDATANOTIFICATION, 0, s tatic_cast<ULONG>(g_blockedByABPPage.size()));
433 return S_OK;
434 }
435 return hr;
425 } 436 }
426 437
427 STDMETHODIMP WBPassthru::Start(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink , 438 STDMETHODIMP WbPassthroughProtocol::Start(LPCWSTR szUrl, IInternetProtocolSink * pOIProtSink,
428 IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved) 439 IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved)
429 { 440 {
430 ATLASSERT(m_spInternetProtocol != 0); 441 ATLASSERT(m_spInternetProtocol != 0);
431 if (!m_spInternetProtocol) 442 if (!m_spInternetProtocol)
432 { 443 {
433 return E_UNEXPECTED; 444 return E_UNEXPECTED;
434 } 445 }
435 446
436 return OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, m_spInterne tProtocol); 447 return OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, m_spInterne tProtocol);
437 } 448 }
438 449
439 STDMETHODIMP WBPassthru::Read(/* [in, out] */ void *pv,/* [in] */ ULONG cb,/* [o ut] */ ULONG *pcbRead) 450 STDMETHODIMP WbPassthroughProtocol::Read(/* [in, out] */ void *pv,/* [in] */ ULO NG cb,/* [out] */ ULONG *pcbRead)
440 { 451 {
441 WBPassthruSink* pSink = GetSink(); 452 WBPassthruSink* pSink = GetSink();
442 return pSink->OnRead(pv, cb, pcbRead); 453 return pSink->OnRead(pv, cb, pcbRead);
443 } 454 }
OLDNEW
« no previous file with comments | « src/plugin/PluginWbPassThrough.h ('k') | src/plugin/passthroughapp/SinkPolicy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld