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 #include "PluginFilter.h" | 6 #include "PluginFilter.h" |
7 #include "PluginMimeFilterClient.h" | 7 #include "PluginMimeFilterClient.h" |
8 #include "PluginClient.h" | 8 #include "PluginClient.h" |
9 #include "PluginClientFactory.h" | 9 #include "PluginClientFactory.h" |
10 #include "PluginMutex.h" | 10 #include "PluginMutex.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 195 |
196 s_criticalSectionLocal.Lock(); | 196 s_criticalSectionLocal.Lock(); |
197 { | 197 { |
198 browser = s_asyncWebBrowser2; | 198 browser = s_asyncWebBrowser2; |
199 } | 199 } |
200 s_criticalSectionLocal.Unlock(); | 200 s_criticalSectionLocal.Unlock(); |
201 | 201 |
202 return browser; | 202 return browser; |
203 } | 203 } |
204 | 204 |
205 CString CPluginClass::GetBrowserUrl() const | 205 std::wstring CPluginClass::GetBrowserUrl() const |
206 { | 206 { |
207 CString url; | 207 std::wstring url; |
208 | |
209 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | 208 CComQIPtr<IWebBrowser2> browser = GetBrowser(); |
210 if (browser) | 209 if (browser) |
211 { | 210 { |
212 CComBSTR bstrURL; | 211 CComBSTR bstrURL; |
213 | 212 if (SUCCEEDED(browser->get_LocationURL(&bstrURL)) && bstrURL) |
214 if (SUCCEEDED(browser->get_LocationURL(&bstrURL))) | |
215 { | 213 { |
216 url = bstrURL; | 214 url = std::wstring(bstrURL, SysStringLen(bstrURL)); |
217 CPluginClient::UnescapeUrl(url); | 215 UnescapeUrl(url); |
218 } | 216 } |
219 } | 217 } |
220 else | 218 else |
221 { | 219 { |
222 url = m_tab->GetDocumentUrl(); | 220 url = m_tab->GetDocumentUrl(); |
223 } | 221 } |
224 | |
225 return url; | 222 return url; |
226 } | 223 } |
227 | 224 |
228 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) | 225 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) |
229 { | 226 { |
230 if (thisPtr == NULL) | 227 if (thisPtr == NULL) |
231 return 0; | 228 return 0; |
232 if (!((CPluginClass*)thisPtr)->InitObject(true)) | 229 if (!((CPluginClass*)thisPtr)->InitObject(true)) |
233 { | 230 { |
234 ((CPluginClass*)thisPtr)->Unadvice(); | 231 ((CPluginClass*)thisPtr)->Unadvice(); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 { | 545 { |
549 WebBrowser2Ptr = pDispParams->rgvarg[6].pdispVal; | 546 WebBrowser2Ptr = pDispParams->rgvarg[6].pdispVal; |
550 } | 547 } |
551 else | 548 else |
552 { | 549 { |
553 // Wrong type, return. | 550 // Wrong type, return. |
554 return; | 551 return; |
555 } | 552 } |
556 | 553 |
557 // Get the URL | 554 // Get the URL |
558 CString url; | 555 std::wstring url; |
559 vt = pDispParams->rgvarg[5].vt; | 556 const auto& arg = pDispParams->rgvarg[5]; |
560 if (vt == VT_BYREF + VT_VARIANT) | 557 vt = arg.vt; |
| 558 if (vt == (VT_BYREF | VT_VARIANT) && arg.pvarVal->vt == VT_BSTR) |
561 { | 559 { |
562 url = pDispParams->rgvarg[5].pvarVal->bstrVal; | 560 BSTR b = arg.pvarVal->bstrVal; |
563 | 561 if (b) { |
564 CPluginClient::UnescapeUrl(url); | 562 url = std::wstring(b, SysStringLen(b)); |
| 563 UnescapeUrl(url); |
| 564 } |
565 } | 565 } |
566 else | 566 else |
567 { | 567 { |
568 // Wrong type, return. | 568 // Wrong type, return. |
569 return; | 569 return; |
570 } | 570 } |
571 | 571 |
572 // If webbrowser2 is equal to top level browser (as set in SetSite), we are na
vigating new page | 572 // If webbrowser2 is equal to top level browser (as set in SetSite), we are na
vigating new page |
573 CPluginClient* client = CPluginClient::GetInstance(); | 573 CPluginClient* client = CPluginClient::GetInstance(); |
574 | 574 CString urlLegacy = ToCString(url); |
575 if (url.Find(L"javascript") == 0) | 575 if (urlLegacy.Find(L"javascript") == 0) |
576 { | 576 { |
577 } | 577 } |
578 else if (GetBrowser().IsEqualObject(WebBrowser2Ptr)) | 578 else if (GetBrowser().IsEqualObject(WebBrowser2Ptr)) |
579 { | 579 { |
580 m_tab->OnNavigate(url); | 580 m_tab->OnNavigate(url); |
581 | 581 |
582 DEBUG_GENERAL(L"============================================================
====================\nBegin main navigation url:" + url + "\n===================
=============================================================") | 582 DEBUG_GENERAL(L"============================================================
====================\nBegin main navigation url:" + urlLegacy + "\n=============
===================================================================") |
583 | 583 |
584 #ifdef ENABLE_DEBUG_RESULT | 584 #ifdef ENABLE_DEBUG_RESULT |
585 CPluginDebug::DebugResultDomain(url); | 585 CPluginDebug::DebugResultDomain(urlLegacy); |
586 #endif | 586 #endif |
587 | 587 |
588 UpdateStatusBar(); | 588 UpdateStatusBar(); |
589 } | 589 } |
590 else | 590 else |
591 { | 591 { |
592 DEBUG_NAVI(L"Navi::Begin navigation url:" + url) | 592 DEBUG_NAVI(L"Navi::Begin navigation url:" + urlLegacy) |
593 m_tab->CacheFrame(url); | 593 m_tab->CacheFrame(url); |
594 } | 594 } |
595 } | 595 } |
596 | 596 |
597 /* | 597 /* |
598 * #1163 implements behavior for method DISPID_WINDOWSTATECHANGED in CPluginClas
s::Invoke | 598 * #1163 implements behavior for method DISPID_WINDOWSTATECHANGED in CPluginClas
s::Invoke |
599 * - should validate and convert arguments in Invoke, not here | 599 * - should validate and convert arguments in Invoke, not here |
600 * - does not validate number of arguments before indexing into 'rgvarg' | 600 * - does not validate number of arguments before indexing into 'rgvarg' |
601 * - does not validate type of argument before using its value | 601 * - does not validate type of argument before using its value |
602 */ | 602 */ |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 | 724 |
725 case DISPID_DOCUMENTCOMPLETE: | 725 case DISPID_DOCUMENTCOMPLETE: |
726 { | 726 { |
727 DEBUG_NAVI("Navi::Document Complete"); | 727 DEBUG_NAVI("Navi::Document Complete"); |
728 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | 728 CComQIPtr<IWebBrowser2> browser = GetBrowser(); |
729 if (browser && pDispParams->cArgs >= 2 && pDispParams->rgvarg[1].vt == V
T_DISPATCH) | 729 if (browser && pDispParams->cArgs >= 2 && pDispParams->rgvarg[1].vt == V
T_DISPATCH) |
730 { | 730 { |
731 CComQIPtr<IWebBrowser2> pBrowser = pDispParams->rgvarg[1].pdispVal; | 731 CComQIPtr<IWebBrowser2> pBrowser = pDispParams->rgvarg[1].pdispVal; |
732 if (pBrowser) | 732 if (pBrowser) |
733 { | 733 { |
734 CString url; | |
735 CComBSTR bstrUrl; | 734 CComBSTR bstrUrl; |
736 if (SUCCEEDED(pBrowser->get_LocationURL(&bstrUrl)) && ::SysStringLen
(bstrUrl) > 0) | 735 if (SUCCEEDED(pBrowser->get_LocationURL(&bstrUrl)) && bstrUrl && ::S
ysStringLen(bstrUrl) > 0) |
737 { | 736 { |
738 url = bstrUrl; | 737 std::wstring url = std::wstring(bstrUrl, SysStringLen(bstrUrl)); |
739 CPluginClient::UnescapeUrl(url); | 738 UnescapeUrl(url); |
740 m_tab->OnDocumentComplete(browser, url, browser.IsEqualObject(pBro
wser)); | 739 m_tab->OnDocumentComplete(browser, url, browser.IsEqualObject(pBro
wser)); |
741 } | 740 } |
742 } | 741 } |
743 } | 742 } |
744 } | 743 } |
745 break; | 744 break; |
746 | 745 |
747 case DISPID_ONQUIT: | 746 case DISPID_ONQUIT: |
748 case DISPID_QUIT: | 747 case DISPID_QUIT: |
749 { | 748 { |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 STDMETHODIMP CPluginClass::QueryStatus(const GUID* pguidCmdGroup, ULONG cCmds, O
LECMD prgCmds[], OLECMDTEXT* pCmdText) | 1152 STDMETHODIMP CPluginClass::QueryStatus(const GUID* pguidCmdGroup, ULONG cCmds, O
LECMD prgCmds[], OLECMDTEXT* pCmdText) |
1154 { | 1153 { |
1155 if (cCmds == 0) return E_INVALIDARG; | 1154 if (cCmds == 0) return E_INVALIDARG; |
1156 if (prgCmds == 0) return E_POINTER; | 1155 if (prgCmds == 0) return E_POINTER; |
1157 | 1156 |
1158 prgCmds[0].cmdf = OLECMDF_ENABLED; | 1157 prgCmds[0].cmdf = OLECMDF_ENABLED; |
1159 | 1158 |
1160 return S_OK; | 1159 return S_OK; |
1161 } | 1160 } |
1162 | 1161 |
1163 HMENU CPluginClass::CreatePluginMenu(const CString& url) | 1162 HMENU CPluginClass::CreatePluginMenu(const std::wstring& url) |
1164 { | 1163 { |
1165 DEBUG_GENERAL("CreatePluginMenu"); | 1164 DEBUG_GENERAL("CreatePluginMenu"); |
1166 HINSTANCE hInstance = _AtlBaseModule.GetModuleInstance(); | 1165 HINSTANCE hInstance = _AtlBaseModule.GetModuleInstance(); |
1167 | 1166 |
1168 HMENU hMenu = ::LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1)); | 1167 HMENU hMenu = ::LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1)); |
1169 | 1168 |
1170 HMENU hMenuTrackPopup = GetSubMenu(hMenu, 0); | 1169 HMENU hMenuTrackPopup = GetSubMenu(hMenu, 0); |
1171 | 1170 |
1172 SetMenuBar(hMenuTrackPopup, url); | 1171 SetMenuBar(hMenuTrackPopup, url); |
1173 | 1172 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1260 { | 1259 { |
1261 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION
_SETTINGS, "Navigation::Failed") | 1260 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION
_SETTINGS, "Navigation::Failed") |
1262 } | 1261 } |
1263 } | 1262 } |
1264 } | 1263 } |
1265 break; | 1264 break; |
1266 } | 1265 } |
1267 case ID_MENU_DISABLE_ON_SITE: | 1266 case ID_MENU_DISABLE_ON_SITE: |
1268 { | 1267 { |
1269 CPluginSettings* settings = CPluginSettings::GetInstance(); | 1268 CPluginSettings* settings = CPluginSettings::GetInstance(); |
1270 CString urlString = GetTab()->GetDocumentUrl(); | 1269 std::wstring urlString = GetTab()->GetDocumentUrl(); |
1271 if (client->IsWhitelistedUrl(to_wstring(urlString))) | 1270 if (client->IsWhitelistedUrl(urlString)) |
1272 { | 1271 { |
1273 settings->RemoveWhiteListedDomain(to_CString(client->GetHostFromUrl(to_w
string(urlString)))); | 1272 settings->RemoveWhiteListedDomain(to_CString(client->GetHostFromUrl(urlS
tring))); |
1274 } | 1273 } |
1275 else | 1274 else |
1276 { | 1275 { |
1277 settings->AddWhiteListedDomain(to_CString(client->GetHostFromUrl(to_wstr
ing(urlString)))); | 1276 settings->AddWhiteListedDomain(to_CString(client->GetHostFromUrl(urlStri
ng))); |
1278 } | 1277 } |
1279 GetBrowser()->Refresh(); | 1278 GetBrowser()->Refresh(); |
1280 } | 1279 } |
1281 default: | 1280 default: |
1282 break; | 1281 break; |
1283 } | 1282 } |
1284 | 1283 |
1285 // Invalidate and redraw the control | 1284 // Invalidate and redraw the control |
1286 UpdateStatusBar(); | 1285 UpdateStatusBar(); |
1287 } | 1286 } |
1288 | 1287 |
1289 | 1288 |
1290 bool CPluginClass::SetMenuBar(HMENU hMenu, const CString& url) | 1289 bool CPluginClass::SetMenuBar(HMENU hMenu, const std::wstring& url) |
1291 { | 1290 { |
1292 DEBUG_GENERAL("SetMenuBar"); | 1291 DEBUG_GENERAL("SetMenuBar"); |
1293 | 1292 |
1294 std::wstring ctext; | 1293 std::wstring ctext; |
1295 Dictionary* dictionary = Dictionary::GetInstance(); | 1294 Dictionary* dictionary = Dictionary::GetInstance(); |
1296 | 1295 |
1297 MENUITEMINFOW fmii = {}; | 1296 MENUITEMINFOW fmii = {}; |
1298 fmii.cbSize = sizeof(fmii); | 1297 fmii.cbSize = sizeof(fmii); |
1299 | 1298 |
1300 MENUITEMINFOW miiSep = {}; | 1299 MENUITEMINFOW miiSep = {}; |
1301 miiSep.cbSize = sizeof(miiSep); | 1300 miiSep.cbSize = sizeof(miiSep); |
1302 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE; | 1301 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE; |
1303 miiSep.fType = MFT_SEPARATOR; | 1302 miiSep.fType = MFT_SEPARATOR; |
1304 | 1303 |
1305 CPluginClient* client = CPluginClient::GetInstance(); | 1304 CPluginClient* client = CPluginClient::GetInstance(); |
1306 CPluginSettings* settings = CPluginSettings::GetInstance(); | 1305 CPluginSettings* settings = CPluginSettings::GetInstance(); |
1307 { | 1306 { |
1308 ctext = dictionary->Lookup("menu", "menu-disable-on-site"); | 1307 ctext = dictionary->Lookup("menu", "menu-disable-on-site"); |
1309 // Is domain in white list? | 1308 // Is domain in white list? |
1310 ReplaceString(ctext, L"?1?", client->GetHostFromUrl(to_wstring(url))); | 1309 ReplaceString(ctext, L"?1?", client->GetHostFromUrl(url)); |
1311 if (client->IsWhitelistedUrl(to_wstring(GetTab()->GetDocumentUrl()))) | 1310 if (client->IsWhitelistedUrl(GetTab()->GetDocumentUrl())) |
1312 { | 1311 { |
1313 fmii.fState = MFS_CHECKED | MFS_ENABLED; | 1312 fmii.fState = MFS_CHECKED | MFS_ENABLED; |
1314 } | 1313 } |
1315 else | 1314 else |
1316 { | 1315 { |
1317 fmii.fState = MFS_UNCHECKED | MFS_ENABLED; | 1316 fmii.fState = MFS_UNCHECKED | MFS_ENABLED; |
1318 } | 1317 } |
1319 fmii.fMask = MIIM_STRING | MIIM_STATE; | 1318 fmii.fMask = MIIM_STRING | MIIM_STATE; |
1320 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); | 1319 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); |
1321 fmii.cch = static_cast<UINT>(ctext.size()); | 1320 fmii.cch = static_cast<UINT>(ctext.size()); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1515 } | 1514 } |
1516 | 1515 |
1517 LRESULT result = CallWindowProc(pClass->m_pWndProcStatus, hWnd, message, wPara
m, lParam); | 1516 LRESULT result = CallWindowProc(pClass->m_pWndProcStatus, hWnd, message, wPara
m, lParam); |
1518 | 1517 |
1519 | 1518 |
1520 return result; | 1519 return result; |
1521 | 1520 |
1522 } | 1521 } |
1523 | 1522 |
1524 | 1523 |
1525 HICON CPluginClass::GetStatusBarIcon(const CString& url) | 1524 HICON CPluginClass::GetStatusBarIcon(const std::wstring& url) |
1526 { | 1525 { |
1527 // use the disable icon as defualt, if the client doesn't exists | 1526 // use the disable icon as defualt, if the client doesn't exists |
1528 HICON hIcon = GetIcon(ICON_PLUGIN_DEACTIVATED); | 1527 HICON hIcon = GetIcon(ICON_PLUGIN_DEACTIVATED); |
1529 | 1528 |
1530 CPluginTab* tab = GetTab(::GetCurrentThreadId()); | 1529 CPluginTab* tab = GetTab(::GetCurrentThreadId()); |
1531 if (tab) | 1530 if (tab) |
1532 { | 1531 { |
1533 CPluginClient* client = CPluginClient::GetInstance(); | 1532 CPluginClient* client = CPluginClient::GetInstance(); |
1534 if (CPluginSettings::GetInstance()->IsPluginEnabled()) | 1533 if (CPluginSettings::GetInstance()->IsPluginEnabled()) |
1535 { | 1534 { |
1536 if (client->IsWhitelistedUrl(ToWstring(url))) | 1535 if (client->IsWhitelistedUrl(url)) |
1537 { | 1536 { |
1538 hIcon = GetIcon(ICON_PLUGIN_DISABLED); | 1537 hIcon = GetIcon(ICON_PLUGIN_DISABLED); |
1539 } | 1538 } |
1540 else | 1539 else |
1541 { | 1540 { |
1542 CPluginSettings* settings = CPluginSettings::GetInstance(); | 1541 CPluginSettings* settings = CPluginSettings::GetInstance(); |
1543 hIcon = GetIcon(ICON_PLUGIN_ENABLED); | 1542 hIcon = GetIcon(ICON_PLUGIN_ENABLED); |
1544 } | 1543 } |
1545 } | 1544 } |
1546 } | 1545 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1644 | 1643 |
1645 // Done! | 1644 // Done! |
1646 EndPaint(hWnd, &ps); | 1645 EndPaint(hWnd, &ps); |
1647 | 1646 |
1648 return 0; | 1647 return 0; |
1649 } | 1648 } |
1650 | 1649 |
1651 case WM_LBUTTONUP: | 1650 case WM_LBUTTONUP: |
1652 case WM_RBUTTONUP: | 1651 case WM_RBUTTONUP: |
1653 { | 1652 { |
1654 CString strURL = pClass->GetBrowserUrl(); | 1653 std::wstring url = pClass->GetBrowserUrl(); |
1655 if (strURL != pClass->GetTab()->GetDocumentUrl()) | 1654 if (url != pClass->GetTab()->GetDocumentUrl()) |
1656 { | 1655 { |
1657 pClass->GetTab()->SetDocumentUrl(strURL); | 1656 pClass->GetTab()->SetDocumentUrl(url); |
1658 } | 1657 } |
1659 | 1658 |
1660 // Create menu | 1659 // Create menu |
1661 HMENU hMenu = pClass->CreatePluginMenu(strURL); | 1660 HMENU hMenu = pClass->CreatePluginMenu(url); |
1662 if (!hMenu) | 1661 if (!hMenu) |
1663 { | 1662 { |
1664 return 0; | 1663 return 0; |
1665 } | 1664 } |
1666 | 1665 |
1667 // Display menu | 1666 // Display menu |
1668 POINT pt; | 1667 POINT pt; |
1669 ::GetCursorPos(&pt); | 1668 ::GetCursorPos(&pt); |
1670 | 1669 |
1671 RECT rc; | 1670 RECT rc; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1875 } | 1874 } |
1876 } | 1875 } |
1877 } | 1876 } |
1878 | 1877 |
1879 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | 1878 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); |
1880 } | 1879 } |
1881 | 1880 |
1882 return hTabWnd; | 1881 return hTabWnd; |
1883 | 1882 |
1884 } | 1883 } |
OLD | NEW |