Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/plugin/PluginClass.cpp

Issue 29323611: Issue #1234, #2058 - Rewrite log facility, improving thread implementation
Patch Set: Created Aug. 19, 2015, 5:42 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include "PluginStdAfx.h" 18 #include "PluginStdAfx.h"
19 19
20 #include "PluginClass.h" 20 #include "PluginClass.h"
21 #include "PluginSettings.h" 21 #include "PluginSettings.h"
22 #include "PluginSystem.h" 22 #include "PluginSystem.h"
23 #include "PluginFilter.h" 23 #include "PluginFilter.h"
24 #include "PluginMimeFilterClient.h" 24 #include "PluginMimeFilterClient.h"
25 #include "AdblockPlusClient.h" 25 #include "AdblockPlusClient.h"
26 #include "PluginClientBase.h"
27 #include "PluginClientFactory.h" 26 #include "PluginClientFactory.h"
28 #include "PluginUtil.h" 27 #include "PluginUtil.h"
29 #include "../shared/Utils.h" 28 #include "../shared/Utils.h"
30 #include "../shared/Dictionary.h" 29 #include "../shared/Dictionary.h"
31 #include "IeVersion.h" 30 #include "IeVersion.h"
32 #include "../shared/Version.h" 31 #include "../shared/Version.h"
33 #include <thread> 32 #include <thread>
34 #include <array> 33 #include <array>
35 34
36 #ifdef DEBUG_HIDE_EL 35 #ifdef DEBUG_HIDE_EL
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 HWND CPluginClass::GetBrowserHWND() const 135 HWND CPluginClass::GetBrowserHWND() const
137 { 136 {
138 SHANDLE_PTR hBrowserWndHandle = NULL; 137 SHANDLE_PTR hBrowserWndHandle = NULL;
139 138
140 CComQIPtr<IWebBrowser2> browser = GetBrowser(); 139 CComQIPtr<IWebBrowser2> browser = GetBrowser();
141 if (browser) 140 if (browser)
142 { 141 {
143 HRESULT hr = browser->get_HWND(&hBrowserWndHandle); 142 HRESULT hr = browser->get_HWND(&hBrowserWndHandle);
144 if (FAILED(hr)) 143 if (FAILED(hr))
145 { 144 {
146 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_BROWSER_WINDOW, " Class::GetBrowserHWND - failed") 145 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_BROWSER_WINDOW, " Class::GetBrowserHWND - failed");
147 } 146 }
148 } 147 }
149 148
150 return (HWND)hBrowserWndHandle; 149 return (HWND)hBrowserWndHandle;
151 } 150 }
152 151
153 152
154 CComQIPtr<IWebBrowser2> CPluginClass::GetBrowser() const 153 CComQIPtr<IWebBrowser2> CPluginClass::GetBrowser() const
155 { 154 {
156 CComQIPtr<IWebBrowser2> browser; 155 CComQIPtr<IWebBrowser2> browser;
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 CComBSTR curLoc; 439 CComBSTR curLoc;
441 browser->get_LocationURL(&curLoc); 440 browser->get_LocationURL(&curLoc);
442 HRESULT hr = browser->Navigate(curLoc, &vFlags, NULL, NULL, NULL); 441 HRESULT hr = browser->Navigate(curLoc, &vFlags, NULL, NULL, NULL);
443 if (FAILED(hr)) 442 if (FAILED(hr))
444 { 443 {
445 vFlags.intVal = navOpenInNewWindow; 444 vFlags.intVal = navOpenInNewWindow;
446 445
447 hr = browser->Navigate(CComBSTR(curLoc), &vFlags, NULL, NULL, NULL); 446 hr = browser->Navigate(CComBSTR(curLoc), &vFlags, NULL, NULL, NULL);
448 if (FAILED(hr)) 447 if (FAILED(hr))
449 { 448 {
450 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATI ON, "Navigation::Failed") 449 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATI ON, "Navigation::Failed");
451 } 450 }
452 } 451 }
453 browser->Quit(); 452 browser->Quit();
454 } 453 }
455 } 454 }
456 } 455 }
457 else 456 else
458 { 457 {
459 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class ::Get statusbar state"); 458 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class ::Get statusbar state");
460 } 459 }
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 { 745 {
747 CriticalSection::Lock lock(m_csStatusBar); 746 CriticalSection::Lock lock(m_csStatusBar);
748 747
749 CPluginClient* client = CPluginClient::GetInstance(); 748 CPluginClient* client = CPluginClient::GetInstance();
750 749
751 std::array<wchar_t, MAX_PATH> className; 750 std::array<wchar_t, MAX_PATH> className;
752 // Get browser window and url 751 // Get browser window and url
753 HWND hBrowserWnd = GetBrowserHWND(); 752 HWND hBrowserWnd = GetBrowserHWND();
754 if (!hBrowserWnd) 753 if (!hBrowserWnd)
755 { 754 {
756 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_BROWSER, "C lass::CreateStatusBarPane - No status bar") 755 TRACE("No window handle for browser site", HERE_F);
757 return false; 756 return false;
758 } 757 }
759 758
760 // Looking for a TabWindowClass window in IE7 759 // Looking for a TabWindowClass window in IE7
761 // the last one should be parent for statusbar 760 // the last one should be parent for statusbar
762 HWND hWndStatusBar = NULL; 761 HWND hWndStatusBar = NULL;
763 762
764 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD); 763 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD);
765 UINT amoundOfNewTabs = 0; 764 UINT amoundOfNewTabs = 0;
766 HWND uniqueNewTab = NULL; 765 HWND uniqueNewTab = NULL;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 { 827 {
829 hWndStatusBar = hWnd; 828 hWndStatusBar = hWnd;
830 break; 829 break;
831 } 830 }
832 831
833 hWnd = ::GetWindow(hWnd, GW_HWNDNEXT); 832 hWnd = ::GetWindow(hWnd, GW_HWNDNEXT);
834 } 833 }
835 834
836 if (!hWndStatusBar) 835 if (!hWndStatusBar)
837 { 836 {
838 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_WIN, "Class ::CreateStatusBarPane - No status bar") 837 TRACE("No status bar", HERE_F);
839 return true; 838 return true;
840 } 839 }
841 840
842 // Calculate pane height 841 // Calculate pane height
843 AdblockPlus::Rectangle rcStatusBar; 842 AdblockPlus::Rectangle rcStatusBar;
844 ::GetClientRect(hWndStatusBar, &rcStatusBar); 843 ::GetClientRect(hWndStatusBar, &rcStatusBar);
845 844
846 if (rcStatusBar.Height() > 0) 845 if (rcStatusBar.Height() > 0)
847 { 846 {
848 if (rcStatusBar.Height() < iconWidth) 847 if (rcStatusBar.Height() < iconWidth)
(...skipping 23 matching lines...) Expand all
872 L"", 871 L"",
873 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 872 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
874 rcStatusBar.Width() - 500, 0, m_nPaneWidth, rcStatusBar.Height(), 873 rcStatusBar.Width() - 500, 0, m_nPaneWidth, rcStatusBar.Height(),
875 hWndStatusBar, 874 hWndStatusBar,
876 (HMENU)3671, 875 (HMENU)3671,
877 _Module.m_hInst, 876 _Module.m_hInst,
878 NULL); 877 NULL);
879 878
880 if (!hWndNewPane) 879 if (!hWndNewPane)
881 { 880 {
882 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_CREATE_ST ATUSBAR_PANE, "Class::CreateStatusBarPane - CreateWindowEx") 881 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_CREATE_ST ATUSBAR_PANE, "Class::CreateStatusBarPane - CreateWindowEx");
883 return false; 882 return false;
884 } 883 }
885 884
886 DEBUG_GENERAL("ABP window created"); 885 DEBUG_GENERAL("ABP window created");
887 m_hTabWnd = hTabWnd; 886 m_hTabWnd = hTabWnd;
888 m_hStatusBarWnd = hWndStatusBar; 887 m_hStatusBarWnd = hWndStatusBar;
889 m_hPaneWnd = hWndNewPane; 888 m_hPaneWnd = hWndNewPane;
890 889
891 UpdateTheme(); 890 UpdateTheme();
892 891
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 927
929 HRESULT hr = GetAsyncBrowser()->Navigate(navigatePath, &vFlags, NULL, NULL, NU LL); 928 HRESULT hr = GetAsyncBrowser()->Navigate(navigatePath, &vFlags, NULL, NULL, NU LL);
930 if (FAILED(hr)) 929 if (FAILED(hr))
931 { 930 {
932 vFlags.intVal = navOpenInNewWindow; 931 vFlags.intVal = navOpenInNewWindow;
933 hr = GetAsyncBrowser()->Navigate(navigatePath, &vFlags, NULL, NULL, NULL); 932 hr = GetAsyncBrowser()->Navigate(navigatePath, &vFlags, NULL, NULL, NULL);
934 } 933 }
935 934
936 if (FAILED(hr)) 935 if (FAILED(hr))
937 { 936 {
938 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION_WELCOME , "Navigation::Welcome page failed") 937 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION_WELCOME , "Navigation::Welcome page failed");
939 } 938 }
940 } 939 }
941 void CPluginClass::CloseTheme() 940 void CPluginClass::CloseTheme()
942 { 941 {
943 if (m_hTheme) 942 if (m_hTheme)
944 { 943 {
945 if (pfnClose) 944 if (pfnClose)
946 { 945 {
947 pfnClose(m_hTheme); 946 pfnClose(m_hTheme);
948 } 947 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 auto userSettingsFileUrl = UserSettingsFileUrl(); 1109 auto userSettingsFileUrl = UserSettingsFileUrl();
1111 ATL::CComBSTR urlToNavigate(static_cast<int>(userSettingsFileUrl.length( )), userSettingsFileUrl.c_str()); 1110 ATL::CComBSTR urlToNavigate(static_cast<int>(userSettingsFileUrl.length( )), userSettingsFileUrl.c_str());
1112 HRESULT hr = browser->Navigate(urlToNavigate, &vFlags, NULL, NULL, NULL) ; 1111 HRESULT hr = browser->Navigate(urlToNavigate, &vFlags, NULL, NULL, NULL) ;
1113 if (FAILED(hr)) 1112 if (FAILED(hr))
1114 { 1113 {
1115 vFlags.intVal = navOpenInNewWindow; 1114 vFlags.intVal = navOpenInNewWindow;
1116 1115
1117 hr = browser->Navigate(urlToNavigate, &vFlags, NULL, NULL, NULL); 1116 hr = browser->Navigate(urlToNavigate, &vFlags, NULL, NULL, NULL);
1118 if (FAILED(hr)) 1117 if (FAILED(hr))
1119 { 1118 {
1120 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION _SETTINGS, "Navigation::Failed") 1119 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION _SETTINGS, "Navigation::Failed");
1121 } 1120 }
1122 } 1121 }
1123 } 1122 }
1124 break; 1123 break;
1125 } 1124 }
1126 case ID_MENU_DISABLE_ON_SITE: 1125 case ID_MENU_DISABLE_ON_SITE:
1127 { 1126 {
1128 CPluginSettings* settings = CPluginSettings::GetInstance(); 1127 CPluginSettings* settings = CPluginSettings::GetInstance();
1129 std::wstring urlString = GetTab()->GetDocumentUrl(); 1128 std::wstring urlString = GetTab()->GetDocumentUrl();
1130 std::string filterText = client->GetWhitelistingFilter(urlString); 1129 std::string filterText = client->GetWhitelistingFilter(urlString);
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 case WM_DESTROY: 1544 case WM_DESTROY:
1546 break; 1545 break;
1547 case SC_CLOSE: 1546 case SC_CLOSE:
1548 break; 1547 break;
1549 1548
1550 case WM_UPDATEUISTATE: 1549 case WM_UPDATEUISTATE:
1551 { 1550 {
1552 CPluginTab* tab = GetTab(::GetCurrentThreadId()); 1551 CPluginTab* tab = GetTab(::GetCurrentThreadId());
1553 if (tab) 1552 if (tab)
1554 { 1553 {
1555 tab->OnActivate();
1556 RECT rect; 1554 RECT rect;
1557 GetWindowRect(pClass->m_hPaneWnd, &rect); 1555 GetWindowRect(pClass->m_hPaneWnd, &rect);
1558 pClass->notificationMessage.Move(rect.left + (rect.right - rect.left) / 2, rect.top + (rect.bottom - rect.top) / 2); 1556 pClass->notificationMessage.Move(rect.left + (rect.right - rect.left) / 2, rect.top + (rect.bottom - rect.top) / 2);
1559 } 1557 }
1560 if (LOWORD(wParam) == UIS_CLEAR) 1558 if (LOWORD(wParam) == UIS_CLEAR)
1561 { 1559 {
1562 pClass->notificationMessage.Hide(); 1560 pClass->notificationMessage.Hide();
1563 } 1561 }
1564 } 1562 }
1565 break; 1563 break;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 return s_atomPaneClass; 1670 return s_atomPaneClass;
1673 } 1671 }
1674 1672
1675 HWND CPluginClass::GetTabHWND() const 1673 HWND CPluginClass::GetTabHWND() const
1676 { 1674 {
1677 std::array<wchar_t, MAX_PATH> className; 1675 std::array<wchar_t, MAX_PATH> className;
1678 // Get browser window and url 1676 // Get browser window and url
1679 HWND hBrowserWnd = GetBrowserHWND(); 1677 HWND hBrowserWnd = GetBrowserHWND();
1680 if (!hBrowserWnd) 1678 if (!hBrowserWnd)
1681 { 1679 {
1682 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_BROWSER, "C lass::GetTabWindow - No tab window") 1680 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_BROWSER, "C lass::GetTabWindow - No tab window");
1683 s_criticalSectionWindow.Unlock(); 1681 s_criticalSectionWindow.Unlock();
1684
1685 return false; 1682 return false;
1686 } 1683 }
1687 1684
1688 // Looking for a TabWindowClass window in IE7 1685 // Looking for a TabWindowClass window in IE7
1689 1686
1690 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD); 1687 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD);
1691 while (hTabWnd) 1688 while (hTabWnd)
1692 { 1689 {
1693 className[0] = L'\0'; 1690 className[0] = L'\0';
1694 int classNameLength = GetClassNameW(hTabWnd, className.data(), className.siz e()); 1691 int classNameLength = GetClassNameW(hTabWnd, className.data(), className.siz e());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 s_criticalSectionLocal.Unlock(); 1729 s_criticalSectionLocal.Unlock();
1733 1730
1734 } 1731 }
1735 } 1732 }
1736 } 1733 }
1737 1734
1738 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); 1735 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT);
1739 } 1736 }
1740 return hTabWnd; 1737 return hTabWnd;
1741 } 1738 }
OLDNEW

Powered by Google App Engine
This is Rietveld