Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1039)

Side by Side Diff: webkit/activex_shim/dispatch_object.h

Issue 200031: Take out the activex control. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/activex_shim/activex_util.cc ('k') | webkit/activex_shim/dispatch_object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 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 WEBKIT_ACTIVEX_SHIM_DISPATCH_OBJECT_H__
6 #define WEBKIT_ACTIVEX_SHIM_DISPATCH_OBJECT_H__
7
8 #include <oaidl.h>
9
10 #include <list>
11
12 #include "webkit/glue/plugins/nphostapi.h"
13
14 namespace activex_shim {
15
16 struct DispatchNPObject;
17
18 // DispatchObject provides service to translate calls on NPObject to the
19 // underlying IDispatch interface. It is isolated from the ActiveXPlugin, so
20 // that when we have scripts like:
21 // wmp.controls.stop();
22 // We can create a spawned dispatch object for "controls" -- an IDispatch
23 // interface returned from property "controls" of the wmp activex control.
24 class DispatchObject {
25 public:
26 DispatchObject(DispatchObject* root);
27 virtual ~DispatchObject();
28
29 // This is used when NPP_GetValue is called by browser and asked for
30 // NPPVpluginScriptableNPObject.
31 NPObject* GetScriptableNPObject();
32
33 // Object scripting
34 NPObject* NPAllocate(NPClass* theClass);
35 void NPInvalidate();
36 bool NPHasMethod(NPIdentifier name);
37 bool NPHasProperty(NPIdentifier name);
38 bool NPInvoke(NPIdentifier name, const NPVariant* args,
39 uint32_t argCount, NPVariant* result);
40 bool NPInvokeDefault(const NPVariant* args, uint32_t argCount,
41 NPVariant* result);
42 bool NPGetProperty(NPIdentifier name, NPVariant* variant);
43 bool NPSetProperty(NPIdentifier name, const NPVariant* variant);
44 bool NPRemoveProperty(NPIdentifier propertyName);
45
46 // Called by NPDeallocate so that we can remove our reference.
47 void OnDeallocateObject(DispatchNPObject* obj);
48 DispatchObject* root() { return root_== NULL ? this : root_; }
49 // Only the root object needs to take care of this.
50 void AddSpawned(DispatchObject* obj);
51 // If a spawned child is released earlier than the root object, it needs to
52 // call this function to remove itself from the children list, to avoid
53 // another destruction when the root object is being destructed.
54 void RemoveSpawned(DispatchObject* obj);
55
56 protected:
57 // Only the root object can release spawned dispatch object. The root object
58 // is coupled with the actual ActiveX control. Thus if the control is dead
59 // we must also release all Dispatch interfaces from that control.
60 void ReleaseSpawned();
61 // root_ is the owner of this object. If root_ == NULL, then this object
62 // itself is the root.
63 DispatchObject* const root_;
64
65 private:
66 typedef std::list<DispatchObject*> SpawnedChildrenList;
67
68 // Must be overrided by subclass to be functional.
69 virtual IDispatch* GetDispatch() = 0;
70 // If this is true, when the related npobject is released, it should delete
71 // this object as well.
72 virtual bool NPObjectOwnsMe() = 0;
73
74 // We create only one NPObject per ActiveXPlugin. It may have different life
75 // span than ActiveXPlugin thus we need a separate object created
76 // specifically for this purpose.
77 DispatchNPObject* npobject_;
78 // A list of spawned children from this root object (if it is).
79 SpawnedChildrenList spawned_children_;
80 bool deleting_spawned_children_;
81 };
82
83 // The spawned dipatch object contains a reference to an IDispatch interface
84 // that it owns. Its lifetime is controlled by the lifetime of related
85 // NPObject, and the root DispatchObject it is spawned from.
86 class SpawnedDispatchObject : public DispatchObject {
87 public:
88 // Constructor will addref to the dispatch interface, and add itself to
89 // spawned children of root.
90 SpawnedDispatchObject(IDispatch* dispatch, DispatchObject* root);
91 ~SpawnedDispatchObject();
92
93 private:
94 virtual IDispatch* GetDispatch() { return dispatch_; }
95 virtual bool NPObjectOwnsMe() { return true; }
96
97 IDispatch* dispatch_;
98 };
99
100 // A simple extension of the NPObject. So that we can put additional information
101 // like who is the underlying DispatchObject with the NPObject. When methods of
102 // NPObject are requested we can resort to the DispatchObject to handle them.
103 struct DispatchNPObject : public NPObject {
104 DispatchObject* dispatch_object;
105 };
106
107 // These functions are to support scriptable plugin object.
108 NPObject* NPAllocate(NPP npp, NPClass* theClass);
109 void NPDeallocate(NPObject* obj);
110 void NPInvalidate(NPObject* obj);
111 bool NPHasMethod(NPObject* obj, NPIdentifier name);
112 bool NPInvoke(NPObject* obj, NPIdentifier name, const NPVariant* args,
113 uint32_t argCount, NPVariant* result);
114 bool NPInvokeDefault(NPObject* obj, const NPVariant* args, uint32_t argCount,
115 NPVariant* result);
116 bool NPHasProperty(NPObject* obj, NPIdentifier name);
117 bool NPGetProperty(NPObject* obj, NPIdentifier name, NPVariant* variant);
118 bool NPSetProperty(NPObject* obj, NPIdentifier name, const NPVariant* variant);
119 bool NPRemoveProperty(NPObject* npobj, NPIdentifier propertyName);
120
121 } // namespace activex_shim
122
123 #endif // #ifndef WEBKIT_ACTIVEX_SHIM_DISPATCH_OBJECT_H__
OLDNEW
« no previous file with comments | « webkit/activex_shim/activex_util.cc ('k') | webkit/activex_shim/dispatch_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698