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

Unified Diff: src/plugin/PluginWbPassThrough.cpp

Issue 5316782940225536: Issue 1557 - Update to the recent libadblockplus to reduce additional updates in the logic later. (Closed)
Patch Set: add hg subrepo file Created Jan. 28, 2015, 1:36 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/plugin/PluginWbPassThrough.h ('k') | src/shared/ContentType.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/plugin/PluginWbPassThrough.cpp
===================================================================
--- a/src/plugin/PluginWbPassThrough.cpp
+++ b/src/plugin/PluginWbPassThrough.cpp
@@ -1,20 +1,20 @@
-/*
- * This file is part of Adblock Plus <https://adblockplus.org/>,
- * Copyright (C) 2006-2015 Eyeo GmbH
- *
- * Adblock Plus is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3 as
- * published by the Free Software Foundation.
- *
- * Adblock Plus is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
- */
-
+/*
+ * This file is part of Adblock Plus <https://adblockplus.org/>,
+ * Copyright (C) 2006-2015 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#include "PluginStdAfx.h"
#include "PluginWbPassThrough.h"
@@ -38,6 +38,8 @@
"</body>"
"</html>";
+ typedef AdblockPlus::FilterEngine::ContentType ContentType;
+
template <class T>
T ExtractHttpHeader(const T& allHeaders, const T& targetHeaderNameWithColon, const T& delimiter)
{
@@ -91,43 +93,43 @@
WBPassthruSink::WBPassthruSink()
: m_currentPositionOfSentPage(0)
- , m_contentType(CFilter::EContentType::contentTypeAny)
+ , m_contentType(ContentType::CONTENT_TYPE_OTHER)
, m_isCustomResponse(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 std::wstring& src)
+ContentType WBPassthruSink::GetContentTypeFromURL(const std::wstring& src)
{
CString srcLegacy = ToCString(src);
CString srcExt = srcLegacy;
@@ -140,45 +142,45 @@
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 std::wstring& src)
+ContentType WBPassthruSink::GetContentType(const CString& mimeType, const std::wstring& domain, const std::wstring& src)
{
// No referer or mime type
// BINDSTRING_XDR_ORIGIN works only for IE v8+
if (mimeType.IsEmpty() && domain.empty() && AdblockPlus::IE::InstalledMajorVersion() >= 8)
{
- return CFilter::contentTypeXmlHttpRequest;
+ return ContentType::CONTENT_TYPE_XMLHTTPREQUEST;
}
- int contentType = GetContentTypeFromMimeType(mimeType);
- if (contentType == CFilter::contentTypeAny)
+ ContentType contentType = GetContentTypeFromMimeType(mimeType);
+ if (contentType == ContentType::CONTENT_TYPE_OTHER)
{
contentType = GetContentTypeFromURL(src);
}
@@ -319,6 +321,7 @@
}
m_boundDomain = TrimString(m_boundDomain);
m_contentType = GetContentType(ATL::CString(acceptHeader.c_str()), m_boundDomain, src);
+
CPluginTab* tab = CPluginClass::GetTab(::GetCurrentThreadId());
CPluginClient* client = CPluginClient::GetInstance();
@@ -330,32 +333,32 @@
{
return nativeHr;
}
- else if (CPluginSettings::GetInstance()->IsPluginEnabled() && !client->IsWhitelistedUrl(documentUrl))
+ else if (CPluginSettings::GetInstance()->IsPluginEnabled() && !client->IsWhitelistedUrl(std::wstring(documentUrl)))
{
if (tab->IsFrameCached(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 && *pszAdditionalHeaders && IsXmlHttpRequest(*pszAdditionalHeaders))
{
- m_contentType = CFilter::EContentType::contentTypeXmlHttpRequest;
+ m_contentType = ContentType::CONTENT_TYPE_XMLHTTPREQUEST;
}
if (client->ShouldBlock(szURL, m_contentType, m_boundDomain, /*debug flag but must be set*/true))
{
// NOTE: Feeding custom HTML to Flash, instead of original object subrequest
- // doesn't have much sense. It also can manifest in unwanted result
- // like video being blocked (See https://issues.adblockplus.org/ticket/1669)
+ // doesn't have much sense. It also can manifest in unwanted result
+ // like video being blocked (See https://issues.adblockplus.org/ticket/1669)
// So we report blocked object subrequests as failed, not just empty HTML.
- m_isCustomResponse = m_contentType != CFilter::contentTypeObjectSubrequest;
+ m_isCustomResponse = m_contentType != ContentType::CONTENT_TYPE_OBJECT_SUBREQUEST;
return E_ABORT;
}
return nativeHr;
« no previous file with comments | « src/plugin/PluginWbPassThrough.h ('k') | src/shared/ContentType.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld