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 25 matching lines...) Expand all Loading... |
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 |
44 | 44 |
45 class ATL_NO_VTABLE CPluginClass : | 45 class ATL_NO_VTABLE CPluginClass : |
46 public CComObjectRootEx<CComMultiThreadModel>, | 46 public ATL::CComObjectRootEx<ATL::CComMultiThreadModel>, |
47 public CComCoClass<CPluginClass, &CLSID_PluginClass>, | 47 public ATL::CComCoClass<CPluginClass, &CLSID_PluginClass>, |
48 public IObjectWithSiteImpl<CPluginClass>, | 48 public ATL::IObjectWithSiteImpl<CPluginClass>, |
49 public IDispatchImpl<IIEPlugin, &IID_IIEPlugin, &LIBID_PluginLib>, | 49 public IOleCommandTarget, |
50 public IOleCommandTarget | 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: | 55 private: |
56 | 56 |
57 CPluginTab* m_tab; | 57 CPluginTab* m_tab; |
58 | 58 |
59 public: | 59 public: |
60 | 60 |
61 DECLARE_REGISTRY_RESOURCEID(IDR_PLUGIN_CLASS) | 61 DECLARE_REGISTRY_RESOURCEID(IDR_PLUGIN_CLASS) |
62 | 62 |
63 DECLARE_PROTECT_FINAL_CONSTRUCT() | 63 DECLARE_PROTECT_FINAL_CONSTRUCT() |
64 | 64 |
65 BEGIN_COM_MAP(CPluginClass) | 65 BEGIN_COM_MAP(CPluginClass) |
66 COM_INTERFACE_ENTRY(IIEPlugin) | |
67 COM_INTERFACE_ENTRY(IDispatch) | |
68 COM_INTERFACE_ENTRY(IObjectWithSite) | 66 COM_INTERFACE_ENTRY(IObjectWithSite) |
69 COM_INTERFACE_ENTRY(IOleCommandTarget) | 67 COM_INTERFACE_ENTRY(IOleCommandTarget) |
70 END_COM_MAP() | 68 END_COM_MAP() |
71 | 69 |
| 70 BEGIN_SINK_MAP(CPluginClass) |
| 71 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_BEFORENAVIGATE2, OnBeforeNa
vigate2) |
| 72 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) |
| 75 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_COMMANDSTATECHANGE, OnComma
ndStateChange) |
| 76 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_ONQUIT, OnOnQuit) |
| 77 END_SINK_MAP() |
| 78 |
72 CPluginClass(); | 79 CPluginClass(); |
73 ~CPluginClass(); | 80 ~CPluginClass(); |
74 | 81 |
75 HRESULT FinalConstruct(); | 82 HRESULT FinalConstruct(); |
76 void FinalRelease(); | 83 void FinalRelease(); |
77 | 84 |
78 // IObjectWithSite | 85 // IObjectWithSite |
79 | 86 |
80 STDMETHOD(SetSite)(IUnknown *pUnkSite); | 87 STDMETHOD(SetSite)(IUnknown *pUnkSite); |
81 | 88 |
82 // IOleCommandTarget | 89 // IOleCommandTarget |
83 | 90 |
84 STDMETHOD(QueryStatus)(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[
], OLECMDTEXT* pCmdText); | 91 STDMETHOD(QueryStatus)(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[
], OLECMDTEXT* pCmdText); |
85 STDMETHOD(Exec)(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, VARIANTARG* pva
Out); | 92 STDMETHOD(Exec)(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, VARIANTARG* pva
Out); |
86 | 93 |
87 // IDispatch | |
88 | |
89 STDMETHOD(Invoke)(DISPID dispidMember,REFIID riid, LCID lcid, WORD wFlags, | |
90 DISPPARAMS * pdispparams, VARIANT * pvarResult,EXCEPINFO * pexcepinfo, UINT
* puArgErr); | |
91 | 94 |
92 static CPluginTab* GetTab(DWORD dwThreadId); | 95 static CPluginTab* GetTab(DWORD dwThreadId); |
93 CPluginTab* GetTab(); | 96 CPluginTab* GetTab(); |
94 | 97 |
95 void UpdateStatusBar(); | 98 void UpdateStatusBar(); |
96 static DWORD WINAPI MainThreadProc(LPVOID pParam); | 99 static DWORD WINAPI MainThreadProc(LPVOID pParam); |
97 | 100 |
98 private: | 101 private: |
99 | 102 |
100 bool SetMenuBar(HMENU hMenu, const std::wstring& url); | 103 bool SetMenuBar(HMENU hMenu, const std::wstring& url); |
101 HMENU CreatePluginMenu(const std::wstring& url); | 104 HMENU CreatePluginMenu(const std::wstring& url); |
102 | 105 |
103 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla
gs); | 106 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla
gs); |
104 bool CreateStatusBarPane(); | 107 bool CreateStatusBarPane(); |
105 | 108 |
106 CComPtr<IConnectionPoint> GetConnectionPoint(); | |
107 | |
108 public: | 109 public: |
109 HWND GetBrowserHWND() const; | 110 HWND GetBrowserHWND() const; |
110 HWND GetTabHWND() const; | 111 HWND GetTabHWND() const; |
111 CComQIPtr<IWebBrowser2> GetBrowser() const; | 112 CComQIPtr<IWebBrowser2> GetBrowser() const; |
112 | 113 |
113 STDMETHODIMP OnTabChanged(DISPPARAMS* pDispParams, WORD wFlags); | |
114 | 114 |
115 static CPluginMimeFilterClient* s_mimeFilter; | 115 static CPluginMimeFilterClient* s_mimeFilter; |
116 | 116 |
117 private: | 117 private: |
118 | 118 |
119 std::wstring GetBrowserUrl() const; | 119 std::wstring GetBrowserUrl() const; |
120 | 120 |
121 static DWORD WINAPI StartInitObject(LPVOID thisPtr); | 121 static DWORD WINAPI StartInitObject(LPVOID thisPtr); |
122 bool InitObject(bool bBHO); | 122 bool InitObject(bool bBHO); |
123 void CloseTheme(); | 123 void CloseTheme(); |
124 void UpdateTheme(); | 124 void UpdateTheme(); |
125 | 125 |
126 static HICON GetStatusBarIcon(const std::wstring& url); | 126 static HICON GetStatusBarIcon(const std::wstring& url); |
127 static CPluginClass* FindInstance(HWND hStatusBarWnd); | 127 static CPluginClass* FindInstance(HWND hStatusBarWnd); |
128 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); |
129 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); |
130 static void FirstRunThread(); | 130 static void FirstRunThread(); |
131 void BeforeNavigate2(DISPPARAMS* pDispParams); | |
132 | 131 |
133 void Unadvice(); | 132 void STDMETHODCALLTYPE OnBeforeNavigate2(/* [in] */ IDispatch* pDisp, |
| 133 /* [in] */ VARIANT* URL, |
| 134 /* [in] */ VARIANT* Flags, |
| 135 /* [in] */ VARIANT* TargetFrameName, |
| 136 /* [in] */ VARIANT* PostData, |
| 137 /* [in] */ VARIANT* Headers, |
| 138 /* [in, out] */ VARIANT_BOOL* Cancel); |
| 139 void STDMETHODCALLTYPE OnDownloadComplete(); |
| 140 void STDMETHODCALLTYPE OnDocumentComplete(IDispatch* frameBrowserDisp, VARIANT
* /*urlOrPidl*/); |
| 141 void STDMETHODCALLTYPE OnWindowStateChanged(unsigned long flags, unsigned long
validFlagsMask); |
| 142 void STDMETHODCALLTYPE OnCommandStateChange(long command, VARIANT_BOOL enable)
; |
| 143 void STDMETHODCALLTYPE OnOnQuit(); |
| 144 void Unadvise(); |
134 | 145 |
135 void ShowStatusBar(); | 146 void ShowStatusBar(); |
136 bool IsStatusBarEnabled(); | 147 bool IsStatusBarEnabled(); |
137 | 148 |
138 public: | 149 public: |
139 CComQIPtr<IWebBrowser2> m_webBrowser2; | 150 CComQIPtr<IWebBrowser2> m_webBrowser2; |
140 private: | 151 private: |
141 DWORD m_nConnectionID; | |
142 HWND m_hBrowserWnd; | 152 HWND m_hBrowserWnd; |
143 HWND m_hTabWnd; | 153 HWND m_hTabWnd; |
144 HWND m_hStatusBarWnd; | 154 HWND m_hStatusBarWnd; |
145 HWND m_hPaneWnd; | 155 HWND m_hPaneWnd; |
146 | 156 |
147 WNDPROC m_pWndProcStatus; | 157 WNDPROC m_pWndProcStatus; |
148 int m_nPaneWidth; | 158 int m_nPaneWidth; |
149 HANDLE m_hTheme; | 159 HANDLE m_hTheme; |
150 | 160 |
151 CriticalSection m_csStatusBar; | 161 CriticalSection m_csStatusBar; |
152 | 162 |
153 NotificationMessage notificationMessage; | 163 NotificationMessage notificationMessage; |
154 | 164 |
155 bool m_isAdviced; | 165 bool m_isAdvised; |
156 bool m_isInitializedOk; | 166 bool m_isInitializedOk; |
157 | 167 |
158 // Atom pane class | 168 // Atom pane class |
159 static ATOM s_atomPaneClass; | 169 static ATOM s_atomPaneClass; |
160 | 170 |
161 static ATOM GetAtomPaneClass(); | 171 static ATOM GetAtomPaneClass(); |
162 | 172 |
163 // Icons | 173 // Icons |
164 static HICON s_hIcons[ICON_MAX]; | 174 static HICON s_hIcons[ICON_MAX]; |
165 static DWORD s_hIconTypes[ICON_MAX]; | 175 static DWORD s_hIconTypes[ICON_MAX]; |
(...skipping 16 matching lines...) Expand all Loading... |
182 | 192 |
183 // Async browser | 193 // Async browser |
184 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2; | 194 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2; |
185 static CComQIPtr<IWebBrowser2> GetAsyncBrowser(); | 195 static CComQIPtr<IWebBrowser2> GetAsyncBrowser(); |
186 }; | 196 }; |
187 | 197 |
188 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass) | 198 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass) |
189 | 199 |
190 | 200 |
191 #endif // _PLUGIN_CLASS_H_ | 201 #endif // _PLUGIN_CLASS_H_ |
OLD | NEW |