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

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

Issue 6299667012780032: Issues #696,1231,1264,1265 - Improve handling in PassthroughApp (Closed)
Left Patch Set: Get rid of yoda style and rename blockedByABPPageSize local var Created Sept. 22, 2014, 4:14 p.m.
Right Patch Set: rebase Created Oct. 17, 2014, 12:51 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/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 #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
7 #include "PluginFilter.h" 6 #include "PluginFilter.h"
8 #endif
9 #include "PluginSettings.h" 7 #include "PluginSettings.h"
10 #include "PluginClass.h" 8 #include "PluginClass.h"
11 #include "PluginSystem.h" 9 #include "PluginSystem.h"
12 #include <WinInet.h> 10 #include <WinInet.h>
13 #include "wtypes.h" 11 #include "wtypes.h"
14 12
15 namespace 13 namespace
16 { 14 {
17 std::string g_blockedByABPPage = "<!DOCTYPE html>" 15 std::string g_blockedByABPPage = "<!DOCTYPE html>"
18 "<html>" 16 "<html>"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 { 92 {
95 return CFilter::contentTypeObject; 93 return CFilter::contentTypeObject;
96 } 94 }
97 else if (ext == L".jsp" || ext == L".php" || ext == L".html") 95 else if (ext == L".jsp" || ext == L".php" || ext == L".html")
98 { 96 {
99 return CFilter::contentTypeSubdocument; 97 return CFilter::contentTypeSubdocument;
100 } 98 }
101 return CFilter::contentTypeAny; 99 return CFilter::contentTypeAny;
102 } 100 }
103 101
104 int WBPassthruSink::GetContentType(const CString& mimeType, const CString& domai n, const CString& src) 102 int WBPassthruSink::GetContentType(const CString& mimeType, const std::wstring& domain, const CString& src)
105 { 103 {
106 // No referer or mime type 104 // No referer or mime type
107 // BINDSTRING_XDR_ORIGIN works only for IE v8+ 105 // BINDSTRING_XDR_ORIGIN works only for IE v8+
108 if (mimeType.IsEmpty() && domain.IsEmpty() && CPluginClient::GetInstance()->Ge tIEVersion() >= 8) 106 if (mimeType.IsEmpty() && domain.empty() && CPluginClient::GetInstance()->GetI EVersion() >= 8)
109 { 107 {
110 return CFilter::contentTypeXmlHttpRequest; 108 return CFilter::contentTypeXmlHttpRequest;
111 } 109 }
112 int contentType = GetContentTypeFromMimeType(mimeType); 110 int contentType = GetContentTypeFromMimeType(mimeType);
113 if (contentType == CFilter::contentTypeAny) 111 if (contentType == CFilter::contentTypeAny)
114 { 112 {
115 contentType = GetContentTypeFromURL(src); 113 contentType = GetContentTypeFromURL(src);
116 } 114 }
117 return contentType; 115 return contentType;
118 } 116 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 163 }
166 } 164 }
167 // We can obtain IBindCtx* here, but IEnumString obtained via IBindCtx::Enum ObjectParam 165 // We can obtain IBindCtx* here, but IEnumString obtained via IBindCtx::Enum ObjectParam
168 // does not return any parameter, so it's useless. 166 // does not return any parameter, so it's useless.
169 } 167 }
170 168
171 CString cookie; 169 CString cookie;
172 ULONG len1 = 2048; 170 ULONG len1 = 2048;
173 ULONG len2 = 2048; 171 ULONG len2 = 2048;
174 172
175 #ifdef SUPPORT_FILTER
176 CPluginTab* tab = CPluginClass::GetTab(::GetCurrentThreadId()); 173 CPluginTab* tab = CPluginClass::GetTab(::GetCurrentThreadId());
177 CPluginClient* client = CPluginClient::GetInstance(); 174 CPluginClient* client = CPluginClient::GetInstance();
178 175
179 if (tab && client) 176 if (tab && client)
180 { 177 {
181 CString documentUrl = tab->GetDocumentUrl(); 178 CString documentUrl = tab->GetDocumentUrl();
182 // Page is identical to document => don't block 179 // Page is identical to document => don't block
183 if (documentUrl == src) 180 if (documentUrl == src)
184 { 181 {
185 // fall through 182 // fall through
186 } 183 }
187 else if (CPluginSettings::GetInstance()->IsPluginEnabled() && !client->IsWhi telistedUrl(std::wstring(documentUrl))) 184 else if (CPluginSettings::GetInstance()->IsPluginEnabled() && !client->IsWhi telistedUrl(std::wstring(documentUrl)))
188 { 185 {
189 m_boundDomain = tab->GetDocumentUrl(); 186 m_boundDomain = tab->GetDocumentUrl();
190 m_contentType = CFilter::contentTypeAny; 187 m_contentType = CFilter::contentTypeAny;
191 #ifdef SUPPORT_FRAME_CACHING
192 if (tab != nullptr && tab->IsFrameCached(src)) 188 if (tab != nullptr && tab->IsFrameCached(src))
193 { 189 {
194 m_contentType = CFilter::contentTypeSubdocument; 190 m_contentType = CFilter::contentTypeSubdocument;
195 } 191 }
196 else 192 else
197 #endif // SUPPORT_FRAME_CACHING
198 { 193 {
199 m_contentType = GetContentType(mimeType, m_boundDomain, src); 194 m_contentType = GetContentType(mimeType, m_boundDomain, src);
200 } 195 }
201 } 196 }
202 } 197 }
203 198
204 if (tab == nullptr) 199 if (tab == nullptr)
205 { 200 {
206 m_contentType = GetContentType(mimeType, m_boundDomain, src); 201 m_contentType = GetContentType(mimeType, m_boundDomain, src);
207 } 202 }
(...skipping 19 matching lines...) Expand all
227 } 222 }
228 } 223 }
229 } 224 }
230 225
231 // The descision about EContentType::contentTypeAny is made later in 226 // The descision about EContentType::contentTypeAny is made later in
232 // WBPassthruSink::BeginningTransaction. Sometimes here we cannot detect the r equest type, but 227 // WBPassthruSink::BeginningTransaction. Sometimes here we cannot detect the r equest type, but
233 // in WBPassthruSink::BeginningTransaction the header Accept is available whic h allows to 228 // in WBPassthruSink::BeginningTransaction the header Accept is available whic h allows to
234 // obtain the "request type" in our terminology. 229 // obtain the "request type" in our terminology.
235 if (nullptr != client 230 if (nullptr != client
236 && CFilter::EContentType::contentTypeAny != m_contentType 231 && CFilter::EContentType::contentTypeAny != m_contentType
237 && client->ShouldBlock(src, m_contentType, m_boundDomain, true)) 232 && client->ShouldBlock(static_cast<const wchar_t*>(src), m_contentType, m_bo undDomain, true))
238 { 233 {
239 isBlocked = true; 234 isBlocked = true;
240 } 235 }
241 236
242 // For IE6 and earlier there is iframe back button issue, so avoid it. 237 // For IE6 and earlier there is iframe back button issue, so avoid it.
243 if (isBlocked && client->GetIEVersion() > 6) 238 if (isBlocked && client->GetIEVersion() > 6)
244 { 239 {
245 handled = true; 240 handled = true;
246 if (CFilter::EContentType::contentTypeImage == m_contentType) 241 if (CFilter::EContentType::contentTypeImage == m_contentType)
247 { 242 {
(...skipping 17 matching lines...) Expand all
265 { 260 {
266 m_spInternetProtocolSink->ReportResult(INET_E_REDIRECTING, 301, L"data:"); 261 m_spInternetProtocolSink->ReportResult(INET_E_REDIRECTING, 301, L"data:");
267 return INET_E_REDIRECT_FAILED; 262 return INET_E_REDIRECT_FAILED;
268 } 263 }
269 if (CFilter::EContentType::contentTypeAny != m_contentType) 264 if (CFilter::EContentType::contentTypeAny != m_contentType)
270 { 265 {
271 m_spInternetProtocolSink->ReportResult(INET_E_REDIRECTING, 301, L"data:"); 266 m_spInternetProtocolSink->ReportResult(INET_E_REDIRECTING, 301, L"data:");
272 return INET_E_REDIRECT_FAILED; 267 return INET_E_REDIRECT_FAILED;
273 } 268 }
274 } 269 }
275 #endif // SUPPORT_FILTER
276 270
277 return isBlocked ? S_FALSE : hr; 271 return isBlocked ? S_FALSE : hr;
278 } 272 }
279 273
280 HRESULT WBPassthruSink::OnRead(void* pv, ULONG cb, ULONG* pcbRead) 274 HRESULT WBPassthruSink::OnRead(void* pv, ULONG cb, ULONG* pcbRead)
281 { 275 {
282 if (pv == nullptr) 276 if (pv == nullptr)
283 { 277 {
284 return E_POINTER; 278 return E_POINTER;
285 } 279 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 } 463 }
470 464
471 STDMETHODIMP WBPassthru::UnlockRequest() 465 STDMETHODIMP WBPassthru::UnlockRequest()
472 { 466 {
473 if (!m_hasOriginalStartCalled) 467 if (!m_hasOriginalStartCalled)
474 { 468 {
475 return S_OK; 469 return S_OK;
476 } 470 }
477 return BaseClass::UnlockRequest(); 471 return BaseClass::UnlockRequest();
478 } 472 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld