OLD | NEW |
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-2015 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 |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "NotificationMessage.h" | 33 #include "NotificationMessage.h" |
34 | 34 |
35 #define ICON_PLUGIN_DISABLED 0 | 35 #define ICON_PLUGIN_DISABLED 0 |
36 #define ICON_PLUGIN_ENABLED 1 | 36 #define ICON_PLUGIN_ENABLED 1 |
37 #define ICON_PLUGIN_DEACTIVATED 2 | 37 #define ICON_PLUGIN_DEACTIVATED 2 |
38 #define ICON_MAX 3 | 38 #define ICON_MAX 3 |
39 | 39 |
40 #define WM_LAUNCH_INFO (WM_APP + 10) | 40 #define WM_LAUNCH_INFO (WM_APP + 10) |
41 | 41 |
42 class CPluginMimeFilterClient; | 42 class CPluginMimeFilterClient; |
43 | 43 class WebBrowserEventsListener; |
44 | 44 |
45 class ATL_NO_VTABLE CPluginClass : | 45 class ATL_NO_VTABLE CPluginClass : |
46 public ATL::CComObjectRootEx<ATL::CComMultiThreadModel>, | 46 public ATL::CComObjectRootEx<ATL::CComMultiThreadModel>, |
47 public ATL::CComCoClass<CPluginClass, &CLSID_PluginClass>, | 47 public ATL::CComCoClass<CPluginClass, &CLSID_PluginClass>, |
48 public ATL::IObjectWithSiteImpl<CPluginClass>, | 48 public ATL::IObjectWithSiteImpl<CPluginClass>, |
49 public IOleCommandTarget, | 49 public IOleCommandTarget, |
50 public ATL::IDispEventImpl<1, CPluginClass, &DIID_DWebBrowserEvents2, &LIBID_S
HDocVw, 1, 1> | 50 public ATL::IDispEventImpl<1, CPluginClass, &DIID_DWebBrowserEvents2, &LIBID_S
HDocVw, 1, 1> |
51 { | 51 { |
52 | 52 |
53 friend class CPluginTab; | 53 friend class CPluginTab; |
54 | 54 |
55 private: | |
56 | |
57 CPluginTab* m_tab; | |
58 | |
59 public: | 55 public: |
60 | 56 |
61 DECLARE_REGISTRY_RESOURCEID(IDR_PLUGIN_CLASS) | 57 DECLARE_REGISTRY_RESOURCEID(IDR_PLUGIN_CLASS) |
62 | 58 |
63 DECLARE_PROTECT_FINAL_CONSTRUCT() | 59 DECLARE_PROTECT_FINAL_CONSTRUCT() |
64 | 60 |
65 BEGIN_COM_MAP(CPluginClass) | 61 BEGIN_COM_MAP(CPluginClass) |
66 COM_INTERFACE_ENTRY(IObjectWithSite) | 62 COM_INTERFACE_ENTRY(IObjectWithSite) |
67 COM_INTERFACE_ENTRY(IOleCommandTarget) | 63 COM_INTERFACE_ENTRY(IOleCommandTarget) |
68 END_COM_MAP() | 64 END_COM_MAP() |
69 | 65 |
70 BEGIN_SINK_MAP(CPluginClass) | 66 BEGIN_SINK_MAP(CPluginClass) |
71 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_BEFORENAVIGATE2, OnBeforeNa
vigate2) | 67 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_BEFORENAVIGATE2, OnBeforeNa
vigate2) |
72 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOWNLOADCOMPLETE, OnDownloa
dComplete) | 68 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOWNLOADCOMPLETE, OnDownloa
dComplete) |
73 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOCUMENTCOMPLETE, OnDocumen
tComplete) | |
74 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_WINDOWSTATECHANGED, OnWindo
wStateChanged) | 69 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_WINDOWSTATECHANGED, OnWindo
wStateChanged) |
75 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_COMMANDSTATECHANGE, OnComma
ndStateChange) | 70 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_COMMANDSTATECHANGE, OnComma
ndStateChange) |
76 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_ONQUIT, OnOnQuit) | 71 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_ONQUIT, OnOnQuit) |
77 END_SINK_MAP() | 72 END_SINK_MAP() |
78 | 73 |
79 CPluginClass(); | 74 CPluginClass(); |
80 ~CPluginClass(); | 75 ~CPluginClass(); |
81 | 76 |
82 HRESULT FinalConstruct(); | 77 HRESULT FinalConstruct(); |
83 void FinalRelease(); | 78 void FinalRelease(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 static void FirstRunThread(); | 125 static void FirstRunThread(); |
131 | 126 |
132 void STDMETHODCALLTYPE OnBeforeNavigate2(IDispatch* pDisp /**< [in] */, | 127 void STDMETHODCALLTYPE OnBeforeNavigate2(IDispatch* pDisp /**< [in] */, |
133 VARIANT* URL /**< [in] */, | 128 VARIANT* URL /**< [in] */, |
134 VARIANT* Flags /**< [in] */, | 129 VARIANT* Flags /**< [in] */, |
135 VARIANT* TargetFrameName /**< [in] */
, | 130 VARIANT* TargetFrameName /**< [in] */
, |
136 VARIANT* PostData /**< [in] */, | 131 VARIANT* PostData /**< [in] */, |
137 VARIANT* Headers /**< [in] */, | 132 VARIANT* Headers /**< [in] */, |
138 VARIANT_BOOL* Cancel /* [in, out] */)
; | 133 VARIANT_BOOL* Cancel /* [in, out] */)
; |
139 void STDMETHODCALLTYPE OnDownloadComplete(); | 134 void STDMETHODCALLTYPE OnDownloadComplete(); |
140 void STDMETHODCALLTYPE OnDocumentComplete(IDispatch* frameBrowserDisp, VARIANT
* /*urlOrPidl*/); | |
141 void STDMETHODCALLTYPE OnWindowStateChanged(unsigned long flags, unsigned long
validFlagsMask); | 135 void STDMETHODCALLTYPE OnWindowStateChanged(unsigned long flags, unsigned long
validFlagsMask); |
142 void STDMETHODCALLTYPE OnCommandStateChange(long command, VARIANT_BOOL enable)
; | 136 void STDMETHODCALLTYPE OnCommandStateChange(long command, VARIANT_BOOL enable)
; |
143 void STDMETHODCALLTYPE OnOnQuit(); | 137 void STDMETHODCALLTYPE OnOnQuit(); |
144 void Unadvise(); | 138 void Unadvise(); |
| 139 void EnsureWebBrowserConnected(const ATL::CComPtr<IWebBrowser2>& webBrowser); |
145 | 140 |
146 void ShowStatusBar(); | 141 void ShowStatusBar(); |
147 bool IsStatusBarEnabled(); | 142 bool IsStatusBarEnabled(); |
148 | 143 |
149 public: | |
150 CComQIPtr<IWebBrowser2> m_webBrowser2; | |
151 private: | 144 private: |
152 HWND m_hBrowserWnd; | 145 HWND m_hBrowserWnd; |
153 HWND m_hTabWnd; | 146 HWND m_hTabWnd; |
154 HWND m_hStatusBarWnd; | 147 HWND m_hStatusBarWnd; |
155 HWND m_hPaneWnd; | 148 HWND m_hPaneWnd; |
156 | 149 |
157 WNDPROC m_pWndProcStatus; | 150 WNDPROC m_pWndProcStatus; |
158 int m_nPaneWidth; | 151 int m_nPaneWidth; |
159 HANDLE m_hTheme; | 152 HANDLE m_hTheme; |
| 153 struct Data |
| 154 { |
| 155 std::map<IWebBrowser2*, WebBrowserEventsListener*> connectedWebBrowsersCache
; |
| 156 std::unique_ptr<CPluginTab> tab; |
| 157 ATL::CComPtr<IWebBrowser2> webBrowser2; |
| 158 }; |
| 159 // 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. |
| 161 std::shared_ptr<Data> m_data; |
160 | 162 |
161 CriticalSection m_csStatusBar; | 163 CriticalSection m_csStatusBar; |
162 | 164 |
163 NotificationMessage notificationMessage; | 165 NotificationMessage notificationMessage; |
164 | 166 |
165 bool m_isAdvised; | 167 bool m_isAdvised; |
166 bool m_isInitializedOk; | 168 bool m_isInitializedOk; |
167 | 169 |
168 // Atom pane class | 170 // Atom pane class |
169 static ATOM s_atomPaneClass; | 171 static ATOM s_atomPaneClass; |
(...skipping 22 matching lines...) Expand all Loading... |
192 | 194 |
193 // Async browser | 195 // Async browser |
194 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2; | 196 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2; |
195 static CComQIPtr<IWebBrowser2> GetAsyncBrowser(); | 197 static CComQIPtr<IWebBrowser2> GetAsyncBrowser(); |
196 }; | 198 }; |
197 | 199 |
198 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass) | 200 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass) |
199 | 201 |
200 | 202 |
201 #endif // _PLUGIN_CLASS_H_ | 203 #endif // _PLUGIN_CLASS_H_ |
OLD | NEW |