1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_TEST_ACTIVEX_TEST_CONTROL_CHROME_TEST_CONTROL_H__
#define CHROME_TEST_ACTIVEX_TEST_CONTROL_CHROME_TEST_CONTROL_H__
#include <atlbase.h>
#include <atlcom.h>
#include <atlctl.h>
#include <comutil.h>
#include "activex_test_control.h"
#include "chrome/test/activex_test_control/chrome_test_control_cp.h"
#include "chrome/test/activex_test_control/resource.h"
// ChromeTestControl
class ATL_NO_VTABLE ChromeTestControl
: public CComObjectRootEx<CComSingleThreadModel>,
public CStockPropImpl<ChromeTestControl, IChromeTestControl>,
public IPersistStreamInitImpl<ChromeTestControl>,
public IOleControlImpl<ChromeTestControl>,
public IOleObjectImpl<ChromeTestControl>,
public IOleInPlaceActiveObjectImpl<ChromeTestControl>,
public IViewObjectExImpl<ChromeTestControl>,
public IOleInPlaceObjectWindowlessImpl<ChromeTestControl>,
public ISupportErrorInfo,
public IConnectionPointContainerImpl<ChromeTestControl>,
public CProxy_IChromeTestControlEvents<ChromeTestControl>,
public IObjectWithSiteImpl<ChromeTestControl>,
public IServiceProviderImpl<ChromeTestControl>,
public IPersistStorageImpl<ChromeTestControl>,
public ISpecifyPropertyPagesImpl<ChromeTestControl>,
public IQuickActivateImpl<ChromeTestControl>,
public IDataObjectImpl<ChromeTestControl>,
public IProvideClassInfo2Impl<&CLSID_ChromeTestControl,
&__uuidof(_IChromeTestControlEvents), &LIBID_activex_test_controlLib>,
public IPropertyNotifySinkCP<ChromeTestControl>,
public IObjectSafetyImpl<ChromeTestControl,
INTERFACESAFE_FOR_UNTRUSTED_CALLER |
INTERFACESAFE_FOR_UNTRUSTED_DATA>,
public CComCoClass<ChromeTestControl, &CLSID_ChromeTestControl>,
public CComControl<ChromeTestControl> {
public:
ChromeTestControl() {
}
DECLARE_OLEMISC_STATUS(OLEMISC_RECOMPOSEONRESIZE |
OLEMISC_CANTLINKINSIDE |
OLEMISC_INSIDEOUT |
OLEMISC_ACTIVATEWHENVISIBLE |
OLEMISC_SETCLIENTSITEFIRST)
DECLARE_REGISTRY_RESOURCEID(IDR_CHROMETESTCONTROL)
BEGIN_COM_MAP(ChromeTestControl)
COM_INTERFACE_ENTRY(IChromeTestControl)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IViewObjectEx)
COM_INTERFACE_ENTRY(IViewObject2)
COM_INTERFACE_ENTRY(IViewObject)
COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
COM_INTERFACE_ENTRY(IOleInPlaceObject)
COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
COM_INTERFACE_ENTRY(IOleControl)
COM_INTERFACE_ENTRY(IOleObject)
COM_INTERFACE_ENTRY(IPersistStreamInit)
COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
COM_INTERFACE_ENTRY(IQuickActivate)
COM_INTERFACE_ENTRY(IPersistStorage)
COM_INTERFACE_ENTRY(IDataObject)
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
COM_INTERFACE_ENTRY(IObjectWithSite)
COM_INTERFACE_ENTRY(IServiceProvider)
COM_INTERFACE_ENTRY_IID(IID_IObjectSafety, IObjectSafety)
END_COM_MAP()
BEGIN_PROP_MAP(ChromeTestControl)
PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
PROP_ENTRY_TYPE("BackColor", DISPID_BACKCOLOR, CLSID_StockColorPage,
VT_COLOR)
PROP_ENTRY_TYPE("BorderColor", DISPID_BORDERCOLOR, CLSID_StockColorPage,
VT_COLOR)
PROP_ENTRY_TYPE("Caption", DISPID_CAPTION, CLSID_NULL, VT_BSTR)
PROP_ENTRY_TYPE("ForeColor", DISPID_FORECOLOR, CLSID_StockColorPage, VT_COLOR)
// Example entries
// PROP_ENTRY("Property Description", dispid, clsid)
// PROP_PAGE(CLSID_StockColorPage)
END_PROP_MAP()
BEGIN_CONNECTION_POINT_MAP(ChromeTestControl)
CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink)
CONNECTION_POINT_ENTRY(__uuidof(_IChromeTestControlEvents))
END_CONNECTION_POINT_MAP()
BEGIN_MSG_MAP(ChromeTestControl)
CHAIN_MSG_MAP(CComControl<ChromeTestControl>)
DEFAULT_REFLECTION_HANDLER()
END_MSG_MAP()
// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid) {
static const IID* arr[] = {
&IID_IChromeTestControl,
};
for (int i=0; i<sizeof(arr)/sizeof(arr[0]); i++) {
if (InlineIsEqualGUID(*arr[i], riid))
return S_OK;
}
return S_FALSE;
}
// IViewObjectEx
DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
// IChromeTestControl
public:
HRESULT OnDraw(ATL_DRAWINFO& di);
void OnBackColorChanged() {
ATLTRACE(_T("OnBackColorChanged\n"));
}
void OnBorderColorChanged() {
ATLTRACE(_T("OnBorderColorChanged\n"));
}
void OnCaptionChanged() {
ATLTRACE(_T("OnCaptionChanged\n"));
}
void OnForeColorChanged() {
ATLTRACE(_T("OnForeColorChanged\n"));
}
STDMETHOD(_InternalQueryService)(REFGUID guidService, REFIID riid,
void** ppvObject) {
return E_NOTIMPL;
}
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct() {
return S_OK;
}
void FinalRelease() {
}
STDMETHOD(get_StringProp)(BSTR* val) {
*val = string_prop_.copy();
return S_OK;
}
STDMETHOD(put_StringProp)(BSTR val) {
string_prop_ = val;
return S_OK;
}
STDMETHOD(get_LongProp)(LONG* val) {
*val = long_prop_;
return S_OK;
}
STDMETHOD(put_LongProp)(LONG val) {
long_prop_ = val;
return S_OK;
}
STDMETHOD(get_DoubleProp)(DOUBLE* val) {
*val = double_prop_;
return S_OK;
}
STDMETHOD(put_DoubleProp)(DOUBLE val) {
double_prop_ = val;
return S_OK;
}
STDMETHOD(get_BoolProp)(VARIANT_BOOL* val) {
*val = bool_prop_;
return S_OK;
}
STDMETHOD(put_BoolProp)(VARIANT_BOOL val) {
bool_prop_ = val;
return S_OK;
}
STDMETHOD(get_ByteProp)(BYTE* val) {
*val = byte_prop_;
return S_OK;
}
STDMETHOD(put_ByteProp)(BYTE val) {
byte_prop_ = val;
return S_OK;
}
STDMETHOD(get_FloatProp)(FLOAT* val) {
*val = float_prop_;
return S_OK;
}
STDMETHOD(put_FloatProp)(FLOAT val) {
float_prop_ = val;
return S_OK;
}
STDMETHOD(SetByte)(BYTE val) {
byte_prop_ = val;
return S_OK;
}
STDMETHOD(SetByteRet)(BYTE val, BYTE* ret) {
byte_prop_ = val;
*ret = val;
return S_OK;
}
STDMETHOD(SetStringRet)(BSTR val, BSTR* ret) {
string_prop_ = val;
*ret = string_prop_.copy();
return S_OK;
}
STDMETHOD(BigSetMethodRet)(BSTR string_param, BYTE byte_param,
FLOAT float_param, VARIANT_BOOL bool_param,
BSTR* ret) {
string_prop_ = string_param;
byte_prop_ = byte_param;
float_prop_ = float_param;
bool_prop_ = bool_param;
*ret = SysAllocString(string_param);
return S_OK;
}
STDMETHOD(GetCookie)(BSTR* cookie) {
CComPtr<IOleContainer> container;
m_spClientSite->GetContainer(&container);
CComQIPtr<IHTMLDocument2> doc = container;
if (doc == NULL) {
*cookie = SysAllocString(L"Bad");
return S_FALSE;
} else {
return doc->get_cookie(cookie);
}
}
// These varialbes are used by CStockPropImpl invisibly and they have to be
// be public to be accessible.
OLE_COLOR m_clrBackColor;
OLE_COLOR m_clrBorderColor;
CComBSTR m_bstrCaption;
OLE_COLOR m_clrForeColor;
private:
_bstr_t string_prop_;
LONG long_prop_;
DOUBLE double_prop_;
VARIANT_BOOL bool_prop_;
BYTE byte_prop_;
FLOAT float_prop_;
};
OBJECT_ENTRY_AUTO(__uuidof(ChromeTestControl), ChromeTestControl)
#endif // #ifndef CHROME_TEST_ACTIVEX_TEST_CONTROL_CHROME_TEST_CONTROL_H__
|