~ubuntu-branches/ubuntu/gutsy/firefox/gutsy

« back to all changes in this revision

Viewing changes to browser/components/safebrowsing/content/list-warden.js

  • Committer: Bazaar Package Importer
  • Author(s): Ian Jackson
  • Date: 2006-10-10 18:49:32 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20061010184932-da75izt7y0e59afq
Tags: 1.99+2.0rc2+dfsg-0ubuntu1
* New upstream version 2.0rc2.
* Fix/workaround for epiphany GtkSocket lifetype crash:
  apply patch id=241087 from Mozilla Bugzilla #241535 to fix LP #63814.
* Change application name to `Firefox', as requested by mdz.
  Files changed:
    - browser/locales/en-US/chrome/branding/brand.dtd
    - browser/locales/en-US/chrome/branding/brand.properties;
  New values:
    - brandShortName and brandFullName: `Bon Echo' => `Firefox'
    - vendorShortName: `Mozilla' => `Ubuntu'
* Make preferences dialogue fit again (bah!).

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
  this.whiteTables_ = [];
65
65
}
66
66
 
 
67
PROT_ListWarden.IN_BLACKLIST = 0
 
68
PROT_ListWarden.IN_WHITELIST = 1
 
69
PROT_ListWarden.NOT_FOUND = 2
 
70
 
67
71
/**
68
72
 * Tell the ListManger to keep all of our tables updated
69
73
 */
132
136
}
133
137
 
134
138
/**
135
 
 * Internal method that looks up a url in both the white and black lists.
 
139
 * Method that looks up a url on the whitelist.
 
140
 *
 
141
 * @param url The URL to check
 
142
 * @param callback Function with a single param:
 
143
 *       PROT_ListWarden.IN_BLACKLIST, PROT_ListWarden.IN_WHITELIST,
 
144
 *       or PROT_ListWarden.NOT_FOUND
 
145
 */
 
146
PROT_ListWarden.prototype.isWhiteURL = function(url, callback) {
 
147
  (new MultiTableQuerier(url,
 
148
                         this.whiteTables_,
 
149
                         [] /* no blacklists */,
 
150
                         callback)).run();
 
151
}
 
152
 
 
153
/**
 
154
 * Method that looks up a url in both the white and black lists.
136
155
 *
137
156
 * If there is conflict, the white list has precedence over the black list.
138
157
 *
141
160
 * MultiTableQuerier (see below) to manage this.
142
161
 *
143
162
 * @param url URL to look up
144
 
 * @param evilCallback Function if the url is evil, we call this function.
 
163
 * @param callback Function with a single param:
 
164
 *       PROT_ListWarden.IN_BLACKLIST, PROT_ListWarden.IN_WHITELIST,
 
165
 *       or PROT_ListWarden.NOT_FOUND
145
166
 */
146
 
PROT_ListWarden.prototype.isEvilURL_ = function(url, evilCallback) {
 
167
PROT_ListWarden.prototype.isEvilURL = function(url, callback) {
147
168
  (new MultiTableQuerier(url,
148
 
                         this.whiteTables_, 
 
169
                         this.whiteTables_,
149
170
                         this.blackTables_,
150
 
                         evilCallback)).run();
 
171
                         callback)).run();
151
172
}
152
173
 
153
174
/**
159
180
 * @param url String The url to check
160
181
 * @param whiteTables Array of strings with each white table name
161
182
 * @param blackTables Array of strings with each black table name
162
 
 * @param evilCallback Function to call if it is an evil url
 
183
 * @param callback Function to call with result 
 
184
 *       PROT_ListWarden.IN_BLACKLIST, PROT_ListWarden.IN_WHITELIST,
 
185
 *       or PROT_ListWarden.NOT_FOUND
163
186
 */
164
 
function MultiTableQuerier(url, whiteTables, blackTables, evilCallback) {
 
187
function MultiTableQuerier(url, whiteTables, blackTables, callback) {
165
188
  this.debugZone = "multitablequerier";
166
189
  this.url_ = url;
167
190
 
170
193
  this.whiteIdx_ = 0;
171
194
  this.blackIdx_ = 0;
172
195
 
173
 
  this.evilCallback_ = evilCallback;
 
196
  this.callback_ = callback;
174
197
  this.listManager_ = Cc["@mozilla.org/url-classifier/listmanager;1"]
175
198
                      .getService(Ci.nsIUrlListManager);
176
199
}
178
201
/**
179
202
 * We first query the white tables in succession.  If any contain
180
203
 * the url, we stop.  If none contain the url, we query the black tables
181
 
 * in succession.  If any contain the url, we call evilCallback and
 
204
 * in succession.  If any contain the url, we call callback and
182
205
 * stop.  If none of the black tables contain the url, then we just stop
183
206
 * (i.e., it's not black url).
184
207
 */
200
223
  } else {
201
224
    // No tables left to check, so we quit.
202
225
    G_Debug(this, "Not found in any tables: " + this.url_);
 
226
    this.callback_(PROT_ListWarden.NOT_FOUND);
203
227
 
204
228
    // Break circular ref to callback.
205
 
    this.evilCallback_ = null;
 
229
    this.callback_ = null;
206
230
    this.listManager_ = null;
207
231
  }
208
232
}
217
241
    this.run();
218
242
  else {
219
243
    G_Debug(this, "Found in whitelist: " + this.url_)
 
244
    this.callback_(PROT_ListWarden.IN_WHITELIST);
220
245
 
221
246
    // Break circular ref to callback.
222
 
    this.evilCallback_ = null;
 
247
    this.callback_ = null;
223
248
    this.listManager_ = null;
224
249
  }
225
250
}
226
251
 
227
252
/**
228
253
 * After checking a black table, we return here.  If the url is found,
229
 
 * we can call the evilCallback and stop.  Otherwise, we call run again.
 
254
 * we can call the callback and stop.  Otherwise, we call run again.
230
255
 */
231
256
MultiTableQuerier.prototype.blackTableCallback_ = function(isFound) {
232
257
  //G_Debug(this, "blackTableCallback_: " + isFound);
235
260
  } else {
236
261
    // In the blacklist, must be an evil url.
237
262
    G_Debug(this, "Found in blacklist: " + this.url_)
238
 
    this.evilCallback_();
 
263
    this.callback_(PROT_ListWarden.IN_BLACKLIST);
239
264
 
240
265
    // Break circular ref to callback.
241
 
    this.evilCallback_ = null;
 
266
    this.callback_ = null;
242
267
    this.listManager_ = null;
243
268
  }
244
269
}