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

Delta Between Two Patch Sets: src/plugin/PluginWbPassThrough.cpp

Issue 29331590: Issue #1484 - Make PassthroughAPP a pass-through again (Closed)
Left Patch Set: Created Nov. 30, 2015, 1:48 p.m.
Right Patch Set: Created Dec. 22, 2015, 2:31 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/plugin/PluginWbPassThrough.h ('k') | src/plugin/passthroughapp/SinkPolicy.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 WBPassthruSink::WBPassthruSink() 138 WBPassthruSink::WBPassthruSink()
139 : m_currentPositionOfSentPage(0) 139 : m_currentPositionOfSentPage(0)
140 , m_contentType(ContentType::CONTENT_TYPE_OTHER) 140 , m_contentType(ContentType::CONTENT_TYPE_OTHER)
141 , m_isCustomResponse(false) 141 , m_isCustomResponse(false)
142 { 142 {
143 } 143 }
144 144
145 ContentType WBPassthruSink::GetContentTypeFromMimeType(const std::wstring& mimeT ype) 145 ContentType WBPassthruSink::GetContentTypeFromMimeType(const std::wstring& mimeT ype)
146 { 146 {
147 if ((mimeType.find(L"text/html") != std::wstring::npos) ||
148 (mimeType.find(L"application/xhtml+xml") != std::wstring::npos))
149 {
150 return ContentType::CONTENT_TYPE_SUBDOCUMENT;
151 }
147 if (mimeType.find(L"image/") != std::wstring::npos) 152 if (mimeType.find(L"image/") != std::wstring::npos)
148 { 153 {
149 return ContentType::CONTENT_TYPE_IMAGE; 154 return ContentType::CONTENT_TYPE_IMAGE;
150 } 155 }
151 if (mimeType.find(L"text/css") != std::wstring::npos) 156 if (mimeType.find(L"text/css") != std::wstring::npos)
152 { 157 {
153 return ContentType::CONTENT_TYPE_STYLESHEET; 158 return ContentType::CONTENT_TYPE_STYLESHEET;
154 } 159 }
155 if ((mimeType.find(L"application/javascript") != std::wstring::npos) || (mimeT ype.find(L"application/json") != std::wstring::npos)) 160 if ((mimeType.find(L"application/javascript") != std::wstring::npos) || (mimeT ype.find(L"application/json") != std::wstring::npos))
156 { 161 {
157 return ContentType::CONTENT_TYPE_SCRIPT; 162 return ContentType::CONTENT_TYPE_SCRIPT;
158 } 163 }
159 if (mimeType.find(L"application/x-shockwave-flash") != std::wstring::npos) 164 if (mimeType.find(L"application/x-shockwave-flash") != std::wstring::npos)
160 { 165 {
161 return ContentType::CONTENT_TYPE_OBJECT; 166 return ContentType::CONTENT_TYPE_OBJECT;
162 }
163 if (mimeType.find(L"text/html") != std::wstring::npos)
164 {
165 return ContentType::CONTENT_TYPE_SUBDOCUMENT;
166 } 167 }
167 // It is important to have this check last, since it is rather generic, and mi ght overlay text/html, for example 168 // It is important to have this check last, since it is rather generic, and mi ght overlay text/html, for example
168 if (mimeType.find(L"xml") != std::wstring::npos) 169 if (mimeType.find(L"xml") != std::wstring::npos)
169 { 170 {
170 return ContentType::CONTENT_TYPE_XMLHTTPREQUEST; 171 return ContentType::CONTENT_TYPE_XMLHTTPREQUEST;
171 } 172 }
172 173
173 return ContentType::CONTENT_TYPE_OTHER; 174 return ContentType::CONTENT_TYPE_OTHER;
174 } 175 }
175 176
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 return BaseClass::ReportResult(hrResult, dwError, szResult); 418 return BaseClass::ReportResult(hrResult, dwError, szResult);
418 } 419 }
419 420
420 HRESULT WbPassthroughSinkStartPolicy::OnStart(LPCWSTR szUrl, 421 HRESULT WbPassthroughSinkStartPolicy::OnStart(LPCWSTR szUrl,
421 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, 422 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
422 DWORD grfPI, HANDLE_PTR dwReserved, 423 DWORD grfPI, HANDLE_PTR dwReserved,
423 IInternetProtocol* pTargetProtocol) 424 IInternetProtocol* pTargetProtocol)
424 { 425 {
425 HRESULT hr = BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwRese rved, pTargetProtocol); 426 HRESULT hr = BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwRese rved, pTargetProtocol);
426 WBPassthruSink* pSink = GetSink(); 427 WBPassthruSink* pSink = GetSink();
427 if (hr == E_ABORT && pSink->m_isCustomResponse) 428 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 {
429 GetProtocol(pSink)->m_shouldSupplyCustomContent = true; 430 GetProtocol(pSink)->m_shouldSupplyCustomContent = true;
430 pSink->m_spInternetProtocolSink->ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE , L"text/html"); 431 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 pSink->m_spInternetProtocolSink->ReportData(BSCF_FIRSTDATANOTIFICATION, 0, s tatic_cast<ULONG>(g_blockedByABPPage.size()));
432 return S_OK; 433 return S_OK;
433 } 434 }
434 return hr; 435 return hr;
435 } 436 }
436 437
437 STDMETHODIMP WbPassthroughProtocol::Start(LPCWSTR szUrl, IInternetProtocolSink * pOIProtSink, 438 STDMETHODIMP WbPassthroughProtocol::Start(LPCWSTR szUrl, IInternetProtocolSink * pOIProtSink,
438 IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved) 439 IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved)
439 { 440 {
440 ATLASSERT(m_spInternetProtocol != 0); 441 ATLASSERT(m_spInternetProtocol != 0);
441 if (!m_spInternetProtocol) 442 if (!m_spInternetProtocol)
442 { 443 {
443 return E_UNEXPECTED; 444 return E_UNEXPECTED;
444 } 445 }
445 446
446 return OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, m_spInterne tProtocol); 447 return OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, m_spInterne tProtocol);
447 } 448 }
448 449
449 STDMETHODIMP WbPassthroughProtocol::Read(/* [in, out] */ void *pv,/* [in] */ ULO NG cb,/* [out] */ ULONG *pcbRead) 450 STDMETHODIMP WbPassthroughProtocol::Read(/* [in, out] */ void *pv,/* [in] */ ULO NG cb,/* [out] */ ULONG *pcbRead)
450 { 451 {
451 WBPassthruSink* pSink = GetSink(); 452 WBPassthruSink* pSink = GetSink();
452 return pSink->OnRead(pv, cb, pcbRead); 453 return pSink->OnRead(pv, cb, pcbRead);
453 } 454 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld