mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 961529 - Add Feeds module (r=felipe)
This commit is contained in:
parent
51d681596f
commit
a34b6333d3
@ -11,6 +11,8 @@ Cu.import("resource://gre/modules/NotificationDB.jsm");
|
||||
Cu.import("resource:///modules/RecentWindow.jsm");
|
||||
Cu.import("resource://gre/modules/WindowsPrefSync.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Feeds",
|
||||
"resource:///modules/Feeds.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Task",
|
||||
"resource://gre/modules/Task.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "CharsetMenu",
|
||||
@ -2837,7 +2839,7 @@ const DOMLinkHandler = {
|
||||
if (!rels.feed && rels.alternate && rels.stylesheet)
|
||||
break;
|
||||
|
||||
if (isValidFeed(link, link.ownerDocument.nodePrincipal, "feed" in rels)) {
|
||||
if (Feeds.isValidFeed(link, link.ownerDocument.nodePrincipal, "feed" in rels)) {
|
||||
FeedHandler.addFeed(link, link.ownerDocument);
|
||||
feedAdded = true;
|
||||
}
|
||||
|
@ -3,6 +3,9 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Feeds",
|
||||
"resource:///modules/Feeds.jsm");
|
||||
|
||||
function initFeedTab()
|
||||
{
|
||||
const feedTypes = {
|
||||
@ -29,7 +32,7 @@ function initFeedTab()
|
||||
}
|
||||
|
||||
if (rels.feed || (link.type && rels.alternate && !rels.stylesheet)) {
|
||||
var type = isValidFeed(link, gDocument.nodePrincipal, "feed" in rels);
|
||||
var type = Feeds.isValidFeed(link, gDocument.nodePrincipal, "feed" in rels);
|
||||
if (type) {
|
||||
type = feedTypes[type] || feedTypes["application/rss+xml"];
|
||||
addRow(link.title, type, link.href);
|
||||
|
@ -1,3 +1,6 @@
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Feeds",
|
||||
"resource:///modules/Feeds.jsm");
|
||||
|
||||
function test() {
|
||||
var exampleUri = makeURI("http://example.com/");
|
||||
var secman = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
|
||||
@ -5,7 +8,7 @@ function test() {
|
||||
|
||||
function testIsFeed(aTitle, aHref, aType, aKnown) {
|
||||
var link = { title: aTitle, href: aHref, type: aType };
|
||||
return isValidFeed(link, principal, aKnown);
|
||||
return Feeds.isValidFeed(link, principal, aKnown);
|
||||
}
|
||||
|
||||
var href = "http://example.com/feed/";
|
||||
|
@ -649,41 +649,6 @@ function openNewWindowWith(aURL, aDocument, aPostData, aAllowThirdPartyFixup, aR
|
||||
referrerURI: aDocument ? aDocument.documentURIObject : aReferrer });
|
||||
}
|
||||
|
||||
/**
|
||||
* isValidFeed: checks whether the given data represents a valid feed.
|
||||
*
|
||||
* @param aLink
|
||||
* An object representing a feed with title, href and type.
|
||||
* @param aPrincipal
|
||||
* The principal of the document, used for security check.
|
||||
* @param aIsFeed
|
||||
* Whether this is already a known feed or not, if true only a security
|
||||
* check will be performed.
|
||||
*/
|
||||
function isValidFeed(aLink, aPrincipal, aIsFeed)
|
||||
{
|
||||
if (!aLink || !aPrincipal)
|
||||
return false;
|
||||
|
||||
var type = aLink.type.toLowerCase().replace(/^\s+|\s*(?:;.*)?$/g, "");
|
||||
if (!aIsFeed) {
|
||||
aIsFeed = (type == "application/rss+xml" ||
|
||||
type == "application/atom+xml");
|
||||
}
|
||||
|
||||
if (aIsFeed) {
|
||||
try {
|
||||
urlSecurityCheck(aLink.href, aPrincipal,
|
||||
Components.interfaces.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
|
||||
return type || "application/rss+xml";
|
||||
}
|
||||
catch(ex) {
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// aCalledFromModal is optional
|
||||
function openHelpLink(aHelpTopic, aCalledFromModal, aWhere) {
|
||||
var url = Components.classes["@mozilla.org/toolkit/URLFormatterService;1"]
|
||||
|
52
browser/modules/Feeds.jsm
Normal file
52
browser/modules/Feeds.jsm
Normal file
@ -0,0 +1,52 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
this.EXPORTED_SYMBOLS = [ "Feeds" ];
|
||||
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "BrowserUtils",
|
||||
"resource://gre/modules/BrowserUtils.jsm");
|
||||
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
this.Feeds = {
|
||||
|
||||
/**
|
||||
* isValidFeed: checks whether the given data represents a valid feed.
|
||||
*
|
||||
* @param aLink
|
||||
* An object representing a feed with title, href and type.
|
||||
* @param aPrincipal
|
||||
* The principal of the document, used for security check.
|
||||
* @param aIsFeed
|
||||
* Whether this is already a known feed or not, if true only a security
|
||||
* check will be performed.
|
||||
*/
|
||||
isValidFeed: function(aLink, aPrincipal, aIsFeed) {
|
||||
if (!aLink || !aPrincipal)
|
||||
return false;
|
||||
|
||||
var type = aLink.type.toLowerCase().replace(/^\s+|\s*(?:;.*)?$/g, "");
|
||||
if (!aIsFeed) {
|
||||
aIsFeed = (type == "application/rss+xml" ||
|
||||
type == "application/atom+xml");
|
||||
}
|
||||
|
||||
if (aIsFeed) {
|
||||
try {
|
||||
BrowserUtils.urlSecurityCheck(aLink.href, aPrincipal,
|
||||
Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
|
||||
return type || "application/rss+xml";
|
||||
}
|
||||
catch(ex) {
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
};
|
@ -10,6 +10,7 @@ EXTRA_JS_MODULES += [
|
||||
'BrowserNewTabPreloader.jsm',
|
||||
'BrowserUITelemetry.jsm',
|
||||
'ContentClick.jsm',
|
||||
'Feeds.jsm',
|
||||
'NetworkPrioritizer.jsm',
|
||||
'offlineAppCache.jsm',
|
||||
'SharedFrame.jsm',
|
||||
|
Loading…
Reference in New Issue
Block a user