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

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

Issue 5948518908821504: Issue #1158 - removed unnecessary definitions and #ifdef/#else/#endif sections (Closed)
Patch Set: Created Aug. 6, 2014, 7:38 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 #include "PluginStdAfx.h" 1 #include "PluginStdAfx.h"
2 2
3 #include "PluginClass.h" 3 #include "PluginClass.h"
4 #include "PluginSettings.h" 4 #include "PluginSettings.h"
5 #include "PluginSystem.h" 5 #include "PluginSystem.h"
6 #ifdef SUPPORT_FILTER
7 #include "PluginFilter.h" 6 #include "PluginFilter.h"
8 #endif
9 #include "PluginMimeFilterClient.h" 7 #include "PluginMimeFilterClient.h"
10 #include "PluginClient.h" 8 #include "PluginClient.h"
11 #include "PluginClientFactory.h" 9 #include "PluginClientFactory.h"
12 #include "PluginMutex.h" 10 #include "PluginMutex.h"
13 #include "sddl.h" 11 #include "sddl.h"
14 #include "PluginUtil.h" 12 #include "PluginUtil.h"
15 #include "PluginUserSettings.h" 13 #include "PluginUserSettings.h"
16 #include "../shared/Utils.h" 14 #include "../shared/Utils.h"
17 #include "../shared/Dictionary.h" 15 #include "../shared/Dictionary.h"
18 #include <thread> 16 #include <thread>
(...skipping 18 matching lines...) Expand all
37 ATOM CPluginClass::s_atomPaneClass = NULL; 35 ATOM CPluginClass::s_atomPaneClass = NULL;
38 HINSTANCE CPluginClass::s_hUxtheme = NULL; 36 HINSTANCE CPluginClass::s_hUxtheme = NULL;
39 std::set<CPluginClass*> CPluginClass::s_instances; 37 std::set<CPluginClass*> CPluginClass::s_instances;
40 std::map<DWORD, CPluginClass*> CPluginClass::s_threadInstances; 38 std::map<DWORD, CPluginClass*> CPluginClass::s_threadInstances;
41 39
42 CComAutoCriticalSection CPluginClass::s_criticalSectionLocal; 40 CComAutoCriticalSection CPluginClass::s_criticalSectionLocal;
43 CComAutoCriticalSection CPluginClass::s_criticalSectionBrowser; 41 CComAutoCriticalSection CPluginClass::s_criticalSectionBrowser;
44 CComAutoCriticalSection CPluginClass::s_criticalSectionWindow; 42 CComAutoCriticalSection CPluginClass::s_criticalSectionWindow;
45 43
46 CComQIPtr<IWebBrowser2> CPluginClass::s_asyncWebBrowser2; 44 CComQIPtr<IWebBrowser2> CPluginClass::s_asyncWebBrowser2;
47
48 #ifdef SUPPORT_WHITELIST
49 std::map<UINT,CString> CPluginClass::s_menuDomains; 45 std::map<UINT,CString> CPluginClass::s_menuDomains;
Oleksandr 2014/10/02 21:24:02 This line can go as well
50 #endif
51 46
52 /* 47 /*
53 * Without namespace declaration, the identifier "Rectangle" is ambiguous 48 * Without namespace declaration, the identifier "Rectangle" is ambiguous
54 * See http://msdn.microsoft.com/en-us/library/windows/desktop/dd162898(v=vs.85) .aspx 49 * See http://msdn.microsoft.com/en-us/library/windows/desktop/dd162898(v=vs.85) .aspx
55 */ 50 */
56 namespace AdblockPlus 51 namespace AdblockPlus
57 { 52 {
58 /** 53 /**
59 * Replacement for ATL type CRect. 54 * Replacement for ATL type CRect.
60 */ 55 */
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 577
583 #ifdef ENABLE_DEBUG_RESULT 578 #ifdef ENABLE_DEBUG_RESULT
584 CPluginDebug::DebugResultDomain(url); 579 CPluginDebug::DebugResultDomain(url);
585 #endif 580 #endif
586 581
587 UpdateStatusBar(); 582 UpdateStatusBar();
588 } 583 }
589 else 584 else
590 { 585 {
591 DEBUG_NAVI(L"Navi::Begin navigation url:" + url) 586 DEBUG_NAVI(L"Navi::Begin navigation url:" + url)
592 587 m_tab->CacheFrame(url);
593 #ifdef SUPPORT_FRAME_CACHING
594 m_tab->CacheFrame(url);
595 #endif
596 } 588 }
597 } 589 }
598 STDMETHODIMP CPluginClass::OnTabChanged(DISPPARAMS* pDispParams, WORD wFlags) 590 STDMETHODIMP CPluginClass::OnTabChanged(DISPPARAMS* pDispParams, WORD wFlags)
599 { 591 {
600 DEBUG_GENERAL("Tab changed"); 592 DEBUG_GENERAL("Tab changed");
601 bool newtabshown = pDispParams->rgvarg[1].intVal==3; 593 bool newtabshown = pDispParams->rgvarg[1].intVal==3;
602 if (newtabshown) 594 if (newtabshown)
603 { 595 {
604 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find(Ge tCurrentThreadId()); 596 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find(Ge tCurrentThreadId());
605 if (it == s_threadInstances.end()) 597 if (it == s_threadInstances.end())
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 1362
1371 1363
1372 bool CPluginClass::SetMenuBar(HMENU hMenu, const CString& url) 1364 bool CPluginClass::SetMenuBar(HMENU hMenu, const CString& url)
1373 { 1365 {
1374 DEBUG_GENERAL("SetMenuBar"); 1366 DEBUG_GENERAL("SetMenuBar");
1375 1367
1376 std::wstring ctext; 1368 std::wstring ctext;
1377 1369
1378 s_criticalSectionLocal.Lock(); 1370 s_criticalSectionLocal.Lock();
1379 { 1371 {
1380 #ifdef SUPPORT_WHITELIST
1381 s_menuDomains.clear(); 1372 s_menuDomains.clear();
Oleksandr 2014/10/02 21:24:02 The whole critical section lock is dummy here. s_m
1382 #endif
1383 } 1373 }
1384 s_criticalSectionLocal.Unlock(); 1374 s_criticalSectionLocal.Unlock();
1385 1375
1386
1387 Dictionary* dictionary = Dictionary::GetInstance(); 1376 Dictionary* dictionary = Dictionary::GetInstance();
1388 1377
1389 MENUITEMINFOW fmii; 1378 MENUITEMINFOW fmii;
1390 memset(&fmii, 0, sizeof(MENUITEMINFO)); 1379 memset(&fmii, 0, sizeof(MENUITEMINFO));
1391 fmii.cbSize = sizeof(MENUITEMINFO); 1380 fmii.cbSize = sizeof(MENUITEMINFO);
1392 1381
1393 MENUITEMINFOW miiSep; 1382 MENUITEMINFOW miiSep;
1394 memset(&miiSep, 0, sizeof(MENUITEMINFO)); 1383 memset(&miiSep, 0, sizeof(MENUITEMINFO));
1395 miiSep.cbSize = sizeof(MENUITEMINFO); 1384 miiSep.cbSize = sizeof(MENUITEMINFO);
1396 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE; 1385 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE;
1397 miiSep.fType = MFT_SEPARATOR; 1386 miiSep.fType = MFT_SEPARATOR;
1398 1387
1399 CPluginClient* client = CPluginClient::GetInstance(); 1388 CPluginClient* client = CPluginClient::GetInstance();
1400
1401 CPluginSettings* settings = CPluginSettings::GetInstance(); 1389 CPluginSettings* settings = CPluginSettings::GetInstance();
1402
1403 #ifdef SUPPORT_WHITELIST
1404 { 1390 {
1405 ctext = dictionary->Lookup("menu", "menu-disable-on-site"); 1391 ctext = dictionary->Lookup("menu", "menu-disable-on-site");
1406 // Is domain in white list? 1392 // Is domain in white list?
1407 ReplaceString(ctext, L"?1?", client->GetHostFromUrl(url.GetString())); 1393 ReplaceString(ctext, L"?1?", client->GetHostFromUrl(url.GetString()));
1408 if (client->IsWhitelistedUrl(std::wstring(GetTab()->GetDocumentUrl()))) 1394 if (client->IsWhitelistedUrl(std::wstring(GetTab()->GetDocumentUrl())))
1409 { 1395 {
1410 fmii.fState = MFS_CHECKED | MFS_ENABLED; 1396 fmii.fState = MFS_CHECKED | MFS_ENABLED;
1411 } 1397 }
1412 else 1398 else
1413 { 1399 {
1414 fmii.fState = MFS_UNCHECKED | MFS_ENABLED; 1400 fmii.fState = MFS_UNCHECKED | MFS_ENABLED;
1415 } 1401 }
1416 fmii.fMask = MIIM_STRING | MIIM_STATE; 1402 fmii.fMask = MIIM_STRING | MIIM_STATE;
1417 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); 1403 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str());
1418 fmii.cch = static_cast<UINT>(ctext.size()); 1404 fmii.cch = static_cast<UINT>(ctext.size());
1419 1405
1420 ::SetMenuItemInfoW(hMenu, ID_MENU_DISABLE_ON_SITE, FALSE, &fmii); 1406 ::SetMenuItemInfoW(hMenu, ID_MENU_DISABLE_ON_SITE, FALSE, &fmii);
1421 } 1407 }
1422 #else
1423 {
1424 ::DeleteMenu(hMenu, ID_MENU_DISABLE_ON_SITE, FALSE);
1425 }
1426 #endif // SUPPORT_WHITELIST
1427 1408
1428 // Plugin update 1409 // Plugin update
1429 ctext = dictionary->Lookup("menu", "menu-update"); 1410 ctext = dictionary->Lookup("menu", "menu-update");
1430 fmii.fMask = MIIM_STATE | MIIM_STRING; 1411 fmii.fMask = MIIM_STATE | MIIM_STRING;
1431 fmii.fState = client ? MFS_ENABLED : MFS_DISABLED; 1412 fmii.fState = client ? MFS_ENABLED : MFS_DISABLED;
1432 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); 1413 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str());
1433 fmii.cch = static_cast<UINT>(ctext.size()); 1414 fmii.cch = static_cast<UINT>(ctext.size());
1434 ::SetMenuItemInfoW(hMenu, ID_MENU_UPDATE, FALSE, &fmii); 1415 ::SetMenuItemInfoW(hMenu, ID_MENU_UPDATE, FALSE, &fmii);
1435 1416
1436 1417
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 1608
1628 HICON CPluginClass::GetStatusBarIcon(const CString& url) 1609 HICON CPluginClass::GetStatusBarIcon(const CString& url)
1629 { 1610 {
1630 // use the disable icon as defualt, if the client doesn't exists 1611 // use the disable icon as defualt, if the client doesn't exists
1631 HICON hIcon = GetIcon(ICON_PLUGIN_DEACTIVATED); 1612 HICON hIcon = GetIcon(ICON_PLUGIN_DEACTIVATED);
1632 1613
1633 CPluginTab* tab = GetTab(::GetCurrentThreadId()); 1614 CPluginTab* tab = GetTab(::GetCurrentThreadId());
1634 if (tab) 1615 if (tab)
1635 { 1616 {
1636 CPluginClient* client = CPluginClient::GetInstance(); 1617 CPluginClient* client = CPluginClient::GetInstance();
1637
1638 #ifdef PRODUCT_ADBLOCKPLUS
1639 if (!CPluginSettings::GetInstance()->IsPluginEnabled()) 1618 if (!CPluginSettings::GetInstance()->IsPluginEnabled())
1640 { 1619 {
Oleksandr 2014/10/02 21:24:02 This is clearly a dummy 'if'. Can we remove it?
1641 } 1620 }
1642 #ifdef SUPPORT_WHITELIST
1643 else if (client->IsWhitelistedUrl(std::wstring(url))) 1621 else if (client->IsWhitelistedUrl(std::wstring(url)))
1644 { 1622 {
1645 hIcon = GetIcon(ICON_PLUGIN_DISABLED); 1623 hIcon = GetIcon(ICON_PLUGIN_DISABLED);
1646 } 1624 }
1647 #endif // SUPPORT_WHITELIST
1648 else 1625 else
1649 { 1626 {
1650 CPluginSettings* settings = CPluginSettings::GetInstance(); 1627 CPluginSettings* settings = CPluginSettings::GetInstance();
1651 hIcon = GetIcon(ICON_PLUGIN_ENABLED); 1628 hIcon = GetIcon(ICON_PLUGIN_ENABLED);
1652 } 1629 }
1653
1654 #endif // PRODUCT_ADBLOCKPLUS
1655 } 1630 }
1656
1657 return hIcon; 1631 return hIcon;
1658 } 1632 }
1659 1633
1660 1634
1661 LRESULT CALLBACK CPluginClass::PaneWindowProc(HWND hWnd, UINT message, WPARAM wP aram, LPARAM lParam) 1635 LRESULT CALLBACK CPluginClass::PaneWindowProc(HWND hWnd, UINT message, WPARAM wP aram, LPARAM lParam)
1662 { 1636 {
1663 // Find tab 1637 // Find tab
1664 CPluginClass *pClass = FindInstance(GetParent(hWnd)); 1638 CPluginClass *pClass = FindInstance(GetParent(hWnd));
1665 if (!pClass) 1639 if (!pClass)
1666 { 1640 {
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1985 } 1959 }
1986 } 1960 }
1987 } 1961 }
1988 1962
1989 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); 1963 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT);
1990 } 1964 }
1991 1965
1992 return hTabWnd; 1966 return hTabWnd;
1993 1967
1994 } 1968 }
OLDNEW

Powered by Google App Engine
This is Rietveld