Source code of Windows XP (NT5)
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.

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