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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 * \tparam Source | 104 * \tparam Source |
105 * Type of event source. Implements IConnectionPoint | 105 * Type of event source. Implements IConnectionPoint |
106 */ | 106 */ |
107 template<class Sink, class Source> | 107 template<class Sink, class Source> |
108 class AtlEventRegistrationHolder | 108 class AtlEventRegistrationHolder |
109 { | 109 { |
110 typedef AtlEventRegistration<Sink, Source> ImplType; | 110 typedef AtlEventRegistration<Sink, Source> ImplType; |
111 std::unique_ptr<ImplType> impl; | 111 std::unique_ptr<ImplType> impl; |
112 | 112 |
113 public: | 113 public: |
114 AtlEventRegistrationHolder() | |
115 : impl(nullptr) | |
116 {} | |
117 | |
118 ~AtlEventRegistrationHolder() // = default; | |
119 {} | |
120 | |
121 bool Start(Sink* consumer, Source* producer) // noexcept | 114 bool Start(Sink* consumer, Source* producer) // noexcept |
122 { | 115 { |
123 try | 116 try |
124 { | 117 { |
125 impl = new ImplType(consumer, producer); | 118 impl.reset(new ImplType(consumer, producer)); |
126 } | 119 } |
127 catch (...) | 120 catch (...) |
128 { | 121 { |
129 impl = nullptr; | 122 impl.reset(); |
130 return false; | 123 return false; |
131 } | 124 } |
132 return true; | 125 return true; |
133 } | 126 } |
134 | 127 |
135 Stop() // noexcept | 128 void Stop() // noexcept |
136 { | 129 { |
137 impl = nullptr; | 130 impl.reset(); |
138 } | 131 } |
139 }; | 132 }; |
140 | |
141 class ATL_NO_VTABLE CPluginClass : | 133 class ATL_NO_VTABLE CPluginClass : |
142 public ATL::CComObjectRootEx<ATL::CComMultiThreadModel>, | 134 public ATL::CComObjectRootEx<ATL::CComMultiThreadModel>, |
143 public ATL::CComCoClass<CPluginClass, &CLSID_PluginClass>, | 135 public ATL::CComCoClass<CPluginClass, &CLSID_PluginClass>, |
144 public ATL::IObjectWithSiteImpl<CPluginClass>, | 136 public ATL::IObjectWithSiteImpl<CPluginClass>, |
145 public IOleCommandTarget, | 137 public IOleCommandTarget, |
146 public ATL::IDispEventImpl<1, CPluginClass, &DIID_DWebBrowserEvents2, &LIBID_S
HDocVw, 1, 1> | 138 public ATL::IDispEventImpl<1, CPluginClass, &DIID_DWebBrowserEvents2, &LIBID_S
HDocVw, 1, 1> |
147 { | 139 { |
148 | 140 |
149 friend class CPluginTab; | 141 friend class CPluginTab; |
150 | 142 |
(...skipping 24 matching lines...) Expand all Loading... |
175 ~CPluginClass(); | 167 ~CPluginClass(); |
176 | 168 |
177 // IObjectWithSite | 169 // IObjectWithSite |
178 STDMETHOD(SetSite)(IUnknown *pUnkSite); | 170 STDMETHOD(SetSite)(IUnknown *pUnkSite); |
179 | 171 |
180 // IOleCommandTarget | 172 // IOleCommandTarget |
181 STDMETHOD(QueryStatus)(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[
], OLECMDTEXT* pCmdText); | 173 STDMETHOD(QueryStatus)(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[
], OLECMDTEXT* pCmdText); |
182 STDMETHOD(Exec)(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, VARIANTARG* pva
Out); | 174 STDMETHOD(Exec)(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, VARIANTARG* pva
Out); |
183 | 175 |
184 | 176 |
185 static CPluginTab* GetTab(DWORD dwThreadId); | 177 static CPluginTab* GetTabForCurrentThread(); |
186 CPluginTab* GetTab(); | 178 CPluginTab* GetTab(); |
187 | 179 |
188 void UpdateStatusBar(); | 180 void UpdateStatusBar(); |
189 | 181 |
190 private: | 182 private: |
191 | 183 |
192 bool SetMenuBar(HMENU hMenu, const std::wstring& url); | 184 bool SetMenuBar(HMENU hMenu, const std::wstring& url); |
193 HMENU CreatePluginMenu(const std::wstring& url); | 185 HMENU CreatePluginMenu(const std::wstring& url); |
194 | 186 |
195 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla
gs); | 187 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla
gs); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 static DWORD s_hIconTypes[ICON_MAX]; | 260 static DWORD s_hIconTypes[ICON_MAX]; |
269 | 261 |
270 static HICON GetIcon(int type); | 262 static HICON GetIcon(int type); |
271 | 263 |
272 // Main thread | 264 // Main thread |
273 static HANDLE s_hMainThread; | 265 static HANDLE s_hMainThread; |
274 static bool s_isMainThreadDone; | 266 static bool s_isMainThreadDone; |
275 | 267 |
276 static HINSTANCE s_hUxtheme; | 268 static HINSTANCE s_hUxtheme; |
277 static std::set<CPluginClass*> s_instances; | 269 static std::set<CPluginClass*> s_instances; |
278 static std::map<DWORD,CPluginClass*> s_threadInstances; | |
279 static CComAutoCriticalSection s_criticalSectionLocal; | 270 static CComAutoCriticalSection s_criticalSectionLocal; |
280 static CComAutoCriticalSection s_criticalSectionWindow; | 271 static CComAutoCriticalSection s_criticalSectionWindow; |
281 | 272 |
282 // Async browser | 273 // Async browser |
283 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2; | 274 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2; |
284 static CComQIPtr<IWebBrowser2> GetAsyncBrowser(); | 275 static CComQIPtr<IWebBrowser2> GetAsyncBrowser(); |
285 }; | 276 }; |
286 | 277 |
287 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass) | 278 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass) |
288 | 279 |
289 | |
290 #endif // _PLUGIN_CLASS_H_ | 280 #endif // _PLUGIN_CLASS_H_ |
LEFT | RIGHT |