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

Delta Between Two Patch Sets: src/plugin/PluginClass.cpp

Issue 4912420225024000: Issue #1234 - Convert strings associated with URL's (Closed)
Left Patch Set: Created Oct. 21, 2014, 5:18 p.m.
Right Patch Set: Created Jan. 5, 2015, 4:15 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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
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;
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
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
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
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 {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 587
583 UpdateStatusBar(); 588 UpdateStatusBar();
584 } 589 }
585 else 590 else
586 { 591 {
587 DEBUG_NAVI(L"Navi::Begin navigation url:" + urlLegacy) 592 DEBUG_NAVI(L"Navi::Begin navigation url:" + urlLegacy)
588 m_tab->CacheFrame(url); 593 m_tab->CacheFrame(url);
589 } 594 }
590 } 595 }
591 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 */
592 STDMETHODIMP CPluginClass::OnTabChanged(DISPPARAMS* pDispParams, WORD wFlags) 603 STDMETHODIMP CPluginClass::OnTabChanged(DISPPARAMS* pDispParams, WORD wFlags)
593 { 604 {
594 DEBUG_GENERAL("Tab changed"); 605 DEBUG_GENERAL("Tab changed");
595 bool newtabshown = pDispParams->rgvarg[1].intVal==3; 606 bool newtabshown = pDispParams->rgvarg[1].intVal==3;
596 if (newtabshown) 607 if (newtabshown)
597 { 608 {
598 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());
599 if (it == s_threadInstances.end()) 610 if (it == s_threadInstances.end())
600 { 611 {
601 s_threadInstances[::GetCurrentThreadId()] = this; 612 s_threadInstances[::GetCurrentThreadId()] = this;
602
603
604 if (!m_isInitializedOk) 613 if (!m_isInitializedOk)
605 { 614 {
606 m_isInitializedOk = true; 615 m_isInitializedOk = true;
607 if (!InitObject(true)) 616 InitObject(true);
608 {
609 //» » » » » Unadvice();
610 }
611 UpdateStatusBar(); 617 UpdateStatusBar();
612 } 618 }
613 } 619 }
614 } 620 }
615 notificationMessage.Hide(); 621 notificationMessage.Hide();
616 DEBUG_GENERAL("Tab change end"); 622 DEBUG_GENERAL("Tab change end");
617 return VARIANT_TRUE; 623 return S_OK;
618 } 624 }
619 625
620 // This gets called whenever there's a browser event 626 // This gets called whenever there's a browser event
627 // ENTRY POINT
621 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)
622 { 629 {
623 WCHAR tmp[256]; 630 try
624 wsprintf(tmp, L"Invoke: %d\n", dispidMember); 631 {
625 DEBUG_GENERAL(tmp); 632 WCHAR tmp[256];
626 switch (dispidMember) 633 wsprintf(tmp, L"Invoke: %d\n", dispidMember);
627 { 634 DEBUG_GENERAL(tmp);
628 635 switch (dispidMember)
629 case DISPID_WINDOWSTATECHANGED: 636 {
630 return OnTabChanged(pDispParams, wFlags); 637 case DISPID_WINDOWSTATECHANGED:
631 break; 638 {
632 case DISPID_HTMLDOCUMENTEVENTS2_ONBEFOREUPDATE: 639 // #1163 should validate and convert arguments here
633 return VARIANT_TRUE; 640 return OnTabChanged(pDispParams, wFlags);
634 break; 641 }
635 642
636 case DISPID_HTMLDOCUMENTEVENTS2_ONCLICK: 643 case DISPID_HTMLDOCUMENTEVENTS2_ONBEFOREUPDATE:
637 return VARIANT_TRUE; 644 break;
638 break; 645
639 646 case DISPID_HTMLDOCUMENTEVENTS2_ONCLICK:
640 case DISPID_EVMETH_ONLOAD: 647 break;
641 DEBUG_NAVI("Navi::OnLoad") 648
642 return VARIANT_TRUE; 649 case DISPID_EVMETH_ONLOAD:
643 break; 650 DEBUG_NAVI("Navi::OnLoad")
644 651 break;
645 case DISPID_EVMETH_ONCHANGE: 652
646 return VARIANT_TRUE; 653 case DISPID_EVMETH_ONCHANGE:
647 654 break;
648 case DISPID_EVMETH_ONMOUSEDOWN: 655
649 return VARIANT_TRUE; 656 case DISPID_EVMETH_ONMOUSEDOWN:
650 657 break;
651 case DISPID_EVMETH_ONMOUSEENTER: 658
652 return VARIANT_TRUE; 659 case DISPID_EVMETH_ONMOUSEENTER:
653 660 break;
654 case DISPID_IHTMLIMGELEMENT_START: 661
655 return VARIANT_TRUE; 662 case DISPID_IHTMLIMGELEMENT_START:
656 663 break;
657 case STDDISPID_XOBJ_ERRORUPDATE: 664
658 return VARIANT_TRUE; 665 case STDDISPID_XOBJ_ERRORUPDATE:
659 666 break;
660 case STDDISPID_XOBJ_ONPROPERTYCHANGE: 667
661 return VARIANT_TRUE; 668 case STDDISPID_XOBJ_ONPROPERTYCHANGE:
662 669 break;
663 case DISPID_READYSTATECHANGE: 670
664 DEBUG_NAVI("Navi::ReadyStateChange") 671 case DISPID_READYSTATECHANGE:
665 return VARIANT_TRUE; 672 DEBUG_NAVI("Navi::ReadyStateChange");
666 673 break;
667 case DISPID_BEFORENAVIGATE: 674
668 DEBUG_NAVI("Navi::BeforeNavigate") 675 case DISPID_BEFORENAVIGATE:
669 return VARIANT_TRUE; 676 DEBUG_NAVI("Navi::BeforeNavigate");
670 case DISPID_COMMANDSTATECHANGE: 677 break;
671 if (m_hPaneWnd == NULL) 678
672 { 679 case DISPID_COMMANDSTATECHANGE:
673 CreateStatusBarPane(); 680 if (m_hPaneWnd == NULL)
674 } 681 {
675 else 682 CreateStatusBarPane();
676 { 683 }
677 if (CPluginClient::GetInstance()->GetIEVersion() > 6) 684 else
678 { 685 {
679 RECT rect; 686 if (CPluginClient::GetInstance()->GetIEVersion() > 6)
680 BOOL rectRes = GetClientRect(m_hStatusBarWnd, &rect); 687 {
681 if (rectRes == TRUE) 688 RECT rect;
682 { 689 BOOL rectRes = GetClientRect(m_hStatusBarWnd, &rect);
683 MoveWindow(m_hPaneWnd, rect.right - 200, 0, m_nPaneWidth, rect.bottom - rect.top, TRUE); 690 if (rectRes == TRUE)
684 } 691 {
685 } 692 MoveWindow(m_hPaneWnd, rect.right - 200, 0, m_nPaneWidth, rect.botto m - rect.top, TRUE);
686 } 693 }
687 break; 694 }
688 case DISPID_STATUSTEXTCHANGE: 695 }
689 break; 696 break;
690 697
691 case DISPID_BEFORENAVIGATE2: 698 case DISPID_STATUSTEXTCHANGE:
692 BeforeNavigate2(pDispParams); 699 break;
693 break; 700
694 701 case DISPID_BEFORENAVIGATE2:
695 case DISPID_DOWNLOADBEGIN: 702 {
696 { 703 // #1163 should validate and convert parameters here
697 DEBUG_NAVI("Navi::Download Begin") 704 BeforeNavigate2(pDispParams);
698 } 705 }
699 break; 706 break;
700 707
701 case DISPID_DOWNLOADCOMPLETE: 708 case DISPID_DOWNLOADBEGIN:
702 { 709 {
703 DEBUG_NAVI("Navi::Download Complete") 710 DEBUG_NAVI("Navi::Download Begin")
704 711 }
712 break;
713
714 case DISPID_DOWNLOADCOMPLETE:
715 {
716 DEBUG_NAVI("Navi::Download Complete");
705 CComQIPtr<IWebBrowser2> browser = GetBrowser(); 717 CComQIPtr<IWebBrowser2> browser = GetBrowser();
706 if (browser) 718 if (browser)
707 { 719 {
708 m_tab->OnDownloadComplete(browser); 720 m_tab->OnDownloadComplete(browser);
709 } 721 }
710 } 722 }
711 break; 723 break;
712 724
713 case DISPID_DOCUMENTCOMPLETE: 725 case DISPID_DOCUMENTCOMPLETE:
714 { 726 {
715 DEBUG_NAVI("Navi::Document Complete") 727 DEBUG_NAVI("Navi::Document Complete");
716
717 CComQIPtr<IWebBrowser2> browser = GetBrowser(); 728 CComQIPtr<IWebBrowser2> browser = GetBrowser();
718 729 if (browser && pDispParams->cArgs >= 2 && pDispParams->rgvarg[1].vt == V T_DISPATCH)
719 if (browser && pDispParams->cArgs >= 2 && pDispParams->rgvarg[1].vt == VT_ DISPATCH) 730 {
720 { 731 CComQIPtr<IWebBrowser2> pBrowser = pDispParams->rgvarg[1].pdispVal;
721 CComQIPtr<IWebBrowser2> pBrowser = pDispParams->rgvarg[1].pdispVal; 732 if (pBrowser)
722 if (pBrowser)
723 {
724 BSTR bstrUrl;
725 if (SUCCEEDED(pBrowser->get_LocationURL(&bstrUrl)) && ::SysStringLen(b strUrl) > 0)
726 { 733 {
727 std::wstring url(bstrUrl, SysStringLen(bstrUrl)); 734 CComBSTR bstrUrl;
728 SysFreeString(bstrUrl); 735 if (SUCCEEDED(pBrowser->get_LocationURL(&bstrUrl)) && bstrUrl && ::S ysStringLen(bstrUrl) > 0)
729 UnescapeUrl(url); 736 {
730 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 }
731 } 741 }
732 } 742 }
733 } 743 }
734 } 744 break;
735 break; 745
736 746 case DISPID_ONQUIT:
737 case DISPID_ONQUIT: 747 case DISPID_QUIT:
738 case DISPID_QUIT: 748 {
739 { 749 Unadvice();
740 Unadvice(); 750 }
741 } 751 break;
742 break; 752
743 753 default:
744 default: 754 {
745 { 755 CString did;
746 CString did; 756 did.Format(L"DispId:%u", dispidMember);
747 did.Format(L"DispId:%u", dispidMember); 757
748 758 DEBUG_NAVI(L"Navi::Default " + did)
749 DEBUG_NAVI(L"Navi::Default " + did) 759 }
750 } 760 /*
751 761 * Ordinarily a method not dispatched should return DISP_E_MEMBERNOTFOUND.
752 // do nothing 762 * As a conservative initial change, we leave it behaving as before,
753 break; 763 * which is to do nothing and return S_OK.
754 } 764 */
755 765 // do nothing
756 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;
757 } 775 }
758 776
759 bool CPluginClass::InitObject(bool bBHO) 777 bool CPluginClass::InitObject(bool bBHO)
760 { 778 {
761 DEBUG_GENERAL("InitObject"); 779 DEBUG_GENERAL("InitObject");
762 CPluginSettings* settings = CPluginSettings::GetInstance(); 780 CPluginSettings* settings = CPluginSettings::GetInstance();
763 781
764 if (!settings->GetPluginEnabled()) 782 if (!settings->GetPluginEnabled())
765 { 783 {
766 s_mimeFilter->Unregister(); 784 s_mimeFilter->Unregister();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 } 816 }
799 } 817 }
800 } 818 }
801 s_criticalSectionLocal.Unlock(); 819 s_criticalSectionLocal.Unlock();
802 820
803 // Register pane class 821 // Register pane class
804 if (!GetAtomPaneClass()) 822 if (!GetAtomPaneClass())
805 { 823 {
806 WNDCLASSEX wcex; 824 WNDCLASSEX wcex;
807 825
808 wcex.cbSize = sizeof(WNDCLASSEX); 826 wcex.cbSize = sizeof(wcex);
809 wcex.style = 0; 827 wcex.style = 0;
810 wcex.lpfnWndProc = (WNDPROC)PaneWindowProc; 828 wcex.lpfnWndProc = (WNDPROC)PaneWindowProc;
811 wcex.cbClsExtra = 0; 829 wcex.cbClsExtra = 0;
812 wcex.cbWndExtra = 0; 830 wcex.cbWndExtra = 0;
813 wcex.hInstance = _Module.m_hInst; 831 wcex.hInstance = _Module.m_hInst;
814 wcex.hIcon = NULL; 832 wcex.hIcon = NULL;
815 wcex.hCursor = NULL; 833 wcex.hCursor = NULL;
816 wcex.hbrBackground = NULL; 834 wcex.hbrBackground = NULL;
817 wcex.lpszMenuName = NULL; 835 wcex.lpszMenuName = NULL;
818 wcex.lpszClassName = STATUSBAR_PANE_NAME; 836 wcex.lpszClassName = STATUSBAR_PANE_NAME;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 s_criticalSectionLocal.Unlock(); 892 s_criticalSectionLocal.Unlock();
875 return true; 893 return true;
876 } 894 }
877 895
878 bool CPluginClass::CreateStatusBarPane() 896 bool CPluginClass::CreateStatusBarPane()
879 { 897 {
880 CriticalSection::Lock lock(m_csStatusBar); 898 CriticalSection::Lock lock(m_csStatusBar);
881 899
882 CPluginClient* client = CPluginClient::GetInstance(); 900 CPluginClient* client = CPluginClient::GetInstance();
883 901
884 wchar_t szClassName[MAX_PATH]; 902 std::array<wchar_t, MAX_PATH> className;
885 // Get browser window and url 903 // Get browser window and url
886 HWND hBrowserWnd = GetBrowserHWND(); 904 HWND hBrowserWnd = GetBrowserHWND();
887 if (!hBrowserWnd) 905 if (!hBrowserWnd)
888 { 906 {
889 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")
890 return false; 908 return false;
891 } 909 }
892 910
893 // Looking for a TabWindowClass window in IE7 911 // Looking for a TabWindowClass window in IE7
894 // the last one should be parent for statusbar 912 // the last one should be parent for statusbar
895 HWND hWndStatusBar = NULL; 913 HWND hWndStatusBar = NULL;
896 914
897 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD); 915 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD);
898 UINT amoundOfNewTabs = 0; 916 UINT amoundOfNewTabs = 0;
899 HWND uniqueNewTab = NULL; 917 HWND uniqueNewTab = NULL;
900 while (hTabWnd) 918 while (hTabWnd)
901 { 919 {
902 memset(szClassName, 0, MAX_PATH); 920 className[0] = L'\0';
903 GetClassName(hTabWnd, szClassName, MAX_PATH); 921 // GetClassNameW returns the number of characters without '\0'
904 922 int classNameLength = GetClassNameW(hTabWnd, className.data(), className.siz e());
905 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))
906 { 925 {
907 // IE8 support 926 // IE8 support
908 HWND hTabWnd2 = hTabWnd; 927 HWND hTabWnd2 = hTabWnd;
909 if (wcscmp(szClassName,L"Frame Tab") == 0) 928 if (wcscmp(className.data(), L"Frame Tab") == 0)
910 { 929 {
911 hTabWnd2 = ::FindWindowEx(hTabWnd2, NULL, L"TabWindowClass", NULL); 930 hTabWnd2 = ::FindWindowEx(hTabWnd2, NULL, L"TabWindowClass", NULL);
912 } 931 }
913 932
914 if (hTabWnd2) 933 if (hTabWnd2)
915 { 934 {
916 DWORD nProcessId; 935 DWORD nProcessId;
917 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId); 936 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId);
918 if (::GetCurrentProcessId() == nProcessId) 937 if (::GetCurrentProcessId() == nProcessId)
919 { 938 {
(...skipping 26 matching lines...) Expand all
946 } 965 }
947 } 966 }
948 } 967 }
949 968
950 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); 969 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT);
951 } 970 }
952 971
953 HWND hWnd = ::GetWindow(hBrowserWnd, GW_CHILD); 972 HWND hWnd = ::GetWindow(hBrowserWnd, GW_CHILD);
954 while (hWnd) 973 while (hWnd)
955 { 974 {
956 memset(szClassName, 0, MAX_PATH); 975 className[0] = L'\0';
957 ::GetClassName(hWnd, szClassName, MAX_PATH); 976 int classNameLength = GetClassNameW(hWnd, className.data(), className.size() );
958 977
959 if (wcscmp(szClassName,L"msctls_statusbar32") == 0) 978 if (classNameLength && wcscmp(className.data(), L"msctls_statusbar32") == 0)
960 { 979 {
961 hWndStatusBar = hWnd; 980 hWndStatusBar = hWnd;
962 break; 981 break;
963 } 982 }
964 983
965 hWnd = ::GetWindow(hWnd, GW_HWNDNEXT); 984 hWnd = ::GetWindow(hWnd, GW_HWNDNEXT);
966 } 985 }
967 986
968 if (!hWndStatusBar) 987 if (!hWndStatusBar)
969 { 988 {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 HINSTANCE hInstance = _AtlBaseModule.GetModuleInstance(); 1165 HINSTANCE hInstance = _AtlBaseModule.GetModuleInstance();
1147 1166
1148 HMENU hMenu = ::LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1)); 1167 HMENU hMenu = ::LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1));
1149 1168
1150 HMENU hMenuTrackPopup = GetSubMenu(hMenu, 0); 1169 HMENU hMenuTrackPopup = GetSubMenu(hMenu, 0);
1151 1170
1152 SetMenuBar(hMenuTrackPopup, url); 1171 SetMenuBar(hMenuTrackPopup, url);
1153 1172
1154 return hMenuTrackPopup; 1173 return hMenuTrackPopup;
1155 } 1174 }
1156 BOOL CreateLowProcess(WCHAR* wszProcessName, WCHAR* cmdLine)
1157 {
1158
1159 BOOL fRet;
1160 HANDLE hToken = NULL;
1161 HANDLE hNewToken = NULL;
1162 PSID pIntegritySid = NULL;
1163 TOKEN_MANDATORY_LABEL TIL = {0};
1164 PROCESS_INFORMATION ProcInfo = {0};
1165 STARTUPINFO StartupInfo = {0};
1166
1167
1168
1169 // Low integrity SID
1170 WCHAR wszIntegritySid[20] = L"S-1-16-4096";
1171
1172
1173 fRet = OpenProcessToken(GetCurrentProcess(),
1174 TOKEN_DUPLICATE |
1175 TOKEN_ADJUST_DEFAULT |
1176 TOKEN_QUERY |
1177 TOKEN_ASSIGN_PRIMARY,
1178 &hToken);
1179
1180 if (!fRet)
1181 {
1182 goto CleanExit;
1183 }
1184
1185 fRet = DuplicateTokenEx(hToken,
1186 0,
1187 NULL,
1188 SecurityImpersonation,
1189 TokenPrimary,
1190 &hNewToken);
1191
1192 if (!fRet)
1193 {
1194 goto CleanExit;
1195 }
1196
1197 fRet = ConvertStringSidToSid(wszIntegritySid, &pIntegritySid);
1198
1199 if (!fRet)
1200 {
1201 goto CleanExit;
1202 }
1203
1204
1205 TIL.Label.Attributes = SE_GROUP_INTEGRITY;
1206 TIL.Label.Sid = pIntegritySid;
1207
1208
1209 //
1210 // Set the process integrity level
1211 //
1212
1213 fRet = SetTokenInformation(hNewToken,
1214 TokenIntegrityLevel,
1215 &TIL,
1216 sizeof(TOKEN_MANDATORY_LABEL) + GetLengthSid(pIntegritySid));
1217
1218 if (!fRet)
1219 {
1220 goto CleanExit;
1221 }
1222
1223 //
1224 // Create the new process at Low integrity
1225 //
1226
1227 fRet = CreateProcessAsUser(hNewToken,
1228 wszProcessName,
1229 cmdLine,
1230 NULL,
1231 NULL,
1232 FALSE,
1233 0,
1234 NULL,
1235 NULL,
1236 &StartupInfo,
1237 &ProcInfo);
1238
1239
1240 CleanExit:
1241
1242 if (ProcInfo.hProcess != NULL)
1243 {
1244 CloseHandle(ProcInfo.hProcess);
1245 }
1246
1247 if (ProcInfo.hThread != NULL)
1248 {
1249 CloseHandle(ProcInfo.hThread);
1250 }
1251
1252 LocalFree(pIntegritySid);
1253
1254 if (hNewToken != NULL)
1255 {
1256 CloseHandle(hNewToken);
1257 }
1258
1259 if (hToken != NULL)
1260 {
1261 CloseHandle(hToken);
1262 }
1263
1264 return fRet;
1265 }
1266 1175
1267 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)
1268 { 1177 {
1269 CPluginClient* client = CPluginClient::GetInstance(); 1178 CPluginClient* client = CPluginClient::GetInstance();
1270 1179
1271 // Create menu parent window 1180 // Create menu parent window
1272 HWND hMenuWnd = ::CreateWindowEx( 1181 HWND hMenuWnd = ::CreateWindowEx(
1273 NULL, 1182 NULL,
1274 MAKEINTATOM(GetAtomPaneClass()), 1183 MAKEINTATOM(GetAtomPaneClass()),
1275 L"", 1184 L"",
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 // Invalidate and redraw the control 1284 // Invalidate and redraw the control
1376 UpdateStatusBar(); 1285 UpdateStatusBar();
1377 } 1286 }
1378 1287
1379 1288
1380 bool CPluginClass::SetMenuBar(HMENU hMenu, const std::wstring& url) 1289 bool CPluginClass::SetMenuBar(HMENU hMenu, const std::wstring& url)
1381 { 1290 {
1382 DEBUG_GENERAL("SetMenuBar"); 1291 DEBUG_GENERAL("SetMenuBar");
1383 1292
1384 std::wstring ctext; 1293 std::wstring ctext;
1385
1386 s_criticalSectionLocal.Lock();
1387 {
1388 s_menuDomains.clear();
1389 }
1390 s_criticalSectionLocal.Unlock();
1391
1392 Dictionary* dictionary = Dictionary::GetInstance(); 1294 Dictionary* dictionary = Dictionary::GetInstance();
1393 1295
1394 MENUITEMINFOW fmii; 1296 MENUITEMINFOW fmii = {};
1395 memset(&fmii, 0, sizeof(MENUITEMINFO)); 1297 fmii.cbSize = sizeof(fmii);
1396 fmii.cbSize = sizeof(MENUITEMINFO); 1298
1397 1299 MENUITEMINFOW miiSep = {};
1398 MENUITEMINFOW miiSep; 1300 miiSep.cbSize = sizeof(miiSep);
1399 memset(&miiSep, 0, sizeof(MENUITEMINFO));
1400 miiSep.cbSize = sizeof(MENUITEMINFO);
1401 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE; 1301 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE;
1402 miiSep.fType = MFT_SEPARATOR; 1302 miiSep.fType = MFT_SEPARATOR;
1403 1303
1404 CPluginClient* client = CPluginClient::GetInstance(); 1304 CPluginClient* client = CPluginClient::GetInstance();
1405 CPluginSettings* settings = CPluginSettings::GetInstance(); 1305 CPluginSettings* settings = CPluginSettings::GetInstance();
1406 { 1306 {
1407 ctext = dictionary->Lookup("menu", "menu-disable-on-site"); 1307 ctext = dictionary->Lookup("menu", "menu-disable-on-site");
1408 // Is domain in white list? 1308 // Is domain in white list?
1409 ReplaceString(ctext, L"?1?", client->GetHostFromUrl(url)); 1309 ReplaceString(ctext, L"?1?", client->GetHostFromUrl(url));
1410 if (client->IsWhitelistedUrl(GetTab()->GetDocumentUrl())) 1310 if (client->IsWhitelistedUrl(GetTab()->GetDocumentUrl()))
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 DWORD nProcessId; 1385 DWORD nProcessId;
1486 ::GetWindowThreadProcessId(hWndToolBar, &nProcessId); 1386 ::GetWindowThreadProcessId(hWndToolBar, &nProcessId);
1487 1387
1488 if (hWndToolBar && ::GetCurrentProcessId() == nProcessId) 1388 if (hWndToolBar && ::GetCurrentProcessId() == nProcessId)
1489 { 1389 {
1490 ::ScreenToClient(hWndToolBar, &pt); 1390 ::ScreenToClient(hWndToolBar, &pt);
1491 int nButton = (int)::SendMessage(hWndToolBar, TB_HITTEST, 0, (LPARAM)&pt); 1391 int nButton = (int)::SendMessage(hWndToolBar, TB_HITTEST, 0, (LPARAM)&pt);
1492 1392
1493 if (nButton > 0) 1393 if (nButton > 0)
1494 { 1394 {
1495 TBBUTTON pTBBtn; 1395 TBBUTTON pTBBtn = {};
1496 memset(&pTBBtn, 0, sizeof(TBBUTTON));
1497 1396
1498 if (SendMessage(hWndToolBar, TB_GETBUTTON, nButton, (LPARAM)&pTBBtn)) 1397 if (SendMessage(hWndToolBar, TB_GETBUTTON, nButton, (LPARAM)&pTBBtn))
1499 { 1398 {
1500 RECT rcButton; 1399 RECT rcButton;
1501 nIDCommand = pTBBtn.idCommand; 1400 nIDCommand = pTBBtn.idCommand;
1502 1401
1503 if (SendMessage(hWndToolBar, TB_GETRECT, nIDCommand, (LPARAM)&rcButton)) 1402 if (SendMessage(hWndToolBar, TB_GETRECT, nIDCommand, (LPARAM)&rcButton))
1504 { 1403 {
1505 pt.x = rcButton.left; 1404 pt.x = rcButton.left;
1506 pt.y = rcButton.bottom; 1405 pt.y = rcButton.bottom;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 1523
1625 HICON CPluginClass::GetStatusBarIcon(const std::wstring& url) 1524 HICON CPluginClass::GetStatusBarIcon(const std::wstring& url)
1626 { 1525 {
1627 // 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
1628 HICON hIcon = GetIcon(ICON_PLUGIN_DEACTIVATED); 1527 HICON hIcon = GetIcon(ICON_PLUGIN_DEACTIVATED);
1629 1528
1630 CPluginTab* tab = GetTab(::GetCurrentThreadId()); 1529 CPluginTab* tab = GetTab(::GetCurrentThreadId());
1631 if (tab) 1530 if (tab)
1632 { 1531 {
1633 CPluginClient* client = CPluginClient::GetInstance(); 1532 CPluginClient* client = CPluginClient::GetInstance();
1634 if (!CPluginSettings::GetInstance()->IsPluginEnabled()) 1533 if (CPluginSettings::GetInstance()->IsPluginEnabled())
1635 { 1534 {
1636 } 1535 if (client->IsWhitelistedUrl(url))
1637 else if (client->IsWhitelistedUrl(url)) 1536 {
1638 { 1537 hIcon = GetIcon(ICON_PLUGIN_DISABLED);
1639 hIcon = GetIcon(ICON_PLUGIN_DISABLED); 1538 }
1640 } 1539 else
1641 else 1540 {
1642 { 1541 CPluginSettings* settings = CPluginSettings::GetInstance();
1643 CPluginSettings* settings = CPluginSettings::GetInstance(); 1542 hIcon = GetIcon(ICON_PLUGIN_ENABLED);
1644 hIcon = GetIcon(ICON_PLUGIN_ENABLED); 1543 }
1645 } 1544 }
1646 } 1545 }
1647 return hIcon; 1546 return hIcon;
1648 } 1547 }
1649 1548
1650 1549
1651 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)
1652 { 1551 {
1653 // Find tab 1552 // Find tab
1654 CPluginClass *pClass = FindInstance(GetParent(hWnd)); 1553 CPluginClass *pClass = FindInstance(GetParent(hWnd));
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 return icon; 1807 return icon;
1909 } 1808 }
1910 1809
1911 ATOM CPluginClass::GetAtomPaneClass() 1810 ATOM CPluginClass::GetAtomPaneClass()
1912 { 1811 {
1913 return s_atomPaneClass; 1812 return s_atomPaneClass;
1914 } 1813 }
1915 1814
1916 HWND CPluginClass::GetTabHWND() const 1815 HWND CPluginClass::GetTabHWND() const
1917 { 1816 {
1918 wchar_t szClassName[MAX_PATH]; 1817 std::array<wchar_t, MAX_PATH> className;
1919 // Get browser window and url 1818 // Get browser window and url
1920 HWND hBrowserWnd = GetBrowserHWND(); 1819 HWND hBrowserWnd = GetBrowserHWND();
1921 if (!hBrowserWnd) 1820 if (!hBrowserWnd)
1922 { 1821 {
1923 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")
1924 s_criticalSectionWindow.Unlock(); 1823 s_criticalSectionWindow.Unlock();
1925 1824
1926 return false; 1825 return false;
1927 } 1826 }
1928 1827
1929 // Looking for a TabWindowClass window in IE7 1828 // Looking for a TabWindowClass window in IE7
1930 1829
1931 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD); 1830 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD);
1932 while (hTabWnd) 1831 while (hTabWnd)
1933 { 1832 {
1934 memset(szClassName, 0, MAX_PATH); 1833 className[0] = L'\0';
1935 GetClassName(hTabWnd, szClassName, MAX_PATH); 1834 int classNameLength = GetClassNameW(hTabWnd, className.data(), className.siz e());
1936 1835
1937 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))
1938 { 1837 {
1939 // IE8 support 1838 // IE8 support
1940 HWND hTabWnd2 = hTabWnd; 1839 HWND hTabWnd2 = hTabWnd;
1941 if (wcscmp(szClassName, L"Frame Tab") == 0) 1840 if (wcscmp(className.data(), L"Frame Tab") == 0)
1942 { 1841 {
1943 hTabWnd2 = ::FindWindowEx(hTabWnd2, NULL, L"TabWindowClass", NULL); 1842 hTabWnd2 = ::FindWindowEx(hTabWnd2, NULL, L"TabWindowClass", NULL);
1944 } 1843 }
1945 1844
1946 if (hTabWnd2) 1845 if (hTabWnd2)
1947 { 1846 {
1948 DWORD nProcessId; 1847 DWORD nProcessId;
1949 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId); 1848 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId);
1950 if (::GetCurrentProcessId() == nProcessId) 1849 if (::GetCurrentProcessId() == nProcessId)
1951 { 1850 {
(...skipping 23 matching lines...) Expand all
1975 } 1874 }
1976 } 1875 }
1977 } 1876 }
1978 1877
1979 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); 1878 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT);
1980 } 1879 }
1981 1880
1982 return hTabWnd; 1881 return hTabWnd;
1983 1882
1984 } 1883 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld