OLD | NEW |
| (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_ACTIVEX_PLUGIN_H__ | |
6 #define WEBKIT_ACTIVEX_SHIM_ACTIVEX_PLUGIN_H__ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 #include "base/scoped_ptr.h" | |
11 #include "webkit/glue/plugins/nphostapi.h" | |
12 #include "webkit/activex_shim/activex_shared.h" | |
13 #include "webkit/activex_shim/dispatch_object.h" | |
14 #include "webkit/activex_shim/npn_scripting.h" | |
15 #include "webkit/activex_shim/web_activex_container.h" | |
16 #include "webkit/activex_shim/web_activex_site.h" | |
17 | |
18 namespace activex_shim { | |
19 | |
20 // ActiveXPlugin, a host for ActiveX control. There is one ActiveXPlugin object | |
21 // for each ActiveX control. It handles NPAPI calls from the browser side | |
22 // and is responsible for most activities of the plugin. | |
23 class ActiveXPlugin : public DispatchObject { | |
24 public: | |
25 explicit ActiveXPlugin(NPP instance); | |
26 ~ActiveXPlugin(); | |
27 | |
28 // NPP API Processing. | |
29 NPError NPP_New(NPMIMEType plugin_type, int16 argc, char* argn[], | |
30 char* argv[], NPSavedData* saved); | |
31 NPError NPP_SetWindow(NPWindow* window); | |
32 NPError NPP_NewStream(NPMIMEType type, NPStream* stream, | |
33 NPBool seekable, uint16* stype); | |
34 NPError NPP_DestroyStream(NPStream* stream, NPReason reason); | |
35 int32 NPP_WriteReady(NPStream* stream); | |
36 int32 NPP_Write(NPStream* stream, int32 offset, int32 len, void* buffer); | |
37 void NPP_StreamAsFile(NPStream* stream, const char* fname); | |
38 void NPP_Print(NPPrint* platformPrint); | |
39 int16 NPP_HandleEvent(void* event); | |
40 void NPP_URLNotify(const char* url, NPReason reason, void* notifyData); | |
41 NPError NPP_GetValue(NPPVariable variable, void* value); | |
42 NPError NPP_SetValue(NPNVariable variable, void* value); | |
43 | |
44 void Draw(HDC dc, RECT* lprc, RECT* lpclip); | |
45 | |
46 // Get scriptable window object from the browser. | |
47 NPNScriptableObject GetWindow(); | |
48 // Retrieves the URL of current webpage from the browser. | |
49 std::wstring GetCurrentURL(); | |
50 // Resolves the relative URL (could be already an absolute URL too) to return | |
51 // full URL based on current document's URL and base. | |
52 std::wstring ResolveURL(const std::wstring& url); | |
53 bool windowless() { return windowless_; } | |
54 NPP npp() { return npp_; } | |
55 ActiveXTypes activex_type() { return activex_type_; } | |
56 | |
57 private: | |
58 // Process parameters passed in from browser. | |
59 void ProcessParams(int16 argc, char* argn[], char* argv[]); | |
60 // For handling wmp mime type, we need to initialize params differently | |
61 // (change src to corresponding param for wmp control), and set clsid to wmp. | |
62 void ConvertForEmbeddedWmp(); | |
63 | |
64 // Overrided functions of base class: DispatchObject. | |
65 virtual IDispatch* GetDispatch(); | |
66 virtual NPP GetNPP() { return npp_; } | |
67 virtual bool NPObjectOwnsMe() { return false; } | |
68 | |
69 // Event handlers for windowless plugin. | |
70 int16 HandlePaintEvent(HDC dc, NPRect* invalid_area); | |
71 int16 HandleInputEvent(uint32 msg, uint32 wparam, uint32 lparam); | |
72 | |
73 // Related NPP instance. | |
74 NPP npp_; | |
75 // Position of the control relative to the browser. | |
76 RECT rect_; | |
77 // Initialization parameters from param tags and object tag. | |
78 std::vector<ControlParam> params_; | |
79 // Clsid of the activex object. | |
80 std::wstring clsid_; | |
81 std::wstring codebase_; | |
82 // At this point every plugin has one container. It simplifies things. | |
83 scoped_ptr<WebActiveXContainer> container_; | |
84 // True if the control supports windowless and we are creating a windowless | |
85 // plugin. | |
86 bool windowless_; | |
87 // Have we ever tried to activate the control. | |
88 bool tried_activation_; | |
89 // Whether we have successfully created the control and activated it. | |
90 bool control_activated_; | |
91 // Initially this is not initialized. We assign it on the first call to | |
92 // GetWindow, then we will keep this copy. | |
93 NPNScriptableObject window_; | |
94 ActiveXTypes activex_type_; | |
95 // Cache of the current url. It is used very frequently. | |
96 std::wstring url_; | |
97 | |
98 DISALLOW_EVIL_CONSTRUCTORS(ActiveXPlugin); | |
99 }; | |
100 | |
101 } // namespace activex_shim | |
102 | |
103 #endif // #ifndef WEBKIT_ACTIVEX_SHIM_ACTIVEX_PLUGIN_H__ | |
OLD | NEW |