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

Unified Diff: src/plugin/PluginClass.h

Issue 4937147073167360: Issue 1672 - Subscribe and listen COM events using ATL::IDispEventImpl and BEGIN_SINK_MAP (Closed)
Patch Set: fix-NITs Created Jan. 9, 2015, 4:06 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/plugin/PluginClass.h
diff --git a/src/plugin/PluginClass.h b/src/plugin/PluginClass.h
index e6ea661304f08c74b27bc7a49911417e3772844f..6a196273d8ef35c9baf92ebf77f475a74bad34c8 100644
--- a/src/plugin/PluginClass.h
+++ b/src/plugin/PluginClass.h
@@ -27,11 +27,11 @@ class CPluginMimeFilterClient;
class ATL_NO_VTABLE CPluginClass :
- public CComObjectRootEx<CComMultiThreadModel>,
- public CComCoClass<CPluginClass, &CLSID_PluginClass>,
- public IObjectWithSiteImpl<CPluginClass>,
- public IDispatchImpl<IIEPlugin, &IID_IIEPlugin, &LIBID_PluginLib>,
- public IOleCommandTarget
+ public ATL::CComObjectRootEx<ATL::CComMultiThreadModel>,
+ public ATL::CComCoClass<CPluginClass, &CLSID_PluginClass>,
+ public ATL::IObjectWithSiteImpl<CPluginClass>,
+ public IOleCommandTarget,
+ public ATL::IDispEventImpl<1, CPluginClass, &DIID_DWebBrowserEvents2, &LIBID_SHDocVw, 1, 1>
{
friend class CPluginTab;
@@ -47,12 +47,20 @@ public:
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(CPluginClass)
- COM_INTERFACE_ENTRY(IIEPlugin)
- COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IObjectWithSite)
COM_INTERFACE_ENTRY(IOleCommandTarget)
END_COM_MAP()
+ BEGIN_SINK_MAP(CPluginClass)
+ SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_BEFORENAVIGATE2, OnBeforeNavigate2)
+ SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOWNLOADBEGIN, OnDownloadBegin)
+ SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOWNLOADCOMPLETE, OnDownloadComplete)
+ SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOCUMENTCOMPLETE, OnDocumentComplete)
+ SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_WINDOWSTATECHANGED, OnWindowStateChanged)
+ SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_COMMANDSTATECHANGE, OnCommandStateChange)
+ SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_ONQUIT, Unadvise)
Eric 2015/01/12 14:18:07 I'd prefer to see an OnQuit function explicitly, e
+ END_SINK_MAP()
+
CPluginClass();
~CPluginClass();
@@ -68,10 +76,6 @@ public:
STDMETHOD(QueryStatus)(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT* pCmdText);
STDMETHOD(Exec)(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, VARIANTARG* pvaOut);
- // IDispatch
-
- STDMETHOD(Invoke)(DISPID dispidMember,REFIID riid, LCID lcid, WORD wFlags,
- DISPPARAMS * pdispparams, VARIANT * pvarResult,EXCEPINFO * pexcepinfo, UINT * puArgErr);
static CPluginTab* GetTab(DWORD dwThreadId);
CPluginTab* GetTab();
@@ -87,14 +91,11 @@ private:
void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFlags);
bool CreateStatusBarPane();
- CComPtr<IConnectionPoint> GetConnectionPoint();
-
public:
HWND GetBrowserHWND() const;
HWND GetTabHWND() const;
CComQIPtr<IWebBrowser2> GetBrowser() const;
- STDMETHODIMP OnTabChanged(DISPPARAMS* pDispParams, WORD wFlags);
static CPluginMimeFilterClient* s_mimeFilter;
@@ -113,9 +114,21 @@ private:
static LRESULT CALLBACK NewStatusProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK PaneWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
static void FirstRunThread();
- void BeforeNavigate2(DISPPARAMS* pDispParams);
- void Unadvice();
+ void STDMETHODCALLTYPE OnBeforeNavigate2(/* [in] */ IDispatch* pDisp,
+ /* [in] */ VARIANT* URL,
+ /* [in] */ VARIANT* Flags,
+ /* [in] */ VARIANT* TargetFrameName,
+ /* [in] */ VARIANT* PostData,
+ /* [in] */ VARIANT* Headers,
+ /* [in, out] */ VARIANT_BOOL* Cancel);
+ void STDMETHODCALLTYPE OnDownloadBegin();
+ void STDMETHODCALLTYPE OnDownloadComplete();
+ void STDMETHODCALLTYPE OnDocumentComplete(IDispatch* frameBrowserDisp, VARIANT* /*urlOrPidl*/);
+ void STDMETHODCALLTYPE OnWindowStateChanged(unsigned long flags, unsigned long validFlagsMask);
+ void STDMETHODCALLTYPE OnCommandStateChange(long command, VARIANT_BOOL enable);
+ // OnOnQuit
+ void STDMETHODCALLTYPE Unadvise();
void ShowStatusBar();
bool IsStatusBarEnabled();
@@ -123,7 +136,6 @@ private:
public:
CComQIPtr<IWebBrowser2> m_webBrowser2;
private:
- DWORD m_nConnectionID;
HWND m_hBrowserWnd;
HWND m_hTabWnd;
HWND m_hStatusBarWnd;
@@ -137,7 +149,7 @@ private:
NotificationMessage notificationMessage;
- bool m_isAdviced;
+ bool m_isAdvised;
bool m_isInitializedOk;
// Atom pane class

Powered by Google App Engine
This is Rietveld