summaryrefslogtreecommitdiffstats
path: root/chrome/tools
diff options
context:
space:
mode:
authoridanan@chromium.org <idanan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-15 17:05:49 +0000
committeridanan@chromium.org <idanan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-15 17:05:49 +0000
commit8d090ca8c25795d526761bcae9fb301b51b2ee43 (patch)
tree75eba8a5fe8e8f6e82dea3974faec5f9bf57f079 /chrome/tools
parente5bf919de97cab42aa719a13a939487cf9f18242 (diff)
downloadchromium_src-8d090ca8c25795d526761bcae9fb301b51b2ee43.zip
chromium_src-8d090ca8c25795d526761bcae9fb301b51b2ee43.tar.gz
chromium_src-8d090ca8c25795d526761bcae9fb301b51b2ee43.tar.bz2
Privacy Blacklist IOImplemented parsing of input (text) blacklists. This is the format in which we will download privacy blacklist.Implemented storing and reading of aggregated blacklists in a binary format. This is the repository which Chromium will read on startup which is more efficient to load than the downloaded blacklists.Added concept of providers to blacklist entries so that we can determine the source of a pattern match, for future display in the UI.Unit tests added for the new IO classes. Privacy Blacklist conversion tool implemented to a single text blacklist into the binary format. Still needs options for storing multiple blacklists (TODO).
BUG=none TEST=Blacklist* Review URL: http://codereview.chromium.org/155298 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20734 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/tools')
-rw-r--r--chrome/tools/pbl_tool/pbl_tool.cc49
1 files changed, 45 insertions, 4 deletions
diff --git a/chrome/tools/pbl_tool/pbl_tool.cc b/chrome/tools/pbl_tool/pbl_tool.cc
index 6c0cdde..355c7ea 100644
--- a/chrome/tools/pbl_tool/pbl_tool.cc
+++ b/chrome/tools/pbl_tool/pbl_tool.cc
@@ -3,14 +3,55 @@
// found in the LICENSE file.
// This tool manages privacy blacklists. Primarily for loading a text
-// blacklist into the binary agregate blacklist.
+// blacklist into the binary aggregate blacklist.
#include <iostream>
#include "base/process_util.h"
+#include "base/string_util.h"
#include "chrome/browser/privacy_blacklist/blacklist.h"
+#include "chrome/browser/privacy_blacklist/blacklist_io.h"
-int main(int argc, char* argv[]) {
+#ifdef OS_POSIX
+#define ICHAR char
+#define ICERR std::cerr
+#define IMAIN main
+#else
+#define ICHAR wchar_t
+#define ICERR std::wcerr
+#define IMAIN wmain
+#endif
+
+namespace {
+
+int PrintUsage(int argc, ICHAR* argv[]) {
+ ICERR << "Usage: " << argv[0] << " <source> <target>\n"
+ " <source> is the text blacklist (.pbl) to load.\n"
+ " <target> is the binary output blacklist repository.\n\n"
+ "Adds all entries from <source> to <target>.\n"
+ "Creates <target> if it does not exist.\n";
+ return 1;
+}
+
+}
+
+int IMAIN(int argc, ICHAR* argv[]) {
base::EnableTerminationOnHeapCorruption();
- std::cout << "Aw, Snap! This is not implemented yet." << std::endl;
- CHECK(std::string() == Blacklist::StripCookies(std::string()));
+
+ if (argc < 3)
+ return PrintUsage(argc, argv);
+
+ FilePath input(argv[1]);
+ FilePath output(argv[2]);
+
+ BlacklistIO io;
+ if (io.Read(input)) {
+ if (io.Write(output)) {
+ return 0;
+ } else {
+ ICERR << "Error writing output file " << argv[2] << "\n";
+ }
+ } else {
+ ICERR << "Error reading input file " << argv[1] << "\n";
+ }
+ return -1;
}