Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/nsPluginNativeWindow.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#ifndef _nsPluginNativeWindow_h_
7
#define _nsPluginNativeWindow_h_
8
9
#include "nscore.h"
10
#include "nsCOMPtr.h"
11
#include "nsISupportsImpl.h"
12
#include "nsNPAPIPluginInstance.h"
13
#include "npapi.h"
14
#include "nsIWidget.h"
15
16
/**
17
 * base class for native plugin window implementations
18
 */
19
class nsPluginNativeWindow : public NPWindow
20
{
21
public:
22
  nsPluginNativeWindow() : NPWindow() {
23
    MOZ_COUNT_CTOR(nsPluginNativeWindow);
24
  }
25
26
  virtual ~nsPluginNativeWindow() {
27
    MOZ_COUNT_DTOR(nsPluginNativeWindow);
28
  }
29
30
  /**
31
   *   !!! CAUTION !!!
32
   *
33
   * The base class |nsPluginWindow| is defined as a struct in nsplugindefs.h,
34
   * thus it does not have a destructor of its own.
35
   * One should never attempt to delete |nsPluginNativeWindow| object instance
36
   * (or derivatives) using a pointer of |nsPluginWindow *| type. Should such
37
   * necessity occur it must be properly casted first.
38
   */
39
40
public:
41
0
  nsresult GetPluginInstance(RefPtr<nsNPAPIPluginInstance> &aPluginInstance) {
42
0
    aPluginInstance = mPluginInstance;
43
0
    return NS_OK;
44
0
  }
45
  nsresult SetPluginInstance(nsNPAPIPluginInstance *aPluginInstance) {
46
    if (mPluginInstance != aPluginInstance)
47
      mPluginInstance = aPluginInstance;
48
    return NS_OK;
49
  }
50
51
0
  nsresult GetPluginWidget(nsIWidget **aWidget) const {
52
0
    NS_IF_ADDREF(*aWidget = mWidget);
53
0
    return NS_OK;
54
0
  }
55
  nsresult SetPluginWidget(nsIWidget *aWidget) {
56
    mWidget = aWidget;
57
    return NS_OK;
58
  }
59
60
public:
61
  virtual nsresult CallSetWindow(RefPtr<nsNPAPIPluginInstance> &aPluginInstance) {
62
    // null aPluginInstance means that we want to call SetWindow(null)
63
    if (aPluginInstance)
64
      aPluginInstance->SetWindow(this);
65
    else if (mPluginInstance)
66
      mPluginInstance->SetWindow(nullptr);
67
68
    SetPluginInstance(aPluginInstance);
69
    return NS_OK;
70
  }
71
72
protected:
73
  RefPtr<nsNPAPIPluginInstance> mPluginInstance;
74
  nsCOMPtr<nsIWidget> mWidget;
75
};
76
77
nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow);
78
nsresult PLUG_DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow);
79
80
#endif //_nsPluginNativeWindow_h_