Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_BEFORENAVIGATE2, OnBeforeNa vigate2) | 67 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_BEFORENAVIGATE2, OnBeforeNa vigate2) |
68 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOWNLOADCOMPLETE, OnDownloa dComplete) | 68 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOWNLOADCOMPLETE, OnDownloa dComplete) |
69 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_WINDOWSTATECHANGED, OnWindo wStateChanged) | 69 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_WINDOWSTATECHANGED, OnWindo wStateChanged) |
70 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_COMMANDSTATECHANGE, OnComma ndStateChange) | 70 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_COMMANDSTATECHANGE, OnComma ndStateChange) |
71 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_ONQUIT, OnOnQuit) | 71 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_ONQUIT, OnOnQuit) |
72 END_SINK_MAP() | 72 END_SINK_MAP() |
73 | 73 |
74 CPluginClass(); | 74 CPluginClass(); |
75 ~CPluginClass(); | 75 ~CPluginClass(); |
76 | 76 |
77 HRESULT FinalConstruct(); | |
78 void FinalRelease(); | |
79 | |
80 // IObjectWithSite | 77 // IObjectWithSite |
81 | |
82 STDMETHOD(SetSite)(IUnknown *pUnkSite); | 78 STDMETHOD(SetSite)(IUnknown *pUnkSite); |
83 | 79 |
84 // IOleCommandTarget | 80 // IOleCommandTarget |
85 | |
86 STDMETHOD(QueryStatus)(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT* pCmdText); | 81 STDMETHOD(QueryStatus)(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT* pCmdText); |
87 STDMETHOD(Exec)(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, VARIANTARG* pva Out); | 82 STDMETHOD(Exec)(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, VARIANTARG* pva Out); |
88 | 83 |
89 | 84 |
90 static CPluginTab* GetTab(DWORD dwThreadId); | 85 static CPluginTab* GetTab(DWORD dwThreadId); |
91 CPluginTab* GetTab(); | 86 CPluginTab* GetTab(); |
92 | 87 |
93 void UpdateStatusBar(); | 88 void UpdateStatusBar(); |
94 static DWORD WINAPI MainThreadProc(LPVOID pParam); | |
95 | 89 |
96 private: | 90 private: |
97 | 91 |
98 bool SetMenuBar(HMENU hMenu, const std::wstring& url); | 92 bool SetMenuBar(HMENU hMenu, const std::wstring& url); |
99 HMENU CreatePluginMenu(const std::wstring& url); | 93 HMENU CreatePluginMenu(const std::wstring& url); |
100 | 94 |
101 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla gs); | 95 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla gs); |
102 bool CreateStatusBarPane(); | 96 bool CreateStatusBarPane(); |
103 | 97 |
104 public: | 98 public: |
105 HWND GetBrowserHWND() const; | 99 HWND GetBrowserHWND() const; |
106 HWND GetTabHWND() const; | 100 bool IsRootBrowser(IWebBrowser2*); |
107 CComQIPtr<IWebBrowser2> GetBrowser() const; | |
108 | |
109 | 101 |
110 static CPluginMimeFilterClient* s_mimeFilter; | 102 static CPluginMimeFilterClient* s_mimeFilter; |
111 | 103 |
112 private: | 104 private: |
113 | 105 |
114 std::wstring GetBrowserUrl() const; | 106 std::wstring GetBrowserUrl() const; |
115 | 107 |
116 static DWORD WINAPI StartInitObject(LPVOID thisPtr); | 108 static DWORD WINAPI StartInitObject(LPVOID thisPtr); |
117 bool InitObject(); | 109 bool InitObject(); |
118 void CloseTheme(); | 110 void CloseTheme(); |
(...skipping 15 matching lines...) Expand all Loading... | |
134 void STDMETHODCALLTYPE OnDownloadComplete(); | 126 void STDMETHODCALLTYPE OnDownloadComplete(); |
135 void STDMETHODCALLTYPE OnWindowStateChanged(unsigned long flags, unsigned long validFlagsMask); | 127 void STDMETHODCALLTYPE OnWindowStateChanged(unsigned long flags, unsigned long validFlagsMask); |
136 void STDMETHODCALLTYPE OnCommandStateChange(long command, VARIANT_BOOL enable) ; | 128 void STDMETHODCALLTYPE OnCommandStateChange(long command, VARIANT_BOOL enable) ; |
137 void STDMETHODCALLTYPE OnOnQuit(); | 129 void STDMETHODCALLTYPE OnOnQuit(); |
138 void Unadvise(); | 130 void Unadvise(); |
139 void EnsureWebBrowserConnected(const ATL::CComPtr<IWebBrowser2>& webBrowser); | 131 void EnsureWebBrowserConnected(const ATL::CComPtr<IWebBrowser2>& webBrowser); |
140 | 132 |
141 void ShowStatusBar(); | 133 void ShowStatusBar(); |
142 bool IsStatusBarEnabled(); | 134 bool IsStatusBarEnabled(); |
143 | 135 |
144 private: | |
145 HWND m_hBrowserWnd; | 136 HWND m_hBrowserWnd; |
146 HWND m_hTabWnd; | 137 HWND m_hTabWnd; |
147 HWND m_hStatusBarWnd; | 138 HWND m_hStatusBarWnd; |
148 HWND m_hPaneWnd; | 139 HWND m_hPaneWnd; |
149 | 140 |
150 WNDPROC m_pWndProcStatus; | 141 WNDPROC m_pWndProcStatus; |
151 int m_nPaneWidth; | 142 int m_nPaneWidth; |
152 HANDLE m_hTheme; | 143 HANDLE m_hTheme; |
153 struct Data | 144 struct Data |
154 { | 145 { |
155 std::map<IWebBrowser2*, WebBrowserEventsListener*> connectedWebBrowsersCache ; | 146 std::map<IWebBrowser2*, WebBrowserEventsListener*> connectedWebBrowsersCache ; |
sergei
2016/02/25 17:48:27
These raw pointers is another point here regarding
sergei
2016/02/26 08:34:51
BTW, in addition we probably need to serialize the
sergei
2016/02/26 16:57:56
According to my tests destructors of `WebBrowserEv
| |
156 std::unique_ptr<CPluginTab> tab; | 147 std::unique_ptr<CPluginTab> tab; |
157 ATL::CComPtr<IWebBrowser2> webBrowser2; | 148 ATL::CComPtr<IWebBrowser2> webBrowser2; |
158 }; | 149 }; |
159 // we need to have it as a shared pointer to get weak pointer to it to avoid | 150 // we need to have it as a shared pointer to get weak pointer to it to avoid |
160 // wrong usage after destroying of this class. | 151 // wrong usage after destroying of this class. |
161 std::shared_ptr<Data> m_data; | 152 std::shared_ptr<Data> m_data; |
Eric
2015/12/02 17:00:14
This struct looks like a Very Bad Idea.
If we get
sergei
2016/02/25 17:48:27
It's not about events coming to non-existing objec
| |
162 | 153 |
163 CriticalSection m_csStatusBar; | 154 CriticalSection m_csStatusBar; |
164 | 155 |
165 NotificationMessage notificationMessage; | 156 NotificationMessage notificationMessage; |
166 | 157 |
167 bool m_isAdvised; | 158 bool m_isAdvised; |
168 bool m_isInitializedOk; | 159 bool m_isInitializedOk; |
169 | 160 |
170 // Atom pane class | 161 // Atom pane class |
171 static ATOM s_atomPaneClass; | 162 static ATOM s_atomPaneClass; |
172 | 163 |
173 static ATOM GetAtomPaneClass(); | 164 static ATOM GetAtomPaneClass(); |
174 | 165 |
175 // Icons | 166 // Icons |
176 static HICON s_hIcons[ICON_MAX]; | 167 static HICON s_hIcons[ICON_MAX]; |
177 static DWORD s_hIconTypes[ICON_MAX]; | 168 static DWORD s_hIconTypes[ICON_MAX]; |
178 | 169 |
179 static HICON GetIcon(int type); | 170 static HICON GetIcon(int type); |
180 | 171 |
181 // Main thread | 172 // Main thread |
182 static HANDLE s_hMainThread; | 173 static HANDLE s_hMainThread; |
183 static bool s_isMainThreadDone; | 174 static bool s_isMainThreadDone; |
184 | 175 |
185 static HANDLE GetMainThreadHandle(); | |
186 static bool IsMainThreadDone(HANDLE mainThread); | |
187 | |
188 static HINSTANCE s_hUxtheme; | 176 static HINSTANCE s_hUxtheme; |
189 static std::set<CPluginClass*> s_instances; | 177 static std::set<CPluginClass*> s_instances; |
190 static std::map<DWORD,CPluginClass*> s_threadInstances; | 178 static std::map<DWORD,CPluginClass*> s_threadInstances; |
191 static CComAutoCriticalSection s_criticalSectionLocal; | 179 static CComAutoCriticalSection s_criticalSectionLocal; |
192 static CComAutoCriticalSection s_criticalSectionBrowser; | |
193 static CComAutoCriticalSection s_criticalSectionWindow; | 180 static CComAutoCriticalSection s_criticalSectionWindow; |
194 | 181 |
195 // Async browser | 182 // Async browser |
196 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2; | 183 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2; |
197 static CComQIPtr<IWebBrowser2> GetAsyncBrowser(); | 184 static CComQIPtr<IWebBrowser2> GetAsyncBrowser(); |
198 }; | 185 }; |
199 | 186 |
200 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass) | 187 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass) |
201 | 188 |
202 | 189 |
203 #endif // _PLUGIN_CLASS_H_ | 190 #endif // _PLUGIN_CLASS_H_ |
LEFT | RIGHT |