diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index 681d77625d3..7a16f4d7d2e 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -451,16 +451,16 @@ pref("browser.send_pings", true); #ifdef MOZ_FEEDS // XXXben This is just here for demo purposes until web registration works! // XXXben Needs Localization! -pref("browser.contentHandlers.types.title0", "Netvibes"); -pref("browser.contentHandlers.types.uri0", "http://www.netvibes.com/subscribe.php?url=%s"); -pref("browser.contentHandlers.types.type0", "application/vnd.mozilla.maybe.feed"); -pref("browser.contentHandlers.types.title1", "My Yahoo"); -pref("browser.contentHandlers.types.uri1", "http://add.my.yahoo.com/rss?url=%s"); -pref("browser.contentHandlers.types.type1", "application/vnd.mozilla.maybe.feed"); -pref("browser.contentHandlers.types.title2", "Bloglines"); -pref("browser.contentHandlers.types.uri2", "http://www.bloglines.com/login?r=/sub/%s"); -pref("browser.contentHandlers.types.type2", "application/vnd.mozilla.maybe.feed"); -pref("browser.contentHandlers.types.title3", "iGoogle/Google Reader"); -pref("browser.contentHandlers.types.uri3", "http://fusion.google.com/add?feedurl=%s"); -pref("browser.contentHandlers.types.type3", "application/vnd.mozilla.maybe.feed"); +pref("browser.contentHandlers.types.0.title", "Netvibes"); +pref("browser.contentHandlers.types.0.uri", "http://www.netvibes.com/subscribe.php?url=%s"); +pref("browser.contentHandlers.types.0.type", "application/vnd.mozilla.maybe.feed"); +pref("browser.contentHandlers.types.1.title", "My Yahoo"); +pref("browser.contentHandlers.types.1.uri", "http://add.my.yahoo.com/rss?url=%s"); +pref("browser.contentHandlers.types.1.type", "application/vnd.mozilla.maybe.feed"); +pref("browser.contentHandlers.types.2.title", "Bloglines"); +pref("browser.contentHandlers.types.2.uri", "http://www.bloglines.com/login?r=/sub/%s"); +pref("browser.contentHandlers.types.2.type", "application/vnd.mozilla.maybe.feed"); +pref("browser.contentHandlers.types.3.title", "iGoogle/Google Reader"); +pref("browser.contentHandlers.types.3.uri", "http://fusion.google.com/add?feedurl=%s"); +pref("browser.contentHandlers.types.3.type", "application/vnd.mozilla.maybe.feed"); #endif diff --git a/browser/components/feeds/src/WebContentConverter.js b/browser/components/feeds/src/WebContentConverter.js index d5eda9fae48..473b71e1bbd 100644 --- a/browser/components/feeds/src/WebContentConverter.js +++ b/browser/components/feeds/src/WebContentConverter.js @@ -346,12 +346,13 @@ var WebContentConverterRegistrar = { var ps = Cc["@mozilla.org/preferences-service;1"]. getService(Ci.nsIPrefService); - var typeBranch = - ps.getBranch(PREF_CONTENTHANDLERS_BRANCH); var i = 0; + var typeBranch = null; while (true) { + typeBranch = + ps.getBranch(PREF_CONTENTHANDLERS_BRANCH + i + "."); try { - typeBranch.getCharPref("type" + i); + typeBranch.getCharPref("type"); ++i; } catch (e) { @@ -359,11 +360,13 @@ var WebContentConverterRegistrar = { break; } } - typeBranch.setCharPref("type" + i, contentType); - typeBranch.setCharPref("uri" + i, uri); - typeBranch.setCharPref("title" + i, title); + if (typeBranch) { + typeBranch.setCharPref("type", contentType); + typeBranch.setCharPref("uri", uri); + typeBranch.setCharPref("title", title); - ps.savePrefFile(null); + ps.savePrefFile(null); + } }, /** @@ -448,14 +451,14 @@ var WebContentConverterRegistrar = { Cc["@mozilla.org/preferences-service;1"]. getService(Ci.nsIPrefService); try { - var handlerBranch = ps.getBranch(PREF_CONTENTHANDLERS_BRANCH); var i = 0; while (true) { + var handlerBranch = + ps.getBranch(PREF_CONTENTHANDLERS_BRANCH + (i++) + "."); try { - var type = handlerBranch.getCharPref("type" + i); - var uri = handlerBranch.getCharPref("uri" + i); - var title = handlerBranch.getCharPref("title" + i); - ++i; + var type = handlerBranch.getCharPref("type"); + var uri = handlerBranch.getCharPref("uri"); + var title = handlerBranch.getCharPref("title"); this._registerContentHandler(type, uri, title); } catch (e) { @@ -467,6 +470,8 @@ var WebContentConverterRegistrar = { // No content handlers yet, that's fine } + // We need to do this _after_ registering all of the available handlers, + // so that getWebContentHandlerByURI can return successfully. try { var autoBranch = ps.getBranch(PREF_CONTENTHANDLERS_AUTO); var childPrefs = autoBranch.getChildList("", { });