Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / content / test / plugin / plugin_npobject_lifetime_test.h
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_TEST_PLUGIN_PLUGIN_NPOBJECT_LIFETIME_TEST_H_
6 #define CONTENT_TEST_PLUGIN_PLUGIN_NPOBJECT_LIFETIME_TEST_H_
7
8 #include "base/compiler_specific.h"
9 #include "build/build_config.h"
10 #include "content/test/plugin/plugin_test.h"
11
12 namespace NPAPIClient {
13
14 // The NPObjectLifeTime class tests the case where a plugin has an NPObject
15 // which points to a different plugin instance on a different frame in the
16 // page and whether refcounts on this npobject are valid when the source frame
17 // is destroyed.
18 class NPObjectLifetimeTest : public PluginTest {
19  public:
20   // Constructor.
21   NPObjectLifetimeTest(NPP id, NPNetscapeFuncs *host_functions);
22
23   // NPAPI SetWindow handler.
24   NPError SetWindow(NPWindow* pNPWindow) override;
25
26   void URLNotify(const char* url, NPReason reason, void* data) override;
27
28  protected:
29   NPObject* other_plugin_instance_object_;
30
31 #if defined(OS_WIN)
32   static void CALLBACK TimerProc(HWND window, UINT message, UINT_PTR timer_id,
33                                  DWORD elapsed_milli_seconds);
34   UINT_PTR timer_id_;
35 #endif
36   DISALLOW_IMPLICIT_CONSTRUCTORS(NPObjectLifetimeTest);
37 };
38
39 // The NPObjectLifetimeTestInstance2 class represents the plugin instance
40 // which is deleted by the NPObjectLifeTime class via a javascript function.
41 class NPObjectLifetimeTestInstance2 : public PluginTest {
42  public:
43   // Constructor.
44   NPObjectLifetimeTestInstance2(NPP id, NPNetscapeFuncs *host_functions);
45   ~NPObjectLifetimeTestInstance2() override;
46
47   // NPAPI SetWindow handler.
48   NPError SetWindow(NPWindow* pNPWindow) override;
49
50  protected:
51   static NPObject* plugin_instance_object_;
52   friend class NPObjectLifetimeTest;
53
54   DISALLOW_IMPLICIT_CONSTRUCTORS(NPObjectLifetimeTestInstance2);
55 };
56
57 // The NPObjectLifeTime class tests the case where a plugin instance is
58 // destroyed in NPN_Evaluate
59 class NPObjectDeletePluginInNPN_Evaluate : public PluginTest {
60  public:
61   // Constructor.
62   NPObjectDeletePluginInNPN_Evaluate(NPP id, NPNetscapeFuncs *host_functions);
63   ~NPObjectDeletePluginInNPN_Evaluate() override;
64
65   // NPAPI SetWindow handler.
66   NPError SetWindow(NPWindow* pNPWindow) override;
67
68  protected:
69   NPObject* plugin_instance_object_;
70 #if defined(OS_WIN)
71   static void CALLBACK TimerProc(HWND window, UINT message, UINT_PTR timer_id,
72                                  DWORD elapsed_milli_seconds);
73   UINT_PTR timer_id_;
74 #endif
75
76  private:
77   static NPObjectDeletePluginInNPN_Evaluate* g_npn_evaluate_test_instance_;
78
79   DISALLOW_IMPLICIT_CONSTRUCTORS(NPObjectDeletePluginInNPN_Evaluate);
80 };
81
82 }  // namespace NPAPIClient
83
84 #endif  // CONTENT_TEST_PLUGIN_PLUGIN_NPOBJECT_LIFETIME_TEST_H_