| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
| 2 | 2 |
| 3 #include "PluginClass.h" | 3 #include "PluginClass.h" |
| 4 #include "PluginDictionary.h" | |
| 5 #include "PluginSettings.h" | 4 #include "PluginSettings.h" |
| 6 #include "PluginSystem.h" | 5 #include "PluginSystem.h" |
| 7 #ifdef SUPPORT_FILTER | 6 #ifdef SUPPORT_FILTER |
| 8 #include "PluginFilter.h" | 7 #include "PluginFilter.h" |
| 9 #endif | 8 #endif |
| 10 #include "PluginMimeFilterClient.h" | 9 #include "PluginMimeFilterClient.h" |
| 11 #include "PluginClient.h" | 10 #include "PluginClient.h" |
| 12 #include "PluginClientFactory.h" | 11 #include "PluginClientFactory.h" |
| 13 #include "PluginHttpRequest.h" | 12 #include "PluginHttpRequest.h" |
| 14 #include "PluginMutex.h" | 13 #include "PluginMutex.h" |
| 15 #include "DownloadSource.h" | 14 #include "DownloadSource.h" |
| 16 #include "sddl.h" | 15 #include "sddl.h" |
| 17 #include "PluginUtil.h" | 16 #include "PluginUtil.h" |
| 18 #include "PluginUserSettings.h" | 17 #include "PluginUserSettings.h" |
| 19 | 18 |
| 19 #include "../shared/Dictionary.h" | |
| 20 | |
| 20 #ifdef DEBUG_HIDE_EL | 21 #ifdef DEBUG_HIDE_EL |
| 21 DWORD profileTime = 0; | 22 DWORD profileTime = 0; |
| 22 #endif | 23 #endif |
| 23 | 24 |
| 24 typedef HANDLE (WINAPI *OPENTHEMEDATA)(HWND, LPCWSTR); | 25 typedef HANDLE (WINAPI *OPENTHEMEDATA)(HWND, LPCWSTR); |
| 25 typedef HRESULT (WINAPI *DRAWTHEMEBACKGROUND)(HANDLE, HDC, INT, INT, LPRECT, LPR ECT); | 26 typedef HRESULT (WINAPI *DRAWTHEMEBACKGROUND)(HANDLE, HDC, INT, INT, LPRECT, LPR ECT); |
| 26 typedef HRESULT (WINAPI *CLOSETHEMEDATA)(HANDLE); | 27 typedef HRESULT (WINAPI *CLOSETHEMEDATA)(HANDLE); |
| 27 | 28 |
| 28 | 29 |
| 29 HICON CPluginClass::s_hIcons[ICON_MAX] = { NULL, NULL, NULL }; | 30 HICON CPluginClass::s_hIcons[ICON_MAX] = { NULL, NULL, NULL }; |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 549 HRESULT hr = S_OK; | 550 HRESULT hr = S_OK; |
| 550 hr = browser->get_StatusBar(&isVisible); | 551 hr = browser->get_StatusBar(&isVisible); |
| 551 if (SUCCEEDED(hr)) | 552 if (SUCCEEDED(hr)) |
| 552 { | 553 { |
| 553 if (!isVisible) | 554 if (!isVisible) |
| 554 { | 555 { |
| 555 if (!settings->GetBool("statusbarasked", false)) | 556 if (!settings->GetBool("statusbarasked", false)) |
| 556 { | 557 { |
| 557 SHANDLE_PTR pBrowserHWnd; | 558 SHANDLE_PTR pBrowserHWnd; |
| 558 browser->get_HWND((SHANDLE_PTR*)&pBrowserHWnd); | 559 browser->get_HWND((SHANDLE_PTR*)&pBrowserHWnd); |
| 559 CPluginDictionary* dictionary = CPluginDictionary::GetInstance(false); | 560 Dictionary* dictionary = Dictionary::GetInstance(); |
| 560 settings->SetBool("statusbarasked", true); | 561 settings->SetBool("statusbarasked", true); |
| 561 settings->Write(); | 562 settings->Write(); |
| 562 | 563 |
| 563 HKEY pHkey; | 564 HKEY pHkey; |
| 564 HKEY pHkeySub; | 565 HKEY pHkeySub; |
| 565 LSTATUS regRes = 0; | 566 LSTATUS regRes = 0; |
| 566 regRes = RegOpenCurrentUser(KEY_WRITE, &pHkey); | 567 regRes = RegOpenCurrentUser(KEY_WRITE, &pHkey); |
| 567 | 568 |
| 568 // Do we have enough rights to enable a status bar? | 569 // Do we have enough rights to enable a status bar? |
| 569 if (regRes != 0) | 570 if (regRes != 0) |
| 570 { | 571 { |
| 571 // We use the tab window here and in the next few calls, since the b rowser window may still not be available | 572 // We use the tab window here and in the next few calls, since the b rowser window may still not be available |
| 572 LRESULT res = MessageBox((HWND)m_hTabWnd, dictionary->Lookup("ERROR_ CAN_NOT_ENABLE_STATUS_BAR"), | 573 LRESULT res = MessageBox((HWND)m_hTabWnd, |
| 573 dictionary->Lookup("ERROR_CAN_NOT_ENABLE_STATUS_BAR_TITLE"), MB_OK ); | 574 dictionary->Lookup("status-bar", "error-text").c_str(), |
| 575 dictionary->Lookup("status-bar", "error-title").c_str(), | |
| 576 MB_OK); | |
| 574 return; | 577 return; |
| 575 } | 578 } |
| 576 // Ask if a user wants to enable a status bar automatically | 579 // Ask if a user wants to enable a status bar automatically |
| 577 LRESULT res = MessageBox((HWND)m_hTabWnd, dictionary->Lookup("ERROR_ST ATUS_BAR_DISABLED"), | 580 LRESULT res = MessageBox((HWND)m_hTabWnd, |
| 578 dictionary->Lookup("ERROR_STATUS_BAR_DISABLED_TITLE"), MB_YESNO); | 581 dictionary->Lookup("status-bar", "question").c_str(), |
| 582 dictionary->Lookup("status-bar", "title").c_str(), | |
| 583 MB_YESNO); | |
| 579 if (res == IDYES) | 584 if (res == IDYES) |
| 580 { | 585 { |
| 581 DWORD trueth = 1; | 586 DWORD trueth = 1; |
| 582 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\ \MINIE", &pHkeySub); | 587 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\ \MINIE", &pHkeySub); |
| 583 regRes = RegSetValueEx(pHkeySub, L"ShowStatusBar", 0, REG_DWORD, (BY TE*)&trueth, sizeof(DWORD)); | 588 regRes = RegSetValueEx(pHkeySub, L"ShowStatusBar", 0, REG_DWORD, (BY TE*)&trueth, sizeof(DWORD)); |
| 584 regRes = RegCloseKey(pHkeySub); | 589 regRes = RegCloseKey(pHkeySub); |
| 585 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\ \Main", &pHkeySub); | 590 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\ \Main", &pHkeySub); |
| 586 regRes = RegSetValueEx(pHkeySub, L"StatusBarWeb", 0, REG_DWORD, (BYT E*)&trueth, sizeof(DWORD)); | 591 regRes = RegSetValueEx(pHkeySub, L"StatusBarWeb", 0, REG_DWORD, (BYT E*)&trueth, sizeof(DWORD)); |
| 587 regRes = RegCloseKey(pHkeySub); | 592 regRes = RegCloseKey(pHkeySub); |
| 588 hr = browser->put_StatusBar(TRUE); | 593 hr = browser->put_StatusBar(TRUE); |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1462 { | 1467 { |
| 1463 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, navigationErrorId, "Navigat ion::Failed") | 1468 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, navigationErrorId, "Navigat ion::Failed") |
| 1464 } | 1469 } |
| 1465 } | 1470 } |
| 1466 } | 1471 } |
| 1467 } | 1472 } |
| 1468 | 1473 |
| 1469 | 1474 |
| 1470 bool CPluginClass::SetMenuBar(HMENU hMenu, const CString& url) | 1475 bool CPluginClass::SetMenuBar(HMENU hMenu, const CString& url) |
| 1471 { | 1476 { |
| 1472 CString ctext; | 1477 std::wstring ctext; |
| 1473 | 1478 |
| 1474 s_criticalSectionLocal.Lock(); | 1479 s_criticalSectionLocal.Lock(); |
| 1475 { | 1480 { |
| 1476 #ifdef SUPPORT_WHITELIST | 1481 #ifdef SUPPORT_WHITELIST |
| 1477 s_menuDomains.clear(); | 1482 s_menuDomains.clear(); |
| 1478 #endif | 1483 #endif |
| 1479 } | 1484 } |
| 1480 s_criticalSectionLocal.Unlock(); | 1485 s_criticalSectionLocal.Unlock(); |
| 1481 | 1486 |
| 1482 CPluginTab* tab = GetTab(::GetCurrentThreadId()); | 1487 CPluginTab* tab = GetTab(::GetCurrentThreadId()); |
| 1483 if (!tab) | 1488 if (!tab) |
| 1484 { | 1489 { |
| 1485 return false; | 1490 return false; |
| 1486 } | 1491 } |
| 1487 | 1492 |
| 1488 CPluginDictionary* dictionary = CPluginDictionary::GetInstance(); | 1493 Dictionary* dictionary = Dictionary::GetInstance(); |
| 1489 | 1494 |
| 1490 MENUITEMINFO fmii; | 1495 MENUITEMINFOW fmii; |
| 1491 memset(&fmii, 0, sizeof(MENUITEMINFO)); | 1496 memset(&fmii, 0, sizeof(MENUITEMINFO)); |
| 1492 fmii.cbSize = sizeof(MENUITEMINFO); | 1497 fmii.cbSize = sizeof(MENUITEMINFO); |
| 1493 | 1498 |
| 1494 MENUITEMINFO miiSep; | 1499 MENUITEMINFOW miiSep; |
| 1495 memset(&miiSep, 0, sizeof(MENUITEMINFO)); | 1500 memset(&miiSep, 0, sizeof(MENUITEMINFO)); |
| 1496 miiSep.cbSize = sizeof(MENUITEMINFO); | 1501 miiSep.cbSize = sizeof(MENUITEMINFO); |
| 1497 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE; | 1502 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE; |
| 1498 miiSep.fType = MFT_SEPARATOR; | 1503 miiSep.fType = MFT_SEPARATOR; |
| 1499 | 1504 |
| 1500 CPluginClient* client = CPluginClient::GetInstance(); | 1505 CPluginClient* client = CPluginClient::GetInstance(); |
| 1501 | 1506 |
| 1502 CPluginSettings* settings = CPluginSettings::GetInstance(); | 1507 CPluginSettings* settings = CPluginSettings::GetInstance(); |
| 1503 | 1508 |
| 1504 settings->RefreshTab(); | 1509 settings->RefreshTab(); |
| 1505 | 1510 |
| 1506 // Update settings | 1511 // Update settings |
| 1507 m_tab->OnUpdateSettings(false); | 1512 m_tab->OnUpdateSettings(false); |
| 1508 | 1513 |
| 1509 #ifdef SUPPORT_WHITELIST | 1514 #ifdef SUPPORT_WHITELIST |
| 1510 { | 1515 { |
| 1511 // White list domain | 1516 // White list domain |
| 1512 ctext = dictionary->Lookup("MENU_DISABLE_ON"); | 1517 ctext = dictionary->Lookup("menu", "disable-on-site"); |
| 1513 fmii.fMask = MIIM_STRING | MIIM_STATE; | 1518 fmii.fMask = MIIM_STRING | MIIM_STATE; |
| 1514 fmii.fState = MFS_DISABLED; | 1519 fmii.fState = MFS_DISABLED; |
| 1515 fmii.dwTypeData = ctext.GetBuffer(); | 1520 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); |
| 1516 fmii.cch = ctext.GetLength(); | 1521 fmii.cch = ctext.size(); |
| 1517 | 1522 |
| 1518 UINT index = WM_WHITELIST_DOMAIN; | 1523 UINT index = WM_WHITELIST_DOMAIN; |
| 1519 | 1524 |
| 1520 ::SetMenuItemInfo(hMenu, ID_WHITELISTDOMAIN, FALSE, &fmii); | 1525 ::SetMenuItemInfoW(hMenu, ID_WHITELISTDOMAIN, FALSE, &fmii); |
| 1521 } | 1526 } |
| 1522 #else | 1527 #else |
| 1523 { | 1528 { |
| 1524 ::DeleteMenu(hMenu, ID_WHITELISTDOMAIN, FALSE); | 1529 ::DeleteMenu(hMenu, ID_WHITELISTDOMAIN, FALSE); |
| 1525 } | 1530 } |
| 1526 #endif // SUPPORT_WHITELIST | 1531 #endif // SUPPORT_WHITELIST |
| 1527 | 1532 |
|
Oleksandr
2013/06/18 07:41:09
This is a menu that has been shown when a user cli
Wladimir Palant
2013/06/18 08:17:48
It's quite the opposite actually - we should make
| |
| 1528 // Invite friends | 1533 // Invite friends |
| 1529 ctext = dictionary->Lookup("MENU_INVITE_FRIENDS"); | 1534 ctext = dictionary->Lookup("menu", "invite"); |
| 1530 fmii.fMask = MIIM_STATE | MIIM_STRING; | 1535 fmii.fMask = MIIM_STATE | MIIM_STRING; |
| 1531 fmii.fState = MFS_ENABLED; | 1536 fmii.fState = MFS_ENABLED; |
| 1532 fmii.dwTypeData = ctext.GetBuffer(); | 1537 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); |
| 1533 fmii.cch = ctext.GetLength(); | 1538 fmii.cch = ctext.size(); |
| 1534 ::SetMenuItemInfo(hMenu, ID_INVITEFRIENDS, FALSE, &fmii); | 1539 ::SetMenuItemInfoW(hMenu, ID_INVITEFRIENDS, FALSE, &fmii); |
| 1535 | 1540 |
| 1536 // FAQ | 1541 // FAQ |
| 1537 ctext = dictionary->Lookup("MENU_FAQ"); | 1542 ctext = dictionary->Lookup("menu", "faq"); |
| 1538 fmii.fMask = MIIM_STATE | MIIM_STRING; | 1543 fmii.fMask = MIIM_STATE | MIIM_STRING; |
| 1539 fmii.fState = MFS_ENABLED; | 1544 fmii.fState = MFS_ENABLED; |
| 1540 fmii.dwTypeData = ctext.GetBuffer(); | 1545 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); |
| 1541 fmii.cch = ctext.GetLength(); | 1546 fmii.cch = ctext.size(); |
| 1542 ::SetMenuItemInfo(hMenu, ID_FAQ, FALSE, &fmii); | 1547 ::SetMenuItemInfoW(hMenu, ID_FAQ, FALSE, &fmii); |
| 1543 | 1548 |
| 1544 // About | 1549 // About |
| 1545 ctext = dictionary->Lookup("MENU_ABOUT"); | 1550 ctext = dictionary->Lookup("menu", "about"); |
| 1546 fmii.fMask = MIIM_STATE | MIIM_STRING; | 1551 fmii.fMask = MIIM_STATE | MIIM_STRING; |
| 1547 fmii.fState = MFS_ENABLED; | 1552 fmii.fState = MFS_ENABLED; |
| 1548 fmii.dwTypeData = ctext.GetBuffer(); | 1553 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); |
| 1549 fmii.cch = ctext.GetLength(); | 1554 fmii.cch = ctext.size(); |
| 1550 ::SetMenuItemInfo(hMenu, ID_ABOUT, FALSE, &fmii); | 1555 ::SetMenuItemInfoW(hMenu, ID_ABOUT, FALSE, &fmii); |
| 1551 | 1556 |
| 1552 // Feedback | 1557 // Feedback |
| 1553 ctext = dictionary->Lookup("MENU_FEEDBACK"); | 1558 ctext = dictionary->Lookup("menu", "feedback"); |
| 1554 fmii.fMask = MIIM_STATE | MIIM_STRING; | 1559 fmii.fMask = MIIM_STATE | MIIM_STRING; |
| 1555 fmii.fState = MFS_ENABLED; | 1560 fmii.fState = MFS_ENABLED; |
| 1556 fmii.dwTypeData = ctext.GetBuffer(); | 1561 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); |
| 1557 fmii.cch = ctext.GetLength(); | 1562 fmii.cch = ctext.size(); |
| 1558 ::SetMenuItemInfo(hMenu, ID_FEEDBACK, FALSE, &fmii); | 1563 ::SetMenuItemInfoW(hMenu, ID_FEEDBACK, FALSE, &fmii); |
| 1559 | 1564 |
| 1560 // Plugin enable | 1565 // Plugin enable |
| 1561 if (settings->GetPluginEnabled()) | 1566 if (settings->GetPluginEnabled()) |
| 1562 { | 1567 { |
| 1563 ctext = dictionary->Lookup("MENU_DISABLE"); | 1568 ctext = dictionary->Lookup("menu", "disable"); |
| 1564 } | 1569 } |
| 1565 else | 1570 else |
| 1566 { | 1571 { |
| 1567 ctext = dictionary->Lookup("MENU_ENABLE"); | 1572 ctext = dictionary->Lookup("menu", "enable"); |
| 1568 } | 1573 } |
| 1569 fmii.fMask = MIIM_STATE | MIIM_STRING; | 1574 fmii.fMask = MIIM_STATE | MIIM_STRING; |
| 1570 fmii.fState = client ? MFS_ENABLED : MFS_DISABLED; | 1575 fmii.fState = client ? MFS_ENABLED : MFS_DISABLED; |
| 1571 fmii.dwTypeData = ctext.GetBuffer(); | 1576 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); |
| 1572 fmii.cch = ctext.GetLength(); | 1577 fmii.cch = ctext.size(); |
| 1573 ::SetMenuItemInfo(hMenu, ID_PLUGIN_ENABLE, FALSE, &fmii); | 1578 ::SetMenuItemInfoW(hMenu, ID_PLUGIN_ENABLE, FALSE, &fmii); |
| 1574 | 1579 |
| 1575 // Settings | 1580 // Settings |
| 1576 #ifndef ENTERPRISE | 1581 #ifndef ENTERPRISE |
| 1577 ctext = dictionary->Lookup("MENU_SETTINGS"); | 1582 ctext = dictionary->Lookup("menu", "settings"); |
| 1578 fmii.fMask = MIIM_STATE | MIIM_STRING; | 1583 fmii.fMask = MIIM_STATE | MIIM_STRING; |
| 1579 fmii.fState = MFS_ENABLED; | 1584 fmii.fState = MFS_ENABLED; |
| 1580 fmii.dwTypeData = ctext.GetBuffer(); | 1585 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); |
| 1581 fmii.cch = ctext.GetLength(); | 1586 fmii.cch = ctext.size(); |
| 1582 ::SetMenuItemInfo(hMenu, ID_SETTINGS, FALSE, &fmii); | 1587 ::SetMenuItemInfoW(hMenu, ID_SETTINGS, FALSE, &fmii); |
| 1583 #else | 1588 #else |
| 1584 RemoveMenu(hMenu, ID_SETTINGS, MF_BYCOMMAND); | 1589 RemoveMenu(hMenu, ID_SETTINGS, MF_BYCOMMAND); |
| 1585 RemoveMenu(hMenu, 5, MF_BYPOSITION); | 1590 RemoveMenu(hMenu, 5, MF_BYPOSITION); |
| 1586 #endif | 1591 #endif |
| 1587 | 1592 |
| 1588 ctext.ReleaseBuffer(); | |
| 1589 | |
| 1590 return true; | 1593 return true; |
| 1591 } | 1594 } |
| 1592 | 1595 |
| 1593 | 1596 |
| 1594 STDMETHODIMP CPluginClass::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, V ARIANTARG*) | 1597 STDMETHODIMP CPluginClass::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, V ARIANTARG*) |
| 1595 { | 1598 { |
| 1596 HWND hBrowserWnd = GetBrowserHWND(); | 1599 HWND hBrowserWnd = GetBrowserHWND(); |
| 1597 if (!hBrowserWnd) | 1600 if (!hBrowserWnd) |
| 1598 { | 1601 { |
| 1599 return E_FAIL; | 1602 return E_FAIL; |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1964 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); | 1967 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); |
| 1965 if (browser) | 1968 if (browser) |
| 1966 { | 1969 { |
| 1967 HRESULT hr = S_OK; | 1970 HRESULT hr = S_OK; |
| 1968 | 1971 |
| 1969 hr = browser->get_StatusBar(&isVisible); | 1972 hr = browser->get_StatusBar(&isVisible); |
| 1970 if (SUCCEEDED(hr)) | 1973 if (SUCCEEDED(hr)) |
| 1971 { | 1974 { |
| 1972 if (!isVisible) | 1975 if (!isVisible) |
| 1973 { | 1976 { |
| 1974 CPluginDictionary* dictionary = CPluginDictionary::GetInstance(); | 1977 Dictionary* dictionary = Dictionary::GetInstance(); |
| 1975 | 1978 |
| 1976 LRESULT res = MessageBox(NULL, dictionary->Lookup("ERROR_STATUS_BA R_DISABLED"), dictionary->Lookup("ERROR_STATUS_BAR_DISABLED_TITLE"), MB_YESNO); | 1979 LRESULT res = MessageBox(NULL, |
| 1980 dictionary->Lookup("status-bar", "question").c_str(), | |
| 1981 dictionary->Lookup("status-bar", "title").c_str(), | |
| 1982 MB_YESNO); | |
| 1977 if (res == IDYES) | 1983 if (res == IDYES) |
| 1978 { | 1984 { |
| 1979 hr = browser->put_StatusBar(TRUE); | 1985 hr = browser->put_StatusBar(TRUE); |
| 1980 if (FAILED(hr)) | 1986 if (FAILED(hr)) |
| 1981 { | 1987 { |
| 1982 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_PUT_STATU SBAR, "Class::Enable statusbar"); | 1988 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_PUT_STATU SBAR, "Class::Enable statusbar"); |
| 1983 } | 1989 } |
| 1984 } | 1990 } |
| 1985 } | 1991 } |
| 1986 } | 1992 } |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2187 } | 2193 } |
| 2188 } | 2194 } |
| 2189 } | 2195 } |
| 2190 | 2196 |
| 2191 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | 2197 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); |
| 2192 } | 2198 } |
| 2193 | 2199 |
| 2194 return hTabWnd; | 2200 return hTabWnd; |
| 2195 | 2201 |
| 2196 } | 2202 } |
| OLD | NEW |