From f618ec6e1a82f0ba3d2e5433592451f6215f4607 Mon Sep 17 00:00:00 2001 From: "benjamin%smedbergs.us" Date: Wed, 26 Jul 2006 18:09:33 +0000 Subject: [PATCH] Bug 335605 - Hook up "download dictionaries" context menu, r=brettw --- browser/app/profile/firefox.js | 3 +++ browser/base/content/browser.js | 30 ++++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index 7ca92ef95db..84403fc5253 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -76,6 +76,9 @@ pref("extensions.blocklist.interval", 86400); pref("extensions.blocklist.url", "https://addons.mozilla.org/blocklist/1/%APP_ID%/%APP_VERSION%/"); pref("extensions.blocklist.detailsURL", "http://www.mozilla.com/blocklist/"); +// Dictionary download preference +pref("browser.dictionaries.download.url", "https://addons.mozilla.org/%LOCALE%/firefox/%VERSION%/dictionaries/"); + // App-specific update preferences // Whether or not app updates are enabled diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index a62abf6bc29..bbf2e78c848 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -5255,12 +5255,30 @@ nsContextMenu.prototype = { addDictionaries : function() { - var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] - .getService(Components.interfaces.nsIPromptService); - // FIXME bug 335605: hook this up so that it takes you to the download - // web page - var rv = ps.alert(window, "Add Dictionaries", - "This command hasn't been hooked up yet. Instead, go to Thunderbird's download page:\n\nhttp://www.mozilla.org/products/thunderbird/dictionaries.html\n\nThese plugins will work in Firefox as well."); + var uri = gPrefService.getCharPref("browser.dictionaries.download.url"); + + var locale = "-"; + try { + locale = gPrefService.getComplexValue("intl.accept_languages", + Components.interfaces.nsIPrefLocalizedString).data; + } + catch (e) { } + + var version = "-"; + try { + version = Components.classes["@mozilla.org/xre/app-info;1"] + .getService(Components.interfaces.nsIXULAppInfo) + .version; + } + catch (e) { } + + uri = uri.replace(/%LOCALE%/, escape(locale)); + uri = uri.replace(/%VERSION%/, version); + + var newWindowPref = gPrefService.getIntPref("browser.link.open_newwindow"); + var where = newWindowPref == 3 ? "tab" : "window"; + + openUILinkIn(uri, where); } }