sbAboutRedirector.js
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
27 // This is the mapping from about:<module> to actual URI loaded. Just changing
28 // this part should be enough to register new things.
29 const PAGES = {
30  "keyboard-help": "chrome://songbird/content/html/keyboardHelp.xhtml"
31 };
32 
33 const Cc = Components.classes;
34 const Ci = Components.interfaces;
35 const Cr = Components.results;
36 
37 const DESCRIPTION = "Songbird about: protocol redirector";
38 const CID = "42631c40-1cbe-4f3a-b859-7936e542130f";
39 const CONTRACTID = "@songbirdnest.com/aboutRedirector";
40 
41 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
42 
43 const PROTOCOL_PREFIX = "@mozilla.org/network/protocol/about;1?what=";
44 
45 function doPostRegister(aCompMgr, aFile, aComponents) {
46  // get our own factory, since XPCOMUtils doesn't expose it
47  var factory = aCompMgr.getClassObject(sbAboutRedirector.prototype.classID,
48  Ci.nsIFactory);
49  for (let key in PAGES) {
50  aCompMgr.registerFactory(sbAboutRedirector.prototype.classID,
51  sbAboutRedirector.prototype.classDescription,
53  factory);
54  }
55 }
56 
57 function sbAboutRedirector() {}
58 sbAboutRedirector.prototype = {
60  classID: Components.ID(CID),
62 
63  newChannel: function(uri) {
64  if (!(uri.path in PAGES)) {
65  throw Components.Exception("URI " + uri.spec + " not supported",
66  Components.results.NS_ERROR_UNEXPECTED);
67  }
68  var ios = Cc["@mozilla.org/network/io-service;1"].
69  getService(Ci.nsIIOService);
70  var childURI = ios.newURI(PAGES[uri.path], null, null);
71  var channel = ios.newChannelFromURI(childURI);
72  channel.originalURI = uri;
73  return channel;
74  },
75 
76  getURIFlags: function(uri) {
77  return Ci.nsIAboutModule.ALLOW_SCRIPT
78  },
79 
80  QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule])
81 };
82 
83 function NSGetModule(compMgr, fileSpec) {
84  return XPCOMUtils.generateModule([sbAboutRedirector],
86 }
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
const Ci
const PROTOCOL_PREFIX
sbOSDControlService prototype QueryInterface
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
const PAGES
const Cc
getService(Ci.sbIFaceplateManager)
function NSGetModule(compMgr, fileSpec)
const DESCRIPTION
function doPostRegister(aCompMgr, aFile, aComponents)
function sbAboutRedirector()
return null
Definition: FeedWriter.js:1143
const Cr
var uri
Definition: FeedWriter.js:1135
sbDeviceFirmwareAutoCheckForUpdate prototype classID
const CONTRACTID
var ios
Definition: head_feeds.js:5
const CID