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

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

Issue 5634261554036736: Issue 1562 - Improve detecting of XmlHttmlRequest requests (Closed)
Patch Set: Created Nov. 13, 2014, 9:11 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 | « no previous file | no next file » | 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 return ""; 56 return "";
57 } 57 }
58 std::string buf(size, '\0'); 58 std::string buf(size, '\0');
59 hr = winInetHttpInfo->QueryInfo(queryOption, &buf[0], &size, &flags, 0); 59 hr = winInetHttpInfo->QueryInfo(queryOption, &buf[0], &size, &flags, 0);
60 if (FAILED(hr)) 60 if (FAILED(hr))
61 { 61 {
62 return ""; 62 return "";
63 } 63 }
64 return ExtractHttpHeader<std::string>(buf, "Accept:", "\r\n"); 64 return ExtractHttpHeader<std::string>(buf, "Accept:", "\r\n");
65 } 65 }
66
67 bool IsXmlHttpRequest(const std::wstring& additionalHeaders)
68 {
69 auto requestedWithHeader = ExtractHttpHeader<std::wstring>(additionalHeaders , L"X-Requested-With:", L"\n");
70 return TrimString(requestedWithHeader) == L"XMLHttpRequest";
71 }
66 } 72 }
67 73
68 WBPassthruSink::WBPassthruSink() 74 WBPassthruSink::WBPassthruSink()
69 : m_currentPositionOfSentPage(0) 75 : m_currentPositionOfSentPage(0)
70 , m_contentType(CFilter::EContentType::contentTypeAny) 76 , m_contentType(CFilter::EContentType::contentTypeAny)
71 , m_blockedInTransaction(false) 77 , m_blockedInTransaction(false)
72 { 78 {
73 } 79 }
74 80
75 int WBPassthruSink::GetContentTypeFromMimeType(const CString& mimeType) 81 int WBPassthruSink::GetContentTypeFromMimeType(const CString& mimeType)
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 { 315 {
310 if (tab->IsFrameCached(ToCString(src))) 316 if (tab->IsFrameCached(ToCString(src)))
311 { 317 {
312 m_contentType = CFilter::contentTypeSubdocument; 318 m_contentType = CFilter::contentTypeSubdocument;
313 } 319 }
314 } 320 }
315 } 321 }
316 322
317 if (IsFlashRequest(pszAdditionalHeaders)) 323 if (IsFlashRequest(pszAdditionalHeaders))
318 { 324 {
319 m_contentType = CFilter::EContentType::contentTypeObjectSubrequest; 325 m_contentType = CFilter::EContentType::contentTypeObjectSubrequest;
326 }
327
328 if (pszAdditionalHeaders && IsXmlHttpRequest(*pszAdditionalHeaders))
329 {
330 m_contentType = CFilter::EContentType::contentTypeXmlHttpRequest;
320 } 331 }
321 332
322 m_blockedInTransaction = client->ShouldBlock(szURL, m_contentType, m_boundDoma in, /*debug flag but must be set*/true); 333 m_blockedInTransaction = client->ShouldBlock(szURL, m_contentType, m_boundDoma in, /*debug flag but must be set*/true);
323 if (m_blockedInTransaction) 334 if (m_blockedInTransaction)
324 { 335 {
325 return E_ABORT; 336 return E_ABORT;
326 } 337 }
327 return nativeHr; 338 return nativeHr;
328 } 339 }
329 340
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 394
384 STDMETHODIMP WBPassthru::LockRequest(/* [in] */ DWORD options) 395 STDMETHODIMP WBPassthru::LockRequest(/* [in] */ DWORD options)
385 { 396 {
386 return BaseClass::LockRequest(options); 397 return BaseClass::LockRequest(options);
387 } 398 }
388 399
389 STDMETHODIMP WBPassthru::UnlockRequest() 400 STDMETHODIMP WBPassthru::UnlockRequest()
390 { 401 {
391 return BaseClass::UnlockRequest(); 402 return BaseClass::UnlockRequest();
392 } 403 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld