OLD | NEW |
1 /* | 1 /* |
2 * http://msdn.microsoft.com/en-us/library/bb250436.aspx | 2 * http://msdn.microsoft.com/en-us/library/bb250436.aspx |
3 */ | 3 */ |
4 | 4 |
5 #ifndef _PLUGIN_CLASS_H_ | 5 #ifndef _PLUGIN_CLASS_H_ |
6 #define _PLUGIN_CLASS_H_ | 6 #define _PLUGIN_CLASS_H_ |
7 | 7 |
8 | 8 |
9 #include "PluginTypedef.h" | 9 #include "PluginTypedef.h" |
10 #include "Plugin.h" | 10 #include "Plugin.h" |
11 #include "PluginTab.h" | 11 #include "PluginTab.h" |
12 #define _CRTDBG_MAP_ALLOC | 12 #define _CRTDBG_MAP_ALLOC |
13 #include <stdlib.h> | 13 #include <stdlib.h> |
14 #include <crtdbg.h> | 14 #include <crtdbg.h> |
15 #include <set> | 15 #include <set> |
16 | 16 |
17 #include "NotificationMessage.h" | 17 #include "NotificationMessage.h" |
18 | 18 |
19 #define ICON_PLUGIN_DISABLED 0 | 19 #define ICON_PLUGIN_DISABLED 0 |
20 #define ICON_PLUGIN_ENABLED 1 | 20 #define ICON_PLUGIN_ENABLED 1 |
21 #define ICON_PLUGIN_DEACTIVATED 2 | 21 #define ICON_PLUGIN_DEACTIVATED 2 |
22 #define ICON_MAX 3 | 22 #define ICON_MAX 3 |
23 | 23 |
24 #define WM_LAUNCH_INFO (WM_APP + 10) | 24 #define WM_LAUNCH_INFO (WM_APP + 10) |
25 | 25 |
26 class CPluginMimeFilterClient; | 26 class CPluginMimeFilterClient; |
27 | 27 |
28 | 28 |
29 class ATL_NO_VTABLE CPluginClass : | 29 class ATL_NO_VTABLE CPluginClass : |
30 public CComObjectRootEx<CComMultiThreadModel>, | 30 public ATL::CComObjectRootEx<ATL::CComMultiThreadModel>, |
31 public CComCoClass<CPluginClass, &CLSID_PluginClass>, | 31 public ATL::CComCoClass<CPluginClass, &CLSID_PluginClass>, |
32 public IObjectWithSiteImpl<CPluginClass>, | 32 public ATL::IObjectWithSiteImpl<CPluginClass>, |
33 public IDispatchImpl<IIEPlugin, &IID_IIEPlugin, &LIBID_PluginLib>, | 33 public IOleCommandTarget, |
34 public IOleCommandTarget | 34 public ATL::IDispEventImpl<1, CPluginClass, &DIID_DWebBrowserEvents2, &LIBID_S
HDocVw, 1, 1> |
35 { | 35 { |
36 | 36 |
37 friend class CPluginTab; | 37 friend class CPluginTab; |
38 | 38 |
39 private: | 39 private: |
40 | 40 |
41 CPluginTab* m_tab; | 41 CPluginTab* m_tab; |
42 | 42 |
43 public: | 43 public: |
44 | 44 |
45 DECLARE_REGISTRY_RESOURCEID(IDR_PLUGIN_CLASS) | 45 DECLARE_REGISTRY_RESOURCEID(IDR_PLUGIN_CLASS) |
46 | 46 |
47 DECLARE_PROTECT_FINAL_CONSTRUCT() | 47 DECLARE_PROTECT_FINAL_CONSTRUCT() |
48 | 48 |
49 BEGIN_COM_MAP(CPluginClass) | 49 BEGIN_COM_MAP(CPluginClass) |
50 COM_INTERFACE_ENTRY(IIEPlugin) | |
51 COM_INTERFACE_ENTRY(IDispatch) | |
52 COM_INTERFACE_ENTRY(IObjectWithSite) | 50 COM_INTERFACE_ENTRY(IObjectWithSite) |
53 COM_INTERFACE_ENTRY(IOleCommandTarget) | 51 COM_INTERFACE_ENTRY(IOleCommandTarget) |
54 END_COM_MAP() | 52 END_COM_MAP() |
55 | 53 |
| 54 BEGIN_SINK_MAP(CPluginClass) |
| 55 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_BEFORENAVIGATE2, OnBeforeNa
vigate2) |
| 56 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOWNLOADBEGIN, OnDownloadBe
gin) |
| 57 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOWNLOADCOMPLETE, OnDownloa
dComplete) |
| 58 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOCUMENTCOMPLETE, OnDocumen
tComplete) |
| 59 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_WINDOWSTATECHANGED, OnWindo
wStateChanged) |
| 60 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_COMMANDSTATECHANGE, OnComma
ndStateChange) |
| 61 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_ONQUIT, OnOnQuit) |
| 62 END_SINK_MAP() |
| 63 |
56 CPluginClass(); | 64 CPluginClass(); |
57 ~CPluginClass(); | 65 ~CPluginClass(); |
58 | 66 |
59 HRESULT FinalConstruct(); | 67 HRESULT FinalConstruct(); |
60 void FinalRelease(); | 68 void FinalRelease(); |
61 | 69 |
62 // IObjectWithSite | 70 // IObjectWithSite |
63 | 71 |
64 STDMETHOD(SetSite)(IUnknown *pUnkSite); | 72 STDMETHOD(SetSite)(IUnknown *pUnkSite); |
65 | 73 |
66 // IOleCommandTarget | 74 // IOleCommandTarget |
67 | 75 |
68 STDMETHOD(QueryStatus)(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[
], OLECMDTEXT* pCmdText); | 76 STDMETHOD(QueryStatus)(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[
], OLECMDTEXT* pCmdText); |
69 STDMETHOD(Exec)(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, VARIANTARG* pva
Out); | 77 STDMETHOD(Exec)(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, VARIANTARG* pva
Out); |
70 | 78 |
71 // IDispatch | |
72 | |
73 STDMETHOD(Invoke)(DISPID dispidMember,REFIID riid, LCID lcid, WORD wFlags, | |
74 DISPPARAMS * pdispparams, VARIANT * pvarResult,EXCEPINFO * pexcepinfo, UINT
* puArgErr); | |
75 | 79 |
76 static CPluginTab* GetTab(DWORD dwThreadId); | 80 static CPluginTab* GetTab(DWORD dwThreadId); |
77 CPluginTab* GetTab(); | 81 CPluginTab* GetTab(); |
78 | 82 |
79 void UpdateStatusBar(); | 83 void UpdateStatusBar(); |
80 static DWORD WINAPI MainThreadProc(LPVOID pParam); | 84 static DWORD WINAPI MainThreadProc(LPVOID pParam); |
81 | 85 |
82 private: | 86 private: |
83 | 87 |
84 bool SetMenuBar(HMENU hMenu, const CString& url); | 88 bool SetMenuBar(HMENU hMenu, const CString& url); |
85 HMENU CreatePluginMenu(const CString& url); | 89 HMENU CreatePluginMenu(const CString& url); |
86 | 90 |
87 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla
gs); | 91 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla
gs); |
88 bool CreateStatusBarPane(); | 92 bool CreateStatusBarPane(); |
89 | 93 |
90 CComPtr<IConnectionPoint> GetConnectionPoint(); | |
91 | |
92 public: | 94 public: |
93 HWND GetBrowserHWND() const; | 95 HWND GetBrowserHWND() const; |
94 HWND GetTabHWND() const; | 96 HWND GetTabHWND() const; |
95 CComQIPtr<IWebBrowser2> GetBrowser() const; | 97 CComQIPtr<IWebBrowser2> GetBrowser() const; |
96 | 98 |
97 STDMETHODIMP OnTabChanged(DISPPARAMS* pDispParams, WORD wFlags); | |
98 | 99 |
99 static CPluginMimeFilterClient* s_mimeFilter; | 100 static CPluginMimeFilterClient* s_mimeFilter; |
100 | 101 |
101 private: | 102 private: |
102 | 103 |
103 CString GetBrowserUrl() const; | 104 CString GetBrowserUrl() const; |
104 | 105 |
105 | 106 |
106 static DWORD WINAPI StartInitObject(LPVOID thisPtr); | 107 static DWORD WINAPI StartInitObject(LPVOID thisPtr); |
107 bool InitObject(bool bBHO); | 108 bool InitObject(bool bBHO); |
108 void CloseTheme(); | 109 void CloseTheme(); |
109 void UpdateTheme(); | 110 void UpdateTheme(); |
110 | 111 |
111 static HICON GetStatusBarIcon(const CString& url); | 112 static HICON GetStatusBarIcon(const CString& url); |
112 static CPluginClass* FindInstance(HWND hStatusBarWnd); | 113 static CPluginClass* FindInstance(HWND hStatusBarWnd); |
113 static LRESULT CALLBACK NewStatusProc(HWND hWnd, UINT message, WPARAM wParam,
LPARAM lParam); | 114 static LRESULT CALLBACK NewStatusProc(HWND hWnd, UINT message, WPARAM wParam,
LPARAM lParam); |
114 static LRESULT CALLBACK PaneWindowProc(HWND hWnd, UINT message, WPARAM wParam,
LPARAM lParam); | 115 static LRESULT CALLBACK PaneWindowProc(HWND hWnd, UINT message, WPARAM wParam,
LPARAM lParam); |
115 static void FirstRunThread(); | 116 static void FirstRunThread(); |
116 void BeforeNavigate2(DISPPARAMS* pDispParams); | |
117 | 117 |
118 void Unadvice(); | 118 void STDMETHODCALLTYPE OnBeforeNavigate2(/* [in] */ IDispatch* pDisp, |
| 119 /* [in] */ VARIANT* URL, |
| 120 /* [in] */ VARIANT* Flags, |
| 121 /* [in] */ VARIANT* TargetFrameName, |
| 122 /* [in] */ VARIANT* PostData, |
| 123 /* [in] */ VARIANT* Headers, |
| 124 /* [in, out] */ VARIANT_BOOL* Cancel); |
| 125 void STDMETHODCALLTYPE OnDownloadBegin(); |
| 126 void STDMETHODCALLTYPE OnDownloadComplete(); |
| 127 void STDMETHODCALLTYPE OnDocumentComplete(IDispatch* frameBrowserDisp, VARIANT
* /*urlOrPidl*/); |
| 128 void STDMETHODCALLTYPE OnWindowStateChanged(unsigned long flags, unsigned long
validFlagsMask); |
| 129 void STDMETHODCALLTYPE OnCommandStateChange(long command, VARIANT_BOOL enable)
; |
| 130 void STDMETHODCALLTYPE OnOnQuit(); |
| 131 void Unadvise(); |
119 | 132 |
120 void ShowStatusBar(); | 133 void ShowStatusBar(); |
121 bool IsStatusBarEnabled(); | 134 bool IsStatusBarEnabled(); |
122 | 135 |
123 public: | 136 public: |
124 CComQIPtr<IWebBrowser2> m_webBrowser2; | 137 CComQIPtr<IWebBrowser2> m_webBrowser2; |
125 private: | 138 private: |
126 DWORD m_nConnectionID; | |
127 HWND m_hBrowserWnd; | 139 HWND m_hBrowserWnd; |
128 HWND m_hTabWnd; | 140 HWND m_hTabWnd; |
129 HWND m_hStatusBarWnd; | 141 HWND m_hStatusBarWnd; |
130 HWND m_hPaneWnd; | 142 HWND m_hPaneWnd; |
131 | 143 |
132 WNDPROC m_pWndProcStatus; | 144 WNDPROC m_pWndProcStatus; |
133 int m_nPaneWidth; | 145 int m_nPaneWidth; |
134 HANDLE m_hTheme; | 146 HANDLE m_hTheme; |
135 | 147 |
136 CriticalSection m_csStatusBar; | 148 CriticalSection m_csStatusBar; |
137 | 149 |
138 NotificationMessage notificationMessage; | 150 NotificationMessage notificationMessage; |
139 | 151 |
140 bool m_isAdviced; | 152 bool m_isAdvised; |
141 bool m_isInitializedOk; | 153 bool m_isInitializedOk; |
142 | 154 |
143 // Atom pane class | 155 // Atom pane class |
144 static ATOM s_atomPaneClass; | 156 static ATOM s_atomPaneClass; |
145 | 157 |
146 static ATOM GetAtomPaneClass(); | 158 static ATOM GetAtomPaneClass(); |
147 | 159 |
148 // Icons | 160 // Icons |
149 static HICON s_hIcons[ICON_MAX]; | 161 static HICON s_hIcons[ICON_MAX]; |
150 static DWORD s_hIconTypes[ICON_MAX]; | 162 static DWORD s_hIconTypes[ICON_MAX]; |
(...skipping 16 matching lines...) Expand all Loading... |
167 | 179 |
168 // Async browser | 180 // Async browser |
169 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2; | 181 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2; |
170 static CComQIPtr<IWebBrowser2> GetAsyncBrowser(); | 182 static CComQIPtr<IWebBrowser2> GetAsyncBrowser(); |
171 }; | 183 }; |
172 | 184 |
173 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass) | 185 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass) |
174 | 186 |
175 | 187 |
176 #endif // _PLUGIN_CLASS_H_ | 188 #endif // _PLUGIN_CLASS_H_ |
OLD | NEW |