Bug #328749 --> phishing detector API changes to stay in sync with firefox.

sr=bienvenu
This commit is contained in:
scott%scott-macgregor.org 2007-08-13 04:41:22 +00:00
Родитель 2ddc4b31be
Коммит 0efc432bd5
2 изменённых файлов: 35 добавлений и 68 удалений

Просмотреть файл

@ -73,10 +73,8 @@ var gPhishingDetector = {
// Register tables // Register tables
// XXX: move table names to a pref that we originally will download // XXX: move table names to a pref that we originally will download
// from the provider (need to workout protocol details) // from the provider (need to workout protocol details)
this.mPhishingWarden.registerWhiteTable("goog-white-domain"); phishWarden.registerWhiteTable("goog-white-exp");
this.mPhishingWarden.registerWhiteTable("goog-white-url"); phishWarden.registerBlackTable("goog-phish-sha128");
this.mPhishingWarden.registerBlackTable("goog-black-url");
this.mPhishingWarden.registerBlackTable("goog-black-enchash");
// Download/update lists if we're in non-enhanced mode // Download/update lists if we're in non-enhanced mode
this.mPhishingWarden.maybeToggleUpdateChecking(); this.mPhishingWarden.maybeToggleUpdateChecking();

Просмотреть файл

@ -196,82 +196,51 @@ function MultiTableQuerier(url, whiteTables, blackTables, callback) {
this.debugZone = "multitablequerier"; this.debugZone = "multitablequerier";
this.url_ = url; this.url_ = url;
this.whiteTables_ = whiteTables; this.whiteTables_ = {};
this.blackTables_ = blackTables; for (var i = 0; i < whiteTables.length; i++) {
this.whiteIdx_ = 0; this.whiteTables_[whiteTables[i]] = true;
this.blackIdx_ = 0; }
this.blackTables_ = {};
for (var i = 0; i < blackTables.length; i++) {
this.blackTables_[blackTables[i]] = true;
}
this.callback_ = callback; this.callback_ = callback;
this.listManager_ = Cc["@mozilla.org/url-classifier/listmanager;1"] this.listManager_ = Cc["@mozilla.org/url-classifier/listmanager;1"]
.getService(Ci.nsIUrlListManager); .getService(Ci.nsIUrlListManager);
} }
/**
* We first query the white tables in succession. If any contain
* the url, we stop. If none contain the url, we query the black tables
* in succession. If any contain the url, we call callback and
* stop. If none of the black tables contain the url, then we just stop
* (i.e., it's not black url).
*/
MultiTableQuerier.prototype.run = function() { MultiTableQuerier.prototype.run = function() {
var whiteTable = this.whiteTables_[this.whiteIdx_]; /* ask the dbservice for all the tables to which this URL belongs */
var blackTable = this.blackTables_[this.blackIdx_]; this.listManager_.safeLookup(this.url_,
if (whiteTable) { BindToObject(this.lookupCallback_, this));
//G_Debug(this, "Looking in whitetable: " + whiteTable); }
++this.whiteIdx_;
this.listManager_.safeExists(whiteTable, this.url_, MultiTableQuerier.prototype.lookupCallback_ = function(result) {
BindToObject(this.whiteTableCallback_, if (result == "") {
this));
} else if (blackTable) {
//G_Debug(this, "Looking in blacktable: " + blackTable);
++this.blackIdx_;
this.listManager_.safeExists(blackTable, this.url_,
BindToObject(this.blackTableCallback_,
this));
} else {
// No tables left to check, so we quit.
G_Debug(this, "Not found in any tables: " + this.url_);
this.callback_(PROT_ListWarden.NOT_FOUND); this.callback_(PROT_ListWarden.NOT_FOUND);
return;
// Break circular ref to callback.
this.callback_ = null;
this.listManager_ = null;
} }
}
/** var tableNames = result.split(",");
* After checking a white table, we return here. If the url is found,
* we can stop. Otherwise, we call run again.
*/
MultiTableQuerier.prototype.whiteTableCallback_ = function(isFound) {
//G_Debug(this, "whiteTableCallback_: " + isFound);
if (!isFound)
this.run();
else {
G_Debug(this, "Found in whitelist: " + this.url_)
this.callback_(PROT_ListWarden.IN_WHITELIST);
// Break circular ref to callback. /* Check the whitelists */
this.callback_ = null; for (var i = 0; i < tableNames.length; i++) {
this.listManager_ = null; if (tableNames[i] && this.whiteTables_[tableNames[i]]) {
this.callback_(PROT_ListWarden.IN_WHITELIST);
return;
}
} }
}
/** /* Check the blacklists */
* After checking a black table, we return here. If the url is found, for (var i = 0; i < tableNames.length; i++) {
* we can call the callback and stop. Otherwise, we call run again. if (tableNames[i] && this.blackTables_[tableNames[i]]) {
*/ this.callback_(PROT_ListWarden.IN_BLACKLIST);
MultiTableQuerier.prototype.blackTableCallback_ = function(isFound) { return;
//G_Debug(this, "blackTableCallback_: " + isFound); }
if (!isFound) {
this.run();
} else {
// In the blacklist, must be an evil url.
G_Debug(this, "Found in blacklist: " + this.url_)
this.callback_(PROT_ListWarden.IN_BLACKLIST);
// Break circular ref to callback.
this.callback_ = null;
this.listManager_ = null;
} }
/* Not in any lists we know about */
this.callback_(PROT_ListWarden.NOT_FOUND);
} }