~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2010 Apple Inc. All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions
 
6
 * are met:
 
7
 * 1. Redistributions of source code must retain the above copyright
 
8
 *    notice, this list of conditions and the following disclaimer.
 
9
 * 2. Redistributions in binary form must reproduce the above copyright
 
10
 *    notice, this list of conditions and the following disclaimer in the
 
11
 *    documentation and/or other materials provided with the distribution.
 
12
 *
 
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 
23
 * THE POSSIBILITY OF SUCH DAMAGE.
 
24
 */
 
25
 
 
26
#ifndef NPJSObjectWrapperMap_h
 
27
#define NPJSObjectWrapperMap_h
 
28
 
 
29
#if ENABLE(NETSCAPE_PLUGIN_API)
 
30
 
 
31
#include <WebCore/RunLoop.h>
 
32
#include <heap/Weak.h>
 
33
#include <wtf/Forward.h>
 
34
#include <wtf/HashMap.h>
 
35
 
 
36
struct NPObject;
 
37
typedef struct _NPVariant NPVariant;
 
38
 
 
39
namespace JSC {
 
40
    class ExecState;
 
41
    class JSGlobalData;
 
42
    class JSGlobalObject;
 
43
    class JSObject;
 
44
    class JSValue;
 
45
}
 
46
 
 
47
namespace WebKit {
 
48
 
 
49
class JSNPObject;
 
50
class NPJSObject;
 
51
class PluginView;
 
52
 
 
53
// A per plug-in map of NPObjects that wrap JavaScript objects.
 
54
class NPRuntimeObjectMap : private JSC::WeakHandleOwner {
 
55
public:
 
56
    explicit NPRuntimeObjectMap(PluginView*);
 
57
 
 
58
    class PluginProtector {
 
59
    public:
 
60
        explicit PluginProtector(NPRuntimeObjectMap* npRuntimeObjectMap);
 
61
        ~PluginProtector();
 
62
        
 
63
    private:
 
64
        RefPtr<PluginView> m_pluginView;
 
65
    };
 
66
 
 
67
    // Returns an NPObject that wraps the given JSObject object. If there is already an NPObject that wraps this JSObject, it will
 
68
    // retain it and return it.
 
69
    NPObject* getOrCreateNPObject(JSC::JSGlobalData&, JSC::JSObject*);
 
70
    void npJSObjectDestroyed(NPJSObject*);
 
71
 
 
72
    // Returns a JSObject object that wraps the given NPObject.
 
73
    JSC::JSObject* getOrCreateJSObject(JSC::JSGlobalObject*, NPObject*);
 
74
    void jsNPObjectDestroyed(JSNPObject*);
 
75
 
 
76
    void convertJSValueToNPVariant(JSC::ExecState*, JSC::JSValue, NPVariant&);
 
77
    JSC::JSValue convertNPVariantToJSValue(JSC::ExecState*, JSC::JSGlobalObject*, const NPVariant&);
 
78
 
 
79
    bool evaluate(NPObject*, const String& scriptString, NPVariant* result);
 
80
 
 
81
    // Called when the plug-in is destroyed. Will invalidate all the NPObjects.
 
82
    void invalidate();
 
83
 
 
84
    JSC::JSGlobalObject* globalObject() const;
 
85
    JSC::ExecState* globalExec() const;
 
86
 
 
87
    static void setGlobalException(const String& exceptionString);
 
88
    static void moveGlobalExceptionToExecState(JSC::ExecState*);
 
89
 
 
90
private:
 
91
    // WeakHandleOwner
 
92
    virtual void finalize(JSC::Handle<JSC::Unknown>, void* context);
 
93
    void addToInvalidationQueue(NPObject*);
 
94
    void invalidateQueuedObjects();
 
95
 
 
96
    PluginView* m_pluginView;
 
97
 
 
98
    HashMap<JSC::JSObject*, NPJSObject*> m_npJSObjects;
 
99
    HashMap<NPObject*, JSC::Weak<JSNPObject> > m_jsNPObjects;
 
100
    Vector<NPObject*> m_npObjectsToFinalize;
 
101
    WebCore::RunLoop::Timer<NPRuntimeObjectMap> m_finalizationTimer;
 
102
};
 
103
 
 
104
} // namespace WebKit
 
105
 
 
106
#endif // ENABLE(NETSCAPE_PLUGIN_API)
 
107
 
 
108
#endif // NPJSObjectWrapperMap_h