Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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" |
11 #include "sddl.h" | 11 #include "sddl.h" |
12 #include "PluginUtil.h" | 12 #include "PluginUtil.h" |
13 #include "PluginUserSettings.h" | 13 #include "PluginUserSettings.h" |
14 #include "../shared/Utils.h" | 14 #include "../shared/Utils.h" |
15 #include "../shared/Dictionary.h" | 15 #include "../shared/Dictionary.h" |
16 #include <thread> | 16 #include <thread> |
17 #include <array> | |
17 | 18 |
18 #ifdef DEBUG_HIDE_EL | 19 #ifdef DEBUG_HIDE_EL |
19 DWORD profileTime = 0; | 20 DWORD profileTime = 0; |
20 #endif | 21 #endif |
21 | 22 |
22 typedef HANDLE (WINAPI *OPENTHEMEDATA)(HWND, LPCWSTR); | 23 typedef HANDLE (WINAPI *OPENTHEMEDATA)(HWND, LPCWSTR); |
23 typedef HRESULT (WINAPI *DRAWTHEMEBACKGROUND)(HANDLE, HDC, INT, INT, LPRECT, LPR ECT); | 24 typedef HRESULT (WINAPI *DRAWTHEMEBACKGROUND)(HANDLE, HDC, INT, INT, LPRECT, LPR ECT); |
24 typedef HRESULT (WINAPI *CLOSETHEMEDATA)(HANDLE); | 25 typedef HRESULT (WINAPI *CLOSETHEMEDATA)(HANDLE); |
25 | 26 |
26 HICON CPluginClass::s_hIcons[ICON_MAX] = { NULL, NULL, NULL }; | 27 HICON CPluginClass::s_hIcons[ICON_MAX] = { NULL, NULL, NULL }; |
27 DWORD CPluginClass::s_hIconTypes[ICON_MAX] = { IDI_ICON_DISABLED, IDI_ICON_ENABL ED, IDI_ICON_DEACTIVATED }; | 28 DWORD CPluginClass::s_hIconTypes[ICON_MAX] = { IDI_ICON_DISABLED, IDI_ICON_ENABL ED, IDI_ICON_DEACTIVATED }; |
28 | 29 |
29 CPluginMimeFilterClient* CPluginClass::s_mimeFilter = NULL; | 30 CPluginMimeFilterClient* CPluginClass::s_mimeFilter = NULL; |
30 | 31 |
31 CLOSETHEMEDATA pfnClose = NULL; | 32 CLOSETHEMEDATA pfnClose = NULL; |
32 DRAWTHEMEBACKGROUND pfnDrawThemeBackground = NULL; | 33 DRAWTHEMEBACKGROUND pfnDrawThemeBackground = NULL; |
33 OPENTHEMEDATA pfnOpenThemeData = NULL; | 34 OPENTHEMEDATA pfnOpenThemeData = NULL; |
34 | 35 |
35 ATOM CPluginClass::s_atomPaneClass = NULL; | 36 ATOM CPluginClass::s_atomPaneClass = NULL; |
36 HINSTANCE CPluginClass::s_hUxtheme = NULL; | 37 HINSTANCE CPluginClass::s_hUxtheme = NULL; |
37 std::set<CPluginClass*> CPluginClass::s_instances; | 38 std::set<CPluginClass*> CPluginClass::s_instances; |
38 std::map<DWORD, CPluginClass*> CPluginClass::s_threadInstances; | 39 std::map<DWORD, CPluginClass*> CPluginClass::s_threadInstances; |
39 | 40 |
40 CComAutoCriticalSection CPluginClass::s_criticalSectionLocal; | 41 CComAutoCriticalSection CPluginClass::s_criticalSectionLocal; |
41 CComAutoCriticalSection CPluginClass::s_criticalSectionBrowser; | 42 CComAutoCriticalSection CPluginClass::s_criticalSectionBrowser; |
42 CComAutoCriticalSection CPluginClass::s_criticalSectionWindow; | 43 CComAutoCriticalSection CPluginClass::s_criticalSectionWindow; |
43 | 44 |
44 CComQIPtr<IWebBrowser2> CPluginClass::s_asyncWebBrowser2; | 45 CComQIPtr<IWebBrowser2> CPluginClass::s_asyncWebBrowser2; |
45 std::map<UINT,CString> CPluginClass::s_menuDomains; | |
46 | 46 |
47 /* | 47 /* |
48 * Without namespace declaration, the identifier "Rectangle" is ambiguous | 48 * Without namespace declaration, the identifier "Rectangle" is ambiguous |
49 * 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 |
50 */ | 50 */ |
51 namespace AdblockPlus | 51 namespace AdblockPlus |
52 { | 52 { |
53 /** | 53 /** |
54 * Replacement for ATL type CRect. | 54 * Replacement for ATL type CRect. |
55 */ | 55 */ |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 | 201 |
202 return browser; | 202 return browser; |
203 } | 203 } |
204 | 204 |
205 std::wstring CPluginClass::GetBrowserUrl() const | 205 std::wstring CPluginClass::GetBrowserUrl() const |
206 { | 206 { |
207 std::wstring url; | 207 std::wstring url; |
208 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | 208 CComQIPtr<IWebBrowser2> browser = GetBrowser(); |
209 if (browser) | 209 if (browser) |
210 { | 210 { |
211 BSTR bstrURL; | 211 CComBSTR bstrURL; |
sergei
2014/10/17 10:10:12
Why is ATL::CComBSTR replaced by BSTR? Looks like
Eric
2014/10/20 02:36:01
Because we don't need CComBSTR here. The only reas
sergei
2014/10/21 09:45:17
Sorry, I don't understand about which mystery your
Eric
2014/10/21 17:19:52
That's because there is no mystery.
I take it, th
Oleksandr
2015/01/05 11:55:40
Let's move back to this specific code change. As I
Eric
2015/01/05 16:18:26
Done.
| |
212 if (SUCCEEDED(browser->get_LocationURL(&bstrURL)) && bstrURL) | 212 if (SUCCEEDED(browser->get_LocationURL(&bstrURL)) && bstrURL) |
213 { | 213 { |
214 url = std::wstring(bstrURL, SysStringLen(bstrURL)); | 214 url = std::wstring(bstrURL, SysStringLen(bstrURL)); |
215 SysFreeString(bstrURL); | |
216 UnescapeUrl(url); | 215 UnescapeUrl(url); |
217 } | 216 } |
218 } | 217 } |
219 else | 218 else |
220 { | 219 { |
221 url = m_tab->GetDocumentUrl(); | 220 url = m_tab->GetDocumentUrl(); |
222 } | 221 } |
223 return url; | 222 return url; |
224 } | 223 } |
225 | 224 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 { | 379 { |
381 s_instances.erase(this); | 380 s_instances.erase(this); |
382 | 381 |
383 std::map<DWORD,CPluginClass*>::iterator it = s_threadInstances.find(::GetC urrentThreadId()); | 382 std::map<DWORD,CPluginClass*>::iterator it = s_threadInstances.find(::GetC urrentThreadId()); |
384 if (it != s_threadInstances.end()) | 383 if (it != s_threadInstances.end()) |
385 { | 384 { |
386 s_threadInstances.erase(it); | 385 s_threadInstances.erase(it); |
387 } | 386 } |
388 if (s_instances.empty()) | 387 if (s_instances.empty()) |
389 { | 388 { |
389 // TODO: Explicitly releasing a resource when a container becomes empty looks like a job better suited for shared_ptr | |
390 CPluginClientFactory::ReleaseMimeFilterClientInstance(); | 390 CPluginClientFactory::ReleaseMimeFilterClientInstance(); |
391 } | 391 } |
392 } | 392 } |
393 s_criticalSectionLocal.Unlock(); | 393 s_criticalSectionLocal.Unlock(); |
394 | 394 |
395 // Release browser interface | 395 // Release browser interface |
396 s_criticalSectionBrowser.Lock(); | 396 s_criticalSectionBrowser.Lock(); |
397 { | 397 { |
398 m_webBrowser2.Release(); | 398 m_webBrowser2.Release(); |
399 } | 399 } |
400 s_criticalSectionBrowser.Unlock(); | 400 s_criticalSectionBrowser.Unlock(); |
401 | 401 |
402 DEBUG_GENERAL("============================================================= ===================\nNEW TAB UI - END\n========================================= =======================================") | 402 DEBUG_GENERAL("============================================================= ===================\nNEW TAB UI - END\n========================================= =======================================") |
403 | 403 |
404 ::CoUninitialize(); | 404 ::CoUninitialize(); |
405 } | 405 } |
406 | 406 |
407 return IObjectWithSiteImpl<CPluginClass>::SetSite(unknownSite); | 407 return IObjectWithSiteImpl<CPluginClass>::SetSite(unknownSite); |
408 } | 408 } |
409 | 409 |
410 bool CPluginClass::IsStatusBarEnabled() | 410 bool CPluginClass::IsStatusBarEnabled() |
411 { | 411 { |
412 DEBUG_GENERAL("IsStatusBarEnabled start"); | 412 DEBUG_GENERAL("IsStatusBarEnabled start"); |
413 HKEY pHkey; | 413 HKEY pHkey; |
414 HKEY pHkeySub; | 414 HKEY pHkeySub; |
415 RegOpenCurrentUser(KEY_QUERY_VALUE, &pHkey); | 415 RegOpenCurrentUser(KEY_QUERY_VALUE, &pHkey); |
416 DWORD trueth = 1; | 416 DWORD truth = 1; |
417 DWORD truethSize = sizeof(DWORD); | 417 DWORD truthSize = sizeof(truth); |
418 RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\Main", &pHkeySub); | 418 RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\Main", &pHkeySub); |
419 LONG res = RegQueryValueEx(pHkeySub, L"StatusBarWeb", NULL, NULL, (BYTE*)&true th, &truethSize); | 419 LONG res = RegQueryValueEx(pHkeySub, L"StatusBarWeb", NULL, NULL, (BYTE*)&trut h, &truthSize); |
420 RegCloseKey(pHkey); | 420 RegCloseKey(pHkey); |
421 if (res != ERROR_SUCCESS) | 421 if (res != ERROR_SUCCESS) |
422 { | 422 { |
423 res = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\MINIE", &p HkeySub); | 423 res = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\MINIE", &p HkeySub); |
424 if (res == ERROR_SUCCESS) | 424 if (res == ERROR_SUCCESS) |
425 { | 425 { |
426 LONG res = RegQueryValueEx(pHkeySub, L"ShowStatusBar", NULL, NULL, (BYTE*) &trueth, &truethSize); | 426 LONG res = RegQueryValueEx(pHkeySub, L"ShowStatusBar", NULL, NULL, (BYTE*) &truth, &truthSize); |
427 if (res == ERROR_SUCCESS) | 427 if (res == ERROR_SUCCESS) |
428 { | 428 { |
429 RegCloseKey(pHkey); | 429 RegCloseKey(pHkey); |
430 } | 430 } |
431 } | 431 } |
432 } | 432 } |
433 DEBUG_GENERAL("IsStatusBarEnabled end"); | 433 DEBUG_GENERAL("IsStatusBarEnabled end"); |
434 return trueth == 1; | 434 return truth == 1; |
435 } | 435 } |
436 | 436 |
437 void CPluginClass::ShowStatusBar() | 437 void CPluginClass::ShowStatusBar() |
438 { | 438 { |
439 DEBUG_GENERAL("ShowStatusBar start"); | 439 DEBUG_GENERAL("ShowStatusBar start"); |
440 | 440 |
441 VARIANT_BOOL isVisible; | 441 VARIANT_BOOL isVisible; |
442 | 442 |
443 | 443 |
444 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); | 444 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); |
(...skipping 24 matching lines...) Expand all Loading... | |
469 MB_OK); | 469 MB_OK); |
470 return; | 470 return; |
471 } | 471 } |
472 // Ask if a user wants to enable a status bar automatically | 472 // Ask if a user wants to enable a status bar automatically |
473 LRESULT res = MessageBox((HWND)m_hTabWnd, | 473 LRESULT res = MessageBox((HWND)m_hTabWnd, |
474 dictionary->Lookup("status-bar", "question").c_str(), | 474 dictionary->Lookup("status-bar", "question").c_str(), |
475 dictionary->Lookup("status-bar", "title").c_str(), | 475 dictionary->Lookup("status-bar", "title").c_str(), |
476 MB_YESNO); | 476 MB_YESNO); |
477 if (res == IDYES) | 477 if (res == IDYES) |
478 { | 478 { |
479 DWORD trueth = 1; | 479 DWORD truth = 1; |
480 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\M INIE", &pHkeySub); | 480 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\M INIE", &pHkeySub); |
481 regRes = RegSetValueEx(pHkeySub, L"ShowStatusBar", 0, REG_DWORD, (BYTE *)&trueth, sizeof(DWORD)); | 481 regRes = RegSetValueEx(pHkeySub, L"ShowStatusBar", 0, REG_DWORD, (BYTE *)&truth, sizeof(truth)); |
482 regRes = RegCloseKey(pHkeySub); | 482 regRes = RegCloseKey(pHkeySub); |
483 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\M ain", &pHkeySub); | 483 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\M ain", &pHkeySub); |
484 regRes = RegSetValueEx(pHkeySub, L"StatusBarWeb", 0, REG_DWORD, (BYTE* )&trueth, sizeof(DWORD)); | 484 regRes = RegSetValueEx(pHkeySub, L"StatusBarWeb", 0, REG_DWORD, (BYTE* )&truth, sizeof(truth)); |
485 regRes = RegCloseKey(pHkeySub); | 485 regRes = RegCloseKey(pHkeySub); |
486 hr = browser->put_StatusBar(TRUE); | 486 hr = browser->put_StatusBar(TRUE); |
487 if (FAILED(hr)) | 487 if (FAILED(hr)) |
488 { | 488 { |
489 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_PUT_STATUSBAR, "Class::Enable statusbar"); | 489 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_PUT_STATUSBAR, "Class::Enable statusbar"); |
490 } | 490 } |
491 CreateStatusBarPane(); | 491 CreateStatusBarPane(); |
492 | 492 |
493 // We need to restart the tab now, to enable the status bar properly | 493 // We need to restart the tab now, to enable the status bar properly |
494 VARIANT vFlags; | 494 VARIANT vFlags; |
(...skipping 18 matching lines...) Expand all Loading... | |
513 } | 513 } |
514 } | 514 } |
515 else | 515 else |
516 { | 516 { |
517 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class ::Get statusbar state"); | 517 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class ::Get statusbar state"); |
518 } | 518 } |
519 } | 519 } |
520 DEBUG_GENERAL("ShowStatusBar end"); | 520 DEBUG_GENERAL("ShowStatusBar end"); |
521 } | 521 } |
522 | 522 |
523 /* | |
524 * #1163 This class is the implementation for method DISPID_BEFORENAVIGATE2 in C PluginClass::Invoke. | |
525 * - It validates and convertes its own arguments, rather than unifying them in the Invoke body. | |
526 * - It's declared void and not HRESULT, so DISPID_BEFORENAVIGATE2 can only retu rn S_OK. | |
527 */ | |
523 void CPluginClass::BeforeNavigate2(DISPPARAMS* pDispParams) | 528 void CPluginClass::BeforeNavigate2(DISPPARAMS* pDispParams) |
524 { | 529 { |
525 | 530 |
526 if (pDispParams->cArgs < 7) | 531 if (pDispParams->cArgs < 7) |
527 { | 532 { |
528 return; | 533 return; |
529 } | 534 } |
530 //Register a mime filter if it's not registered yet | 535 //Register a mime filter if it's not registered yet |
531 if (s_mimeFilter == NULL) | 536 if (s_mimeFilter == NULL) |
532 { | 537 { |
533 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); | 538 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); |
534 } | 539 } |
535 | 540 |
536 // Get the IWebBrowser2 interface | 541 // Get the IWebBrowser2 interface |
537 CComQIPtr<IWebBrowser2, &IID_IWebBrowser2> WebBrowser2Ptr; | 542 CComQIPtr<IWebBrowser2, &IID_IWebBrowser2> WebBrowser2Ptr; |
538 VARTYPE vt = pDispParams->rgvarg[6].vt; | 543 VARTYPE vt = pDispParams->rgvarg[6].vt; |
539 if (vt == VT_DISPATCH) | 544 if (vt == VT_DISPATCH) |
540 { | 545 { |
541 WebBrowser2Ptr = pDispParams->rgvarg[6].pdispVal; | 546 WebBrowser2Ptr = pDispParams->rgvarg[6].pdispVal; |
542 } | 547 } |
543 else | 548 else |
544 { | 549 { |
545 // Wrong type, return. | 550 // Wrong type, return. |
546 return; | 551 return; |
547 } | 552 } |
548 | 553 |
549 // Get the URL | 554 // Get the URL |
550 std::wstring url; | 555 std::wstring url; |
551 auto arg = pDispParams->rgvarg[5]; | 556 const auto& arg = pDispParams->rgvarg[5]; |
sergei
2014/10/17 10:10:12
I would prefer `const auto&` here.
Eric
2014/10/20 02:36:01
OK.
| |
552 vt = arg.vt; | 557 vt = arg.vt; |
553 if (vt == VT_BYREF + VT_VARIANT && arg.pvarVal->vt == VT_BSTR) | 558 if (vt == (VT_BYREF | VT_VARIANT) && arg.pvarVal->vt == VT_BSTR) |
sergei
2014/10/17 10:10:12
'+' here looks unusual, despite it works, I think
Eric
2014/10/20 02:36:01
It's out of scope, but it's also trivial.
Done.
| |
554 { | 559 { |
555 BSTR b = arg.pvarVal->bstrVal; | 560 BSTR b = arg.pvarVal->bstrVal; |
556 if (b) { | 561 if (b) { |
557 url = std::wstring(b, SysStringLen(b)); | 562 url = std::wstring(b, SysStringLen(b)); |
558 SysFreeString(b); | |
sergei
2014/10/17 10:10:12
It's not allowed to modify arguments, especially b
Eric
2014/10/20 02:36:01
Brain fart. Forgot that this was deriving from IDi
| |
559 UnescapeUrl(url); | 563 UnescapeUrl(url); |
560 } | 564 } |
561 } | 565 } |
562 else | 566 else |
563 { | 567 { |
564 // Wrong type, return. | 568 // Wrong type, return. |
565 return; | 569 return; |
566 } | 570 } |
567 | 571 |
568 // 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 |
(...skipping 14 matching lines...) Expand all Loading... | |
583 | 587 |
584 UpdateStatusBar(); | 588 UpdateStatusBar(); |
585 } | 589 } |
586 else | 590 else |
587 { | 591 { |
588 DEBUG_NAVI(L"Navi::Begin navigation url:" + urlLegacy) | 592 DEBUG_NAVI(L"Navi::Begin navigation url:" + urlLegacy) |
589 m_tab->CacheFrame(url); | 593 m_tab->CacheFrame(url); |
590 } | 594 } |
591 } | 595 } |
592 | 596 |
597 /* | |
598 * #1163 implements behavior for method DISPID_WINDOWSTATECHANGED in CPluginClas s::Invoke | |
599 * - should validate and convert arguments in Invoke, not here | |
600 * - does not validate number of arguments before indexing into 'rgvarg' | |
601 * - does not validate type of argument before using its value | |
602 */ | |
593 STDMETHODIMP CPluginClass::OnTabChanged(DISPPARAMS* pDispParams, WORD wFlags) | 603 STDMETHODIMP CPluginClass::OnTabChanged(DISPPARAMS* pDispParams, WORD wFlags) |
594 { | 604 { |
595 DEBUG_GENERAL("Tab changed"); | 605 DEBUG_GENERAL("Tab changed"); |
596 bool newtabshown = pDispParams->rgvarg[1].intVal==3; | 606 bool newtabshown = pDispParams->rgvarg[1].intVal==3; |
597 if (newtabshown) | 607 if (newtabshown) |
598 { | 608 { |
599 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find(Ge tCurrentThreadId()); | 609 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find(Ge tCurrentThreadId()); |
600 if (it == s_threadInstances.end()) | 610 if (it == s_threadInstances.end()) |
601 { | 611 { |
602 s_threadInstances[::GetCurrentThreadId()] = this; | 612 s_threadInstances[::GetCurrentThreadId()] = this; |
603 | |
604 | |
605 if (!m_isInitializedOk) | 613 if (!m_isInitializedOk) |
606 { | 614 { |
607 m_isInitializedOk = true; | 615 m_isInitializedOk = true; |
608 if (!InitObject(true)) | 616 InitObject(true); |
609 { | |
610 //» » » » » Unadvice(); | |
611 } | |
612 UpdateStatusBar(); | 617 UpdateStatusBar(); |
613 } | 618 } |
614 } | 619 } |
615 } | 620 } |
616 notificationMessage.Hide(); | 621 notificationMessage.Hide(); |
617 DEBUG_GENERAL("Tab change end"); | 622 DEBUG_GENERAL("Tab change end"); |
618 return VARIANT_TRUE; | 623 return S_OK; |
619 } | 624 } |
620 | 625 |
621 // This gets called whenever there's a browser event | 626 // This gets called whenever there's a browser event |
627 // ENTRY POINT | |
622 STDMETHODIMP CPluginClass::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, W ORD wFlags, DISPPARAMS* pDispParams, VARIANT* pvarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) | 628 STDMETHODIMP CPluginClass::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, W ORD wFlags, DISPPARAMS* pDispParams, VARIANT* pvarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) |
623 { | 629 { |
624 WCHAR tmp[256]; | 630 try |
625 wsprintf(tmp, L"Invoke: %d\n", dispidMember); | 631 { |
626 DEBUG_GENERAL(tmp); | 632 WCHAR tmp[256]; |
627 switch (dispidMember) | 633 wsprintf(tmp, L"Invoke: %d\n", dispidMember); |
628 { | 634 DEBUG_GENERAL(tmp); |
629 | 635 switch (dispidMember) |
630 case DISPID_WINDOWSTATECHANGED: | 636 { |
631 return OnTabChanged(pDispParams, wFlags); | 637 case DISPID_WINDOWSTATECHANGED: |
632 break; | 638 { |
633 case DISPID_HTMLDOCUMENTEVENTS2_ONBEFOREUPDATE: | 639 // #1163 should validate and convert arguments here |
634 return VARIANT_TRUE; | 640 return OnTabChanged(pDispParams, wFlags); |
635 break; | 641 } |
636 | 642 |
637 case DISPID_HTMLDOCUMENTEVENTS2_ONCLICK: | 643 case DISPID_HTMLDOCUMENTEVENTS2_ONBEFOREUPDATE: |
638 return VARIANT_TRUE; | 644 break; |
639 break; | 645 |
640 | 646 case DISPID_HTMLDOCUMENTEVENTS2_ONCLICK: |
641 case DISPID_EVMETH_ONLOAD: | 647 break; |
642 DEBUG_NAVI("Navi::OnLoad") | 648 |
643 return VARIANT_TRUE; | 649 case DISPID_EVMETH_ONLOAD: |
644 break; | 650 DEBUG_NAVI("Navi::OnLoad") |
645 | 651 break; |
646 case DISPID_EVMETH_ONCHANGE: | 652 |
647 return VARIANT_TRUE; | 653 case DISPID_EVMETH_ONCHANGE: |
648 | 654 break; |
649 case DISPID_EVMETH_ONMOUSEDOWN: | 655 |
650 return VARIANT_TRUE; | 656 case DISPID_EVMETH_ONMOUSEDOWN: |
651 | 657 break; |
652 case DISPID_EVMETH_ONMOUSEENTER: | 658 |
653 return VARIANT_TRUE; | 659 case DISPID_EVMETH_ONMOUSEENTER: |
654 | 660 break; |
655 case DISPID_IHTMLIMGELEMENT_START: | 661 |
656 return VARIANT_TRUE; | 662 case DISPID_IHTMLIMGELEMENT_START: |
657 | 663 break; |
658 case STDDISPID_XOBJ_ERRORUPDATE: | 664 |
659 return VARIANT_TRUE; | 665 case STDDISPID_XOBJ_ERRORUPDATE: |
660 | 666 break; |
661 case STDDISPID_XOBJ_ONPROPERTYCHANGE: | 667 |
662 return VARIANT_TRUE; | 668 case STDDISPID_XOBJ_ONPROPERTYCHANGE: |
663 | 669 break; |
664 case DISPID_READYSTATECHANGE: | 670 |
665 DEBUG_NAVI("Navi::ReadyStateChange") | 671 case DISPID_READYSTATECHANGE: |
666 return VARIANT_TRUE; | 672 DEBUG_NAVI("Navi::ReadyStateChange"); |
667 | 673 break; |
668 case DISPID_BEFORENAVIGATE: | 674 |
669 DEBUG_NAVI("Navi::BeforeNavigate") | 675 case DISPID_BEFORENAVIGATE: |
670 return VARIANT_TRUE; | 676 DEBUG_NAVI("Navi::BeforeNavigate"); |
671 case DISPID_COMMANDSTATECHANGE: | 677 break; |
672 if (m_hPaneWnd == NULL) | 678 |
673 { | 679 case DISPID_COMMANDSTATECHANGE: |
674 CreateStatusBarPane(); | 680 if (m_hPaneWnd == NULL) |
675 } | 681 { |
676 else | 682 CreateStatusBarPane(); |
677 { | 683 } |
678 if (CPluginClient::GetInstance()->GetIEVersion() > 6) | 684 else |
679 { | 685 { |
680 RECT rect; | 686 if (CPluginClient::GetInstance()->GetIEVersion() > 6) |
681 BOOL rectRes = GetClientRect(m_hStatusBarWnd, &rect); | 687 { |
682 if (rectRes == TRUE) | 688 RECT rect; |
683 { | 689 BOOL rectRes = GetClientRect(m_hStatusBarWnd, &rect); |
684 MoveWindow(m_hPaneWnd, rect.right - 200, 0, m_nPaneWidth, rect.bottom - rect.top, TRUE); | 690 if (rectRes == TRUE) |
685 } | 691 { |
686 } | 692 MoveWindow(m_hPaneWnd, rect.right - 200, 0, m_nPaneWidth, rect.botto m - rect.top, TRUE); |
687 } | 693 } |
688 break; | 694 } |
689 case DISPID_STATUSTEXTCHANGE: | 695 } |
690 break; | 696 break; |
691 | 697 |
692 case DISPID_BEFORENAVIGATE2: | 698 case DISPID_STATUSTEXTCHANGE: |
693 BeforeNavigate2(pDispParams); | 699 break; |
694 break; | 700 |
695 | 701 case DISPID_BEFORENAVIGATE2: |
696 case DISPID_DOWNLOADBEGIN: | 702 { |
697 { | 703 // #1163 should validate and convert parameters here |
698 DEBUG_NAVI("Navi::Download Begin") | 704 BeforeNavigate2(pDispParams); |
699 } | 705 } |
700 break; | 706 break; |
701 | 707 |
702 case DISPID_DOWNLOADCOMPLETE: | 708 case DISPID_DOWNLOADBEGIN: |
703 { | 709 { |
704 DEBUG_NAVI("Navi::Download Complete") | 710 DEBUG_NAVI("Navi::Download Begin") |
705 | 711 } |
712 break; | |
713 | |
714 case DISPID_DOWNLOADCOMPLETE: | |
715 { | |
716 DEBUG_NAVI("Navi::Download Complete"); | |
706 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | 717 CComQIPtr<IWebBrowser2> browser = GetBrowser(); |
707 if (browser) | 718 if (browser) |
708 { | 719 { |
709 m_tab->OnDownloadComplete(browser); | 720 m_tab->OnDownloadComplete(browser); |
710 } | 721 } |
711 } | 722 } |
712 break; | 723 break; |
713 | 724 |
714 case DISPID_DOCUMENTCOMPLETE: | 725 case DISPID_DOCUMENTCOMPLETE: |
715 { | 726 { |
716 DEBUG_NAVI("Navi::Document Complete") | 727 DEBUG_NAVI("Navi::Document Complete"); |
717 | |
718 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | 728 CComQIPtr<IWebBrowser2> browser = GetBrowser(); |
719 | 729 if (browser && pDispParams->cArgs >= 2 && pDispParams->rgvarg[1].vt == V T_DISPATCH) |
720 if (browser && pDispParams->cArgs >= 2 && pDispParams->rgvarg[1].vt == VT_ DISPATCH) | 730 { |
721 { | 731 CComQIPtr<IWebBrowser2> pBrowser = pDispParams->rgvarg[1].pdispVal; |
722 CComQIPtr<IWebBrowser2> pBrowser = pDispParams->rgvarg[1].pdispVal; | 732 if (pBrowser) |
723 if (pBrowser) | |
724 { | |
725 BSTR bstrUrl; | |
sergei
2014/10/17 10:10:12
Again CComBSTR is replaced by BSTR.
Eric
2014/10/20 02:36:01
And for the same reasons I stated above.
| |
726 if (SUCCEEDED(pBrowser->get_LocationURL(&bstrUrl)) && ::SysStringLen(b strUrl) > 0) | |
727 { | 733 { |
728 std::wstring url(bstrUrl, SysStringLen(bstrUrl)); | 734 CComBSTR bstrUrl; |
729 SysFreeString(bstrUrl); | 735 if (SUCCEEDED(pBrowser->get_LocationURL(&bstrUrl)) && bstrUrl && ::S ysStringLen(bstrUrl) > 0) |
730 UnescapeUrl(url); | 736 { |
731 m_tab->OnDocumentComplete(browser, url, browser.IsEqualObject(pBrows er)); | 737 std::wstring url = std::wstring(bstrUrl, SysStringLen(bstrUrl)); |
738 UnescapeUrl(url); | |
739 m_tab->OnDocumentComplete(browser, url, browser.IsEqualObject(pBro wser)); | |
740 } | |
732 } | 741 } |
733 } | 742 } |
734 } | 743 } |
735 } | 744 break; |
736 break; | 745 |
737 | 746 case DISPID_ONQUIT: |
738 case DISPID_ONQUIT: | 747 case DISPID_QUIT: |
739 case DISPID_QUIT: | 748 { |
740 { | 749 Unadvice(); |
741 Unadvice(); | 750 } |
742 } | 751 break; |
743 break; | 752 |
744 | 753 default: |
745 default: | 754 { |
746 { | 755 CString did; |
747 CString did; | 756 did.Format(L"DispId:%u", dispidMember); |
748 did.Format(L"DispId:%u", dispidMember); | 757 |
749 | 758 DEBUG_NAVI(L"Navi::Default " + did) |
750 DEBUG_NAVI(L"Navi::Default " + did) | 759 } |
751 } | 760 /* |
752 | 761 * Ordinarily a method not dispatched should return DISP_E_MEMBERNOTFOUND. |
753 // do nothing | 762 * As a conservative initial change, we leave it behaving as before, |
754 break; | 763 * which is to do nothing and return S_OK. |
755 } | 764 */ |
756 | 765 // do nothing |
757 return VARIANT_TRUE; | 766 break; |
767 } | |
768 } | |
769 catch(...) | |
770 { | |
771 DEBUG_GENERAL( "Caught unknown exception in CPluginClass::Invoke" ); | |
772 return E_FAIL; | |
773 } | |
774 return S_OK; | |
758 } | 775 } |
759 | 776 |
760 bool CPluginClass::InitObject(bool bBHO) | 777 bool CPluginClass::InitObject(bool bBHO) |
761 { | 778 { |
762 DEBUG_GENERAL("InitObject"); | 779 DEBUG_GENERAL("InitObject"); |
763 CPluginSettings* settings = CPluginSettings::GetInstance(); | 780 CPluginSettings* settings = CPluginSettings::GetInstance(); |
764 | 781 |
765 if (!settings->GetPluginEnabled()) | 782 if (!settings->GetPluginEnabled()) |
766 { | 783 { |
767 s_mimeFilter->Unregister(); | 784 s_mimeFilter->Unregister(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
799 } | 816 } |
800 } | 817 } |
801 } | 818 } |
802 s_criticalSectionLocal.Unlock(); | 819 s_criticalSectionLocal.Unlock(); |
803 | 820 |
804 // Register pane class | 821 // Register pane class |
805 if (!GetAtomPaneClass()) | 822 if (!GetAtomPaneClass()) |
806 { | 823 { |
807 WNDCLASSEX wcex; | 824 WNDCLASSEX wcex; |
808 | 825 |
809 wcex.cbSize = sizeof(WNDCLASSEX); | 826 wcex.cbSize = sizeof(wcex); |
810 wcex.style = 0; | 827 wcex.style = 0; |
811 wcex.lpfnWndProc = (WNDPROC)PaneWindowProc; | 828 wcex.lpfnWndProc = (WNDPROC)PaneWindowProc; |
812 wcex.cbClsExtra = 0; | 829 wcex.cbClsExtra = 0; |
813 wcex.cbWndExtra = 0; | 830 wcex.cbWndExtra = 0; |
814 wcex.hInstance = _Module.m_hInst; | 831 wcex.hInstance = _Module.m_hInst; |
815 wcex.hIcon = NULL; | 832 wcex.hIcon = NULL; |
816 wcex.hCursor = NULL; | 833 wcex.hCursor = NULL; |
817 wcex.hbrBackground = NULL; | 834 wcex.hbrBackground = NULL; |
818 wcex.lpszMenuName = NULL; | 835 wcex.lpszMenuName = NULL; |
819 wcex.lpszClassName = STATUSBAR_PANE_NAME; | 836 wcex.lpszClassName = STATUSBAR_PANE_NAME; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
875 s_criticalSectionLocal.Unlock(); | 892 s_criticalSectionLocal.Unlock(); |
876 return true; | 893 return true; |
877 } | 894 } |
878 | 895 |
879 bool CPluginClass::CreateStatusBarPane() | 896 bool CPluginClass::CreateStatusBarPane() |
880 { | 897 { |
881 CriticalSection::Lock lock(m_csStatusBar); | 898 CriticalSection::Lock lock(m_csStatusBar); |
882 | 899 |
883 CPluginClient* client = CPluginClient::GetInstance(); | 900 CPluginClient* client = CPluginClient::GetInstance(); |
884 | 901 |
885 wchar_t szClassName[MAX_PATH]; | 902 std::array<wchar_t, MAX_PATH> className; |
886 // Get browser window and url | 903 // Get browser window and url |
887 HWND hBrowserWnd = GetBrowserHWND(); | 904 HWND hBrowserWnd = GetBrowserHWND(); |
888 if (!hBrowserWnd) | 905 if (!hBrowserWnd) |
889 { | 906 { |
890 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_BROWSER, "C lass::CreateStatusBarPane - No status bar") | 907 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_BROWSER, "C lass::CreateStatusBarPane - No status bar") |
891 return false; | 908 return false; |
892 } | 909 } |
893 | 910 |
894 // Looking for a TabWindowClass window in IE7 | 911 // Looking for a TabWindowClass window in IE7 |
895 // the last one should be parent for statusbar | 912 // the last one should be parent for statusbar |
896 HWND hWndStatusBar = NULL; | 913 HWND hWndStatusBar = NULL; |
897 | 914 |
898 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD); | 915 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD); |
899 UINT amoundOfNewTabs = 0; | 916 UINT amoundOfNewTabs = 0; |
900 HWND uniqueNewTab = NULL; | 917 HWND uniqueNewTab = NULL; |
901 while (hTabWnd) | 918 while (hTabWnd) |
902 { | 919 { |
903 memset(szClassName, 0, MAX_PATH); | 920 className[0] = L'\0'; |
904 GetClassName(hTabWnd, szClassName, MAX_PATH); | 921 // GetClassNameW returns the number of characters without '\0' |
905 | 922 int classNameLength = GetClassNameW(hTabWnd, className.data(), className.siz e()); |
906 if (wcscmp(szClassName, L"TabWindowClass") == 0 || wcscmp(szClassName,L"Fram e Tab") == 0) | 923 |
924 if (classNameLength && (wcscmp(className.data(), L"TabWindowClass") == 0 || wcscmp(className.data(), L"Frame Tab") == 0)) | |
907 { | 925 { |
908 // IE8 support | 926 // IE8 support |
909 HWND hTabWnd2 = hTabWnd; | 927 HWND hTabWnd2 = hTabWnd; |
910 if (wcscmp(szClassName,L"Frame Tab") == 0) | 928 if (wcscmp(className.data(), L"Frame Tab") == 0) |
911 { | 929 { |
912 hTabWnd2 = ::FindWindowEx(hTabWnd2, NULL, L"TabWindowClass", NULL); | 930 hTabWnd2 = ::FindWindowEx(hTabWnd2, NULL, L"TabWindowClass", NULL); |
913 } | 931 } |
914 | 932 |
915 if (hTabWnd2) | 933 if (hTabWnd2) |
916 { | 934 { |
917 DWORD nProcessId; | 935 DWORD nProcessId; |
918 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId); | 936 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId); |
919 if (::GetCurrentProcessId() == nProcessId) | 937 if (::GetCurrentProcessId() == nProcessId) |
920 { | 938 { |
(...skipping 26 matching lines...) Expand all Loading... | |
947 } | 965 } |
948 } | 966 } |
949 } | 967 } |
950 | 968 |
951 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | 969 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); |
952 } | 970 } |
953 | 971 |
954 HWND hWnd = ::GetWindow(hBrowserWnd, GW_CHILD); | 972 HWND hWnd = ::GetWindow(hBrowserWnd, GW_CHILD); |
955 while (hWnd) | 973 while (hWnd) |
956 { | 974 { |
957 memset(szClassName, 0, MAX_PATH); | 975 className[0] = L'\0'; |
958 ::GetClassName(hWnd, szClassName, MAX_PATH); | 976 int classNameLength = GetClassNameW(hWnd, className.data(), className.size() ); |
959 | 977 |
960 if (wcscmp(szClassName,L"msctls_statusbar32") == 0) | 978 if (classNameLength && wcscmp(className.data(), L"msctls_statusbar32") == 0) |
961 { | 979 { |
962 hWndStatusBar = hWnd; | 980 hWndStatusBar = hWnd; |
963 break; | 981 break; |
964 } | 982 } |
965 | 983 |
966 hWnd = ::GetWindow(hWnd, GW_HWNDNEXT); | 984 hWnd = ::GetWindow(hWnd, GW_HWNDNEXT); |
967 } | 985 } |
968 | 986 |
969 if (!hWndStatusBar) | 987 if (!hWndStatusBar) |
970 { | 988 { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1147 HINSTANCE hInstance = _AtlBaseModule.GetModuleInstance(); | 1165 HINSTANCE hInstance = _AtlBaseModule.GetModuleInstance(); |
1148 | 1166 |
1149 HMENU hMenu = ::LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1)); | 1167 HMENU hMenu = ::LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1)); |
1150 | 1168 |
1151 HMENU hMenuTrackPopup = GetSubMenu(hMenu, 0); | 1169 HMENU hMenuTrackPopup = GetSubMenu(hMenu, 0); |
1152 | 1170 |
1153 SetMenuBar(hMenuTrackPopup, url); | 1171 SetMenuBar(hMenuTrackPopup, url); |
1154 | 1172 |
1155 return hMenuTrackPopup; | 1173 return hMenuTrackPopup; |
1156 } | 1174 } |
1157 BOOL CreateLowProcess(WCHAR* wszProcessName, WCHAR* cmdLine) | |
1158 { | |
1159 | |
1160 BOOL fRet; | |
1161 HANDLE hToken = NULL; | |
1162 HANDLE hNewToken = NULL; | |
1163 PSID pIntegritySid = NULL; | |
1164 TOKEN_MANDATORY_LABEL TIL = {0}; | |
1165 PROCESS_INFORMATION ProcInfo = {0}; | |
1166 STARTUPINFO StartupInfo = {0}; | |
1167 | |
1168 | |
1169 | |
1170 // Low integrity SID | |
1171 WCHAR wszIntegritySid[20] = L"S-1-16-4096"; | |
1172 | |
1173 | |
1174 fRet = OpenProcessToken(GetCurrentProcess(), | |
1175 TOKEN_DUPLICATE | | |
1176 TOKEN_ADJUST_DEFAULT | | |
1177 TOKEN_QUERY | | |
1178 TOKEN_ASSIGN_PRIMARY, | |
1179 &hToken); | |
1180 | |
1181 if (!fRet) | |
1182 { | |
1183 goto CleanExit; | |
1184 } | |
1185 | |
1186 fRet = DuplicateTokenEx(hToken, | |
1187 0, | |
1188 NULL, | |
1189 SecurityImpersonation, | |
1190 TokenPrimary, | |
1191 &hNewToken); | |
1192 | |
1193 if (!fRet) | |
1194 { | |
1195 goto CleanExit; | |
1196 } | |
1197 | |
1198 fRet = ConvertStringSidToSid(wszIntegritySid, &pIntegritySid); | |
1199 | |
1200 if (!fRet) | |
1201 { | |
1202 goto CleanExit; | |
1203 } | |
1204 | |
1205 | |
1206 TIL.Label.Attributes = SE_GROUP_INTEGRITY; | |
1207 TIL.Label.Sid = pIntegritySid; | |
1208 | |
1209 | |
1210 // | |
1211 // Set the process integrity level | |
1212 // | |
1213 | |
1214 fRet = SetTokenInformation(hNewToken, | |
1215 TokenIntegrityLevel, | |
1216 &TIL, | |
1217 sizeof(TOKEN_MANDATORY_LABEL) + GetLengthSid(pIntegritySid)); | |
1218 | |
1219 if (!fRet) | |
1220 { | |
1221 goto CleanExit; | |
1222 } | |
1223 | |
1224 // | |
1225 // Create the new process at Low integrity | |
1226 // | |
1227 | |
1228 fRet = CreateProcessAsUser(hNewToken, | |
1229 wszProcessName, | |
1230 cmdLine, | |
1231 NULL, | |
1232 NULL, | |
1233 FALSE, | |
1234 0, | |
1235 NULL, | |
1236 NULL, | |
1237 &StartupInfo, | |
1238 &ProcInfo); | |
1239 | |
1240 | |
1241 CleanExit: | |
1242 | |
1243 if (ProcInfo.hProcess != NULL) | |
1244 { | |
1245 CloseHandle(ProcInfo.hProcess); | |
1246 } | |
1247 | |
1248 if (ProcInfo.hThread != NULL) | |
1249 { | |
1250 CloseHandle(ProcInfo.hThread); | |
1251 } | |
1252 | |
1253 LocalFree(pIntegritySid); | |
1254 | |
1255 if (hNewToken != NULL) | |
1256 { | |
1257 CloseHandle(hNewToken); | |
1258 } | |
1259 | |
1260 if (hToken != NULL) | |
1261 { | |
1262 CloseHandle(hToken); | |
1263 } | |
1264 | |
1265 return fRet; | |
1266 } | |
1267 | 1175 |
1268 void CPluginClass::DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, U INT nMenuFlags) | 1176 void CPluginClass::DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, U INT nMenuFlags) |
1269 { | 1177 { |
1270 CPluginClient* client = CPluginClient::GetInstance(); | 1178 CPluginClient* client = CPluginClient::GetInstance(); |
1271 | 1179 |
1272 // Create menu parent window | 1180 // Create menu parent window |
1273 HWND hMenuWnd = ::CreateWindowEx( | 1181 HWND hMenuWnd = ::CreateWindowEx( |
1274 NULL, | 1182 NULL, |
1275 MAKEINTATOM(GetAtomPaneClass()), | 1183 MAKEINTATOM(GetAtomPaneClass()), |
1276 L"", | 1184 L"", |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1376 // Invalidate and redraw the control | 1284 // Invalidate and redraw the control |
1377 UpdateStatusBar(); | 1285 UpdateStatusBar(); |
1378 } | 1286 } |
1379 | 1287 |
1380 | 1288 |
1381 bool CPluginClass::SetMenuBar(HMENU hMenu, const std::wstring& url) | 1289 bool CPluginClass::SetMenuBar(HMENU hMenu, const std::wstring& url) |
1382 { | 1290 { |
1383 DEBUG_GENERAL("SetMenuBar"); | 1291 DEBUG_GENERAL("SetMenuBar"); |
1384 | 1292 |
1385 std::wstring ctext; | 1293 std::wstring ctext; |
1386 | |
1387 s_criticalSectionLocal.Lock(); | |
1388 { | |
1389 s_menuDomains.clear(); | |
1390 } | |
1391 s_criticalSectionLocal.Unlock(); | |
1392 | |
1393 Dictionary* dictionary = Dictionary::GetInstance(); | 1294 Dictionary* dictionary = Dictionary::GetInstance(); |
1394 | 1295 |
1395 MENUITEMINFOW fmii; | 1296 MENUITEMINFOW fmii = {}; |
1396 memset(&fmii, 0, sizeof(MENUITEMINFO)); | 1297 fmii.cbSize = sizeof(fmii); |
1397 fmii.cbSize = sizeof(MENUITEMINFO); | 1298 |
1398 | 1299 MENUITEMINFOW miiSep = {}; |
1399 MENUITEMINFOW miiSep; | 1300 miiSep.cbSize = sizeof(miiSep); |
1400 memset(&miiSep, 0, sizeof(MENUITEMINFO)); | |
1401 miiSep.cbSize = sizeof(MENUITEMINFO); | |
1402 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE; | 1301 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE; |
1403 miiSep.fType = MFT_SEPARATOR; | 1302 miiSep.fType = MFT_SEPARATOR; |
1404 | 1303 |
1405 CPluginClient* client = CPluginClient::GetInstance(); | 1304 CPluginClient* client = CPluginClient::GetInstance(); |
1406 CPluginSettings* settings = CPluginSettings::GetInstance(); | 1305 CPluginSettings* settings = CPluginSettings::GetInstance(); |
1407 { | 1306 { |
1408 ctext = dictionary->Lookup("menu", "menu-disable-on-site"); | 1307 ctext = dictionary->Lookup("menu", "menu-disable-on-site"); |
1409 // Is domain in white list? | 1308 // Is domain in white list? |
1410 ReplaceString(ctext, L"?1?", client->GetHostFromUrl(url)); | 1309 ReplaceString(ctext, L"?1?", client->GetHostFromUrl(url)); |
1411 if (client->IsWhitelistedUrl(GetTab()->GetDocumentUrl())) | 1310 if (client->IsWhitelistedUrl(GetTab()->GetDocumentUrl())) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1486 DWORD nProcessId; | 1385 DWORD nProcessId; |
1487 ::GetWindowThreadProcessId(hWndToolBar, &nProcessId); | 1386 ::GetWindowThreadProcessId(hWndToolBar, &nProcessId); |
1488 | 1387 |
1489 if (hWndToolBar && ::GetCurrentProcessId() == nProcessId) | 1388 if (hWndToolBar && ::GetCurrentProcessId() == nProcessId) |
1490 { | 1389 { |
1491 ::ScreenToClient(hWndToolBar, &pt); | 1390 ::ScreenToClient(hWndToolBar, &pt); |
1492 int nButton = (int)::SendMessage(hWndToolBar, TB_HITTEST, 0, (LPARAM)&pt); | 1391 int nButton = (int)::SendMessage(hWndToolBar, TB_HITTEST, 0, (LPARAM)&pt); |
1493 | 1392 |
1494 if (nButton > 0) | 1393 if (nButton > 0) |
1495 { | 1394 { |
1496 TBBUTTON pTBBtn; | 1395 TBBUTTON pTBBtn = {}; |
1497 memset(&pTBBtn, 0, sizeof(TBBUTTON)); | |
1498 | 1396 |
1499 if (SendMessage(hWndToolBar, TB_GETBUTTON, nButton, (LPARAM)&pTBBtn)) | 1397 if (SendMessage(hWndToolBar, TB_GETBUTTON, nButton, (LPARAM)&pTBBtn)) |
1500 { | 1398 { |
1501 RECT rcButton; | 1399 RECT rcButton; |
1502 nIDCommand = pTBBtn.idCommand; | 1400 nIDCommand = pTBBtn.idCommand; |
1503 | 1401 |
1504 if (SendMessage(hWndToolBar, TB_GETRECT, nIDCommand, (LPARAM)&rcButton)) | 1402 if (SendMessage(hWndToolBar, TB_GETRECT, nIDCommand, (LPARAM)&rcButton)) |
1505 { | 1403 { |
1506 pt.x = rcButton.left; | 1404 pt.x = rcButton.left; |
1507 pt.y = rcButton.bottom; | 1405 pt.y = rcButton.bottom; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1625 | 1523 |
1626 HICON CPluginClass::GetStatusBarIcon(const std::wstring& url) | 1524 HICON CPluginClass::GetStatusBarIcon(const std::wstring& url) |
1627 { | 1525 { |
1628 // 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 |
1629 HICON hIcon = GetIcon(ICON_PLUGIN_DEACTIVATED); | 1527 HICON hIcon = GetIcon(ICON_PLUGIN_DEACTIVATED); |
1630 | 1528 |
1631 CPluginTab* tab = GetTab(::GetCurrentThreadId()); | 1529 CPluginTab* tab = GetTab(::GetCurrentThreadId()); |
1632 if (tab) | 1530 if (tab) |
1633 { | 1531 { |
1634 CPluginClient* client = CPluginClient::GetInstance(); | 1532 CPluginClient* client = CPluginClient::GetInstance(); |
1635 if (!CPluginSettings::GetInstance()->IsPluginEnabled()) | 1533 if (CPluginSettings::GetInstance()->IsPluginEnabled()) |
1636 { | 1534 { |
1637 } | 1535 if (client->IsWhitelistedUrl(url)) |
1638 else if (client->IsWhitelistedUrl(url)) | 1536 { |
1639 { | 1537 hIcon = GetIcon(ICON_PLUGIN_DISABLED); |
1640 hIcon = GetIcon(ICON_PLUGIN_DISABLED); | 1538 } |
1641 } | 1539 else |
1642 else | 1540 { |
1643 { | 1541 CPluginSettings* settings = CPluginSettings::GetInstance(); |
1644 CPluginSettings* settings = CPluginSettings::GetInstance(); | 1542 hIcon = GetIcon(ICON_PLUGIN_ENABLED); |
1645 hIcon = GetIcon(ICON_PLUGIN_ENABLED); | 1543 } |
1646 } | 1544 } |
1647 } | 1545 } |
1648 return hIcon; | 1546 return hIcon; |
1649 } | 1547 } |
1650 | 1548 |
1651 | 1549 |
1652 LRESULT CALLBACK CPluginClass::PaneWindowProc(HWND hWnd, UINT message, WPARAM wP aram, LPARAM lParam) | 1550 LRESULT CALLBACK CPluginClass::PaneWindowProc(HWND hWnd, UINT message, WPARAM wP aram, LPARAM lParam) |
1653 { | 1551 { |
1654 // Find tab | 1552 // Find tab |
1655 CPluginClass *pClass = FindInstance(GetParent(hWnd)); | 1553 CPluginClass *pClass = FindInstance(GetParent(hWnd)); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1909 return icon; | 1807 return icon; |
1910 } | 1808 } |
1911 | 1809 |
1912 ATOM CPluginClass::GetAtomPaneClass() | 1810 ATOM CPluginClass::GetAtomPaneClass() |
1913 { | 1811 { |
1914 return s_atomPaneClass; | 1812 return s_atomPaneClass; |
1915 } | 1813 } |
1916 | 1814 |
1917 HWND CPluginClass::GetTabHWND() const | 1815 HWND CPluginClass::GetTabHWND() const |
1918 { | 1816 { |
1919 wchar_t szClassName[MAX_PATH]; | 1817 std::array<wchar_t, MAX_PATH> className; |
1920 // Get browser window and url | 1818 // Get browser window and url |
1921 HWND hBrowserWnd = GetBrowserHWND(); | 1819 HWND hBrowserWnd = GetBrowserHWND(); |
1922 if (!hBrowserWnd) | 1820 if (!hBrowserWnd) |
1923 { | 1821 { |
1924 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_BROWSER, "C lass::GetTabWindow - No tab window") | 1822 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_BROWSER, "C lass::GetTabWindow - No tab window") |
1925 s_criticalSectionWindow.Unlock(); | 1823 s_criticalSectionWindow.Unlock(); |
1926 | 1824 |
1927 return false; | 1825 return false; |
1928 } | 1826 } |
1929 | 1827 |
1930 // Looking for a TabWindowClass window in IE7 | 1828 // Looking for a TabWindowClass window in IE7 |
1931 | 1829 |
1932 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD); | 1830 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD); |
1933 while (hTabWnd) | 1831 while (hTabWnd) |
1934 { | 1832 { |
1935 memset(szClassName, 0, MAX_PATH); | 1833 className[0] = L'\0'; |
1936 GetClassName(hTabWnd, szClassName, MAX_PATH); | 1834 int classNameLength = GetClassNameW(hTabWnd, className.data(), className.siz e()); |
1937 | 1835 |
1938 if (wcscmp(szClassName, L"TabWindowClass") == 0 || wcscmp(szClassName, L"Fra me Tab") == 0) | 1836 if (classNameLength && (wcscmp(className.data(), L"TabWindowClass") == 0 || wcscmp(className.data(), L"Frame Tab") == 0)) |
1939 { | 1837 { |
1940 // IE8 support | 1838 // IE8 support |
1941 HWND hTabWnd2 = hTabWnd; | 1839 HWND hTabWnd2 = hTabWnd; |
1942 if (wcscmp(szClassName, L"Frame Tab") == 0) | 1840 if (wcscmp(className.data(), L"Frame Tab") == 0) |
1943 { | 1841 { |
1944 hTabWnd2 = ::FindWindowEx(hTabWnd2, NULL, L"TabWindowClass", NULL); | 1842 hTabWnd2 = ::FindWindowEx(hTabWnd2, NULL, L"TabWindowClass", NULL); |
1945 } | 1843 } |
1946 | 1844 |
1947 if (hTabWnd2) | 1845 if (hTabWnd2) |
1948 { | 1846 { |
1949 DWORD nProcessId; | 1847 DWORD nProcessId; |
1950 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId); | 1848 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId); |
1951 if (::GetCurrentProcessId() == nProcessId) | 1849 if (::GetCurrentProcessId() == nProcessId) |
1952 { | 1850 { |
(...skipping 23 matching lines...) Expand all Loading... | |
1976 } | 1874 } |
1977 } | 1875 } |
1978 } | 1876 } |
1979 | 1877 |
1980 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | 1878 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); |
1981 } | 1879 } |
1982 | 1880 |
1983 return hTabWnd; | 1881 return hTabWnd; |
1984 | 1882 |
1985 } | 1883 } |
LEFT | RIGHT |