| 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_WEB_ACTIVEX_SITE_H__ | |
| 6 #define WEBKIT_ACTIVEX_SHIM_WEB_ACTIVEX_SITE_H__ | |
| 7 | |
| 8 #include <objsafe.h> | |
| 9 #include <map> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/scoped_comptr_win.h" | |
| 13 #include "webkit/activex_shim/activex_util.h" | |
| 14 | |
| 15 namespace activex_shim { | |
| 16 | |
| 17 class WebActiveXContainer; | |
| 18 class ActiveXPlugin; | |
| 19 | |
| 20 // Control creation parameters | |
| 21 struct ControlParam { | |
| 22 ControlParam(const std::wstring& new_name, const std::wstring& new_value) { | |
| 23 name = new_name; | |
| 24 value = new_value; | |
| 25 } | |
| 26 ControlParam() { } | |
| 27 std::wstring name; | |
| 28 std::wstring value; | |
| 29 }; | |
| 30 | |
| 31 // ActiveX control site to receive requests etc from the ActiveX control, | |
| 32 // and interact the container to host a control. | |
| 33 // Implemented interfaces: | |
| 34 // IDispatch: | |
| 35 // Required for ambient properties. | |
| 36 // IOleClientSite: | |
| 37 // Required interface. | |
| 38 // IOleControlSite: | |
| 39 // Required interface. | |
| 40 // IOleInPlaceSiteWindowless: | |
| 41 // Required for windowless activation. | |
| 42 // IServiceProvider: | |
| 43 // Some controls use this interface to get interface to the IBindHost, | |
| 44 // IWebBrowserApp interfaces. e.g., Flash needs the IBindHost to create | |
| 45 // a moniker to the movie. Thus this is a required interface. | |
| 46 // IPropertyBag: | |
| 47 // If the control supports IPersistPropertyBag, we could use this interface | |
| 48 // to initialize the control with param values. | |
| 49 class WebActiveXSite : public MinimumIDispatchImpl, | |
| 50 public IOleClientSite, | |
| 51 public IOleControlSite, | |
| 52 public IOleInPlaceSiteWindowless, | |
| 53 public IServiceProvider, | |
| 54 public IPropertyBag, | |
| 55 public IPropertyBag2 { | |
| 56 public: | |
| 57 WebActiveXSite(); | |
| 58 // It's necessary to make it virtual because we do not directly create | |
| 59 // this object. Instead we usually create NoRefIUnknownImpl<WebActiveXSite> | |
| 60 virtual ~WebActiveXSite(); | |
| 61 | |
| 62 // Container calls this to init a site. The container should assume passing | |
| 63 // the ownership of IUnknown to site, and not try to release control there | |
| 64 // after. Site will release control in FinalRelease. | |
| 65 void Init(WebActiveXContainer* container, IUnknown* control); | |
| 66 // Deactive and release ActiveX control. Cleanup everything. | |
| 67 void FinalRelease(); | |
| 68 // Sets the extent of the control, params and inplace activates it. | |
| 69 HRESULT ActivateControl(int x, int y, int width, int height, | |
| 70 const std::vector<ControlParam>& params); | |
| 71 // A simplified version of calling control's DoVerb. | |
| 72 HRESULT DoVerb(long verb); | |
| 73 // Changes the position/size of the control. The container/plugin is | |
| 74 // responsible to call this everytime the control's position/size changed. | |
| 75 void SetRect(const RECT* rect); | |
| 76 | |
| 77 // IUnknown | |
| 78 virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, | |
| 79 void** object); | |
| 80 | |
| 81 // IOleClientSite | |
| 82 virtual HRESULT STDMETHODCALLTYPE SaveObject(); | |
| 83 virtual HRESULT STDMETHODCALLTYPE GetMoniker( | |
| 84 DWORD assign, | |
| 85 DWORD which_moniker, | |
| 86 IMoniker** moniker); | |
| 87 virtual HRESULT STDMETHODCALLTYPE GetContainer(IOleContainer** container); | |
| 88 virtual HRESULT STDMETHODCALLTYPE ShowObject(); | |
| 89 virtual HRESULT STDMETHODCALLTYPE OnShowWindow(BOOL show); | |
| 90 virtual HRESULT STDMETHODCALLTYPE RequestNewObjectLayout(); | |
| 91 | |
| 92 // IOleControlSite | |
| 93 virtual HRESULT STDMETHODCALLTYPE OnControlInfoChanged(); | |
| 94 virtual HRESULT STDMETHODCALLTYPE LockInPlaceActive(BOOL lock); | |
| 95 virtual HRESULT STDMETHODCALLTYPE GetExtendedControl(IDispatch** disp); | |
| 96 virtual HRESULT STDMETHODCALLTYPE TransformCoords(POINTL* ptl_himetric, | |
| 97 POINTF* ptf_container, | |
| 98 DWORD flags); | |
| 99 virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator(MSG* msg, | |
| 100 DWORD modifiers); | |
| 101 virtual HRESULT STDMETHODCALLTYPE OnFocus(BOOL got_focus); | |
| 102 virtual HRESULT STDMETHODCALLTYPE ShowPropertyFrame(); | |
| 103 | |
| 104 // IOleWindow | |
| 105 virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND* wnd); | |
| 106 virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL enter_mode); | |
| 107 | |
| 108 // IOleInPlaceSite | |
| 109 virtual HRESULT STDMETHODCALLTYPE CanInPlaceActivate(); | |
| 110 virtual HRESULT STDMETHODCALLTYPE OnInPlaceActivate(); | |
| 111 virtual HRESULT STDMETHODCALLTYPE OnUIActivate(); | |
| 112 virtual HRESULT STDMETHODCALLTYPE GetWindowContext( | |
| 113 IOleInPlaceFrame** frame, | |
| 114 IOleInPlaceUIWindow** doc, | |
| 115 LPRECT pos, | |
| 116 LPRECT clip, | |
| 117 LPOLEINPLACEFRAMEINFO frame_info); | |
| 118 virtual HRESULT STDMETHODCALLTYPE Scroll(SIZE scroll_extant); | |
| 119 virtual HRESULT STDMETHODCALLTYPE OnUIDeactivate(BOOL undoable); | |
| 120 virtual HRESULT STDMETHODCALLTYPE OnInPlaceDeactivate(); | |
| 121 virtual HRESULT STDMETHODCALLTYPE DiscardUndoState(); | |
| 122 virtual HRESULT STDMETHODCALLTYPE DeactivateAndUndo(); | |
| 123 virtual HRESULT STDMETHODCALLTYPE OnPosRectChange(LPCRECT pos); | |
| 124 | |
| 125 // IOleInPlaceSiteEx | |
| 126 virtual HRESULT STDMETHODCALLTYPE OnInPlaceActivateEx( | |
| 127 BOOL* no_redraw, | |
| 128 DWORD flags); | |
| 129 virtual HRESULT STDMETHODCALLTYPE OnInPlaceDeactivateEx(BOOL no_redraw); | |
| 130 virtual HRESULT STDMETHODCALLTYPE RequestUIActivate(); | |
| 131 | |
| 132 // IOleInPlaceSiteWindowless | |
| 133 virtual HRESULT STDMETHODCALLTYPE CanWindowlessActivate(); | |
| 134 virtual HRESULT STDMETHODCALLTYPE GetCapture(); | |
| 135 virtual HRESULT STDMETHODCALLTYPE SetCapture(BOOL capture); | |
| 136 virtual HRESULT STDMETHODCALLTYPE GetFocus(); | |
| 137 virtual HRESULT STDMETHODCALLTYPE SetFocus(BOOL focus); | |
| 138 virtual HRESULT STDMETHODCALLTYPE GetDC( | |
| 139 LPCRECT rect, | |
| 140 DWORD flags, | |
| 141 HDC* dc); | |
| 142 virtual HRESULT STDMETHODCALLTYPE ReleaseDC(HDC dc); | |
| 143 virtual HRESULT STDMETHODCALLTYPE InvalidateRect( | |
| 144 LPCRECT rect, | |
| 145 BOOL erase); | |
| 146 virtual HRESULT STDMETHODCALLTYPE InvalidateRgn( | |
| 147 HRGN rgn, | |
| 148 BOOL erase); | |
| 149 virtual HRESULT STDMETHODCALLTYPE ScrollRect( | |
| 150 INT dx, | |
| 151 INT dy, | |
| 152 LPCRECT scroll, | |
| 153 LPCRECT clip); | |
| 154 virtual HRESULT STDMETHODCALLTYPE AdjustRect(LPRECT rc); | |
| 155 virtual HRESULT STDMETHODCALLTYPE OnDefWindowMessage( | |
| 156 UINT msg, | |
| 157 WPARAM wparam, | |
| 158 LPARAM lparam, | |
| 159 LRESULT* result); | |
| 160 | |
| 161 // IServiceProvider | |
| 162 virtual HRESULT STDMETHODCALLTYPE QueryService( | |
| 163 REFGUID guid, | |
| 164 REFIID riid, | |
| 165 void** object); | |
| 166 | |
| 167 // IPropertyBag | |
| 168 virtual HRESULT STDMETHODCALLTYPE Read(LPCOLESTR prop_name, VARIANT* var, | |
| 169 IErrorLog* err_log); | |
| 170 virtual HRESULT STDMETHODCALLTYPE Write(LPCOLESTR prop_name, VARIANT* var); | |
| 171 | |
| 172 // IPropertyBag2 | |
| 173 virtual HRESULT STDMETHODCALLTYPE Read(ULONG c_properties, | |
| 174 PROPBAG2* prop_bag, | |
| 175 IErrorLog* err_log, | |
| 176 VARIANT* value, | |
| 177 HRESULT* error); | |
| 178 virtual HRESULT STDMETHODCALLTYPE Write(ULONG c_properties, | |
| 179 PROPBAG2* prop_bag, | |
| 180 VARIANT* value); | |
| 181 virtual HRESULT STDMETHODCALLTYPE CountProperties(ULONG* c_properties); | |
| 182 virtual HRESULT STDMETHODCALLTYPE GetPropertyInfo(ULONG iproperty, | |
| 183 ULONG c_properties, | |
| 184 PROPBAG2* prop_bag, | |
| 185 ULONG* properties_returned); | |
| 186 virtual HRESULT STDMETHODCALLTYPE LoadObject(LPCOLESTR pstr_name, | |
| 187 DWORD hint, | |
| 188 IUnknown* unk_object, | |
| 189 IErrorLog* err_log); | |
| 190 | |
| 191 friend WebActiveXContainer; | |
| 192 friend ActiveXPlugin; | |
| 193 | |
| 194 private: | |
| 195 // Call IOleObject::SetExtent to change the size of the control. width and | |
| 196 // height should be in pixels. | |
| 197 HRESULT SetExtent(int width, int height); | |
| 198 | |
| 199 WebActiveXContainer* container_; | |
| 200 // Theorectically the control could support only IUnknown interface. This is | |
| 201 // the minimum requirement. | |
| 202 ScopedComPtr<IUnknown> control_; | |
| 203 // These are all optional interfaces and they could be NULL even if we have | |
| 204 // created the control successfully. | |
| 205 ScopedComPtr<IDispatch> dispatch_; | |
| 206 ScopedComPtr<IOleObject> ole_object_; | |
| 207 ScopedComPtr<IOleInPlaceObject> inplace_object_; | |
| 208 ScopedComPtr<IViewObject> view_object_; | |
| 209 ScopedComPtr<IOleInPlaceObjectWindowless> inplace_object_windowless_; | |
| 210 RECT rect_; | |
| 211 // We need to remember whether we are activated so we can decide whether to | |
| 212 // deactivate during destruction. | |
| 213 bool inplace_activated_; | |
| 214 bool has_capture_; | |
| 215 // We need to save the initial properties so that during control | |
| 216 // initialization, the control can query us (IPropertyBag) for those | |
| 217 // properties. | |
| 218 std::vector<ControlParam> initial_params_; | |
| 219 | |
| 220 DISALLOW_EVIL_CONSTRUCTORS(WebActiveXSite); | |
| 221 }; | |
| 222 | |
| 223 } // namespace activex_shim | |
| 224 | |
| 225 #endif // #ifndef WEBKIT_ACTIVEX_SHIM_WEB_ACTIVEX_SITE_H__ | |
| OLD | NEW |