michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_plugins_PluginHangUIChild_h michael@0: #define mozilla_plugins_PluginHangUIChild_h michael@0: michael@0: #include "MiniShmChild.h" michael@0: michael@0: #include michael@0: michael@0: #include michael@0: michael@0: namespace mozilla { michael@0: namespace plugins { michael@0: michael@0: /** michael@0: * This class implements the plugin-hang-ui. michael@0: * michael@0: * NOTE: PluginHangUIChild is *not* an IPDL actor! In this case, "Child" michael@0: * is describing the fact that plugin-hang-ui is a child process to the michael@0: * firefox process, which is the PluginHangUIParent. michael@0: * PluginHangUIParent and PluginHangUIChild are a matched pair. michael@0: * @see PluginHangUIParent michael@0: */ michael@0: class PluginHangUIChild : public MiniShmObserver michael@0: { michael@0: public: michael@0: PluginHangUIChild(); michael@0: virtual ~PluginHangUIChild(); michael@0: michael@0: bool michael@0: Init(int aArgc, wchar_t* aArgv[]); michael@0: michael@0: /** michael@0: * Displays the Plugin Hang UI and does not return until the UI has michael@0: * been dismissed. michael@0: * michael@0: * @return true if the UI was displayed and the user response was michael@0: * successfully sent back to the parent. Otherwise false. michael@0: */ michael@0: bool michael@0: Show(); michael@0: michael@0: /** michael@0: * Causes the calling thread to wait either for the Hang UI to be michael@0: * dismissed or for the parent process to terminate. This should michael@0: * be called by the main thread. michael@0: * michael@0: * @return true unless there was an error initiating the wait michael@0: */ michael@0: bool michael@0: WaitForDismissal(); michael@0: michael@0: virtual void michael@0: OnMiniShmEvent(MiniShmBase* aMiniShmObj) MOZ_OVERRIDE; michael@0: michael@0: private: michael@0: bool michael@0: RecvShow(); michael@0: michael@0: bool michael@0: RecvCancel(); michael@0: michael@0: bool michael@0: SetMainThread(); michael@0: michael@0: void michael@0: ResizeButtons(); michael@0: michael@0: INT_PTR michael@0: HangUIDlgProc(HWND aDlgHandle, UINT aMsgCode, WPARAM aWParam, LPARAM aLParam); michael@0: michael@0: static VOID CALLBACK michael@0: ShowAPC(ULONG_PTR aContext); michael@0: michael@0: static INT_PTR CALLBACK michael@0: SHangUIDlgProc(HWND aDlgHandle, UINT aMsgCode, WPARAM aWParam, michael@0: LPARAM aLParam); michael@0: michael@0: static VOID CALLBACK michael@0: SOnParentProcessExit(PVOID aObject, BOOLEAN aIsTimer); michael@0: michael@0: static PluginHangUIChild *sSelf; michael@0: michael@0: const wchar_t* mMessageText; michael@0: const wchar_t* mWindowTitle; michael@0: const wchar_t* mWaitBtnText; michael@0: const wchar_t* mKillBtnText; michael@0: const wchar_t* mNoFutureText; michael@0: unsigned int mResponseBits; michael@0: HWND mParentWindow; michael@0: HWND mDlgHandle; michael@0: HANDLE mMainThread; michael@0: HANDLE mParentProcess; michael@0: HANDLE mRegWaitProcess; michael@0: DWORD mIPCTimeoutMs; michael@0: MiniShmChild mMiniShm; michael@0: michael@0: static const int kExpectedMinimumArgc; michael@0: michael@0: typedef HRESULT (WINAPI *SETAPPUSERMODELID)(PCWSTR); michael@0: michael@0: DISALLOW_COPY_AND_ASSIGN(PluginHangUIChild); michael@0: }; michael@0: michael@0: } // namespace plugins michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_plugins_PluginHangUIChild_h michael@0: