2006-05-16 03:02:28 +00:00
|
|
|
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2000-11-08 21:00:37 +00:00
|
|
|
*
|
2012-05-21 11:12:37 +00:00
|
|
|
* 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/. */
|
2000-11-08 21:00:37 +00:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
|
|
|
interface nsIURI;
|
2013-05-01 11:04:21 +00:00
|
|
|
interface nsIInputStream;
|
2022-07-19 03:27:18 +00:00
|
|
|
interface nsIDNSListener;
|
2020-05-13 14:54:47 +00:00
|
|
|
webidl BrowsingContext;
|
2000-11-08 21:00:37 +00:00
|
|
|
|
2014-04-24 22:42:00 +00:00
|
|
|
/**
|
|
|
|
* Interface indicating what we found/corrected when fixing up a URI
|
|
|
|
*/
|
2014-09-11 13:50:55 +00:00
|
|
|
[scriptable, uuid(4819f183-b532-4932-ac09-b309cd853be7)]
|
2014-04-24 22:42:00 +00:00
|
|
|
interface nsIURIFixupInfo : nsISupports
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Consumer that asked for fixed up URI.
|
|
|
|
*/
|
2020-05-13 14:54:47 +00:00
|
|
|
attribute BrowsingContext consumer;
|
2014-04-24 22:42:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Our best guess as to what URI the consumer will want. Might
|
|
|
|
* be null if we couldn't salvage anything (for instance, because
|
|
|
|
* the input was invalid as a URI and FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP
|
|
|
|
* was not passed)
|
|
|
|
*/
|
2020-04-08 11:30:14 +00:00
|
|
|
attribute nsIURI preferredURI;
|
2014-04-24 22:42:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The fixed-up original input, *never* using a keyword search.
|
|
|
|
* (might be null if the original input was not recoverable as
|
|
|
|
* a URL, e.g. "foo bar"!)
|
|
|
|
*/
|
2020-04-08 11:30:14 +00:00
|
|
|
attribute nsIURI fixedURI;
|
2014-04-24 22:42:00 +00:00
|
|
|
|
|
|
|
/**
|
2014-09-11 13:50:55 +00:00
|
|
|
* The name of the keyword search provider used to provide a keyword search;
|
|
|
|
* empty string if no keyword search was done.
|
2014-04-24 22:42:00 +00:00
|
|
|
*/
|
2020-04-08 11:30:14 +00:00
|
|
|
attribute AString keywordProviderName;
|
2014-09-11 13:50:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The keyword as used for the search (post trimming etc.)
|
|
|
|
* empty string if no keyword search was done.
|
|
|
|
*/
|
2020-04-08 11:30:14 +00:00
|
|
|
attribute AString keywordAsSent;
|
2014-04-24 22:42:00 +00:00
|
|
|
|
|
|
|
/**
|
2014-07-25 10:46:07 +00:00
|
|
|
* Whether we changed the protocol instead of using one from the input as-is.
|
2014-04-24 22:42:00 +00:00
|
|
|
*/
|
2020-04-08 11:30:14 +00:00
|
|
|
attribute boolean fixupChangedProtocol;
|
2014-04-24 22:42:00 +00:00
|
|
|
|
|
|
|
/**
|
2014-07-25 10:46:07 +00:00
|
|
|
* Whether we created an alternative URI. We might have added a prefix and/or
|
|
|
|
* suffix, the contents of which are controlled by the
|
|
|
|
* browser.fixup.alternate.prefix and .suffix prefs, with the defaults being
|
|
|
|
* "www." and ".com", respectively.
|
2014-04-24 22:42:00 +00:00
|
|
|
*/
|
2020-04-08 11:30:14 +00:00
|
|
|
attribute boolean fixupCreatedAlternateURI;
|
2014-04-24 22:42:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The original input
|
|
|
|
*/
|
2020-04-08 11:30:14 +00:00
|
|
|
attribute AUTF8String originalInput;
|
2020-10-13 10:20:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The POST data to submit with the returned URI (see nsISearchSubmission).
|
|
|
|
*/
|
|
|
|
attribute nsIInputStream postData;
|
2014-04-24 22:42:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-11-08 21:00:37 +00:00
|
|
|
/**
|
|
|
|
* Interface implemented by objects capable of fixing up strings into URIs
|
|
|
|
*/
|
2015-05-28 07:21:58 +00:00
|
|
|
[scriptable, uuid(1da7e9d4-620b-4949-849a-1cd6077b1b2d)]
|
2000-11-08 21:00:37 +00:00
|
|
|
interface nsIURIFixup : nsISupports
|
|
|
|
{
|
2001-11-06 22:55:30 +00:00
|
|
|
/** No fixup flags. */
|
|
|
|
const unsigned long FIXUP_FLAG_NONE = 0;
|
2000-11-08 21:00:37 +00:00
|
|
|
|
2001-11-06 22:55:30 +00:00
|
|
|
/**
|
|
|
|
* Allow the fixup to use a keyword lookup service to complete the URI.
|
|
|
|
* The fixup object implementer should honour this flag and only perform
|
|
|
|
* any lengthy keyword (or search) operation if it is set.
|
|
|
|
*/
|
|
|
|
const unsigned long FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP = 1;
|
2000-11-08 21:00:37 +00:00
|
|
|
|
2001-12-19 15:58:58 +00:00
|
|
|
/**
|
|
|
|
* Tell the fixup to make an alternate URI from the input URI, for example
|
|
|
|
* to turn foo into www.foo.com.
|
|
|
|
*/
|
|
|
|
const unsigned long FIXUP_FLAGS_MAKE_ALTERNATE_URI = 2;
|
|
|
|
|
2019-10-12 12:37:51 +00:00
|
|
|
/*
|
|
|
|
* Set when the fixup happens in a private context, the used search engine
|
|
|
|
* may differ in this case. Not all consumers care about this, because they
|
|
|
|
* may not want the url to be transformed in a search.
|
|
|
|
*/
|
|
|
|
const unsigned long FIXUP_FLAG_PRIVATE_CONTEXT = 4;
|
|
|
|
|
2014-08-29 03:25:02 +00:00
|
|
|
/*
|
2013-11-17 20:16:45 +00:00
|
|
|
* Fix common scheme typos.
|
|
|
|
*/
|
|
|
|
const unsigned long FIXUP_FLAG_FIX_SCHEME_TYPOS = 8;
|
|
|
|
|
2022-07-15 19:08:56 +00:00
|
|
|
/*
|
|
|
|
* Force the fixup to make an alternate URI from the input URI regardless
|
|
|
|
* of the browser.fixup.alternate.enabled preference.
|
|
|
|
*/
|
|
|
|
const unsigned long FIXUP_FLAG_FORCE_ALTERNATE_URI = 16;
|
|
|
|
|
2001-11-06 22:55:30 +00:00
|
|
|
/**
|
2020-10-13 10:20:16 +00:00
|
|
|
* Tries to converts the specified string into a URI, first attempting
|
|
|
|
* to correct any errors in the syntax or other vagaries.
|
|
|
|
* It returns information about what it corrected
|
2014-04-24 22:42:00 +00:00
|
|
|
* (e.g. whether we could rescue the URI or "just" generated a keyword
|
|
|
|
* search URI instead).
|
|
|
|
*
|
|
|
|
* @param aURIText Candidate URI.
|
|
|
|
* @param aFixupFlags Flags that govern ways the URI may be fixed up.
|
2020-10-13 10:20:16 +00:00
|
|
|
* Defaults to FIXUP_FLAG_NONE.
|
2014-04-24 22:42:00 +00:00
|
|
|
*/
|
|
|
|
nsIURIFixupInfo getFixupURIInfo(in AUTF8String aURIText,
|
2020-10-13 10:20:16 +00:00
|
|
|
[optional] in unsigned long aFixupFlags);
|
2014-04-24 22:42:00 +00:00
|
|
|
|
2019-06-04 16:19:27 +00:00
|
|
|
/**
|
|
|
|
* Convert load flags from nsIWebNavigation to URI fixup flags for use in
|
2020-11-12 18:00:55 +00:00
|
|
|
* getFixupURIInfo.
|
2019-06-04 16:19:27 +00:00
|
|
|
*
|
|
|
|
* @param aURIText Candidate URI; used for determining whether to
|
|
|
|
* allow keyword lookups.
|
|
|
|
* @param aDocShellFlags Load flags from nsIDocShell to convert.
|
|
|
|
*/
|
|
|
|
unsigned long webNavigationFlagsToFixupFlags(
|
|
|
|
in AUTF8String aURIText, in unsigned long aDocShellFlags);
|
|
|
|
|
2006-05-16 03:02:28 +00:00
|
|
|
/**
|
|
|
|
* Converts the specified keyword string into a URI. Note that it's the
|
|
|
|
* caller's responsibility to check whether keywords are enabled and
|
|
|
|
* whether aKeyword is a sensible keyword.
|
2013-05-01 11:04:21 +00:00
|
|
|
*
|
|
|
|
* @param aKeyword The keyword string to convert into a URI
|
2019-10-12 12:37:51 +00:00
|
|
|
* @param aIsPrivateContext Whether this is invoked from a private context.
|
2006-05-16 03:02:28 +00:00
|
|
|
*/
|
2014-09-11 13:50:55 +00:00
|
|
|
nsIURIFixupInfo keywordToURI(in AUTF8String aKeyword,
|
2020-10-13 10:20:16 +00:00
|
|
|
[optional] in boolean aIsPrivateContext);
|
2015-05-28 07:21:58 +00:00
|
|
|
|
2022-07-19 03:27:18 +00:00
|
|
|
/**
|
|
|
|
* Given a uri-like string with a protocol, attempt to fix and convert it
|
|
|
|
* into an instance of nsIURIFixupInfo.
|
|
|
|
*
|
|
|
|
* Differently from getFixupURIInfo, this assumes the input string is an
|
|
|
|
* http/https uri, and can add a prefix and/or suffix to its hostname.
|
|
|
|
*
|
|
|
|
* The scheme will be changed to the scheme defined in
|
|
|
|
* "browser.fixup.alternate.protocol", which is by default, https.
|
|
|
|
*
|
|
|
|
* If the prefix and suffix of the host are missing, it will add them to
|
|
|
|
* the host using the preferences "browser.fixup.alternate.prefix" and
|
|
|
|
* "browser.fixup.alternate.suffix" as references.
|
|
|
|
*
|
|
|
|
* If a hostname suffix is present, but the URI doesn't contain a prefix,
|
|
|
|
* it will add the prefix via "browser.fixup.alternate.prefix"
|
|
|
|
*
|
|
|
|
* @param aUriString The URI to fixup and convert.
|
|
|
|
* @returns nsIURIFixupInfo
|
|
|
|
* A nsIURIFixupInfo object with the property fixedURI
|
|
|
|
* which contains the modified URI.
|
|
|
|
* @throws NS_ERROR_FAILURE
|
|
|
|
* If aUriString is undefined, or the scheme is not
|
|
|
|
* http/https.
|
|
|
|
*/
|
|
|
|
nsIURIFixupInfo forceHttpFixup(in AUTF8String aUriString);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* With the host associated with the URI, use nsIDNSService to determine
|
|
|
|
* if an IP address can be found for this host. This method will ignore checking
|
|
|
|
* hosts that are IP addresses. If the host does not contain any periods, depending
|
|
|
|
* on the browser.urlbar.dnsResolveFullyQualifiedNames preference value, a period
|
|
|
|
* may be appended in order to make it a fully qualified domain name.
|
|
|
|
*
|
|
|
|
* @param aURI The URI to parse and pass into the DNS lookup.
|
|
|
|
* @param aListener The listener when the result from the lookup is available.
|
|
|
|
* @param aOriginAttributes The originAttributes to pass the DNS lookup.
|
|
|
|
* @throws NS_ERROR_FAILURE if aURI does not have a displayHost or asciiHost.
|
|
|
|
*/
|
|
|
|
void checkHost(in nsIURI aURI,
|
|
|
|
in nsIDNSListener aListener,
|
|
|
|
[optional] in jsval aOriginAttributes);
|
|
|
|
|
2015-05-28 07:21:58 +00:00
|
|
|
/**
|
2020-06-24 15:59:04 +00:00
|
|
|
* Returns true if the specified domain is known and false otherwise.
|
|
|
|
* A known domain is relevant when we have a single word and can't be
|
2015-05-28 07:21:58 +00:00
|
|
|
* sure whether to treat the word as a host name or should instead be
|
|
|
|
* treated as a search term.
|
|
|
|
*
|
|
|
|
* @param aDomain A domain name to query.
|
|
|
|
*/
|
2020-06-24 15:59:04 +00:00
|
|
|
bool isDomainKnown(in AUTF8String aDomain);
|
2000-11-08 21:00:37 +00:00
|
|
|
};
|