From 206b2a4b9e833b35faaadcd82bbfd04f81f61dbb Mon Sep 17 00:00:00 2001 From: "jwalden%mit.edu" Date: Wed, 16 Aug 2006 07:23:53 +0000 Subject: [PATCH] Bug 346942 - Finalize anti-phishing UI, part 2. This gets rid of the stupid dialog we had before. Parts of patch courtesy of Tony Chang, rest was me, r=mconnor git-svn-id: svn://10.0.0.236/trunk@207566 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/browser/app/profile/firefox.js | 3 + mozilla/browser/components/preferences/jar.mn | 3 + .../components/preferences/phishEULA.js | 157 ++++++++++++++++++ .../components/preferences/phishEULA.xhtml | 16 ++ .../components/preferences/phishEULA.xul | 76 +++++++++ .../components/preferences/security.js | 110 ++++++++---- .../components/preferences/security.xul | 6 +- .../chrome/browser/preferences/phishEULA.dtd | 14 ++ .../preferences/preferences.properties | 14 +- .../chrome/browser/safebrowsing/eula.dtd | 17 ++ mozilla/browser/locales/jar.mn | 6 +- 11 files changed, 375 insertions(+), 47 deletions(-) create mode 100644 mozilla/browser/components/preferences/phishEULA.js create mode 100644 mozilla/browser/components/preferences/phishEULA.xhtml create mode 100644 mozilla/browser/components/preferences/phishEULA.xul create mode 100644 mozilla/browser/locales/en-US/chrome/browser/preferences/phishEULA.dtd create mode 100644 mozilla/browser/locales/en-US/chrome/browser/safebrowsing/eula.dtd diff --git a/mozilla/browser/app/profile/firefox.js b/mozilla/browser/app/profile/firefox.js index d1597c621e2..45db4310b8c 100644 --- a/mozilla/browser/app/profile/firefox.js +++ b/mozilla/browser/app/profile/firefox.js @@ -509,6 +509,9 @@ pref("browser.safebrowsing.provider.0.lookupURL", "http://sb.google.com/safebrow pref("browser.safebrowsing.provider.0.keyURL", "https://www.google.com/safebrowsing/getkey?"); pref("browser.safebrowsing.provider.0.reportURL", "http://sb.google.com/safebrowsing/report?"); +// privacy policy -- must be chrome URL +pref("browser.safebrowsing.provider.0.privacy.url", "chrome://browser/content/preferences/phishEULA.xhtml"); + // HTML report pages pref("browser.safebrowsing.provider.0.reportGenericURL", "http://www.mozilla.org/projects/bonecho/anti-phishing/report_general/?hl={moz:locale}"); pref("browser.safebrowsing.provider.0.reportErrorURL", "http://www.mozilla.org/projects/bonecho/anti-phishing/report_error/?hl={moz:locale}"); diff --git a/mozilla/browser/components/preferences/jar.mn b/mozilla/browser/components/preferences/jar.mn index e7a9c4909f8..35e133f1e70 100644 --- a/mozilla/browser/components/preferences/jar.mn +++ b/mozilla/browser/components/preferences/jar.mn @@ -25,6 +25,9 @@ browser.jar: * content/browser/preferences/permissions.xul * content/browser/preferences/permissions.js * content/browser/preferences/permissionsutils.js +* content/browser/preferences/phishEULA.xul +* content/browser/preferences/phishEULA.js +* content/browser/preferences/phishEULA.xhtml * content/browser/preferences/preferences.xul * content/browser/preferences/privacy.xul * content/browser/preferences/privacy.js diff --git a/mozilla/browser/components/preferences/phishEULA.js b/mozilla/browser/components/preferences/phishEULA.js new file mode 100644 index 00000000000..bd85e201b5e --- /dev/null +++ b/mozilla/browser/components/preferences/phishEULA.js @@ -0,0 +1,157 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** 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 Firefox Anti-Phishing Support. + * + * The Initial Developer of the Original Code is + * Mozilla Corporation. + * Portions created by the Initial Developer are Copyright (C) 2006 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Jeff Walden (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 ***** */ + +/** + * gPhishDialog controls the user interface for displaying the privacy policy of + * an anti-phishing provider. + * + * The caller (gSecurityPane._userAgreedToPhishingEULA in main.js) invokes this + * dialog with a single argument - a reference to an object with .providerNum + * and .userAgreed properties. This code displays the dialog for the provider + * as dictated by .providerNum and loads the policy. When that load finishes, + * the OK button is enabled and the user can either accept or decline the + * agreement (a choice which is communicated by setting .userAgreed to true if + * the user did indeed agree). + */ +var gPhishDialog = { + /** + * The nsIWebProgress object associated with the privacy policy frame. + */ + _webProgress: null, + + /** + * Initializes UI and starts the privacy policy loading. + */ + init: function () + { + const Cc = Components.classes, Ci = Components.interfaces; + + var providerNum = window.arguments[0].providerNum; + + var phishBefore = document.getElementById("phishBefore"); + var phishAfter = document.getElementById("phishAfter"); + + var prefb = Cc["@mozilla.org/preferences-service;1"]. + getService(Ci.nsIPrefService). + getBranch("browser.safebrowsing.provider."); + + // init before-frame and after-frame strings + // note that description only wraps when the string is the element's + // *content* and *not* when it's the value attribute + var providerName = prefb.getCharPref(providerNum + ".name"); + var strings = document.getElementById("bundle_phish"); + phishBefore.textContent = strings.getFormattedString("phishBefore", [providerName]); + phishAfter.textContent = strings.getFormattedString("phishAfter", [providerName]); + + // guaranteed to be present, because only providers with privacy policies + // are displayed in the prefwindow + var privacyURL = prefb.getComplexValue(providerNum + ".privacy.url", Ci.nsISupportsString).data; + + // add progress listener to enable OK when page loads + var frame = document.getElementById("phishPolicyFrame"); + var webProgress = frame.docShell + .QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIWebProgress); + webProgress.addProgressListener(this._progressListener, + Ci.nsIWebProgress.NOTIFY_STATE_WINDOW); + + this._webProgress = webProgress; // for easy use later + + // start loading the privacyURL + const loadFlags = Ci.nsIWebNavigation.LOAD_FLAGS_NONE; + frame.webNavigation.loadURI(privacyURL, loadFlags, null, null, null); + }, + + /** + * The nsIWebProgressListener used to watch the status of the load of the + * privacy policy; enables the OK button when the load completes. + */ + _progressListener: + { + onStateChange: function (aWebProgress, aRequest, aStateFlags, aStatus) + { + // enable the OK button when the request completes + const Ci = Components.interfaces, Cr = Components.results; + if ((aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) && + (aStateFlags & Ci.nsIWebProgressListener.STATE_IS_WINDOW)) { + // XXX check for load failure here! + document.documentElement.getButton("accept").disabled = false; + } + }, + + onProgressChange: function(aWebProgress, aRequest, aCurSelfProgress, + aMaxSelfProgress, aCurTotalProgress, + aMaxTotalProgress) + { + }, + + onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage) + { + }, + + QueryInterface : function(aIID) + { + const Ci = Components.interfaces; + if (aIID.equals(Ci.nsIWebProgressListener) || + aIID.equals(Ci.nsISupportsWeakReference) || + aIID.equals(Ci.nsISupports)) + return this; + throw Components.results.NS_NOINTERFACE; + } + }, + + /** + * Signals that the user accepted the privacy policy by setting the window + * arguments appropriately. Note that this does *not* change preferences; + * the opener of this dialog handles that. + */ + accept: function () + { + window.arguments[0].userAgreed = true; + }, + + /** + * Clean up any XPCOM-JS cycles we may have created. + */ + uninit: function () + { + // overly aggressive, but better safe than sorry + this._webProgress.removeProgressListener(this._progressListener); + this._progressListener = this._webProgress = null; + } +}; diff --git a/mozilla/browser/components/preferences/phishEULA.xhtml b/mozilla/browser/components/preferences/phishEULA.xhtml new file mode 100644 index 00000000000..08b342c41e4 --- /dev/null +++ b/mozilla/browser/components/preferences/phishEULA.xhtml @@ -0,0 +1,16 @@ + + + + %htmlDTD; + + %phisheulaDTD; +]> + + + &phish.eulatext; + diff --git a/mozilla/browser/components/preferences/phishEULA.xul b/mozilla/browser/components/preferences/phishEULA.xul new file mode 100644 index 00000000000..9cad7e96e14 --- /dev/null +++ b/mozilla/browser/components/preferences/phishEULA.xul @@ -0,0 +1,76 @@ + + +# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# ***** 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 the Firefox Preferences System. +# +# The Initial Developer of the Original Code is +# Mozilla Corporation. +# Portions created by the Initial Developer are Copyright (C) 2006 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Jeff Walden (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 ***** + + + + + + + + +