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

Unified Diff: src/shared/ContentType.cpp

Issue 5316782940225536: Issue 1557 - Update to the recent libadblockplus to reduce additional updates in the logic later. (Closed)
Patch Set: remove debugging code Created Nov. 24, 2014, 11:09 a.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
« src/shared/ContentType.h ('K') | « src/shared/ContentType.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/shared/ContentType.cpp
===================================================================
new file mode 100644
--- /dev/null
+++ b/src/shared/ContentType.cpp
@@ -0,0 +1,36 @@
+#include "ContentType.h"
+
+// Based on impl from libadblockplus
Oleksandr 2015/01/11 09:22:46 I guess the idea here was to move the content type
+
+using AdblockPlus::FilterEngine;
+
+namespace
+{
+ typedef std::map<FilterEngine::ContentType, std::string> ContentTypeMap;
+ ContentTypeMap CreateContentTypeMap()
+ {
+ ContentTypeMap contentTypes;
+ contentTypes[FilterEngine::CONTENT_TYPE_OTHER] = "OTHER";
+ contentTypes[FilterEngine::CONTENT_TYPE_SCRIPT] = "SCRIPT";
+ contentTypes[FilterEngine::CONTENT_TYPE_IMAGE] = "IMAGE";
+ contentTypes[FilterEngine::CONTENT_TYPE_STYLESHEET] = "STYLESHEET";
+ contentTypes[FilterEngine::CONTENT_TYPE_OBJECT] = "OBJECT";
+ contentTypes[FilterEngine::CONTENT_TYPE_SUBDOCUMENT] = "SUBDOCUMENT";
+ contentTypes[FilterEngine::CONTENT_TYPE_DOCUMENT] = "DOCUMENT";
+ contentTypes[FilterEngine::CONTENT_TYPE_XMLHTTPREQUEST] = "XMLHTTPREQUEST";
+ contentTypes[FilterEngine::CONTENT_TYPE_OBJECT_SUBREQUEST] = "OBJECT_SUBREQUEST";
+ contentTypes[FilterEngine::CONTENT_TYPE_FONT] = "FONT";
+ contentTypes[FilterEngine::CONTENT_TYPE_MEDIA] = "MEDIA";
+ contentTypes[FilterEngine::CONTENT_TYPE_ELEMHIDE] = "ELEMHIDE";
+ return contentTypes;
+ }
+ const ContentTypeMap g_contentTypes = CreateContentTypeMap();
+}
+
+std::string ContentTypeToString(AdblockPlus::FilterEngine::ContentType contentType)
+{
+ ContentTypeMap::const_iterator it = g_contentTypes.find(contentType);
+ if (it != g_contentTypes.end())
+ return it->second;
+ throw std::invalid_argument("Argument is not a valid ContentType");
+}
« src/shared/ContentType.h ('K') | « src/shared/ContentType.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld