OLD | NEW |
1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
2 | 2 |
3 // Internet / FTP | 3 // Internet / FTP |
4 #include <wininet.h> | 4 #include <wininet.h> |
5 | 5 |
6 // IP adapter | 6 // IP adapter |
7 #include <iphlpapi.h> | 7 #include <iphlpapi.h> |
8 | 8 |
9 #include "PluginSettings.h" | 9 #include "PluginSettings.h" |
10 #include "PluginSystem.h" | 10 #include "PluginSystem.h" |
11 #include "PluginMutex.h" | 11 #include "PluginMutex.h" |
12 #include "PluginClass.h" | 12 #include "PluginClass.h" |
13 | 13 |
14 #include "PluginClientBase.h" | 14 #include "PluginClientBase.h" |
| 15 #include "PluginUtil.h" |
| 16 |
| 17 #include <ostream> |
| 18 #include <iomanip> |
15 | 19 |
16 // IP adapter | 20 // IP adapter |
17 #pragma comment(lib, "IPHLPAPI.lib") | 21 #pragma comment(lib, "IPHLPAPI.lib") |
18 | 22 |
19 // IE functions | 23 // IE functions |
20 #pragma comment(lib, "iepmapi.lib") | 24 #pragma comment(lib, "iepmapi.lib") |
21 | 25 |
22 // Internet / FTP | 26 // Internet / FTP |
23 #pragma comment(lib, "wininet.lib") | 27 #pragma comment(lib, "wininet.lib") |
24 | 28 |
25 | 29 |
26 CComAutoCriticalSection CPluginClientBase::s_criticalSectionLocal; | 30 CComAutoCriticalSection CPluginClientBase::s_criticalSectionLocal; |
27 | 31 |
28 std::vector<CPluginError> CPluginClientBase::s_pluginErrors; | 32 std::vector<CPluginError> CPluginClientBase::s_pluginErrors; |
29 | 33 |
30 bool CPluginClientBase::s_isErrorLogging = false; | 34 bool CPluginClientBase::s_isErrorLogging = false; |
31 | 35 |
32 | 36 |
33 CPluginClientBase::CPluginClientBase() | 37 CPluginClientBase::CPluginClientBase() |
34 { | 38 { |
35 } | 39 } |
36 | 40 |
37 | 41 |
38 CPluginClientBase::~CPluginClientBase() | 42 CPluginClientBase::~CPluginClientBase() |
39 { | 43 { |
40 } | 44 } |
41 | 45 |
42 | 46 |
43 bool CPluginClientBase::IsValidDomain(const CString& domain) | 47 bool CPluginClientBase::IsValidDomain(const std::wstring & domain) |
44 { | 48 { |
45 return domain != L"about:blank" && | 49 return domain != L"about:blank" && |
46 domain != L"about:tabs" && | 50 domain != L"about:tabs" && |
47 domain.Find(L"javascript:") != 0 && | 51 !ABP::util::begins_with( domain, L"javascript:" ) && |
48 !domain.IsEmpty(); | 52 !domain.empty(); |
49 } | 53 } |
50 | 54 |
51 | 55 |
52 CString& CPluginClientBase::UnescapeUrl(CString& url) | 56 void CPluginClientBase::LogPluginError(DWORD errorCode, int errorId, int errorSu
bid, const std::wstring & description, bool isAsync, DWORD dwProcessId, DWORD dw
ThreadId) |
53 { | |
54 CString unescapedUrl; | |
55 DWORD cb = 2048; | |
56 | |
57 if (SUCCEEDED(::UrlUnescape(url.GetBuffer(), unescapedUrl.GetBufferSetLength(c
b), &cb, 0))) | |
58 { | |
59 unescapedUrl.ReleaseBuffer(); | |
60 unescapedUrl.Truncate(cb); | |
61 | |
62 url.ReleaseBuffer(); | |
63 url = unescapedUrl; | |
64 } | |
65 | |
66 return url; | |
67 } | |
68 | |
69 | |
70 void CPluginClientBase::LogPluginError(DWORD errorCode, int errorId, int errorSu
bid, const CString& description, bool isAsync, DWORD dwProcessId, DWORD dwThread
Id) | |
71 { | 57 { |
72 // Prevent circular references | 58 // Prevent circular references |
73 if (CPluginSettings::HasInstance() && isAsync) | 59 if (CPluginSettings::HasInstance() && isAsync) |
74 { | 60 { |
75 DEBUG_ERROR_CODE_EX(errorCode, description, dwProcessId, dwThreadId); | 61 DEBUG_ERROR_CODE_EX(errorCode, description, dwProcessId, dwThreadId); |
76 | 62 |
77 CString pluginError; | 63 std::wostringstream message ; |
78 pluginError.Format(L"%2.2d%2.2d", errorId, errorSubid); | 64 message << std::setfill( L'0' ); |
| 65 message << std::setw(2) << errorId; |
| 66 message << std::setw(2) << errorSubid; |
| 67 std::wstring error = message.str(); |
79 | 68 |
80 CString pluginErrorCode; | 69 message = std::wostringstream(); |
81 pluginErrorCode.Format(L"%u", errorCode); | 70 message << L"0x" << std::hex << errorCode; |
| 71 std::wstring error_code = message.str(); |
82 | 72 |
83 CPluginSettings* settings = CPluginSettings::GetInstance(); | 73 CPluginSettings::GetInstance()->AddError(error, error_code); |
84 | |
85 settings->AddError(pluginError, pluginErrorCode); | |
86 } | 74 } |
87 | 75 |
88 // Post error to client for later submittal | 76 // Post error to client for later submittal |
89 if (!isAsync) | 77 if (!isAsync) |
90 { | 78 { |
91 CPluginClientBase::PostPluginError(errorId, errorSubid, errorCode, descripti
on); | 79 CPluginClientBase::PostPluginError(errorId, errorSubid, errorCode, descripti
on); |
92 } | 80 } |
93 } | 81 } |
94 | 82 |
95 | 83 |
96 void CPluginClientBase::PostPluginError(int errorId, int errorSubid, DWORD error
Code, const CString& errorDescription) | 84 void CPluginClientBase::PostPluginError(int errorId, int errorSubid, DWORD error
Code, const std::wstring & errorDescription) |
97 { | 85 { |
98 s_criticalSectionLocal.Lock(); | 86 s_criticalSectionLocal.Lock(); |
99 { | 87 { |
100 CPluginError pluginError(errorId, errorSubid, errorCode, errorDescription); | 88 CPluginError pluginError(errorId, errorSubid, errorCode, errorDescription); |
101 | 89 |
102 s_pluginErrors.push_back(pluginError); | 90 s_pluginErrors.push_back(pluginError); |
103 } | 91 } |
104 s_criticalSectionLocal.Unlock(); | 92 s_criticalSectionLocal.Unlock(); |
105 } | 93 } |
106 | 94 |
(...skipping 11 matching lines...) Expand all Loading... |
118 | 106 |
119 hasError = true; | 107 hasError = true; |
120 | 108 |
121 s_pluginErrors.erase(it); | 109 s_pluginErrors.erase(it); |
122 } | 110 } |
123 } | 111 } |
124 s_criticalSectionLocal.Unlock(); | 112 s_criticalSectionLocal.Unlock(); |
125 | 113 |
126 return hasError; | 114 return hasError; |
127 } | 115 } |
OLD | NEW |