Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef mozilla_plugins_PluginHangUIChild_h |
michael@0 | 8 | #define mozilla_plugins_PluginHangUIChild_h |
michael@0 | 9 | |
michael@0 | 10 | #include "MiniShmChild.h" |
michael@0 | 11 | |
michael@0 | 12 | #include <string> |
michael@0 | 13 | |
michael@0 | 14 | #include <windows.h> |
michael@0 | 15 | |
michael@0 | 16 | namespace mozilla { |
michael@0 | 17 | namespace plugins { |
michael@0 | 18 | |
michael@0 | 19 | /** |
michael@0 | 20 | * This class implements the plugin-hang-ui. |
michael@0 | 21 | * |
michael@0 | 22 | * NOTE: PluginHangUIChild is *not* an IPDL actor! In this case, "Child" |
michael@0 | 23 | * is describing the fact that plugin-hang-ui is a child process to the |
michael@0 | 24 | * firefox process, which is the PluginHangUIParent. |
michael@0 | 25 | * PluginHangUIParent and PluginHangUIChild are a matched pair. |
michael@0 | 26 | * @see PluginHangUIParent |
michael@0 | 27 | */ |
michael@0 | 28 | class PluginHangUIChild : public MiniShmObserver |
michael@0 | 29 | { |
michael@0 | 30 | public: |
michael@0 | 31 | PluginHangUIChild(); |
michael@0 | 32 | virtual ~PluginHangUIChild(); |
michael@0 | 33 | |
michael@0 | 34 | bool |
michael@0 | 35 | Init(int aArgc, wchar_t* aArgv[]); |
michael@0 | 36 | |
michael@0 | 37 | /** |
michael@0 | 38 | * Displays the Plugin Hang UI and does not return until the UI has |
michael@0 | 39 | * been dismissed. |
michael@0 | 40 | * |
michael@0 | 41 | * @return true if the UI was displayed and the user response was |
michael@0 | 42 | * successfully sent back to the parent. Otherwise false. |
michael@0 | 43 | */ |
michael@0 | 44 | bool |
michael@0 | 45 | Show(); |
michael@0 | 46 | |
michael@0 | 47 | /** |
michael@0 | 48 | * Causes the calling thread to wait either for the Hang UI to be |
michael@0 | 49 | * dismissed or for the parent process to terminate. This should |
michael@0 | 50 | * be called by the main thread. |
michael@0 | 51 | * |
michael@0 | 52 | * @return true unless there was an error initiating the wait |
michael@0 | 53 | */ |
michael@0 | 54 | bool |
michael@0 | 55 | WaitForDismissal(); |
michael@0 | 56 | |
michael@0 | 57 | virtual void |
michael@0 | 58 | OnMiniShmEvent(MiniShmBase* aMiniShmObj) MOZ_OVERRIDE; |
michael@0 | 59 | |
michael@0 | 60 | private: |
michael@0 | 61 | bool |
michael@0 | 62 | RecvShow(); |
michael@0 | 63 | |
michael@0 | 64 | bool |
michael@0 | 65 | RecvCancel(); |
michael@0 | 66 | |
michael@0 | 67 | bool |
michael@0 | 68 | SetMainThread(); |
michael@0 | 69 | |
michael@0 | 70 | void |
michael@0 | 71 | ResizeButtons(); |
michael@0 | 72 | |
michael@0 | 73 | INT_PTR |
michael@0 | 74 | HangUIDlgProc(HWND aDlgHandle, UINT aMsgCode, WPARAM aWParam, LPARAM aLParam); |
michael@0 | 75 | |
michael@0 | 76 | static VOID CALLBACK |
michael@0 | 77 | ShowAPC(ULONG_PTR aContext); |
michael@0 | 78 | |
michael@0 | 79 | static INT_PTR CALLBACK |
michael@0 | 80 | SHangUIDlgProc(HWND aDlgHandle, UINT aMsgCode, WPARAM aWParam, |
michael@0 | 81 | LPARAM aLParam); |
michael@0 | 82 | |
michael@0 | 83 | static VOID CALLBACK |
michael@0 | 84 | SOnParentProcessExit(PVOID aObject, BOOLEAN aIsTimer); |
michael@0 | 85 | |
michael@0 | 86 | static PluginHangUIChild *sSelf; |
michael@0 | 87 | |
michael@0 | 88 | const wchar_t* mMessageText; |
michael@0 | 89 | const wchar_t* mWindowTitle; |
michael@0 | 90 | const wchar_t* mWaitBtnText; |
michael@0 | 91 | const wchar_t* mKillBtnText; |
michael@0 | 92 | const wchar_t* mNoFutureText; |
michael@0 | 93 | unsigned int mResponseBits; |
michael@0 | 94 | HWND mParentWindow; |
michael@0 | 95 | HWND mDlgHandle; |
michael@0 | 96 | HANDLE mMainThread; |
michael@0 | 97 | HANDLE mParentProcess; |
michael@0 | 98 | HANDLE mRegWaitProcess; |
michael@0 | 99 | DWORD mIPCTimeoutMs; |
michael@0 | 100 | MiniShmChild mMiniShm; |
michael@0 | 101 | |
michael@0 | 102 | static const int kExpectedMinimumArgc; |
michael@0 | 103 | |
michael@0 | 104 | typedef HRESULT (WINAPI *SETAPPUSERMODELID)(PCWSTR); |
michael@0 | 105 | |
michael@0 | 106 | DISALLOW_COPY_AND_ASSIGN(PluginHangUIChild); |
michael@0 | 107 | }; |
michael@0 | 108 | |
michael@0 | 109 | } // namespace plugins |
michael@0 | 110 | } // namespace mozilla |
michael@0 | 111 | |
michael@0 | 112 | #endif // mozilla_plugins_PluginHangUIChild_h |
michael@0 | 113 |