1
0

browser.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. #ifndef NULLSOFT_WINAMP_OMBROWSER_HEADER
  2. #define NULLSOFT_WINAMP_OMBROWSER_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include <wtypes.h>
  7. #include "../nu/HTMLContainer2.h"
  8. #include "./browserInternal.h"
  9. class obj_ombrowser;
  10. class Browser;
  11. class ifc_omdebugconfig;
  12. class ifc_omservice;
  13. class ifc_travelloghelper;
  14. typedef void (CALLBACK *BHCALLBACK)(Browser* /*browser*/);
  15. typedef void (CALLBACK *BHNAVCOMPLETECALLBACK)(Browser* /*browser*/, IDispatch* /*pDispatch*/, VARIANT* /*URL*/);
  16. typedef void (CALLBACK *BHCMDSTATECALLBACK)(Browser* /*browser*/, INT /*commandId*/, BOOL /*fEnabled*/);
  17. typedef void (CALLBACK *BHTEXTCALLBACK)(Browser* /*browser*/, LPCWSTR /*pszText*/);
  18. typedef HRESULT (CALLBACK *BHSERVICECALLBACK)(Browser* /*browser*/, ifc_omservice** /*ppService*/);
  19. typedef LRESULT (CALLBACK *BHMSGCALLBACK)(Browser* /*browser*/, MSG* /*pMsg*/);
  20. typedef void (CALLBACK *BHCREATEPOPUPCALLBACK)(Browser* /*browser*/, IDispatch** /*ppDisp*/, VARIANT_BOOL* /*Cancel*/);
  21. typedef void (CALLBACK *BHBOOLCALLBACK)(Browser* /*browser*/, VARIANT_BOOL /*Visible*/);
  22. typedef void (CALLBACK *BHCLOSECALLBACK)(Browser* /*browser*/, VARIANT_BOOL /*IsChild*/, VARIANT_BOOL* /*Cancel*/);
  23. typedef void (CALLBACK *BHSHOWUICALLBACK)(Browser* /*browser*/, UINT /*elementId*/, VARIANT_BOOL /*fShow*/);
  24. typedef void (CALLBACK *BHCLIENTTOHOSTCALLBACK)(Browser* /*browser*/, LONG* /*CX*/, LONG* /*CY*/);
  25. typedef void (CALLBACK *BHFOCUSCHANGECALLBACK)(Browser* /*browser*/, VARIANT_BOOL* /*fAllow*/);
  26. typedef void (CALLBACK *BHWINDOWPOSCALLBACK)(Browser* /*browser*/, UINT /*Flags*/, LONG /*X*/, LONG /*Y*/, LONG /*Width*/, LONG /*Height*/);
  27. class Browser : public HTMLContainer2,
  28. public IDropTarget,
  29. public IProtectFocus,
  30. public IHTMLOMWindowServices,
  31. public INewWindowManager
  32. {
  33. public:
  34. typedef enum
  35. {
  36. commandNone = 0,
  37. commandBack = 1,
  38. commandForward = 2,
  39. commandStop = 3,
  40. commandRefresh = 4,
  41. commandRefreshCompletely = 5,
  42. } Commands;
  43. typedef enum
  44. {
  45. commandStateSupported = 1,
  46. commandStateEnabled = 2,
  47. commandStateLatched = 4,
  48. } CommandStates;
  49. typedef enum
  50. {
  51. flagUiDisableScroll = 0x00000001,
  52. flagUiDisableContextMenu = 0x00000002,
  53. flagUiDialogMode = 0x00000004,
  54. flagUiDisableHostCss = 0x00000008,
  55. } UiFlags;
  56. protected:
  57. Browser(obj_ombrowser *browserMngr, HWND winampWindow, HWND hParent);
  58. ~Browser();
  59. public:
  60. static Browser *CreateInstance(obj_ombrowser *browserManager, HWND winampWindow, HWND hParent);
  61. public:
  62. /*** IUnknown ***/
  63. STDMETHOD_(ULONG, AddRef)(void);
  64. STDMETHOD_(ULONG, Release)(void);
  65. STDMETHOD (QueryInterface)(REFIID, LPVOID*);
  66. /*** IDropTarget ***/
  67. STDMETHOD (DragEnter)(IDataObject *, DWORD, POINTL, DWORD*);
  68. STDMETHOD (DragOver)(DWORD, POINTL, DWORD*);
  69. STDMETHOD (DragLeave)(void);
  70. STDMETHOD (Drop)(IDataObject*, DWORD, POINTL, DWORD*);
  71. STDMETHOD (GetDropTarget)(IDropTarget*, IDropTarget **);
  72. STDMETHOD (GetExternal)(IDispatch __RPC_FAR *__RPC_FAR *ppDispatch);
  73. STDMETHOD (ShowContextMenu)(DWORD dwID, POINT __RPC_FAR *ppt, IUnknown __RPC_FAR *pcmdtReserved, IDispatch __RPC_FAR *pdispReserved);
  74. STDMETHOD (ShowMessage)(HWND hwnd, LPOLESTR lpstrText, LPOLESTR lpstrCaption, DWORD dwType, LPOLESTR lpstrHelpFile, DWORD dwHelpContext, LRESULT *plResult);
  75. // *** IDocHostUIHandler ***
  76. STDMETHOD (TranslateAccelerator)(LPMSG lpMsg, const GUID __RPC_FAR *pguidCmdGroup, DWORD nCmdID);
  77. /*** IDocHostUIHandler2 ***/
  78. STDMETHOD (GetOverrideKeyPath)(LPOLESTR __RPC_FAR *pchKey, DWORD dw);
  79. /*** IOleCommandTarget ***/
  80. STDMETHOD (Exec)(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdExecOpt, VARIANTARG *pvaIn, VARIANTARG *pvaOut);
  81. /*** IServiceProvider ***/
  82. STDMETHOD (QueryService)(REFGUID guidService, REFIID riid, void **ppv);
  83. /*** IProtectFocus ***/
  84. STDMETHOD (AllowFocusChange)(BOOL *pfAllow);
  85. /*** IHTMLOMWindowServices ***/
  86. STDMETHOD (moveTo)(LONG x, LONG y);
  87. STDMETHOD (moveBy)(LONG x, LONG y);
  88. STDMETHOD (resizeTo)(LONG x, LONG y);
  89. STDMETHOD (resizeBy)(LONG x, LONG y);
  90. /*** INewWindowManager ***/
  91. STDMETHOD (EvaluateNewWindow)(LPCWSTR pszUrl, LPCWSTR pszName, LPCWSTR pszUrlContext, LPCWSTR pszFeatures, BOOL fReplace, DWORD dwFlags, DWORD dwUserActionTime);
  92. STDMETHOD (Initialize)(BOOL fRegisterAsBrowser);
  93. STDMETHOD (Finish)(void);
  94. HRESULT SetExternal(IDispatch *pDispatch);
  95. HRESULT SendCommand(INT commandId);
  96. HRESULT QueryCommandState(INT commandId, INT *commandState);
  97. UINT GetSecueLockIcon() { return secureLockIcon; }
  98. BOOL TranslateKey(LPMSG pMsg);
  99. /*Events*/
  100. BHNAVCOMPLETECALLBACK EventDocumentReady;
  101. BHNAVCOMPLETECALLBACK EventNavigateComplete;
  102. BHCALLBACK EventDownloadBegin;
  103. BHCALLBACK EventDownloadComplete;
  104. BHCALLBACK EventContainerDestroyed;
  105. BHCMDSTATECALLBACK EventCommandStateChange;
  106. BHTEXTCALLBACK EventStatusChange;
  107. BHTEXTCALLBACK EventTitleChange;
  108. BHCALLBACK EventSecureLockIconChange;
  109. BHCREATEPOPUPCALLBACK EventCreatePopup;
  110. BHBOOLCALLBACK EventVisible;
  111. BHBOOLCALLBACK EventSetResizable;
  112. BHCLOSECALLBACK EventWindowClosing;
  113. BHSHOWUICALLBACK EventShowUiElement;
  114. BHCLIENTTOHOSTCALLBACK EventClientToHost;
  115. BHWINDOWPOSCALLBACK EventSetWindowPos;
  116. BHFOCUSCHANGECALLBACK EventFocusChange;
  117. BHBOOLCALLBACK EventSetFullscreen;
  118. BHCALLBACK EventClosePopup;
  119. BHSERVICECALLBACK CallbackGetOmService;
  120. BHMSGCALLBACK CallbackRedirectKey;
  121. HRESULT GetExternalName(LPWSTR pszBuffer, INT cchBufferMax);
  122. void SetUiFlags(UINT flags, UINT mask);
  123. UINT GetUiFlags(UINT mask);
  124. HRESULT ToggleFullscreen();
  125. HRESULT GetTravelLog(ifc_travelloghelper **travelLog);
  126. protected:
  127. void OnBeforeNavigate(IDispatch *pDispatch, VARIANT *URL, VARIANT *Flags, VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers, VARIANT_BOOL *Cancel);
  128. void OnDownloadBegin(void);
  129. void OnDownloadComplete(void);
  130. void OnNavigateComplete(IDispatch *pDispatch, VARIANT *URL);
  131. void OnDocumentReady(IDispatch *pDispatch, VARIANT *URL);
  132. void OnNavigateError(IDispatch *pDispatch, VARIANT *URL, VARIANT *TargetFrameName, VARIANT *StatusCode, VARIANT_BOOL *Cancel);
  133. void OnCommandStateChange(LONG commandId, VARIANT_BOOL Enable);
  134. void OnStatusTextChange(LPCWSTR pszText);
  135. void OnSetSecureLockIcon(UINT secureLockIcon);
  136. void OnNavigateCancelled(LPCWSTR pszUrl, VARIANT_BOOL *Cancel);
  137. void OnNewWindow2(IDispatch **ppDisp, VARIANT_BOOL *Cancel);
  138. void OnNewWindow3(IDispatch **ppDisp, VARIANT_BOOL *Cancel, DWORD dwFlags, BSTR bstrUrlContext, BSTR bstrUrl);
  139. void OnTitleChange(BSTR pszText);
  140. void OnVisibleChange(VARIANT_BOOL fVisible);
  141. void OnWindowClosing(VARIANT_BOOL IsChildWindow, VARIANT_BOOL *Cancel);
  142. void OnShowUiElement(UINT elementId, VARIANT_BOOL fShow);
  143. void OnWindowSetResizable(VARIANT_BOOL Enable);
  144. void OnEnableFullscreen(VARIANT_BOOL Enable);
  145. void OnClientToHostWindow(LONG *CX, LONG *CY);
  146. void OnSetWindowPos(UINT Flags, LONG X, LONG Y, LONG CX, LONG CY);
  147. virtual COLORREF OnGetHostBkColor(void);
  148. virtual DWORD OnGetHostInfoFlags(void);
  149. virtual OLECHAR* OnGetHostCSS(void);
  150. virtual DWORD OnGetDownlodFlags(void);
  151. virtual LPCWSTR OnGetUserAgent(void);
  152. HRESULT FormatErrorParam(LPWSTR pszBuffer, INT cchBufferMax, UINT errorCode, LPCWSTR pszUrl);
  153. HANDLE InitializePopupHook(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  154. void DeletePopupHook(HANDLE hHook);
  155. void InitializeMenuPopup(HWND hwnd, HMENU hMenu, INT iPos, BOOL fWindowMenu);
  156. BOOL InputLangChangeRequest(HWND hwnd, UINT flags, HKL hkl);
  157. void InputLangChange(UINT charset, HKL hkl);
  158. void OnClosePopupInternal();
  159. HRESULT GetDebugConfig(ifc_omdebugconfig **debugConfig);
  160. HRESULT GetErrorPageName(LPWSTR pszBuffer, HRESULT cchBufferMax, UINT errorCode, BOOL fCancel);
  161. private:
  162. typedef enum
  163. {
  164. navigationForwardEnabled = 0x0001,
  165. navigationBackEnabled = 0x0002,
  166. navigationActive = 0x0004,
  167. } navigationState;
  168. private:
  169. obj_ombrowser *browserManager;
  170. IDispatch *externalDisp;
  171. IDropTargetHelper *pDropTargetHerlper;
  172. UINT navigationState;
  173. UINT secureLockIcon;
  174. WCHAR szDone[64];
  175. LPWSTR pszUserAgent;
  176. UINT uiFlags;
  177. };
  178. #ifdef _DEBUG
  179. void BrowserDebug_PrintRefs(Browser *browser);
  180. #else
  181. #define BrowserDebug_PrintRefs(x)
  182. #endif //_DEBUG
  183. #endif //NULLSOFT_WINAMP_OMBROWSER_HEADER