|
1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * |
|
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 #include "nsISupports.idl" |
|
8 |
|
9 interface nsIURI; |
|
10 interface nsIInputStream; |
|
11 |
|
12 /** |
|
13 * Interface implemented by objects capable of fixing up strings into URIs |
|
14 */ |
|
15 [scriptable, uuid(731877f8-973b-414c-b772-9ca1f3fffb7e)] |
|
16 interface nsIURIFixup : nsISupports |
|
17 { |
|
18 /** No fixup flags. */ |
|
19 const unsigned long FIXUP_FLAG_NONE = 0; |
|
20 |
|
21 /** |
|
22 * Allow the fixup to use a keyword lookup service to complete the URI. |
|
23 * The fixup object implementer should honour this flag and only perform |
|
24 * any lengthy keyword (or search) operation if it is set. |
|
25 */ |
|
26 const unsigned long FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP = 1; |
|
27 |
|
28 /** |
|
29 * Tell the fixup to make an alternate URI from the input URI, for example |
|
30 * to turn foo into www.foo.com. |
|
31 */ |
|
32 const unsigned long FIXUP_FLAGS_MAKE_ALTERNATE_URI = 2; |
|
33 |
|
34 /** |
|
35 * Fix common scheme typos. |
|
36 */ |
|
37 const unsigned long FIXUP_FLAG_FIX_SCHEME_TYPOS = 8; |
|
38 |
|
39 /* Note that flag 4 is available. */ |
|
40 |
|
41 /** |
|
42 * Converts an internal URI (e.g. a wyciwyg URI) into one which we can |
|
43 * expose to the user, for example on the URL bar. |
|
44 * |
|
45 * @param aURI The URI to be converted |
|
46 * @return nsIURI The converted, exposable URI |
|
47 * @throws NS_ERROR_MALFORMED_URI when the exposable portion of aURI is malformed |
|
48 * @throws NS_ERROR_UNKNOWN_PROTOCOL when we can't get a protocol handler service |
|
49 * for the URI scheme. |
|
50 */ |
|
51 nsIURI createExposableURI(in nsIURI aURI); |
|
52 |
|
53 /** |
|
54 * Converts the specified string into a URI, first attempting |
|
55 * to correct any errors in the syntax or other vagaries. Returns |
|
56 * a wellformed URI or nullptr if it can't. |
|
57 * |
|
58 * @param aURIText Candidate URI. |
|
59 * @param aFixupFlags Flags that govern ways the URI may be fixed up. |
|
60 * @param aPostData The POST data to submit with the returned |
|
61 * URI (see nsISearchSubmission). |
|
62 */ |
|
63 nsIURI createFixupURI(in AUTF8String aURIText, in unsigned long aFixupFlags, |
|
64 [optional] out nsIInputStream aPostData); |
|
65 |
|
66 /** |
|
67 * Converts the specified keyword string into a URI. Note that it's the |
|
68 * caller's responsibility to check whether keywords are enabled and |
|
69 * whether aKeyword is a sensible keyword. |
|
70 * |
|
71 * @param aKeyword The keyword string to convert into a URI |
|
72 * @param aPostData The POST data to submit to the returned URI |
|
73 * (see nsISearchSubmission). |
|
74 * |
|
75 * @throws NS_ERROR_FAILURE if the resulting URI requires submission of POST |
|
76 * data and aPostData is null. |
|
77 */ |
|
78 nsIURI keywordToURI(in AUTF8String aKeyword, |
|
79 [optional] out nsIInputStream aPostData); |
|
80 }; |
|
81 |