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

Unified Diff: shell/src/MatchesCommand.cpp

Issue 10100009: FilterEngine API improvements (Closed)
Patch Set: Replace GetElementHidingRules by a domain-specific GetElementHidingSelectors Created April 5, 2013, 12:22 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
Index: shell/src/MatchesCommand.cpp
===================================================================
--- a/shell/src/MatchesCommand.cpp
+++ b/shell/src/MatchesCommand.cpp
@@ -10,29 +10,34 @@ MatchesCommand::MatchesCommand(AdblockPl
void MatchesCommand::operator()(const std::string& arguments)
{
std::istringstream argumentStream(arguments);
std::string url;
argumentStream >> url;
std::string contentType;
argumentStream >> contentType;
- if (!url.size() || !contentType.size())
+ std::string documentUrl;
+ argumentStream >> documentUrl;
+ if (!url.size() || !contentType.size() || !documentUrl.size())
{
ShowUsage();
return;
}
- if (filterEngine.Matches(url, contentType))
- std::cout << "Match" << std::endl;
+ AdblockPlus::Filter* match = filterEngine.Matches(url, contentType, documentUrl);
+ if (!match)
+ std::cout << "No match" << std::endl;
+ else if (match->GetProperty("type", "") == "exception")
+ std::cout << "Whitelisted" << std::endl;
else
- std::cout << "No match" << std::endl;
+ std::cout << "Blocked" << std::endl;
}
std::string MatchesCommand::GetDescription() const
{
return "Returns the first filter that matches the supplied URL";
}
std::string MatchesCommand::GetUsage() const
{
- return name + " URL CONTENT_TYPE";
+ return name + " URL CONTENT_TYPE DOCUMENT_URL";
}

Powered by Google App Engine
This is Rietveld