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

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

Issue 6495401389588480: Issue #1173 - add exception handler to CPluginClass::Invoke (Closed)
Left Patch Set: Created Aug. 6, 2014, 9:32 p.m.
Right Patch Set: Created Oct. 2, 2014, 11:09 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
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifdef SUPPORT_FILTER 6 #ifdef SUPPORT_FILTER
7 #include "PluginFilter.h" 7 #include "PluginFilter.h"
8 #endif 8 #endif
9 #include "PluginMimeFilterClient.h" 9 #include "PluginMimeFilterClient.h"
10 #include "PluginClient.h" 10 #include "PluginClient.h"
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 { 387 {
388 s_instances.erase(this); 388 s_instances.erase(this);
389 389
390 std::map<DWORD,CPluginClass*>::iterator it = s_threadInstances.find(::GetC urrentThreadId()); 390 std::map<DWORD,CPluginClass*>::iterator it = s_threadInstances.find(::GetC urrentThreadId());
391 if (it != s_threadInstances.end()) 391 if (it != s_threadInstances.end())
392 { 392 {
393 s_threadInstances.erase(it); 393 s_threadInstances.erase(it);
394 } 394 }
395 if (s_instances.empty()) 395 if (s_instances.empty())
396 { 396 {
397 // AUDIT: Explicitly releasing a resource when a container becomes empty looks like a job better suited for shared_ptr 397 // TODO: Explicitly releasing a resource when a container becomes empty looks like a job better suited for shared_ptr
Oleksandr 2014/08/21 14:49:56 I think it's better to create an issue then to put
Eric 2014/09/29 19:16:44 Well, I don't know what the issue would be yet; I
Oleksandr 2014/10/02 20:44:16 How about TODO: then? On 2014/09/29 19:16:44, Eri
Eric 2014/10/02 23:11:02 OK.
398 CPluginClientFactory::ReleaseMimeFilterClientInstance(); 398 CPluginClientFactory::ReleaseMimeFilterClientInstance();
399 } 399 }
400 } 400 }
401 s_criticalSectionLocal.Unlock(); 401 s_criticalSectionLocal.Unlock();
402 402
403 // Release browser interface 403 // Release browser interface
404 s_criticalSectionBrowser.Lock(); 404 s_criticalSectionBrowser.Lock();
405 { 405 {
406 m_webBrowser2.Release(); 406 m_webBrowser2.Release();
407 } 407 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class ::Get statusbar state"); 525 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class ::Get statusbar state");
526 } 526 }
527 } 527 }
528 DEBUG_GENERAL("ShowStatusBar end"); 528 DEBUG_GENERAL("ShowStatusBar end");
529 } 529 }
530 530
531 /* 531 /*
532 * #1163 This class is the implementation for method DISPID_BEFORENAVIGATE2 in C PluginClass::Invoke. 532 * #1163 This class is the implementation for method DISPID_BEFORENAVIGATE2 in C PluginClass::Invoke.
533 * - It validates and convertes its own arguments, rather than unifying them in the Invoke body. 533 * - It validates and convertes its own arguments, rather than unifying them in the Invoke body.
534 * - It's declared void and not HRESULT, so DISPID_BEFORENAVIGATE2 can only retu rn S_OK. 534 * - It's declared void and not HRESULT, so DISPID_BEFORENAVIGATE2 can only retu rn S_OK.
535 */ 535 */
Oleksandr 2014/08/21 14:49:56 All the comments in this file that start with #116
Eric 2014/09/29 19:16:44 These comments are intended to exist only while #1
Oleksandr 2014/10/02 20:44:16 ok, as long as you'll be able to keep track of the
Eric 2014/10/02 23:11:02 No problem. That's what grep is for.
536 void CPluginClass::BeforeNavigate2(DISPPARAMS* pDispParams) 536 void CPluginClass::BeforeNavigate2(DISPPARAMS* pDispParams)
537 { 537 {
538 538
539 if (pDispParams->cArgs < 7) 539 if (pDispParams->cArgs < 7)
540 { 540 {
541 return; 541 return;
542 } 542 }
543 //Register a mime filter if it's not registered yet 543 //Register a mime filter if it's not registered yet
544 if (s_mimeFilter == NULL) 544 if (s_mimeFilter == NULL)
545 { 545 {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 UpdateStatusBar(); 625 UpdateStatusBar();
626 } 626 }
627 } 627 }
628 } 628 }
629 notificationMessage.Hide(); 629 notificationMessage.Hide();
630 DEBUG_GENERAL("Tab change end"); 630 DEBUG_GENERAL("Tab change end");
631 return S_OK; 631 return S_OK;
632 } 632 }
633 633
634 // This gets called whenever there's a browser event 634 // This gets called whenever there's a browser event
635 // ENTRY POINT
635 STDMETHODIMP CPluginClass::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, W ORD wFlags, DISPPARAMS* pDispParams, VARIANT* pvarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) 636 STDMETHODIMP CPluginClass::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, W ORD wFlags, DISPPARAMS* pDispParams, VARIANT* pvarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
636 { 637 {
637 // Entry point exception handler
Oleksandr 2014/08/21 14:49:56 Self-evident, IMHO
Eric 2014/09/29 19:16:44 I mentioned this in another review, but I'd like t
Eric 2014/10/02 23:11:02 Per a suggestion in another review, I'm changing t
638 try 638 try
639 { 639 {
640 WCHAR tmp[256]; 640 WCHAR tmp[256];
641 wsprintf(tmp, L"Invoke: %d\n", dispidMember); 641 wsprintf(tmp, L"Invoke: %d\n", dispidMember);
642 DEBUG_GENERAL(tmp); 642 DEBUG_GENERAL(tmp);
643 switch (dispidMember) 643 switch (dispidMember)
644 { 644 {
645 case DISPID_WINDOWSTATECHANGED: 645 case DISPID_WINDOWSTATECHANGED:
646 { 646 {
647 // #1163 should validate and convert arguments here 647 // #1163 should validate and convert arguments here
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 /* 769 /*
770 * Ordinarily a method not dispatched should return DISP_E_MEMBERNOTFOUND. 770 * Ordinarily a method not dispatched should return DISP_E_MEMBERNOTFOUND.
771 * As a conservative initial change, we leave it behaving as before, 771 * As a conservative initial change, we leave it behaving as before,
772 * which is to do nothing and return S_OK. 772 * which is to do nothing and return S_OK.
773 */ 773 */
774 // do nothing 774 // do nothing
775 break; 775 break;
776 } 776 }
777 } 777 }
778 catch(...) 778 catch(...)
779 { 779 {
Oleksandr 2014/08/21 14:49:56 Maybe let's log at least something first
Eric 2014/09/29 19:16:44 We could. Got a suggestion? Right now we've got no
Oleksandr 2014/10/02 20:44:16 Yes, I think it would be sufficient. We could in t
Eric 2014/10/02 23:11:02 OK. I just used DEBUG_GENERAL, lacking anything sp
780 DEBUG_GENERAL( "Caught unknown exception in CPluginClass::Invoke" );
780 return E_FAIL; 781 return E_FAIL;
781 } 782 }
782 return S_OK; 783 return S_OK;
783 } 784 }
784 785
785 bool CPluginClass::InitObject(bool bBHO) 786 bool CPluginClass::InitObject(bool bBHO)
786 { 787 {
787 DEBUG_GENERAL("InitObject"); 788 DEBUG_GENERAL("InitObject");
788 CPluginSettings* settings = CPluginSettings::GetInstance(); 789 CPluginSettings* settings = CPluginSettings::GetInstance();
789 790
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 } 859 }
859 860
860 861
861 int ieVersion = CPluginClient::GetInstance()->GetIEVersion(); 862 int ieVersion = CPluginClient::GetInstance()->GetIEVersion();
862 // Create status pane 863 // Create status pane
863 if (bBHO && ieVersion > 6 && !CreateStatusBarPane()) 864 if (bBHO && ieVersion > 6 && !CreateStatusBarPane())
864 { 865 {
865 return false; 866 return false;
866 } 867 }
867 868
868 if (CPluginClient::GetInstance()->IsFirstRun()) 869 s_criticalSectionLocal.Lock();
870 int versionCompRes = CPluginClient::GetInstance()->CompareVersions(CPluginClie nt::GetInstance()->GetPref(L"currentVersion", L"0.0"), L"1.2");
871
872 bool isFirstRun = CPluginClient::GetInstance()->IsFirstRun();
873 CPluginClient::GetInstance()->SetPref(L"currentVersion", std::wstring(IEPLUGIN _VERSION));
874 // This is the first time ABP was installed
875 // Or ABP was updated from the version that did not support Acceptable Ads (<1 .2)
876 if (isFirstRun || versionCompRes < 0)
869 { 877 {
878 if (!isFirstRun)
879 {
880 CPluginClient::GetInstance()->SetPref(L"displayUpdatePage", true);
881 }
882
Oleksandr 2014/10/03 08:31:50 I understand this was added here inadvertently, si
Oleksandr 2014/10/03 15:19:20 hm. Trying doing a diff for patchset 1 vs a patchs
Eric 2014/10/03 15:37:52 Ah. What you're seeing is an artifact of rebasing
870 // IE6 can't be accessed from another thread, execute in current thread 883 // IE6 can't be accessed from another thread, execute in current thread
871 if (ieVersion < 7) 884 if (ieVersion < 7)
872 { 885 {
873 FirstRunThread(); 886 FirstRunThread();
874 } 887 }
875 else 888 else
876 { 889 {
877 CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)CPluginClass::FirstRunThr ead, NULL, NULL, NULL); 890 CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)CPluginClass::FirstRunThr ead, NULL, NULL, NULL);
878 } 891 }
879 if ((m_hPaneWnd == NULL) || (!IsStatusBarEnabled())) 892 if (((m_hPaneWnd == NULL) || !IsStatusBarEnabled()) && isFirstRun)
880 { 893 {
881 ShowStatusBar(); 894 ShowStatusBar();
882 } 895 }
883 896
884 } 897 // Enable acceptable ads by default
898 std::wstring aaUrl = CPluginClient::GetInstance()->GetPref(L"subscriptions_e xceptionsurl", L"");
899 CPluginClient::GetInstance()->AddSubscription(aaUrl);
900 }
901 s_criticalSectionLocal.Unlock();
885 return true; 902 return true;
886 } 903 }
887 904
888 bool CPluginClass::CreateStatusBarPane() 905 bool CPluginClass::CreateStatusBarPane()
889 { 906 {
890 CriticalSection::Lock lock(m_csStatusBar); 907 CriticalSection::Lock lock(m_csStatusBar);
891 908
892 CPluginClient* client = CPluginClient::GetInstance(); 909 CPluginClient* client = CPluginClient::GetInstance();
893 910
894 wchar_t szClassName[MAX_PATH]; 911 wchar_t szClassName[MAX_PATH];
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
2003 } 2020 }
2004 } 2021 }
2005 } 2022 }
2006 2023
2007 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); 2024 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT);
2008 } 2025 }
2009 2026
2010 return hTabWnd; 2027 return hTabWnd;
2011 2028
2012 } 2029 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld