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

Delta Between Two Patch Sets: src/plugin/PluginClass.h

Issue 4937147073167360: Issue 1672 - Subscribe and listen COM events using ATL::IDispEventImpl and BEGIN_SINK_MAP (Closed)
Left Patch Set: fix-NITs Created Jan. 9, 2015, 4:06 p.m.
Right Patch Set: rebase, parent = 5d5eb4df1bf2 Created March 13, 2015, 3:20 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/plugin/AdblockPlus.idl ('k') | src/plugin/PluginClass.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH
4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
1 /* 18 /*
2 * http://msdn.microsoft.com/en-us/library/bb250436.aspx 19 * http://msdn.microsoft.com/en-us/library/bb250436.aspx
3 */ 20 */
4 21
5 #ifndef _PLUGIN_CLASS_H_ 22 #ifndef _PLUGIN_CLASS_H_
6 #define _PLUGIN_CLASS_H_ 23 #define _PLUGIN_CLASS_H_
7 24
8 25
9 #include "PluginTypedef.h"
10 #include "Plugin.h" 26 #include "Plugin.h"
11 #include "PluginTab.h" 27 #include "PluginTabBase.h"
12 #define _CRTDBG_MAP_ALLOC 28 #define _CRTDBG_MAP_ALLOC
13 #include <stdlib.h> 29 #include <stdlib.h>
14 #include <crtdbg.h> 30 #include <crtdbg.h>
15 #include <set> 31 #include <set>
16 32
17 #include "NotificationMessage.h" 33 #include "NotificationMessage.h"
18 34
19 #define ICON_PLUGIN_DISABLED 0 35 #define ICON_PLUGIN_DISABLED 0
20 #define ICON_PLUGIN_ENABLED 1 36 #define ICON_PLUGIN_ENABLED 1
21 #define ICON_PLUGIN_DEACTIVATED 2 37 #define ICON_PLUGIN_DEACTIVATED 2
(...skipping 24 matching lines...) Expand all
46 62
47 DECLARE_PROTECT_FINAL_CONSTRUCT() 63 DECLARE_PROTECT_FINAL_CONSTRUCT()
48 64
49 BEGIN_COM_MAP(CPluginClass) 65 BEGIN_COM_MAP(CPluginClass)
50 COM_INTERFACE_ENTRY(IObjectWithSite) 66 COM_INTERFACE_ENTRY(IObjectWithSite)
51 COM_INTERFACE_ENTRY(IOleCommandTarget) 67 COM_INTERFACE_ENTRY(IOleCommandTarget)
52 END_COM_MAP() 68 END_COM_MAP()
53 69
54 BEGIN_SINK_MAP(CPluginClass) 70 BEGIN_SINK_MAP(CPluginClass)
55 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_BEFORENAVIGATE2, OnBeforeNa vigate2) 71 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) 72 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOWNLOADCOMPLETE, OnDownloa dComplete)
58 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOCUMENTCOMPLETE, OnDocumen tComplete) 73 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOCUMENTCOMPLETE, OnDocumen tComplete)
59 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_WINDOWSTATECHANGED, OnWindo wStateChanged) 74 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_WINDOWSTATECHANGED, OnWindo wStateChanged)
60 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_COMMANDSTATECHANGE, OnComma ndStateChange) 75 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_COMMANDSTATECHANGE, OnComma ndStateChange)
61 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_ONQUIT, Unadvise) 76 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_ONQUIT, OnOnQuit)
Eric 2015/01/12 14:18:07 I'd prefer to see an OnQuit function explicitly, e
62 END_SINK_MAP() 77 END_SINK_MAP()
63 78
64 CPluginClass(); 79 CPluginClass();
65 ~CPluginClass(); 80 ~CPluginClass();
66 81
67 HRESULT FinalConstruct(); 82 HRESULT FinalConstruct();
68 void FinalRelease(); 83 void FinalRelease();
69 84
70 // IObjectWithSite 85 // IObjectWithSite
71 86
72 STDMETHOD(SetSite)(IUnknown *pUnkSite); 87 STDMETHOD(SetSite)(IUnknown *pUnkSite);
73 88
74 // IOleCommandTarget 89 // IOleCommandTarget
75 90
76 STDMETHOD(QueryStatus)(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT* pCmdText); 91 STDMETHOD(QueryStatus)(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT* pCmdText);
77 STDMETHOD(Exec)(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, VARIANTARG* pva Out); 92 STDMETHOD(Exec)(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, VARIANTARG* pva Out);
78 93
79 94
80 static CPluginTab* GetTab(DWORD dwThreadId); 95 static CPluginTab* GetTab(DWORD dwThreadId);
81 CPluginTab* GetTab(); 96 CPluginTab* GetTab();
82 97
83 void UpdateStatusBar(); 98 void UpdateStatusBar();
84 static DWORD WINAPI MainThreadProc(LPVOID pParam); 99 static DWORD WINAPI MainThreadProc(LPVOID pParam);
85 100
86 private: 101 private:
87 102
88 bool SetMenuBar(HMENU hMenu, const CString& url); 103 bool SetMenuBar(HMENU hMenu, const std::wstring& url);
89 HMENU CreatePluginMenu(const CString& url); 104 HMENU CreatePluginMenu(const std::wstring& url);
90 105
91 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla gs); 106 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla gs);
92 bool CreateStatusBarPane(); 107 bool CreateStatusBarPane();
93 108
94 public: 109 public:
95 HWND GetBrowserHWND() const; 110 HWND GetBrowserHWND() const;
96 HWND GetTabHWND() const; 111 HWND GetTabHWND() const;
97 CComQIPtr<IWebBrowser2> GetBrowser() const; 112 CComQIPtr<IWebBrowser2> GetBrowser() const;
98 113
99 114
100 static CPluginMimeFilterClient* s_mimeFilter; 115 static CPluginMimeFilterClient* s_mimeFilter;
101 116
102 private: 117 private:
103 118
104 CString GetBrowserUrl() const; 119 std::wstring GetBrowserUrl() const;
105
106 120
107 static DWORD WINAPI StartInitObject(LPVOID thisPtr); 121 static DWORD WINAPI StartInitObject(LPVOID thisPtr);
108 bool InitObject(bool bBHO); 122 bool InitObject(bool bBHO);
109 void CloseTheme(); 123 void CloseTheme();
110 void UpdateTheme(); 124 void UpdateTheme();
111 125
112 static HICON GetStatusBarIcon(const CString& url); 126 static HICON GetStatusBarIcon(const std::wstring& url);
113 static CPluginClass* FindInstance(HWND hStatusBarWnd); 127 static CPluginClass* FindInstance(HWND hStatusBarWnd);
114 static LRESULT CALLBACK NewStatusProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 128 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); 129 static LRESULT CALLBACK PaneWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
116 static void FirstRunThread(); 130 static void FirstRunThread();
117 131
118 void STDMETHODCALLTYPE OnBeforeNavigate2(/* [in] */ IDispatch* pDisp, 132 void STDMETHODCALLTYPE OnBeforeNavigate2(/* [in] */ IDispatch* pDisp,
119 /* [in] */ VARIANT* URL, 133 /* [in] */ VARIANT* URL,
120 /* [in] */ VARIANT* Flags, 134 /* [in] */ VARIANT* Flags,
121 /* [in] */ VARIANT* TargetFrameName, 135 /* [in] */ VARIANT* TargetFrameName,
122 /* [in] */ VARIANT* PostData, 136 /* [in] */ VARIANT* PostData,
123 /* [in] */ VARIANT* Headers, 137 /* [in] */ VARIANT* Headers,
124 /* [in, out] */ VARIANT_BOOL* Cancel); 138 /* [in, out] */ VARIANT_BOOL* Cancel);
125 void STDMETHODCALLTYPE OnDownloadBegin();
126 void STDMETHODCALLTYPE OnDownloadComplete(); 139 void STDMETHODCALLTYPE OnDownloadComplete();
127 void STDMETHODCALLTYPE OnDocumentComplete(IDispatch* frameBrowserDisp, VARIANT * /*urlOrPidl*/); 140 void STDMETHODCALLTYPE OnDocumentComplete(IDispatch* frameBrowserDisp, VARIANT * /*urlOrPidl*/);
128 void STDMETHODCALLTYPE OnWindowStateChanged(unsigned long flags, unsigned long validFlagsMask); 141 void STDMETHODCALLTYPE OnWindowStateChanged(unsigned long flags, unsigned long validFlagsMask);
129 void STDMETHODCALLTYPE OnCommandStateChange(long command, VARIANT_BOOL enable) ; 142 void STDMETHODCALLTYPE OnCommandStateChange(long command, VARIANT_BOOL enable) ;
130 // OnOnQuit 143 void STDMETHODCALLTYPE OnOnQuit();
131 void STDMETHODCALLTYPE Unadvise(); 144 void Unadvise();
132 145
133 void ShowStatusBar(); 146 void ShowStatusBar();
134 bool IsStatusBarEnabled(); 147 bool IsStatusBarEnabled();
135 148
136 public: 149 public:
137 CComQIPtr<IWebBrowser2> m_webBrowser2; 150 CComQIPtr<IWebBrowser2> m_webBrowser2;
138 private: 151 private:
139 HWND m_hBrowserWnd; 152 HWND m_hBrowserWnd;
140 HWND m_hTabWnd; 153 HWND m_hTabWnd;
141 HWND m_hStatusBarWnd; 154 HWND m_hStatusBarWnd;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 192
180 // Async browser 193 // Async browser
181 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2; 194 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2;
182 static CComQIPtr<IWebBrowser2> GetAsyncBrowser(); 195 static CComQIPtr<IWebBrowser2> GetAsyncBrowser();
183 }; 196 };
184 197
185 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass) 198 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass)
186 199
187 200
188 #endif // _PLUGIN_CLASS_H_ 201 #endif // _PLUGIN_CLASS_H_
LEFTRIGHT

Powered by Google App Engine
This is Rietveld