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

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

Issue 4912420225024000: Issue #1234 - Convert strings associated with URL's (Closed)
Patch Set: Created Jan. 5, 2015, 4:15 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 102 }
103 // It is important to have this check last, since it is rather generic, and mi ght overlay text/html, for example 103 // It is important to have this check last, since it is rather generic, and mi ght overlay text/html, for example
104 if (mimeType.Find(L"xml") >= 0) 104 if (mimeType.Find(L"xml") >= 0)
105 { 105 {
106 return CFilter::contentTypeXmlHttpRequest; 106 return CFilter::contentTypeXmlHttpRequest;
107 } 107 }
108 108
109 return CFilter::contentTypeAny; 109 return CFilter::contentTypeAny;
110 } 110 }
111 111
112 int WBPassthruSink::GetContentTypeFromURL(const CString& src) 112 int WBPassthruSink::GetContentTypeFromURL(const std::wstring& src)
113 { 113 {
114 CString srcExt = src; 114 CString srcLegacy = ToCString(src);
115 CString srcExt = srcLegacy;
115 116
116 int pos = 0; 117 int pos = 0;
117 if ((pos = src.Find('?')) > 0) 118 if ((pos = srcLegacy.Find('?')) > 0)
118 { 119 {
119 srcExt = src.Left(pos); 120 srcExt = srcLegacy.Left(pos);
120 } 121 }
121 122
122 int lastDotIndex = srcExt.ReverseFind('.'); 123 int lastDotIndex = srcExt.ReverseFind('.');
123 if (lastDotIndex < 0) 124 if (lastDotIndex < 0)
124 return CFilter::contentTypeAny; 125 return CFilter::contentTypeAny;
125 CString ext = srcExt.Mid(lastDotIndex); 126 CString ext = srcExt.Mid(lastDotIndex);
126 if (ext == L".jpg" || ext == L".gif" || ext == L".png" || ext == L".jpeg") 127 if (ext == L".jpg" || ext == L".gif" || ext == L".png" || ext == L".jpeg")
127 { 128 {
128 return CFilter::contentTypeImage; 129 return CFilter::contentTypeImage;
129 } 130 }
(...skipping 13 matching lines...) Expand all
143 { 144 {
144 return CFilter::contentTypeObject; 145 return CFilter::contentTypeObject;
145 } 146 }
146 else if (ext == L".jsp" || ext == L".php" || ext == L".html") 147 else if (ext == L".jsp" || ext == L".php" || ext == L".html")
147 { 148 {
148 return CFilter::contentTypeSubdocument; 149 return CFilter::contentTypeSubdocument;
149 } 150 }
150 return CFilter::contentTypeAny; 151 return CFilter::contentTypeAny;
151 } 152 }
152 153
153 int WBPassthruSink::GetContentType(const CString& mimeType, const std::wstring& domain, const CString& src) 154 int WBPassthruSink::GetContentType(const CString& mimeType, const std::wstring& domain, const std::wstring& src)
154 { 155 {
155 // No referer or mime type 156 // No referer or mime type
156 // BINDSTRING_XDR_ORIGIN works only for IE v8+ 157 // BINDSTRING_XDR_ORIGIN works only for IE v8+
157 if (mimeType.IsEmpty() && domain.empty() && CPluginClient::GetInstance()->GetI EVersion() >= 8) 158 if (mimeType.IsEmpty() && domain.empty() && CPluginClient::GetInstance()->GetI EVersion() >= 8)
158 { 159 {
159 return CFilter::contentTypeXmlHttpRequest; 160 return CFilter::contentTypeXmlHttpRequest;
160 } 161 }
161 int contentType = GetContentTypeFromMimeType(mimeType); 162 int contentType = GetContentTypeFromMimeType(mimeType);
162 if (contentType == CFilter::contentTypeAny) 163 if (contentType == CFilter::contentTypeAny)
163 { 164 {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 if (pszAdditionalHeaders && *pszAdditionalHeaders) 299 if (pszAdditionalHeaders && *pszAdditionalHeaders)
299 { 300 {
300 m_boundDomain = ExtractHttpHeader<std::wstring>(*pszAdditionalHeaders, L"Ref erer:", L"\n"); 301 m_boundDomain = ExtractHttpHeader<std::wstring>(*pszAdditionalHeaders, L"Ref erer:", L"\n");
301 } 302 }
302 m_boundDomain = TrimString(m_boundDomain); 303 m_boundDomain = TrimString(m_boundDomain);
303 CPluginTab* tab = CPluginClass::GetTab(::GetCurrentThreadId()); 304 CPluginTab* tab = CPluginClass::GetTab(::GetCurrentThreadId());
304 CPluginClient* client = CPluginClient::GetInstance(); 305 CPluginClient* client = CPluginClient::GetInstance();
305 306
306 if (tab && client) 307 if (tab && client)
307 { 308 {
308 CString documentUrl = tab->GetDocumentUrl(); 309 std::wstring documentUrl = tab->GetDocumentUrl();
309 // Page is identical to document => don't block 310 // Page is identical to document => don't block
310 if (documentUrl == ToCString(src)) 311 if (documentUrl == src)
311 { 312 {
312 return nativeHr; 313 return nativeHr;
313 } 314 }
314 else if (CPluginSettings::GetInstance()->IsPluginEnabled() && !client->IsWhi telistedUrl(std::wstring(documentUrl))) 315 else if (CPluginSettings::GetInstance()->IsPluginEnabled() && !client->IsWhi telistedUrl(documentUrl))
315 { 316 {
316 if (tab->IsFrameCached(ToCString(src))) 317 if (tab->IsFrameCached(src))
317 { 318 {
318 m_contentType = CFilter::contentTypeSubdocument; 319 m_contentType = CFilter::contentTypeSubdocument;
319 } 320 }
320 } 321 }
321 } 322 }
322 323
323 if (IsFlashRequest(pszAdditionalHeaders)) 324 if (IsFlashRequest(pszAdditionalHeaders))
324 { 325 {
325 m_contentType = CFilter::EContentType::contentTypeObjectSubrequest; 326 m_contentType = CFilter::EContentType::contentTypeObjectSubrequest;
326 } 327 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 } 389 }
389 390
390 return OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, m_spInterne tProtocol); 391 return OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, m_spInterne tProtocol);
391 } 392 }
392 393
393 STDMETHODIMP WBPassthru::Read(/* [in, out] */ void *pv,/* [in] */ ULONG cb,/* [o ut] */ ULONG *pcbRead) 394 STDMETHODIMP WBPassthru::Read(/* [in, out] */ void *pv,/* [in] */ ULONG cb,/* [o ut] */ ULONG *pcbRead)
394 { 395 {
395 WBPassthruSink* pSink = GetSink(); 396 WBPassthruSink* pSink = GetSink();
396 return pSink->OnRead(pv, cb, pcbRead); 397 return pSink->OnRead(pv, cb, pcbRead);
397 } 398 }
OLDNEW
« src/plugin/PluginWbPassThrough.h ('K') | « src/plugin/PluginWbPassThrough.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld