Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 : * vim: sw=4 ts=4 et :
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_PluginModuleParent_h
8 : #define mozilla_plugins_PluginModuleParent_h
9 :
10 : #include "base/process.h"
11 : #include "mozilla/FileUtils.h"
12 : #include "mozilla/HangAnnotations.h"
13 : #include "mozilla/PluginLibrary.h"
14 : #include "mozilla/ipc/CrashReporterHost.h"
15 : #include "mozilla/plugins/PluginProcessParent.h"
16 : #include "mozilla/plugins/PPluginModuleParent.h"
17 : #include "mozilla/plugins/PluginMessageUtils.h"
18 : #include "mozilla/plugins/PluginTypes.h"
19 : #include "mozilla/ipc/TaskFactory.h"
20 : #include "mozilla/TimeStamp.h"
21 : #include "mozilla/Unused.h"
22 : #include "npapi.h"
23 : #include "npfunctions.h"
24 : #include "nsDataHashtable.h"
25 : #include "nsHashKeys.h"
26 : #include "nsIObserver.h"
27 : #ifdef XP_WIN
28 : #include "nsWindowsHelpers.h"
29 : #if defined(MOZ_SANDBOX)
30 : #include "sandboxPermissions.h"
31 : #endif
32 : #endif
33 :
34 : #ifdef MOZ_CRASHREPORTER
35 : #include "nsExceptionHandler.h"
36 : #endif
37 :
38 : class nsPluginTag;
39 :
40 : namespace mozilla {
41 :
42 : namespace layers {
43 : class TextureClientRecycleAllocator;
44 : } // namespace layers
45 :
46 : namespace plugins {
47 : //-----------------------------------------------------------------------------
48 :
49 : class BrowserStreamParent;
50 : class PluginInstanceParent;
51 :
52 : #ifdef XP_WIN
53 : class PluginHangUIParent;
54 : #endif
55 : #ifdef MOZ_CRASHREPORTER_INJECTOR
56 : class FinishInjectorInitTask;
57 : #endif
58 :
59 : /**
60 : * PluginModuleParent
61 : *
62 : * This class implements the NPP API from the perspective of the rest
63 : * of Gecko, forwarding NPP calls along to the child process that is
64 : * actually running the plugin.
65 : *
66 : * This class /also/ implements a version of the NPN API, because the
67 : * child process needs to make these calls back into Gecko proper.
68 : * This class is responsible for "actually" making those function calls.
69 : *
70 : * If a plugin is running, there will always be one PluginModuleParent for it in
71 : * the chrome process. In addition, any content process using the plugin will
72 : * have its own PluginModuleParent. The subclasses PluginModuleChromeParent and
73 : * PluginModuleContentParent implement functionality that is specific to one
74 : * case or the other.
75 : */
76 : class PluginModuleParent
77 : : public PPluginModuleParent
78 : , public PluginLibrary
79 : #ifdef MOZ_CRASHREPORTER_INJECTOR
80 : , public CrashReporter::InjectorCrashCallback
81 : #endif
82 : {
83 : protected:
84 : typedef mozilla::PluginLibrary PluginLibrary;
85 :
86 : PPluginInstanceParent*
87 : AllocPPluginInstanceParent(const nsCString& aMimeType,
88 : const InfallibleTArray<nsCString>& aNames,
89 : const InfallibleTArray<nsCString>& aValues)
90 : override;
91 :
92 : virtual bool
93 : DeallocPPluginInstanceParent(PPluginInstanceParent* aActor) override;
94 :
95 : public:
96 : explicit PluginModuleParent(bool aIsChrome);
97 : virtual ~PluginModuleParent();
98 :
99 0 : bool IsChrome() const { return mIsChrome; }
100 :
101 0 : virtual void SetPlugin(nsNPAPIPlugin* plugin) override
102 : {
103 0 : mPlugin = plugin;
104 0 : }
105 :
106 : virtual void ActorDestroy(ActorDestroyReason why) override;
107 :
108 0 : const NPNetscapeFuncs* GetNetscapeFuncs() {
109 0 : return mNPNIface;
110 : }
111 :
112 0 : bool OkToCleanup() const {
113 0 : return !IsOnCxxStack();
114 : }
115 :
116 : void ProcessRemoteNativeEventsInInterruptCall() override;
117 :
118 0 : nsCString GetHistogramKey() const {
119 0 : return mPluginName + mPluginVersion;
120 : }
121 :
122 : void AccumulateModuleInitBlockedTime();
123 :
124 : virtual nsresult GetRunID(uint32_t* aRunID) override;
125 0 : virtual void SetHasLocalInstance() override {
126 0 : mHadLocalInstance = true;
127 0 : }
128 :
129 : int GetQuirks() { return mQuirks; }
130 :
131 : protected:
132 : virtual mozilla::ipc::RacyInterruptPolicy
133 0 : MediateInterruptRace(const MessageInfo& parent,
134 : const MessageInfo& child) override
135 : {
136 0 : return MediateRace(parent, child);
137 : }
138 :
139 : virtual mozilla::ipc::IPCResult
140 : RecvBackUpXResources(const FileDescriptor& aXSocketFd) override;
141 :
142 : virtual mozilla::ipc::IPCResult AnswerProcessSomeEvents() override;
143 :
144 : virtual mozilla::ipc::IPCResult
145 : RecvProcessNativeEventsInInterruptCall() override;
146 :
147 : virtual mozilla::ipc::IPCResult
148 : RecvPluginShowWindow(const uint32_t& aWindowId, const bool& aModal,
149 : const int32_t& aX, const int32_t& aY,
150 : const size_t& aWidth, const size_t& aHeight) override;
151 :
152 : virtual mozilla::ipc::IPCResult
153 : RecvPluginHideWindow(const uint32_t& aWindowId) override;
154 :
155 : virtual mozilla::ipc::IPCResult
156 : RecvSetCursor(const NSCursorInfo& aCursorInfo) override;
157 :
158 : virtual mozilla::ipc::IPCResult
159 : RecvShowCursor(const bool& aShow) override;
160 :
161 : virtual mozilla::ipc::IPCResult
162 : RecvPushCursor(const NSCursorInfo& aCursorInfo) override;
163 :
164 : virtual mozilla::ipc::IPCResult
165 : RecvPopCursor() override;
166 :
167 : virtual mozilla::ipc::IPCResult
168 : RecvNPN_SetException(const nsCString& aMessage) override;
169 :
170 : virtual mozilla::ipc::IPCResult
171 : RecvNPN_ReloadPlugins(const bool& aReloadPages) override;
172 :
173 : static BrowserStreamParent* StreamCast(NPP instance, NPStream* s);
174 :
175 : virtual mozilla::ipc::IPCResult
176 : AnswerNPN_SetValue_NPPVpluginRequiresAudioDeviceChanges(
177 : const bool& shouldRegister,
178 : NPError* result) override;
179 :
180 : virtual mozilla::ipc::IPCResult
181 0 : AnswerGetFileName(const GetFileNameFunc& aFunc,
182 : const OpenFileNameIPC& aOfnIn,
183 : OpenFileNameRetIPC* aOfnOut, bool* aResult) override
184 : {
185 0 : return IPC_FAIL_NO_REASON(this);
186 : }
187 :
188 : virtual mozilla::ipc::IPCResult
189 0 : AnswerSetCursorPos(const int &x, const int &y, bool* aResult) override
190 : {
191 0 : return IPC_FAIL_NO_REASON(this);
192 : }
193 :
194 : protected:
195 : void SetChildTimeout(const int32_t aChildTimeout);
196 : static void TimeoutChanged(const char* aPref, void* aModule);
197 :
198 0 : virtual void UpdatePluginTimeout() {}
199 :
200 0 : virtual mozilla::ipc::IPCResult RecvNotifyContentModuleDestroyed() override { return IPC_OK(); }
201 :
202 : virtual mozilla::ipc::IPCResult AnswerGetKeyState(const int32_t& aVirtKey, int16_t* aRet) override;
203 :
204 : virtual mozilla::ipc::IPCResult RecvReturnClearSiteData(const NPError& aRv,
205 : const uint64_t& aCallbackId) override;
206 :
207 : virtual mozilla::ipc::IPCResult RecvReturnSitesWithData(nsTArray<nsCString>&& aSites,
208 : const uint64_t& aCallbackId) override;
209 :
210 : void SetPluginFuncs(NPPluginFuncs* aFuncs);
211 :
212 : nsresult NPP_NewInternal(NPMIMEType pluginType, NPP instance,
213 : InfallibleTArray<nsCString>& names,
214 : InfallibleTArray<nsCString>& values,
215 : NPSavedData* saved, NPError* error);
216 :
217 : // NPP-like API that Gecko calls are trampolined into. These
218 : // messages then get forwarded along to the plugin instance,
219 : // and then eventually the child process.
220 :
221 : static NPError NPP_Destroy(NPP instance, NPSavedData** save);
222 :
223 : static NPError NPP_SetWindow(NPP instance, NPWindow* window);
224 : static NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
225 : NPBool seekable, uint16_t* stype);
226 : static NPError NPP_DestroyStream(NPP instance,
227 : NPStream* stream, NPReason reason);
228 : static int32_t NPP_WriteReady(NPP instance, NPStream* stream);
229 : static int32_t NPP_Write(NPP instance, NPStream* stream,
230 : int32_t offset, int32_t len, void* buffer);
231 : static void NPP_StreamAsFile(NPP instance,
232 : NPStream* stream, const char* fname);
233 : static void NPP_Print(NPP instance, NPPrint* platformPrint);
234 : static int16_t NPP_HandleEvent(NPP instance, void* event);
235 : static void NPP_URLNotify(NPP instance, const char* url,
236 : NPReason reason, void* notifyData);
237 : static NPError NPP_GetValue(NPP instance,
238 : NPPVariable variable, void *ret_value);
239 : static NPError NPP_SetValue(NPP instance, NPNVariable variable,
240 : void *value);
241 : static void NPP_URLRedirectNotify(NPP instance, const char* url,
242 : int32_t status, void* notifyData);
243 :
244 : virtual bool HasRequiredFunctions() override;
245 : virtual nsresult AsyncSetWindow(NPP aInstance, NPWindow* aWindow) override;
246 : virtual nsresult GetImageContainer(NPP aInstance, mozilla::layers::ImageContainer** aContainer) override;
247 : virtual nsresult GetImageSize(NPP aInstance, nsIntSize* aSize) override;
248 : virtual void DidComposite(NPP aInstance) override;
249 0 : virtual bool IsOOP() override { return true; }
250 : virtual nsresult SetBackgroundUnknown(NPP instance) override;
251 : virtual nsresult BeginUpdateBackground(NPP instance,
252 : const nsIntRect& aRect,
253 : DrawTarget** aDrawTarget) override;
254 : virtual nsresult EndUpdateBackground(NPP instance,
255 : const nsIntRect& aRect) override;
256 :
257 : #if defined(XP_WIN)
258 : virtual nsresult GetScrollCaptureContainer(NPP aInstance, mozilla::layers::ImageContainer** aContainer) override;
259 : #endif
260 :
261 : virtual nsresult HandledWindowedPluginKeyEvent(
262 : NPP aInstance,
263 : const mozilla::NativeEventData& aNativeKeyData,
264 : bool aIsConsumed) override;
265 :
266 : #if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)
267 : virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error) override;
268 : #else
269 : virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) override;
270 : #endif
271 : virtual nsresult NP_Shutdown(NPError* error) override;
272 :
273 : virtual nsresult NP_GetMIMEDescription(const char** mimeDesc) override;
274 : virtual nsresult NP_GetValue(void *future, NPPVariable aVariable,
275 : void *aValue, NPError* error) override;
276 : #if defined(XP_WIN) || defined(XP_MACOSX)
277 : virtual nsresult NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error) override;
278 : #endif
279 : virtual nsresult NPP_New(NPMIMEType pluginType, NPP instance,
280 : int16_t argc, char* argn[],
281 : char* argv[], NPSavedData* saved,
282 : NPError* error) override;
283 : virtual nsresult NPP_ClearSiteData(const char* site, uint64_t flags, uint64_t maxAge,
284 : nsCOMPtr<nsIClearSiteDataCallback> callback) override;
285 : virtual nsresult NPP_GetSitesWithData(nsCOMPtr<nsIGetSitesWithDataCallback> callback) override;
286 :
287 : private:
288 : std::map<uint64_t, nsCOMPtr<nsIClearSiteDataCallback>> mClearSiteDataCallbacks;
289 : std::map<uint64_t, nsCOMPtr<nsIGetSitesWithDataCallback>> mSitesWithDataCallbacks;
290 :
291 : nsCString mPluginFilename;
292 : int mQuirks;
293 : void InitQuirksModes(const nsCString& aMimeType);
294 :
295 : public:
296 :
297 : #if defined(XP_MACOSX)
298 : virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, bool *aDrawing) override;
299 : #endif
300 : #if defined(XP_MACOSX) || defined(XP_WIN)
301 : virtual nsresult ContentsScaleFactorChanged(NPP instance, double aContentsScaleFactor) override;
302 : #endif
303 :
304 : layers::TextureClientRecycleAllocator* EnsureTextureAllocatorForDirectBitmap();
305 : layers::TextureClientRecycleAllocator* EnsureTextureAllocatorForDXGISurface();
306 :
307 : protected:
308 : void NotifyFlashHang();
309 : void NotifyPluginCrashed();
310 : void OnInitFailure();
311 : bool DoShutdown(NPError* error);
312 :
313 : bool GetSetting(NPNVariable aVariable);
314 : void GetSettings(PluginSettings* aSettings);
315 :
316 : bool mIsChrome;
317 : bool mShutdown;
318 : bool mHadLocalInstance;
319 : bool mClearSiteDataSupported;
320 : bool mGetSitesWithDataSupported;
321 : NPNetscapeFuncs* mNPNIface;
322 : NPPluginFuncs* mNPPIface;
323 : nsNPAPIPlugin* mPlugin;
324 : ipc::TaskFactory<PluginModuleParent> mTaskFactory;
325 : nsString mHangID;
326 : TimeDuration mTimeBlocked;
327 : nsCString mPluginName;
328 : nsCString mPluginVersion;
329 : int32_t mSandboxLevel;
330 : bool mIsFlashPlugin;
331 :
332 : #ifdef MOZ_X11
333 : // Dup of plugin's X socket, used to scope its resources to this
334 : // object instead of the plugin process's lifetime
335 : ScopedClose mPluginXSocketFdDup;
336 : #endif
337 :
338 : bool
339 : GetPluginDetails();
340 :
341 : uint32_t mRunID;
342 :
343 : RefPtr<layers::TextureClientRecycleAllocator> mTextureAllocatorForDirectBitmap;
344 : RefPtr<layers::TextureClientRecycleAllocator> mTextureAllocatorForDXGISurface;
345 :
346 : #ifdef MOZ_CRASHREPORTER
347 : /**
348 : * This mutex protects the crash reporter when the Plugin Hang UI event
349 : * handler is executing off main thread. It is intended to protect both
350 : * the mCrashReporter variable in addition to the CrashReporterHost object
351 : * that mCrashReporter refers to.
352 : */
353 : mozilla::Mutex mCrashReporterMutex;
354 : UniquePtr<ipc::CrashReporterHost> mCrashReporter;
355 : #endif // MOZ_CRASHREPORTER
356 : };
357 :
358 : class PluginModuleContentParent : public PluginModuleParent
359 : {
360 : public:
361 : explicit PluginModuleContentParent();
362 :
363 : static PluginLibrary* LoadModule(uint32_t aPluginId, nsPluginTag* aPluginTag);
364 :
365 : virtual ~PluginModuleContentParent();
366 :
367 : #if defined(XP_WIN) || defined(XP_MACOSX)
368 : nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) override;
369 : #endif
370 :
371 : private:
372 : static void Initialize(Endpoint<PPluginModuleParent>&& aEndpoint);
373 :
374 : virtual bool ShouldContinueFromReplyTimeout() override;
375 : virtual void OnExitedSyncSend() override;
376 :
377 : #ifdef MOZ_CRASHREPORTER_INJECTOR
378 : void OnCrash(DWORD processID) override {}
379 : #endif
380 :
381 : static PluginModuleContentParent* sSavedModuleParent;
382 :
383 : uint32_t mPluginId;
384 : };
385 :
386 : class PluginModuleChromeParent
387 : : public PluginModuleParent
388 : , public mozilla::HangMonitor::Annotator
389 : {
390 : friend class mozilla::ipc::CrashReporterHost;
391 : using TerminateChildProcessCallback =
392 : mozilla::ipc::CrashReporterHost::CallbackWrapper<bool>;
393 : using TakeFullMinidumpCallback =
394 : mozilla::ipc::CrashReporterHost::CallbackWrapper<nsString>;
395 : public:
396 : /**
397 : * LoadModule
398 : *
399 : * This may or may not launch a plugin child process,
400 : * and may or may not be very expensive.
401 : */
402 : static PluginLibrary* LoadModule(const char* aFilePath, uint32_t aPluginId,
403 : nsPluginTag* aPluginTag);
404 :
405 : virtual ~PluginModuleChromeParent();
406 :
407 : /*
408 : * Takes a full multi-process dump including the plugin process and the
409 : * content process. If aBrowserDumpId is not empty then the browser dump
410 : * associated with it will be paired to the resulting minidump.
411 : * Takes ownership of the file associated with aBrowserDumpId.
412 : *
413 : * @param aContentPid PID of the e10s content process from which a hang was
414 : * reported. May be kInvalidProcessId if not applicable.
415 : * @param aBrowserDumpId (optional) previously taken browser dump id. If
416 : * provided TakeFullMinidump will use this dump file instead of
417 : * generating a new one. If not provided a browser dump will be taken at
418 : * the time of this call.
419 : * @param aCallback a callback invoked when the operation completes. The ID
420 : * of the newly generated crash dump is provided in the callback argument.
421 : * An empty string will be provided upon failure.
422 : * @param aAsync whether to perform the dump asynchronously.
423 : */
424 : void
425 : TakeFullMinidump(base::ProcessId aContentPid,
426 : const nsAString& aBrowserDumpId,
427 : std::function<void(nsString)>&& aCallback,
428 : bool aAsync);
429 :
430 : /*
431 : * Terminates the plugin process associated with this plugin module. Also
432 : * generates appropriate crash reports unless an existing one is provided.
433 : * Takes ownership of the file associated with aDumpId on success.
434 : *
435 : * @param aMsgLoop the main message pump associated with the module
436 : * protocol.
437 : * @param aContentPid PID of the e10s content process from which a hang was
438 : * reported. May be kInvalidProcessId if not applicable.
439 : * @param aMonitorDescription a string describing the hang monitor that
440 : * is making this call. This string is added to the crash reporter
441 : * annotations for the plugin process.
442 : * @param aDumpId (optional) previously taken dump id. If provided
443 : * TerminateChildProcess will use this dump file instead of generating a
444 : * multi-process crash report. If not provided a multi-process dump will
445 : * be taken at the time of this call.
446 : * @param aCallback a callback invoked when the operation completes. The
447 : * argument denotes whether the operation succeeded.
448 : * @param aAsync whether to perform the operation asynchronously.
449 : */
450 : void
451 : TerminateChildProcess(MessageLoop* aMsgLoop,
452 : base::ProcessId aContentPid,
453 : const nsCString& aMonitorDescription,
454 : const nsAString& aDumpId,
455 : std::function<void(bool)>&& aCallback,
456 : bool aAsync);
457 :
458 : /**
459 : * Helper for passing a dummy callback in calling the above function if it
460 : * is called synchronously and the caller doesn't care about the callback
461 : * result.
462 : */
463 : template<typename T>
464 0 : static std::function<void(T)> DummyCallback()
465 : {
466 0 : return std::function<void(T)>([](T aResult) { });
467 : }
468 :
469 : private:
470 : #ifdef MOZ_CRASHREPORTER
471 : // The following methods are callbacks invoked after calling
472 : // TakeFullMinidump(). The methods are invoked in the following order:
473 : void TakeBrowserAndPluginMinidumps(bool aReportsReady,
474 : base::ProcessId aContentPid,
475 : const nsAString& aBrowserDumpId,
476 : bool aAsync);
477 : void OnTakeFullMinidumpComplete(bool aReportsReady,
478 : base::ProcessId aContentPid,
479 : const nsAString& aBrowserDumpId);
480 :
481 : #endif
482 : // The following method is the callback invoked after calling
483 : // TerminateChidlProcess().
484 : void TerminateChildProcessOnDumpComplete(MessageLoop* aMsgLoop,
485 : const nsCString& aMonitorDescription);
486 : public:
487 :
488 : #ifdef XP_WIN
489 : /**
490 : * Called by Plugin Hang UI to notify that the user has clicked continue.
491 : * Used for chrome hang annotations.
492 : */
493 : void
494 : OnHangUIContinue();
495 :
496 : void
497 : EvaluateHangUIState(const bool aReset);
498 : #endif // XP_WIN
499 :
500 : void CachedSettingChanged();
501 :
502 : virtual mozilla::ipc::IPCResult
503 : AnswerGetKeyState(const int32_t& aVirtKey, int16_t* aRet) override;
504 :
505 : // Proxy GetOpenFileName/GetSaveFileName on Windows.
506 : virtual mozilla::ipc::IPCResult
507 : AnswerGetFileName(const GetFileNameFunc& aFunc,
508 : const OpenFileNameIPC& aOfnIn,
509 : OpenFileNameRetIPC* aOfnOut, bool* aResult) override;
510 :
511 : // Proxy SetCursorPos on Windows.
512 : virtual mozilla::ipc::IPCResult
513 : AnswerSetCursorPos(const int &x, const int &y, bool* aResult) override;
514 :
515 : private:
516 : virtual void
517 : EnteredCxxStack() override;
518 :
519 : void
520 : ExitedCxxStack() override;
521 :
522 : mozilla::ipc::IProtocol* GetInvokingProtocol();
523 : PluginInstanceParent* GetManagingInstance(mozilla::ipc::IProtocol* aProtocol);
524 :
525 : virtual void
526 : AnnotateHang(mozilla::HangMonitor::HangAnnotations& aAnnotations) override;
527 :
528 : virtual bool ShouldContinueFromReplyTimeout() override;
529 :
530 : #ifdef MOZ_CRASHREPORTER
531 : void ProcessFirstMinidump();
532 : void WriteExtraDataForMinidump();
533 : void RetainPluginRef();
534 : void ReleasePluginRef();
535 : #endif
536 :
537 0 : PluginProcessParent* Process() const { return mSubprocess; }
538 : base::ProcessHandle ChildProcessHandle() { return mSubprocess->GetChildProcessHandle(); }
539 :
540 : #if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)
541 : virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error) override;
542 : #else
543 : virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) override;
544 : #endif
545 :
546 : #if defined(XP_WIN) || defined(XP_MACOSX)
547 : virtual nsresult NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error) override;
548 : #endif
549 :
550 : virtual void ActorDestroy(ActorDestroyReason why) override;
551 :
552 : // aFilePath is UTF8, not native!
553 : explicit PluginModuleChromeParent(const char* aFilePath, uint32_t aPluginId,
554 : int32_t aSandboxLevel);
555 :
556 : void CleanupFromTimeout(const bool aByHangUI);
557 :
558 : virtual void UpdatePluginTimeout() override;
559 :
560 : void RegisterSettingsCallbacks();
561 : void UnregisterSettingsCallbacks();
562 :
563 : bool InitCrashReporter();
564 :
565 : virtual mozilla::ipc::IPCResult RecvNotifyContentModuleDestroyed() override;
566 :
567 : static void CachedSettingChanged(const char* aPref, void* aModule);
568 :
569 : virtual mozilla::ipc::IPCResult
570 : AnswerNPN_SetValue_NPPVpluginRequiresAudioDeviceChanges(
571 : const bool& shouldRegister,
572 : NPError* result) override;
573 :
574 : PluginProcessParent* mSubprocess;
575 : uint32_t mPluginId;
576 :
577 : ipc::TaskFactory<PluginModuleChromeParent> mChromeTaskFactory;
578 :
579 : enum HangAnnotationFlags
580 : {
581 : kInPluginCall = (1u << 0),
582 : kHangUIShown = (1u << 1),
583 : kHangUIContinued = (1u << 2),
584 : kHangUIDontShow = (1u << 3)
585 : };
586 : Atomic<uint32_t> mHangAnnotationFlags;
587 : #ifdef XP_WIN
588 : InfallibleTArray<float> mPluginCpuUsageOnHang;
589 : PluginHangUIParent *mHangUIParent;
590 : bool mHangUIEnabled;
591 : bool mIsTimerReset;
592 :
593 : /**
594 : * Launches the Plugin Hang UI.
595 : *
596 : * @return true if plugin-hang-ui.exe has been successfully launched.
597 : * false if the Plugin Hang UI is disabled, already showing,
598 : * or the launch failed.
599 : */
600 : bool
601 : LaunchHangUI();
602 :
603 : /**
604 : * Finishes the Plugin Hang UI and cancels if it is being shown to the user.
605 : */
606 : void
607 : FinishHangUI();
608 : #endif
609 :
610 : #ifdef MOZ_CRASHREPORTER_INJECTOR
611 : friend class mozilla::plugins::FinishInjectorInitTask;
612 :
613 : void InitializeInjector();
614 : void DoInjection(const nsAutoHandle& aSnapshot);
615 : static DWORD WINAPI GetToolhelpSnapshot(LPVOID aContext);
616 :
617 : void OnCrash(DWORD processID) override;
618 :
619 : DWORD mFlashProcess1;
620 : DWORD mFlashProcess2;
621 : RefPtr<mozilla::plugins::FinishInjectorInitTask> mFinishInitTask;
622 : #endif
623 :
624 : void OnProcessLaunched(const bool aSucceeded);
625 :
626 0 : class LaunchedTask : public LaunchCompleteTask
627 : {
628 : public:
629 0 : explicit LaunchedTask(PluginModuleChromeParent* aModule)
630 0 : : mModule(aModule)
631 : {
632 0 : MOZ_ASSERT(aModule);
633 0 : }
634 :
635 0 : NS_IMETHOD Run() override
636 : {
637 0 : mModule->OnProcessLaunched(mLaunchSucceeded);
638 0 : return NS_OK;
639 : }
640 :
641 : private:
642 : PluginModuleChromeParent* mModule;
643 : };
644 :
645 : friend class LaunchedTask;
646 :
647 : nsCOMPtr<nsIObserver> mPluginOfflineObserver;
648 : bool mIsBlocklisted;
649 : #if defined(XP_WIN) && defined(MOZ_SANDBOX)
650 : mozilla::SandboxPermissions mSandboxPermissions;
651 : #endif
652 :
653 : #ifdef MOZ_CRASHREPORTER
654 : nsCOMPtr<nsIFile> mBrowserDumpFile;
655 : TakeFullMinidumpCallback mTakeFullMinidumpCallback;
656 : #endif
657 : TerminateChildProcessCallback mTerminateChildProcessCallback;
658 : };
659 :
660 : } // namespace plugins
661 : } // namespace mozilla
662 :
663 : #endif // mozilla_plugins_PluginModuleParent_h
|