Left: | ||
Right: |
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 CLOSETHEMEDATA pfnClose = NULL; | 53 CLOSETHEMEDATA pfnClose = NULL; |
54 DRAWTHEMEBACKGROUND pfnDrawThemeBackground = NULL; | 54 DRAWTHEMEBACKGROUND pfnDrawThemeBackground = NULL; |
55 OPENTHEMEDATA pfnOpenThemeData = NULL; | 55 OPENTHEMEDATA pfnOpenThemeData = NULL; |
56 | 56 |
57 ATOM CPluginClass::s_atomPaneClass = NULL; | 57 ATOM CPluginClass::s_atomPaneClass = NULL; |
58 HINSTANCE CPluginClass::s_hUxtheme = NULL; | 58 HINSTANCE CPluginClass::s_hUxtheme = NULL; |
59 std::set<CPluginClass*> CPluginClass::s_instances; | 59 std::set<CPluginClass*> CPluginClass::s_instances; |
60 std::map<DWORD, CPluginClass*> CPluginClass::s_threadInstances; | 60 std::map<DWORD, CPluginClass*> CPluginClass::s_threadInstances; |
61 | 61 |
62 CComAutoCriticalSection CPluginClass::s_criticalSectionLocal; | 62 CComAutoCriticalSection CPluginClass::s_criticalSectionLocal; |
63 CComAutoCriticalSection CPluginClass::s_criticalSectionBrowser; | |
64 CComAutoCriticalSection CPluginClass::s_criticalSectionWindow; | 63 CComAutoCriticalSection CPluginClass::s_criticalSectionWindow; |
65 | 64 |
66 CComQIPtr<IWebBrowser2> CPluginClass::s_asyncWebBrowser2; | 65 CComQIPtr<IWebBrowser2> CPluginClass::s_asyncWebBrowser2; |
67 | 66 |
68 /* | 67 /* |
69 * Without namespace declaration, the identifier "Rectangle" is ambiguous | 68 * Without namespace declaration, the identifier "Rectangle" is ambiguous |
70 * See http://msdn.microsoft.com/en-us/library/windows/desktop/dd162898(v=vs.85) .aspx | 69 * See http://msdn.microsoft.com/en-us/library/windows/desktop/dd162898(v=vs.85) .aspx |
71 */ | 70 */ |
72 namespace AdblockPlus | 71 namespace AdblockPlus |
73 { | 72 { |
(...skipping 10 matching lines...) Expand all Loading... | |
84 } | 83 } |
85 | 84 |
86 int Width() const | 85 int Width() const |
87 { | 86 { |
88 return right - left; | 87 return right - left; |
89 } | 88 } |
90 }; | 89 }; |
91 } | 90 } |
92 | 91 |
93 CPluginClass::CPluginClass() | 92 CPluginClass::CPluginClass() |
93 : m_webBrowser2(nullptr) | |
94 { | 94 { |
95 //Use this line to debug memory leaks | 95 //Use this line to debug memory leaks |
96 // _CrtDumpMemoryLeaks(); | 96 // _CrtDumpMemoryLeaks(); |
97 | 97 |
98 m_isAdvised = false; | 98 m_isAdvised = false; |
99 m_hTabWnd = NULL; | 99 m_hTabWnd = NULL; |
100 m_hStatusBarWnd = NULL; | 100 m_hStatusBarWnd = NULL; |
101 m_hPaneWnd = NULL; | 101 m_hPaneWnd = NULL; |
102 m_nPaneWidth = 0; | 102 m_nPaneWidth = 0; |
103 m_pWndProcStatus = NULL; | 103 m_pWndProcStatus = NULL; |
104 m_hTheme = NULL; | 104 m_hTheme = NULL; |
105 m_isInitializedOk = false; | 105 m_isInitializedOk = false; |
106 | 106 |
107 | 107 |
108 m_tab = new CPluginTab(this); | 108 m_tab = new CPluginTab(this); |
109 | 109 |
110 Dictionary::Create(GetBrowserLanguage()); | 110 Dictionary::Create(GetBrowserLanguage()); |
111 } | 111 } |
112 | 112 |
113 CPluginClass::~CPluginClass() | 113 CPluginClass::~CPluginClass() |
114 { | 114 { |
115 delete m_tab; | 115 delete m_tab; |
116 } | 116 } |
117 | 117 |
118 | |
119 ///////////////////////////////////////////////////////////////////////////// | |
120 // Initialization | |
121 | |
122 HRESULT CPluginClass::FinalConstruct() | |
123 { | |
124 return S_OK; | |
125 } | |
Eric
2015/12/03 14:24:54
I've edited the commit message accordingly.
To be
sergei
2015/12/07 10:49:08
I disagree that we don't need them, they are reall
Eric
2015/12/07 14:04:12
If you want to use them here, please submit a subs
sergei
2015/12/08 09:42:00
Acknowledged.
| |
126 | |
127 void CPluginClass::FinalRelease() | |
128 { | |
129 s_criticalSectionBrowser.Lock(); | |
130 { | |
131 m_webBrowser2.Release(); | |
132 } | |
133 s_criticalSectionBrowser.Unlock(); | |
134 } | |
135 | |
136 HWND CPluginClass::GetBrowserHWND() const | 118 HWND CPluginClass::GetBrowserHWND() const |
137 { | 119 { |
138 SHANDLE_PTR hBrowserWndHandle = NULL; | 120 if (!m_webBrowser2) |
139 | |
140 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | |
141 if (browser) | |
142 { | 121 { |
143 HRESULT hr = browser->get_HWND(&hBrowserWndHandle); | 122 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::GetBrowserHWND - Reached with m_webB rowser2 == nullptr"); |
144 if (FAILED(hr)) | 123 return nullptr; |
145 { | |
146 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_BROWSER_WINDOW, " Class::GetBrowserHWND - failed") | |
147 } | |
148 } | 124 } |
149 | 125 SHANDLE_PTR hBrowserWndHandle; |
126 HRESULT hr = m_webBrowser2->get_HWND(&hBrowserWndHandle); | |
127 if (FAILED(hr)) | |
128 { | |
129 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_BROWSER_WINDOW, "Cl ass::GetBrowserHWND - failed"); | |
130 return nullptr; | |
131 } | |
150 return (HWND)hBrowserWndHandle; | 132 return (HWND)hBrowserWndHandle; |
151 } | 133 } |
152 | 134 |
153 | 135 bool CPluginClass::IsRootBrowser(IWebBrowser2* otherBrowser) |
154 CComQIPtr<IWebBrowser2> CPluginClass::GetBrowser() const | |
155 { | 136 { |
156 CComQIPtr<IWebBrowser2> browser; | 137 return m_webBrowser2.IsEqualObject(otherBrowser); |
157 | |
158 s_criticalSectionBrowser.Lock(); | |
159 { | |
160 browser = m_webBrowser2; | |
161 } | |
162 s_criticalSectionBrowser.Unlock(); | |
163 | |
164 return browser; | |
165 } | 138 } |
166 | 139 |
167 | |
168 CComQIPtr<IWebBrowser2> CPluginClass::GetAsyncBrowser() | 140 CComQIPtr<IWebBrowser2> CPluginClass::GetAsyncBrowser() |
169 { | 141 { |
170 CComQIPtr<IWebBrowser2> browser; | 142 CComQIPtr<IWebBrowser2> browser; |
171 | 143 |
172 s_criticalSectionLocal.Lock(); | 144 s_criticalSectionLocal.Lock(); |
173 { | 145 { |
174 browser = s_asyncWebBrowser2; | 146 browser = s_asyncWebBrowser2; |
175 } | 147 } |
176 s_criticalSectionLocal.Unlock(); | 148 s_criticalSectionLocal.Unlock(); |
177 | 149 |
178 return browser; | 150 return browser; |
179 } | 151 } |
180 | 152 |
181 std::wstring CPluginClass::GetBrowserUrl() const | 153 std::wstring CPluginClass::GetBrowserUrl() const |
182 { | 154 { |
183 std::wstring url; | 155 std::wstring url; |
184 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | 156 if (m_webBrowser2) |
185 if (browser) | |
186 { | 157 { |
187 CComBSTR bstrURL; | 158 CComBSTR bstrURL; |
188 if (SUCCEEDED(browser->get_LocationURL(&bstrURL)) && bstrURL) | 159 if (SUCCEEDED(m_webBrowser2->get_LocationURL(&bstrURL)) && bstrURL) |
189 { | 160 { |
190 url = std::wstring(bstrURL, SysStringLen(bstrURL)); | 161 url = std::wstring(bstrURL, SysStringLen(bstrURL)); |
191 } | 162 } |
192 } | 163 } |
193 else | 164 else |
194 { | 165 { |
166 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::GetBrowserUrl - Reached with m_webBr owser2 == nullptr"); | |
195 url = m_tab->GetDocumentUrl(); | 167 url = m_tab->GetDocumentUrl(); |
196 } | 168 } |
197 return url; | 169 return url; |
198 } | 170 } |
199 | 171 |
200 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) | 172 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) |
201 { | 173 { |
202 if (thisPtr == NULL) | 174 if (thisPtr == NULL) |
203 return 0; | 175 return 0; |
204 if (!((CPluginClass*)thisPtr)->InitObject()) | 176 if (!((CPluginClass*)thisPtr)->InitObject()) |
(...skipping 22 matching lines...) Expand all Loading... | |
227 { | 199 { |
228 | 200 |
229 DEBUG_GENERAL(L"========================================================== ======================\nNEW TAB UI\n============================================ ====================================") | 201 DEBUG_GENERAL(L"========================================================== ======================\nNEW TAB UI\n============================================ ====================================") |
230 | 202 |
231 HRESULT hr = ::CoInitialize(NULL); | 203 HRESULT hr = ::CoInitialize(NULL); |
232 if (FAILED(hr)) | 204 if (FAILED(hr)) |
233 { | 205 { |
234 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_COINIT, "Class::SetSite - CoInitialize"); | 206 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_COINIT, "Class::SetSite - CoInitialize"); |
235 } | 207 } |
236 | 208 |
237 s_criticalSectionBrowser.Lock(); | 209 /* |
210 * We were instantiated as a BHO, so our site is always of type IWebBrowse r2. | |
211 */ | |
212 m_webBrowser2 = ATL::CComQIPtr<IWebBrowser2>(unknownSite); | |
213 if (!m_webBrowser2) | |
238 { | 214 { |
239 m_webBrowser2 = unknownSite; | 215 throw std::logic_error("CPluginClass::SetSite - Unable to convert site p ointer to IWebBrowser2*"); |
240 } | 216 } |
241 s_criticalSectionBrowser.Unlock(); | |
242 | 217 |
243 //register the mimefilter | 218 //register the mimefilter |
244 //and only mimefilter | 219 //and only mimefilter |
245 //on some few computers the mimefilter does not get properly registered wh en it is done on another thread | 220 //on some few computers the mimefilter does not get properly registered wh en it is done on another thread |
246 | |
247 s_criticalSectionLocal.Lock(); | 221 s_criticalSectionLocal.Lock(); |
248 { | 222 { |
249 // Always register on startup, then check if we need to unregister in a separate thread | 223 // Always register on startup, then check if we need to unregister in a separate thread |
250 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); | 224 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); |
251 s_asyncWebBrowser2 = unknownSite; | 225 s_asyncWebBrowser2 = unknownSite; |
252 s_instances.insert(this); | 226 s_instances.insert(this); |
253 } | 227 } |
254 s_criticalSectionLocal.Unlock(); | 228 s_criticalSectionLocal.Unlock(); |
255 | 229 |
256 try | 230 try |
257 { | 231 { |
258 auto webBrowser = GetBrowser(); | 232 DEBUG_GENERAL("Loaded as BHO"); |
259 if (webBrowser) | 233 HRESULT hr = DispEventAdvise(m_webBrowser2); |
234 if (SUCCEEDED(hr)) | |
260 { | 235 { |
261 DEBUG_GENERAL("Loaded as BHO"); | 236 m_isAdvised = true; |
262 HRESULT hr = DispEventAdvise(webBrowser); | 237 try |
263 if (SUCCEEDED(hr)) | |
264 { | 238 { |
265 m_isAdvised = true; | 239 std::thread startInitObjectThread(StartInitObject, this); |
266 try | 240 startInitObjectThread.detach(); // TODO: but actually we should wait for the thread in the dtr. |
267 { | |
268 std::thread startInitObjectThread(StartInitObject, this); | |
269 startInitObjectThread.detach(); // TODO: but actually we should wa it for the thread in the dtr. | |
270 } | |
271 catch (const std::system_error& ex) | |
272 { | |
273 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_ THREAD_CREATE_PROCESS, | |
274 "Class::Thread - Failed to create StartInitObject thread"); | |
275 } | |
276 } | 241 } |
277 else | 242 catch (const std::system_error& ex) |
278 { | 243 { |
279 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_ADV ICE, "Class::SetSite - Advise"); | 244 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_TH READ_CREATE_PROCESS, |
245 "Class::Thread - Failed to create StartInitObject thread"); | |
280 } | 246 } |
281 } | 247 } |
248 else | |
249 { | |
250 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_ADVIC E, "Class::SetSite - Advise"); | |
251 } | |
282 } | 252 } |
283 catch (const std::runtime_error& ex) | 253 catch (const std::runtime_error& ex) |
284 { | 254 { |
285 DEBUG_EXCEPTION(ex); | 255 DEBUG_EXCEPTION(ex); |
286 Unadvise(); | 256 Unadvise(); |
287 } | 257 } |
288 } | 258 } |
289 else | 259 else |
290 { | 260 { |
291 Unadvise(); | 261 Unadvise(); |
(...skipping 29 matching lines...) Expand all Loading... | |
321 s_threadInstances.erase(it); | 291 s_threadInstances.erase(it); |
322 } | 292 } |
323 if (s_instances.empty()) | 293 if (s_instances.empty()) |
324 { | 294 { |
325 // TODO: Explicitly releasing a resource when a container becomes empt y looks like a job better suited for shared_ptr | 295 // TODO: Explicitly releasing a resource when a container becomes empt y looks like a job better suited for shared_ptr |
326 CPluginClientFactory::ReleaseMimeFilterClientInstance(); | 296 CPluginClientFactory::ReleaseMimeFilterClientInstance(); |
327 } | 297 } |
328 } | 298 } |
329 s_criticalSectionLocal.Unlock(); | 299 s_criticalSectionLocal.Unlock(); |
330 | 300 |
331 // Release browser interface | 301 m_webBrowser2 = nullptr; |
332 s_criticalSectionBrowser.Lock(); | |
333 { | |
334 m_webBrowser2.Release(); | |
335 } | |
336 s_criticalSectionBrowser.Unlock(); | |
337 | 302 |
338 DEBUG_GENERAL("=========================================================== =====================\nNEW TAB UI - END\n======================================= =========================================") | 303 DEBUG_GENERAL("=========================================================== =====================\nNEW TAB UI - END\n======================================= =========================================") |
339 | 304 |
340 ::CoUninitialize(); | 305 ::CoUninitialize(); |
341 } | 306 } |
342 | 307 |
343 IObjectWithSiteImpl<CPluginClass>::SetSite(unknownSite); | |
344 } | 308 } |
345 catch (...) | 309 catch (...) |
346 { | 310 { |
347 } | 311 } |
312 IObjectWithSiteImpl<CPluginClass>::SetSite(unknownSite); | |
348 return S_OK; | 313 return S_OK; |
349 } | 314 } |
350 | 315 |
351 bool CPluginClass::IsStatusBarEnabled() | 316 bool CPluginClass::IsStatusBarEnabled() |
352 { | 317 { |
353 DEBUG_GENERAL("IsStatusBarEnabled start"); | 318 DEBUG_GENERAL("IsStatusBarEnabled start"); |
354 HKEY pHkey; | 319 HKEY pHkey; |
355 HKEY pHkeySub; | 320 HKEY pHkeySub; |
356 RegOpenCurrentUser(KEY_QUERY_VALUE, &pHkey); | 321 RegOpenCurrentUser(KEY_QUERY_VALUE, &pHkey); |
357 DWORD truth = 1; | 322 DWORD truth = 1; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
483 return; | 448 return; |
484 } | 449 } |
485 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal)); | 450 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal)); |
486 | 451 |
487 // If webbrowser2 is equal to top level browser (as set in SetSite), we are | 452 // If webbrowser2 is equal to top level browser (as set in SetSite), we are |
488 // navigating new page | 453 // navigating new page |
489 CPluginClient* client = CPluginClient::GetInstance(); | 454 CPluginClient* client = CPluginClient::GetInstance(); |
490 if (url.find(L"javascript") == 0) | 455 if (url.find(L"javascript") == 0) |
491 { | 456 { |
492 } | 457 } |
493 else if (GetBrowser().IsEqualObject(webBrowser)) | 458 else if (IsRootBrowser(webBrowser)) |
494 { | 459 { |
495 m_tab->OnNavigate(url); | 460 m_tab->OnNavigate(url); |
496 DEBUG_GENERAL( | 461 DEBUG_GENERAL( |
497 L"======================================================================== ========\n" | 462 L"======================================================================== ========\n" |
498 L"Begin main navigation url:" + url + L"\n" | 463 L"Begin main navigation url:" + url + L"\n" |
499 L"======================================================================== ========") | 464 L"======================================================================== ========") |
500 | 465 |
501 #ifdef ENABLE_DEBUG_RESULT | 466 #ifdef ENABLE_DEBUG_RESULT |
502 CPluginDebug::DebugResultDomain(url); | 467 CPluginDebug::DebugResultDomain(url); |
503 #endif | 468 #endif |
504 UpdateStatusBar(); | 469 UpdateStatusBar(); |
505 } | 470 } |
506 else | 471 else |
507 { | 472 { |
508 DEBUG_NAVI(L"Navi::Begin navigation url:" + url) | 473 DEBUG_NAVI(L"Navi::Begin navigation url:" + url) |
509 m_tab->CacheFrame(url); | 474 m_tab->CacheFrame(url); |
510 } | 475 } |
511 } | 476 } |
512 catch (...) | 477 catch (...) |
513 { | 478 { |
514 } | 479 } |
515 } | 480 } |
516 | 481 |
517 // Entry point | 482 // Entry point |
518 void STDMETHODCALLTYPE CPluginClass::OnDownloadComplete() | 483 void STDMETHODCALLTYPE CPluginClass::OnDownloadComplete() |
519 { | 484 { |
520 try | 485 try |
521 { | 486 { |
487 if (!m_webBrowser2) | |
488 { | |
489 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::OnDownloadComplete - Reached with m_webBrowser2 == nullptr"); | |
490 return; | |
491 } | |
522 DEBUG_NAVI(L"Navi::Download Complete") | 492 DEBUG_NAVI(L"Navi::Download Complete") |
523 ATL::CComPtr<IWebBrowser2> browser = GetBrowser(); | 493 m_tab->OnDownloadComplete(m_webBrowser2); |
524 if (browser) | |
525 { | |
526 m_tab->OnDownloadComplete(browser); | |
527 } | |
528 } | 494 } |
529 catch (...) | 495 catch (...) |
530 { | 496 { |
531 } | 497 } |
532 } | 498 } |
533 | 499 |
534 // Entry point | 500 // Entry point |
535 void STDMETHODCALLTYPE CPluginClass::OnDocumentComplete(IDispatch* frameBrowserD isp, VARIANT* /*urlOrPidl*/) | 501 void STDMETHODCALLTYPE CPluginClass::OnDocumentComplete(IDispatch* frameBrowserD isp, VARIANT* /*urlOrPidl*/) |
536 { | 502 { |
537 try | 503 try |
538 { | 504 { |
539 DEBUG_NAVI(L"Navi::Document Complete"); | 505 DEBUG_NAVI(L"Navi::Document Complete"); |
540 ATL::CComQIPtr<IWebBrowser2> webBrowser2 = frameBrowserDisp; | 506 ATL::CComQIPtr<IWebBrowser2> webBrowser2 = frameBrowserDisp; |
541 if (!webBrowser2) | 507 if (!webBrowser2) |
542 { | 508 { |
543 return; | 509 return; |
544 } | 510 } |
545 std::wstring frameSrc = GetLocationUrl(*webBrowser2); | 511 std::wstring frameSrc = GetLocationUrl(*webBrowser2); |
546 bool isRootPageBrowser = GetBrowser().IsEqualObject(webBrowser2); | 512 m_tab->OnDocumentComplete(webBrowser2, frameSrc, IsRootBrowser(webBrowser2)) ; |
547 m_tab->OnDocumentComplete(webBrowser2, frameSrc, isRootPageBrowser); | |
548 } | 513 } |
549 catch (...) | 514 catch (...) |
550 { | 515 { |
551 } | 516 } |
552 } | 517 } |
553 | 518 |
554 // Entry point | 519 // Entry point |
555 void STDMETHODCALLTYPE CPluginClass::OnWindowStateChanged(unsigned long flags, u nsigned long validFlagsMask) | 520 void STDMETHODCALLTYPE CPluginClass::OnWindowStateChanged(unsigned long flags, u nsigned long validFlagsMask) |
556 { | 521 { |
557 try | 522 try |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
616 { | 581 { |
617 Unadvise(); | 582 Unadvise(); |
618 } | 583 } |
619 catch (...) | 584 catch (...) |
620 { | 585 { |
621 } | 586 } |
622 } | 587 } |
623 | 588 |
624 bool CPluginClass::InitObject() | 589 bool CPluginClass::InitObject() |
625 { | 590 { |
626 DEBUG_GENERAL("InitObject"); | 591 DEBUG_GENERAL("InitObject - begin"); |
627 CPluginSettings* settings = CPluginSettings::GetInstance(); | 592 CPluginSettings* settings = CPluginSettings::GetInstance(); |
628 | 593 |
629 if (!settings->GetPluginEnabled()) | 594 if (!settings->GetPluginEnabled()) |
630 { | 595 { |
631 s_mimeFilter->Unregister(); | 596 s_mimeFilter->Unregister(); |
632 } | 597 } |
633 | 598 |
634 // Load theme module | 599 // Load theme module |
635 s_criticalSectionLocal.Lock(); | 600 s_criticalSectionLocal.Lock(); |
636 { | 601 { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
729 if (((m_hPaneWnd == NULL) || !IsStatusBarEnabled()) && isFirstRun) | 694 if (((m_hPaneWnd == NULL) || !IsStatusBarEnabled()) && isFirstRun) |
730 { | 695 { |
731 ShowStatusBar(); | 696 ShowStatusBar(); |
732 } | 697 } |
733 | 698 |
734 // Enable acceptable ads by default | 699 // Enable acceptable ads by default |
735 std::wstring aaUrl = CPluginClient::GetInstance()->GetPref(L"subscriptions_e xceptionsurl", L""); | 700 std::wstring aaUrl = CPluginClient::GetInstance()->GetPref(L"subscriptions_e xceptionsurl", L""); |
736 CPluginClient::GetInstance()->AddSubscription(aaUrl); | 701 CPluginClient::GetInstance()->AddSubscription(aaUrl); |
737 } | 702 } |
738 s_criticalSectionLocal.Unlock(); | 703 s_criticalSectionLocal.Unlock(); |
704 | |
705 DEBUG_GENERAL("InitObject - end"); | |
739 return true; | 706 return true; |
740 } | 707 } |
741 | 708 |
742 bool CPluginClass::CreateStatusBarPane() | 709 bool CPluginClass::CreateStatusBarPane() |
743 { | 710 { |
744 CriticalSection::Lock lock(m_csStatusBar); | 711 CriticalSection::Lock lock(m_csStatusBar); |
745 | 712 |
746 CPluginClient* client = CPluginClient::GetInstance(); | 713 CPluginClient* client = CPluginClient::GetInstance(); |
747 | 714 |
748 std::array<wchar_t, MAX_PATH> className; | 715 std::array<wchar_t, MAX_PATH> className; |
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1617 } | 1584 } |
1618 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE)) | 1585 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE)) |
1619 { | 1586 { |
1620 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID ATE_STATUSBAR, "Class::Invalidate statusbar"); | 1587 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID ATE_STATUSBAR, "Class::Invalidate statusbar"); |
1621 } | 1588 } |
1622 } | 1589 } |
1623 | 1590 |
1624 | 1591 |
1625 void CPluginClass::Unadvise() | 1592 void CPluginClass::Unadvise() |
1626 { | 1593 { |
1594 if (!m_webBrowser2) | |
1595 { | |
1596 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::Unadvise - Reached with m_webBrowser 2 == nullptr"); | |
1597 return; | |
1598 } | |
1627 s_criticalSectionLocal.Lock(); | 1599 s_criticalSectionLocal.Lock(); |
1628 { | 1600 { |
1629 if (m_isAdvised) | 1601 if (m_isAdvised) |
1630 { | 1602 { |
1631 HRESULT hr = DispEventUnadvise(GetBrowser()); | 1603 HRESULT hr = DispEventUnadvise(m_webBrowser2); |
1632 if (FAILED(hr)) | 1604 if (FAILED(hr)) |
1633 { | 1605 { |
1634 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_UNADVIS E, "Class::Unadvise - Unadvise"); | 1606 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_UNADVIS E, "Class::Unadvise - Unadvise"); |
1635 } | 1607 } |
1636 m_isAdvised = false; | 1608 m_isAdvised = false; |
1637 } | 1609 } |
1638 } | 1610 } |
1639 s_criticalSectionLocal.Unlock(); | 1611 s_criticalSectionLocal.Unlock(); |
1640 } | 1612 } |
1641 | 1613 |
(...skipping 19 matching lines...) Expand all Loading... | |
1661 s_criticalSectionLocal.Unlock(); | 1633 s_criticalSectionLocal.Unlock(); |
1662 | 1634 |
1663 return icon; | 1635 return icon; |
1664 } | 1636 } |
1665 | 1637 |
1666 ATOM CPluginClass::GetAtomPaneClass() | 1638 ATOM CPluginClass::GetAtomPaneClass() |
1667 { | 1639 { |
1668 return s_atomPaneClass; | 1640 return s_atomPaneClass; |
1669 } | 1641 } |
1670 | 1642 |
1671 HWND CPluginClass::GetTabHWND() const | |
1672 { | |
1673 std::array<wchar_t, MAX_PATH> className; | |
1674 // Get browser window and url | |
1675 HWND hBrowserWnd = GetBrowserHWND(); | |
1676 if (!hBrowserWnd) | |
1677 { | |
1678 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_BROWSER, "C lass::GetTabWindow - No tab window") | |
1679 s_criticalSectionWindow.Unlock(); | |
1680 | |
1681 return false; | |
1682 } | |
1683 | |
1684 // Looking for a TabWindowClass window in IE7 | |
1685 | |
1686 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD); | |
1687 while (hTabWnd) | |
1688 { | |
1689 className[0] = L'\0'; | |
1690 int classNameLength = GetClassNameW(hTabWnd, className.data(), className.siz e()); | |
1691 | |
1692 if (classNameLength && (wcscmp(className.data(), L"TabWindowClass") == 0 || wcscmp(className.data(), L"Frame Tab") == 0)) | |
1693 { | |
1694 // IE8 support | |
1695 HWND hTabWnd2 = hTabWnd; | |
1696 if (wcscmp(className.data(), L"Frame Tab") == 0) | |
1697 { | |
1698 hTabWnd2 = ::FindWindowEx(hTabWnd2, NULL, L"TabWindowClass", NULL); | |
1699 } | |
1700 | |
1701 if (hTabWnd2) | |
1702 { | |
1703 DWORD nProcessId; | |
1704 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId); | |
1705 if (::GetCurrentProcessId() == nProcessId) | |
1706 { | |
1707 bool bExistingTab = false; | |
1708 s_criticalSectionLocal.Lock(); | |
1709 | |
1710 { | |
1711 for (auto instance : s_instances) | |
1712 { | |
1713 if (instance->m_hTabWnd == hTabWnd2) | |
1714 { | |
1715 bExistingTab = true; | |
1716 break; | |
1717 } | |
1718 } | |
1719 } | |
1720 | |
1721 if (!bExistingTab) | |
1722 { | |
1723 hBrowserWnd = hTabWnd2; | |
1724 hTabWnd = hTabWnd2; | |
1725 s_criticalSectionLocal.Unlock(); | |
1726 break; | |
1727 } | |
1728 s_criticalSectionLocal.Unlock(); | |
1729 | |
1730 } | |
1731 } | |
1732 } | |
1733 | |
1734 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | |
1735 } | |
1736 return hTabWnd; | |
1737 } | |
OLD | NEW |