summaryrefslogtreecommitdiffstats
path: root/dom/plugins/ipc/PluginHangUIParent.h
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/plugins/ipc/PluginHangUIParent.h
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/plugins/ipc/PluginHangUIParent.h')
-rw-r--r--dom/plugins/ipc/PluginHangUIParent.h159
1 files changed, 159 insertions, 0 deletions
diff --git a/dom/plugins/ipc/PluginHangUIParent.h b/dom/plugins/ipc/PluginHangUIParent.h
new file mode 100644
index 000000000..8a6b2e6cb
--- /dev/null
+++ b/dom/plugins/ipc/PluginHangUIParent.h
@@ -0,0 +1,159 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_plugins_PluginHangUIParent_h
+#define mozilla_plugins_PluginHangUIParent_h
+
+#include "nsString.h"
+
+#include "base/process.h"
+#include "base/process_util.h"
+
+#include "mozilla/Mutex.h"
+#include "mozilla/plugins/PluginMessageUtils.h"
+
+#include "MiniShmParent.h"
+
+namespace mozilla {
+namespace plugins {
+
+class PluginModuleChromeParent;
+
+/**
+ * This class is responsible for launching and communicating with the
+ * plugin-hang-ui process.
+ *
+ * NOTE: PluginHangUIParent is *not* an IPDL actor! In this case, "Parent"
+ * is describing the fact that firefox is the parent process to the
+ * plugin-hang-ui process, which is the PluginHangUIChild.
+ * PluginHangUIParent and PluginHangUIChild are a matched pair.
+ * @see PluginHangUIChild
+ */
+class PluginHangUIParent : public MiniShmObserver
+{
+public:
+ PluginHangUIParent(PluginModuleChromeParent* aModule,
+ const int32_t aHangUITimeoutPref,
+ const int32_t aChildTimeoutPref);
+ virtual ~PluginHangUIParent();
+
+ /**
+ * Spawn the plugin-hang-ui.exe child process and terminate the given
+ * plugin container process if the user elects to stop the hung plugin.
+ *
+ * @param aPluginName Human-readable name of the affected plugin.
+ * @return true if the plugin hang ui process was successfully launched,
+ * otherwise false.
+ */
+ bool
+ Init(const nsString& aPluginName);
+
+ /**
+ * If the Plugin Hang UI is being shown, send a cancel notification to the
+ * Plugin Hang UI child process.
+ *
+ * @return true if the UI was shown and the cancel command was successfully
+ * sent to the child process, otherwise false.
+ */
+ bool
+ Cancel();
+
+ /**
+ * Returns whether the Plugin Hang UI is currently being displayed.
+ *
+ * @return true if the Plugin Hang UI is showing, otherwise false.
+ */
+ bool
+ IsShowing() const { return mIsShowing; }
+
+ /**
+ * Returns whether this Plugin Hang UI instance has been shown. Note
+ * that this does not necessarily mean that the UI is showing right now.
+ *
+ * @return true if the Plugin Hang UI has shown, otherwise false.
+ */
+ bool
+ WasShown() const { return mIsShowing || mLastUserResponse != 0; }
+
+ /**
+ * Returns whether the user checked the "Don't ask me again" checkbox.
+ *
+ * @return true if the user does not want to see the Hang UI again.
+ */
+ bool
+ DontShowAgain() const;
+
+ /**
+ * Returns whether the user clicked stop during the last time that the
+ * Plugin Hang UI was displayed, if applicable.
+ *
+ * @return true if the UI was shown and the user chose to stop the
+ * plugin, otherwise false
+ */
+ bool
+ WasLastHangStopped() const;
+
+ /**
+ * @return unsigned int containing the response bits from the last
+ * time the Plugin Hang UI ran.
+ */
+ unsigned int
+ LastUserResponse() const { return mLastUserResponse; }
+
+ /**
+ * @return unsigned int containing the number of milliseconds that
+ * the Plugin Hang UI was displayed before the user responded.
+ * Returns 0 if the Plugin Hang UI has not been shown or was cancelled.
+ */
+ unsigned int
+ LastShowDurationMs() const;
+
+ virtual void
+ OnMiniShmEvent(MiniShmBase* aMiniShmObj) override;
+
+ virtual void
+ OnMiniShmConnect(MiniShmBase* aMiniShmObj) override;
+
+private:
+ nsresult
+ GetHangUIOwnerWindowHandle(NativeWindowHandle& windowHandle);
+
+ bool
+ SendCancel();
+
+ bool
+ RecvUserResponse(const unsigned int& aResponse);
+
+ bool
+ UnwatchHangUIChildProcess(bool aWait);
+
+ static
+ VOID CALLBACK SOnHangUIProcessExit(PVOID aContext, BOOLEAN aIsTimer);
+
+private:
+ Mutex mMutex;
+ PluginModuleChromeParent* mModule;
+ const uint32_t mTimeoutPrefMs;
+ const uint32_t mIPCTimeoutMs;
+ MessageLoop* mMainThreadMessageLoop;
+ bool mIsShowing;
+ unsigned int mLastUserResponse;
+ base::ProcessHandle mHangUIProcessHandle;
+ NativeWindowHandle mMainWindowHandle;
+ HANDLE mRegWait;
+ HANDLE mShowEvent;
+ DWORD mShowTicks;
+ DWORD mResponseTicks;
+ MiniShmParent mMiniShm;
+
+ DISALLOW_COPY_AND_ASSIGN(PluginHangUIParent);
+};
+
+} // namespace plugins
+} // namespace mozilla
+
+#endif // mozilla_plugins_PluginHangUIParent_h
+