OLD | NEW |
| (Empty) |
1 // Copyright 2010 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 // | |
16 // NpFunctionHost hosts an NPObject inside an IDispatch interface to allow | |
17 // invoking NPAPI functions from a COM environment. Types are automatically | |
18 // marshalled between NPVariant and VARIANT using the functions in | |
19 // variant_utils.h. (For the reverse -- providing an NPObject interface to | |
20 // a COM object implementing IDispatch -- see DispatchHost.) | |
21 // | |
22 // Note that this currently only supports functions; this does not currently | |
23 // support objects. NPN_Enumerate() only provides method/property names, | |
24 // not return types or argument counts/types, which makes it impossible to | |
25 // properly implement IDispatch::GetTypeInfo(). (However, we can implement | |
26 // GetIDsOfNames() if we need it in the future.) | |
27 | |
28 #ifndef OMAHA_PLUGINS_UPDATE_NPAPI_NPFUNCTION_HOST_H_ | |
29 #define OMAHA_PLUGINS_UPDATE_NPAPI_NPFUNCTION_HOST_H_ | |
30 | |
31 #include <atlbase.h> | |
32 #include <atlcom.h> | |
33 | |
34 #include "base/basictypes.h" | |
35 #include "third_party/npapi/bindings/nphostapi.h" | |
36 | |
37 namespace omaha { | |
38 | |
39 class NpFunctionHostTest; | |
40 | |
41 class ATL_NO_VTABLE NpFunctionHost | |
42 : public CComObjectRootEx<CComObjectThreadModel>, | |
43 public IDispatch { | |
44 public: | |
45 static HRESULT Create(NPP npp, NPObject* npobj, IDispatch** host); | |
46 | |
47 BEGIN_COM_MAP(NpFunctionHost) | |
48 COM_INTERFACE_ENTRY(IDispatch) | |
49 END_COM_MAP() | |
50 | |
51 // IDispatch methods. | |
52 STDMETHOD(GetTypeInfoCount)(UINT* pctinfo); | |
53 STDMETHOD(GetTypeInfo)(UINT iTInfo, | |
54 LCID lcid, | |
55 ITypeInfo** ppTInfo); | |
56 STDMETHOD(GetIDsOfNames)(REFIID riid, | |
57 LPOLESTR* rgszNames, | |
58 UINT cNames, | |
59 LCID lcid, | |
60 DISPID* rgDispId); | |
61 STDMETHOD(Invoke)(DISPID dispIdMember, | |
62 REFIID riid, | |
63 LCID lcid, | |
64 WORD wFlags, | |
65 DISPPARAMS* pDispParams, | |
66 VARIANT* pVarResult, | |
67 EXCEPINFO* pExcepInfo, | |
68 UINT* puArgErr); | |
69 | |
70 // CComObjectRootEx overrides. | |
71 void FinalRelease(); | |
72 | |
73 protected: | |
74 NpFunctionHost(); | |
75 virtual ~NpFunctionHost() {} | |
76 | |
77 private: | |
78 NPP npp_; | |
79 NPObject* obj_; | |
80 | |
81 DISALLOW_COPY_AND_ASSIGN(NpFunctionHost); | |
82 }; | |
83 | |
84 } // namespace omaha | |
85 | |
86 #endif // OMAHA_PLUGINS_UPDATE_NPAPI_NPFUNCTION_HOST_H_ | |
OLD | NEW |