|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
2 * vim: sw=2 ts=2 sts=2 et |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 const Cc = Components.classes; |
|
8 const Ci = Components.interfaces; |
|
9 |
|
10 Components.utils.import("resource://gre/modules/NetUtil.jsm"); |
|
11 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); |
|
12 |
|
13 const SCHEME = "place"; |
|
14 const URL = "chrome://browser/content/places/content-ui/controller.xhtml"; |
|
15 |
|
16 function PlacesProtocolHandler() {} |
|
17 |
|
18 PlacesProtocolHandler.prototype = { |
|
19 scheme: SCHEME, |
|
20 defaultPort: -1, |
|
21 protocolFlags: Ci.nsIProtocolHandler.URI_DANGEROUS_TO_LOAD | |
|
22 Ci.nsIProtocolHandler.URI_IS_LOCAL_RESOURCE | |
|
23 Ci.nsIProtocolHandler.URI_NORELATIVE | |
|
24 Ci.nsIProtocolHandler.URI_NOAUTH, |
|
25 |
|
26 newURI: function PPH_newURI(aSpec, aOriginCharset, aBaseUri) { |
|
27 let uri = Cc["@mozilla.org/network/simple-uri;1"].createInstance(Ci.nsIURI); |
|
28 uri.spec = aSpec; |
|
29 return uri; |
|
30 }, |
|
31 |
|
32 newChannel: function PPH_newChannel(aUri) { |
|
33 let chan = NetUtil.newChannel(URL); |
|
34 chan.originalURI = aUri; |
|
35 return chan; |
|
36 }, |
|
37 |
|
38 allowPort: function PPH_allowPort(aPort, aScheme) { |
|
39 return false; |
|
40 }, |
|
41 |
|
42 QueryInterface: XPCOMUtils.generateQI([ |
|
43 Ci.nsIProtocolHandler |
|
44 ]), |
|
45 |
|
46 classID: Components.ID("{6bcb9bde-9018-4443-a071-c32653469597}") |
|
47 }; |
|
48 |
|
49 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([PlacesProtocolHandler]); |