Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1268 lines
52 KiB

  1. #include "dhuihand.h"
  2. #include "iface.h"
  3. #include "dspsprt.h"
  4. #include "privacyui.hpp"
  5. #ifdef UNIX
  6. #define MAIL_ACTION_SEND 1
  7. #define MAIL_ACTION_READ 2
  8. #endif
  9. #define MAX_SCRIPT_ERR_CACHE_SIZE 20
  10. class CDocObjectHost;
  11. interface IToolbarExt;
  12. interface IHTMLPrivateWindow;
  13. interface IPrivacyServices;
  14. //
  15. // script error handling
  16. // support for caching errors and displaying them when the script error icon
  17. // on the status bar is clicked by the user
  18. //
  19. class CScriptErrorList : public CImpIDispatch,
  20. public IScriptErrorList
  21. {
  22. public:
  23. CScriptErrorList();
  24. ~CScriptErrorList();
  25. BOOL IsEmpty()
  26. { return _hdpa != NULL && DPA_GetPtrCount(_hdpa) == 0; }
  27. BOOL IsFull()
  28. { return _hdpa != NULL && DPA_GetPtrCount(_hdpa) >= MAX_SCRIPT_ERR_CACHE_SIZE; }
  29. HRESULT AddNewErrorInfo(LONG lLine,
  30. LONG lChar,
  31. LONG lCode,
  32. BSTR strMsg,
  33. BSTR strUrl);
  34. void ClearErrorList();
  35. // IUnknown
  36. STDMETHODIMP QueryInterface(REFIID, void **);
  37. STDMETHODIMP_(ULONG) AddRef();
  38. STDMETHODIMP_(ULONG) Release();
  39. // IDispatch
  40. STDMETHODIMP GetTypeInfoCount(UINT * pctinfo)
  41. { return CImpIDispatch::GetTypeInfoCount(pctinfo); }
  42. STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo * * pptinfo)
  43. { return CImpIDispatch::GetTypeInfo(itinfo, lcid, pptinfo); }
  44. STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR * * rgszNames, UINT cNames, LCID lcid, DISPID * rgdispid)
  45. { return CImpIDispatch::GetIDsOfNames(riid, rgszNames, cNames, lcid, rgdispid); }
  46. STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo, UINT * puArgErr)
  47. { return CImpIDispatch::Invoke(dispidMember, riid, lcid, wFlags, pdispparams, pvarResult, pexcepinfo, puArgErr); }
  48. // IScriptErrorList
  49. STDMETHODIMP advanceError();
  50. STDMETHODIMP retreatError();
  51. STDMETHODIMP canAdvanceError(BOOL * pfCanAdvance);
  52. STDMETHODIMP canRetreatError(BOOL * pfCanRetreat);
  53. STDMETHODIMP getErrorLine(LONG * plLine);
  54. STDMETHODIMP getErrorChar(LONG * plChar);
  55. STDMETHODIMP getErrorCode(LONG * plCode);
  56. STDMETHODIMP getErrorMsg(BSTR * pstrMsg);
  57. STDMETHODIMP getErrorUrl(BSTR * pstrUrl);
  58. STDMETHODIMP getAlwaysShowLockState(BOOL * pfAlwaysShowLock);
  59. STDMETHODIMP getDetailsPaneOpen(BOOL * pfDetailsPaneOpen);
  60. STDMETHODIMP setDetailsPaneOpen(BOOL fDetailsPaneOpen);
  61. STDMETHODIMP getPerErrorDisplay(BOOL * pfPerErrorDisplay);
  62. STDMETHODIMP setPerErrorDisplay(BOOL fPerErrorDisplay);
  63. private:
  64. class _CScriptErrInfo
  65. {
  66. public:
  67. ~_CScriptErrInfo();
  68. HRESULT Init(LONG lLine, LONG lChar, LONG lCode, BSTR strMsg, BSTR strUrl);
  69. LONG _lLine;
  70. LONG _lChar;
  71. LONG _lCode;
  72. BSTR _strMsg;
  73. BSTR _strUrl;
  74. };
  75. HDPA _hdpa;
  76. LONG _lDispIndex;
  77. ULONG _ulRefCount;
  78. };
  79. // The dochost and docview need to talk to eachother. We can't use the IOleCommandTarget
  80. // because there's no direction associated with that. Create two different interfaces
  81. // for now becuz that'll probably be useful if we ever make dochost a CoCreateable thing
  82. // so we can share hosting code with shell32.
  83. // (We can coalesce them into one interface later if they don't diverge.)
  84. //
  85. // IDocHostObject
  86. //
  87. EXTERN_C const GUID IID_IDocHostObject; //67431840-C511-11CF-89A9-00A0C9054129
  88. #undef INTERFACE
  89. #define INTERFACE IDocHostObject
  90. DECLARE_INTERFACE_(IDocHostObject, IUnknown)
  91. {
  92. // *** IUnknown methods ***
  93. STDMETHOD(QueryInterface)(THIS_ REFIID riid, void **ppv) PURE;
  94. STDMETHOD_(ULONG,AddRef)(THIS) PURE;
  95. STDMETHOD_(ULONG,Release)(THIS) PURE;
  96. // *** IDocHostObject methods ***
  97. virtual STDMETHODIMP OnQueryStatus(const GUID *pguidCmdGroup,
  98. ULONG cCmds, OLECMD rgCmds[], OLECMDTEXT *pcmdtext, HRESULT hres) PURE;
  99. virtual STDMETHODIMP OnExec(const GUID *pguidCmdGroup,
  100. DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut) PURE;
  101. virtual STDMETHODIMP QueryStatusDown(const GUID *pguidCmdGroup,
  102. ULONG cCmds, OLECMD rgCmds[], OLECMDTEXT *pcmdtext) PURE;
  103. virtual STDMETHODIMP ExecDown(const GUID *pguidCmdGroup,
  104. DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut) PURE;
  105. } ;
  106. //
  107. // This is a proxy IOleInPlaceActiveObject class. The interface to this
  108. // object will be passed to the IOleInPlaceUIWindow interface of the browser
  109. // if it support it.
  110. //
  111. class CProxyActiveObject : public IOleInPlaceActiveObject
  112. {
  113. public:
  114. // *** IUnknown methods ***
  115. STDMETHODIMP QueryInterface(REFIID riid, void ** ppvObj);
  116. virtual STDMETHODIMP_(ULONG) AddRef(void) ;
  117. virtual STDMETHODIMP_(ULONG) Release(void);
  118. // *** IOleWindow methods ***
  119. STDMETHODIMP GetWindow(HWND * lphwnd);
  120. STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
  121. // *** IOleInPlaceActiveObject ***
  122. STDMETHODIMP TranslateAccelerator(LPMSG lpmsg);
  123. STDMETHODIMP OnFrameWindowActivate(
  124. BOOL fActivate);
  125. STDMETHODIMP OnDocWindowActivate(
  126. BOOL fActivate);
  127. STDMETHODIMP ResizeBorder(
  128. LPCRECT prcBorder,
  129. IOleInPlaceUIWindow *pUIWindow,
  130. BOOL fFrameWindow);
  131. STDMETHODIMP EnableModeless(
  132. BOOL fEnable);
  133. void Initialize(CDocObjectHost* pdoh) { _pdoh = pdoh; }
  134. IOleInPlaceActiveObject *GetObject() { return _piact;}
  135. HWND GetHwnd() {return _hwnd;}
  136. void SetActiveObject(IOleInPlaceActiveObject * );
  137. protected:
  138. CDocObjectHost* _pdoh;
  139. IOleInPlaceActiveObject* _piact; // non-NULL while UI-active
  140. HWND _hwnd;
  141. };
  142. // This is a proxy IOleInPlaceFrame class. The interfaces to this object
  143. // will be passed to in-place active object.
  144. //
  145. class CDocObjectFrame : public IOleInPlaceFrame
  146. , public IOleCommandTarget
  147. , public IServiceProvider
  148. , public IInternetSecurityMgrSite
  149. {
  150. public:
  151. // *** IUnknown methods ***
  152. STDMETHODIMP QueryInterface(REFIID riid, void ** ppvObj);
  153. virtual STDMETHODIMP_(ULONG) AddRef(void) ;
  154. virtual STDMETHODIMP_(ULONG) Release(void);
  155. // *** IOleWindow methods ***
  156. STDMETHODIMP GetWindow(HWND * lphwnd);
  157. STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
  158. // IOleInPlaceUIWindow (also IOleWindow)
  159. STDMETHODIMP GetBorder(LPRECT lprectBorder);
  160. STDMETHODIMP RequestBorderSpace(LPCBORDERWIDTHS pborderwidths);
  161. STDMETHODIMP SetBorderSpace(LPCBORDERWIDTHS pborderwidths);
  162. STDMETHODIMP SetActiveObject(
  163. IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName);
  164. // IOleInPlaceFrame (also IOleInPlaceUIWindow)
  165. STDMETHODIMP InsertMenus(HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths);
  166. STDMETHODIMP SetMenu(HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject);
  167. STDMETHODIMP RemoveMenus(HMENU hmenuShared);
  168. STDMETHODIMP SetStatusText(LPCOLESTR pszStatusText);
  169. STDMETHODIMP EnableModeless(BOOL fEnable);
  170. STDMETHODIMP TranslateAccelerator(LPMSG lpmsg, WORD wID);
  171. // IOleCommandTarget
  172. STDMETHODIMP QueryStatus(const GUID *pguidCmdGroup,
  173. ULONG cCmds, OLECMD rgCmds[], OLECMDTEXT *pcmdtext);
  174. STDMETHODIMP Exec(const GUID *pguidCmdGroup,
  175. DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut);
  176. // IServiceProvider (must be QI'able from IOleClientSite)
  177. STDMETHODIMP QueryService(REFGUID guidService,
  178. REFIID riid, void **ppvObj);
  179. // *** IInternetSecurityMgrSite methods ***
  180. // STDMETHODIMP GetWindow(HWND * lphwnd) { return IOleWindow::GetWindow(lphwnd); }
  181. // STDMETHODIMP EnableModeless(BOOL fEnable) { return IOleInPlaceFrame::EnableModeless(fEnable); }
  182. public:
  183. void Initialize(CDocObjectHost* pdoh) { _pdoh = pdoh; }
  184. protected:
  185. CDocObjectHost* _pdoh;
  186. };
  187. //
  188. // LATER: Move it to a private, but shared header later.
  189. //
  190. // BROWSERFLAG_OPENCOPY - make a copy of object (Excel)
  191. // BROWSERFLAG_OPENVERB - use OLEIVERB_OPEN instead of PRIMARY
  192. // BROWSERFLAG_SETHOSTNAME - set HostName
  193. // BROWSERFLAG_DONTINPLACE - Never in-place activate
  194. // BROWSERFLAG_CANOPENFILEMULTIPETIMES-
  195. // BROWSERFLAG_DONTUIDEACTIVATE - Never UI-deactivate
  196. // BROWSERFLAG_NEVERERASEBKGND - Never erase background (Trident)
  197. // BROWSERFLAG_PRINTPROMPTUI - Don't pass DONPROMPTUI for PRINT (PPT)
  198. // BROWSERFLAG_SUPPORTTOP - Handles Navigate("#top")
  199. // BROWSERFLAG_INITNEWTOKEEP - IPS::InitNew to keep it running
  200. // BROWSERFLAG_DONTAUTOCLOSE - Don't auto close on first navigate w/ no OLE object
  201. // BROWSERFLAG_REPLACE - Don't use hard-coded flags
  202. // BROWSERFLAG_DONTCACHESERVER - Don't cache the server.
  203. // BROWSERFLAG_ENABLETOOLSBUTTON - Ignore when QueryStatus doesn't set enabled flag (Visio)
  204. // BROWSERFLAG_SAVEASWHENCLOSING - Show the Save As dialog instead of attempting to save (Visio)
  205. //
  206. #define BROWSERFLAG_OPENCOPY 0x00000001
  207. #define BROWSERFLAG_OPENVERB 0x00000002
  208. #define BROWSERFLAG_SETHOSTNAME 0x00000004
  209. #define BROWSERFLAG_DONTINPLACE 0x00000008
  210. #define BROWSERFLAG_CANOPENFILEMULTIPETIMES 0x00000010
  211. #define BROWSERFLAG_DONTUIDEACTIVATE 0x00000020
  212. #define BROWSERFLAG_NEVERERASEBKGND 0x00000040
  213. #define BROWSERFLAG_PRINTPROMPTUI 0x00000080
  214. #define BROWSERFLAG_SUPPORTTOP 0x00000100
  215. #define BROWSERFLAG_INITNEWTOKEEP 0x00000200
  216. #define BROWSERFLAG_DONTAUTOCLOSE 0x00000400
  217. #define BROWSERFLAG_DONTDEACTIVATEMSOVIEW 0x00000800
  218. #define BROWSERFLAG_MSHTML 0x40000000
  219. #define BROWSERFLAG_REPLACE 0x80000000
  220. #define BROWSERFLAG_DONTCACHESERVER 0x00001000
  221. #define BROWSERFLAG_ENABLETOOLSBTN 0x00002000
  222. #define BROWSERFLAG_SAVEASWHENCLOSING 0x00004000
  223. #ifdef FEATURE_PICS
  224. class CPicsRootDownload;
  225. #endif
  226. // CMenuList: a small class that tracks whether a given hmenu belongs
  227. // to the frame or the object, so the messages can be
  228. // dispatched correctly.
  229. class CMenuList
  230. {
  231. public:
  232. CMenuList(void);
  233. ~CMenuList(void);
  234. void Set(HMENU hmenuShared, HMENU hmenuFrame);
  235. void AddMenu(HMENU hmenu);
  236. void RemoveMenu(HMENU hmenu);
  237. BOOL IsObjectMenu(HMENU hmenu);
  238. #ifdef DEBUG
  239. void Dump(LPCTSTR pszMsg);
  240. #endif
  241. private:
  242. HDSA _hdsa;
  243. };
  244. #define ERRORPAGE_DNS 1
  245. #define ERRORPAGE_SYNTAX 2
  246. #define ERRORPAGE_NAVCANCEL 3
  247. #define ERRORPAGE_OFFCANCEL 4
  248. #define ERRORPAGE_CHANNELNOTINCACHE 5
  249. // Array of http error codes and file names.
  250. //
  251. struct ErrorUrls
  252. {
  253. DWORD dwError;
  254. LPCTSTR pszUrl;
  255. };
  256. class CDocObjectHost :
  257. /* public CDocHostUIHandler */
  258. public IDocHostUIHandler2
  259. , public IDocHostShowUI
  260. /* Group 2 */ , public IOleClientSite, public IOleDocumentSite
  261. , public IOleCommandTarget
  262. /* Group 3 */ , public IOleInPlaceSiteEx
  263. /* VBE */ , public IServiceProvider
  264. , public IDocHostObject
  265. /* palette */ , public IViewObject, public IAdviseSink
  266. , public IDispatch // ambient properties (from container/iedisp)
  267. , public IPropertyNotifySink // for READYSTATE
  268. , public IOleControlSite // forward to container/iedisp
  269. , protected CImpWndProc
  270. {
  271. /*typedef CDocHostUIHandler super;*/
  272. friend class CDocObjectView;
  273. friend CDocObjectFrame;
  274. friend CProxyActiveObject;
  275. public:
  276. CDocObjectHost(BOOL fWindowOpen = FALSE);
  277. // *** IUnknown methods ***
  278. STDMETHODIMP QueryInterface(REFIID riid, void ** ppvObj);
  279. virtual STDMETHODIMP_(ULONG) AddRef(void) ;
  280. virtual STDMETHODIMP_(ULONG) Release(void);
  281. // IOleClientSite
  282. STDMETHODIMP SaveObject(void);
  283. STDMETHODIMP GetMoniker(DWORD, DWORD, IMoniker **);
  284. STDMETHODIMP GetContainer(IOleContainer **);
  285. STDMETHODIMP ShowObject(void);
  286. STDMETHODIMP OnShowWindow(BOOL fShow);
  287. STDMETHODIMP RequestNewObjectLayout(void);
  288. // IServiceProvider (must be QI'able from IOleClientSite)
  289. STDMETHODIMP QueryService(REFGUID guidService,
  290. REFIID riid, void **ppvObj);
  291. // IViewObject
  292. STDMETHODIMP Draw(DWORD, LONG, void *, DVTARGETDEVICE *, HDC, HDC,
  293. const RECTL *, const RECTL *, BOOL (*)(ULONG_PTR), ULONG_PTR);
  294. STDMETHODIMP GetColorSet(DWORD, LONG, void *, DVTARGETDEVICE *,
  295. HDC, LOGPALETTE **);
  296. STDMETHODIMP Freeze(DWORD, LONG, void *, DWORD *);
  297. STDMETHODIMP Unfreeze(DWORD);
  298. STDMETHODIMP SetAdvise(DWORD, DWORD, IAdviseSink *);
  299. STDMETHODIMP GetAdvise(DWORD *, DWORD *, IAdviseSink **);
  300. // IAdviseSink
  301. virtual STDMETHODIMP_(void) OnDataChange(FORMATETC *, STGMEDIUM *);
  302. virtual STDMETHODIMP_(void) OnViewChange(DWORD dwAspect, LONG lindex);
  303. virtual STDMETHODIMP_(void) OnRename(IMoniker *);
  304. virtual STDMETHODIMP_(void) OnSave();
  305. virtual STDMETHODIMP_(void) OnClose();
  306. // *** IOleWindow methods ***
  307. STDMETHODIMP GetWindow(HWND * lphwnd);
  308. STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
  309. // IOleInPlaceSite (also IOleWindow)
  310. STDMETHODIMP CanInPlaceActivate( void);
  311. STDMETHODIMP OnInPlaceActivate( void);
  312. STDMETHODIMP OnUIActivate( void);
  313. STDMETHODIMP GetWindowContext(
  314. IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc,
  315. LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo);
  316. STDMETHODIMP Scroll(SIZE scrollExtant);
  317. STDMETHODIMP OnUIDeactivate(BOOL fUndoable);
  318. STDMETHODIMP OnInPlaceDeactivate( void);
  319. STDMETHODIMP DiscardUndoState( void);
  320. STDMETHODIMP DeactivateAndUndo( void);
  321. STDMETHODIMP OnPosRectChange(LPCRECT lprcPosRect);
  322. // IOleInPlaceSiteEx
  323. STDMETHODIMP OnInPlaceActivateEx(BOOL *pfNoRedraw, DWORD dwFlags);
  324. STDMETHODIMP OnInPlaceDeactivateEx(BOOL fNoRedraw);
  325. STDMETHODIMP RequestUIActivate( void);
  326. // IOleDocumentSite
  327. STDMETHODIMP ActivateMe(IOleDocumentView *pviewToActivate);
  328. // IDocHostUIHandler
  329. STDMETHODIMP ShowContextMenu(
  330. DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved);
  331. STDMETHODIMP GetHostInfo(DOCHOSTUIINFO *pInfo);
  332. STDMETHODIMP ShowUI(
  333. DWORD dwID, IOleInPlaceActiveObject *pActiveObject,
  334. IOleCommandTarget *pCommandTarget, IOleInPlaceFrame *pFrame,
  335. IOleInPlaceUIWindow *pDoc);
  336. STDMETHODIMP HideUI(void);
  337. STDMETHODIMP UpdateUI(void);
  338. STDMETHODIMP EnableModeless(BOOL fEnable);
  339. STDMETHODIMP OnDocWindowActivate(BOOL fActivate);
  340. STDMETHODIMP OnFrameWindowActivate(BOOL fActivate);
  341. STDMETHODIMP ResizeBorder(
  342. LPCRECT prcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow);
  343. STDMETHODIMP TranslateAccelerator(
  344. LPMSG lpMsg, const GUID *pguidCmdGroup, DWORD nCmdID);
  345. STDMETHODIMP GetOptionKeyPath(BSTR *pbstrKey, DWORD dw);
  346. STDMETHODIMP GetDropTarget(
  347. IDropTarget *pDropTarget, IDropTarget **ppDropTarget);
  348. STDMETHODIMP GetExternal(IDispatch **ppDisp);
  349. STDMETHODIMP TranslateUrl(DWORD dwTranslate, OLECHAR *pchURLIn, OLECHAR **ppchURLOut);
  350. STDMETHODIMP FilterDataObject(IDataObject *pDO, IDataObject **ppDORet);
  351. // IDocHostUIHandler2
  352. STDMETHODIMP GetOverrideKeyPath(LPOLESTR *pchKey, DWORD dw);
  353. // IDocHostShowUI
  354. STDMETHODIMP ShowMessage(HWND hwnd, LPOLESTR lpstrText, LPOLESTR lpstrCaption,
  355. DWORD dwType, LPOLESTR lpstrHelpFile, DWORD dwHelpContext, LRESULT *plResult);
  356. STDMETHODIMP ShowHelp(HWND hwnd, LPOLESTR pszHelpFile, UINT uCommand, DWORD dwData,
  357. POINT ptMouse, IDispatch *pDispatchObjectHit);
  358. // IOleInPlaceFrame equivalent (non-virtual)
  359. HRESULT _InsertMenus(HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths);
  360. HRESULT _SetMenu(HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject);
  361. HRESULT _RemoveMenus(HMENU hmenuShared);
  362. HRESULT _SetStatusText(LPCOLESTR pszStatusText);
  363. HRESULT _EnableModeless(BOOL fEnable);
  364. HRESULT _TranslateAccelerator(LPMSG lpmsg, WORD wID);
  365. // IOleCommandTarget equivalent (virtual / both direction)
  366. STDMETHODIMP QueryStatus(const GUID *pguidCmdGroup,
  367. ULONG cCmds, OLECMD rgCmds[], OLECMDTEXT *pcmdtext);
  368. STDMETHODIMP Exec(const GUID *pguidCmdGroup,
  369. DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut);
  370. // *** IDocHostObject methods ***
  371. STDMETHODIMP OnQueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD rgCmds[], OLECMDTEXT *pcmdtext, HRESULT hres);
  372. STDMETHODIMP OnExec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut);
  373. STDMETHODIMP QueryStatusDown(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD rgCmds[], OLECMDTEXT *pcmdtext);
  374. STDMETHODIMP ExecDown(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut);
  375. // *** IDispatch methods ***
  376. STDMETHOD(GetTypeInfoCount) (unsigned int *pctinfo)
  377. { return E_NOTIMPL; };
  378. STDMETHOD(GetTypeInfo) (unsigned int itinfo, LCID lcid, ITypeInfo **pptinfo)
  379. { return E_NOTIMPL; };
  380. STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR * * rgszNames, unsigned int cNames, LCID lcid, DISPID * rgdispid)
  381. { return E_NOTIMPL; };
  382. STDMETHODIMP Invoke(DISPID dispidMember, REFIID iid, LCID lcid, WORD wFlags, DISPPARAMS * pdispparams,
  383. VARIANT * pvarResult,EXCEPINFO * pexcepinfo,UINT * puArgErr);
  384. // *** IPropertyNotifySink methods ***
  385. STDMETHODIMP OnChanged(DISPID dispid);
  386. STDMETHODIMP OnRequestEdit(DISPID dispid);
  387. // *** IOleControlSite ***
  388. STDMETHODIMP OnControlInfoChanged();
  389. STDMETHODIMP LockInPlaceActive(BOOL fLock)
  390. { return E_NOTIMPL; };
  391. STDMETHODIMP GetExtendedControl(IDispatch **ppDisp)
  392. { *ppDisp = NULL; return E_NOTIMPL; };
  393. STDMETHODIMP TransformCoords(POINTL *pPtlHimetric, POINTF *pPtfContainer,DWORD dwFlags)
  394. { return E_NOTIMPL; };
  395. STDMETHODIMP TranslateAccelerator(MSG *pMsg,DWORD grfModifiers);
  396. STDMETHODIMP OnFocus(BOOL fGotFocus)
  397. { return E_NOTIMPL; };
  398. STDMETHODIMP ShowPropertyFrame(void)
  399. { return E_NOTIMPL; };
  400. HRESULT SetTarget(IMoniker* pmk, UINT uiCP, LPCTSTR pszLocation, LPITEMIDLIST pidlKey, IShellView* psvPrev, BOOL fFileProtocol);
  401. HRESULT UIActivate(UINT uState, BOOL fPrevViewIsDocView);
  402. //Helper function for initing History related privates
  403. IUnknown *get_punkSFHistory();
  404. BOOL InitHostWindow(IShellView* psv, IShellBrowser* psb, LPRECT prcView);
  405. void DestroyHostWindow();
  406. void _ChainBSC();
  407. HRESULT TranslateHostAccelerators(LPMSG lpmsg);
  408. HRESULT AddPages(LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam);
  409. BOOL _IsMenuShared(HMENU hmenu);
  410. void _SetPriorityStatusText(LPCOLESTR pszPriorityStatusText);
  411. BOOL DocCanHandleNavigation() const
  412. { return (_fPrevDocHost && _fDocCanNavigate); }
  413. void OnInitialUpdate();
  414. void ResetRefreshUrl();
  415. void HideBrowser() const;
  416. protected:
  417. virtual ~CDocObjectHost();
  418. // Private method
  419. void _InitOleObject();
  420. void _ResetOwners();
  421. virtual LRESULT v_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  422. void _OnMenuSelect(UINT id, UINT mf, HMENU hmenu);
  423. void _OnInitMenuPopup(HMENU hmInit, int nIndex, BOOL fSystemMenu);
  424. void _OnCommand(UINT wNotify, UINT id, HWND hwndControl);
  425. void _OnNotify(LPNMHDR lpnm);
  426. void _OnSave(void);
  427. void _OnBound(HRESULT hres);
  428. static BOOL_PTR CALLBACK s_RunDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  429. void _OnOpen(void);
  430. void _OnClose() const;
  431. BOOL _HideBrowserBar() const;
  432. void _OnImportExport(HWND hwnd);
  433. void _OnAddToSitesList(HWND hwnd, DWORD dwZone);
  434. HRESULT _PrepFileOpenAddrBand(IAddressEditBox ** ppaeb, IWinEventHandler ** ppweh, IBandSite ** ppbs);
  435. void _OnPaint(HDC hdc);
  436. void _OnSetFocus(void);
  437. void _GetClipRect(RECT* prc);
  438. void _RegisterWindowClass(void);
  439. void _PlaceProgressBar(BOOL fForcedLayout=FALSE);
  440. void _OnSetProgressPos(DWORD dwPos, DWORD state);
  441. void _OnSetProgressMax(DWORD dwRange);
  442. HRESULT _OnContentDisposition();
  443. void _OnSetStatusText(VARIANTARG *pvarIn);
  444. void _Navigate();
  445. #ifndef UNIX
  446. void _NavigateFolder(BSTR bstrUrl);
  447. #endif // UNIX
  448. // IE Media Bar functions
  449. BOOL _DelegateToMediaBar(IBindCtx * pbc, LPCWSTR pwzMimeType);
  450. void _ForceCreateMediaBar();
  451. static INT_PTR CALLBACK s_MimeDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  452. void _CancelPendingNavigation(BOOL fDownloadAsync,
  453. BOOL fSyncReally = FALSE,
  454. BOOL fDontShowNavCancelPage = FALSE,
  455. BOOL fForceClose = FALSE);
  456. void _DoAsyncNavigation(LPCTSTR pwzURL);
  457. IOleInPlaceSite* _GetParentSite(void);
  458. HRESULT _GetCurrentPage(LPTSTR szBuf, UINT cchMax, BOOL fURL=FALSE);
  459. HRESULT _GetCurrentPageW(LPOLESTR * ppszDisplayName, BOOL fURL=FALSE);
  460. BOOL _IsDirty(IPersistFile** pppf);
  461. HRESULT _OnSaveAs(void);
  462. void _MergeToolbarSB();
  463. void _OnHelpGoto(UINT idRes);
  464. void _Navigate(LPCWSTR pwszURL);
  465. HRESULT _OnMaySaveChanges(void);
  466. void _OnCodePageChange(const VARIANTARG* pvarargIn);
  467. void _MappedBrowserExec(DWORD nCmdID, DWORD nCmdexecopt);
  468. #ifdef DEBUG
  469. void _DumpMenus(LPCTSTR pszMsg, BOOL bBreak);
  470. #endif
  471. HRESULT _BindSync(IMoniker* pmk, IBindCtx* pbc, IShellView* psvPrev);
  472. void _PostBindAppHack(void);
  473. void _AppHackForExcel95(void);
  474. HRESULT _GetOfflineSilent(BOOL *pbIsOffline, BOOL *pbIsSilent);
  475. HRESULT _StartAsyncBinding(IMoniker* pmk, IBindCtx* pbc, IShellView* psvPrev);
  476. HRESULT _BindWithRetry(IMoniker* pmk, IBindCtx* pbc, IShellView* psvPrev);
  477. void _UnBind(void);
  478. void _ReleaseOleObject(BOOL fIfInited = TRUE);
  479. void _ReleasePendingObject(BOOL fIfInited = TRUE);
  480. HRESULT _GetUrlVariant(VARIANT *pvarOut);
  481. HRESULT _CreatePendingDocObject(BOOL fMustInit, BOOL fWindowOpen = FALSE);
  482. void _ActivateOleObject(void);
  483. HRESULT _CreateMsoView(void);
  484. void _CloseMsoView(void);
  485. HRESULT _EnsureActivateMsoView(void);
  486. void _ShowMsoView(void);
  487. void _HideOfficeToolbars(void);
  488. HRESULT _ActivateMsoView(void);
  489. HRESULT _DoVerbHelper(BOOL fOC);
  490. void _InitToolbarButtons(void);
  491. void _UIDeactivateMsoView(void);
  492. BOOL _BuildClassMapping(void);
  493. HRESULT _RegisterMediaTypeClass(IBindCtx* pbc);
  494. void _IPDeactivateMsoView(IOleDocumentView* pmsov);
  495. void _CompleteHelpMenuMerge(HMENU hmenu);
  496. BOOL _ShouldForwardMenu(UINT uMsg, WPARAM wParam, LPARAM lParam);
  497. LRESULT _ForwardObjectMsg(UINT uMsg, WPARAM wParam, LPARAM lParam);
  498. HRESULT _MayHaveVirus(REFCLSID rclsid);
  499. HRESULT _ForwardSetSecureLock(int lock);
  500. void _ResetStatusBar();
  501. BOOL _ToolsButtonAvailable();
  502. BYTE _DefToolsButtonState(DWORD dwRest);
  503. BYTE _DefFontsButtonState(DWORD dwRest);
  504. DWORD _DiscussionsButtonCmdf();
  505. BOOL _DiscussionsButtonAvailable();
  506. BYTE _DefDiscussionsButtonState(DWORD dwRest);
  507. BOOL _MailButtonAvailable();
  508. BYTE _DefMailButtonState(DWORD dwRest);
  509. BOOL _EditButtonAvailable();
  510. BYTE _DefEditButtonState(DWORD dwRest);
  511. void _MarkDefaultButtons(PTBBUTTON tbStd);
  512. const GUID* _GetButtonCommandGroup();
  513. void _AddButtons(BOOL fForceReload);
  514. HRESULT _OnChangedReadyState();
  515. void _OnReadyState(long lVal, BOOL fUpdateHistory = TRUE);
  516. BOOL _SetUpTransitionCapability(BOOL fWindowOpen = FALSE);
  517. BOOL _RemoveTransitionCapability();
  518. void _UpdateHistoryAndIntSiteDB(LPCWSTR pszTitle);
  519. HRESULT _CoCreateHTMLDocument(REFIID riid, LPVOID* ppvOut);
  520. void _RemoveFrameSubMenus(void);
  521. HRESULT _DestroyBrowserMenu(void);
  522. HRESULT _CreateBrowserMenu(LPOLEMENUGROUPWIDTHS pmw);
  523. void _OnSetTitle(VARIANTARG *pvTitle);
  524. DWORD _GetAppHack(void);
  525. void _CleanupProgress(void);
  526. // Trident Native Frames Support
  527. //
  528. VOID ClearScriptError();
  529. HRESULT _HandleFailedNavigation(VARIANTARG * varargIn, VARIANTARG * varargOut = NULL );
  530. HRESULT _DisplayHttpErrorPage(IHTMLWindow2 * pCurrentWindow,
  531. BSTR bstrUrl,
  532. DWORD dwError,
  533. BOOL fAddrBarNav,
  534. BOOL fRefresh = FALSE );
  535. HRESULT _DoAutoSearch(VARIANTARG * pvarargIn,
  536. long lStartIdx,
  537. DWORD dwStatusCode,
  538. BOOL fAddMRU,
  539. BOOL * pfShouldDisplayError);
  540. HRESULT _HandleDocHostCmds(DWORD nCmdID,
  541. DWORD nCmdexecopt,
  542. VARIANTARG * pvarargIn,
  543. VARIANTARG * pvarargOut,
  544. BOOL * pfHandled);
  545. HRESULT _HandleDocHostCmdPriv(DWORD nCmdID,
  546. DWORD nCmdexecopt,
  547. VARIANTARG * pvarargIn,
  548. VARIANTARG * pvarargOut,
  549. BOOL * pfHandled);
  550. HRESULT _NavigateDocument(BSTR bstrUrl, BSTR bstrLocation);
  551. void _GetShortCutPath(BSTR * bstrShortCutPath);
  552. void _GetDocNavFlags(DWORD * pdwDocNavFlags);
  553. BOOL _HandleShdocvwCmds(DWORD nCmdID,
  554. DWORD nCmdexecopt,
  555. VARIANTARG * pvarargIn,
  556. VARIANTARG * pvarargOut);
  557. void _StartPicsForWindow(VARIANTARG * pvarargIn, VARIANTARG * pvarargOut);
  558. void _CancelPicsForWindow(VARIANTARG * pvarargIn);
  559. void _IsPicsEnabled(VARIANTARG * pvarIsPicsEnabled);
  560. HRESULT _UpdateState(LPITEMIDLIST pidl, BOOL fIsErrorUrl);
  561. void _Init();
  562. BOOL _IsInBrowserBand() const;
  563. DEBUG_CODE(void _TraceMonikerDbg(IMoniker * pmk, TCHAR * pszCaller) const;)
  564. HRESULT _LoadDocument();
  565. void _FireNavigateErrorHelper(IHTMLWindow2 * pHTMLWindow2,
  566. DWORD dwStatusCode,
  567. BOOL * pfCancelAutoSearch,
  568. BSTR bstrPendingURL = NULL);
  569. static LRESULT s_IconsWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  570. static UINT _MapCommandID(UINT id, BOOL fToMsoCmd);
  571. inline static UINT _MapToMso(UINT id) { return _MapCommandID(id, TRUE); }
  572. inline static UINT _MapFromMso(UINT idMso) { return _MapCommandID(idMso, FALSE); }
  573. inline IOleInPlaceActiveObject *_ActiveObject() { return _xao.GetObject(); }
  574. inline HWND _ActiveHwnd() { return _xao.GetHwnd(); }
  575. inline IOleObject * GetOleObject() { return _pole; }
  576. // internal class objects
  577. CDocObjectFrame _dof;
  578. CProxyActiveObject _xao;
  579. CDocHostUIHandler _dhUIHandler;
  580. IToolbarExt * _pBrowsExt;
  581. int _iString; // start index for toolbar button strings
  582. UINT _cRef;
  583. // parent references
  584. IShellView * _psv;
  585. IOleCommandTarget* _pmsoctView;
  586. IDocViewSite* _pdvs;
  587. //
  588. IShellBrowser* _psb;
  589. IOleCommandTarget* _pmsoctBrowser;
  590. IBrowserService* _pwb;
  591. IServiceProvider* _psp;
  592. IOleInPlaceUIWindow* _pipu; // Optional interface from IShellBrowser
  593. IExpDispSupport * _peds;
  594. IExpDispSupportOC * _pedsHelper;
  595. // for pre-merged menu
  596. IOleCommandTarget* _pcmdMergedMenu;
  597. // Pointer to the WebBrowserOC's DocHostUIHandler, if any.
  598. IDocHostUIHandler * _pWebOCUIHandler;
  599. IDocHostUIHandler2 * _pWebOCUIHandler2;
  600. // Pointer to the WebBrowserOC's ShowUI handler, if any.
  601. IDocHostShowUI * _pWebOCShowUI;
  602. // Pointer to the WebBrowserOC's InPlaceSiteEx, if any.
  603. IOleInPlaceSiteEx * _pWebOCInPlaceSiteEx;
  604. // we created...
  605. UINT _uState;
  606. HWND _hwndProgress;
  607. HWND _hwndIcons;
  608. HWND _hwndTooltip;
  609. WNDPROC _pfnStaticWndProc;
  610. HACCEL _hacc;
  611. // Menus: the final menu bar the user sees (_hmenuCur, _hmenuSet) is the product
  612. // of merging the object's menu with the browser's menu. The browser's menu
  613. // (_hmenuBrowser) is the result of combining the browser's
  614. // menu (owned by mshtml, obtained via IShellBrowser) with the
  615. // frame's menu (_hmenuFrame).
  616. HMENU _hmenuFrame; // menu to be merged when we have focus
  617. HMENU _hmenuBrowser; // Menu from IShellBrowser
  618. HMENU _hmenuSet; // set by ::SetMenu
  619. HMENU _hmenuCur; // currently set menu
  620. HMENU _hmenuMergedHelp; // Merged help menu
  621. HMENU _hmenuObjHelp; // Hosted object's help menu
  622. CMenuList _menulist; // Menu list for dispatching
  623. LPCTSTR _pszLocation;
  624. UINT _uiCP;
  625. LPOLESTR _pwszRefreshUrl; // Url to refresh when intrenal error page is dispalyed.
  626. BOOL _fNeedToActivate:1; // this is set when we do a LoadHistory on the _pole
  627. BOOL _fClientSiteSet:1;
  628. BOOL _fDontInplaceActivate:1;
  629. BOOL _fDrawBackground:1;
  630. BOOL _fCanceledByBrowser:1;
  631. BOOL _fForwardMenu:1; // TRUE: forward the menu message
  632. BOOL _fHaveParentSite:1; // pretty much "we're in a frame"
  633. BOOL _fhasLastModified; // object has Last-Modified header
  634. BOOL _fIPDeactivatingView:1;
  635. BOOL _fCantSaveBack:1; // We can't call IPSFile::Save(NULL)
  636. BOOL _fHaveAppHack:1;
  637. BOOL _fReadystateInteractiveProcessed:1;
  638. BOOL _fFileProtocol:1;
  639. BOOL _fConfirmed:1; // _MayHaveVirus already confirmed
  640. BOOL _fCycleFocus:1; // 1=got callback to do CycleFocus
  641. BOOL _fCreatingPending:1; // we are creating _punkPending
  642. BOOL _fAbortCreatePending:1; // abort create due to reentrant free
  643. BOOL _fCalledMayOpenSafeDlg:1; // Already called MayOpenSafeOpenDialog.
  644. BOOL _fPendingNeedsInit:1; // does _punkPending need to be inited?
  645. BOOL _fPendingWasInited:1; // _punkPending was inited
  646. BOOL _fSetSecureLock:1; // indicates we should update the browser with fSecureLock
  647. BOOL _fProgressTimer:1; // progress timer is active
  648. BOOL _fProgressTimerFull:1; // wait a quarter sec with a full progress bar
  649. BOOL _fIsHistoricalObject:1; // this item was retrieved from GetHistoryObject() and successfully took LoadHistory()
  650. BOOL _fSyncBindToObject:1; // to detect when the call backs are on the sync thread
  651. BOOL _fUIActivatingView:1; // Indicates if we're UIActivating or Showing our DocObj view.
  652. BOOL _fShowProgressCtl:1; // Show the progress control on the status bar.
  653. BOOL _fWebOC:1; // are we a web oc?
  654. #ifdef DEBUG
  655. BOOL _fFriendlyError:1; // So we know we're going to an error page.
  656. #endif
  657. BOOL _fDocCanNavigate:1; // TRUE indicates that the hosted document can navigate itself.
  658. BOOL _fPrevDocHost:1; // TRUE if there was a previous doc object host.
  659. BOOL _fClosing:1; // The browser is being closed.
  660. BOOL _fRefresh:1; // the browser is being refreshed (ie we are handling refresh).
  661. BOOL _fDelegatedNavigation:1; // TRUE if the navigation was delegated from the document.
  662. BOOL _fErrorPage : 1; // True if we're navigating to some sort of error page.
  663. BOOL _fWindowOpen:1;
  664. IHTMLWindow2 * _pHTMLWindow; // Navigation interface of the hosted document.
  665. LPITEMIDLIST _pidl; // Current pidl.
  666. HRESULT _hrOnStopBinding; // set in onstopbinding when _fSyncBindToObject
  667. DWORD _dwPropNotifyCookie;
  668. DWORD _dwAppHack;
  669. DWORD _dwSecurityStatus; // Return from QueryOptions(INTERNET_OPTION_SECURITY_FLAGS)
  670. int _eSecureLock; // one of the SECURELOCK_* values
  671. HINSTANCE _hinstInetCpl; // Inetcpl
  672. TBBUTTON* _ptbStd; // buffer for button array (used for ETCMDID_GETBUTTONS)
  673. int _nNumButtons;
  674. VARIANT _varUserEnteredUrl; // The URL entered by the user in the address bar.
  675. // Needed for AutoSearch when initiated by Trident.
  676. BOOL _fDontInPlaceNavigate() { ASSERT(_fHaveAppHack); return (_dwAppHack & BROWSERFLAG_DONTINPLACE); }
  677. BOOL _fCallSetHostName() { ASSERT(_fHaveAppHack); return (_dwAppHack & BROWSERFLAG_SETHOSTNAME); }
  678. BOOL _fUseOpenVerb() { ASSERT(_fHaveAppHack); return (_dwAppHack & BROWSERFLAG_OPENVERB); }
  679. BOOL _fAppHackForExcel() { ASSERT(_fHaveAppHack); return (_dwAppHack & BROWSERFLAG_OPENCOPY); }
  680. UINT posOfflineIcon;
  681. enum {
  682. PROGRESS_RESET,
  683. PROGRESS_FINDING,
  684. PROGRESS_TICK,
  685. PROGRESS_SENDING,
  686. PROGRESS_RECEIVING,
  687. PROGRESS_FULL
  688. };
  689. #define PROGRESS_REBASE 100
  690. #define PROGRESS_FINDMAX 30 * PROGRESS_REBASE // maximum amount of status on find
  691. #define PROGRESS_SENDMAX 40 * PROGRESS_REBASE // maximum amount of status on send
  692. #define PROGRESS_TOTALMAX 100 * PROGRESS_REBASE // the total size of the progress bar in find/send
  693. #define PROGRESS_INCREMENT 50 // default progress increment
  694. #define ADJUSTPROGRESSMAX(dw) (PROGRESS_REBASE * (dw) )
  695. #define ADJUSTPROGRESSPOS(dw) ((dw) * PROGRESS_REBASE + ((_dwProgressBase * _dwProgressMax) / PROGRESS_REBASE))
  696. DWORD _dwProgressMax; // max progress range for progress bar
  697. DWORD _dwProgressPos;
  698. DWORD _dwProgressInc;
  699. DWORD _dwProgressTicks;
  700. DWORD _dwProgressMod;
  701. DWORD _dwProgressBase;
  702. #define IDTIMER_PROGRESS 88
  703. #define IDTIMER_PROGRESSFULL 89
  704. #ifdef HLINK_EXTRA
  705. // Navigation
  706. IHlinkBrowseContext* _pihlbc;
  707. #endif // HLINK_EXTRA
  708. // Data associated
  709. IMoniker* _pmkCur;
  710. IBindCtx* _pbcCur;
  711. IOleObject* _pole;
  712. IViewObject* _pvo;
  713. IStorage* _pstg;
  714. IUnknown* _punkPending;
  715. IHlinkFrame *_phf;
  716. IOleCommandTarget*_pocthf;
  717. IUnknown *_punkSFHistory;
  718. // Advisory connection
  719. IAdviseSink *_padvise;
  720. DWORD _advise_aspect;
  721. DWORD _advise_advf;
  722. // View associated (only used when the object is active)
  723. IOleDocumentView* _pmsov;
  724. IOleCommandTarget* _pmsot;
  725. IOleControl* _pmsoc;
  726. IHlinkSource* _phls;
  727. BORDERWIDTHS _bwTools;
  728. RECT _rcView;
  729. int _iZoom;
  730. int _iZoomMin;
  731. int _iZoomMax;
  732. class CDOHBindStatusCallback : public IBindStatusCallback
  733. , public IAuthenticate
  734. , public IServiceProvider
  735. , public IHttpNegotiate
  736. , public IHttpSecurity
  737. {
  738. friend CDocObjectHost;
  739. protected:
  740. // *** IUnknown methods ***
  741. STDMETHODIMP QueryInterface(REFIID riid, void ** ppvObj);
  742. virtual STDMETHODIMP_(ULONG) AddRef(void) ;
  743. virtual STDMETHODIMP_(ULONG) Release(void);
  744. // *** IAuthenticate ***
  745. STDMETHODIMP Authenticate(
  746. HWND *phwnd,
  747. LPWSTR *pszUsername,
  748. LPWSTR *pszPassword);
  749. // *** IServiceProvider ***
  750. STDMETHODIMP QueryService(REFGUID guidService,
  751. REFIID riid, void **ppvObj);
  752. // *** IBindStatusCallback ***
  753. STDMETHODIMP OnStartBinding(
  754. /* [in] */ DWORD grfBSCOption,
  755. /* [in] */ IBinding *pib);
  756. STDMETHODIMP GetPriority(
  757. /* [out] */ LONG *pnPriority);
  758. STDMETHODIMP OnLowResource(
  759. /* [in] */ DWORD reserved);
  760. STDMETHODIMP OnProgress(
  761. /* [in] */ ULONG ulProgress,
  762. /* [in] */ ULONG ulProgressMax,
  763. /* [in] */ ULONG ulStatusCode,
  764. /* [in] */ LPCWSTR szStatusText);
  765. STDMETHODIMP OnStopBinding(
  766. /* [in] */ HRESULT hresult,
  767. /* [in] */ LPCWSTR szError);
  768. STDMETHODIMP GetBindInfo(
  769. /* [out] */ DWORD *grfBINDINFOF,
  770. /* [unique][out][in] */ BINDINFO *pbindinfo);
  771. STDMETHODIMP OnDataAvailable(
  772. /* [in] */ DWORD grfBSCF,
  773. /* [in] */ DWORD dwSize,
  774. /* [in] */ FORMATETC *pformatetc,
  775. /* [in] */ STGMEDIUM *pstgmed);
  776. STDMETHODIMP OnObjectAvailable(
  777. /* [in] */ REFIID riid,
  778. /* [iid_is][in] */ IUnknown *punk);
  779. /* *** IHttpNegotiate *** */
  780. STDMETHODIMP BeginningTransaction(LPCWSTR szURL, LPCWSTR szHeaders,
  781. DWORD dwReserved, LPWSTR *pszAdditionalHeaders);
  782. STDMETHODIMP OnResponse(DWORD dwResponseCode, LPCWSTR szResponseHeaders,
  783. LPCWSTR szRequestHeaders,
  784. LPWSTR *pszAdditionalRequestHeaders);
  785. /* *** IHttpSecurity *** */
  786. STDMETHODIMP GetWindow(REFGUID rguidReason, HWND* phwnd);
  787. STDMETHODIMP OnSecurityProblem(DWORD dwProblem);
  788. protected:
  789. ~CDOHBindStatusCallback();
  790. IBinding* _pib;
  791. IBindCtx* _pbc;
  792. IBindStatusCallback* _pbscChained;
  793. IHttpNegotiate* _pnegotiateChained;
  794. IShellView* _psvPrev;
  795. ULONG _bindst;
  796. HGLOBAL _hszPostData;
  797. int _cbPostData;
  798. LPSTR _pszHeaders;
  799. LPTSTR _pszRedirectedURL;
  800. LPTSTR _pszCacheFileName;
  801. DWORD _dwBindVerb; // the verb requested
  802. DWORD _dwBindf; // last set of bind flags returned as a response to the GetBindInfo call...
  803. DWORD _cbContentLength;
  804. BOOL _fSelfAssociated:1; //
  805. BOOL _fBinding:1; // downloading
  806. BOOL _bFrameIsOffline:1;
  807. BOOL _bFrameIsSilent:1;
  808. BOOL _fDocWriteAbort:1; // abort to use _punkPending
  809. BOOL _fBoundToMSHTML:1; // if bound to TRIDENT
  810. BOOL _fBoundToNoOleObject:1; // the object does not support IOleObject
  811. BOOL _fAborted:1; // TRUE when AbortBinding called when IDCANCEL for BINDSTATUS_CONTENTDISPOSITIONATTACH
  812. //Privacy data
  813. LPTSTR _pszPolicyRefURL;
  814. LPTSTR _pszP3PHeader;
  815. DWORD _dwPrivacyFlags;
  816. CPrivacyQueue _privacyQueue;
  817. void _Redirect(LPCWSTR pwzNew);
  818. void _UpdateSSLIcon(void);
  819. BOOL _DisplayFriendlyHttpErrors(void);
  820. void _HandleHttpErrors(DWORD dwError, DWORD cbContentLength, CDocObjectHost* pdoh);
  821. HRESULT _HandleFailedNavigationSearch (LPBOOL pfShouldDisplayError,
  822. DWORD dwStatusCode,
  823. CDocObjectHost * pdoh,
  824. HRESULT hrDisplay,
  825. TCHAR * szURL,
  826. LPCWSTR szError,
  827. IBinding * pib,
  828. BOOL fAddMRU = TRUE,
  829. BOOL fFromTrident = FALSE);
  830. void _CheckForCodePageAndShortcut(void);
  831. void _DontAddToMRU(CDocObjectHost* pdoh);
  832. void _UpdateMRU(CDocObjectHost* pdoh, LPCWSTR pszUrl);
  833. HRESULT _SetSearchInfo(CDocObjectHost *pdoh, DWORD dwIndex, BOOL fAllowSearch, BOOL fContinueSearch, BOOL fSentToEngine);
  834. void ResetPrivacyInfo();
  835. HRESULT BuildRecord();
  836. HRESULT AddToPrivacyQueue(LPTSTR * ppszUrl, LPTSTR * ppszPolicyRef, LPTSTR * ppszP3PHeader, DWORD dwFlags);
  837. public:
  838. void AbortBinding(void);
  839. CDOHBindStatusCallback() : _pib(NULL) {}
  840. void _RegisterObjectParam(IBindCtx* pbc);
  841. void _RevokeObjectParam(IBindCtx* pbc);
  842. void _NavigateToErrorPage(DWORD dwError, CDocObjectHost* pdoh, BOOL fInPlace);
  843. };
  844. friend class CDOHBindStatusCallback;
  845. CDOHBindStatusCallback _bsc;
  846. #ifdef FEATURE_PICS
  847. #define PICS_WAIT_FOR_ASYNC 0x01 /* waiting for async rating query */
  848. #define PICS_WAIT_FOR_INDOC 0x02 /* waiting for in-document rating */
  849. #define PICS_WAIT_FOR_ROOT 0x04 /* waiting for root document */
  850. #define PICS_WAIT_FOR_END 0x08 /* waiting for end of document */
  851. #define PICS_MULTIPLE_FLAGS PICS_WAIT_FOR_INDOC /* sources which can produce multiple results */
  852. #define PICS_LABEL_FROM_HEADER 0 /* label was obtained from the http header */
  853. #define PICS_LABEL_FROM_PAGE 1 /* label was obtained from the page itself */
  854. /*
  855. * _fPicsBlockLate - TRUE if we're using a DocObject which we have
  856. * to allow to download completely because we may
  857. * need to get ratings out of it. FALSE if we
  858. * just want to block it as early as possible
  859. * (usually at OnProgress(CLASSIDAVAILABLE)).
  860. * _fSetTarget - bug 29364: this indicates we are calling _StartAsyncBinding
  861. * and we shouldn't do any activation, even if we're told to.
  862. * Has URLMON changed how it binds to objects? (GregJ claims
  863. * that URLMON never called OnObjectAvailable synchronously
  864. * with the _StartAsyncBinding call...) It also seems that
  865. * both Trident and this PICS stuff use the
  866. * message SHDVID_ACTIVATEMENOW which might confuse
  867. * the delayed activation stuff CDTurner put in... [mikesh]
  868. */
  869. BOOL _fSetTarget:1;
  870. BOOL _fPicsBlockLate:1;
  871. class CPicsProcessor : public IOleCommandTarget
  872. {
  873. // Everything public because the _bsc needs to get at base proc
  874. public:
  875. friend class CDocObjectHost;
  876. CPicsProcessor();
  877. ~CPicsProcessor() { _ReInit(); }
  878. void _ReInit();
  879. // *** IUnknown methods ***
  880. STDMETHODIMP QueryInterface(REFIID riid, void ** ppvObj);
  881. virtual STDMETHODIMP_(ULONG) AddRef(void) ;
  882. virtual STDMETHODIMP_(ULONG) Release(void);
  883. // IOleCommandTarget equivalent (virtual / both direction)
  884. STDMETHODIMP QueryStatus(const GUID *pguidCmdGroup,
  885. ULONG cCmds, OLECMD rgCmds[], OLECMDTEXT *pcmdtext);
  886. STDMETHODIMP Exec(const GUID *pguidCmdGroup,
  887. DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut);
  888. /* PICS state flags:
  889. *
  890. * _fPicsAccessAllowed - Whether the most significant rating we've
  891. * found so far (that actually applies to the
  892. * thing we're browsing to) would allow access.
  893. * Once all rating sources report in, this flag
  894. * indicates whether the user can see the content.
  895. */
  896. BYTE _fPicsAccessAllowed:1;
  897. BYTE _fInDialog:1;
  898. BYTE _fTerminated:1;
  899. /* The following flags are a separate bitfield so I can easily test
  900. * "if (!_fbPicsWaitFlags)" to see if I'm done waiting.
  901. *
  902. * IMPORTANT: The flags are in order of precedence. That is, ASYNC
  903. * is more important than INDOC, which is more important than ROOT.
  904. * This way, given any flag which specifies the source of a rating,
  905. * if that rating applies to the content, then
  906. *
  907. * _fbPicsWaitFlags &= (flag - 1);
  908. *
  909. * will turn off that flag and all flags above it, causing the code
  910. * to not consider any further ratings from that source or less
  911. * important sources.
  912. */
  913. BYTE _fbPicsWaitFlags;
  914. DWORD _dwPicsLabelSource;
  915. LPVOID _pRatingDetails;
  916. DWORD _dwPicsSerialNumber; /* serial number for async query */
  917. DWORD _dwKey; /* Key for identifying CPicsProcs */
  918. HANDLE _hPicsQuery; /* handle to async query event */
  919. LPTSTR _pszPicsURL; /* result of CoInternetGetSecurityUrl */
  920. IHTMLPrivateWindow * _pPrivWindow; /* Private Window on behalf of which this proccessing is being done */
  921. CPicsRootDownload * _pRootDownload; /* object managing root document download */
  922. CDocObjectHost * _pdoh;
  923. CPicsProcessor * _pPicsProcNext; /* the next pics proc in the chain */
  924. LONG_PTR _GetKey() { return (LONG_PTR)_dwKey; }
  925. UINT _PicsBlockingDialog();
  926. HRESULT _StartPicsQuery(LPCOLESTR pwszRawURL);
  927. void _HandlePicsChecksComplete();
  928. void _GotLabel(HRESULT hres, LPVOID pDetails, BYTE bfSource);
  929. void _HandleInDocumentLabel(LPCTSTR pszLabel);
  930. void _HandleDocumentEnd(void);
  931. void _StartPicsRootQuery(LPCTSTR pszURL);
  932. void _Terminate();
  933. };
  934. friend class CPicsProcessor;
  935. CPicsProcessor _PicsProcBase;
  936. DWORD _dwPicsKeyBase;
  937. CPicsProcessor* _GetPicsProcessorFromKey(LONG_PTR lKey);
  938. CPicsProcessor* _GetPicsProcessorFromSerialNumber( DWORD dwPicsSerialNumber );
  939. void _StartBasePicsProcessor();
  940. HRESULT _StartSecondaryPicsProcessor(IHTMLPrivateWindow * pPrivWindow);
  941. HRESULT _RemovePicsProcessorByKey(LONG_PTR lKey);
  942. HRESULT _RemovePicsProcessorByPrivWindowUnk(IUnknown* pUnkFind);
  943. HRESULT _RemoveAllPicsProcessors();
  944. #endif
  945. BSTR _strPriorityStatusText;
  946. // support for caching of script errors
  947. CScriptErrorList * _pScriptErrList;
  948. BOOL _fScriptErrDlgOpen;
  949. BOOL _fShowScriptErrDlgAgain;
  950. HRESULT _ScriptErr_CacheInfo(VARIANTARG *pvarIn);
  951. void _ScriptErr_Dlg(BOOL fOverrridePerErrorMode);
  952. };
  953. #ifdef FEATURE_PICS
  954. //#include <brwsectl.h> /* for IBrowseControl */
  955. class CPicsRootDownload : public IBindStatusCallback,
  956. IOleClientSite, IServiceProvider,
  957. IDispatch
  958. {
  959. protected:
  960. UINT m_cRef;
  961. long m_lFlags;
  962. IOleCommandTarget *m_pctParent;
  963. IOleObject *m_pole;
  964. IOleCommandTarget *m_pctObject;
  965. IBinding *m_pBinding;
  966. IBindCtx *m_pBindCtx;
  967. void _NotifyEndOfDocument(void);
  968. HRESULT _Abort(void);
  969. BOOL m_fFrameIsSilent:1;
  970. BOOL m_fFrameIsOffline:1;
  971. public:
  972. CPicsRootDownload(IOleCommandTarget *pctParent, BOOL fFrameIsOffline, BOOL fFrameIsSilent);
  973. ~CPicsRootDownload();
  974. HRESULT StartDownload(IMoniker *pmk);
  975. void CleanUp(void);
  976. // IUnknown members
  977. STDMETHODIMP QueryInterface(REFIID riid, void **punk);
  978. STDMETHODIMP_(ULONG) AddRef(void);
  979. STDMETHODIMP_(ULONG) Release(void);
  980. // IBindStatusCallback methods
  981. STDMETHODIMP OnStartBinding(DWORD dwReserved, IBinding* pbinding);
  982. STDMETHODIMP GetPriority(LONG* pnPriority);
  983. STDMETHODIMP OnLowResource(DWORD dwReserved);
  984. STDMETHODIMP OnProgress(ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode,
  985. LPCWSTR pwzStatusText);
  986. STDMETHODIMP OnStopBinding(HRESULT hrResult, LPCWSTR szError);
  987. STDMETHODIMP GetBindInfo(DWORD* pgrfBINDF, BINDINFO* pbindinfo);
  988. STDMETHODIMP OnDataAvailable(DWORD grfBSCF, DWORD dwSize, FORMATETC *pfmtetc,
  989. STGMEDIUM* pstgmed);
  990. STDMETHODIMP OnObjectAvailable(REFIID riid, IUnknown* punk);
  991. // IOleClientSite
  992. STDMETHODIMP SaveObject(void);
  993. STDMETHODIMP GetMoniker(DWORD, DWORD, IMoniker **);
  994. STDMETHODIMP GetContainer(IOleContainer **);
  995. STDMETHODIMP ShowObject(void);
  996. STDMETHODIMP OnShowWindow(BOOL fShow);
  997. STDMETHODIMP RequestNewObjectLayout(void);
  998. // IServiceProvider (must be QI'able from IOleClientSite)
  999. STDMETHODIMP QueryService(REFGUID guidService,
  1000. REFIID riid, void **ppvObj);
  1001. // *** IDispatch methods ***
  1002. STDMETHOD(GetTypeInfoCount) (unsigned int *pctinfo)
  1003. { return E_NOTIMPL; };
  1004. STDMETHOD(GetTypeInfo) (unsigned int itinfo, LCID lcid, ITypeInfo **pptinfo)
  1005. { return E_NOTIMPL; };
  1006. STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR * * rgszNames, unsigned int cNames, LCID lcid, DISPID * rgdispid)
  1007. { return E_NOTIMPL; };
  1008. STDMETHODIMP Invoke(DISPID dispidMember, REFIID iid, LCID lcid, WORD wFlags, DISPPARAMS * pdispparams,
  1009. VARIANT * pvarResult,EXCEPINFO * pexcepinfo,UINT * puArgErr);
  1010. };
  1011. // IID_IsPicsBrowser is a way we can use pClientSite->QueryService to find out
  1012. // if the top-level browser is a PICS root document download or not, so we can
  1013. // avoid navigating sub-frames. No real interface corresponds to this IID, we
  1014. // just return an IUnknown pointer.
  1015. EXTERN_C const GUID IID_IsPicsBrowser; // F114C2C0-90BE-11D0-83B1-00C04FD705B2
  1016. #endif
  1017. void DeleteFileSent(LPTSTR *ppszTempFile);
  1018. BOOL ShouldShellExecURL( LPTSTR pszURL );
  1019. DWORD GetSyncMode (DWORD dwDefault);
  1020. // in Dochost.cpp
  1021. BOOL _ValidateURL(LPTSTR pszName, DWORD dwFlags);
  1022. void GetAppHackFlags(IOleObject* pole, const CLSID* pclsid, DWORD* pdwAppHack);
  1023. BOOL _IsDesktopItem(CDocObjectHost * pdoh);
  1024. BOOL IsAssociatedWithIE(LPCWSTR pwszFileName);
  1025. UINT OpenSafeOpenDialog(HWND hwnd, UINT idRes, LPCTSTR pszFileClass, LPCTSTR pszURL, LPCTSTR pszRedirURL, LPCTSTR pszCacheName, LPCTSTR pszDisplay, UINT uiCP, IUnknown *punk = NULL, BOOL fDisableOpen = FALSE);
  1026. void CDownLoad_OpenUI(IMoniker* pmk,
  1027. IBindCtx *pbc,
  1028. BOOL fSync,
  1029. BOOL fSaveAs=FALSE,
  1030. BOOL fSafe=FALSE,
  1031. LPWSTR pwzHeaders = NULL,
  1032. DWORD dwVerb=BINDVERB_GET,
  1033. DWORD grfBINDF = (BINDF_ASYNCHRONOUS | BINDF_PULLDATA),
  1034. BINDINFO* pbinfo = NULL,
  1035. LPCTSTR pszRedir=NULL,
  1036. UINT uiCP = CP_ACP,
  1037. IUnknown *punk = NULL,
  1038. BOOL fConfirmed=FALSE
  1039. );
  1040. HRESULT CDownLoad_OpenUIURL(LPCWSTR pwszURL, IBindCtx *pbc, LPWSTR pwzHeaders, BOOL fSync, BOOL fSaveAs=FALSE, BOOL fSafe=FALSE, DWORD dwVerb=BINDVERB_GET, DWORD grfBINDF=(BINDF_ASYNCHRONOUS | BINDF_PULLDATA), BINDINFO* pbinfo=NULL,
  1041. LPCTSTR pszRedir=NULL, UINT uiCP=CP_ACP, IUnknown *punk = NULL, BOOL fConfirmed=FALSE);
  1042. HRESULT _GetRequestFlagFromPIB(IBinding *pib, DWORD *pdwOptions);
  1043. HRESULT _SetSearchInfo (IServiceProvider *psp, DWORD dwIndex, BOOL fAllowSearch, BOOL fContinueSearch, BOOL fSentToEngine);
  1044. HRESULT _GetSearchInfo (IServiceProvider *psp, LPDWORD pdwIndex, LPBOOL pfAllowSearch, LPBOOL pfContinueSearch, LPBOOL pfSentToEngine);
  1045. // Values for automatically scanning common net suffixes
  1046. #define NO_SUFFIXES 0
  1047. #define SCAN_SUFFIXES 1
  1048. #define DONE_SUFFIXES 2
  1049. // Registry values for automatically sending request to search engine
  1050. #define NEVERSEARCH 0
  1051. #define PROMPTSEARCH 1
  1052. #define ALWAYSSEARCH 2
  1053. #define SHOULD_DO_SEARCH(x,y) (y || (x && x != DONE_SUFFIXES))