This file is indexed.

/usr/include/thunderbird/mozilla/plugins/PluginInstanceParent.h is in thunderbird-dev 1:52.8.0-1~deb8u1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 * vim: sw=4 ts=4 et :
 * 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 dom_plugins_PluginInstanceParent_h
#define dom_plugins_PluginInstanceParent_h 1

#include "mozilla/plugins/PPluginInstanceParent.h"
#include "mozilla/plugins/PluginScriptableObjectParent.h"
#if defined(OS_WIN)
#include "mozilla/gfx/SharedDIBWin.h"
#include <d3d10_1.h>
#include "nsRefPtrHashtable.h"
#elif defined(MOZ_WIDGET_COCOA)
#include "mozilla/gfx/QuartzSupport.h"
#endif

#include "npfunctions.h"
#include "nsDataHashtable.h"
#include "nsHashKeys.h"
#include "nsRect.h"
#include "PluginDataResolver.h"

#include "mozilla/Unused.h"
#include "mozilla/EventForwards.h"

class gfxASurface;
class gfxContext;
class nsPluginInstanceOwner;

namespace mozilla {
namespace layers {
class Image;
class ImageContainer;
class TextureClientRecycleAllocator;
} // namespace layers
namespace plugins {

class PBrowserStreamParent;
class PluginModuleParent;
class D3D11SurfaceHolder;

class PluginInstanceParent : public PPluginInstanceParent
                           , public PluginDataResolver
{
    friend class PluginModuleParent;
    friend class BrowserStreamParent;
    friend class PluginStreamParent;
    friend class StreamNotifyParent;

#if defined(XP_WIN)
public:
    /**
     * Helper method for looking up instances based on a supplied id.
     */
    static PluginInstanceParent*
    LookupPluginInstanceByID(uintptr_t aId);
#endif // defined(XP_WIN)

public:
    typedef mozilla::gfx::DrawTarget DrawTarget;

    PluginInstanceParent(PluginModuleParent* parent,
                         NPP npp,
                         const nsCString& mimeType,
                         const NPNetscapeFuncs* npniface);

    virtual ~PluginInstanceParent();

    bool InitMetadata(const nsACString& aMimeType,
                      const nsACString& aSrcAttribute);
    NPError Destroy();

    virtual void ActorDestroy(ActorDestroyReason why) override;

    virtual PPluginScriptableObjectParent*
    AllocPPluginScriptableObjectParent() override;

    virtual bool
    RecvPPluginScriptableObjectConstructor(PPluginScriptableObjectParent* aActor) override;

    virtual bool
    DeallocPPluginScriptableObjectParent(PPluginScriptableObjectParent* aObject) override;
    virtual PBrowserStreamParent*
    AllocPBrowserStreamParent(const nsCString& url,
                              const uint32_t& length,
                              const uint32_t& lastmodified,
                              PStreamNotifyParent* notifyData,
                              const nsCString& headers) override;
    virtual bool
    DeallocPBrowserStreamParent(PBrowserStreamParent* stream) override;

    virtual PPluginStreamParent*
    AllocPPluginStreamParent(const nsCString& mimeType,
                             const nsCString& target,
                             NPError* result) override;
    virtual bool
    DeallocPPluginStreamParent(PPluginStreamParent* stream) override;

    virtual bool
    AnswerNPN_GetValue_NPNVnetscapeWindow(NativeWindowHandle* value,
                                          NPError* result) override;
    virtual bool
    AnswerNPN_GetValue_NPNVWindowNPObject(
                                       PPluginScriptableObjectParent** value,
                                       NPError* result) override;
    virtual bool
    AnswerNPN_GetValue_NPNVPluginElementNPObject(
                                       PPluginScriptableObjectParent** value,
                                       NPError* result) override;
    virtual bool
    AnswerNPN_GetValue_NPNVprivateModeBool(bool* value, NPError* result) override;

    virtual bool
    AnswerNPN_GetValue_DrawingModelSupport(const NPNVariable& model, bool* value) override;
  
    virtual bool
    AnswerNPN_GetValue_NPNVdocumentOrigin(nsCString* value, NPError* result) override;

    virtual bool
    AnswerNPN_GetValue_SupportsAsyncBitmapSurface(bool* value) override;

    virtual bool
    AnswerNPN_GetValue_SupportsAsyncDXGISurface(bool* value) override;

    virtual bool
    AnswerNPN_GetValue_PreferredDXGIAdapter(DxgiAdapterDesc* desc) override;

    virtual bool
    AnswerNPN_SetValue_NPPVpluginWindow(const bool& windowed, NPError* result) override;
    virtual bool
    AnswerNPN_SetValue_NPPVpluginTransparent(const bool& transparent,
                                             NPError* result) override;
    virtual bool
    AnswerNPN_SetValue_NPPVpluginUsesDOMForCursor(const bool& useDOMForCursor,
                                                  NPError* result) override;
    virtual bool
    AnswerNPN_SetValue_NPPVpluginDrawingModel(const int& drawingModel,
                                              NPError* result) override;
    virtual bool
    AnswerNPN_SetValue_NPPVpluginEventModel(const int& eventModel,
                                             NPError* result) override;
    virtual bool
    AnswerNPN_SetValue_NPPVpluginIsPlayingAudio(const bool& isAudioPlaying,
                                                NPError* result) override;

    virtual bool
    AnswerNPN_GetURL(const nsCString& url, const nsCString& target,
                     NPError *result) override;

    virtual bool
    AnswerNPN_PostURL(const nsCString& url, const nsCString& target,
                      const nsCString& buffer, const bool& file,
                      NPError* result) override;

    virtual PStreamNotifyParent*
    AllocPStreamNotifyParent(const nsCString& url, const nsCString& target,
                             const bool& post, const nsCString& buffer,
                             const bool& file,
                             NPError* result) override;

    virtual bool
    AnswerPStreamNotifyConstructor(PStreamNotifyParent* actor,
                                   const nsCString& url,
                                   const nsCString& target,
                                   const bool& post, const nsCString& buffer,
                                   const bool& file,
                                   NPError* result) override;

    virtual bool
    DeallocPStreamNotifyParent(PStreamNotifyParent* notifyData) override;

    virtual bool
    RecvNPN_InvalidateRect(const NPRect& rect) override;

    virtual bool
    RecvRevokeCurrentDirectSurface() override;

    virtual bool
    RecvInitDXGISurface(const gfx::SurfaceFormat& format,
                         const gfx::IntSize& size,
                         WindowsHandle* outHandle,
                         NPError* outError) override;
    virtual bool
    RecvFinalizeDXGISurface(const WindowsHandle& handle) override;

    virtual bool
    RecvShowDirectBitmap(Shmem&& buffer,
                         const gfx::SurfaceFormat& format,
                         const uint32_t& stride,
                         const gfx::IntSize& size,
                         const gfx::IntRect& dirty) override;

    virtual bool
    RecvShowDirectDXGISurface(const WindowsHandle& handle,
                               const gfx::IntRect& rect) override;

    // Async rendering
    virtual bool
    RecvShow(const NPRect& updatedRect,
             const SurfaceDescriptor& newSurface,
             SurfaceDescriptor* prevSurface) override;

    virtual PPluginSurfaceParent*
    AllocPPluginSurfaceParent(const WindowsSharedMemoryHandle& handle,
                              const mozilla::gfx::IntSize& size,
                              const bool& transparent) override;

    virtual bool
    DeallocPPluginSurfaceParent(PPluginSurfaceParent* s) override;

    virtual bool
    AnswerNPN_PushPopupsEnabledState(const bool& aState) override;

    virtual bool
    AnswerNPN_PopPopupsEnabledState() override;

    virtual bool
    AnswerNPN_GetValueForURL(const NPNURLVariable& variable,
                             const nsCString& url,
                             nsCString* value, NPError* result) override;

    virtual bool
    AnswerNPN_SetValueForURL(const NPNURLVariable& variable,
                             const nsCString& url,
                             const nsCString& value, NPError* result) override;

    virtual bool
    AnswerNPN_GetAuthenticationInfo(const nsCString& protocol,
                                    const nsCString& host,
                                    const int32_t& port,
                                    const nsCString& scheme,
                                    const nsCString& realm,
                                    nsCString* username,
                                    nsCString* password,
                                    NPError* result) override;

    virtual bool
    AnswerNPN_ConvertPoint(const double& sourceX,
                           const bool&   ignoreDestX,
                           const double& sourceY,
                           const bool&   ignoreDestY,
                           const NPCoordinateSpace& sourceSpace,
                           const NPCoordinateSpace& destSpace,
                           double *destX,
                           double *destY,
                           bool *result) override;

    virtual bool
    RecvRedrawPlugin() override;

    virtual bool
    RecvNegotiatedCarbon() override;

    virtual bool
    RecvAsyncNPP_NewResult(const NPError& aResult) override;

    virtual bool
    RecvSetNetscapeWindowAsParent(const NativeWindowHandle& childWindow) override;

    NPError NPP_SetWindow(const NPWindow* aWindow);

    NPError NPP_GetValue(NPPVariable variable, void* retval);
    NPError NPP_SetValue(NPNVariable variable, void* value);

    void NPP_URLRedirectNotify(const char* url, int32_t status,
                               void* notifyData);

    NPError NPP_NewStream(NPMIMEType type, NPStream* stream,
                          NPBool seekable, uint16_t* stype);
    NPError NPP_DestroyStream(NPStream* stream, NPReason reason);

    void NPP_Print(NPPrint* platformPrint);

    int16_t NPP_HandleEvent(void* event);

    void NPP_URLNotify(const char* url, NPReason reason, void* notifyData);

    PluginModuleParent* Module()
    {
        return mParent;
    }

    const NPNetscapeFuncs* GetNPNIface()
    {
        return mNPNIface;
    }

    bool
    RegisterNPObjectForActor(NPObject* aObject,
                             PluginScriptableObjectParent* aActor);

    void
    UnregisterNPObject(NPObject* aObject);

    PluginScriptableObjectParent*
    GetActorForNPObject(NPObject* aObject);

    NPP
    GetNPP()
    {
      return mNPP;
    }

    bool
    UseSurrogate() const
    {
        return mUseSurrogate;
    }

    void
    GetSrcAttribute(nsACString& aOutput) const
    {
        aOutput = mSrcAttribute;
    }

    virtual bool
    AnswerPluginFocusChange(const bool& gotFocus) override;

    nsresult AsyncSetWindow(NPWindow* window);
    nsresult GetImageContainer(mozilla::layers::ImageContainer** aContainer);
    nsresult GetImageSize(nsIntSize* aSize);
#ifdef XP_MACOSX
    nsresult IsRemoteDrawingCoreAnimation(bool *aDrawing);
#endif
#if defined(XP_MACOSX) || defined(XP_WIN)
    nsresult ContentsScaleFactorChanged(double aContentsScaleFactor);
#endif
    nsresult SetBackgroundUnknown();
    nsresult BeginUpdateBackground(const nsIntRect& aRect,
                                   DrawTarget** aDrawTarget);
    nsresult EndUpdateBackground(const nsIntRect& aRect);
#if defined(XP_WIN)
    nsresult SetScrollCaptureId(uint64_t aScrollCaptureId);
    nsresult GetScrollCaptureContainer(mozilla::layers::ImageContainer** aContainer);
#endif
    void DidComposite();

    bool IsUsingDirectDrawing();

    virtual PluginAsyncSurrogate* GetAsyncSurrogate() override;

    virtual PluginInstanceParent* GetInstance() override { return this; }

    static PluginInstanceParent* Cast(NPP instance,
                                      PluginAsyncSurrogate** aSurrogate = nullptr);

    // for IME hook
    virtual bool
    RecvGetCompositionString(const uint32_t& aIndex,
                             nsTArray<uint8_t>* aBuffer,
                             int32_t* aLength) override;
    virtual bool
    RecvSetCandidateWindow(
        const mozilla::widget::CandidateWindowPosition& aPosition) override;
    virtual bool
    RecvRequestCommitOrCancel(const bool& aCommitted) override;

    // for reserved shortcut key handling with windowed plugin on Windows
    nsresult HandledWindowedPluginKeyEvent(
      const mozilla::NativeEventData& aKeyEventData,
      bool aIsConsumed);
    virtual bool
    RecvOnWindowedPluginKeyEvent(
      const mozilla::NativeEventData& aKeyEventData) override;

private:
    // Create an appropriate platform surface for a background of size
    // |aSize|.  Return true if successful.
    bool CreateBackground(const nsIntSize& aSize);
    void DestroyBackground();
    SurfaceDescriptor BackgroundDescriptor() /*const*/;

    typedef mozilla::layers::ImageContainer ImageContainer;
    ImageContainer *GetImageContainer();

    virtual PPluginBackgroundDestroyerParent*
    AllocPPluginBackgroundDestroyerParent() override;

    virtual bool
    DeallocPPluginBackgroundDestroyerParent(PPluginBackgroundDestroyerParent* aActor) override;

    bool InternalGetValueForNPObject(NPNVariable aVariable,
                                     PPluginScriptableObjectParent** aValue,
                                     NPError* aResult);

    nsPluginInstanceOwner* GetOwner();

    void SetCurrentImage(layers::Image* aImage);

    // Update Telemetry with the current drawing model.
    void RecordDrawingModel();

private:
    PluginModuleParent* mParent;
    RefPtr<PluginAsyncSurrogate> mSurrogate;
    bool mUseSurrogate;
    NPP mNPP;
    const NPNetscapeFuncs* mNPNIface;
    nsCString mSrcAttribute;
    NPWindowType mWindowType;
    int16_t mDrawingModel;

    // Since plugins may request different drawing models to find a compatible
    // one, we only record the drawing model after a SetWindow call and if the
    // drawing model has changed.
    int mLastRecordedDrawingModel;

    nsDataHashtable<nsPtrHashKey<NPObject>, PluginScriptableObjectParent*> mScriptableObjects;

    // This is used to tell the compositor that it should invalidate the ImageLayer.
    uint32_t mFrameID;

#if defined(XP_WIN)
    // Note: DXGI 1.1 surface handles are global across all processes, and are not
    // marshaled. As long as we haven't freed a texture its handle should be valid
    // as a unique cross-process identifier for the texture.
    nsRefPtrHashtable<nsPtrHashKey<void>, D3D11SurfaceHolder> mD3D11Surfaces;
#endif

#if defined(OS_WIN)
private:
    // Used in handling parent/child forwarding of events.
    static LRESULT CALLBACK PluginWindowHookProc(HWND hWnd, UINT message,
                                                 WPARAM wParam, LPARAM lParam);
    void SubclassPluginWindow(HWND aWnd);
    void UnsubclassPluginWindow();

    bool MaybeCreateAndParentChildPluginWindow();
    void MaybeCreateChildPopupSurrogate();

private:
    nsIntRect          mPluginPort;
    nsIntRect          mSharedSize;
    HWND               mPluginHWND;
    // This is used for the normal child plugin HWND for windowed plugins and,
    // if needed, also the child popup surrogate HWND for windowless plugins.
    HWND               mChildPluginHWND;
    HWND               mChildPluginsParentHWND;
    WNDPROC            mPluginWndProc;
    bool               mNestedEventState;
#endif // defined(XP_WIN)
#if defined(MOZ_WIDGET_COCOA)
private:
    Shmem                  mShSurface; 
    uint16_t               mShWidth;
    uint16_t               mShHeight;
    CGColorSpaceRef        mShColorSpace;
    RefPtr<MacIOSurface> mIOSurface;
    RefPtr<MacIOSurface> mFrontIOSurface;
#endif // definied(MOZ_WIDGET_COCOA)

    // ObjectFrame layer wrapper
    RefPtr<gfxASurface>    mFrontSurface;
    // For windowless+transparent instances, this surface contains a
    // "pretty recent" copy of the pixels under its <object> frame.
    // On the plugin side, we use this surface to avoid doing alpha
    // recovery when possible.  This surface is created and owned by
    // the browser, but a "read-only" reference is sent to the plugin.
    //
    // We have explicitly chosen not to provide any guarantees about
    // the consistency of the pixels in |mBackground|.  A plugin may
    // be able to observe partial updates to the background.
    RefPtr<gfxASurface>    mBackground;

    RefPtr<ImageContainer> mImageContainer;
};


} // namespace plugins
} // namespace mozilla

#endif // ifndef dom_plugins_PluginInstanceParent_h