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: rebase only Created Nov. 26, 2015, 1:07 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
« no previous file with comments | « src/plugin/PluginClass.h ('k') | src/plugin/PluginClientBase.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 CComBSTR curLoc; 438 CComBSTR curLoc;
440 browser->get_LocationURL(&curLoc); 439 browser->get_LocationURL(&curLoc);
441 HRESULT hr = browser->Navigate(curLoc, &vFlags, NULL, NULL, NULL); 440 HRESULT hr = browser->Navigate(curLoc, &vFlags, NULL, NULL, NULL);
442 if (FAILED(hr)) 441 if (FAILED(hr))
443 { 442 {
444 vFlags.intVal = navOpenInNewWindow; 443 vFlags.intVal = navOpenInNewWindow;
445 444
446 hr = browser->Navigate(CComBSTR(curLoc), &vFlags, NULL, NULL, NULL); 445 hr = browser->Navigate(CComBSTR(curLoc), &vFlags, NULL, NULL, NULL);
447 if (FAILED(hr)) 446 if (FAILED(hr))
448 { 447 {
449 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATI ON, "Navigation::Failed") 448 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATI ON, "Navigation::Failed");
450 } 449 }
451 } 450 }
452 browser->Quit(); 451 browser->Quit();
453 } 452 }
454 } 453 }
455 } 454 }
456 else 455 else
457 { 456 {
458 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class ::Get statusbar state"); 457 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class ::Get statusbar state");
459 } 458 }
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 { 742 {
744 CriticalSection::Lock lock(m_csStatusBar); 743 CriticalSection::Lock lock(m_csStatusBar);
745 744
746 CPluginClient* client = CPluginClient::GetInstance(); 745 CPluginClient* client = CPluginClient::GetInstance();
747 746
748 std::array<wchar_t, MAX_PATH> className; 747 std::array<wchar_t, MAX_PATH> className;
749 // Get browser window and url 748 // Get browser window and url
750 HWND hBrowserWnd = GetBrowserHWND(); 749 HWND hBrowserWnd = GetBrowserHWND();
751 if (!hBrowserWnd) 750 if (!hBrowserWnd)
752 { 751 {
753 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_BROWSER, "C lass::CreateStatusBarPane - No status bar") 752 TRACE("No window handle for browser site", HERE_F);
754 return false; 753 return false;
755 } 754 }
756 755
757 // Looking for a TabWindowClass window in IE7 756 // Looking for a TabWindowClass window in IE7
758 // the last one should be parent for statusbar 757 // the last one should be parent for statusbar
759 HWND hWndStatusBar = NULL; 758 HWND hWndStatusBar = NULL;
760 759
761 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD); 760 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD);
762 UINT amoundOfNewTabs = 0; 761 UINT amoundOfNewTabs = 0;
763 HWND uniqueNewTab = NULL; 762 HWND uniqueNewTab = NULL;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 { 824 {
826 hWndStatusBar = hWnd; 825 hWndStatusBar = hWnd;
827 break; 826 break;
828 } 827 }
829 828
830 hWnd = ::GetWindow(hWnd, GW_HWNDNEXT); 829 hWnd = ::GetWindow(hWnd, GW_HWNDNEXT);
831 } 830 }
832 831
833 if (!hWndStatusBar) 832 if (!hWndStatusBar)
834 { 833 {
835 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_WIN, "Class ::CreateStatusBarPane - No status bar") 834 TRACE("No status bar", HERE_F);
836 return true; 835 return true;
837 } 836 }
838 837
839 // Calculate pane height 838 // Calculate pane height
840 AdblockPlus::Rectangle rcStatusBar; 839 AdblockPlus::Rectangle rcStatusBar;
841 ::GetClientRect(hWndStatusBar, &rcStatusBar); 840 ::GetClientRect(hWndStatusBar, &rcStatusBar);
842 841
843 if (rcStatusBar.Height() > 0) 842 if (rcStatusBar.Height() > 0)
844 { 843 {
845 if (rcStatusBar.Height() < iconWidth) 844 if (rcStatusBar.Height() < iconWidth)
(...skipping 23 matching lines...) Expand all
869 L"", 868 L"",
870 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 869 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
871 rcStatusBar.Width() - 500, 0, m_nPaneWidth, rcStatusBar.Height(), 870 rcStatusBar.Width() - 500, 0, m_nPaneWidth, rcStatusBar.Height(),
872 hWndStatusBar, 871 hWndStatusBar,
873 (HMENU)3671, 872 (HMENU)3671,
874 _Module.m_hInst, 873 _Module.m_hInst,
875 NULL); 874 NULL);
876 875
877 if (!hWndNewPane) 876 if (!hWndNewPane)
878 { 877 {
879 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_CREATE_ST ATUSBAR_PANE, "Class::CreateStatusBarPane - CreateWindowEx") 878 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_CREATE_ST ATUSBAR_PANE, "Class::CreateStatusBarPane - CreateWindowEx");
880 return false; 879 return false;
881 } 880 }
882 881
883 DEBUG_GENERAL("ABP window created"); 882 DEBUG_GENERAL("ABP window created");
884 m_hTabWnd = hTabWnd; 883 m_hTabWnd = hTabWnd;
885 m_hStatusBarWnd = hWndStatusBar; 884 m_hStatusBarWnd = hWndStatusBar;
886 m_hPaneWnd = hWndNewPane; 885 m_hPaneWnd = hWndNewPane;
887 886
888 UpdateTheme(); 887 UpdateTheme();
889 888
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 924
926 HRESULT hr = GetAsyncBrowser()->Navigate(navigatePath, &vFlags, NULL, NULL, NU LL); 925 HRESULT hr = GetAsyncBrowser()->Navigate(navigatePath, &vFlags, NULL, NULL, NU LL);
927 if (FAILED(hr)) 926 if (FAILED(hr))
928 { 927 {
929 vFlags.intVal = navOpenInNewWindow; 928 vFlags.intVal = navOpenInNewWindow;
930 hr = GetAsyncBrowser()->Navigate(navigatePath, &vFlags, NULL, NULL, NULL); 929 hr = GetAsyncBrowser()->Navigate(navigatePath, &vFlags, NULL, NULL, NULL);
931 } 930 }
932 931
933 if (FAILED(hr)) 932 if (FAILED(hr))
934 { 933 {
935 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION_WELCOME , "Navigation::Welcome page failed") 934 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION_WELCOME , "Navigation::Welcome page failed");
936 } 935 }
937 } 936 }
938 void CPluginClass::CloseTheme() 937 void CPluginClass::CloseTheme()
939 { 938 {
940 if (m_hTheme) 939 if (m_hTheme)
941 { 940 {
942 if (pfnClose) 941 if (pfnClose)
943 { 942 {
944 pfnClose(m_hTheme); 943 pfnClose(m_hTheme);
945 } 944 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 auto userSettingsFileUrl = UserSettingsFileUrl(); 1106 auto userSettingsFileUrl = UserSettingsFileUrl();
1108 ATL::CComBSTR urlToNavigate(static_cast<int>(userSettingsFileUrl.length( )), userSettingsFileUrl.c_str()); 1107 ATL::CComBSTR urlToNavigate(static_cast<int>(userSettingsFileUrl.length( )), userSettingsFileUrl.c_str());
1109 HRESULT hr = browser->Navigate(urlToNavigate, &vFlags, NULL, NULL, NULL) ; 1108 HRESULT hr = browser->Navigate(urlToNavigate, &vFlags, NULL, NULL, NULL) ;
1110 if (FAILED(hr)) 1109 if (FAILED(hr))
1111 { 1110 {
1112 vFlags.intVal = navOpenInNewWindow; 1111 vFlags.intVal = navOpenInNewWindow;
1113 1112
1114 hr = browser->Navigate(urlToNavigate, &vFlags, NULL, NULL, NULL); 1113 hr = browser->Navigate(urlToNavigate, &vFlags, NULL, NULL, NULL);
1115 if (FAILED(hr)) 1114 if (FAILED(hr))
1116 { 1115 {
1117 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION _SETTINGS, "Navigation::Failed") 1116 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION _SETTINGS, "Navigation::Failed");
1118 } 1117 }
1119 } 1118 }
1120 } 1119 }
1121 break; 1120 break;
1122 } 1121 }
1123 case ID_MENU_DISABLE_ON_SITE: 1122 case ID_MENU_DISABLE_ON_SITE:
1124 { 1123 {
1125 std::wstring urlString = GetTab()->GetDocumentUrl(); 1124 std::wstring urlString = GetTab()->GetDocumentUrl();
1126 std::string filterText = client->GetWhitelistingFilter(urlString); 1125 std::string filterText = client->GetWhitelistingFilter(urlString);
1127 if (!filterText.empty()) 1126 if (!filterText.empty())
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 case WM_DESTROY: 1540 case WM_DESTROY:
1542 break; 1541 break;
1543 case SC_CLOSE: 1542 case SC_CLOSE:
1544 break; 1543 break;
1545 1544
1546 case WM_UPDATEUISTATE: 1545 case WM_UPDATEUISTATE:
1547 { 1546 {
1548 CPluginTab* tab = GetTab(::GetCurrentThreadId()); 1547 CPluginTab* tab = GetTab(::GetCurrentThreadId());
1549 if (tab) 1548 if (tab)
1550 { 1549 {
1551 tab->OnActivate();
1552 RECT rect; 1550 RECT rect;
1553 GetWindowRect(pClass->m_hPaneWnd, &rect); 1551 GetWindowRect(pClass->m_hPaneWnd, &rect);
1554 pClass->notificationMessage.Move(rect.left + (rect.right - rect.left) / 2, rect.top + (rect.bottom - rect.top) / 2); 1552 pClass->notificationMessage.Move(rect.left + (rect.right - rect.left) / 2, rect.top + (rect.bottom - rect.top) / 2);
1555 } 1553 }
1556 if (LOWORD(wParam) == UIS_CLEAR) 1554 if (LOWORD(wParam) == UIS_CLEAR)
1557 { 1555 {
1558 pClass->notificationMessage.Hide(); 1556 pClass->notificationMessage.Hide();
1559 } 1557 }
1560 } 1558 }
1561 break; 1559 break;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 return s_atomPaneClass; 1666 return s_atomPaneClass;
1669 } 1667 }
1670 1668
1671 HWND CPluginClass::GetTabHWND() const 1669 HWND CPluginClass::GetTabHWND() const
1672 { 1670 {
1673 std::array<wchar_t, MAX_PATH> className; 1671 std::array<wchar_t, MAX_PATH> className;
1674 // Get browser window and url 1672 // Get browser window and url
1675 HWND hBrowserWnd = GetBrowserHWND(); 1673 HWND hBrowserWnd = GetBrowserHWND();
1676 if (!hBrowserWnd) 1674 if (!hBrowserWnd)
1677 { 1675 {
1678 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_BROWSER, "C lass::GetTabWindow - No tab window") 1676 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_BROWSER, "C lass::GetTabWindow - No tab window");
1679 s_criticalSectionWindow.Unlock(); 1677 s_criticalSectionWindow.Unlock();
1680
1681 return false; 1678 return false;
1682 } 1679 }
1683 1680
1684 // Looking for a TabWindowClass window in IE7 1681 // Looking for a TabWindowClass window in IE7
1685 1682
1686 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD); 1683 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD);
1687 while (hTabWnd) 1684 while (hTabWnd)
1688 { 1685 {
1689 className[0] = L'\0'; 1686 className[0] = L'\0';
1690 int classNameLength = GetClassNameW(hTabWnd, className.data(), className.siz e()); 1687 int classNameLength = GetClassNameW(hTabWnd, className.data(), className.siz e());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 s_criticalSectionLocal.Unlock(); 1725 s_criticalSectionLocal.Unlock();
1729 1726
1730 } 1727 }
1731 } 1728 }
1732 } 1729 }
1733 1730
1734 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); 1731 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT);
1735 } 1732 }
1736 return hTabWnd; 1733 return hTabWnd;
1737 } 1734 }
OLDNEW
« no previous file with comments | « src/plugin/PluginClass.h ('k') | src/plugin/PluginClientBase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld