bug 400061: add Podcast and Video Podcast entries to the applications prefpane; Patch by Will Guaraldi; r=myk,sayrer; a=beltzner

git-svn-id: svn://10.0.0.236/trunk@244507 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
myk%mozilla.org 2008-01-30 07:12:08 +00:00
parent bd01eec05a
commit 090529ec66
3 changed files with 138 additions and 31 deletions

View File

@ -525,6 +525,8 @@ pref("browser.contentHandlers.types.5.uri", "chrome://browser-region/locale/regi
pref("browser.contentHandlers.types.5.type", "application/vnd.mozilla.maybe.feed");
pref("browser.feeds.handler", "ask");
pref("browser.videoFeeds.handler", "ask");
pref("browser.audioFeeds.handler", "ask");
// For now, this is living in content rather than in locales, as per Pike.
// Eventually it will get merged into region.properties; see bug 395277.

View File

@ -26,6 +26,7 @@
# Asaf Romano <mozilla.mano@sent.com>
# Myk Melez <myk@mozilla.org>
# Florian Queze <florian@queze.net>
# Will Guaraldi <will.guaraldi@pculture.org>
#
# 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
@ -52,11 +53,13 @@ var Cc = Components.classes;
var Ci = Components.interfaces;
var Cr = Components.results;
var TYPE_MAYBE_FEED = "application/vnd.mozilla.maybe.feed";
const kXULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
/*
#endif
*/
var TYPE_MAYBE_AUDIO_FEED = "application/vnd.mozilla.maybe.audio.feed";
var TYPE_MAYBE_VIDEO_FEED = "application/vnd.mozilla.maybe.video.feed";
const PREF_DISABLED_PLUGIN_TYPES = "plugin.disable_full_page_plugin_for_types";
// Preferences that affect which entries to show in the list.
@ -92,6 +95,16 @@ const PREF_FEED_SELECTED_WEB = "browser.feeds.handlers.webservice";
const PREF_FEED_SELECTED_ACTION = "browser.feeds.handler";
const PREF_FEED_SELECTED_READER = "browser.feeds.handler.default";
const PREF_VIDEO_FEED_SELECTED_APP = "browser.videoFeeds.handlers.application";
const PREF_VIDEO_FEED_SELECTED_WEB = "browser.videoFeeds.handlers.webservice";
const PREF_VIDEO_FEED_SELECTED_ACTION = "browser.videoFeeds.handler";
const PREF_VIDEO_FEED_SELECTED_READER = "browser.videoFeeds.handler.default";
const PREF_AUDIO_FEED_SELECTED_APP = "browser.audioFeeds.handlers.application";
const PREF_AUDIO_FEED_SELECTED_WEB = "browser.audioFeeds.handlers.webservice";
const PREF_AUDIO_FEED_SELECTED_ACTION = "browser.audioFeeds.handler";
const PREF_AUDIO_FEED_SELECTED_READER = "browser.audioFeeds.handler.default";
// The nsHandlerInfoAction enumeration values in nsIHandlerInfo identify
// the actions the application can take with content of various types.
// But since nsIHandlerInfo doesn't support plugins, there's no value
@ -175,6 +188,9 @@ ArrayEnumerator.prototype = {
}
};
function isFeedType(t) {
return t == TYPE_MAYBE_FEED || t == TYPE_MAYBE_VIDEO_FEED || t == TYPE_MAYBE_AUDIO_FEED;
}
//****************************************************************************//
// HandlerInfoWrapper
@ -493,7 +509,7 @@ HandlerInfoWrapper.prototype = {
// Feed Handler Info
/**
* This object implements nsIHandlerInfo for the feed type. It's a separate
* This object implements nsIHandlerInfo for the feed types. It's a separate
* object because we currently store handling information for the feed type
* in a set of preferences rather than the nsIHandlerService-managed datastore.
*
@ -505,10 +521,13 @@ HandlerInfoWrapper.prototype = {
* the fact that the wrapper expects to have a wrappedHandlerInfo, which we
* don't provide.
*/
var feedHandlerInfo = {
__proto__: new HandlerInfoWrapper(TYPE_MAYBE_FEED, null),
function FeedHandlerInfo(aMIMEType) {
HandlerInfoWrapper.call(this, aMIMEType, null);
}
FeedHandlerInfo.prototype = {
__proto__: HandlerInfoWrapper.prototype,
//**************************************************************************//
// Convenience Utils
@ -530,24 +549,23 @@ var feedHandlerInfo = {
// nsIHandlerInfo
get description() {
return this.element("bundlePreferences").getString("webFeed");
return this.element("bundlePreferences").getString(this._appPrefLabel);
},
get preferredApplicationHandler() {
switch (this.element(PREF_FEED_SELECTED_READER).value) {
switch (this.element(this._prefSelectedReader).value) {
case "client":
var file = this.element(PREF_FEED_SELECTED_APP).value;
var file = this.element(this._prefSelectedApp).value;
if (file)
return getLocalHandlerApp(file);
return null;
case "web":
var uri = this.element(PREF_FEED_SELECTED_WEB).value;
var uri = this.element(this._prefSelectedWeb).value;
if (!uri)
return null;
return this._converterSvc.getWebContentHandlerByURI(TYPE_MAYBE_FEED,
uri);
return this._converterSvc.getWebContentHandlerByURI(this.type, uri);
case "bookmarks":
default:
@ -560,12 +578,12 @@ var feedHandlerInfo = {
set preferredApplicationHandler(aNewValue) {
if (aNewValue instanceof Ci.nsILocalHandlerApp) {
this.element(PREF_FEED_SELECTED_APP).value = aNewValue.executable;
this.element(PREF_FEED_SELECTED_READER).value = "client";
this.element(this._prefSelectedApp).value = aNewValue.executable;
this.element(this._prefSelectedReader).value = "client";
}
else if (aNewValue instanceof Ci.nsIWebContentHandlerInfo) {
this.element(PREF_FEED_SELECTED_WEB).value = aNewValue.uri;
this.element(PREF_FEED_SELECTED_READER).value = "web";
this.element(this._prefSelectedWeb).value = aNewValue.uri;
this.element(this._prefSelectedReader).value = "web";
// Make the web handler be the new "auto handler" for feeds.
// Note: we don't have to unregister the auto handler when the user picks
// a non-web handler (local app, Live Bookmarks, etc.) because the service
@ -625,7 +643,7 @@ var feedHandlerInfo = {
// only a single path. But we display all the local apps the user chooses
// while the prefpane is open, only dropping the list when the user closes
// the prefpane, for maximum usability and consistency with other types.
var preferredAppFile = this.element(PREF_FEED_SELECTED_APP).value;
var preferredAppFile = this.element(this._prefSelectedApp).value;
if (preferredAppFile) {
let preferredApp = getLocalHandlerApp(preferredAppFile);
let defaultApp = this._defaultApplicationHandler;
@ -696,7 +714,7 @@ var feedHandlerInfo = {
// What to do with content of this type.
get preferredAction() {
switch (this.element(PREF_FEED_SELECTED_ACTION).value) {
switch (this.element(this._prefSelectedAction).value) {
case "bookmarks":
return Ci.nsIHandlerInfo.handleInternally;
@ -734,31 +752,31 @@ var feedHandlerInfo = {
switch (aNewValue) {
case Ci.nsIHandlerInfo.handleInternally:
this.element(PREF_FEED_SELECTED_READER).value = "bookmarks";
this.element(this._prefSelectedReader).value = "bookmarks";
break;
case Ci.nsIHandlerInfo.useHelperApp:
this.element(PREF_FEED_SELECTED_ACTION).value = "reader";
this.element(this._prefSelectedAction).value = "reader";
// The controller has already set preferredApplicationHandler
// to the new helper app.
break;
case Ci.nsIHandlerInfo.useSystemDefault:
this.element(PREF_FEED_SELECTED_ACTION).value = "reader";
this.element(this._prefSelectedAction).value = "reader";
this.preferredApplicationHandler = this._defaultApplicationHandler;
break;
}
},
get alwaysAskBeforeHandling() {
return this.element(PREF_FEED_SELECTED_ACTION).value == "ask";
return this.element(this._prefSelectedAction).value == "ask";
},
set alwaysAskBeforeHandling(aNewValue) {
if (aNewValue == true)
this.element(PREF_FEED_SELECTED_ACTION).value = "ask";
this.element(this._prefSelectedAction).value = "ask";
else
this.element(PREF_FEED_SELECTED_ACTION).value = "reader";
this.element(this._prefSelectedAction).value = "reader";
},
// Whether or not we are currently storing the action selected by the user.
@ -810,15 +828,48 @@ var feedHandlerInfo = {
// Icons
get smallIcon() {
return "chrome://browser/skin/feeds/feedIcon16.png";
return this._smallIcon;
},
get largeIcon() {
return "chrome://browser/skin/feeds/feedIcon.png";
return this._largeIcon;
}
};
var feedHandlerInfo = {
__proto__: new FeedHandlerInfo(TYPE_MAYBE_FEED),
_prefSelectedApp: PREF_FEED_SELECTED_APP,
_prefSelectedWeb: PREF_FEED_SELECTED_WEB,
_prefSelectedAction: PREF_FEED_SELECTED_ACTION,
_prefSelectedReader: PREF_FEED_SELECTED_READER,
_smallIcon: "chrome://browser/skin/feeds/feedIcon16.png",
_largeIcon: "chrome://browser/skin/feeds/feedIcon.png",
_appPrefLabel: "webFeed"
}
var videoFeedHandlerInfo = {
__proto__: new FeedHandlerInfo(TYPE_MAYBE_VIDEO_FEED),
_prefSelectedApp: PREF_VIDEO_FEED_SELECTED_APP,
_prefSelectedWeb: PREF_VIDEO_FEED_SELECTED_WEB,
_prefSelectedAction: PREF_VIDEO_FEED_SELECTED_ACTION,
_prefSelectedReader: PREF_VIDEO_FEED_SELECTED_READER,
_smallIcon: "chrome://browser/skin/feeds/videoFeedIcon16.png",
_largeIcon: "chrome://browser/skin/feeds/videoFeedIcon.png",
_appPrefLabel: "videoPodcastFeed"
}
var audioFeedHandlerInfo = {
__proto__: new FeedHandlerInfo(TYPE_MAYBE_AUDIO_FEED),
_prefSelectedApp: PREF_AUDIO_FEED_SELECTED_APP,
_prefSelectedWeb: PREF_AUDIO_FEED_SELECTED_WEB,
_prefSelectedAction: PREF_AUDIO_FEED_SELECTED_ACTION,
_prefSelectedReader: PREF_AUDIO_FEED_SELECTED_READER,
_smallIcon: "chrome://browser/skin/feeds/audioFeedIcon16.png",
_largeIcon: "chrome://browser/skin/feeds/audioFeedIcon.png",
_appPrefLabel: "audioPodcastFeed"
}
//****************************************************************************//
// Prefpane Controller
@ -892,6 +943,17 @@ var gApplicationsPane = {
this._prefSvc.addObserver(PREF_FEED_SELECTED_ACTION, this, false);
this._prefSvc.addObserver(PREF_FEED_SELECTED_READER, this, false);
this._prefSvc.addObserver(PREF_VIDEO_FEED_SELECTED_APP, this, false);
this._prefSvc.addObserver(PREF_VIDEO_FEED_SELECTED_WEB, this, false);
this._prefSvc.addObserver(PREF_VIDEO_FEED_SELECTED_ACTION, this, false);
this._prefSvc.addObserver(PREF_VIDEO_FEED_SELECTED_READER, this, false);
this._prefSvc.addObserver(PREF_AUDIO_FEED_SELECTED_APP, this, false);
this._prefSvc.addObserver(PREF_AUDIO_FEED_SELECTED_WEB, this, false);
this._prefSvc.addObserver(PREF_AUDIO_FEED_SELECTED_ACTION, this, false);
this._prefSvc.addObserver(PREF_AUDIO_FEED_SELECTED_READER, this, false);
// Listen for window unload so we can remove our preference observers.
window.addEventListener("unload", this, false);
@ -933,6 +995,16 @@ var gApplicationsPane = {
this._prefSvc.removeObserver(PREF_FEED_SELECTED_WEB, this);
this._prefSvc.removeObserver(PREF_FEED_SELECTED_ACTION, this);
this._prefSvc.removeObserver(PREF_FEED_SELECTED_READER, this);
this._prefSvc.removeObserver(PREF_VIDEO_FEED_SELECTED_APP, this);
this._prefSvc.removeObserver(PREF_VIDEO_FEED_SELECTED_WEB, this);
this._prefSvc.removeObserver(PREF_VIDEO_FEED_SELECTED_ACTION, this);
this._prefSvc.removeObserver(PREF_VIDEO_FEED_SELECTED_READER, this);
this._prefSvc.removeObserver(PREF_AUDIO_FEED_SELECTED_APP, this);
this._prefSvc.removeObserver(PREF_AUDIO_FEED_SELECTED_WEB, this);
this._prefSvc.removeObserver(PREF_AUDIO_FEED_SELECTED_ACTION, this);
this._prefSvc.removeObserver(PREF_AUDIO_FEED_SELECTED_READER, this);
},
@ -993,6 +1065,12 @@ var gApplicationsPane = {
_loadFeedHandler: function() {
this._handledTypes[TYPE_MAYBE_FEED] = feedHandlerInfo;
feedHandlerInfo.handledOnlyByPlugin = false;
this._handledTypes[TYPE_MAYBE_VIDEO_FEED] = videoFeedHandlerInfo;
videoFeedHandlerInfo.handledOnlyByPlugin = false;
this._handledTypes[TYPE_MAYBE_AUDIO_FEED] = audioFeedHandlerInfo;
audioFeedHandlerInfo.handledOnlyByPlugin = false;
},
/**
@ -1175,7 +1253,7 @@ var gApplicationsPane = {
// is set, then describe that behavior instead. For most types, this is
// the "alwaysAsk" string, but for the feed type we show something special.
if (aHandlerInfo.alwaysAskBeforeHandling) {
if (aHandlerInfo.type == TYPE_MAYBE_FEED)
if (isFeedType(aHandlerInfo.type))
return this._prefsBundle.getFormattedString("previewInApp",
[this._brandShortName]);
else
@ -1197,7 +1275,7 @@ var gApplicationsPane = {
case Ci.nsIHandlerInfo.handleInternally:
// For the feed type, handleInternally means live bookmarks.
if (aHandlerInfo.type == TYPE_MAYBE_FEED)
if (isFeedType(aHandlerInfo.type))
return this._prefsBundle.getFormattedString("addLiveBookmarksInApp",
[this._brandShortName]);
@ -1304,7 +1382,7 @@ var gApplicationsPane = {
var askMenuItem = document.createElement("menuitem");
askMenuItem.setAttribute("alwaysAsk", "true");
let label;
if (handlerInfo.type == TYPE_MAYBE_FEED)
if (isFeedType(handlerInfo.type))
label = this._prefsBundle.getFormattedString("previewInApp",
[this._brandShortName]);
else
@ -1320,7 +1398,7 @@ var gApplicationsPane = {
// what it means to save a URL having a certain scheme to disk, nor is it
// available to feeds, since the feed code doesn't implement the capability.
if ((handlerInfo.wrappedHandlerInfo instanceof Ci.nsIMIMEInfo) &&
handlerInfo.type != TYPE_MAYBE_FEED) {
!isFeedType(handlerInfo.type)) {
var saveMenuItem = document.createElement("menuitem");
saveMenuItem.setAttribute("action", Ci.nsIHandlerInfo.saveToDisk);
let label = this._prefsBundle.getString("saveFile");
@ -1331,7 +1409,7 @@ var gApplicationsPane = {
}
// If this is the feed type, add a Live Bookmarks item.
if (handlerInfo.type == TYPE_MAYBE_FEED) {
if (isFeedType(handlerInfo.type)) {
var internalMenuItem = document.createElement("menuitem");
internalMenuItem.setAttribute("action", Ci.nsIHandlerInfo.handleInternally);
let label = this._prefsBundle.getFormattedString("addLiveBookmarksInApp",
@ -1653,7 +1731,7 @@ var gApplicationsPane = {
var params = {};
var handlerInfo = this._handledTypes[this._list.selectedItem.type];
if (handlerInfo.type == TYPE_MAYBE_FEED) {
if (isFeedType(handlerInfo.type)) {
// MIME info will be null, create a temp object.
params.mimeInfo = this._mimeSvc.getFromTypeAndExtension(handlerInfo.type,
handlerInfo.primaryExtension);
@ -1746,7 +1824,7 @@ var gApplicationsPane = {
return true;
case Ci.nsIHandlerInfo.handleInternally:
if (aHandlerInfo.type == TYPE_MAYBE_FEED) {
if (isFeedType(aHandlerInfo.type)) {
aElement.setAttribute(APP_ICON_ATTR_NAME, "feed");
return true;
}

View File

@ -69,6 +69,33 @@
<preference id="browser.feeds.handlers.webservice"
name="browser.feeds.handlers.webservice"
type="string"/>
<preference id="browser.videoFeeds.handler"
name="browser.videoFeeds.handler"
type="string"/>
<preference id="browser.videoFeeds.handler.default"
name="browser.videoFeeds.handler.default"
type="string"/>
<preference id="browser.videoFeeds.handlers.application"
name="browser.videoFeeds.handlers.application"
type="file"/>
<preference id="browser.videoFeeds.handlers.webservice"
name="browser.videoFeeds.handlers.webservice"
type="string"/>
<preference id="browser.audioFeeds.handler"
name="browser.audioFeeds.handler"
type="string"/>
<preference id="browser.audioFeeds.handler.default"
name="browser.audioFeeds.handler.default"
type="string"/>
<preference id="browser.audioFeeds.handlers.application"
name="browser.audioFeeds.handlers.application"
type="file"/>
<preference id="browser.audioFeeds.handlers.webservice"
name="browser.audioFeeds.handlers.webservice"
type="string"/>
<preference id="pref.downloads.disable_button.edit_actions"
name="pref.downloads.disable_button.edit_actions"
type="bool"/>