From bd48c1dd29411ac5ecc2c35b1456b88c5624f87c Mon Sep 17 00:00:00 2001 From: "jwalden%mit.edu" Date: Fri, 18 Aug 2006 17:46:16 +0000 Subject: [PATCH] Bug 348820 - Fix followups from bug 346942. r=mconnor --- .../components/preferences/fallbackEULA.xhtml | 16 +++ browser/components/preferences/jar.mn | 1 + browser/components/preferences/phishEULA.js | 116 +++++++++++------- browser/components/preferences/phishEULA.xul | 10 +- .../browser/preferences/fallbackEULA.dtd | 1 + .../chrome/browser/preferences/phishEULA.dtd | 9 +- .../preferences/preferences.properties | 10 +- browser/locales/jar.mn | 1 + 8 files changed, 108 insertions(+), 56 deletions(-) create mode 100644 browser/components/preferences/fallbackEULA.xhtml create mode 100644 browser/locales/en-US/chrome/browser/preferences/fallbackEULA.dtd diff --git a/browser/components/preferences/fallbackEULA.xhtml b/browser/components/preferences/fallbackEULA.xhtml new file mode 100644 index 000000000000..7ee443020ea7 --- /dev/null +++ b/browser/components/preferences/fallbackEULA.xhtml @@ -0,0 +1,16 @@ + + + + %htmlDTD; + + %phisheulaDTD; +]> + + + &fallback.text; + diff --git a/browser/components/preferences/jar.mn b/browser/components/preferences/jar.mn index 35e133f1e70d..ba515980ee8f 100644 --- a/browser/components/preferences/jar.mn +++ b/browser/components/preferences/jar.mn @@ -13,6 +13,7 @@ browser.jar: * content/browser/preferences/connection.js * content/browser/preferences/downloadactions.xul * content/browser/preferences/downloadactions.js +* content/browser/preferences/fallbackEULA.xhtml * content/browser/preferences/feeds.xul * content/browser/preferences/feeds.js * content/browser/preferences/fonts.xul diff --git a/browser/components/preferences/phishEULA.js b/browser/components/preferences/phishEULA.js index bd85e201b5e1..7b9b205f6cf7 100644 --- a/browser/components/preferences/phishEULA.js +++ b/browser/components/preferences/phishEULA.js @@ -1,40 +1,40 @@ -/* -*- 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 ***** */ +# -*- 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 @@ -64,7 +64,6 @@ var gPhishDialog = { 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). @@ -73,16 +72,15 @@ var gPhishDialog = { // 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 providerName = prefb.getComplexValue(providerNum + ".name", Ci.nsISupportsString).data var strings = document.getElementById("bundle_phish"); - phishBefore.textContent = strings.getFormattedString("phishBefore", [providerName]); - phishAfter.textContent = strings.getFormattedString("phishAfter", [providerName]); + phishBefore.textContent = strings.getFormattedString("phishBeforeText", [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 + // add progress listener to enable OK, radios when page loads var frame = document.getElementById("phishPolicyFrame"); var webProgress = frame.docShell .QueryInterface(Ci.nsIInterfaceRequestor) @@ -103,14 +101,35 @@ var gPhishDialog = { */ _progressListener: { + /** + * True if we tried loading the first URL and encountered a failure. + */ + _loadFailed: false, + 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; + // check for failure + if (aRequest.status & 0x80000000) { + if (!this._loadFailed) { + this._loadFailed = true; + + // fire off a load of the fallback policy + const loadFlags = Ci.nsIWebNavigation.LOAD_FLAGS_NONE; + const fallbackURL = "chrome://browser/content/preferences/fallbackEULA.xhtml"; + var frame = document.getElementById("phishPolicyFrame"); + frame.webNavigation.loadURI(fallbackURL, loadFlags, null, null, null); + + // disable radios + document.getElementById("acceptOrDecline").disabled = true; + } + else { + throw "Fallback policy failed to load -- what the hay!?!"; + } + } } }, @@ -153,5 +172,14 @@ var gPhishDialog = { // overly aggressive, but better safe than sorry this._webProgress.removeProgressListener(this._progressListener); this._progressListener = this._webProgress = null; + }, + + /** + * Called when the user changes the agree/disagree radio. + */ + onchangeRadio: function () + { + var radio = document.getElementById("acceptOrDecline"); + document.documentElement.getButton("accept").disabled = (radio.value == "false"); } }; diff --git a/browser/components/preferences/phishEULA.xul b/browser/components/preferences/phishEULA.xul index 9cad7e96e14b..9d3d766e5001 100644 --- a/browser/components/preferences/phishEULA.xul +++ b/browser/components/preferences/phishEULA.xul @@ -44,8 +44,8 @@ - + + + + diff --git a/browser/locales/en-US/chrome/browser/preferences/fallbackEULA.dtd b/browser/locales/en-US/chrome/browser/preferences/fallbackEULA.dtd new file mode 100644 index 000000000000..a7eab57c1387 --- /dev/null +++ b/browser/locales/en-US/chrome/browser/preferences/fallbackEULA.dtd @@ -0,0 +1 @@ +The privacy agreement failed to load.

"> diff --git a/browser/locales/en-US/chrome/browser/preferences/phishEULA.dtd b/browser/locales/en-US/chrome/browser/preferences/phishEULA.dtd index ddb40b6aeabf..69eaf7acd369 100644 --- a/browser/locales/en-US/chrome/browser/preferences/phishEULA.dtd +++ b/browser/locales/en-US/chrome/browser/preferences/phishEULA.dtd @@ -1,4 +1,4 @@ - + - - + + + + + diff --git a/browser/locales/en-US/chrome/browser/preferences/preferences.properties b/browser/locales/en-US/chrome/browser/preferences/preferences.properties index c6fe5c60295a..9887178c9028 100644 --- a/browser/locales/en-US/chrome/browser/preferences/preferences.properties +++ b/browser/locales/en-US/chrome/browser/preferences/preferences.properties @@ -16,12 +16,10 @@ addReader=Add New Reader... #### Security -# LOCALIZATION NOTE: phishBefore and phishAfter use %S to represent the name of -# the provider whose privacy policy must be accepted (for -# enabling check-every-page-as-I-load-it phishing -# protection). -phishBefore=Selecting this option will send the address of web pages you are viewing to %S. To continue, please review the following privacy agreement: -phishAfter=Do you want to accept this privacy agreement and ask %S about each site you visit? +# LOCALIZATION NOTE: phishBefore uses %S to represent the name of the provider +# whose privacy policy must be accepted (for enabling +# check-every-page-as-I-load-it phishing protection). +phishBeforeText=Selecting this option will send the address of web pages you are viewing to %S. To continue, please review and accept the following terms of service. setMasterPassword=Set Master Password... setMasterPassword_accesskey=M diff --git a/browser/locales/jar.mn b/browser/locales/jar.mn index 7c39dc062a75..3cdd0e768183 100644 --- a/browser/locales/jar.mn +++ b/browser/locales/jar.mn @@ -61,6 +61,7 @@ locale/browser/preferences/content.dtd (%chrome/browser/preferences/content.dtd) locale/browser/preferences/connection.dtd (%chrome/browser/preferences/connection.dtd) locale/browser/preferences/downloadactions.dtd (%chrome/browser/preferences/downloadactions.dtd) + locale/browser/preferences/fallbackEULA.dtd (%chrome/browser/preferences/fallbackEULA.dtd) locale/browser/preferences/feeds.dtd (%chrome/browser/preferences/feeds.dtd) locale/browser/preferences/fonts.dtd (%chrome/browser/preferences/fonts.dtd) locale/browser/preferences/main.dtd (%chrome/browser/preferences/main.dtd)