Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 #ifdef SUPPORT_FILTER | 6 #ifdef SUPPORT_FILTER |
7 #include "PluginFilter.h" | 7 #include "PluginFilter.h" |
8 #endif | 8 #endif |
9 #include "PluginSettings.h" | 9 #include "PluginSettings.h" |
10 #include "PluginClass.h" | 10 #include "PluginClass.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 } | 184 } |
185 else | 185 else |
186 #endif // SUPPORT_FRAME_CACHING | 186 #endif // SUPPORT_FRAME_CACHING |
187 { | 187 { |
188 m_contentType = GetContentType(mimeType, m_boundDomain, src); | 188 m_contentType = GetContentType(mimeType, m_boundDomain, src); |
189 } | 189 } |
190 } | 190 } |
191 | 191 |
192 } | 192 } |
193 | 193 |
194 if (nullptr == tab) | 194 if (nullptr == tab) |
Oleksandr
2014/10/01 09:15:39
I personally don't like yoda conditions, and I thi
| |
195 { | 195 { |
196 m_contentType = GetContentType(mimeType, m_boundDomain, src); | 196 m_contentType = GetContentType(mimeType, m_boundDomain, src); |
197 } | 197 } |
198 | 198 |
199 if (nullptr != client | 199 if (nullptr != client |
200 && CFilter::EContentType::contentTypeAny != m_contentType | 200 && CFilter::EContentType::contentTypeAny != m_contentType |
201 && client->ShouldBlock(src, m_contentType, m_boundDomain, true)) | 201 && client->ShouldBlock(src, m_contentType, m_boundDomain, true)) |
Oleksandr
2014/10/01 09:15:39
Comment about yoda conditions applies here as well
| |
202 { | 202 { |
203 isBlocked = true; | 203 isBlocked = true; |
204 DEBUG_BLOCKER("Blocker::Blocking Http-request:" + src); | |
205 } | |
206 if (!isBlocked) | |
207 { | |
208 DEBUG_BLOCKER("Blocker::Ignoring Http-request:" + src) | |
209 } | 204 } |
210 | 205 |
211 // For IE6 and earlier there is iframe back button issue, so avoid it. | 206 // For IE6 and earlier there is iframe back button issue, so avoid it. |
212 if (isBlocked && client->GetIEVersion() > 6) | 207 if (isBlocked && client->GetIEVersion() > 6) |
213 { | 208 { |
214 handled = true; | 209 handled = true; |
215 if (CFilter::EContentType::contentTypeImage == m_contentType) | 210 if (CFilter::EContentType::contentTypeImage == m_contentType) |
216 { | 211 { |
217 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa rgetProtocol); | 212 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa rgetProtocol); |
218 // IE shows a cross that img is not loaded | 213 // IE shows a cross that img is not loaded |
219 return INET_E_REDIRECT_FAILED; | 214 return INET_E_REDIRECT_FAILED; |
220 } | 215 } |
221 if (CFilter::EContentType::contentTypeSubdocument == m_contentType) | 216 if (CFilter::EContentType::contentTypeSubdocument == m_contentType) |
222 { | 217 { |
223 PassthroughAPP::CustomSinkStartPolicy<WBPassthru, WBPassthruSink>::GetProt ocol(this)->m_shouldSupplyCustomContent = true; | 218 PassthroughAPP::CustomSinkStartPolicy<WBPassthru, WBPassthruSink>::GetProt ocol(this)->m_shouldSupplyCustomContent = true; |
224 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa rgetProtocol); | 219 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa rgetProtocol); |
225 m_spInternetProtocolSink->ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE, L"t ext/html"); | 220 m_spInternetProtocolSink->ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE, L"t ext/html"); |
226 m_spInternetProtocolSink->ReportData(BSCF_FIRSTDATANOTIFICATION, 0, static _cast<ULONG>(g_myPageBlocked.size())); | 221 m_spInternetProtocolSink->ReportData(BSCF_FIRSTDATANOTIFICATION, 0, static _cast<ULONG>(g_myPageBlocked.size())); |
227 return S_OK; | 222 return S_OK; |
228 } | 223 } |
229 if (CFilter::EContentType::contentTypeScript == m_contentType) | 224 if (CFilter::EContentType::contentTypeScript == m_contentType) |
230 { | 225 { |
231 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa rgetProtocol); | 226 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa rgetProtocol); |
232 m_spInternetProtocolSink->ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE, L"t ext/javascript"); | 227 m_spInternetProtocolSink->ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE, L"t ext/javascript"); |
233 m_spInternetProtocolSink->ReportResult(INET_E_REDIRECTING, 301, L"data:"); | 228 m_spInternetProtocolSink->ReportResult(INET_E_REDIRECTING, 301, L"data:"); |
234 return INET_E_REDIRECT_FAILED; | 229 return INET_E_REDIRECT_FAILED; |
235 } | 230 } |
236 if (CFilter::EContentType::contentTypeXmlHttpRequest == m_contentType) | 231 if (CFilter::EContentType::contentTypeXmlHttpRequest == m_contentType) |
Oleksandr
2014/10/01 09:15:39
Looks like we don't need a special case for conten
| |
232 { | |
233 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa rgetProtocol); | |
234 m_spInternetProtocolSink->ReportResult(INET_E_REDIRECTING, 301, L"data:"); | |
235 return INET_E_REDIRECT_FAILED; | |
236 } | |
237 if (CFilter::EContentType::contentTypeAny != m_contentType) | |
237 { | 238 { |
238 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa rgetProtocol); | 239 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa rgetProtocol); |
239 m_spInternetProtocolSink->ReportResult(INET_E_REDIRECTING, 301, L"data:"); | 240 m_spInternetProtocolSink->ReportResult(INET_E_REDIRECTING, 301, L"data:"); |
Oleksandr
2014/10/01 09:15:39
I don't think redirecting all requests to 'data:'
| |
240 return INET_E_REDIRECT_FAILED; | 241 return INET_E_REDIRECT_FAILED; |
241 } | 242 } |
242 } | 243 } |
243 #endif // SUPPORT_FILTER | 244 #endif // SUPPORT_FILTER |
244 | 245 |
245 return isBlocked ? S_FALSE : BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInf o, grfPI, dwReserved, pTargetProtocol); | 246 return isBlocked ? S_FALSE : BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInf o, grfPI, dwReserved, pTargetProtocol); |
246 } | 247 } |
247 | 248 |
248 HRESULT WBPassthruSink::OnRead(void* pv, ULONG cb, ULONG* pcbRead) | 249 HRESULT WBPassthruSink::OnRead(void* pv, ULONG cb, ULONG* pcbRead) |
249 { | 250 { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
351 } | 352 } |
352 acceptHeaderBeginsAt += sizeof(acceptHeader); | 353 acceptHeaderBeginsAt += sizeof(acceptHeader); |
353 auto acceptHeaderEndsAt = buf.find("\n", acceptHeaderBeginsAt); | 354 auto acceptHeaderEndsAt = buf.find("\n", acceptHeaderBeginsAt); |
354 if (std::string::npos == acceptHeaderEndsAt) | 355 if (std::string::npos == acceptHeaderEndsAt) |
355 { | 356 { |
356 return ""; | 357 return ""; |
357 } | 358 } |
358 return buf.substr(acceptHeaderBeginsAt, acceptHeaderEndsAt - acceptHeaderB eginsAt); | 359 return buf.substr(acceptHeaderBeginsAt, acceptHeaderEndsAt - acceptHeaderB eginsAt); |
359 }(); | 360 }(); |
360 m_contentType = GetContentTypeFromMimeType(ATL::CString(acceptHeader.c_str() )); | 361 m_contentType = GetContentTypeFromMimeType(ATL::CString(acceptHeader.c_str() )); |
361 bool isBlocked = client->ShouldBlock(szURL, m_contentType, | 362 bool isBlocked = client->ShouldBlock(szURL, m_contentType, m_boundDomain, /* debug flag but must be set*/true); |
362 //client->GetHostFromUrl(m_boundDomain.operator LPCWSTR()).c_str(), /*debu g flag but must be set*/true); | |
363 m_boundDomain, /*debug flag but must be set*/true); | |
364 if (isBlocked) | 363 if (isBlocked) |
365 { | 364 { |
366 return E_ABORT; | 365 return E_ABORT; |
367 } | 366 } |
368 } | 367 } |
369 CComPtr<IHttpNegotiate> spHttpNegotiate; | 368 CComPtr<IHttpNegotiate> spHttpNegotiate; |
370 QueryServiceFromClient(&spHttpNegotiate); | 369 QueryServiceFromClient(&spHttpNegotiate); |
371 return spHttpNegotiate ? spHttpNegotiate->BeginningTransaction(szURL, szHeader s,dwReserved, pszAdditionalHeaders) : S_OK; | 370 return spHttpNegotiate ? spHttpNegotiate->BeginningTransaction(szURL, szHeader s,dwReserved, pszAdditionalHeaders) : S_OK; |
372 } | 371 } |
373 | 372 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
422 } | 421 } |
423 | 422 |
424 STDMETHODIMP WBPassthru::UnlockRequest() | 423 STDMETHODIMP WBPassthru::UnlockRequest() |
425 { | 424 { |
426 if (m_shouldSupplyCustomContent) | 425 if (m_shouldSupplyCustomContent) |
427 { | 426 { |
428 return S_OK; | 427 return S_OK; |
429 } | 428 } |
430 return PassthroughAPP::CInternetProtocol<WBStartPolicy>::UnlockRequest(); | 429 return PassthroughAPP::CInternetProtocol<WBStartPolicy>::UnlockRequest(); |
431 } | 430 } |
LEFT | RIGHT |