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