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.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsISupports.idl" |
michael@0 | 7 | |
michael@0 | 8 | /* nsINativeAppSupport |
michael@0 | 9 | * |
michael@0 | 10 | * This "pseudo" (in the XPCOM sense) interface provides for |
michael@0 | 11 | * platform-specific general application support: |
michael@0 | 12 | * o It manages the details of the simple DDE communication |
michael@0 | 13 | * supported on the Win32 platform (it is the addition of this |
michael@0 | 14 | * item that prompted the creation of this interface. |
michael@0 | 15 | * |
michael@0 | 16 | * Due to the nature of the beast, this interface is not a full-blown |
michael@0 | 17 | * XPCOM component. The primary reason is that objects that implement |
michael@0 | 18 | * this interface generally must be operational *before* XPCOM (or any |
michael@0 | 19 | * of the rest of Mozilla) are initialized. As a result, this |
michael@0 | 20 | * interface is instantiated by somewhat unconventional means. |
michael@0 | 21 | * |
michael@0 | 22 | * To create the implementor of this interface, you call the function |
michael@0 | 23 | * NS_CreateNativeAppSupport. This is done in the startup code |
michael@0 | 24 | * in nsAppRunner.cpp |
michael@0 | 25 | * |
michael@0 | 26 | * The interface provides these functions: |
michael@0 | 27 | * start - You call this to inform the native app support that the |
michael@0 | 28 | * application is starting. In addition, it serves as a |
michael@0 | 29 | * query as to whether the application should continue to |
michael@0 | 30 | * run. |
michael@0 | 31 | * |
michael@0 | 32 | * If the returned boolean result is PR_FALSE, then the |
michael@0 | 33 | * application should exit without further processing. In |
michael@0 | 34 | * such cases, the returned nsresult indicates whether the |
michael@0 | 35 | * reason to exit is due to an error or not. |
michael@0 | 36 | * |
michael@0 | 37 | * Win32 Note: In the case of starting a second instance |
michael@0 | 38 | * of this executable, this function will return |
michael@0 | 39 | * PR_FALSE and nsresult==NS_OK. This means that |
michael@0 | 40 | * the command line arguments have been |
michael@0 | 41 | * successfully passed to the instance of the |
michael@0 | 42 | * application acting as a DDE server. |
michael@0 | 43 | * |
michael@0 | 44 | * stop - You call this to inform the native app support that the |
michael@0 | 45 | * application *wishes* to terminate. If the returned boolean |
michael@0 | 46 | * value is PR_FALSE, then the application should continue |
michael@0 | 47 | * (as if there were still additional top-level windows open). |
michael@0 | 48 | * |
michael@0 | 49 | * Win32 Note: If this is the instance of the application |
michael@0 | 50 | * acting as the DDE server, and there are current |
michael@0 | 51 | * DDE conversations active with other instances |
michael@0 | 52 | * acting as DDE clients, then this function will |
michael@0 | 53 | * return PR_FALSE. |
michael@0 | 54 | * |
michael@0 | 55 | * quit - Like Stop, but this method *forces* termination (or more |
michael@0 | 56 | * precisely, indicates that the application is about to be |
michael@0 | 57 | * terminated regardless of what a call to Stop might have |
michael@0 | 58 | * returned. |
michael@0 | 59 | * |
michael@0 | 60 | * This method is intended to be called when the user selects |
michael@0 | 61 | * the "Quit" option (close all windows and exit). |
michael@0 | 62 | * |
michael@0 | 63 | * Win32 Note: Stop is problematic in the case of "Quit" (close |
michael@0 | 64 | * all windows and exit the application) because |
michael@0 | 65 | * either we don't Quit or (potentially) we lose |
michael@0 | 66 | * requests coming from other instances of the |
michael@0 | 67 | * application. The strategy is to give preference |
michael@0 | 68 | * to the user's explicit Quit request. In the |
michael@0 | 69 | * unlikely event that a request is pending from |
michael@0 | 70 | * another instance of the application, then such |
michael@0 | 71 | * requests are essentially ignored. This is |
michael@0 | 72 | * roughly equivalent to handling that request by |
michael@0 | 73 | * opening a new window, followed by immediately |
michael@0 | 74 | * closing it. Since this is the same as if the |
michael@0 | 75 | * request came in immediately before the Quit |
michael@0 | 76 | * call (versus immediately after it), no harm. |
michael@0 | 77 | * |
michael@0 | 78 | * There is an exposure here: Upon return from this |
michael@0 | 79 | * function, any DDE connect request (for Mozilla) |
michael@0 | 80 | * will fail and other instances of the application |
michael@0 | 81 | * will start up as a DDE server. In that case, |
michael@0 | 82 | * those instances may do things that conflict with |
michael@0 | 83 | * the subsequent shutting down of the instance that |
michael@0 | 84 | * is quitting. For this reason, the call to Quit |
michael@0 | 85 | * should be deferred as long as possible. |
michael@0 | 86 | * |
michael@0 | 87 | * onLastWindowClosing - Called when the last window is closed. Used as a |
michael@0 | 88 | * "soft" shutdown, passwords are flushed. |
michael@0 | 89 | */ |
michael@0 | 90 | |
michael@0 | 91 | interface nsIXULWindow; |
michael@0 | 92 | interface nsICmdLineService; |
michael@0 | 93 | |
michael@0 | 94 | [scriptable, uuid(5fdf8480-1f98-11d4-8077-00600811a9c3)] |
michael@0 | 95 | interface nsINativeAppSupport : nsISupports { |
michael@0 | 96 | // Startup/shutdown. |
michael@0 | 97 | boolean start(); |
michael@0 | 98 | void enable(); |
michael@0 | 99 | boolean stop(); |
michael@0 | 100 | void quit(); |
michael@0 | 101 | |
michael@0 | 102 | void onLastWindowClosing(); |
michael@0 | 103 | void ReOpen(); |
michael@0 | 104 | }; |