340897 - lots of rss bug fixes r=sspitzer

This commit is contained in:
beng%bengoodger.com 2006-06-12 18:14:55 +00:00
Родитель 56920f9784
Коммит 145430bef6
23 изменённых файлов: 618 добавлений и 182 удалений

Просмотреть файл

@ -455,18 +455,15 @@ 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.0.title", "Netvibes");
pref("browser.contentHandlers.types.0.uri", "http://www.netvibes.com/subscribe.php?url=%s");
pref("browser.contentHandlers.types.0.title", "Bloglines");
pref("browser.contentHandlers.types.0.uri", "http://www.bloglines.com/login?r=/sub/%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.title", "iGoogle/Google Reader");
pref("browser.contentHandlers.types.1.uri", "http://fusion.google.com/add?feedurl=%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.title", "My Yahoo");
pref("browser.contentHandlers.types.2.uri", "http://add.my.yahoo.com/rss?url=%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
#ifdef MOZ_SAFE_BROWSING

Просмотреть файл

@ -0,0 +1,150 @@
/* -*- 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 the Add Feed Reader Dialog.
*
* 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):
* Ben Goodger <beng@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 ***** */
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
function LOG(str) {
dump("*** " + str + "\n");
}
const TYPE_MAYBE_FEED = "application/vnd.mozilla.maybe.feed";
const PREF_SELECTED_WEB = "browser.feeds.handlers.webservice";
const TYPETYPE_MIME = 1;
const TYPETYPE_PROTOCOL = 2;
//
// window.arguments:
//
// 0 nsIDialogParamBlock containing user decision result
// 1 string uri of the service being registered
// 2 string title of the service being registered
// 3 string type of service being registered for
// 4 integer 1 = content type 2 = protocol
var AddFeedReader = {
_result: null,
_uri: null,
_title: null,
_type: null,
_typeType: null,
init: function AFR_init() {
this._result = window.arguments[0].QueryInterface(Ci.nsIDialogParamBlock);
this._uri = window.arguments[1];
this._title = window.arguments[2];
this._type = window.arguments[3];
this._typeType = window.arguments[4];
var strings = document.getElementById("strings");
var dlg = document.documentElement;
var addQuestion = document.getElementById("addQuestion");
var wccr =
Cc["@mozilla.org/web-content-handler-registrar;1"].
getService(Ci.nsIWebContentConverterService);
var handler =
wccr.getWebContentHandlerByURI(this._type, this._uri);
var key = handler != null ? "handlerRegistered" : "addHandler";
var message = strings.getFormattedString(key, [this._title]);
addQuestion.setAttribute("value", message);
this._updateAddAsDefaultCheckbox();
if (this._type != TYPE_MAYBE_FEED && this._typeType == TYPETYPE_MIME) {
var mimeService =
Cc["@mozilla.org/uriloader/external-helper-app-service;1"].
getService(Ci.nsIMIMEService);
var ext = mimeService.getPrimaryExtension(this._type, null);
var imageBox = document.getElementById("imageBox");
imageBox.style.backgroundImage = "url('moz-icon://goat." + ext + "?size=32');";
}
var site = document.getElementById("site");
site.value = this._uri;
if (handler)
dlg.getButton("accept").focus();
else {
dlg.getButton("accept").label = strings.getString("addHandlerYes");
dlg.getButton("cancel").label = strings.getString("addHandlerNo");
dlg.getButton("cancel").focus();
}
},
_updateAddAsDefaultCheckbox: function AFR__updateAddAsDefaultCheckbox() {
var addAsDefaultCheckbox =
document.getElementById("addAsDefaultCheckbox");
if (this._type != TYPE_MAYBE_FEED) {
addAsDefaultCheckbox.hidden = true;
return;
}
try {
var ps =
Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
var webHandler =
ps.getComplexValue(PREF_SELECTED_WEB, Ci.nsIPrefLocalizedString);
if (webHandler.data == window.arguments[0]) {
addAsDefaultCheckbox.checked = true;
addAsDefaultCheckbox.disabled = true;
}
}
catch (e) {
}
},
add: function AFR_add() {
// Used to tell the WCCR that the user chose to add the handler (rather
// than canceling) and whether or not they made it their default handler.
const PARAM_SHOULD_ADD_HANDLER = 0;
const PARAM_SHOULD_MAKE_DEFAULT = 1;
this._result.SetInt(PARAM_SHOULD_ADD_HANDLER, 1);
if (this._type == TYPE_MAYBE_FEED) {
var addAsDefaultCheckbox = document.getElementById("addAsDefaultCheckbox");
this._result.SetInt(PARAM_SHOULD_MAKE_DEFAULT,
addAsDefaultCheckbox.checked ? 1 : 0);
}
}
};

Просмотреть файл

Просмотреть файл

@ -65,10 +65,55 @@ var SubscriptionOptions = {
catch (e) {
}
this._initClientApp();
this.populateWebHandlers();
var handler = "bookmarks";
try {
handler = prefs.getCharPref(PREF_SELECTED_HANDLER);
}
catch (e) {
}
var reader = document.getElementById("reader");
reader.value = handler != "bookmarks" ? "reader" : "bookmarks";
var readers = document.getElementById("readers");
if (handler == "web") {
try {
readers.value = prefs.getCharPref(PREF_SELECTED_WEB);
}
catch (e) {
readers.selectedIndex = 1;
}
}
else if (handler == "client")
readers.selectedIndex = 0;
if ("arguments" in window && window.arguments[0] == "subscribe") {
var strings = document.getElementById("bundle");
var okButton = document.documentElement.getButton("accept");
okButton.label = strings.getString("subscribeNow");
document.title = strings.getString("subscribeTitle");
okButton.className += " feedSubscribeButton";
}
if (handler != "bookmarks")
readers.focus();
},
_initClientApp: function SO__initClientApp() {
var clientApp = document.getElementById("clientApp");
try {
var prefs =
Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
clientApp.file =
prefs.getComplexValue(PREF_SELECTED_APP, Ci.nsILocalFile);
var application = document.getElementById("applicationName");
application.setAttribute("label", clientApp.label);
application.setAttribute("image", clientApp.image);
}
catch (e) {
// No specified file, look on the system for one
@ -82,7 +127,8 @@ var SubscriptionOptions = {
var path = regKey.readStringValue("");
if (path.charAt(0) == "\"") {
// Everything inside the quotes
path = path.substr(1, path.lastIndexOf("\"") - 1);
path = path.substr(1);
path = path.substr(0, path.indexOf("\""));
}
else {
// Everything up to the first space
@ -92,82 +138,50 @@ var SubscriptionOptions = {
Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
file.initWithPath(path);
clientApp.file = file;
var application = document.getElementById("applicationName");
application.setAttribute("label", clientApp.label);
application.setAttribute("image", clientApp.image);
}
catch (e) {
LOG("SubscriptionOptions.init: No feed: handler registered on system");
}
#endif
}
var wsp = document.getElementById("webServicePopup");
this.populateWebHandlers(wsp);
if (!document.getElementById("noneItem")) {
// If there are any web handlers installed, this option should
// be enabled for selection.
var readerWebOption = document.getElementById("readerWeb");
readerWebOption.removeAttribute("disabled");
}
var webService = document.getElementById("webService");
try {
webService.value = prefs.getCharPref(PREF_SELECTED_WEB);
}
catch (e) {
webService.selectedIndex = 0;
}
var reader = document.getElementById("reader");
try {
reader.value = prefs.getCharPref(PREF_SELECTED_HANDLER);
}
catch (e) {
reader.value = "bookmarks";
}
},
populateWebHandlers: function SO_populateWebHandlers(popup) {
readerTypeChanged: function SO_readerTypeChanged() {
var reader = document.getElementById("reader");
var chooseClientApp = document.getElementById("chooseClientApp");
var readers = document.getElementById("readers");
readers.disabled = chooseClientApp.disabled =
reader.value == "bookmarks";
},
populateWebHandlers: function SO_populateWebHandlers() {
var wccr =
Cc["@mozilla.org/web-content-handler-registrar;1"].
getService(Ci.nsIWebContentConverterRegistrar);
getService(Ci.nsIWebContentConverterService);
var handlers = wccr.getContentHandlers(TYPE_MAYBE_FEED, {});
if (handlers.length == 0)
return;
while (popup.hasChildNodes())
popup.removeChild(popup.firstChild);
var appRow = document.getElementById("application");
while (appRow.nextSibling)
appRow.parentNode.removeChild(appRow.parentNode.lastChild);
var ios =
Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
for (var i = 0; i < handlers.length; ++i) {
var menuitem = document.createElementNS(XUL_NS, "menuitem");
menuitem.setAttribute("label", handlers[i].name);
menuitem.setAttribute("value", handlers[i].uri);
var row = document.createElementNS(XUL_NS, "listitem");
row.className = "listitem-iconic";
row.setAttribute("label", handlers[i].name);
row.setAttribute("value", handlers[i].uri);
var uri = ios.newURI(handlers[i].uri, null, null);
menuitem.setAttribute("src", uri.prePath + "/favicon.ico");
row.setAttribute("image", uri.prePath + "/favicon.ico");
popup.appendChild(menuitem);
}
},
selectionChanged: function SO_selectionChanged() {
var reader = document.getElementById("reader");
var clientApp = document.getElementById("clientApp");
var chooseClientApp = document.getElementById("chooseClientApp");
var webService = document.getElementById("webService");
switch (reader.value) {
case "client":
webService.disabled = true;
clientApp.disabled = chooseClientApp.disabled = false;
break;
case "web":
webService.disabled = false;
clientApp.disabled = chooseClientApp.disabled = true;
break;
case "bookmarks":
webService.disabled = true;
clientApp.disabled = chooseClientApp.disabled = true;
break;
appRow.parentNode.appendChild(row);
}
},
@ -177,8 +191,20 @@ var SubscriptionOptions = {
fp.init(window, title, Ci.nsIFilePicker.modeOpen);
fp.appendFilters(Ci.nsIFilePicker.filterApps);
if (fp.show() == Ci.nsIFilePicker.returnOK && fp.file) {
// XXXben - we need to compare this with the running instance executable
// just don't know how to do that via script...
if (fp.file.leafName == "firefox.exe")
return false;
var clientApp = document.getElementById("clientApp");
clientApp.file = fp.file;
var application = document.getElementById("applicationName");
application.setAttribute("label", clientApp.label);
application.setAttribute("image", clientApp.image);
var okButton = document.documentElement.getButton("accept");
okButton.disabled = !clientApp.file.exists();
return true;
}
return false;
@ -190,23 +216,28 @@ var SubscriptionOptions = {
getService(Ci.nsIPrefBranch);
var reader = document.getElementById("reader");
prefs.setCharPref(PREF_SELECTED_HANDLER, reader.value);
var readers = document.getElementById("readers");
var selectedHandler = "bookmarks";
if (reader.value != "bookmarks")
selectedHandler = readers.selectedIndex == 0 ? "client" : "web";
prefs.setCharPref(PREF_SELECTED_HANDLER, selectedHandler);
var clientApp = document.getElementById("clientApp");
if (clientApp.file)
prefs.setComplexValue(PREF_SELECTED_APP, Ci.nsILocalFile,
clientApp.file);
var webService = document.getElementById("webService");
prefs.setCharPref(PREF_SELECTED_WEB, webService.value);
if (selectedHandler == "web")
prefs.setCharPref(PREF_SELECTED_WEB, readers.selectedItem.value);
var autoHandle = document.getElementById("autoHandle");
prefs.setBoolPref(PREF_SKIP_PREVIEW_PAGE, autoHandle.checked);
if (reader.value == "web") {
if (selectedHandler == "web") {
var wccr =
Cc["@mozilla.org/web-content-handler-registrar;1"].
getService(Ci.nsIWebContentConverterRegistrar);
getService(Ci.nsIWebContentConverterService);
if (autoHandle.checked) {
var handler =
wccr.getWebContentHandlerByURI(TYPE_MAYBE_FEED, webService.value);
@ -217,6 +248,16 @@ var SubscriptionOptions = {
wccr.setAutoHandler(TYPE_MAYBE_FEED, null);
}
try {
var params = window.arguments[1].QueryInterface(Ci.nsIDialogParamBlock);
// Used to tell the preview page that the user chose to subscribe with
// a particular reader, and so it should subscribe now.
const PARAM_USER_SUBSCRIBED = 0;
params.SetInt(PARAM_USER_SUBSCRIBED, 1);
}
catch (e) {
}
prefs.QueryInterface(Ci.nsIPrefService);
prefs.savePrefFile(null);
},

Просмотреть файл

@ -19,40 +19,40 @@
<script type="application/x-javascript"
src="chrome://browser/content/feeds/options.js"/>
<groupbox>
<groupbox id="readerGroup">
<caption label="&readers.title;"/>
<radiogroup id="reader" onselect="SubscriptionOptions.selectionChanged();">
<radio id="readerClient" value="client"
label="&readerClient.label;" accesskey="&readerClient.accesskey;"/>
<separator class="thin"/>
<filefield class="indent" id="clientApp" disabled="true" collapsed="true"/>
<radiogroup id="reader" onselect="SubscriptionOptions.readerTypeChanged()">
<hbox>
<filefield class="indent" id="clientApp" disabled="true" flex="1"/>
<button id="chooseClientApp"
label="&chooseClientApp.label;" accesskey="&chooseClientApp.accesskey;"
oncommand="SubscriptionOptions.chooseClientApp();"/>
</hbox>
<separator class="thin"/>
<radio id="readerWeb" value="web" disabled="true"
label="&readerWeb.label;" accesskey="&readerWeb.accesskey;"/>
<separator class="thin"/>
<menulist class="indent" id="webService" disabled="true">
<menupopup id="webServicePopup"
onpopupshowing="SubscriptionOptions.populateWebHandlers(this);">
<menuitem id="noneItem" label="&none.label;"/>
</menupopup>
</menulist>
<separator/>
<hbox>
<radio id="readerBookmarks" value="bookmarks"
label="&readerBookmarks.label;" accesskey="&readerBookmarks.accesskey;"/>
<radio id="useBookmarks" value="bookmarks"
label="&useBookmarks.label;" accesskey="&useBookmarks.accesskey;"/>
<separator flex="1"/>
<button class="plain link" url="&liveBookmarksInfo.url;"
label="&liveBookmarksInfo.label;" accesskey="&liveBookmarksInfo.accesskey;"
oncommand="SubscriptionOptions.whatAreLiveBookmarks(this);"/>
</hbox>
<radio id="useReader" value="reader"
label="&useReader.label;" accesskey="&useReader.accesskey;"/>
<hbox id="readerContainer" class="indent" flex="1">
<listbox id="readers" onselect="event.preventBubble();" rows="5" flex="1">
<listcols>
<listcol flex="1"/>
<listcol/>
</listcols>
<listitem id="application" value="application" allowevents="true">
<listcell id="applicationName" class="listcell-iconic"/>
<listcell>
<button id="chooseClientApp"
label="&chooseClientApp.label;" accesskey="&chooseClientApp.accesskey;"
oncommand="SubscriptionOptions.chooseClientApp();"/>
</listcell>
</listitem>
</listbox>
</hbox>
</radiogroup>
<separator/>
<separator class="thin"/>
</groupbox>
<separator class="thin"/>
<hbox>

Просмотреть файл

@ -203,6 +203,10 @@ var SubscribeHandler = {
for (var i = 0; i < feed.items.length; ++i) {
var entry = feed.items.queryElementAt(i, Ci.nsIFeedEntry);
entry.QueryInterface(Ci.nsIFeedContainer);
var entryContainer = document.createElementNS(HTML_NS, "div");
entryContainer.className = "entry";
var a = document.createElementNS(HTML_NS, "a");
a.appendChild(document.createTextNode(entry.title));
@ -212,7 +216,7 @@ var SubscribeHandler = {
var title = document.createElementNS(HTML_NS, "h3");
title.appendChild(a);
feedContent.appendChild(title);
entryContainer.appendChild(title);
var body = document.createElementNS(HTML_NS, "p");
var summary = entry.summary(true)
@ -222,7 +226,9 @@ var SubscribeHandler = {
// XXXben - Change to use innerHTML
body.appendChild(document.createTextNode(summary));
body.className = "feedEntryContent";
feedContent.appendChild(body);
entryContainer.appendChild(body);
feedContent.appendChild(entryContainer);
}
},
@ -270,6 +276,7 @@ var SubscribeHandler = {
var selectedApp =
prefs.getComplexValue(PREF_SELECTED_APP, Ci.nsILocalFile);
var displayName = this._getFileDisplayName(selectedApp);
LOG("displayName: "+ displayName);
this._setContentText("feedSubscribeHandleText", displayName);
var url = ios.newFileURI(selectedApp).QueryInterface(Ci.nsIURL);
@ -279,7 +286,7 @@ var SubscribeHandler = {
var webURI = prefs.getCharPref(PREF_SELECTED_WEB);
var wccr =
Cc["@mozilla.org/web-content-handler-registrar;1"].
getService(Ci.nsIWebContentConverterRegistrar);
getService(Ci.nsIWebContentConverterService);
var title ="Unknown";
var handler =
wccr.getWebContentHandlerByURI(TYPE_MAYBE_FEED, webURI);
@ -297,6 +304,9 @@ var SubscribeHandler = {
}
unchosen.setAttribute("hidden", "true");
chosen.removeAttribute("hidden");
var button = document.getElementById("feedSubscribeLink");
button.focus();
var displayArea =
document.getElementById("feedSubscribeHandleText");
@ -309,6 +319,9 @@ var SubscribeHandler = {
chosen.setAttribute("hidden", "true");
unchosen.removeAttribute("hidden");
document.getElementById("feedHeader").setAttribute("firstrun", "true");
var button = document.getElementById("feedChooseInitialReader");
button.focus();
}
},
@ -318,19 +331,36 @@ var SubscribeHandler = {
},
changeOptions: function SH_changeOptions() {
openDialog("chrome://browser/content/feeds/options.xul", "", "modal,centerscreen");
var paramBlock =
Cc["@mozilla.org/embedcomp/dialogparam;1"].
createInstance(Ci.nsIDialogParamBlock);
// Used to tell the preview page that the user chose to subscribe with
// a particular reader, and so it should subscribe now.
const PARAM_USER_SUBSCRIBED = 0;
paramBlock.SetInt(PARAM_USER_SUBSCRIBED, 0);
openDialog("chrome://browser/content/feeds/options.xul", "",
"modal,centerscreen", "subscribe", paramBlock);
if (paramBlock.GetInt(PARAM_USER_SUBSCRIBED) == 1)
this.subscribe();
},
subscribe: function FH_subscribe() {
var prefs =
Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
var handler = prefs.getCharPref(PREF_SELECTED_HANDLER);
try {
var handler = prefs.getCharPref(PREF_SELECTED_HANDLER);
}
catch (e) {
// Something is bogus in our state. Prompt the user to fix it.
this.changeOptions();
return;
}
if (handler == "web") {
var webURI = prefs.getCharPref(PREF_SELECTED_WEB);
var wccr =
Cc["@mozilla.org/web-content-handler-registrar;1"].
getService(Ci.nsIWebContentConverterRegistrar);
getService(Ci.nsIWebContentConverterService);
var handler =
wccr.getWebContentHandlerByURI(TYPE_MAYBE_FEED, webURI);
window.location.href = handler.getHandlerURI(window.location.href);

Просмотреть файл

@ -32,8 +32,10 @@
</div>
<div id="feedSubscribeLine">
<div id="feedSubscribeLineHandlerChosen">
<a id="feedSubscribeLink" href="javascript:SubscribeHandler.subscribe();">
&feedSubscribeNow;</a>
<button id="feedSubscribeLink" class="feedSubscribeLink"
onclick="SubscribeHandler.subscribe();">
<span class="feedSubscribeLinkBox">&feedSubscribeNow;</span>
</button>
&feedSubscribeUsing;
<span id="feedSubscribeHandler">
<a id="feedSubscribeHandleText"></a>
@ -42,8 +44,10 @@
&feedSubscribeChangeSubscribeOptions;</a>
</div>
<div id="feedSubscribeLineHandlerUnchosen" hidden="true">
<a id="feedChooseSubscribeOptions" href="javascript:SubscribeHandler.changeOptions();">
&feedSubscribeChooseSubscribeOptions;</a>
<button id="feedChooseInitialReader" class="feedSubscribeLink"
onclick="SubscribeHandler.changeOptions();">
<span class="feedSubscribeLinkBox">&feedSubscribeChooseSubscribeOptions;</span>
</button>
&feedSubscribeChooseInfo;
</div>
</div>

Просмотреть файл

@ -3,3 +3,5 @@ browser.jar:
* content/browser/feeds/subscribe.js (content/subscribe.js)
* content/browser/feeds/options.xul (content/options.xul)
* content/browser/feeds/options.js (content/options.js)
* content/browser/feeds/addFeedReader.xul (content/addFeedReader.xul)
* content/browser/feeds/addFeedReader.js (content/addFeedReader.js)

Просмотреть файл

@ -78,7 +78,7 @@ interface nsIWebContentHandlerInfo : nsISupports
};
[scriptable, uuid(632b16a8-5c6b-4dc5-a8db-01771af7a79d)]
interface nsIWebContentConverterRegistrar : nsISupports
interface nsIWebContentConverterService : nsISupports
{
/**
* Specifies the handler to be used to automatically handle all links of a
@ -115,17 +115,6 @@ interface nsIWebContentConverterRegistrar : nsISupports
nsIWebContentHandlerInfo getWebContentHandlerByURI(in AString contentType,
in AString uri);
/**
* Gets the URI Spec for the "handler" of a particular type, with the
* specified uri embedded.
* @param uri
* The uri to be embedded in the handler URI
* @param contentType
* The content type of the document at |uri|
* @returns A uri of the handler for the |contentType|, with the |
*/
AString getHandlerURI(in AString uri, in AString contentType);
/**
* Loads the preferred handler when content of a registered type is about
* to be loaded.
@ -184,5 +173,13 @@ interface nsIWebContentConverterRegistrar : nsISupports
*/
void getContentHandlers(in AString contentType, out unsigned long count,
[retval,array,size_is(count)] out nsIWebContentHandlerInfo handlers);
/**
* Resets the list of available content handlers to the default set from
* the distribution.
* @param contentType
* The content type to reset handlers for
*/
void resetHandlersForType(in AString contentType);
};

Просмотреть файл

@ -179,7 +179,7 @@ FeedConverter.prototype = {
if (handler == "web") {
var wccr =
Cc["@mozilla.org/web-content-handler-registrar;1"].
getService(Ci.nsIWebContentConverterRegistrar);
getService(Ci.nsIWebContentConverterService);
var feed = result.doc.QueryInterface(Ci.nsIFeed);
if (feed.type == Ci.nsIFeed.TYPE_FEED &&
wccr.getAutoHandler(TYPE_MAYBE_FEED)) {

Просмотреть файл

@ -40,7 +40,7 @@ const Ci = Components.interfaces;
const Cr = Components.results;
function LOG(str) {
debug("*** " + str + "\n");
dump("*** " + str + "\n");
}
const WCCR_CONTRACTID = "@mozilla.org/web-content-handler-registrar;1";
@ -55,6 +55,8 @@ const TYPE_ANY = "*/*";
const PREF_CONTENTHANDLERS_AUTO = "browser.contentHandlers.auto.";
const PREF_CONTENTHANDLERS_BRANCH = "browser.contentHandlers.types.";
const PREF_SELECTED_WEB = "browser.feeds.handlers.webservice";
const PREF_SELECTED_HANDLER = "browser.feeds.handler";
function WebContentConverter() {
}
@ -67,12 +69,13 @@ WebContentConverter.prototype = {
onStartRequest: function WCC_onStartRequest(request, context) {
var wccr =
Cc["@mozilla.org/web-content-handler-registrar;1"].
getService(Ci.nsIWebContentConverterRegistrar);
getService(Ci.nsIWebContentConverterService);
wccr.loadPreferredHandler(request);
},
QueryInterface: function WCC_QueryInterface(iid) {
if (iid.equals(Ci.nsIStreamConverter) ||
iid.equals(Ci.nsIStreamListener) ||
iid.equals(Ci.nsISupports))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
@ -155,7 +158,7 @@ var WebContentConverterRegistrar = {
_autoHandleContentTypes: { },
/**
* See nsIWebContentConverterRegistrar
* See nsIWebContentConverterService
*/
getAutoHandler:
function WCCR_getAutoHandler(contentType) {
@ -166,7 +169,7 @@ var WebContentConverterRegistrar = {
},
/**
* See nsIWebContentConverterRegistrar
* See nsIWebContentConverterService
*/
setAutoHandler:
function WCCR_setAutoHandler(contentType, handler) {
@ -200,7 +203,7 @@ var WebContentConverterRegistrar = {
},
/**
* See nsIWebContentConverterRegistrar
* See nsIWebContentConverterService
*/
getWebContentHandlerByURI:
function WCCR_getWebContentHandlerByURI(contentType, uri) {
@ -213,7 +216,7 @@ var WebContentConverterRegistrar = {
},
/**
* See nsIWebContentConverterRegistrar
* See nsIWebContentConverterService
*/
loadPreferredHandler:
function WCCR_loadPreferredHandler(request) {
@ -232,7 +235,7 @@ var WebContentConverterRegistrar = {
},
/**
* See nsIWebContentConverterRegistrar
* See nsIWebContentConverterService
*/
removeProtocolHandler:
function WCCR_removeProtocolHandler(protocol, uri) {
@ -245,7 +248,7 @@ var WebContentConverterRegistrar = {
},
/**
* See nsIWebContentConverterRegistrar
* See nsIWebContentConverterService
*/
removeContentHandler:
function WCCR_removeContentHandler(contentType, uri) {
@ -288,28 +291,97 @@ var WebContentConverterRegistrar = {
return contentType;
},
_confirmAdd: function WCCR__confirmAdd(title, uri) {
var ps =
Cc["@mozilla.org/embedcomp/prompt-service;1"].
getService(Ci.nsIPromptService);
return ps.confirm(null, "Add Handler",
"Add web handler for " + title + " to " + uri + "?",
"Yes", "No", null, null);
_wrapString: function WCCR__wrapString(string) {
var supportsString =
Cc["@mozilla.org/supports-string;1"].
createInstance(Ci.nsISupportsString);
supportsString.data = string;
return supportsString;
},
_updateDefaultReader: function WCCR__updateDefaultReader(uri) {
var ps =
Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
var localizedString =
Cc["@mozilla.org/pref-localizedstring;1"].
createInstance(Ci.nsIPrefLocalizedString);
localizedString.data = uri;
ps.setComplexValue(PREF_SELECTED_WEB, Ci.nsIPrefLocalizedString,
localizedString);
if (ps.getCharPref(PREF_SELECTED_HANDLER) != "web")
ps.setCharPref(PREF_SELECTED_HANDLER, "web");
},
_confirmAddHandler: function WCCR__confirmAddHandler(contentType, title, uri) {
var args =
Cc["@mozilla.org/supports-array;1"].
createInstance(Ci.nsISupportsArray);
var paramBlock =
Cc["@mozilla.org/embedcomp/dialogparam;1"].
createInstance(Ci.nsIDialogParamBlock);
// Used to tell the WCCR that the user chose to add the handler (rather
// than canceling) and whether or not they made it their default handler.
const PARAM_SHOULD_ADD_HANDLER = 0;
const PARAM_SHOULD_MAKE_DEFAULT = 1;
paramBlock.SetInt(PARAM_SHOULD_ADD_HANDLER, 0);
paramBlock.SetInt(PARAM_SHOULD_MAKE_DEFAULT, 0);
args.AppendElement(paramBlock);
args.AppendElement(this._wrapString(uri));
args.AppendElement(this._wrapString(title));
args.AppendElement(this._wrapString(contentType));
var typeType =
Cc["@mozilla.org/supports-PRInt32;1"].
createInstance(Ci.nsISupportsPRInt32);
typeType.data = 1;
args.AppendElement(typeType);
var ww =
Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
ww.openWindow(null, "chrome://browser/content/feeds/addFeedReader.xul",
"", "modal,titlebar,centerscreen,dialog=yes", args);
var shouldAdd = paramBlock.GetInt(PARAM_SHOULD_ADD_HANDLER) == 1;
if (shouldAdd&& contentType == TYPE_MAYBE_FEED &&
paramBlock.GetInt(PARAM_SHOULD_MAKE_DEFAULT) == 1) {
// User chose to use the reader as their default, so update the
// chosen reader preference, too.
this._updateDefaultReader(uri);
}
return shouldAdd;
},
_checkForDuplicateContentType:
function WCCR__checkForDuplicateContentType(contentType, uri, title) {
contentType = this._resolveContentType(contentType);
if (this._typeIsRegistered(contentType, uri)) {
// Show a special dialog for the feed case (XXXben - generalize at some
// point to allow other types to register specialized prompts).
this._confirmAddHandler(contentType, title, uri);
return false;
}
return true;
},
// XXXben: These functions need to move to window.navigator
/**
* See nsIWebContentConverterRegistrar
* See nsIWebContentHandlerRegistrar
*/
registerProtocolHandler:
function WCCR_registerProtocolHandler(protocol, uri, title) {
// XXXben - for Firefox 2 we only support feed types
return;
LOG("registerProtocolHandler(" + protocol + "," + uri + "," + title + ")");
if (this._confirmAdd(title, uri))
if (this._confirmAddHandler(protocol, title, uri))
this._protocols[protocol] = uri;
},
/**
* See nsIWebContentConverterRegistrar
* See nsIWebContentHandlerRegistrar
* This is the web front end into the registration system, so a prompt to
* confirm the registration is provided, and the result is saved to
* preferences.
@ -318,10 +390,20 @@ var WebContentConverterRegistrar = {
function WCCR_registerContentHandler(contentType, uri, title) {
LOG("registerContentHandler(" + contentType + "," + uri + "," + title + ")");
if (!this._confirmAdd(title, uri))
// XXXben - for Firefox 2 we only support feed types
contentType = this._resolveContentType(contentType);
if (contentType != TYPE_MAYBE_FEED)
return;
contentType = this._resolveContentType(contentType);
if (!this._checkForDuplicateContentType(contentType, uri, title) ||
!this._confirmAddHandler(contentType, title, uri))
return;
// Reset the auto handler so that the user is asked again the next time
// they load content of this type.
if (this.getAutoHandler(contentType))
this.setAutoHandler(contentType, null);
this._registerContentHandler(contentType, uri, title);
this._saveContentHandlerToPrefs(contentType, uri, title);
},
@ -378,6 +460,9 @@ var WebContentConverterRegistrar = {
* The uri of the
*/
_typeIsRegistered: function WCCR__typeIsRegistered(contentType, uri) {
if (!(contentType in this._contentTypes))
return false;
var services = this._contentTypes[contentType];
for (var i = 0; i < services.length; ++i) {
// This uri has already been registered
@ -429,7 +514,7 @@ var WebContentConverterRegistrar = {
},
/**
* See nsIWebContentConverterRegistrar
* See nsIWebContentConverterService
*/
getContentHandlers:
function WCCR_getContentHandlers(contentType, countRef) {
@ -442,6 +527,54 @@ var WebContentConverterRegistrar = {
return handlers;
},
/**
* See nsIWebContentConverterService
*/
resetHandlersForType:
function WCCR_resetHandlersForType(contentType) {
contentType = this._resolveContentType(contentType);
var ps =
Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefService);
try {
var i = 0;
while (true) {
var handlerBranch =
ps.getBranch(PREF_CONTENTHANDLERS_BRANCH + i + ".");
try {
if (handlerBranch.getCharPref("type") == contentType)
handlerBranch.resetBranch("");
var defaultBranch =
ps.getDefaultBranch(PREF_CONTENTHANDLERS_BRANCH + i + ".");
if (!this._registerContentHandlerWithBranch(defaultBranch))
break;
++i;
}
catch (e) {
}
}
}
catch (e) {
}
ps.savePrefFile(null);
},
/**
* Registers a handler from the settings on a branch
*/
_registerContentHandlerWithBranch: function(branch) {
try {
var type = branch.getCharPref("type");
var uri = branch.getCharPref("uri");
var title = branch.getCharPref("title");
this._registerContentHandler(type, uri, title);
}
catch (e) {
return false;
}
return true;
},
/**
* Load the auto handler, content handler and protocol tables from
* preferences.
@ -455,21 +588,13 @@ var WebContentConverterRegistrar = {
while (true) {
var handlerBranch =
ps.getBranch(PREF_CONTENTHANDLERS_BRANCH + (i++) + ".");
try {
var type = handlerBranch.getCharPref("type");
var uri = handlerBranch.getCharPref("uri");
var title = handlerBranch.getCharPref("title");
this._registerContentHandler(type, uri, title);
}
catch (e) {
LOG("WCCR.init: There are " + (i-1) + " handlers registered in preferences.");
if (!this._registerContentHandlerWithBranch(handlerBranch))
break;
}
}
}
catch (e) {
// No content handlers yet, that's fine
LOG("WCCR.init: There are no content handlers registered in preferences (benign).");
//LOG("WCCR.init: There are no content handlers registered in preferences (benign).");
}
// We need to do this _after_ registering all of the available handlers,
@ -488,7 +613,7 @@ var WebContentConverterRegistrar = {
}
catch (e) {
// No auto branch yet, that's fine
LOG("WCCR.init: There is no auto branch, benign");
//LOG("WCCR.init: There is no auto branch, benign");
}
},
@ -523,8 +648,11 @@ var WebContentConverterRegistrar = {
* See nsIClassInfo
*/
getInterfaces: function WCCR_getInterfaces(countRef) {
countRef.value = 2;
return [Ci.nsIWebContentConverterRegistrar, Ci.nsIClassInfo];
var interfaces =
[Ci.nsIWebContentConverterService, Ci.nsIWebContentHandlerRegistrar,
Ci.nsIObserver, Ci.nsIClassInfo, Ci.nsIFactory, Ci.nsISupports];
countRef.value = interfaces.length;
return interfaces;
},
getHelperForLanguage: function WCCR_getHelperForLanguage(language) {
return null;
@ -539,7 +667,8 @@ var WebContentConverterRegistrar = {
* See nsISupports
*/
QueryInterface: function WCCR_QueryInterface(iid) {
if (iid.equals(Ci.nsIWebContentConverterRegistrar) ||
if (iid.equals(Ci.nsIWebContentConverterService) ||
/*iid.equals(Ci.nsIWebContentHandlerRegistrar) || see bug 340179 */
iid.equals(Ci.nsIObserver) ||
iid.equals(Ci.nsIClassInfo) ||
iid.equals(Ci.nsIFactory) ||

Просмотреть файл

Просмотреть файл

@ -2,24 +2,12 @@
"Subscription Options">
<!ENTITY readers.title
"Choose a Feed Reader:">
<!ENTITY readerClient.label
"Use an Application:">
<!ENTITY readerClient.accesskey
"A">
<!ENTITY readerWeb.label
"Use a Web Site:">
<!ENTITY readerWeb.accesskey
"W">
<!ENTITY readerBookmarks.label
"Use Live Bookmarks">
<!ENTITY readerBookmarks.accesskey
"L">
<!ENTITY autoHandle.label
"Open Feeds with my chosen reader automatically, skipping the preview page">
<!ENTITY autoHandle.accesskey
"O">
<!ENTITY chooseClientApp.label
"Choose...">
"Change...">
<!ENTITY chooseClientApp.accesskey
"C">
@ -33,3 +21,12 @@
<!ENTITY none.label
"None Available">
<!ENTITY useReader.label
"Use a Feed Reader:">
<!ENTITY useReader.accesskey
"F">
<!ENTITY useBookmarks.label
"Use Live Bookmarks">
<!ENTITY useBookmarks.accesskey
"B">

Просмотреть файл

@ -1,2 +1,8 @@
linkTitleTextFormat=Go to %S
liveBookmarks=Live Bookmarks
addHandler=Add "%S" as a feed reader?
addHandlerYes=Yes
addHandlerNo=No
handlerRegistered="%S" is already registered as a Feed Reader
subscribeNow=Subscribe Now
subscribeTitle=Choose a Feed Reader

Просмотреть файл

@ -45,6 +45,7 @@
#ifdef MOZ_FEEDS
locale/browser/feeds/subscribe.dtd (%chrome/browser/feeds/subscribe.dtd)
locale/browser/feeds/options.dtd (%chrome/browser/feeds/options.dtd)
locale/browser/feeds/addFeedReader.dtd (%chrome/browser/feeds/addFeedReader.dtd)
locale/browser/feeds/subscribe.properties (%chrome/browser/feeds/subscribe.properties)
#endif
locale/browser/history/history.dtd (%chrome/browser/history/history.dtd)

Просмотреть файл

Двоичные данные
browser/themes/pinstripe/browser/feeds/feedIcon16.png Executable file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 3.5 KiB

Просмотреть файл

@ -60,15 +60,20 @@ html {
}
#feedSubscribeHandleText {
-moz-padding-start: 18px;
background: url("chrome://browser/skin/places/livemarkItem.png") left 0 no-repeat;
-moz-padding-start: 20px;
background: url("chrome://browser/skin/feeds/feedIcon16.png") left 0 no-repeat;
}
#feedSubscribeLink {
background: url("chrome://browser/skin/places/livemarkItem.png") left 0 no-repeat;
-moz-padding-start: 18px;
.feedSubscribeLink {
font-weight: bold;
-moz-margin-end: .4em;
padding: .2em .1em .2em .1em;
}
.feedSubscribeLinkBox {
background: url("chrome://browser/skin/feeds/feedIcon16.png") left 0 no-repeat;
-moz-padding-start: 19px;
-moz-margin-end: 0px;
}
#feedSubscribeOptionsGroup {
@ -185,3 +190,37 @@ a[href] img {
.plain:focus > .button-box {
border: 1px dotted ThreeDDarkShadow;
}
#readerContainer {
-moz-appearance: listbox;
}
#readers {
-moz-appearance: none;
border: none;
margin: 0px;
}
#readers > listitem {
-moz-padding-start: 4px;
}
#chooseClientApp {
font-size: 80%;
}
#application {
border-bottom: 1px solid ThreeDShadow;
}
#readerGroup {
-moz-padding-end: 14px;
}
.feedSubscribeButton {
font-weight: bold;
list-style-image: url("chrome://browser/skin/feeds/feedIcon16.png");
}
.feedSubscribeButton .button-icon {
-moz-margin-end: 3px;
}

Просмотреть файл

@ -36,6 +36,8 @@ classic.jar:
#ifdef MOZ_FEEDS
skin/classic/browser/feeds/subscribe.css (feeds/subscribe.css)
skin/classic/browser/feeds/feedIcon.png (feeds/feedIcon.png)
skin/classic/browser/feeds/feedIcon16.png (feeds/feedIcon16.png)
skin/classic/browser/feeds/addFeedReader.css (feeds/addFeedReader.css)
#endif
#ifdef MOZ_PLACES
skin/classic/browser/places/places.css (places/places.css)

Просмотреть файл

Двоичные данные
browser/themes/winstripe/browser/feeds/feedIcon16.png Executable file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 3.5 KiB

Просмотреть файл

@ -60,15 +60,20 @@ html {
}
#feedSubscribeHandleText {
-moz-padding-start: 18px;
background: url("chrome://browser/skin/places/livemarkItem.png") left 0 no-repeat;
-moz-padding-start: 20px;
background: url("chrome://browser/skin/feeds/feedIcon16.png") left 0 no-repeat;
}
#feedSubscribeLink {
background: url("chrome://browser/skin/places/livemarkItem.png") left 0 no-repeat;
-moz-padding-start: 18px;
.feedSubscribeLink {
font-weight: bold;
-moz-margin-end: .4em;
padding: .2em .1em .2em .1em;
}
.feedSubscribeLinkBox {
background: url("chrome://browser/skin/feeds/feedIcon16.png") left 0 no-repeat;
-moz-padding-start: 19px;
-moz-margin-end: 0px;
}
#feedSubscribeOptionsGroup {
@ -185,3 +190,37 @@ a[href] img {
.plain:focus > .button-box {
border: 1px dotted ThreeDDarkShadow;
}
#readerContainer {
-moz-appearance: listbox;
}
#readers {
-moz-appearance: none;
border: none;
margin: 0px;
}
#readers > listitem {
-moz-padding-start: 4px;
}
#chooseClientApp {
font-size: 80%;
}
#application {
border-bottom: 1px solid ThreeDShadow;
}
#readerGroup {
-moz-padding-end: 14px;
}
.feedSubscribeButton {
font-weight: bold;
list-style-image: url("chrome://browser/skin/feeds/feedIcon16.png");
}
.feedSubscribeButton .button-icon {
-moz-margin-end: 3px;
}

Просмотреть файл

@ -23,7 +23,9 @@ classic.jar:
skin/classic/browser/Toolbar-small.png
#ifdef MOZ_FEEDS
skin/classic/browser/feeds/feedIcon.png (feeds/feedIcon.png)
skin/classic/browser/feeds/feedIcon16.png (feeds/feedIcon16.png)
skin/classic/browser/feeds/subscribe.css (feeds/subscribe.css)
skin/classic/browser/feeds/addFeedReader.css (feeds/addFeedReader.css)
#endif
#ifdef MOZ_PLACES
skin/classic/browser/places/places.css (places/places.css)