Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/plugin/PluginClass.h

Issue 4937147073167360: Issue 1672 - Subscribe and listen COM events using ATL::IDispEventImpl and BEGIN_SINK_MAP (Closed)
Patch Set: Created Dec. 8, 2014, 12:19 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 10 matching lines...) Expand all
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 #define WM_WHITELIST_DOMAIN (WM_LAUNCH_INFO + 1) 25 #define WM_WHITELIST_DOMAIN (WM_LAUNCH_INFO + 1)
26 26
27 class CPluginMimeFilterClient; 27 class CPluginMimeFilterClient;
28 28
29 29
30 class ATL_NO_VTABLE CPluginClass : 30 class ATL_NO_VTABLE CPluginClass :
31 public CComObjectRootEx<CComMultiThreadModel>, 31 public ATL::CComObjectRootEx<ATL::CComMultiThreadModel>,
32 public CComCoClass<CPluginClass, &CLSID_PluginClass>, 32 public ATL::CComCoClass<CPluginClass, &CLSID_PluginClass>,
33 public IObjectWithSiteImpl<CPluginClass>, 33 public ATL::IObjectWithSiteImpl<CPluginClass>,
34 public IDispatchImpl<IIEPlugin, &IID_IIEPlugin, &LIBID_PluginLib>, 34 public IOleCommandTarget,
35 public IOleCommandTarget 35 public ATL::IDispEventImpl<1, CPluginClass, &DIID_DWebBrowserEvents2, &LIBID_S HDocVw, 1, 1>
Eric 2014/12/31 17:03:15 From http://msdn.microsoft.com/en-us/library/d7eec
Oleksandr 2015/01/09 00:02:17 For reference: discussion on this moved to the com
36 { 36 {
37 37
38 friend class CPluginTab; 38 friend class CPluginTab;
39 39
40 private: 40 private:
41 41
42 CPluginTab* m_tab; 42 CPluginTab* m_tab;
43 43
44 public: 44 public:
45 45
46 DECLARE_REGISTRY_RESOURCEID(IDR_PLUGIN_CLASS) 46 DECLARE_REGISTRY_RESOURCEID(IDR_PLUGIN_CLASS)
47 47
48 DECLARE_PROTECT_FINAL_CONSTRUCT() 48 DECLARE_PROTECT_FINAL_CONSTRUCT()
49 49
50 BEGIN_COM_MAP(CPluginClass) 50 BEGIN_COM_MAP(CPluginClass)
51 COM_INTERFACE_ENTRY(IIEPlugin)
52 COM_INTERFACE_ENTRY(IDispatch)
53 COM_INTERFACE_ENTRY(IObjectWithSite) 51 COM_INTERFACE_ENTRY(IObjectWithSite)
54 COM_INTERFACE_ENTRY(IOleCommandTarget) 52 COM_INTERFACE_ENTRY(IOleCommandTarget)
55 END_COM_MAP() 53 END_COM_MAP()
56 54
55 BEGIN_SINK_MAP(CPluginClass)
56 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_BEFORENAVIGATE2, OnBeforeNa vigate2)
57 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOWNLOADBEGIN, OnDownloadBe gin)
58 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOWNLOADCOMPLETE, OnDownloa dComplete)
59 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOCUMENTCOMPLETE, OnDocumen tComplete)
60 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_WINDOWSTATECHANGED, OnWindo wStateChanged)
61 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_COMMANDSTATECHANGE, OnComma ndStateChange)
62 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_ONQUIT, Unadvice)
63 END_SINK_MAP()
64
57 CPluginClass(); 65 CPluginClass();
58 ~CPluginClass(); 66 ~CPluginClass();
59 67
60 HRESULT FinalConstruct(); 68 HRESULT FinalConstruct();
61 void FinalRelease(); 69 void FinalRelease();
62 70
63 // IObjectWithSite 71 // IObjectWithSite
64 72
65 STDMETHOD(SetSite)(IUnknown *pUnkSite); 73 STDMETHOD(SetSite)(IUnknown *pUnkSite);
66 74
67 // IOleCommandTarget 75 // IOleCommandTarget
68 76
69 STDMETHOD(QueryStatus)(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT* pCmdText); 77 STDMETHOD(QueryStatus)(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT* pCmdText);
70 STDMETHOD(Exec)(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, VARIANTARG* pva Out); 78 STDMETHOD(Exec)(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, VARIANTARG* pva Out);
71 79
72 // IDispatch
73
74 STDMETHOD(Invoke)(DISPID dispidMember,REFIID riid, LCID lcid, WORD wFlags,
75 DISPPARAMS * pdispparams, VARIANT * pvarResult,EXCEPINFO * pexcepinfo, UINT * puArgErr);
76 80
77 static CPluginTab* GetTab(DWORD dwThreadId); 81 static CPluginTab* GetTab(DWORD dwThreadId);
78 CPluginTab* GetTab(); 82 CPluginTab* GetTab();
79 83
80 void UpdateStatusBar(); 84 void UpdateStatusBar();
81 static DWORD WINAPI MainThreadProc(LPVOID pParam); 85 static DWORD WINAPI MainThreadProc(LPVOID pParam);
82 86
83 private: 87 private:
84 88
85 bool SetMenuBar(HMENU hMenu, const CString& url); 89 bool SetMenuBar(HMENU hMenu, const CString& url);
86 HMENU CreatePluginMenu(const CString& url); 90 HMENU CreatePluginMenu(const CString& url);
87 91
88 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla gs); 92 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla gs);
89 bool CreateStatusBarPane(); 93 bool CreateStatusBarPane();
90 94
91 CComPtr<IConnectionPoint> GetConnectionPoint();
92
93 public: 95 public:
94 HWND GetBrowserHWND() const; 96 HWND GetBrowserHWND() const;
95 HWND GetTabHWND() const; 97 HWND GetTabHWND() const;
96 CComQIPtr<IWebBrowser2> GetBrowser() const; 98 CComQIPtr<IWebBrowser2> GetBrowser() const;
97 99
98 STDMETHODIMP OnTabChanged(DISPPARAMS* pDispParams, WORD wFlags);
99 100
100 static CPluginMimeFilterClient* s_mimeFilter; 101 static CPluginMimeFilterClient* s_mimeFilter;
101 102
102 private: 103 private:
103 104
104 CString GetBrowserUrl() const; 105 CString GetBrowserUrl() const;
105 106
106 107
107 static DWORD WINAPI StartInitObject(LPVOID thisPtr); 108 static DWORD WINAPI StartInitObject(LPVOID thisPtr);
108 bool InitObject(bool bBHO); 109 bool InitObject(bool bBHO);
109 void CloseTheme(); 110 void CloseTheme();
110 void UpdateTheme(); 111 void UpdateTheme();
111 112
112 static HICON GetStatusBarIcon(const CString& url); 113 static HICON GetStatusBarIcon(const CString& url);
113 static CPluginClass* FindInstance(HWND hStatusBarWnd); 114 static CPluginClass* FindInstance(HWND hStatusBarWnd);
114 static LRESULT CALLBACK NewStatusProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 115 static LRESULT CALLBACK NewStatusProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
115 static LRESULT CALLBACK PaneWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 116 static LRESULT CALLBACK PaneWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
116 static void FirstRunThread(); 117 static void FirstRunThread();
117 void BeforeNavigate2(DISPPARAMS* pDispParams);
118 118
119 void Unadvice(); 119 void STDMETHODCALLTYPE OnBeforeNavigate2(/* [in] */ IDispatch* pDisp,
120 /* [in] */ VARIANT* URL,
121 /* [in] */ VARIANT* Flags,
122 /* [in] */ VARIANT* TargetFrameName,
123 /* [in] */ VARIANT* PostData,
124 /* [in] */ VARIANT* Headers,
125 /* [in, out] */ VARIANT_BOOL* Cancel);
126 void STDMETHODCALLTYPE OnDownloadBegin();
127 void STDMETHODCALLTYPE OnDownloadComplete();
128 void STDMETHODCALLTYPE OnDocumentComplete(IDispatch* frameBrowserDisp, VARIANT * /*urlOrPidl*/);
129 void STDMETHODCALLTYPE OnWindowStateChanged(unsigned long flags, unsigned long validFlagsMask);
130 void STDMETHODCALLTYPE OnCommandStateChange(long command, VARIANT_BOOL enable) ;
131 // OnOnQuit
132 void STDMETHODCALLTYPE Unadvice();
120 133
121 void ShowStatusBar(); 134 void ShowStatusBar();
122 bool IsStatusBarEnabled(); 135 bool IsStatusBarEnabled();
123 136
124 public: 137 public:
125 CComQIPtr<IWebBrowser2> m_webBrowser2; 138 CComQIPtr<IWebBrowser2> m_webBrowser2;
126 private: 139 private:
127 DWORD m_nConnectionID;
128 HWND m_hBrowserWnd; 140 HWND m_hBrowserWnd;
129 HWND m_hTabWnd; 141 HWND m_hTabWnd;
130 HWND m_hStatusBarWnd; 142 HWND m_hStatusBarWnd;
131 HWND m_hPaneWnd; 143 HWND m_hPaneWnd;
132 144
133 WNDPROC m_pWndProcStatus; 145 WNDPROC m_pWndProcStatus;
134 int m_nPaneWidth; 146 int m_nPaneWidth;
135 HANDLE m_hTheme; 147 HANDLE m_hTheme;
136 148
137 CriticalSection m_csStatusBar; 149 CriticalSection m_csStatusBar;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 182
171 // Async browser 183 // Async browser
172 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2; 184 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2;
173 static CComQIPtr<IWebBrowser2> GetAsyncBrowser(); 185 static CComQIPtr<IWebBrowser2> GetAsyncBrowser();
174 }; 186 };
175 187
176 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass) 188 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass)
177 189
178 190
179 #endif // _PLUGIN_CLASS_H_ 191 #endif // _PLUGIN_CLASS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld