| Index: src/plugin/PluginWbPassThrough.cpp |
| =================================================================== |
| --- a/src/plugin/PluginWbPassThrough.cpp |
| +++ b/src/plugin/PluginWbPassThrough.cpp |
| @@ -20,6 +20,8 @@ |
| "</body>" |
| "</html>"; |
| + typedef AdblockPlus::FilterEngine::ContentType ContentType; |
| + |
| template <class T> |
| T ExtractHttpHeader(const T& allHeaders, const T& targetHeaderNameWithColon, const T& delimiter) |
| { |
| @@ -73,43 +75,43 @@ |
| WBPassthruSink::WBPassthruSink() |
| : m_currentPositionOfSentPage(0) |
| - , m_contentType(CFilter::EContentType::contentTypeAny) |
| + , m_contentType(AdblockPlus::FilterEngine::ContentType::CONTENT_TYPE_OTHER) |
|
Oleksandr
2015/01/11 09:22:46
Don't we have a typedef to shorten this? Though pe
|
| , m_blockedInTransaction(false) |
| { |
| } |
| -int WBPassthruSink::GetContentTypeFromMimeType(const CString& mimeType) |
| +ContentType WBPassthruSink::GetContentTypeFromMimeType(const CString& mimeType) |
| { |
| if (mimeType.Find(L"image/") >= 0) |
| { |
| - return CFilter::contentTypeImage; |
| + return ContentType::CONTENT_TYPE_IMAGE; |
| } |
| if (mimeType.Find(L"text/css") >= 0) |
| { |
| - return CFilter::contentTypeStyleSheet; |
| + return ContentType::CONTENT_TYPE_STYLESHEET; |
| } |
| if ((mimeType.Find(L"application/javascript") >= 0) || (mimeType.Find(L"application/json") >= 0)) |
| { |
| - return CFilter::contentTypeScript; |
| + return ContentType::CONTENT_TYPE_SCRIPT; |
| } |
| if (mimeType.Find(L"application/x-shockwave-flash") >= 0) |
| { |
| - return CFilter::contentTypeObject; |
| + return ContentType::CONTENT_TYPE_OBJECT; |
| } |
| if (mimeType.Find(L"text/html") >= 0) |
| { |
| - return CFilter::contentTypeSubdocument; |
| + return ContentType::CONTENT_TYPE_SUBDOCUMENT; |
| } |
| // It is important to have this check last, since it is rather generic, and might overlay text/html, for example |
| if (mimeType.Find(L"xml") >= 0) |
| { |
| - return CFilter::contentTypeXmlHttpRequest; |
| + return ContentType::CONTENT_TYPE_XMLHTTPREQUEST; |
| } |
| - return CFilter::contentTypeAny; |
| + return ContentType::CONTENT_TYPE_OTHER; |
| } |
| -int WBPassthruSink::GetContentTypeFromURL(const CString& src) |
| +ContentType WBPassthruSink::GetContentTypeFromURL(const CString& src) |
| { |
| CString srcExt = src; |
| @@ -121,49 +123,49 @@ |
| int lastDotIndex = srcExt.ReverseFind('.'); |
| if (lastDotIndex < 0) |
| - return CFilter::contentTypeAny; |
| + return ContentType::CONTENT_TYPE_OTHER; |
| CString ext = srcExt.Mid(lastDotIndex); |
| if (ext == L".jpg" || ext == L".gif" || ext == L".png" || ext == L".jpeg") |
| { |
| - return CFilter::contentTypeImage; |
| + return ContentType::CONTENT_TYPE_IMAGE; |
| } |
| else if (ext == L".css") |
| { |
| - return CFilter::contentTypeStyleSheet; |
| + return ContentType::CONTENT_TYPE_STYLESHEET; |
| } |
| else if (ext.Right(3) == L".js") |
| { |
| - return CFilter::contentTypeScript; |
| + return ContentType::CONTENT_TYPE_SCRIPT; |
| } |
| else if (ext == L".xml") |
| { |
| - return CFilter::contentTypeXmlHttpRequest; |
| + return ContentType::CONTENT_TYPE_XMLHTTPREQUEST; |
| } |
| else if (ext == L".swf") |
| { |
| - return CFilter::contentTypeObject; |
| + return ContentType::CONTENT_TYPE_OBJECT; |
| } |
| else if (ext == L".jsp" || ext == L".php" || ext == L".html") |
| { |
| - return CFilter::contentTypeSubdocument; |
| + return ContentType::CONTENT_TYPE_SUBDOCUMENT; |
| } |
| - return CFilter::contentTypeAny; |
| + return ContentType::CONTENT_TYPE_OTHER; |
| } |
| -int WBPassthruSink::GetContentType(const CString& mimeType, const std::wstring& domain, const CString& src) |
| +ContentType WBPassthruSink::GetContentType(const CString& mimeType, const std::wstring& domain, const CString& src) |
| { |
| // No referer or mime type |
| // BINDSTRING_XDR_ORIGIN works only for IE v8+ |
| if (mimeType.IsEmpty() && domain.empty() && CPluginClient::GetInstance()->GetIEVersion() >= 8) |
| { |
| - return CFilter::contentTypeXmlHttpRequest; |
| + return ContentType::CONTENT_TYPE_XMLHTTPREQUEST; |
| } |
| int contentType = GetContentTypeFromMimeType(mimeType); |
| - if (contentType == CFilter::contentTypeAny) |
| + if (contentType == ContentType::CONTENT_TYPE_OTHER) |
| { |
| contentType = GetContentTypeFromURL(src); |
| } |
| - return contentType; |
| + return ContentType::CONTENT_TYPE_OTHER; |
| } |
| //////////////////////////////////////////////////////////////////////////////////////// |
| @@ -315,22 +317,22 @@ |
| { |
| if (tab->IsFrameCached(ToCString(src))) |
| { |
| - m_contentType = CFilter::contentTypeSubdocument; |
| + m_contentType = ContentType::CONTENT_TYPE_SUBDOCUMENT; |
| } |
| } |
| } |
| if (IsFlashRequest(pszAdditionalHeaders)) |
| { |
| - m_contentType = CFilter::EContentType::contentTypeObjectSubrequest; |
| + m_contentType = ContentType::CONTENT_TYPE_OBJECT_SUBREQUEST; |
| } |
| if (pszAdditionalHeaders && IsXmlHttpRequest(*pszAdditionalHeaders)) |
| { |
| - m_contentType = CFilter::EContentType::contentTypeXmlHttpRequest; |
| + m_contentType = ContentType::CONTENT_TYPE_XMLHTTPREQUEST; |
| } |
| - m_blockedInTransaction = client->ShouldBlock(szURL, m_contentType, m_boundDomain, /*debug flag but must be set*/true); |
| + m_blockedInTransaction = client->ShouldBlock(szURL, m_contentType, m_boundDomain); |
| if (m_blockedInTransaction) |
| { |
| return E_ABORT; |