Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "nsISupports.idl"
7 interface nsIFile;
8 interface nsIURI;
9 interface nsIDOMWindow;
11 /**
12 * Represents the command line used to invoke a XUL application. This may be the
13 * original command-line of this instance, or a command line remoted from another
14 * instance of the application.
15 *
16 * DEFINITIONS:
17 * "arguments" are any values found on the command line.
18 * "flags" are switches. In normalized form they are preceded by a single dash.
19 * Some flags may take "parameters", e.g. "-url <param>" or "-install-xpi <param>"
20 */
22 [scriptable, uuid(bc3173bd-aa46-46a0-9d25-d9867a9659b6)]
23 interface nsICommandLine : nsISupports
24 {
25 /**
26 * Number of arguments in the command line. The application name is not
27 * part of the command line.
28 */
29 readonly attribute long length;
31 /**
32 * Get an argument from the array of command-line arguments.
33 *
34 * On windows, flags of the form /flag are normalized to -flag. /flag:param
35 * are normalized to -flag param.
36 *
37 * On *nix and mac flags of the form --flag are normalized to -flag. --flag=param
38 * are normalized to the form -flag param.
39 *
40 * @param aIndex The argument to retrieve. This index is 0-based, and does
41 * not include the application name.
42 * @return The indexth argument.
43 * @throws NS_ERROR_INVALID_ARG if aIndex is out of bounds.
44 */
45 AString getArgument(in long aIndex);
47 /**
48 * Find a command-line flag.
49 *
50 * @param aFlag The flag name to locate. Do not include the initial
51 * hyphen.
52 * @param aCaseSensitive Whether to do case-sensitive comparisons.
53 * @return The position of the flag in the command line.
54 */
55 long findFlag(in AString aFlag, in boolean aCaseSensitive);
57 /**
58 * Remove arguments from the command line. This normally occurs after
59 * a handler has processed the arguments.
60 *
61 * @param aStart Index to begin removing.
62 * @param aEnd Index to end removing, inclusive.
63 */
64 void removeArguments(in long aStart, in long aEnd);
66 /**
67 * A helper method which will find a flag and remove it in one step.
68 *
69 * @param aFlag The flag name to find and remove.
70 * @param aCaseSensitive Whether to do case-sensitive comparisons.
71 * @return Whether the flag was found.
72 */
73 boolean handleFlag(in AString aFlag, in boolean aCaseSensitive);
75 /**
76 * Find a flag with a parameter and remove both. This is a helper
77 * method that combines "findFlag" and "removeArguments" in one step.
78 *
79 * @return null (a void astring) if the flag is not found. The parameter value
80 * if found. Note that null and the empty string are not the same.
81 * @throws NS_ERROR_INVALID_ARG if the flag exists without a parameter
82 *
83 * @param aFlag The flag name to find and remove.
84 * @param aCaseSensitive Whether to do case-sensitive flag search.
85 */
86 AString handleFlagWithParam(in AString aFlag, in boolean aCaseSensitive);
88 /**
89 * The type of command line being processed.
90 *
91 * STATE_INITIAL_LAUNCH is the first launch of the application instance.
92 * STATE_REMOTE_AUTO is a remote command line automatically redirected to
93 * this instance.
94 * STATE_REMOTE_EXPLICIT is a remote command line explicitly redirected to
95 * this instance using xremote/windde/appleevents.
96 */
97 readonly attribute unsigned long state;
99 const unsigned long STATE_INITIAL_LAUNCH = 0;
100 const unsigned long STATE_REMOTE_AUTO = 1;
101 const unsigned long STATE_REMOTE_EXPLICIT = 2;
103 /**
104 * There may be a command-line handler which performs a default action if
105 * there was no explicit action on the command line (open a default browser
106 * window, for example). This flag allows the default action to be prevented.
107 */
108 attribute boolean preventDefault;
110 /**
111 * The working directory for this command line. Use this property instead
112 * of the working directory for the current process, since a redirected
113 * command line may have had a different working directory.
114 */
115 readonly attribute nsIFile workingDirectory;
117 /**
118 * A window to be targeted by this command line. In most cases, this will
119 * be null (xremote will sometimes set this attribute).
120 */
121 readonly attribute nsIDOMWindow windowContext;
123 /**
124 * Resolve a file-path argument into an nsIFile. This method gracefully
125 * handles relative or absolute file paths, according to the working
126 * directory of this command line.
127 *
128 * @param aArgument The command-line argument to resolve.
129 */
130 nsIFile resolveFile(in AString aArgument);
132 /**
133 * Resolves a URI argument into a URI. This method has platform-specific
134 * logic for converting an absolute URI or a relative file-path into the
135 * appropriate URI object; it gracefully handles win32 C:\ paths which would
136 * confuse the ioservice if passed directly.
137 *
138 * @param aArgument The command-line argument to resolve.
139 */
140 nsIURI resolveURI(in AString aArgument);
141 };