OLD | NEW |
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 | 6 #ifdef SUPPORT_FILTER |
7 #include "PluginFilter.h" | 7 #include "PluginFilter.h" |
8 #endif | 8 #endif |
9 #include "PluginMimeFilterClient.h" | 9 #include "PluginMimeFilterClient.h" |
10 #include "PluginClient.h" | 10 #include "PluginClient.h" |
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 return fRet; | 1226 return fRet; |
1227 } | 1227 } |
1228 | 1228 |
1229 void CPluginClass::DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, U
INT nMenuFlags) | 1229 void CPluginClass::DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, U
INT nMenuFlags) |
1230 { | 1230 { |
1231 CPluginClient* client = CPluginClient::GetInstance(); | 1231 CPluginClient* client = CPluginClient::GetInstance(); |
1232 | 1232 |
1233 CPluginSystem* system = CPluginSystem::GetInstance(); | 1233 CPluginSystem* system = CPluginSystem::GetInstance(); |
1234 | 1234 |
1235 CString url; | 1235 CString url; |
1236 int navigationErrorId = 0; | 1236 int navigationErrorId = 0; |
1237 | 1237 |
1238 // Create menu parent window | 1238 // Create menu parent window |
1239 HWND hMenuWnd = ::CreateWindowEx( | 1239 HWND hMenuWnd = ::CreateWindowEx( |
1240 NULL, | 1240 NULL, |
1241 MAKEINTATOM(GetAtomPaneClass()), | 1241 MAKEINTATOM(GetAtomPaneClass()), |
1242 _T(""), | 1242 _T(""), |
1243 0, | 1243 0, |
1244 0,0,0,0, | 1244 0,0,0,0, |
1245 NULL, | 1245 NULL, |
1246 NULL, | 1246 NULL, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 else | 1279 else |
1280 { | 1280 { |
1281 s_mimeFilter = NULL; | 1281 s_mimeFilter = NULL; |
1282 | 1282 |
1283 CPluginClientFactory::ReleaseMimeFilterClientInstance(); | 1283 CPluginClientFactory::ReleaseMimeFilterClientInstance(); |
1284 } | 1284 } |
1285 } | 1285 } |
1286 s_criticalSectionLocal.Unlock(); | 1286 s_criticalSectionLocal.Unlock(); |
1287 } | 1287 } |
1288 break; | 1288 break; |
| 1289 case ID_SETTINGS: |
| 1290 { |
| 1291 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); |
| 1292 if (browser) |
| 1293 { |
| 1294 VARIANT vFlags; |
| 1295 vFlags.vt = VT_I4; |
| 1296 vFlags.intVal = navOpenInNewTab; |
| 1297 |
| 1298 HRESULT hr = browser->Navigate(BString(UserSettingsFileUrl()), &vFlags,
NULL, NULL, NULL); |
| 1299 if (FAILED(hr)) |
| 1300 { |
| 1301 vFlags.intVal = navOpenInNewWindow; |
| 1302 |
| 1303 hr = browser->Navigate(BString(UserSettingsFileUrl()), &vFlags, NULL,
NULL, NULL); |
| 1304 if (FAILED(hr)) |
| 1305 { |
| 1306 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION
_SETTINGS, "Navigation::Failed") |
| 1307 } |
| 1308 } |
| 1309 } |
| 1310 break; |
| 1311 } |
| 1312 case ID_WHITELISTDOMAIN: |
| 1313 { |
| 1314 CPluginSettings* settings = CPluginSettings::GetInstance(); |
| 1315 CString urlString = GetTab()->GetDocumentUrl(); |
| 1316 if (client->IsWhitelistedUrl(std::wstring(urlString))) |
| 1317 { |
| 1318 settings->RemoveWhiteListedDomain(ExtractDomain(urlString)); |
| 1319 |
| 1320 } |
| 1321 else |
| 1322 { |
| 1323 settings->AddWhiteListedDomain(ExtractDomain(urlString)); |
| 1324 } |
| 1325 GetBrowser()->Refresh(); |
| 1326 } |
1289 default: | 1327 default: |
1290 break; | 1328 break; |
1291 } | 1329 } |
1292 | 1330 |
1293 // Invalidate and redraw the control | 1331 // Invalidate and redraw the control |
1294 UpdateStatusBar(); | 1332 UpdateStatusBar(); |
1295 | |
1296 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | |
1297 if (!url.IsEmpty() && browser) | |
1298 { | |
1299 VARIANT vFlags; | |
1300 vFlags.vt = VT_I4; | |
1301 vFlags.intVal = navOpenInNewTab; | |
1302 | |
1303 HRESULT hr = browser->Navigate(CComBSTR(url), &vFlags, NULL, NULL, NULL); | |
1304 if (FAILED(hr)) | |
1305 { | |
1306 vFlags.intVal = navOpenInNewWindow; | |
1307 | |
1308 hr = browser->Navigate(CComBSTR(url), &vFlags, NULL, NULL, NULL); | |
1309 if (FAILED(hr)) | |
1310 { | |
1311 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, navigationErrorId, "Navigat
ion::Failed") | |
1312 } | |
1313 } | |
1314 } | |
1315 } | 1333 } |
1316 | 1334 |
1317 | 1335 |
1318 bool CPluginClass::SetMenuBar(HMENU hMenu, const CString& url) | 1336 bool CPluginClass::SetMenuBar(HMENU hMenu, const CString& url) |
1319 { | 1337 { |
1320 std::wstring ctext; | 1338 std::wstring ctext; |
1321 | 1339 |
1322 s_criticalSectionLocal.Lock(); | 1340 s_criticalSectionLocal.Lock(); |
1323 { | 1341 { |
1324 #ifdef SUPPORT_WHITELIST | 1342 #ifdef SUPPORT_WHITELIST |
(...skipping 20 matching lines...) Expand all Loading... |
1345 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE; | 1363 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE; |
1346 miiSep.fType = MFT_SEPARATOR; | 1364 miiSep.fType = MFT_SEPARATOR; |
1347 | 1365 |
1348 CPluginClient* client = CPluginClient::GetInstance(); | 1366 CPluginClient* client = CPluginClient::GetInstance(); |
1349 | 1367 |
1350 CPluginSettings* settings = CPluginSettings::GetInstance(); | 1368 CPluginSettings* settings = CPluginSettings::GetInstance(); |
1351 | 1369 |
1352 #ifdef SUPPORT_WHITELIST | 1370 #ifdef SUPPORT_WHITELIST |
1353 { | 1371 { |
1354 // White list domain | 1372 // White list domain |
1355 ctext = dictionary->Lookup("menu", "disable-on-site"); | 1373 if (client->IsWhitelistedUrl(std::wstring(GetTab()->GetDocumentUrl()))) |
| 1374 { |
| 1375 ctext = dictionary->Lookup("menu", "enable-on-site"); |
| 1376 } |
| 1377 else |
| 1378 { |
| 1379 ctext = dictionary->Lookup("menu", "disable-on-site"); |
| 1380 } |
1356 fmii.fMask = MIIM_STRING | MIIM_STATE; | 1381 fmii.fMask = MIIM_STRING | MIIM_STATE; |
1357 fmii.fState = MFS_DISABLED; | 1382 fmii.fState = MFS_ENABLED; |
1358 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); | 1383 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); |
1359 fmii.cch = ctext.size(); | 1384 fmii.cch = ctext.size(); |
1360 | 1385 |
1361 UINT index = WM_WHITELIST_DOMAIN; | |
1362 | |
1363 ::SetMenuItemInfoW(hMenu, ID_WHITELISTDOMAIN, FALSE, &fmii); | 1386 ::SetMenuItemInfoW(hMenu, ID_WHITELISTDOMAIN, FALSE, &fmii); |
1364 } | 1387 } |
1365 #else | 1388 #else |
1366 { | 1389 { |
1367 ::DeleteMenu(hMenu, ID_WHITELISTDOMAIN, FALSE); | 1390 ::DeleteMenu(hMenu, ID_WHITELISTDOMAIN, FALSE); |
1368 } | 1391 } |
1369 #endif // SUPPORT_WHITELIST | 1392 #endif // SUPPORT_WHITELIST |
1370 | 1393 |
1371 // Plugin enable | 1394 // Plugin enable |
1372 if (settings->GetPluginEnabled()) | 1395 if (settings->GetPluginEnabled()) |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1574 { | 1597 { |
1575 } | 1598 } |
1576 #ifdef SUPPORT_WHITELIST | 1599 #ifdef SUPPORT_WHITELIST |
1577 else if (client->IsWhitelistedUrl(std::wstring(url))) | 1600 else if (client->IsWhitelistedUrl(std::wstring(url))) |
1578 { | 1601 { |
1579 hIcon = GetIcon(ICON_PLUGIN_DISABLED); | 1602 hIcon = GetIcon(ICON_PLUGIN_DISABLED); |
1580 } | 1603 } |
1581 #endif // SUPPORT_WHITELIST | 1604 #endif // SUPPORT_WHITELIST |
1582 else | 1605 else |
1583 { | 1606 { |
1584 //Deativate adblock icon if adblock limit reached | |
1585 CPluginSettings* settings = CPluginSettings::GetInstance(); | 1607 CPluginSettings* settings = CPluginSettings::GetInstance(); |
1586 if (!settings->GetPluginEnabled()) { | |
1587 hIcon = GetIcon(ICON_PLUGIN_DEACTIVATED); | |
1588 return hIcon; | |
1589 } | |
1590 hIcon = GetIcon(ICON_PLUGIN_ENABLED); | 1608 hIcon = GetIcon(ICON_PLUGIN_ENABLED); |
1591 } | 1609 } |
1592 | 1610 |
1593 #endif // PRODUCT_ADBLOCKPLUS | 1611 #endif // PRODUCT_ADBLOCKPLUS |
1594 } | 1612 } |
1595 | 1613 |
1596 return hIcon; | 1614 return hIcon; |
1597 } | 1615 } |
1598 | 1616 |
1599 | 1617 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1701 | 1719 |
1702 case WM_LBUTTONUP: | 1720 case WM_LBUTTONUP: |
1703 case WM_RBUTTONUP: | 1721 case WM_RBUTTONUP: |
1704 { | 1722 { |
1705 CString strURL = pClass->GetBrowserUrl(); | 1723 CString strURL = pClass->GetBrowserUrl(); |
1706 if (strURL != pClass->GetTab()->GetDocumentUrl()) | 1724 if (strURL != pClass->GetTab()->GetDocumentUrl()) |
1707 { | 1725 { |
1708 pClass->GetTab()->SetDocumentUrl(strURL); | 1726 pClass->GetTab()->SetDocumentUrl(strURL); |
1709 } | 1727 } |
1710 | 1728 |
1711 #ifdef SUPPORT_SHOW_PLUGIN_MENU | |
1712 // Create menu | 1729 // Create menu |
1713 HMENU hMenu = pClass->CreatePluginMenu(strURL); | 1730 HMENU hMenu = pClass->CreatePluginMenu(strURL); |
1714 if (!hMenu) | 1731 if (!hMenu) |
1715 { | 1732 { |
1716 return 0; | 1733 return 0; |
1717 } | 1734 } |
1718 | 1735 |
1719 // Display menu | 1736 // Display menu |
1720 POINT pt; | 1737 POINT pt; |
1721 ::GetCursorPos(&pt); | 1738 ::GetCursorPos(&pt); |
1722 | 1739 |
1723 RECT rc; | 1740 RECT rc; |
1724 ::GetWindowRect(hWnd, &rc); | 1741 ::GetWindowRect(hWnd, &rc); |
1725 | 1742 |
1726 if (rc.left >= 0 && rc.top >= 0) | 1743 if (rc.left >= 0 && rc.top >= 0) |
1727 { | 1744 { |
1728 pt.x = rc.left; | 1745 pt.x = rc.left; |
1729 pt.y = rc.top; | 1746 pt.y = rc.top; |
1730 } | 1747 } |
1731 | 1748 |
1732 pClass->DisplayPluginMenu(hMenu, -1, pt, TPM_LEFTALIGN|TPM_BOTTOMALIGN); | 1749 pClass->DisplayPluginMenu(hMenu, -1, pt, TPM_LEFTALIGN|TPM_BOTTOMALIGN); |
1733 #else | |
1734 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); | |
1735 if (browser) | |
1736 { | |
1737 VARIANT vFlags; | |
1738 vFlags.vt = VT_I4; | |
1739 vFlags.intVal = navOpenInNewTab; | |
1740 | |
1741 HRESULT hr = browser->Navigate(BString(UserSettingsFileUrl()), &vFlags,
NULL, NULL, NULL); | |
1742 if (FAILED(hr)) | |
1743 { | |
1744 vFlags.intVal = navOpenInNewWindow; | |
1745 | |
1746 hr = browser->Navigate(BString(UserSettingsFileUrl()), &vFlags, NULL,
NULL, NULL); | |
1747 if (FAILED(hr)) | |
1748 { | |
1749 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION
_SETTINGS, "Navigation::Failed") | |
1750 } | |
1751 } | |
1752 } | |
1753 #endif | |
1754 } | 1750 } |
1755 break; | 1751 break; |
1756 case WM_DESTROY: | 1752 case WM_DESTROY: |
1757 break; | 1753 break; |
1758 case SC_CLOSE: | 1754 case SC_CLOSE: |
1759 break; | 1755 break; |
1760 | 1756 |
1761 case WM_UPDATEUISTATE: | 1757 case WM_UPDATEUISTATE: |
1762 { | 1758 { |
1763 CPluginTab* tab = GetTab(::GetCurrentThreadId()); | 1759 CPluginTab* tab = GetTab(::GetCurrentThreadId()); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 } | 1899 } |
1904 } | 1900 } |
1905 } | 1901 } |
1906 | 1902 |
1907 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | 1903 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); |
1908 } | 1904 } |
1909 | 1905 |
1910 return hTabWnd; | 1906 return hTabWnd; |
1911 | 1907 |
1912 } | 1908 } |
OLD | NEW |