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

Delta Between Two Patch Sets: Shared/PluginClass.cpp

Issue 9998007: Initial libadblockplus integration (Closed)
Left Patch Set: Subscription changes and filter management cleanup Created April 5, 2013, 1:56 a.m.
Right Patch Set: Whitelisting management Created April 11, 2013, 9:06 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « Shared/AdblockPlusClient.h ('k') | Shared/PluginConfiguration.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 #include "PluginStdAfx.h" 1 #include "PluginStdAfx.h"
2 2
3 #include "PluginClass.h" 3 #include "PluginClass.h"
4 #include "PluginDictionary.h" 4 #include "PluginDictionary.h"
5 #include "PluginSettings.h" 5 #include "PluginSettings.h"
6 #include "PluginSystem.h" 6 #include "PluginSystem.h"
7 #ifdef SUPPORT_FILTER 7 #ifdef SUPPORT_FILTER
8 #include "PluginFilter.h" 8 #include "PluginFilter.h"
9 #endif 9 #endif
10 #include "PluginMimeFilterClient.h" 10 #include "PluginMimeFilterClient.h"
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 1436
1437 case ID_ABOUT: 1437 case ID_ABOUT:
1438 { 1438 {
1439 url = CPluginHttpRequest::GetStandardUrl(USERS_SCRIPT_ABOUT); 1439 url = CPluginHttpRequest::GetStandardUrl(USERS_SCRIPT_ABOUT);
1440 navigationErrorId = PLUGIN_ERROR_NAVIGATION_ABOUT; 1440 navigationErrorId = PLUGIN_ERROR_NAVIGATION_ABOUT;
1441 } 1441 }
1442 break; 1442 break;
1443 1443
1444 default: 1444 default:
1445 1445
1446 #ifdef SUPPORT_WHITELIST
1447 {
1448 if (nCommand >= WM_WHITELIST_DOMAIN && nCommand <= WM_WHITELIST_DOMAIN_MAX )
1449 {
1450 CPluginSettings* settings = CPluginSettings::GetInstance();
1451
1452 CString domain;
1453
1454 s_criticalSectionLocal.Lock();
1455 {
1456 domain = s_menuDomains[nCommand];
1457 }
1458 s_criticalSectionLocal.Unlock();
1459
1460 if (settings->IsWhiteListedDomain(domain))
1461 {
1462 settings->AddWhiteListedDomain(domain, 3, true);
1463 }
1464 else
1465 {
1466 settings->AddWhiteListedDomain(domain, 1, true);
1467 }
1468
1469 client->ClearWhiteListCache();
1470 }
1471 }
1472 #endif // SUPPORT_WHITELIST
1473 break; 1446 break;
1474 } 1447 }
1475 1448
1476 // Invalidate and redraw the control 1449 // Invalidate and redraw the control
1477 UpdateStatusBar(); 1450 UpdateStatusBar();
1478 1451
1479 CComQIPtr<IWebBrowser2> browser = GetBrowser(); 1452 CComQIPtr<IWebBrowser2> browser = GetBrowser();
1480 if (!url.IsEmpty() && browser) 1453 if (!url.IsEmpty() && browser)
1481 { 1454 {
1482 VARIANT vFlags; 1455 VARIANT vFlags;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 #ifdef SUPPORT_WHITELIST 1527 #ifdef SUPPORT_WHITELIST
1555 { 1528 {
1556 // White list domain 1529 // White list domain
1557 ctext = dictionary->Lookup("MENU_DISABLE_ON"); 1530 ctext = dictionary->Lookup("MENU_DISABLE_ON");
1558 fmii.fMask = MIIM_STRING | MIIM_STATE; 1531 fmii.fMask = MIIM_STRING | MIIM_STATE;
1559 fmii.fState = MFS_DISABLED; 1532 fmii.fState = MFS_DISABLED;
1560 fmii.dwTypeData = ctext.GetBuffer(); 1533 fmii.dwTypeData = ctext.GetBuffer();
1561 fmii.cch = ctext.GetLength(); 1534 fmii.cch = ctext.GetLength();
1562 1535
1563 UINT index = WM_WHITELIST_DOMAIN; 1536 UINT index = WM_WHITELIST_DOMAIN;
1564
1565 // Add domains from history
1566 if (client)
1567 {
1568 bool isFirst = true;
1569
1570 TDomainHistory domainHistory = settings->GetDomainHistory();
1571
1572 CString documentDomain = tab->GetDocumentDomain();
1573
1574 if (CPluginClient::IsValidDomain(documentDomain))
1575 {
1576 CString documentDomainT = documentDomain;
1577
1578 for (TDomainHistory::const_reverse_iterator it = domainHistory.rbegin(); it != domainHistory.rend(); ++it)
1579 {
1580 if (documentDomain == it->first)
1581 {
1582 if (isFirst)
1583 {
1584 fmii.fState = MFS_ENABLED;
1585 fmii.fMask |= MIIM_SUBMENU;
1586 fmii.hSubMenu = ::CreateMenu();
1587 }
1588
1589 MENUITEMINFO smii;
1590 memset(&smii, 0, sizeof(MENUITEMINFO));
1591 smii.cbSize = sizeof(MENUITEMINFO);
1592
1593 smii.fMask = MIIM_STRING | MIIM_ID;
1594 smii.dwTypeData = documentDomainT.GetBuffer();
1595 smii.cch = documentDomainT.GetLength();
1596 smii.wID = index;
1597
1598 bool isWhitelisted = settings->IsWhiteListedDomain(it->first);
1599 if (isWhitelisted)
1600 {
1601 smii.fMask |= MIIM_STATE;
1602 smii.fState |= MFS_CHECKED;
1603 }
1604
1605 if (isFirst)
1606 {
1607 smii.fMask |= MIIM_STATE;
1608 smii.fState |= MFS_DEFAULT;
1609
1610 isFirst = false;
1611 }
1612
1613 InsertMenuItem(fmii.hSubMenu, index, FALSE, &smii);
1614
1615 s_criticalSectionLocal.Lock();
1616 {
1617 s_menuDomains[index++] = documentDomain;
1618 }
1619 s_criticalSectionLocal.Unlock();
1620 }
1621 }
1622 }
1623
1624 // Add last domains
1625 for (TDomainHistory::const_reverse_iterator it = domainHistory.rbegin(); i t != domainHistory.rend(); ++it)
1626 {
1627 if (it->first != documentDomain)
1628 {
1629 if (isFirst)
1630 {
1631 fmii.fMask |= MIIM_STATE | MIIM_SUBMENU;
1632 fmii.fState = MFS_ENABLED;
1633 fmii.hSubMenu = CreateMenu();
1634
1635 isFirst = false;
1636 }
1637
1638 CString domain = it->first;
1639
1640 MENUITEMINFO smii;
1641 memset(&smii, 0, sizeof(MENUITEMINFO));
1642 smii.cbSize = sizeof(MENUITEMINFO);
1643 smii.fMask = MIIM_STRING | MIIM_ID;
1644 smii.dwTypeData = domain.GetBuffer();
1645 smii.cch = domain.GetLength();
1646 smii.wID = index;
1647
1648 bool isWhitelisted = settings->IsWhiteListedDomain(it->first);
1649 if (isWhitelisted)
1650 {
1651 smii.fMask |= MIIM_STATE;
1652 smii.fState |= MFS_CHECKED;
1653 }
1654
1655 ::InsertMenuItem(fmii.hSubMenu, index, FALSE, &smii);
1656
1657 s_criticalSectionLocal.Lock();
1658 {
1659 s_menuDomains[index++] = it->first;
1660 }
1661 s_criticalSectionLocal.Unlock();
1662 }
1663 }
1664 }
1665 1537
1666 ::SetMenuItemInfo(hMenu, ID_WHITELISTDOMAIN, FALSE, &fmii); 1538 ::SetMenuItemInfo(hMenu, ID_WHITELISTDOMAIN, FALSE, &fmii);
1667 } 1539 }
1668 #else 1540 #else
1669 { 1541 {
1670 ::DeleteMenu(hMenu, ID_WHITELISTDOMAIN, FALSE); 1542 ::DeleteMenu(hMenu, ID_WHITELISTDOMAIN, FALSE);
1671 } 1543 }
1672 #endif // SUPPORT_WHITELIST 1544 #endif // SUPPORT_WHITELIST
1673 1545
1674 // Invite friends 1546 // Invite friends
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
2333 } 2205 }
2334 } 2206 }
2335 } 2207 }
2336 2208
2337 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); 2209 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT);
2338 } 2210 }
2339 2211
2340 return hTabWnd; 2212 return hTabWnd;
2341 2213
2342 } 2214 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld