зеркало из https://github.com/mozilla/gecko-dev.git
landing performance improvements for safe browsing (bugs: 338189, 338191, 338327, 338369, 338366, 338193, 338371, 338562) patches by tony+brettw, r=bryner+darin
This commit is contained in:
Родитель
de0973f23a
Коммит
f598aa62e6
|
@ -52,10 +52,6 @@
|
||||||
<?xml-stylesheet href="chrome://browser/skin/places/browser-places.css" type="text/css"?>
|
<?xml-stylesheet href="chrome://browser/skin/places/browser-places.css" type="text/css"?>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MOZ_SAFE_BROWSING
|
|
||||||
<?xml-stylesheet href="chrome://browser/skin/safebrowsing/browser-protection.css" type="text/css"?>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
<?xml-stylesheet href="chrome://global/skin/toolbar.css" type="text/css"?>
|
<?xml-stylesheet href="chrome://global/skin/toolbar.css" type="text/css"?>
|
||||||
<?xml-stylesheet href="chrome://global/skin/findBar.css" type="text/css"?>
|
<?xml-stylesheet href="chrome://global/skin/findBar.css" type="text/css"?>
|
||||||
|
|
||||||
|
@ -67,9 +63,6 @@
|
||||||
|
|
||||||
<window id="main-window"
|
<window id="main-window"
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
#ifdef MOZ_SAFE_BROWSING
|
|
||||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
|
||||||
#endif
|
|
||||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
onload="BrowserStartup()" onunload="BrowserShutdown()" onclose="return WindowIsClosing();"
|
onload="BrowserStartup()" onunload="BrowserShutdown()" onclose="return WindowIsClosing();"
|
||||||
contenttitlesetting="true"
|
contenttitlesetting="true"
|
||||||
|
@ -501,11 +494,6 @@
|
||||||
</vbox>
|
</vbox>
|
||||||
</hbox>
|
</hbox>
|
||||||
|
|
||||||
#ifdef MOZ_SAFE_BROWSING
|
|
||||||
#include ../../components/safebrowsing/content/safebrowsing.inc
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#include ../../../toolkit/components/typeaheadfind/content/findBar.inc
|
#include ../../../toolkit/components/typeaheadfind/content/findBar.inc
|
||||||
|
|
||||||
<statusbar class="chromeclass-status" id="status-bar"
|
<statusbar class="chromeclass-status" id="status-bar"
|
||||||
|
|
|
@ -73,6 +73,7 @@ REQUIRES += \
|
||||||
history \
|
history \
|
||||||
storage \
|
storage \
|
||||||
places \
|
places \
|
||||||
|
safebrowsing \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
LOCAL_INCLUDES += -I$(srcdir)/../places/src
|
LOCAL_INCLUDES += -I$(srcdir)/../places/src
|
||||||
|
@ -88,6 +89,11 @@ LOCAL_INCLUDES += -I$(srcdir)/../feeds/src
|
||||||
SHARED_LIBRARY_LIBS += ../feeds/src/$(LIB_PREFIX)browser_feeds_s.$(LIB_SUFFIX)
|
SHARED_LIBRARY_LIBS += ../feeds/src/$(LIB_PREFIX)browser_feeds_s.$(LIB_SUFFIX)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef MOZ_SAFE_BROWSING
|
||||||
|
LOCAL_INCLUDES += -I$(srcdir)/../safebrowsing/src
|
||||||
|
SHARED_LIBRARY_LIBS += ../safebrowsing/src/$(LIB_PREFIX)safebrowsing_s.$(LIB_SUFFIX)
|
||||||
|
endif
|
||||||
|
|
||||||
# Link to gkgfx for GNOME shell service
|
# Link to gkgfx for GNOME shell service
|
||||||
ifeq ($(MOZ_WIDGET_TOOLKIT), gtk2)
|
ifeq ($(MOZ_WIDGET_TOOLKIT), gtk2)
|
||||||
EXTRA_DSO_LIBS += gkgfx
|
EXTRA_DSO_LIBS += gkgfx
|
||||||
|
|
|
@ -129,3 +129,9 @@
|
||||||
|
|
||||||
#define NS_FEEDSNIFFER_CONTRACTID \
|
#define NS_FEEDSNIFFER_CONTRACTID \
|
||||||
"@mozilla.org/browser/feeds/sniffer;1"
|
"@mozilla.org/browser/feeds/sniffer;1"
|
||||||
|
|
||||||
|
#define NS_DOCNAVSTARTPROGRESSLISTENER_CID \
|
||||||
|
{ 0x7baf8179, 0xa4fd, 0x4bc0, { 0xbe, 0x43, 0xa9, 0xb1, 0x22, 0xc5, 0xde, 0xb6 } }
|
||||||
|
|
||||||
|
#define NS_DOCNAVSTARTPROGRESSLISTENER_CONTRACTID \
|
||||||
|
"@mozilla.org/browser/safebrowsing/navstartlistener;1"
|
||||||
|
|
|
@ -80,6 +80,9 @@
|
||||||
#ifdef MOZ_FEEDS
|
#ifdef MOZ_FEEDS
|
||||||
#include "nsFeedSniffer.h"
|
#include "nsFeedSniffer.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef MOZ_SAFE_BROWSING
|
||||||
|
#include "nsDocNavStartProgressListener.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -124,6 +127,9 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsICabProfileMigrator)
|
||||||
#ifdef MOZ_FEEDS
|
#ifdef MOZ_FEEDS
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFeedSniffer)
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFeedSniffer)
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef MOZ_SAFE_BROWSING
|
||||||
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDocNavStartProgressListener)
|
||||||
|
#endif
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -222,6 +228,13 @@ static const nsModuleComponentInfo components[] =
|
||||||
nsFeedSniffer::Register },
|
nsFeedSniffer::Register },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MOZ_SAFE_BROWSING
|
||||||
|
{ "Safe browsing document nav start progress listener",
|
||||||
|
NS_DOCNAVSTARTPROGRESSLISTENER_CID,
|
||||||
|
NS_DOCNAVSTARTPROGRESSLISTENER_CONTRACTID,
|
||||||
|
nsDocNavStartProgressListenerConstructor },
|
||||||
|
#endif
|
||||||
|
|
||||||
{ "Profile Migrator",
|
{ "Profile Migrator",
|
||||||
NS_FIREFOX_PROFILEMIGRATOR_CID,
|
NS_FIREFOX_PROFILEMIGRATOR_CID,
|
||||||
NS_PROFILEMIGRATOR_CONTRACTID,
|
NS_PROFILEMIGRATOR_CONTRACTID,
|
||||||
|
|
|
@ -43,7 +43,7 @@ VPATH = @srcdir@
|
||||||
|
|
||||||
include $(DEPTH)/config/autoconf.mk
|
include $(DEPTH)/config/autoconf.mk
|
||||||
|
|
||||||
DIRS = src
|
DIRS = public src
|
||||||
|
|
||||||
ifdef ENABLE_TESTS
|
ifdef ENABLE_TESTS
|
||||||
DIRS += tests
|
DIRS += tests
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
function PROT_Application() {
|
function PROT_Application() {
|
||||||
this.debugZone= "application";
|
this.debugZone= "application";
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
// TODO This is truly lame; we definitely want something better
|
// TODO This is truly lame; we definitely want something better
|
||||||
function runUnittests() {
|
function runUnittests() {
|
||||||
if (false) {
|
if (false) {
|
||||||
|
@ -81,6 +82,7 @@ function PROT_Application() {
|
||||||
};
|
};
|
||||||
|
|
||||||
runUnittests();
|
runUnittests();
|
||||||
|
#endif
|
||||||
|
|
||||||
// expose some classes
|
// expose some classes
|
||||||
this.G_TabbedBrowserWatcher = G_TabbedBrowserWatcher;
|
this.G_TabbedBrowserWatcher = G_TabbedBrowserWatcher;
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
<!-- Commands included by the browser overlay
|
|
||||||
browser/base/content/browser-sets.inc -->
|
|
||||||
<command id="safebrowsing-show-warning"
|
|
||||||
oncommand="SB_executeCommandLocally('safebrowsing-show-warning')" />
|
|
||||||
<command id="safebrowsing-accept-warning"
|
|
||||||
oncommand="SB_executeCommandLocally('safebrowsing-accept-warning')" />
|
|
||||||
<command id="safebrowsing-decline-warning"
|
|
||||||
oncommand="SB_executeCommandLocally('safebrowsing-decline-warning')" />
|
|
||||||
<command id="safebrowsing-palm-showmore"
|
|
||||||
oncommand="SB_executeCommandLocally('safebrowsing-palm-showmore')" />
|
|
||||||
<command id="safebrowsing-palm-phishingorg"
|
|
||||||
oncommand="SB_executeCommandLocally('safebrowsing-palm-phishingorg')" />
|
|
||||||
<command id="safebrowsing-palm-phishingfaq"
|
|
||||||
oncommand="SB_executeCommandLocally('safebrowsing-palm-phishingfaq')" />
|
|
||||||
<command id="safebrowsing-palm-fraudpage"
|
|
||||||
oncommand="SB_executeCommandLocally('safebrowsing-palm-fraudpage')" />
|
|
||||||
<command id="safebrowsing-palm-falsepositive"
|
|
||||||
oncommand="SB_executeCommandLocally('safebrowsing-palm-falsepositive')" />
|
|
||||||
<command id="safebrowsing-submit-blacklist"
|
|
||||||
oncommand="SB_executeCommandLocally('safebrowsing-submit-blacklist')" />
|
|
||||||
<command id="safebrowsing-submit-generic-phishing"
|
|
||||||
oncommand="SB_executeCommandLocally('safebrowsing-submit-generic-phishing')"/>
|
|
||||||
<command id="safebrowsing-preferences"
|
|
||||||
oncommand="SB_executeCommandLocally('safebrowsing-preferences')" />
|
|
||||||
<command id="safebrowsing-test-link"
|
|
||||||
oncommand="SB_executeCommandLocally('safebrowsing-test-link')" />
|
|
|
@ -375,3 +375,44 @@ PROT_Controller.prototype.onTabSwitch = function(e) {
|
||||||
PROT_Controller.prototype.loadURI = function(browser, url) {
|
PROT_Controller.prototype.loadURI = function(browser, url) {
|
||||||
browser.loadURI(url, null, null);
|
browser.loadURI(url, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check all browsers (tabs) to see if any of them are phishy.
|
||||||
|
* This isn't that clean of a design because as new wardens get
|
||||||
|
* added, this method needs to be updated manually. TODO: fix this
|
||||||
|
* when we add a second warden and know what the needs are.
|
||||||
|
*/
|
||||||
|
PROT_Controller.prototype.checkAllBrowsers = function() {
|
||||||
|
var browsers = this.tabWatcher_.getTabBrowser().browsers;
|
||||||
|
for (var i = 0, browser = null; browser = browsers[i]; ++i) {
|
||||||
|
// Check window and all frames.
|
||||||
|
this.checkAllHtmlWindows_(browser, browser.contentWindow)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check the HTML window and all containing frames for phishing urls.
|
||||||
|
* @param browser ChromeWindow that contains the html window
|
||||||
|
* @param win HTMLWindow
|
||||||
|
*/
|
||||||
|
PROT_Controller.prototype.checkAllHtmlWindows_ = function(browser, win) {
|
||||||
|
// Check this window
|
||||||
|
var doc = win && win.document;
|
||||||
|
if (!doc)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var url = doc.location.href;
|
||||||
|
|
||||||
|
var callback = BindToObject(this.browserView_.isProblemDocument_,
|
||||||
|
this.browserView_,
|
||||||
|
browser,
|
||||||
|
doc,
|
||||||
|
this.phishingWarden_);
|
||||||
|
|
||||||
|
this.phishingWarden_.checkUrl_(url, callback);
|
||||||
|
|
||||||
|
// Check all frames
|
||||||
|
for (var i = 0, frame = null; frame = win.frames[i]; ++i) {
|
||||||
|
this.checkAllHtmlWindows_(browser, frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -42,9 +42,6 @@
|
||||||
// This class does _not_ embody semantics, defaults, or the like. If we
|
// This class does _not_ embody semantics, defaults, or the like. If we
|
||||||
// need something that does, we'll add our own preference registry.
|
// need something that does, we'll add our own preference registry.
|
||||||
//
|
//
|
||||||
// TODO: These values are actually specific to SafeBrowsing, not url
|
|
||||||
// classifier, so this file should be moved into
|
|
||||||
// browser/components/safebrowsing
|
|
||||||
// TODO: many of these values should just be moved directly into code.
|
// TODO: many of these values should just be moved directly into code.
|
||||||
// TODO: The code needs to fail more gracefully if these values aren't set
|
// TODO: The code needs to fail more gracefully if these values aren't set
|
||||||
// E.g., createInstance should fail for listmanager without these.
|
// E.g., createInstance should fail for listmanager without these.
|
||||||
|
|
|
@ -1,266 +0,0 @@
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the Mozilla Public License Version
|
|
||||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*
|
|
||||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
||||||
* for the specific language governing rights and limitations under the
|
|
||||||
* License.
|
|
||||||
*
|
|
||||||
* The Original Code is Google Safe Browsing.
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is Google Inc.
|
|
||||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
|
||||||
* the Initial Developer. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
* Fritz Schneider <fritz@google.com> (original author)
|
|
||||||
*
|
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
|
||||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
||||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
||||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
||||||
* of those above. If you wish to allow use of your version of this file only
|
|
||||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
||||||
* use your version of this file under the terms of the MPL, indicate your
|
|
||||||
* decision by deleting the provisions above and replace them with the notice
|
|
||||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
||||||
* the provisions above, a recipient may use your version of this file under
|
|
||||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
|
|
||||||
// A NavWatcher abstracts away the mechanics of listening for progresslistener-
|
|
||||||
// based notifications. You register on it to hear these notifications instead
|
|
||||||
// of on a tabbedbrowser or the docloader service.
|
|
||||||
//
|
|
||||||
// Since it hooks the docloader service, you only need one NavWatcher
|
|
||||||
// per application (as opposed to a TabbedBrowserWatcher, of which you need
|
|
||||||
// one per tabbedbrowser, meaning one per browser window).
|
|
||||||
//
|
|
||||||
// The notifications you can register to hear are:
|
|
||||||
//
|
|
||||||
// EVENT DESCRIPTION
|
|
||||||
// ----- -----------
|
|
||||||
//
|
|
||||||
// docnavstart Fires when the request for a Document has begun. This is
|
|
||||||
// as early a notification as you can get (roughly
|
|
||||||
// equivalent to STATE_START). As a result, there is no
|
|
||||||
// guarantee that when the notification fires the request
|
|
||||||
// has been associated with a Document accessible in a
|
|
||||||
// browser somewhere; the only guarantee is that there
|
|
||||||
// _will_ be, baring some major error. You can handle
|
|
||||||
// such error cases gracefully by examining the nsIRequest
|
|
||||||
// isPending flag. See phishing-warden.js for an example.
|
|
||||||
//
|
|
||||||
// For docnavstart the event object you'll receive will have the following
|
|
||||||
// properties:
|
|
||||||
//
|
|
||||||
// request -- reference to the nsIRequest of the new request
|
|
||||||
// url -- String containing the URL the request is for (from
|
|
||||||
// reuest.name, currently, but might be something better
|
|
||||||
// in the future)
|
|
||||||
//
|
|
||||||
// Example:
|
|
||||||
//
|
|
||||||
// function handler(e /*event object*/) {
|
|
||||||
// foo(e.request);
|
|
||||||
// };
|
|
||||||
// var watcher = new G_NavWatcher();
|
|
||||||
// watcher.registerListener("docnavstart", handler);
|
|
||||||
// watcher.removeListener("docnavstart", handler);
|
|
||||||
//
|
|
||||||
// TODO: should probably make both NavWatcher and TabbedBrowserWatcher
|
|
||||||
// subclasses of EventRegistrar
|
|
||||||
//
|
|
||||||
// TODO: might make a stateful NavWatcher, one that takes care of mapping
|
|
||||||
// requests and urls to Documents.
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The NavWatcher abstracts listening for progresslistener-based
|
|
||||||
* notifications.
|
|
||||||
*
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function G_NavWatcher() {
|
|
||||||
this.debugZone = "navwatcher";
|
|
||||||
this.events = G_NavWatcher.events; // Convenience pointer
|
|
||||||
|
|
||||||
this.registrar_ = new EventRegistrar(this.events);
|
|
||||||
|
|
||||||
var wp = Ci.nsIWebProgress;
|
|
||||||
var wpService = Cc["@mozilla.org/docloaderservice;1"].getService(wp);
|
|
||||||
wpService.addProgressListener(this, wp.NOTIFY_STATE_REQUEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Events for which listeners can register. Future additions could include
|
|
||||||
// things such as docnavstop or navstart (for any navigation).
|
|
||||||
G_NavWatcher.events = {
|
|
||||||
DOCNAVSTART: "docnavstart",
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* We implement nsIWebProgressListener
|
|
||||||
*/
|
|
||||||
G_NavWatcher.prototype.QueryInterface = function(iid) {
|
|
||||||
if (iid.equals(Ci.nsISupports) ||
|
|
||||||
iid.equals(Ci.nsIWebProgressListener) ||
|
|
||||||
iid.equals(Ci.nsISupportsWeakReference))
|
|
||||||
return this;
|
|
||||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register to receive events of a particular type
|
|
||||||
*
|
|
||||||
* @param eventType String indicating the event (see
|
|
||||||
* G_NavWatcher.events)
|
|
||||||
*
|
|
||||||
* @param listener Function to invoke when the event occurs. See top-
|
|
||||||
* level comments for parameters.
|
|
||||||
*/
|
|
||||||
G_NavWatcher.prototype.registerListener = function(eventType,
|
|
||||||
listener) {
|
|
||||||
this.registrar_.registerListener(eventType, listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregister a listener.
|
|
||||||
*
|
|
||||||
* @param eventType String one of G_NavWatcher.events' members
|
|
||||||
*
|
|
||||||
* @param listener Function to remove as listener
|
|
||||||
*/
|
|
||||||
G_NavWatcher.prototype.removeListener = function(eventType,
|
|
||||||
listener) {
|
|
||||||
this.registrar_.removeListener(eventType, listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send an event to all listeners for that type.
|
|
||||||
*
|
|
||||||
* @param eventType String indicating the event to trigger
|
|
||||||
*
|
|
||||||
* @param e Object to pass to each listener (NOT copied -- be careful)
|
|
||||||
*/
|
|
||||||
G_NavWatcher.prototype.fire = function(eventType, e) {
|
|
||||||
this.registrar_.fire(eventType, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper function to determine whether a given URL is "spurious" for some
|
|
||||||
* definition of "spurious".
|
|
||||||
*
|
|
||||||
* @param url String containing the URL to check
|
|
||||||
*
|
|
||||||
* @returns Boolean indicating whether Fritz thinks it's too boring to notice
|
|
||||||
*/
|
|
||||||
G_NavWatcher.prototype.isSpurious_ = function(url) {
|
|
||||||
return (url == "about:blank" ||
|
|
||||||
url == "about:config" ||
|
|
||||||
url.startsWith("chrome://") ||
|
|
||||||
url.startsWith("file://") ||
|
|
||||||
url.startsWith("jar:"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* We do our dirtywork on state changes.
|
|
||||||
*/
|
|
||||||
G_NavWatcher.prototype.onStateChange = function(webProgress,
|
|
||||||
request,
|
|
||||||
stateFlags,
|
|
||||||
status) {
|
|
||||||
|
|
||||||
var wp = Ci.nsIWebProgressListener;
|
|
||||||
|
|
||||||
// Debugging stuff
|
|
||||||
// function D(msg) {
|
|
||||||
// dump(msg + "\n");
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// function w(s) {
|
|
||||||
// if (stateFlags & wp[s])
|
|
||||||
// D(s);
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// D("\nState change:");
|
|
||||||
// try {
|
|
||||||
// D("URL: " + request.name);
|
|
||||||
// } catch (e) {};
|
|
||||||
// w("STATE_IS_REQUEST");
|
|
||||||
// w("STATE_IS_DOCUMENT");
|
|
||||||
// w("STATE_IS_NETWORK");
|
|
||||||
// w("STATE_IS_WINDOW");
|
|
||||||
// w("STATE_STOP");
|
|
||||||
// w("STATE_START");
|
|
||||||
// w("STATE_REDIRECTING");
|
|
||||||
// w("STATE_TRANSFERRING");
|
|
||||||
// w("STATE_NEGOTIATING");
|
|
||||||
|
|
||||||
// Thanks Darin for helping with this
|
|
||||||
if (stateFlags & wp.STATE_START &&
|
|
||||||
stateFlags & wp.STATE_IS_REQUEST &&
|
|
||||||
request.loadFlags & Ci.nsIChannel.LOAD_DOCUMENT_URI) {
|
|
||||||
|
|
||||||
var url;
|
|
||||||
try {
|
|
||||||
url = request.name;
|
|
||||||
} catch(e) { return; }
|
|
||||||
|
|
||||||
if (!this.isSpurious_(url)) {
|
|
||||||
G_Debug(this, "firing docnavstart for " + url);
|
|
||||||
var eventObj = {
|
|
||||||
"request": request,
|
|
||||||
"url": url,
|
|
||||||
};
|
|
||||||
this.fire(this.events.DOCNAVSTART, eventObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// We don't care about the other kinds of updates (and won't get them since we
|
|
||||||
// only signed up for state requests), but we should implement the interface
|
|
||||||
// anyway.
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NOP
|
|
||||||
*/
|
|
||||||
G_NavWatcher.prototype.onLocationChange = function(webProgress,
|
|
||||||
request,
|
|
||||||
location) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NOP
|
|
||||||
*/
|
|
||||||
G_NavWatcher.prototype.onProgressChange = function(webProgress,
|
|
||||||
request,
|
|
||||||
curSelfProgress,
|
|
||||||
maxSelfProgress,
|
|
||||||
curTotalProgress,
|
|
||||||
maxTotalProgress) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NOP
|
|
||||||
*/
|
|
||||||
G_NavWatcher.prototype.onSecurityChange = function(webProgress,
|
|
||||||
request,
|
|
||||||
state) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NOP
|
|
||||||
*/
|
|
||||||
G_NavWatcher.prototype.onStatusChange = function(webProgress,
|
|
||||||
request,
|
|
||||||
status,
|
|
||||||
message) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NOP
|
|
||||||
*/
|
|
||||||
G_NavWatcher.prototype.onLinkIconAvailable = function(browser, aHref) { }
|
|
||||||
|
|
|
@ -169,10 +169,9 @@ PROT_PhishMsgDisplayerBase.prototype.acceptAction = function() {
|
||||||
* Invoked when the browser is resized
|
* Invoked when the browser is resized
|
||||||
*/
|
*/
|
||||||
PROT_PhishMsgDisplayerBase.prototype.onBrowserResized_ = function(event) {
|
PROT_PhishMsgDisplayerBase.prototype.onBrowserResized_ = function(event) {
|
||||||
|
G_Debug(this, "Got resize for " + event.target);
|
||||||
|
|
||||||
G_Debug(this, "Got resize for " + event.target.nodeName);
|
if (event.target == this.doc_.defaultView) {
|
||||||
|
|
||||||
if (event.target == this.doc_) {
|
|
||||||
G_Debug(this, "User resized browser.");
|
G_Debug(this, "User resized browser.");
|
||||||
|
|
||||||
if (this.messageShowing_) {
|
if (this.messageShowing_) {
|
||||||
|
@ -246,6 +245,14 @@ PROT_PhishMsgDisplayerBase.prototype.start = function() {
|
||||||
this.commandController_ = new PROT_CommandController(this.commandHandlers_);
|
this.commandController_ = new PROT_CommandController(this.commandHandlers_);
|
||||||
this.doc_.defaultView.controllers.appendController(this.commandController_);
|
this.doc_.defaultView.controllers.appendController(this.commandController_);
|
||||||
|
|
||||||
|
// Load the overlay if we haven't already.
|
||||||
|
var stack = this.doc_.getElementById('safebrowsing-content-stack');
|
||||||
|
if (!stack) {
|
||||||
|
this.doc_.loadOverlay(
|
||||||
|
"chrome://browser/content/safebrowsing/warning-overlay.xul",
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
this.resizeHandler_ = BindToObject(this.onBrowserResized_, this);
|
this.resizeHandler_ = BindToObject(this.onBrowserResized_, this);
|
||||||
this.doc_.defaultView.addEventListener("resize",
|
this.doc_.defaultView.addEventListener("resize",
|
||||||
this.resizeHandler_,
|
this.resizeHandler_,
|
||||||
|
|
|
@ -87,10 +87,6 @@ function PROT_PhishingWarden() {
|
||||||
// We use this dude to do lookups on our remote server
|
// We use this dude to do lookups on our remote server
|
||||||
this.fetcher_ = new PROT_TRFetcher();
|
this.fetcher_ = new PROT_TRFetcher();
|
||||||
|
|
||||||
var wp = Ci.nsIWebProgress;
|
|
||||||
var wpService = Cc["@mozilla.org/docloaderservice;1"].getService(wp);
|
|
||||||
wpService.addProgressListener(this, wp.NOTIFY_STATE_DOCUMENT);
|
|
||||||
|
|
||||||
// We need to know whether we're enabled and whether we're in advanced
|
// We need to know whether we're enabled and whether we're in advanced
|
||||||
// mode, so reflect the appropriate preferences into our state.
|
// mode, so reflect the appropriate preferences into our state.
|
||||||
|
|
||||||
|
@ -116,6 +112,12 @@ function PROT_PhishingWarden() {
|
||||||
// check out the warning.
|
// check out the warning.
|
||||||
this.testURLs_ = PROT_GlobalStore.getTestURLs();
|
this.testURLs_ = PROT_GlobalStore.getTestURLs();
|
||||||
|
|
||||||
|
// hook up our browser listener
|
||||||
|
this.progressListener_ = Cc["@mozilla.org/browser/safebrowsing/navstartlistener;1"]
|
||||||
|
.getService(Ci.nsIDocNavStartProgressListener);
|
||||||
|
this.progressListener_.callback = this;
|
||||||
|
this.progressListener_.enabled = this.phishWardenEnabled_;
|
||||||
|
|
||||||
G_Debug(this, "phishWarden initialized");
|
G_Debug(this, "phishWarden initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,6 +134,13 @@ PROT_PhishingWarden.prototype.QueryInterface = function(iid) {
|
||||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleanup on shutdown.
|
||||||
|
*/
|
||||||
|
PROT_PhishingWarden.prototype.shutdown = function() {
|
||||||
|
this.progressListener_.callback = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When a preference (either advanced features or the phishwarden
|
* When a preference (either advanced features or the phishwarden
|
||||||
* enabled) changes, we might have to start or stop asking for updates.
|
* enabled) changes, we might have to start or stop asking for updates.
|
||||||
|
@ -236,6 +245,7 @@ PROT_PhishingWarden.prototype.onPhishWardenEnabledPrefChanged = function(
|
||||||
this.phishWardenEnabled_ =
|
this.phishWardenEnabled_ =
|
||||||
this.prefs_.getBoolPrefOrDefault(prefName, this.phishWardenEnabled_);
|
this.prefs_.getBoolPrefOrDefault(prefName, this.phishWardenEnabled_);
|
||||||
this.maybeToggleUpdateChecking();
|
this.maybeToggleUpdateChecking();
|
||||||
|
this.progressListener_.enabled = this.phishWardenEnabled_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -264,17 +274,18 @@ PROT_PhishingWarden.prototype.onDocNavStart = function(request, url) {
|
||||||
// If we're on the test page and we're not explicitly disabled
|
// If we're on the test page and we're not explicitly disabled
|
||||||
// XXX Do we still need a test url or should each provider just put
|
// XXX Do we still need a test url or should each provider just put
|
||||||
// it in their local list?
|
// it in their local list?
|
||||||
//if (this.isBlacklistTestURL(url)) {
|
|
||||||
// this.houstonWeHaveAProblem_(request);
|
|
||||||
// return;
|
|
||||||
//}
|
|
||||||
// Either send a request off or check locally
|
// Either send a request off or check locally
|
||||||
if (this.checkRemote_) {
|
if (this.checkRemote_) {
|
||||||
// TODO: Use local whitelists to suppress remote BL lookups.
|
// First check to see if it's a blacklist url.
|
||||||
this.fetcher_.get(url,
|
if (this.isBlacklistTestURL(url)) {
|
||||||
BindToObject(this.onTRFetchComplete,
|
this.houstonWeHaveAProblem_(request);
|
||||||
this,
|
} else {
|
||||||
request));
|
// TODO: Use local whitelists to suppress remote BL lookups.
|
||||||
|
this.fetcher_.get(url,
|
||||||
|
BindToObject(this.onTRFetchComplete,
|
||||||
|
this,
|
||||||
|
request));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Check the local lists for a match.
|
// Check the local lists for a match.
|
||||||
// XXX This is to not slow down Tp. The real solution is to
|
// XXX This is to not slow down Tp. The real solution is to
|
||||||
|
@ -440,6 +451,11 @@ PROT_PhishingWarden.prototype.isBlacklistTestURL = function(url) {
|
||||||
* @param callback Function
|
* @param callback Function
|
||||||
*/
|
*/
|
||||||
PROT_PhishingWarden.prototype.checkUrl_ = function(url, callback) {
|
PROT_PhishingWarden.prototype.checkUrl_ = function(url, callback) {
|
||||||
|
// First check to see if it's a blacklist url.
|
||||||
|
if (this.isBlacklistTestURL(url)) {
|
||||||
|
callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!this.isSpurious_(url))
|
if (!this.isSpurious_(url))
|
||||||
this.isEvilURL_(url, callback);
|
this.isEvilURL_(url, callback);
|
||||||
}
|
}
|
||||||
|
@ -495,69 +511,3 @@ PROT_PhishingWarden.prototype.isSpurious_ = function(url) {
|
||||||
url.startsWith("jar:") ||
|
url.startsWith("jar:") ||
|
||||||
url.startsWith("javascript:"));
|
url.startsWith("javascript:"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* We do our dirtywork on state changes.
|
|
||||||
*/
|
|
||||||
PROT_PhishingWarden.prototype.onStateChange = function(webProgress,
|
|
||||||
request,
|
|
||||||
stateFlags,
|
|
||||||
status) {
|
|
||||||
var wp = Ci.nsIWebProgressListener;
|
|
||||||
|
|
||||||
// Thanks Darin for helping with this
|
|
||||||
if (stateFlags & wp.STATE_START &&
|
|
||||||
stateFlags & wp.STATE_IS_REQUEST &&
|
|
||||||
request.loadFlags & Ci.nsIChannel.LOAD_DOCUMENT_URI &&
|
|
||||||
this.phishWardenEnabled_ === true) {
|
|
||||||
|
|
||||||
var url;
|
|
||||||
try {
|
|
||||||
url = request.name;
|
|
||||||
} catch(e) { return; }
|
|
||||||
|
|
||||||
G_Debug(this, "firing docnavstart for " + url);
|
|
||||||
this.onDocNavStart(request, url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// We don't care about the other kinds of updates (and won't get them since we
|
|
||||||
// only signed up for state requests), but we should implement the interface
|
|
||||||
// anyway.
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NOP
|
|
||||||
*/
|
|
||||||
PROT_PhishingWarden.prototype.onLocationChange = function(webProgress,
|
|
||||||
request,
|
|
||||||
location) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NOP
|
|
||||||
*/
|
|
||||||
PROT_PhishingWarden.prototype.onProgressChange = function(webProgress,
|
|
||||||
request,
|
|
||||||
curSelfProgress,
|
|
||||||
maxSelfProgress,
|
|
||||||
curTotalProgress,
|
|
||||||
maxTotalProgress) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NOP
|
|
||||||
*/
|
|
||||||
PROT_PhishingWarden.prototype.onSecurityChange = function(webProgress,
|
|
||||||
request,
|
|
||||||
state) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NOP
|
|
||||||
*/
|
|
||||||
PROT_PhishingWarden.prototype.onStatusChange = function(webProgress,
|
|
||||||
request,
|
|
||||||
status,
|
|
||||||
message) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NOP
|
|
||||||
*/
|
|
||||||
PROT_PhishingWarden.prototype.onLinkIconAvailable = function(browser, aHref) { }
|
|
||||||
|
|
|
@ -1,168 +0,0 @@
|
||||||
<!-- browser.xul overlay
|
|
||||||
included from browser/base/content/browser.xul -->
|
|
||||||
|
|
||||||
<!-- This dims out the browser content -->
|
|
||||||
|
|
||||||
<vbox id="safebrowsing-dim-area-transp" hidden="true">
|
|
||||||
<spacer flex="1" />
|
|
||||||
</vbox>
|
|
||||||
|
|
||||||
<!-- This is the spike aka tail on top of the warning -->
|
|
||||||
|
|
||||||
<hbox id="safebrowsing-palm-message-tail-container" hidden="true"
|
|
||||||
pack="end">
|
|
||||||
<image id="safebrowsing-palm-message-tail"
|
|
||||||
src="chrome://browser/skin/safebrowsing/tail.png" />
|
|
||||||
</hbox>
|
|
||||||
|
|
||||||
<!-- This is the phishing afterload warning message -->
|
|
||||||
|
|
||||||
<vbox id="safebrowsing-palm-message" hidden="true" pack="center"
|
|
||||||
class="safebrowsing-palm-fixed-width">
|
|
||||||
|
|
||||||
<!-- This is the main warning area -->
|
|
||||||
|
|
||||||
<vbox id="safebrowsing-palm-message-content"
|
|
||||||
class="safebrowsing-palm-fixed-width safebrowsing-palm-message-bubble">
|
|
||||||
|
|
||||||
<!-- Top line -->
|
|
||||||
|
|
||||||
<hbox id="safebrowsing-palm-message-titlebox"
|
|
||||||
class="safebrowsing-palm-fixed-width">
|
|
||||||
<image
|
|
||||||
src="chrome://browser/skin/safebrowsing/warning24x24.png"
|
|
||||||
id="safebrowsing-palm-title-icon" />
|
|
||||||
<description id="safebrowsing-palm-message-title"
|
|
||||||
class="safebrowsing-palm-title"
|
|
||||||
value="&safeb.palm.warning.heading;" />
|
|
||||||
<spacer flex="1" />
|
|
||||||
<vbox pack="start" align="start">
|
|
||||||
<box onclick="goDoCommand('safebrowsing-decline-warning')"><image
|
|
||||||
src="chrome://browser/skin/safebrowsing/close16x16.png"
|
|
||||||
id="safebrowsing-palm-close" /></box>
|
|
||||||
<spacer flex="1" />
|
|
||||||
</vbox>
|
|
||||||
</hbox>
|
|
||||||
|
|
||||||
<!-- Content area: short warning -->
|
|
||||||
|
|
||||||
<description id="safebrowsing-palm-content"
|
|
||||||
class="safebrowsing-paragraph">
|
|
||||||
&safeb.palm.message.part1;
|
|
||||||
<html:a class="safebrowsing-palm-link" tabindex="1"
|
|
||||||
statustext="&safeb.palm.showmore.statustext;"
|
|
||||||
onmouseover="SB_setStatus(this.getAttribute('statustext'))"
|
|
||||||
onmouseout="SB_clearStatus()"
|
|
||||||
id="safebrowsing-palm-showmore-link" href="#"
|
|
||||||
onclick="goDoCommand('safebrowsing-palm-showmore')">
|
|
||||||
&safeb.palm.message.link1.more;
|
|
||||||
</html:a>
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<!-- Content area: rest of the warning, revealed if the user
|
|
||||||
hits the more link -->
|
|
||||||
|
|
||||||
<vbox id="safebrowsing-palm-extended-message" hidden="true"
|
|
||||||
class="safebrowsing-palm-fixed-width">
|
|
||||||
|
|
||||||
<description class="safebrowsing-palm-paragraph">
|
|
||||||
&safeb.palm.message.part2;
|
|
||||||
<html:a class="safebrowsing-palm-link" tabindex="2"
|
|
||||||
id="safebrowsing-palm-faq-link"
|
|
||||||
onmouseover="SB_setStatusFor(this.id)"
|
|
||||||
onmouseout="SB_clearStatus()"
|
|
||||||
onclick="goDoCommand('safebrowsing-palm-phishingfaq')">
|
|
||||||
&safeb.palm.message.link2.phishing.faq;</html:a>
|
|
||||||
&safeb.palm.message.part3;
|
|
||||||
<html:a class="safebrowsing-palm-link" tabindex="3"
|
|
||||||
id="safebrowsing-palm-phishingorg-link"
|
|
||||||
onmouseover="SB_setStatusFor(this.id)"
|
|
||||||
onmouseout="SB_clearStatus()"
|
|
||||||
onclick="goDoCommand('safebrowsing-palm-phishingorg')">
|
|
||||||
&safeb.palm.message.link3.antiphishing.org;</html:a>&safeb.palm.message.part3.dot;
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<description class="safebrowsing-palm-paragraph">
|
|
||||||
&safeb.palm.message.part4;
|
|
||||||
<html:a class="safebrowsing-palm-link" tabindex="4"
|
|
||||||
id="safebrowsing-palm-fraudpage-link"
|
|
||||||
onmouseover="SB_setStatusFor(this.id)"
|
|
||||||
onmouseout="SB_clearStatus()"
|
|
||||||
onclick="goDoCommand('safebrowsing-palm-fraudpage')">
|
|
||||||
&safeb.palm.message.link4.gwghome;</html:a>&safeb.palm.message.part4.dot;</description>
|
|
||||||
<description class="safebrowsing-palm-paragraph">
|
|
||||||
&safeb.palm.message.part5;<html:a
|
|
||||||
class="safebrowsing-palm-link" tabindex="6"
|
|
||||||
id="safebrowsing-palm-falsepositive-link"
|
|
||||||
onmouseover="SB_setStatusFor(this.id)"
|
|
||||||
onmouseout="SB_clearStatus()"
|
|
||||||
onclick="goDoCommand('safebrowsing-palm-falsepositive')">
|
|
||||||
&safeb.palm.message.link5.report;</html:a>&safeb.palm.message.part5.dot;
|
|
||||||
</description>
|
|
||||||
</vbox>
|
|
||||||
|
|
||||||
<!-- Main action links -->
|
|
||||||
|
|
||||||
<hbox id="safebrowsing-palm-message-actionbox" pack="center"
|
|
||||||
align="center"
|
|
||||||
class="safebrowsing-palm-fixed-width">
|
|
||||||
<description>
|
|
||||||
<html:a
|
|
||||||
class="safebrowsing-palm-link safebrowsing-palm-bigtext safebrowsing-padded"
|
|
||||||
statustext="&safeb.palm.accept.statustext;"
|
|
||||||
id="safebrowsing-palm-accept-link"
|
|
||||||
onmouseover="SB_setStatus(this.getAttribute('statustext'))"
|
|
||||||
onmouseout="SB_clearStatus()"
|
|
||||||
tabindex="2"
|
|
||||||
onclick="goDoCommand('safebrowsing-accept-warning')">
|
|
||||||
&safeb.palm.accept.label;</html:a></description>
|
|
||||||
<spacer />
|
|
||||||
<spacer />
|
|
||||||
<description>
|
|
||||||
<html:a
|
|
||||||
class="safebrowsing-palm-link safebrowsing-palm-bigtext safebrowsing-padded"
|
|
||||||
statustext="&safeb.palm.decline.statustext;"
|
|
||||||
id="safebrowsing-palm-decline-link"
|
|
||||||
onmouseover="SB_setStatus(this.getAttribute('statustext'))"
|
|
||||||
onmouseout="SB_clearStatus()"
|
|
||||||
tabindex="3"
|
|
||||||
onclick="goDoCommand('safebrowsing-decline-warning')">
|
|
||||||
&safeb.palm.decline.label;</html:a></description>
|
|
||||||
</hbox>
|
|
||||||
|
|
||||||
<!-- Footer -->
|
|
||||||
|
|
||||||
<hbox align="center" class="safebrowsing-palm-fixed-width">
|
|
||||||
<!-- branding logo
|
|
||||||
<image id="safebrowsing-palm-logo"
|
|
||||||
tooltiptext="&safeb.palm.provider.logo.tooltip;"
|
|
||||||
src="chrome://browser/skin/safebrowsing/logo.png" />
|
|
||||||
-->
|
|
||||||
<Spacer flex="1" />
|
|
||||||
<hbox>
|
|
||||||
[<description><html:a id="safebrowsing-palm-report-link"
|
|
||||||
onmouseover="SB_setStatusFor(this.id)"
|
|
||||||
onmouseout="SB_clearStatus()"
|
|
||||||
class="safebrowsing-palm-smalltext safebrowsing-palm-link"
|
|
||||||
onclick="goDoCommand('safebrowsing-submit-generic-phishing')">
|
|
||||||
&safeb.palm.sendreport.label;</html:a></description>]
|
|
||||||
</hbox>
|
|
||||||
</hbox>
|
|
||||||
</vbox>
|
|
||||||
</vbox>
|
|
||||||
|
|
||||||
<!-- We position things over a canvas; to do so, we need a stack -->
|
|
||||||
|
|
||||||
<stack id="safebrowsing-content-stack" insertbefore="status-bar"
|
|
||||||
hidden="true">
|
|
||||||
|
|
||||||
<!-- The canvas goes here as the first child, but since it takes
|
|
||||||
up so much memory and is rarely used, we add and remove it
|
|
||||||
dynamically -->
|
|
||||||
|
|
||||||
<!-- This dims out the browser content -->
|
|
||||||
|
|
||||||
<vbox id="safebrowsing-dim-area-canvas" hidden="true" flex="1">
|
|
||||||
</vbox>
|
|
||||||
|
|
||||||
</stack>
|
|
|
@ -46,11 +46,17 @@ var safebrowsing = {
|
||||||
phishWarden: null,
|
phishWarden: null,
|
||||||
|
|
||||||
startup: function() {
|
startup: function() {
|
||||||
// XXX Defer this to make startup faster?
|
setTimeout(safebrowsing.deferredStartup, 2000);
|
||||||
|
|
||||||
|
// clean up
|
||||||
|
window.removeEventListener("load", safebrowsing.startup, false);
|
||||||
|
},
|
||||||
|
|
||||||
|
deferredStartup: function() {
|
||||||
var Cc = Components.classes;
|
var Cc = Components.classes;
|
||||||
var appContext = Cc["@mozilla.org/safebrowsing/application;1"]
|
var appContext = Cc["@mozilla.org/safebrowsing/application;1"]
|
||||||
.getService().wrappedJSObject;
|
.getService().wrappedJSObject;
|
||||||
safebrowsing.globalStore = appContext;
|
safebrowsing.globalStore = appContext.PROT_GlobalStore;
|
||||||
|
|
||||||
// Each new browser window needs its own controller.
|
// Each new browser window needs its own controller.
|
||||||
|
|
||||||
|
@ -60,11 +66,11 @@ var safebrowsing = {
|
||||||
safebrowsing.phishWarden = phishWarden;
|
safebrowsing.phishWarden = phishWarden;
|
||||||
|
|
||||||
// Register tables
|
// Register tables
|
||||||
// XXX: move table names to a pref
|
// XXX: move table names to a pref that we originally will download
|
||||||
|
// from the provider (need to workout protocol details)
|
||||||
phishWarden.registerWhiteTable("goog-white-domain");
|
phishWarden.registerWhiteTable("goog-white-domain");
|
||||||
phishWarden.registerWhiteTable("goog-white-url");
|
phishWarden.registerWhiteTable("goog-white-url");
|
||||||
phishWarden.registerBlackTable("goog-black-url");
|
phishWarden.registerBlackTable("goog-black-url");
|
||||||
phishWarden.registerBlackTable("goog-black-enchash");
|
|
||||||
|
|
||||||
// Download/update lists if we're in non-enhanced mode
|
// Download/update lists if we're in non-enhanced mode
|
||||||
phishWarden.maybeToggleUpdateChecking();
|
phishWarden.maybeToggleUpdateChecking();
|
||||||
|
@ -77,15 +83,24 @@ var safebrowsing = {
|
||||||
tabWatcher,
|
tabWatcher,
|
||||||
phishWarden);
|
phishWarden);
|
||||||
|
|
||||||
// clean up
|
// The initial pages may be a phishing site (e.g., user clicks on a link
|
||||||
window.removeEventListener("load", safebrowsing.startup, false);
|
// in an email message and it opens a new window with a phishing site),
|
||||||
|
// so we need to check all open tabs.
|
||||||
|
safebrowsing.controller.checkAllBrowsers();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clean up.
|
* Clean up.
|
||||||
*/
|
*/
|
||||||
shutdown: function() {
|
shutdown: function() {
|
||||||
safebrowsing.controller.shutdown();
|
if (safebrowsing.controller) {
|
||||||
|
// If the user shuts down before deferredStartup, there is no controller.
|
||||||
|
safebrowsing.controller.shutdown();
|
||||||
|
}
|
||||||
|
if (safebrowsing.phishWarden) {
|
||||||
|
safebrowsing.phishWarden.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
window.removeEventListener("unload", safebrowsing.shutdown, false);
|
window.removeEventListener("unload", safebrowsing.shutdown, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,32 +114,6 @@ window.addEventListener("unload", safebrowsing.shutdown, false);
|
||||||
|
|
||||||
// Some utils for our UI.
|
// Some utils for our UI.
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute a command on a window
|
|
||||||
*
|
|
||||||
* @param cmd String containing command to execute
|
|
||||||
* @param win Reference to Window on which to execute it
|
|
||||||
*/
|
|
||||||
function SB_executeCommand(cmd, win) {
|
|
||||||
try {
|
|
||||||
var disp = win.document.commandDispatcher;
|
|
||||||
var ctrl = disp.getControllerForCommand(cmd);
|
|
||||||
ctrl.doCommand(cmd);
|
|
||||||
} catch (e) {
|
|
||||||
dump("Exception on command: " + cmd + "\n");
|
|
||||||
dump(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute a command on this window
|
|
||||||
*
|
|
||||||
* @param cmd String containing command to execute
|
|
||||||
*/
|
|
||||||
function SB_executeCommandLocally(cmd) {
|
|
||||||
SB_executeCommand(cmd, window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set status text for a particular link. We look the URLs up in our
|
* Set status text for a particular link. We look the URLs up in our
|
||||||
* globalstore.
|
* globalstore.
|
||||||
|
|
|
@ -166,8 +166,8 @@ PROT_TRFetcher.prototype.extractResponse_ = function(responseText) {
|
||||||
return this.protocol4Parser_.parse(responseText);
|
return this.protocol4Parser_.parse(responseText);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
// Unittests
|
// Unittests
|
||||||
|
|
||||||
function TEST_PROT_TRFetcher() {
|
function TEST_PROT_TRFetcher() {
|
||||||
if (G_GDEBUG) {
|
if (G_GDEBUG) {
|
||||||
var z = "trfetcher UNITTEST";
|
var z = "trfetcher UNITTEST";
|
||||||
|
@ -203,3 +203,4 @@ function TEST_PROT_TRFetcher() {
|
||||||
G_Debug(z, "PASSED");
|
G_Debug(z, "PASSED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,178 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<!-- This css and dtd are for the phishing warning message -->
|
||||||
|
|
||||||
|
<?xml-stylesheet
|
||||||
|
href="chrome://browser/skin/safebrowsing/browser-protection.css"
|
||||||
|
type="text/css" ?>
|
||||||
|
<!DOCTYPE
|
||||||
|
window SYSTEM "chrome://browser/locale/safebrowsing/phishing-afterload-warning-message.dtd">
|
||||||
|
|
||||||
|
<overlay id="safebrowsing-overlay"
|
||||||
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||||
|
|
||||||
|
<window id="main-window">
|
||||||
|
<!-- This dims out the browser content -->
|
||||||
|
|
||||||
|
<vbox id="safebrowsing-dim-area-transp" hidden="true">
|
||||||
|
<spacer flex="1" />
|
||||||
|
</vbox>
|
||||||
|
|
||||||
|
<!-- This is the spike aka tail on top of the warning -->
|
||||||
|
|
||||||
|
<hbox id="safebrowsing-palm-message-tail-container" hidden="true"
|
||||||
|
pack="end">
|
||||||
|
<image id="safebrowsing-palm-message-tail"
|
||||||
|
src="chrome://browser/skin/safebrowsing/tail.png" />
|
||||||
|
</hbox>
|
||||||
|
|
||||||
|
<!-- This is the phishing afterload warning message -->
|
||||||
|
|
||||||
|
<vbox id="safebrowsing-palm-message" hidden="true" pack="center"
|
||||||
|
class="safebrowsing-palm-fixed-width">
|
||||||
|
|
||||||
|
<!-- This is the main warning area -->
|
||||||
|
|
||||||
|
<vbox id="safebrowsing-palm-message-content"
|
||||||
|
class="safebrowsing-palm-fixed-width safebrowsing-palm-message-bubble">
|
||||||
|
|
||||||
|
<!-- Top line -->
|
||||||
|
|
||||||
|
<hbox id="safebrowsing-palm-message-titlebox"
|
||||||
|
class="safebrowsing-palm-fixed-width">
|
||||||
|
<image
|
||||||
|
src="chrome://browser/skin/safebrowsing/warning24x24.png"
|
||||||
|
id="safebrowsing-palm-title-icon" />
|
||||||
|
<description id="safebrowsing-palm-message-title"
|
||||||
|
class="safebrowsing-palm-title"
|
||||||
|
value="&safeb.palm.warning.heading;" />
|
||||||
|
<spacer flex="1" />
|
||||||
|
<vbox pack="start" align="start">
|
||||||
|
<image
|
||||||
|
src="chrome://browser/skin/safebrowsing/close16x16.png"
|
||||||
|
id="safebrowsing-palm-close"
|
||||||
|
onclick="goDoCommand('safebrowsing-decline-warning')" />
|
||||||
|
</vbox>
|
||||||
|
</hbox>
|
||||||
|
|
||||||
|
<!-- Content area: short warning -->
|
||||||
|
|
||||||
|
<description id="safebrowsing-palm-content"
|
||||||
|
class="safebrowsing-paragraph">
|
||||||
|
&safeb.palm.message.part1;
|
||||||
|
<label class="text-link plain"
|
||||||
|
statustext="&safeb.palm.showmore.statustext;"
|
||||||
|
onmouseover="SB_setStatus(this.getAttribute('statustext'))"
|
||||||
|
onmouseout="SB_clearStatus()"
|
||||||
|
id="safebrowsing-palm-showmore-link"
|
||||||
|
onclick="goDoCommand('safebrowsing-palm-showmore')"
|
||||||
|
value="&safeb.palm.message.link1.more;" />
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<!-- Content area: rest of the warning, revealed if the user
|
||||||
|
hits the more link -->
|
||||||
|
|
||||||
|
<vbox id="safebrowsing-palm-extended-message" hidden="true"
|
||||||
|
class="safebrowsing-palm-fixed-width">
|
||||||
|
|
||||||
|
<description class="safebrowsing-palm-paragraph">
|
||||||
|
&safeb.palm.message.part2;
|
||||||
|
<label class="text-link plain"
|
||||||
|
id="safebrowsing-palm-faq-link"
|
||||||
|
onmouseover="SB_setStatusFor(this.id)"
|
||||||
|
onmouseout="SB_clearStatus()"
|
||||||
|
onclick="goDoCommand('safebrowsing-palm-phishingfaq')"
|
||||||
|
value="&safeb.palm.message.link2.phishing.faq;" />
|
||||||
|
&safeb.palm.message.part3;
|
||||||
|
<label class="text-link plain"
|
||||||
|
id="safebrowsing-palm-phishingorg-link"
|
||||||
|
onmouseover="SB_setStatusFor(this.id)"
|
||||||
|
onmouseout="SB_clearStatus()"
|
||||||
|
onclick="goDoCommand('safebrowsing-palm-phishingorg')"
|
||||||
|
value="&safeb.palm.message.link3.antiphishing.org;" />&safeb.palm.message.part3.dot;
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<description class="safebrowsing-palm-paragraph">
|
||||||
|
&safeb.palm.message.part4;
|
||||||
|
<label class="text-link plain"
|
||||||
|
id="safebrowsing-palm-fraudpage-link"
|
||||||
|
onmouseover="SB_setStatusFor(this.id)"
|
||||||
|
onmouseout="SB_clearStatus()"
|
||||||
|
onclick="goDoCommand('safebrowsing-palm-fraudpage')"
|
||||||
|
value="&safeb.palm.message.link4.gwghome;" />&safeb.palm.message.part4.dot;
|
||||||
|
</description>
|
||||||
|
<description class="safebrowsing-palm-paragraph">
|
||||||
|
&safeb.palm.message.part5;
|
||||||
|
<label
|
||||||
|
class="text-link plain"
|
||||||
|
id="safebrowsing-palm-falsepositive-link"
|
||||||
|
onmouseover="SB_setStatusFor(this.id)"
|
||||||
|
onmouseout="SB_clearStatus()"
|
||||||
|
onclick="goDoCommand('safebrowsing-palm-falsepositive')"
|
||||||
|
value="&safeb.palm.message.link5.report;" />&safeb.palm.message.part5.dot;
|
||||||
|
</description>
|
||||||
|
</vbox>
|
||||||
|
|
||||||
|
<!-- Main action links -->
|
||||||
|
<hbox id="safebrowsing-palm-message-actionbox"
|
||||||
|
class="safebrowsing-palm-fixed-width"
|
||||||
|
align="center" crop="none">
|
||||||
|
<label
|
||||||
|
class="safebrowsing-palm-bigtext text-link plain"
|
||||||
|
statustext="&safeb.palm.accept.statustext;"
|
||||||
|
id="safebrowsing-palm-accept-link"
|
||||||
|
onmouseover="SB_setStatus(this.getAttribute('statustext'))"
|
||||||
|
onmouseout="SB_clearStatus()"
|
||||||
|
onclick="goDoCommand('safebrowsing-accept-warning')"
|
||||||
|
value="&safeb.palm.accept.label;" />
|
||||||
|
<spacer flex="1"/>
|
||||||
|
<label
|
||||||
|
class="safebrowsing-palm-bigtext text-link plain"
|
||||||
|
statustext="&safeb.palm.decline.statustext;"
|
||||||
|
id="safebrowsing-palm-decline-link"
|
||||||
|
onmouseover="SB_setStatus(this.getAttribute('statustext'))"
|
||||||
|
onmouseout="SB_clearStatus()"
|
||||||
|
onclick="goDoCommand('safebrowsing-decline-warning')"
|
||||||
|
value="&safeb.palm.decline.label;" />
|
||||||
|
</hbox>
|
||||||
|
|
||||||
|
<!-- Footer -->
|
||||||
|
|
||||||
|
<hbox align="center" class="safebrowsing-palm-fixed-width">
|
||||||
|
<!-- a branding logo could be added here
|
||||||
|
<image id="safebrowsing-palm-logo"
|
||||||
|
tooltiptext="&safeb.palm.provider.logo.tooltip;"
|
||||||
|
src="chrome://browser/skin/safebrowsing/logo.png" />
|
||||||
|
-->
|
||||||
|
<spacer flex="1" />
|
||||||
|
<description>
|
||||||
|
[
|
||||||
|
<label id="safebrowsing-palm-report-link"
|
||||||
|
onmouseover="SB_setStatusFor(this.id)"
|
||||||
|
onmouseout="SB_clearStatus()"
|
||||||
|
class="safebrowsing-palm-smalltext text-link plain"
|
||||||
|
onclick="goDoCommand('safebrowsing-submit-generic-phishing')"
|
||||||
|
value="&safeb.palm.sendreport.label;" />
|
||||||
|
]
|
||||||
|
</description>
|
||||||
|
</hbox>
|
||||||
|
</vbox>
|
||||||
|
</vbox>
|
||||||
|
|
||||||
|
<!-- We position things over a canvas; to do so, we need a stack -->
|
||||||
|
|
||||||
|
<stack id="safebrowsing-content-stack" insertbefore="status-bar"
|
||||||
|
hidden="true">
|
||||||
|
|
||||||
|
<!-- The canvas goes here as the first child, but since it takes
|
||||||
|
up so much memory and is rarely used, we add and remove it
|
||||||
|
dynamically -->
|
||||||
|
|
||||||
|
<!-- This dims out the browser content -->
|
||||||
|
|
||||||
|
<vbox id="safebrowsing-dim-area-canvas" hidden="true" flex="1">
|
||||||
|
</vbox>
|
||||||
|
|
||||||
|
</stack>
|
||||||
|
</window>
|
||||||
|
</overlay>
|
|
@ -1,22 +1,4 @@
|
||||||
browser.jar:
|
browser.jar:
|
||||||
# http://developer.mozilla.org/en/docs/jar.mn
|
|
||||||
# script file included into main browser.js
|
# script file included into main browser.js
|
||||||
+ content/browser/safebrowsing/sb-loader.js (content/sb-loader.js)
|
+ content/browser/safebrowsing/sb-loader.js (content/sb-loader.js)
|
||||||
#
|
+ content/browser/safebrowsing/warning-overlay.xul (content/warning-overlay.xul)
|
||||||
# main src files
|
|
||||||
+ content/browser/safebrowsing/application.js (content/application.js)
|
|
||||||
+ content/browser/safebrowsing/browser-view.js (content/browser-view.js)
|
|
||||||
+ content/browser/safebrowsing/controller.js (content/controller.js)
|
|
||||||
+ content/browser/safebrowsing/firefox-commands.js (content/firefox-commands.js)
|
|
||||||
+ content/browser/safebrowsing/globalstore.js (content/globalstore.js)
|
|
||||||
+ content/browser/safebrowsing/list-warden.js (content/list-warden.js)
|
|
||||||
+ content/browser/safebrowsing/phishing-afterload-displayer.js (content/phishing-afterload-displayer.js)
|
|
||||||
+ content/browser/safebrowsing/phishing-warden.js (content/phishing-warden.js)
|
|
||||||
+ content/browser/safebrowsing/reporter.js (content/reporter.js)
|
|
||||||
+ content/browser/safebrowsing/tr-fetcher.js (content/tr-fetcher.js)
|
|
||||||
#
|
|
||||||
# general library files
|
|
||||||
+ content/browser/safebrowsing/js/eventregistrar.js (content/js/eventregistrar.js)
|
|
||||||
+ content/browser/safebrowsing/js/listdictionary.js (content/js/listdictionary.js)
|
|
||||||
+ content/browser/safebrowsing/moz/navwatcher.js (content/moz/navwatcher.js)
|
|
||||||
+ content/browser/safebrowsing/moz/tabbedbrowserwatcher.js (content/moz/tabbedbrowserwatcher.js)
|
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
# ***** BEGIN LICENSE BLOCK *****
|
||||||
|
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
#
|
||||||
|
# The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
# http://www.mozilla.org/MPL/
|
||||||
|
#
|
||||||
|
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
# for the specific language governing rights and limitations under the
|
||||||
|
# License.
|
||||||
|
#
|
||||||
|
# The Original Code is mozilla.org code.
|
||||||
|
#
|
||||||
|
# The Initial Developer of the Original Code is Google Inc.
|
||||||
|
# Portions created by the Initial Developer are Copyright (C) 2006
|
||||||
|
# the Initial Developer. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Contributor(s):
|
||||||
|
# Brett Wilson <brettw@gmail.com>
|
||||||
|
#
|
||||||
|
# Alternatively, the contents of this file may be used under the terms of
|
||||||
|
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
# of those above. If you wish to allow use of your version of this file only
|
||||||
|
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
# use your version of this file under the terms of the MPL, indicate your
|
||||||
|
# decision by deleting the provisions above and replace them with the notice
|
||||||
|
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
# the provisions above, a recipient may use your version of this file under
|
||||||
|
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
#
|
||||||
|
# ***** END LICENSE BLOCK *****
|
||||||
|
|
||||||
|
|
||||||
|
DEPTH = ../../../..
|
||||||
|
topsrcdir = @top_srcdir@
|
||||||
|
srcdir = @srcdir@
|
||||||
|
VPATH = @srcdir@
|
||||||
|
|
||||||
|
include $(DEPTH)/config/autoconf.mk
|
||||||
|
|
||||||
|
MODULE = safebrowsing
|
||||||
|
XPIDL_MODULE = safebrowsing
|
||||||
|
|
||||||
|
XPIDLSRCS = nsIDocNavStartProgressListener.idl
|
||||||
|
|
||||||
|
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,64 @@
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is Google Safe Browsing.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Google Inc.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Brett Wilson <brettw@gmail.com>
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
#include "nsISupports.idl"
|
||||||
|
|
||||||
|
interface nsIRequest;
|
||||||
|
interface nsIURI;
|
||||||
|
|
||||||
|
|
||||||
|
[scriptable, function, uuid(163f3437-1d69-4db7-9ce1-fd420fba8219)]
|
||||||
|
interface nsIDocNavStartProgressCallback : nsISupports
|
||||||
|
{
|
||||||
|
void onDocNavStart(in nsIRequest aRequest, in AUTF8String aUri);
|
||||||
|
};
|
||||||
|
|
||||||
|
[scriptable, uuid(8b8474f3-2091-4afa-bbe0-f113e0472661)]
|
||||||
|
interface nsIDocNavStartProgressListener : nsISupports
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Set to true to enable this component. Defaults to false (disabled). When
|
||||||
|
* you set this to true, the listener will be attached to the docloader and
|
||||||
|
* the callback can start getting events.
|
||||||
|
*/
|
||||||
|
attribute boolean enabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback object to be used when enabled=true.
|
||||||
|
* NULL when there is no callback.
|
||||||
|
*/
|
||||||
|
attribute nsIDocNavStartProgressCallback callback;
|
||||||
|
};
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
# ***** BEGIN LICENSE BLOCK *****
|
# ***** BEGIN LICENSE BLOCK *****
|
||||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
#
|
#
|
||||||
|
@ -14,9 +13,8 @@
|
||||||
#
|
#
|
||||||
# The Original Code is mozilla.org code.
|
# The Original Code is mozilla.org code.
|
||||||
#
|
#
|
||||||
# The Initial Developer of the Original Code is
|
# The Initial Developer of the Original Code is Google Inc.
|
||||||
# Netscape Communications Corporation.
|
# Portions created by the Initial Developer are Copyright (C) 2006
|
||||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
|
||||||
# the Initial Developer. All Rights Reserved.
|
# the Initial Developer. All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Contributor(s):
|
# Contributor(s):
|
||||||
|
@ -43,7 +41,21 @@ VPATH = @srcdir@
|
||||||
|
|
||||||
include $(DEPTH)/config/autoconf.mk
|
include $(DEPTH)/config/autoconf.mk
|
||||||
|
|
||||||
|
MODULE = safebrowsing
|
||||||
|
LIBRARY_NAME = safebrowsing_s
|
||||||
|
MOZILLA_INTERNAL_API = 1
|
||||||
|
FORCE_STATIC_LIB = 1
|
||||||
|
|
||||||
|
REQUIRES = \
|
||||||
|
necko \
|
||||||
|
safebrowsing \
|
||||||
|
string \
|
||||||
|
uriloader \
|
||||||
|
xpcom
|
||||||
|
|
||||||
|
CPPSRCS = nsDocNavStartProgressListener.cpp
|
||||||
|
|
||||||
# EXTRA_COMPONENTS installs components written in JS to dist/bin/components
|
# EXTRA_COMPONENTS installs components written in JS to dist/bin/components
|
||||||
EXTRA_COMPONENTS = safebrowsingApplication.js
|
EXTRA_PP_COMPONENTS = nsSafebrowsingApplication.js
|
||||||
|
|
||||||
include $(topsrcdir)/config/rules.mk
|
include $(topsrcdir)/config/rules.mk
|
||||||
|
|
|
@ -0,0 +1,223 @@
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is Google Safe Browsing.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Google Inc.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Brett Wilson <brettw@gmail.com>
|
||||||
|
* based on JavaScript code by Fritz Schneider <fritz@google.com>
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
#include "nsCURILoader.h"
|
||||||
|
#include "nsDocNavStartProgressListener.h"
|
||||||
|
#include "nsIChannel.h"
|
||||||
|
#include "nsIRequest.h"
|
||||||
|
#include "nsIWebProgress.h"
|
||||||
|
#include "nsServiceManagerUtils.h"
|
||||||
|
#include "nsString.h"
|
||||||
|
|
||||||
|
NS_IMPL_ISUPPORTS3(nsDocNavStartProgressListener,
|
||||||
|
nsIDocNavStartProgressListener,
|
||||||
|
nsIWebProgressListener,
|
||||||
|
nsISupportsWeakReference)
|
||||||
|
|
||||||
|
nsDocNavStartProgressListener::nsDocNavStartProgressListener() :
|
||||||
|
mEnabled(PR_FALSE)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
nsDocNavStartProgressListener::~nsDocNavStartProgressListener()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// nsDocNavStartProgressListener::AttachListeners
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsDocNavStartProgressListener::AttachListeners()
|
||||||
|
{
|
||||||
|
nsresult rv;
|
||||||
|
nsCOMPtr<nsIWebProgress> webProgressService = do_GetService(
|
||||||
|
NS_DOCUMENTLOADER_SERVICE_CONTRACTID, &rv);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
return webProgressService->AddProgressListener(this,
|
||||||
|
nsIWebProgress::NOTIFY_STATE_DOCUMENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// nsDocNavStartProgressListener::DetachListeners
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsDocNavStartProgressListener::DetachListeners()
|
||||||
|
{
|
||||||
|
nsresult rv;
|
||||||
|
nsCOMPtr<nsIWebProgress> webProgressService = do_GetService(
|
||||||
|
NS_DOCUMENTLOADER_SERVICE_CONTRACTID, &rv);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
return webProgressService->RemoveProgressListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// nsIDocNavStartProgressCallback ***********************************************
|
||||||
|
|
||||||
|
// nsDocNavStartProgressListener::GetEnabled
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocNavStartProgressListener::GetEnabled(PRBool* aEnabled)
|
||||||
|
{
|
||||||
|
*aEnabled = mEnabled;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// nsDocNavStartProgressListener::SetEnabled
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocNavStartProgressListener::SetEnabled(PRBool aEnabled)
|
||||||
|
{
|
||||||
|
if (aEnabled && ! mEnabled) {
|
||||||
|
// enable component
|
||||||
|
mEnabled = PR_TRUE;
|
||||||
|
return AttachListeners();
|
||||||
|
} else if (! aEnabled && mEnabled) {
|
||||||
|
// disable component
|
||||||
|
mEnabled = PR_FALSE;
|
||||||
|
return DetachListeners();
|
||||||
|
}
|
||||||
|
return NS_OK; // nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// nsDocNavStartProgressListener::GetCallback
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocNavStartProgressListener::GetCallback(
|
||||||
|
nsIDocNavStartProgressCallback** aCallback)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aCallback);
|
||||||
|
*aCallback = mCallback;
|
||||||
|
NS_IF_ADDREF(*aCallback);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// nsDocNavStartProgressListener::SetCallback
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocNavStartProgressListener::SetCallback(
|
||||||
|
nsIDocNavStartProgressCallback* aCallback)
|
||||||
|
{
|
||||||
|
mCallback = aCallback;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// nsIWebProgressListener ******************************************************
|
||||||
|
|
||||||
|
|
||||||
|
// nsDocNavStartProgressListener::OnStateChange
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocNavStartProgressListener::OnStateChange(nsIWebProgress *aWebProgress,
|
||||||
|
nsIRequest *aRequest,
|
||||||
|
PRUint32 aStateFlags,
|
||||||
|
nsresult aStatus)
|
||||||
|
{
|
||||||
|
if (mEnabled && aStateFlags & STATE_START && aStateFlags & STATE_IS_REQUEST) {
|
||||||
|
// might be for us, check load flags
|
||||||
|
nsresult rv;
|
||||||
|
#ifdef DEBUG
|
||||||
|
nsLoadFlags loadFlags;
|
||||||
|
rv = aRequest->GetLoadFlags(&loadFlags);
|
||||||
|
NS_ASSERTION(NS_SUCCEEDED(rv) && loadFlags & nsIChannel::LOAD_DOCUMENT_URI,
|
||||||
|
"Unexpected load flags, we only registered for loads");
|
||||||
|
#endif
|
||||||
|
// send notification
|
||||||
|
nsCAutoString name;
|
||||||
|
rv = aRequest->GetName(name);
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
return NS_OK; // ignore requests with no name
|
||||||
|
if (mCallback)
|
||||||
|
mCallback->OnDocNavStart(aRequest, name);
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// nsDocNavStartProgressListener::OnProgressChange
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocNavStartProgressListener::OnProgressChange(nsIWebProgress *aWebProgress,
|
||||||
|
nsIRequest *aRequest,
|
||||||
|
PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress,
|
||||||
|
PRInt32 aCurTotalProgress,
|
||||||
|
PRInt32 aMaxTotalProgress)
|
||||||
|
{
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// nsDocNavStartProgressListener::OnLocationChange
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocNavStartProgressListener::OnLocationChange(nsIWebProgress *aWebProgress,
|
||||||
|
nsIRequest *aRequest,
|
||||||
|
nsIURI *aLocation)
|
||||||
|
{
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// nsDocNavStartProgressListener::OnStatusChange
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocNavStartProgressListener::OnStatusChange(nsIWebProgress *aWebProgress,
|
||||||
|
nsIRequest *aRequest,
|
||||||
|
nsresult aStatus,
|
||||||
|
const PRUnichar *aMessage)
|
||||||
|
{
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// nsDocNavStartProgressListener::OnSecurityChange
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocNavStartProgressListener::OnSecurityChange(nsIWebProgress *aWebProgress,
|
||||||
|
nsIRequest *aRequest,
|
||||||
|
PRUint32 aState)
|
||||||
|
{
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is Google Safe Browsing.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Google Inc.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Brett Wilson <brettw@gmail.com>
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
#include "nsIDocNavStartProgressListener.h"
|
||||||
|
#include "nsIWebProgressListener.h"
|
||||||
|
#include "nsCOMPtr.h"
|
||||||
|
#include "nsWeakReference.h"
|
||||||
|
|
||||||
|
class nsDocNavStartProgressListener : public nsIDocNavStartProgressListener,
|
||||||
|
public nsIWebProgressListener,
|
||||||
|
public nsSupportsWeakReference
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
nsDocNavStartProgressListener();
|
||||||
|
virtual ~nsDocNavStartProgressListener();
|
||||||
|
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
NS_DECL_NSIDOCNAVSTARTPROGRESSLISTENER
|
||||||
|
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
PRBool mEnabled;
|
||||||
|
nsCOMPtr<nsIDocNavStartProgressCallback> mCallback;
|
||||||
|
|
||||||
|
nsresult AttachListeners();
|
||||||
|
nsresult DetachListeners();
|
||||||
|
};
|
|
@ -0,0 +1,95 @@
|
||||||
|
const Cc = Components.classes;
|
||||||
|
const Ci = Components.interfaces;
|
||||||
|
|
||||||
|
// This is copied from toolkit/components/content/js/lang.js.
|
||||||
|
// It seems cleaner to copy this rather than #include from so far away.
|
||||||
|
Function.prototype.inherits = function(parentCtor) {
|
||||||
|
var tempCtor = function(){};
|
||||||
|
tempCtor.prototype = parentCtor.prototype;
|
||||||
|
this.superClass_ = parentCtor.prototype;
|
||||||
|
this.prototype = new tempCtor();
|
||||||
|
}
|
||||||
|
|
||||||
|
#include ../content/js/eventregistrar.js
|
||||||
|
#include ../content/js/listdictionary.js
|
||||||
|
#include ../content/moz/tabbedbrowserwatcher.js
|
||||||
|
|
||||||
|
#include ../content/application.js
|
||||||
|
#include ../content/browser-view.js
|
||||||
|
#include ../content/controller.js
|
||||||
|
#include ../content/firefox-commands.js
|
||||||
|
#include ../content/globalstore.js
|
||||||
|
#include ../content/list-warden.js
|
||||||
|
#include ../content/phishing-afterload-displayer.js
|
||||||
|
#include ../content/phishing-warden.js
|
||||||
|
#include ../content/reporter.js
|
||||||
|
#include ../content/tr-fetcher.js
|
||||||
|
|
||||||
|
var modScope = this;
|
||||||
|
function Init() {
|
||||||
|
var jslib = Cc["@mozilla.org/url-classifier/jslib;1"]
|
||||||
|
.getService().wrappedJSObject;
|
||||||
|
modScope.String.prototype.startsWith = jslib.String.prototype.startsWith;
|
||||||
|
modScope.G_Debug = jslib.G_Debug;
|
||||||
|
modScope.G_Assert = jslib.G_Assert;
|
||||||
|
modScope.G_Alarm = jslib.G_Alarm;
|
||||||
|
modScope.G_ConditionalAlarm = jslib.G_ConditionalAlarm;
|
||||||
|
modScope.G_Preferences = jslib.G_Preferences;
|
||||||
|
modScope.PROT_XMLFetcher = jslib.PROT_XMLFetcher;
|
||||||
|
modScope.BindToObject = jslib.BindToObject;
|
||||||
|
modScope.G_Protocol4Parser = jslib.G_Protocol4Parser;
|
||||||
|
modScope.G_ObjectSafeMap = jslib.G_ObjectSafeMap;
|
||||||
|
modScope.PROT_UrlCrypto = jslib.PROT_UrlCrypto;
|
||||||
|
|
||||||
|
// We only need to call Init once
|
||||||
|
modScope.Init = function() {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Module object
|
||||||
|
function SafebrowsingApplicationMod() {
|
||||||
|
this.firstTime = true;
|
||||||
|
this.cid = Components.ID("{c64d0bcb-8270-4ca7-a0b3-3380c8ffecb5}");
|
||||||
|
this.progid = "@mozilla.org/safebrowsing/application;1";
|
||||||
|
}
|
||||||
|
|
||||||
|
SafebrowsingApplicationMod.prototype.registerSelf = function(compMgr, fileSpec, loc, type) {
|
||||||
|
if (this.firstTime) {
|
||||||
|
this.firstTime = false;
|
||||||
|
throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
|
||||||
|
}
|
||||||
|
compMgr = compMgr.QueryInterface(Ci.nsIComponentRegistrar);
|
||||||
|
compMgr.registerFactoryLocation(this.cid,
|
||||||
|
"Safebrowsing Application Module",
|
||||||
|
this.progid,
|
||||||
|
fileSpec,
|
||||||
|
loc,
|
||||||
|
type);
|
||||||
|
};
|
||||||
|
|
||||||
|
SafebrowsingApplicationMod.prototype.getClassObject = function(compMgr, cid, iid) {
|
||||||
|
if (!cid.equals(this.cid))
|
||||||
|
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||||
|
if (!iid.equals(Ci.nsIFactory))
|
||||||
|
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
return this.factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
SafebrowsingApplicationMod.prototype.canUnload = function(compMgr) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
SafebrowsingApplicationMod.prototype.factory = {
|
||||||
|
createInstance: function(outer, iid) {
|
||||||
|
if (outer != null)
|
||||||
|
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||||
|
Init();
|
||||||
|
return new PROT_Application();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var ApplicationModInst = new SafebrowsingApplicationMod();
|
||||||
|
|
||||||
|
function NSGetModule(compMgr, fileSpec) {
|
||||||
|
return ApplicationModInst;
|
||||||
|
}
|
|
@ -1,99 +0,0 @@
|
||||||
const Cc = Components.classes;
|
|
||||||
const Ci = Components.interfaces;
|
|
||||||
const G_GDEBUG = false;
|
|
||||||
|
|
||||||
// Use subscript loader to load files. The files in ../content get mapped
|
|
||||||
// to chrome://browser/content/safebrowsing/. Order matters if one file depends
|
|
||||||
// on another file during initialization.
|
|
||||||
const LIB_FILES = [
|
|
||||||
// some files are from toolkit
|
|
||||||
"chrome://global/content/url-classifier/js/lang.js",
|
|
||||||
"chrome://global/content/url-classifier/moz/preferences.js",
|
|
||||||
"chrome://global/content/url-classifier/moz/filesystem.js",
|
|
||||||
"chrome://global/content/url-classifier/moz/debug.js", // req js/lang.js moz/prefs.js moz/filesystem.js
|
|
||||||
|
|
||||||
"chrome://global/content/url-classifier/js/arc4.js",
|
|
||||||
"chrome://global/content/url-classifier/moz/alarm.js",
|
|
||||||
"chrome://global/content/url-classifier/moz/base64.js",
|
|
||||||
"chrome://global/content/url-classifier/moz/cryptohasher.js",
|
|
||||||
"chrome://global/content/url-classifier/moz/lang.js",
|
|
||||||
"chrome://global/content/url-classifier/moz/objectsafemap.js",
|
|
||||||
"chrome://global/content/url-classifier/moz/observer.js",
|
|
||||||
"chrome://global/content/url-classifier/moz/protocol4.js",
|
|
||||||
"chrome://global/content/url-classifier/application.js",
|
|
||||||
"chrome://global/content/url-classifier/url-crypto.js",
|
|
||||||
"chrome://global/content/url-classifier/url-crypto-key-manager.js",
|
|
||||||
"chrome://global/content/url-classifier/xml-fetcher.js",
|
|
||||||
|
|
||||||
// some are in browser
|
|
||||||
"chrome://browser/content/safebrowsing/js/eventregistrar.js",
|
|
||||||
"chrome://browser/content/safebrowsing/js/listdictionary.js",
|
|
||||||
"chrome://browser/content/safebrowsing/moz/navwatcher.js",
|
|
||||||
"chrome://browser/content/safebrowsing/moz/tabbedbrowserwatcher.js",
|
|
||||||
|
|
||||||
"chrome://browser/content/safebrowsing/application.js",
|
|
||||||
"chrome://browser/content/safebrowsing/browser-view.js",
|
|
||||||
"chrome://browser/content/safebrowsing/controller.js",
|
|
||||||
"chrome://browser/content/safebrowsing/firefox-commands.js",
|
|
||||||
"chrome://browser/content/safebrowsing/globalstore.js",
|
|
||||||
"chrome://browser/content/safebrowsing/list-warden.js",
|
|
||||||
"chrome://browser/content/safebrowsing/phishing-afterload-displayer.js",
|
|
||||||
"chrome://browser/content/safebrowsing/phishing-warden.js",
|
|
||||||
"chrome://browser/content/safebrowsing/reporter.js",
|
|
||||||
"chrome://browser/content/safebrowsing/tr-fetcher.js",
|
|
||||||
];
|
|
||||||
|
|
||||||
for (var i = 0, libFile; libFile = LIB_FILES[i]; ++i) {
|
|
||||||
//dump('*** loading subscript ' + libFile + '\n');
|
|
||||||
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
||||||
.getService(Ci.mozIJSSubScriptLoader)
|
|
||||||
.loadSubScript(libFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Module object
|
|
||||||
function SafebrowsingApplicationMod() {
|
|
||||||
this.firstTime = true;
|
|
||||||
this.cid = Components.ID("{c64d0bcb-8270-4ca7-a0b3-3380c8ffecb5}");
|
|
||||||
this.progid = "@mozilla.org/safebrowsing/application;1";
|
|
||||||
}
|
|
||||||
|
|
||||||
SafebrowsingApplicationMod.prototype.registerSelf = function(compMgr, fileSpec, loc, type) {
|
|
||||||
if (this.firstTime) {
|
|
||||||
this.firstTime = false;
|
|
||||||
throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
|
|
||||||
}
|
|
||||||
compMgr = compMgr.QueryInterface(Ci.nsIComponentRegistrar);
|
|
||||||
compMgr.registerFactoryLocation(this.cid,
|
|
||||||
"Safebrowsing Application Module",
|
|
||||||
this.progid,
|
|
||||||
fileSpec,
|
|
||||||
loc,
|
|
||||||
type);
|
|
||||||
};
|
|
||||||
|
|
||||||
SafebrowsingApplicationMod.prototype.getClassObject = function(compMgr, cid, iid) {
|
|
||||||
if (!cid.equals(this.cid))
|
|
||||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
||||||
if (!iid.equals(Ci.nsIFactory))
|
|
||||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
|
|
||||||
return this.factory;
|
|
||||||
}
|
|
||||||
|
|
||||||
SafebrowsingApplicationMod.prototype.canUnload = function(compMgr) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
SafebrowsingApplicationMod.prototype.factory = {
|
|
||||||
createInstance: function(outer, iid) {
|
|
||||||
if (outer != null)
|
|
||||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
|
||||||
return new PROT_Application();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var ApplicationModInst = new SafebrowsingApplicationMod();
|
|
||||||
|
|
||||||
function NSGetModule(compMgr, fileSpec) {
|
|
||||||
return ApplicationModInst;
|
|
||||||
}
|
|
|
@ -1,15 +1,15 @@
|
||||||
<!ENTITY safeb.palm.warning.heading "Web Forgery">
|
<!ENTITY safeb.palm.warning.heading "Web Forgery">
|
||||||
|
|
||||||
<!ENTITY safeb.palm.message.part1 "This page is very likely to have been designed to trick users into sharing personal or financial information. Entering any personal information on this page may result in identity theft or other fraud.   ">
|
<!ENTITY safeb.palm.message.part1 "This page is very likely to have been designed to trick users into sharing personal or financial information. Entering any personal information on this page may result in identity theft or other fraud.  ">
|
||||||
<!ENTITY safeb.palm.message.link1.more "more »">
|
<!ENTITY safeb.palm.message.link1.more "more »">
|
||||||
<!ENTITY safeb.palm.showmore.statustext "Read more">
|
<!ENTITY safeb.palm.showmore.statustext "Read more">
|
||||||
<!ENTITY safeb.palm.message.part2 "Safe Browsing uses automated technology to warn you about web pages that we believe may be unsafe. This page appears to be a part of a scam known as a ">
|
<!ENTITY safeb.palm.message.part2 "Safe Browsing uses automated technology to warn you about web pages that we believe may be unsafe. This page appears to be a part of a scam known as a">
|
||||||
<!ENTITY safeb.palm.message.link2.phishing.faq "phishing">
|
<!ENTITY safeb.palm.message.link2.phishing.faq "phishing">
|
||||||
<!ENTITY safeb.palm.message.part3 "attack, in which criminals create fraudulent pages to mimic legitimate sources that you may trust. You can read more about phishing here">
|
<!ENTITY safeb.palm.message.part3 "attack, in which criminals create fraudulent pages to mimic legitimate sources that you may trust. You can read more about phishing at">
|
||||||
<!ENTITY safeb.palm.message.link3.antiphishing.org "antiphishing.org">
|
<!ENTITY safeb.palm.message.link3.antiphishing.org "antiphishing.org">
|
||||||
<!ENTITY safeb.palm.message.part3.dot ".">
|
<!ENTITY safeb.palm.message.part3.dot ".">
|
||||||
<!ENTITY safeb.palm.message.part4 "You can also learn more about ">
|
<!ENTITY safeb.palm.message.part4 "You can also learn more about">
|
||||||
<!ENTITY safeb.palm.message.link4.gwghome "about Safe Browsing">
|
<!ENTITY safeb.palm.message.link4.gwghome "Safe Browsing">
|
||||||
<!ENTITY safeb.palm.message.part4.dot ".">
|
<!ENTITY safeb.palm.message.part4.dot ".">
|
||||||
<!ENTITY safeb.palm.message.part5 "Finally, if you believe this page has been falsely flagged as a forgery, you can ">
|
<!ENTITY safeb.palm.message.part5 "Finally, if you believe this page has been falsely flagged as a forgery, you can ">
|
||||||
<!ENTITY safeb.palm.message.link5.report "report it">
|
<!ENTITY safeb.palm.message.link5.report "report it">
|
||||||
|
|
|
@ -35,12 +35,6 @@
|
||||||
max-height: 24px;
|
max-height: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.safebrowsing-palm-link {
|
|
||||||
color: blue;
|
|
||||||
cursor: pointer;
|
|
||||||
text-decoration: underline
|
|
||||||
}
|
|
||||||
|
|
||||||
.safebrowsing-palm-paragraph {
|
.safebrowsing-palm-paragraph {
|
||||||
padding-bottom: 2em;
|
padding-bottom: 2em;
|
||||||
}
|
}
|
||||||
|
@ -81,8 +75,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#safebrowsing-palm-message-actionbox {
|
#safebrowsing-palm-message-actionbox {
|
||||||
padding-top: 10px;
|
padding: 10px 10px 15px;
|
||||||
padding-bottom: 15px;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.safebrowsing-palm-bigtext {
|
.safebrowsing-palm-bigtext {
|
||||||
|
|
|
@ -35,12 +35,6 @@
|
||||||
max-height: 24px;
|
max-height: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.safebrowsing-palm-link {
|
|
||||||
color: blue;
|
|
||||||
cursor: pointer;
|
|
||||||
text-decoration: underline
|
|
||||||
}
|
|
||||||
|
|
||||||
.safebrowsing-palm-paragraph {
|
.safebrowsing-palm-paragraph {
|
||||||
padding-bottom: 2em;
|
padding-bottom: 2em;
|
||||||
}
|
}
|
||||||
|
@ -81,8 +75,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#safebrowsing-palm-message-actionbox {
|
#safebrowsing-palm-message-actionbox {
|
||||||
padding-top: 10px;
|
padding: 10px 10px 15px;
|
||||||
padding-bottom: 15px;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.safebrowsing-palm-bigtext {
|
.safebrowsing-palm-bigtext {
|
||||||
|
|
|
@ -4261,6 +4261,7 @@ browser)
|
||||||
MOZ_UPDATER=1
|
MOZ_UPDATER=1
|
||||||
MOZ_PHOENIX=1
|
MOZ_PHOENIX=1
|
||||||
MOZ_PLACES=1
|
MOZ_PLACES=1
|
||||||
|
MOZ_SAFE_BROWSING=1
|
||||||
MOZ_APP_VERSION=$FIREFOX_VERSION
|
MOZ_APP_VERSION=$FIREFOX_VERSION
|
||||||
MOZ_NO_XPCOM_OBSOLETE=1
|
MOZ_NO_XPCOM_OBSOLETE=1
|
||||||
MOZ_EXTENSIONS_DEFAULT=" cookie xml-rpc inspector gnomevfs permissions reporter spellcheck"
|
MOZ_EXTENSIONS_DEFAULT=" cookie xml-rpc inspector gnomevfs permissions reporter spellcheck"
|
||||||
|
|
|
@ -310,7 +310,7 @@ PROT_EnchashDecrypter.prototype.decryptData = function(data, host) {
|
||||||
return this.base64_.stringifyArray(encrypted_data);
|
return this.base64_.stringifyArray(encrypted_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
/**
|
/**
|
||||||
* Lame unittesting function
|
* Lame unittesting function
|
||||||
*/
|
*/
|
||||||
|
@ -541,4 +541,4 @@ function TEST_PROT_EnchashDecrypter() {
|
||||||
G_Debug(z, "PASSED");
|
G_Debug(z, "PASSED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -101,10 +101,6 @@ ARC4.prototype.crypt = function(data, opt_length) {
|
||||||
opt_length = data.length;
|
opt_length = data.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isArray(data)) {
|
|
||||||
throw new Error("Data parameter must be a byte array");
|
|
||||||
}
|
|
||||||
|
|
||||||
var i = this._i;
|
var i = this._i;
|
||||||
var j = this._j;
|
var j = this._j;
|
||||||
var S = this._S;
|
var S = this._S;
|
||||||
|
|
|
@ -128,7 +128,8 @@ function PROT_ListManager() {
|
||||||
|
|
||||||
this.observerServiceObserver_ = new G_ObserverServiceObserver(
|
this.observerServiceObserver_ = new G_ObserverServiceObserver(
|
||||||
'xpcom-shutdown',
|
'xpcom-shutdown',
|
||||||
BindToObject(this.shutdown_, this));
|
BindToObject(this.shutdown_, this),
|
||||||
|
true /*only once*/);
|
||||||
|
|
||||||
// Lazily create urlCrypto (see tr-fetcher.js)
|
// Lazily create urlCrypto (see tr-fetcher.js)
|
||||||
this.urlCrypto_ = null;
|
this.urlCrypto_ = null;
|
||||||
|
@ -142,7 +143,6 @@ PROT_ListManager.prototype.shutdown_ = function() {
|
||||||
for (var name in this.tablesData) {
|
for (var name in this.tablesData) {
|
||||||
delete this.tablesData[name];
|
delete this.tablesData[name];
|
||||||
}
|
}
|
||||||
this.observerServiceObserver_.unregister();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -216,6 +216,7 @@ G_Base64.prototype.stringifyArray = function(array) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
/**
|
/**
|
||||||
* Lame unittesting function
|
* Lame unittesting function
|
||||||
*/
|
*/
|
||||||
|
@ -291,3 +292,4 @@ function TEST_G_Base64() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -172,6 +172,7 @@ G_CryptoHasher.prototype.toHex_ = function(str) {
|
||||||
return hexrep.join('');
|
return hexrep.join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
/**
|
/**
|
||||||
* Lame unittest function
|
* Lame unittest function
|
||||||
*/
|
*/
|
||||||
|
@ -201,3 +202,4 @@ function TEST_G_CryptoHasher() {
|
||||||
G_Debug(z, "PASSED");
|
G_Debug(z, "PASSED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -282,7 +282,7 @@ G_FileWriter.prototype.close = function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
function TEST_G_File() {
|
function TEST_G_File() {
|
||||||
if (G_GDEBUG) {
|
if (G_GDEBUG) {
|
||||||
var z = "gfile UNITTEST";
|
var z = "gfile UNITTEST";
|
||||||
|
@ -310,3 +310,4 @@ function TEST_G_File() {
|
||||||
G_Debug(z, "PASS");
|
G_Debug(z, "PASS");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -177,6 +177,7 @@ G_ObjectSafeMap.prototype.size = function() {
|
||||||
return this.keys_.length;
|
return this.keys_.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
// Cheesey, yes, but it's what we've got
|
// Cheesey, yes, but it's what we've got
|
||||||
function TEST_G_ObjectSafeMap() {
|
function TEST_G_ObjectSafeMap() {
|
||||||
if (G_GDEBUG) {
|
if (G_GDEBUG) {
|
||||||
|
@ -227,3 +228,4 @@ function TEST_G_ObjectSafeMap() {
|
||||||
G_Debug(z, "PASSED");
|
G_Debug(z, "PASSED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -120,6 +120,7 @@ function G_ObserverServiceObserver(topic, observeFunction, opt_onlyOnce) {
|
||||||
*/
|
*/
|
||||||
G_ObserverServiceObserver.prototype.unregister = function() {
|
G_ObserverServiceObserver.prototype.unregister = function() {
|
||||||
this.observerService_.removeObserver(this.observer_, this.topic_);
|
this.observerService_.removeObserver(this.observer_, this.topic_);
|
||||||
|
this.observerService_ = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,7 +132,7 @@ G_ObserverServiceObserver.prototype.observe_ = function(subject, topic, data) {
|
||||||
this.unregister();
|
this.unregister();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
function TEST_G_Observer() {
|
function TEST_G_Observer() {
|
||||||
if (G_GDEBUG) {
|
if (G_GDEBUG) {
|
||||||
|
|
||||||
|
@ -172,3 +173,4 @@ function TEST_G_Observer() {
|
||||||
G_Debug(z, "PASSED");
|
G_Debug(z, "PASSED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -81,19 +81,9 @@
|
||||||
function G_Preferences(opt_startPoint, opt_getDefaultBranch) {
|
function G_Preferences(opt_startPoint, opt_getDefaultBranch) {
|
||||||
this.debugZone = "prefs";
|
this.debugZone = "prefs";
|
||||||
this.observers_ = {};
|
this.observers_ = {};
|
||||||
|
this.getDefaultBranch_ = !!opt_getDefaultBranch;
|
||||||
|
|
||||||
var startPoint = opt_startPoint || null;
|
this.startPoint_ = opt_startPoint || null;
|
||||||
var prefSvc = Cc["@mozilla.org/preferences-service;1"]
|
|
||||||
.getService(Ci.nsIPrefService);
|
|
||||||
|
|
||||||
if (opt_getDefaultBranch) {
|
|
||||||
this.prefs_ = prefSvc.getDefaultBranch(startPoint);
|
|
||||||
} else {
|
|
||||||
this.prefs_ = prefSvc.getBranch(startPoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
// QI to prefinternal in case we want to add observers
|
|
||||||
this.prefs_.QueryInterface(Ci.nsIPrefBranchInternal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
G_Preferences.setterMap_ = { "string": "setCharPref",
|
G_Preferences.setterMap_ = { "string": "setCharPref",
|
||||||
|
@ -105,6 +95,21 @@ G_Preferences.getterMap_[Ci.nsIPrefBranch.PREF_STRING] = "getCharPref";
|
||||||
G_Preferences.getterMap_[Ci.nsIPrefBranch.PREF_BOOL] = "getBoolPref";
|
G_Preferences.getterMap_[Ci.nsIPrefBranch.PREF_BOOL] = "getBoolPref";
|
||||||
G_Preferences.getterMap_[Ci.nsIPrefBranch.PREF_INT] = "getIntPref";
|
G_Preferences.getterMap_[Ci.nsIPrefBranch.PREF_INT] = "getIntPref";
|
||||||
|
|
||||||
|
G_Preferences.prototype.__defineGetter__('prefs_', function() {
|
||||||
|
var prefs;
|
||||||
|
var prefSvc = Cc["@mozilla.org/preferences-service;1"]
|
||||||
|
.getService(Ci.nsIPrefService);
|
||||||
|
|
||||||
|
if (this.getDefaultBranch_) {
|
||||||
|
prefs = prefSvc.getDefaultBranch(this.startPoint_);
|
||||||
|
} else {
|
||||||
|
prefs = prefSvc.getBranch(this.startPoint_);
|
||||||
|
}
|
||||||
|
|
||||||
|
// QI to prefs in case we want to add observers
|
||||||
|
prefs.QueryInterface(Ci.nsIPrefBranchInternal);
|
||||||
|
return prefs;
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores a key/value in a user preference. Valid types for val are string,
|
* Stores a key/value in a user preference. Valid types for val are string,
|
||||||
|
@ -300,9 +305,8 @@ G_PreferenceObserver.prototype.QueryInterface = function(iid) {
|
||||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
// UNITTESTS
|
// UNITTESTS
|
||||||
|
|
||||||
function TEST_G_Preferences() {
|
function TEST_G_Preferences() {
|
||||||
if (G_GDEBUG) {
|
if (G_GDEBUG) {
|
||||||
var z = "preferences UNITTEST";
|
var z = "preferences UNITTEST";
|
||||||
|
@ -359,3 +363,4 @@ function TEST_G_Preferences() {
|
||||||
G_Debug(z, "PASSED");
|
G_Debug(z, "PASSED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -108,7 +108,7 @@ G_Protocol4Parser.prototype.serialize = function(map) {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
/**
|
/**
|
||||||
* Cheesey unittests
|
* Cheesey unittests
|
||||||
*/
|
*/
|
||||||
|
@ -162,3 +162,4 @@ function TEST_G_Protocol4Parser() {
|
||||||
G_Debug(z, "PASSED");
|
G_Debug(z, "PASSED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -63,6 +63,8 @@ function MultiQuerier(tokens, tableName, callback) {
|
||||||
MultiQuerier.prototype.run = function() {
|
MultiQuerier.prototype.run = function() {
|
||||||
if (this.tokens_.length == 0) {
|
if (this.tokens_.length == 0) {
|
||||||
this.callback_.handleEvent(false);
|
this.callback_.handleEvent(false);
|
||||||
|
this.dbservice_ = null;
|
||||||
|
this.callback_ = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,10 +79,13 @@ MultiQuerier.prototype.run = function() {
|
||||||
* test, go ahead and call the main callback.
|
* test, go ahead and call the main callback.
|
||||||
*/
|
*/
|
||||||
MultiQuerier.prototype.result_ = function(value) {
|
MultiQuerier.prototype.result_ = function(value) {
|
||||||
if (this.condition_(value))
|
if (this.condition_(value)) {
|
||||||
this.callback_.handleEvent(true)
|
this.callback_.handleEvent(true)
|
||||||
else
|
this.dbservice_ = null;
|
||||||
|
this.callback_ = null;
|
||||||
|
} else {
|
||||||
this.run();
|
this.run();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subclasses must override this.
|
// Subclasses must override this.
|
||||||
|
@ -119,6 +124,8 @@ EnchashMultiQuerier.inherits(MultiQuerier);
|
||||||
EnchashMultiQuerier.prototype.run = function() {
|
EnchashMultiQuerier.prototype.run = function() {
|
||||||
if (this.tokens_.length == 0) {
|
if (this.tokens_.length == 0) {
|
||||||
this.callback_.handleEvent(false);
|
this.callback_.handleEvent(false);
|
||||||
|
this.dbservice_ = null;
|
||||||
|
this.callback_ = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var host = this.tokens_.pop();
|
var host = this.tokens_.pop();
|
||||||
|
|
|
@ -67,8 +67,6 @@ UrlClassifierTable.prototype.exists = function(url, callback) {
|
||||||
// Url table implementation
|
// Url table implementation
|
||||||
function UrlClassifierTableUrl() {
|
function UrlClassifierTableUrl() {
|
||||||
UrlClassifierTable.call(this);
|
UrlClassifierTable.call(this);
|
||||||
this.dbservice_ = Cc["@mozilla.org/url-classifier/dbservice;1"]
|
|
||||||
.getService(Ci.nsIUrlClassifierDBService);
|
|
||||||
}
|
}
|
||||||
UrlClassifierTableUrl.inherits(UrlClassifierTable);
|
UrlClassifierTableUrl.inherits(UrlClassifierTable);
|
||||||
|
|
||||||
|
@ -79,11 +77,13 @@ UrlClassifierTableUrl.prototype.exists = function(url, callback) {
|
||||||
var canonicalized = PROT_URLCanonicalizer.canonicalizeURL_(url);
|
var canonicalized = PROT_URLCanonicalizer.canonicalizeURL_(url);
|
||||||
G_Debug(this, "Looking up: " + url + " (" + canonicalized + ")");
|
G_Debug(this, "Looking up: " + url + " (" + canonicalized + ")");
|
||||||
|
|
||||||
this.dbservice_.exists(this.name,
|
var dbservice_ = Cc["@mozilla.org/url-classifier/dbservice;1"]
|
||||||
canonicalized,
|
.getService(Ci.nsIUrlClassifierDBService);
|
||||||
BindToObject(this.dbCallback_,
|
dbservice_.exists(this.name,
|
||||||
this,
|
canonicalized,
|
||||||
callback));
|
BindToObject(this.dbCallback_,
|
||||||
|
this,
|
||||||
|
callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,7 +112,10 @@ UrlClassifierTableDomain.inherits(UrlClassifierTable);
|
||||||
*/
|
*/
|
||||||
UrlClassifierTableDomain.prototype.exists = function(url, callback) {
|
UrlClassifierTableDomain.prototype.exists = function(url, callback) {
|
||||||
var urlObj = this.ioService_.newURI(url, null, null);
|
var urlObj = this.ioService_.newURI(url, null, null);
|
||||||
var host = urlObj.host;
|
var host = '';
|
||||||
|
try {
|
||||||
|
host = urlObj.host;
|
||||||
|
} catch (e) { }
|
||||||
var components = host.split(".");
|
var components = host.split(".");
|
||||||
|
|
||||||
// We don't have a good way map from hosts to domains, so we instead try
|
// We don't have a good way map from hosts to domains, so we instead try
|
||||||
|
|
|
@ -225,6 +225,7 @@ PROT_URLCanonicalizer.specialEncodeURL_ = function(arrayOfASCIIValues) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
/**
|
/**
|
||||||
* Lame unittesting function
|
* Lame unittesting function
|
||||||
*/
|
*/
|
||||||
|
@ -348,4 +349,4 @@ function TEST_PROT_URLCanonicalizer() {
|
||||||
G_Debug(z, "PASSED");
|
G_Debug(z, "PASSED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -303,7 +303,7 @@ PROT_UrlCryptoKeyManager.prototype.maybeLoadOldKey = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
/**
|
/**
|
||||||
* Cheesey tests
|
* Cheesey tests
|
||||||
*/
|
*/
|
||||||
|
@ -396,4 +396,4 @@ function TEST_PROT_UrlCryptoKeyManager() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -383,6 +383,7 @@ PROT_UrlCrypto.prototype.computeMac = function(data,
|
||||||
return this.macer_.digestBase64();
|
return this.macer_.digestBase64();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
/**
|
/**
|
||||||
* Cheeseball unittest
|
* Cheeseball unittest
|
||||||
*/
|
*/
|
||||||
|
@ -687,3 +688,4 @@ function TEST_PROT_UrlCrypto() {
|
||||||
G_Debug(z, "PASS");
|
G_Debug(z, "PASS");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -234,6 +234,7 @@ PROT_VersionParser.prototype.processOptTokens_ = function(line) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
function TEST_PROT_WireFormat() {
|
function TEST_PROT_WireFormat() {
|
||||||
if (G_GDEBUG) {
|
if (G_GDEBUG) {
|
||||||
var z = "versionparser UNITTEST";
|
var z = "versionparser UNITTEST";
|
||||||
|
@ -258,3 +259,4 @@ function TEST_PROT_WireFormat() {
|
||||||
G_Debug(z, "PASSED");
|
G_Debug(z, "PASSED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
toolkit.jar:
|
toolkit.jar:
|
||||||
|
# XXX: delete this file after browser/components/safebrowsing uses pre-processor
|
||||||
+ content/global/url-classifier/application.js (content/application.js)
|
+ content/global/url-classifier/application.js (content/application.js)
|
||||||
+ content/global/url-classifier/enchash-decrypter.js (content/enchash-decrypter.js)
|
+ content/global/url-classifier/enchash-decrypter.js (content/enchash-decrypter.js)
|
||||||
+ content/global/url-classifier/listmanager.js (content/listmanager.js)
|
+ content/global/url-classifier/listmanager.js (content/listmanager.js)
|
||||||
|
|
|
@ -26,9 +26,10 @@ LOCAL_INCLUDES = \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
|
||||||
# EXTRA_COMPONENTS installs components written in JS to dist/bin/components
|
# Same as JS components that are run through the pre-processor.
|
||||||
EXTRA_COMPONENTS = nsUrlClassifierTable.js \
|
EXTRA_PP_COMPONENTS = nsUrlClassifierTable.js \
|
||||||
urlListManager.js \
|
nsUrlClassifierLib.js \
|
||||||
$(NULL)
|
nsUrlClassifierListManager.js \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
include $(topsrcdir)/config/rules.mk
|
include $(topsrcdir)/config/rules.mk
|
||||||
|
|
|
@ -0,0 +1,119 @@
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is Url Classifier code
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Google Inc.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Tony Chang <tony@ponderer.org>
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
// We wastefully reload the same JS files across components. This puts all
|
||||||
|
// the common JS files used by safebrowsing and url-classifier into a
|
||||||
|
// single component.
|
||||||
|
|
||||||
|
const Cc = Components.classes;
|
||||||
|
const Ci = Components.interfaces;
|
||||||
|
const G_GDEBUG = false;
|
||||||
|
|
||||||
|
// TODO: get rid of application.js and filesystem.js (not used much)
|
||||||
|
#include ../content/js/arc4.js
|
||||||
|
#include ../content/js/lang.js
|
||||||
|
|
||||||
|
#include ../content/moz/preferences.js
|
||||||
|
#include ../content/moz/filesystem.js
|
||||||
|
#include ../content/moz/debug.js
|
||||||
|
#include ../content/moz/alarm.js
|
||||||
|
#include ../content/moz/base64.js
|
||||||
|
#include ../content/moz/cryptohasher.js
|
||||||
|
#include ../content/moz/lang.js
|
||||||
|
#include ../content/moz/objectsafemap.js
|
||||||
|
#include ../content/moz/observer.js
|
||||||
|
#include ../content/moz/protocol4.js
|
||||||
|
|
||||||
|
#include ../content/application.js
|
||||||
|
#include ../content/url-crypto.js
|
||||||
|
#include ../content/url-crypto-key-manager.js
|
||||||
|
#include ../content/xml-fetcher.js
|
||||||
|
|
||||||
|
// Expose this whole component.
|
||||||
|
var lib = this;
|
||||||
|
|
||||||
|
function UrlClassifierLib() {
|
||||||
|
this.wrappedJSObject = lib;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Module object
|
||||||
|
function UrlClassifierLibMod() {
|
||||||
|
this.firstTime = true;
|
||||||
|
this.cid = Components.ID("{26a4a019-2827-4a89-a85c-5931a678823a}");
|
||||||
|
this.progid = "@mozilla.org/url-classifier/jslib;1";
|
||||||
|
}
|
||||||
|
|
||||||
|
UrlClassifierLibMod.prototype.registerSelf = function(compMgr, fileSpec, loc, type) {
|
||||||
|
if (this.firstTime) {
|
||||||
|
this.firstTime = false;
|
||||||
|
throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
|
||||||
|
}
|
||||||
|
compMgr = compMgr.QueryInterface(Ci.nsIComponentRegistrar);
|
||||||
|
compMgr.registerFactoryLocation(this.cid,
|
||||||
|
"UrlClassifier JS Lib",
|
||||||
|
this.progid,
|
||||||
|
fileSpec,
|
||||||
|
loc,
|
||||||
|
type);
|
||||||
|
};
|
||||||
|
|
||||||
|
UrlClassifierLibMod.prototype.getClassObject = function(compMgr, cid, iid) {
|
||||||
|
if (!cid.equals(this.cid))
|
||||||
|
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||||
|
if (!iid.equals(Ci.nsIFactory))
|
||||||
|
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
return this.factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
UrlClassifierLibMod.prototype.canUnload = function(compMgr) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
UrlClassifierLibMod.prototype.factory = {
|
||||||
|
createInstance: function(outer, iid) {
|
||||||
|
if (outer != null)
|
||||||
|
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||||
|
return new UrlClassifierLib();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var LibModInst = new UrlClassifierLibMod();
|
||||||
|
|
||||||
|
function NSGetModule(compMgr, fileSpec) {
|
||||||
|
return LibModInst;
|
||||||
|
}
|
|
@ -35,42 +35,30 @@
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
// TODO: Rename this file to nsUrlClassifierListManager.js
|
|
||||||
|
|
||||||
const Cc = Components.classes;
|
const Cc = Components.classes;
|
||||||
const Ci = Components.interfaces;
|
const Ci = Components.interfaces;
|
||||||
const G_GDEBUG = false;
|
|
||||||
|
|
||||||
// Use subscript loader to load files. The files in ../content get mapped
|
#include ../content/listmanager.js
|
||||||
// to chrome://global/content/url-classifier/. Order matters if one file depends
|
#include ../content/wireformat.js
|
||||||
// on another file during initialization.
|
|
||||||
const LIB_FILES = [
|
|
||||||
"chrome://global/content/url-classifier/js/arc4.js",
|
|
||||||
"chrome://global/content/url-classifier/js/lang.js",
|
|
||||||
|
|
||||||
"chrome://global/content/url-classifier/moz/preferences.js",
|
var modScope = this;
|
||||||
"chrome://global/content/url-classifier/moz/filesystem.js",
|
function Init() {
|
||||||
"chrome://global/content/url-classifier/moz/debug.js", // dep js/lang.js moz/prefs.js moz/filesystem.js
|
// Pull the library in.
|
||||||
"chrome://global/content/url-classifier/moz/alarm.js",
|
var jslib = Cc["@mozilla.org/url-classifier/jslib;1"]
|
||||||
"chrome://global/content/url-classifier/moz/base64.js",
|
.getService().wrappedJSObject;
|
||||||
"chrome://global/content/url-classifier/moz/cryptohasher.js",
|
Function.prototype.inherits = jslib.Function.prototype.inherits;
|
||||||
"chrome://global/content/url-classifier/moz/lang.js",
|
modScope.G_Preferences = jslib.G_Preferences;
|
||||||
"chrome://global/content/url-classifier/moz/observer.js",
|
modScope.G_PreferenceObserver = jslib.G_PreferenceObserver;
|
||||||
"chrome://global/content/url-classifier/moz/protocol4.js",
|
modScope.G_ObserverServiceObserver = jslib.G_ObserverServiceObserver;
|
||||||
|
modScope.G_Debug = jslib.G_Debug;
|
||||||
|
modScope.G_Assert = jslib.G_Assert;
|
||||||
|
modScope.G_debugService = jslib.G_debugService;
|
||||||
|
modScope.G_Alarm = jslib.G_Alarm;
|
||||||
|
modScope.BindToObject = jslib.BindToObject;
|
||||||
|
modScope.PROT_XMLFetcher = jslib.PROT_XMLFetcher;
|
||||||
|
|
||||||
"chrome://global/content/url-classifier/application.js",
|
// We only need to call Init once.
|
||||||
"chrome://global/content/url-classifier/listmanager.js",
|
modScope.Init = function() {};
|
||||||
"chrome://global/content/url-classifier/url-crypto.js",
|
|
||||||
"chrome://global/content/url-classifier/url-crypto-key-manager.js", // dep url-crypto.js
|
|
||||||
"chrome://global/content/url-classifier/wireformat.js",
|
|
||||||
"chrome://global/content/url-classifier/xml-fetcher.js",
|
|
||||||
];
|
|
||||||
|
|
||||||
for (var i = 0, libFile; libFile = LIB_FILES[i]; ++i) {
|
|
||||||
//dump('*** loading subscript ' + libFile + '\n');
|
|
||||||
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
||||||
.getService(Ci.mozIJSSubScriptLoader)
|
|
||||||
.loadSubScript(libFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Module object
|
// Module object
|
||||||
|
@ -111,6 +99,7 @@ UrlClassifierListManagerMod.prototype.factory = {
|
||||||
createInstance: function(outer, iid) {
|
createInstance: function(outer, iid) {
|
||||||
if (outer != null)
|
if (outer != null)
|
||||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||||
|
Init();
|
||||||
return (new PROT_ListManager()).QueryInterface(iid);
|
return (new PROT_ListManager()).QueryInterface(iid);
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -37,35 +37,32 @@
|
||||||
|
|
||||||
const Cc = Components.classes;
|
const Cc = Components.classes;
|
||||||
const Ci = Components.interfaces;
|
const Ci = Components.interfaces;
|
||||||
const G_GDEBUG = false;
|
|
||||||
|
|
||||||
// Use subscript loader to load files. The files in ../content get mapped
|
// js/lang.js is needed for Function.prototype.inherts
|
||||||
// to chrome://global/content/url-classifier/. Order matters if one file depends
|
#include ../content/js/lang.js
|
||||||
// on another file during initialization.
|
#include ../content/enchash-decrypter.js
|
||||||
const LIB_FILES = [
|
#include ../content/multi-querier.js
|
||||||
"chrome://global/content/url-classifier/js/arc4.js",
|
#include ../content/url-canonicalizer.js
|
||||||
"chrome://global/content/url-classifier/js/lang.js",
|
#include ../content/trtable.js
|
||||||
|
|
||||||
"chrome://global/content/url-classifier/moz/preferences.js",
|
var modScope = this;
|
||||||
"chrome://global/content/url-classifier/moz/filesystem.js",
|
function Init() {
|
||||||
"chrome://global/content/url-classifier/moz/debug.js", // req js/lang.js moz/prefs.js moz/filesystem.js
|
// Pull the library in.
|
||||||
"chrome://global/content/url-classifier/moz/lang.js",
|
var jslib = Cc["@mozilla.org/url-classifier/jslib;1"]
|
||||||
|
.getService().wrappedJSObject;
|
||||||
|
modScope.G_Preferences = jslib.G_Preferences;
|
||||||
|
modScope.G_PreferenceObserver = jslib.G_PreferenceObserver;
|
||||||
|
modScope.G_Debug = jslib.G_Debug;
|
||||||
|
modScope.G_CryptoHasher = jslib.G_CryptoHasher;
|
||||||
|
modScope.G_Base64 = jslib.G_Base64;
|
||||||
|
modScope.ARC4 = jslib.ARC4;
|
||||||
|
modScope.BindToObject = jslib.BindToObject;
|
||||||
|
|
||||||
"chrome://global/content/url-classifier/moz/base64.js",
|
// We only need to call Init once.
|
||||||
"chrome://global/content/url-classifier/moz/cryptohasher.js",
|
modScope.Init = function() {};
|
||||||
"chrome://global/content/url-classifier/enchash-decrypter.js",
|
|
||||||
"chrome://global/content/url-classifier/multi-querier.js",
|
|
||||||
"chrome://global/content/url-classifier/url-canonicalizer.js",
|
|
||||||
"chrome://global/content/url-classifier/trtable.js"
|
|
||||||
];
|
|
||||||
|
|
||||||
for (var i = 0, libFile; libFile = LIB_FILES[i]; ++i) {
|
|
||||||
//dump('*** loading subscript ' + libFile + '\n');
|
|
||||||
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
||||||
.getService(Ci.mozIJSSubScriptLoader)
|
|
||||||
.loadSubScript(libFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function UrlClassifierTableMod() {
|
function UrlClassifierTableMod() {
|
||||||
this.components = {};
|
this.components = {};
|
||||||
this.addComponent({
|
this.addComponent({
|
||||||
|
@ -132,6 +129,7 @@ function UrlClassifierTableFactory(ctor) {
|
||||||
UrlClassifierTableFactory.prototype.createInstance = function(outer, iid) {
|
UrlClassifierTableFactory.prototype.createInstance = function(outer, iid) {
|
||||||
if (outer != null)
|
if (outer != null)
|
||||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||||
|
Init();
|
||||||
return (new this.ctor()).QueryInterface(iid);
|
return (new this.ctor()).QueryInterface(iid);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче