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

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

Issue 5020125841326080: Issue 1669 - Report blocked object subrequests as failed, not as empty HTML (Closed)
Patch Set: Moved to WBPassthruSink::BeginningTransaction. Renamed the m_blockedInTransaction. Created Dec. 9, 2014, 10:16 a.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/SinkPolicy.inl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "PluginStdAfx.h" 1 #include "PluginStdAfx.h"
2 2
3 #include "PluginWbPassThrough.h" 3 #include "PluginWbPassThrough.h"
4 #include "PluginClient.h" 4 #include "PluginClient.h"
5 #include "PluginClientFactory.h" 5 #include "PluginClientFactory.h"
6 #include "PluginFilter.h" 6 #include "PluginFilter.h"
7 #include "PluginSettings.h" 7 #include "PluginSettings.h"
8 #include "PluginClass.h" 8 #include "PluginClass.h"
9 #include "PluginSystem.h" 9 #include "PluginSystem.h"
10 #include <WinInet.h> 10 #include <WinInet.h>
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 bool IsXmlHttpRequest(const std::wstring& additionalHeaders) 67 bool IsXmlHttpRequest(const std::wstring& additionalHeaders)
68 { 68 {
69 auto requestedWithHeader = ExtractHttpHeader<std::wstring>(additionalHeaders , L"X-Requested-With:", L"\n"); 69 auto requestedWithHeader = ExtractHttpHeader<std::wstring>(additionalHeaders , L"X-Requested-With:", L"\n");
70 return TrimString(requestedWithHeader) == L"XMLHttpRequest"; 70 return TrimString(requestedWithHeader) == L"XMLHttpRequest";
71 } 71 }
72 } 72 }
73 73
74 WBPassthruSink::WBPassthruSink() 74 WBPassthruSink::WBPassthruSink()
75 : m_currentPositionOfSentPage(0) 75 : m_currentPositionOfSentPage(0)
76 , m_contentType(CFilter::EContentType::contentTypeAny) 76 , m_contentType(CFilter::EContentType::contentTypeAny)
77 , m_blockedInTransaction(false) 77 , m_isCustomResponse(false)
78 { 78 {
79 } 79 }
80 80
81 int WBPassthruSink::GetContentTypeFromMimeType(const CString& mimeType) 81 int WBPassthruSink::GetContentTypeFromMimeType(const CString& mimeType)
82 { 82 {
83 if (mimeType.Find(L"image/") >= 0) 83 if (mimeType.Find(L"image/") >= 0)
84 { 84 {
85 return CFilter::contentTypeImage; 85 return CFilter::contentTypeImage;
86 } 86 }
87 if (mimeType.Find(L"text/css") >= 0) 87 if (mimeType.Find(L"text/css") >= 0)
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 if (IsFlashRequest(pszAdditionalHeaders)) 323 if (IsFlashRequest(pszAdditionalHeaders))
324 { 324 {
325 m_contentType = CFilter::EContentType::contentTypeObjectSubrequest; 325 m_contentType = CFilter::EContentType::contentTypeObjectSubrequest;
326 } 326 }
327 327
328 if (pszAdditionalHeaders && *pszAdditionalHeaders && IsXmlHttpRequest(*pszAddi tionalHeaders)) 328 if (pszAdditionalHeaders && *pszAdditionalHeaders && IsXmlHttpRequest(*pszAddi tionalHeaders))
329 { 329 {
330 m_contentType = CFilter::EContentType::contentTypeXmlHttpRequest; 330 m_contentType = CFilter::EContentType::contentTypeXmlHttpRequest;
331 } 331 }
332 332
333 m_blockedInTransaction = client->ShouldBlock(szURL, m_contentType, m_boundDoma in, /*debug flag but must be set*/true); 333 if (client->ShouldBlock(szURL, m_contentType, m_boundDomain, /*debug flag but must be set*/true))
334 if (m_blockedInTransaction)
335 { 334 {
335 m_isCustomResponse = m_contentType != CFilter::contentTypeObjectSubrequest;
336 return E_ABORT; 336 return E_ABORT;
337 } 337 }
338 return nativeHr; 338 return nativeHr;
339 } 339 }
340 340
341 STDMETHODIMP WBPassthruSink::OnResponse(DWORD dwResponseCode, LPCWSTR szResponse Headers, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders) 341 STDMETHODIMP WBPassthruSink::OnResponse(DWORD dwResponseCode, LPCWSTR szResponse Headers, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
342 { 342 {
343 if (pszAdditionalRequestHeaders) 343 if (pszAdditionalRequestHeaders)
344 { 344 {
345 *pszAdditionalRequestHeaders = 0; 345 *pszAdditionalRequestHeaders = 0;
346 } 346 }
347 347
348 CComPtr<IHttpNegotiate> spHttpNegotiate; 348 CComPtr<IHttpNegotiate> spHttpNegotiate;
349 QueryServiceFromClient(&spHttpNegotiate); 349 QueryServiceFromClient(&spHttpNegotiate);
350 350
351 return spHttpNegotiate ? spHttpNegotiate->OnResponse(dwResponseCode, szRespons eHeaders, szRequestHeaders, pszAdditionalRequestHeaders) : S_OK; 351 return spHttpNegotiate ? spHttpNegotiate->OnResponse(dwResponseCode, szRespons eHeaders, szRequestHeaders, pszAdditionalRequestHeaders) : S_OK;
352 } 352 }
353 353
354 STDMETHODIMP WBPassthruSink::ReportProgress(ULONG ulStatusCode, LPCWSTR szStatus Text) 354 STDMETHODIMP WBPassthruSink::ReportProgress(ULONG ulStatusCode, LPCWSTR szStatus Text)
355 { 355 {
356 return m_spInternetProtocolSink ? m_spInternetProtocolSink->ReportProgress(ulS tatusCode, szStatusText) : S_OK; 356 return m_spInternetProtocolSink ? m_spInternetProtocolSink->ReportProgress(ulS tatusCode, szStatusText) : S_OK;
357 } 357 }
358 358
359 STDMETHODIMP WBPassthruSink::ReportResult(/* [in] */ HRESULT hrResult, /* [in] * / DWORD dwError, /* [in] */ LPCWSTR szResult) 359 STDMETHODIMP WBPassthruSink::ReportResult(/* [in] */ HRESULT hrResult, /* [in] * / DWORD dwError, /* [in] */ LPCWSTR szResult)
360 { 360 {
361 if (m_blockedInTransaction) 361 if (m_isCustomResponse)
362 { 362 {
363 // Don't notify the client about aborting of the operation, thus don't call BaseClass::ReportResult. 363 // Don't notify the client about aborting of the operation, thus don't call BaseClass::ReportResult.
364 // Current method is called by the original protocol implementation and we a re intercepting the 364 // Current method is called by the original protocol implementation and we a re intercepting the
365 // call here and eating it, we will call the proper ReportResult later by ou rself. 365 // call here and eating it, we will call the proper ReportResult later by ou rself.
366 return S_OK; 366 return S_OK;
367 } 367 }
368 return BaseClass::ReportResult(hrResult, dwError, szResult); 368 return BaseClass::ReportResult(hrResult, dwError, szResult);
369 } 369 }
370 370
371 371
(...skipping 12 matching lines...) Expand all
384 } 384 }
385 385
386 return OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, m_spInterne tProtocol); 386 return OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, m_spInterne tProtocol);
387 } 387 }
388 388
389 STDMETHODIMP WBPassthru::Read(/* [in, out] */ void *pv,/* [in] */ ULONG cb,/* [o ut] */ ULONG *pcbRead) 389 STDMETHODIMP WBPassthru::Read(/* [in, out] */ void *pv,/* [in] */ ULONG cb,/* [o ut] */ ULONG *pcbRead)
390 { 390 {
391 WBPassthruSink* pSink = GetSink(); 391 WBPassthruSink* pSink = GetSink();
392 return pSink->OnRead(pv, cb, pcbRead); 392 return pSink->OnRead(pv, cb, pcbRead);
393 } 393 }
OLDNEW
« no previous file with comments | « src/plugin/PluginWbPassThrough.h ('k') | src/plugin/SinkPolicy.inl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld