Left: | ||
Right: |
OLD | NEW |
---|---|
1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
2 #include "PluginSettings.h" | 2 #include "PluginSettings.h" |
3 #include "PluginSystem.h" | 3 #include "PluginSystem.h" |
4 #include "PluginFilter.h" | 4 #include "PluginFilter.h" |
5 #include "PluginClientFactory.h" | 5 #include "PluginClientFactory.h" |
6 #include "PluginMutex.h" | 6 #include "PluginMutex.h" |
7 #include "PluginClass.h" | 7 #include "PluginClass.h" |
8 | 8 |
9 #include "AdblockPlusClient.h" | 9 #include "AdblockPlusClient.h" |
10 | 10 |
11 #include "../shared/Utils.h" | 11 #include "../shared/Utils.h" |
12 | 12 |
13 #include <memory> | |
14 | |
13 namespace | 15 namespace |
14 { | 16 { |
17 /** | |
18 * A temporary wchar buffer, initialized from a wstring. | |
19 * Used to pass parameters to CreateProcess* API functions, which may modify t he buffer contents. | |
20 * | |
21 * This class is a wrapper around unique_ptr. | |
22 */ | |
23 class temporary_wchar_buffer { | |
sergei
2014/07/08 11:58:34
Despite below it's mentioned that we can proceed e
Eric
2014/07/08 17:46:37
On 2014/07/08 11:58:34, sergei wrote:
< this class
| |
24 /** | |
25 * Length of input string, not including terminating null character. | |
26 */ | |
27 size_t len ; | |
28 | |
29 /** | |
30 * The underlying unique_ptr | |
31 */ | |
32 std::unique_ptr< wchar_t[] > buffer ; | |
Oleksandr
2014/06/26 00:48:43
Nit: Here and in other places no space after < and
| |
33 | |
34 public: | |
35 /** | |
36 * Ordinary constructor. | |
37 */ | |
38 temporary_wchar_buffer( std::wstring s ) | |
sergei
2014/07/08 11:58:34
Just in case, it's safer to have such constructors
Eric
2014/07/08 17:46:37
I have no problem with that.
| |
39 : len( s.length() ), buffer( new wchar_t[ len + 1 ] ) | |
40 { | |
41 s.copy( buffer.get(), len ); | |
42 buffer[ len ] = L'\0' ; | |
43 } | |
44 | |
45 /** | |
46 * Conversion operator returns pointer to allocated buffer. | |
47 */ | |
48 operator wchar_t *() | |
49 { | |
50 return buffer.get(); | |
51 } | |
52 }; | |
53 | |
15 void SpawnAdblockPlusEngine() | 54 void SpawnAdblockPlusEngine() |
16 { | 55 { |
17 std::wstring engineExecutablePath = GetDllDir() + L"AdblockPlusEngine.exe"; | 56 std::wstring engineExecutablePath = GetDllDir() + L"AdblockPlusEngine.exe"; |
18 CString params = L"AdblockPlusEngine.exe " + CPluginSystem::GetInstance()->G etBrowserLanguage(); | 57 temporary_wchar_buffer params( L"AdblockPlusEngine.exe " + CPluginSystem::Ge tInstance()->GetBrowserLanguage() ); |
19 | 58 |
20 STARTUPINFO startupInfo = {}; | 59 STARTUPINFO startupInfo = {}; |
21 PROCESS_INFORMATION processInformation = {}; | 60 PROCESS_INFORMATION processInformation = {}; |
22 | 61 |
23 HANDLE token; | 62 HANDLE token; |
24 OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE | TOKEN_ADJUST_DEFAULT | TOKEN_QUERY | TOKEN_ASSIGN_PRIMARY, &token); | 63 OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE | TOKEN_ADJUST_DEFAULT | TOKEN_QUERY | TOKEN_ASSIGN_PRIMARY, &token); |
25 | 64 |
26 TOKEN_APPCONTAINER_INFORMATION *acs = NULL; | 65 TOKEN_APPCONTAINER_INFORMATION *acs = NULL; |
27 DWORD length = 0; | 66 DWORD length = 0; |
28 | 67 |
(...skipping 10 matching lines...) Expand all Loading... | |
39 throw std::runtime_error("Out of memory"); | 78 throw std::runtime_error("Out of memory"); |
40 } | 79 } |
41 } | 80 } |
42 | 81 |
43 BOOL createProcRes = 0; | 82 BOOL createProcRes = 0; |
44 // Running inside AppContainer or in Windows XP | 83 // Running inside AppContainer or in Windows XP |
45 if ((acs != NULL && acs->TokenAppContainer != NULL) || (!IsWindowsVistaOrLat er())) | 84 if ((acs != NULL && acs->TokenAppContainer != NULL) || (!IsWindowsVistaOrLat er())) |
46 { | 85 { |
47 // We need to break out from AppContainer. Launch with default security - registry entry will eat the user prompt | 86 // We need to break out from AppContainer. Launch with default security - registry entry will eat the user prompt |
48 // See http://msdn.microsoft.com/en-us/library/bb250462(v=vs.85).aspx#wpm_ elebp | 87 // See http://msdn.microsoft.com/en-us/library/bb250462(v=vs.85).aspx#wpm_ elebp |
49 createProcRes = CreateProcessW(engineExecutablePath.c_str(), params.GetBuf fer(params.GetLength() + 1), | 88 createProcRes = CreateProcessW(engineExecutablePath.c_str(), (LPWSTR) para ms, |
Oleksandr
2014/06/26 00:48:43
We've had a similar issue (a need to get a writabl
Eric
2014/06/26 15:13:56
This issue is not contiguous memory. Rather, it's
Felix Dahlke
2014/06/30 13:35:39
c_str() returns a const char, but we using ¶ms
sergei
2014/07/08 11:58:34
I also vote for `¶ms[0]`.
Eric
2014/07/08 17:46:37
We have two issues:
1) Contiguous memory.
2) Writa
| |
50 0, 0, false, 0, 0, 0, (STARTUPINFOW*)&startupInfo, &processInformation); | 89 0, 0, false, 0, 0, 0, (STARTUPINFOW*)&startupInfo, &processInformation); |
51 } | 90 } |
52 else | 91 else |
53 { | 92 { |
54 // Launch with Low Integrity explicitly | 93 // Launch with Low Integrity explicitly |
55 HANDLE newToken; | 94 HANDLE newToken; |
56 DuplicateTokenEx(token, 0, 0, SecurityImpersonation, TokenPrimary, &newTok en); | 95 DuplicateTokenEx(token, 0, 0, SecurityImpersonation, TokenPrimary, &newTok en); |
57 | 96 |
58 PSID integritySid = 0; | 97 PSID integritySid = 0; |
59 ConvertStringSidToSid(L"S-1-16-4096", &integritySid); | 98 ConvertStringSidToSid(L"S-1-16-4096", &integritySid); |
60 std::tr1::shared_ptr<SID> sharedIntegritySid(static_cast<SID*>(integritySi d), FreeSid); // Just to simplify cleanup | 99 std::tr1::shared_ptr<SID> sharedIntegritySid(static_cast<SID*>(integritySi d), FreeSid); // Just to simplify cleanup |
61 | 100 |
62 TOKEN_MANDATORY_LABEL tml = {}; | 101 TOKEN_MANDATORY_LABEL tml = {}; |
63 tml.Label.Attributes = SE_GROUP_INTEGRITY; | 102 tml.Label.Attributes = SE_GROUP_INTEGRITY; |
64 tml.Label.Sid = integritySid; | 103 tml.Label.Sid = integritySid; |
65 | 104 |
66 // Set the process integrity level | 105 // Set the process integrity level |
67 SetTokenInformation(newToken, TokenIntegrityLevel, &tml, sizeof(TOKEN_MAND ATORY_LABEL) + GetLengthSid(integritySid)); | 106 SetTokenInformation(newToken, TokenIntegrityLevel, &tml, sizeof(TOKEN_MAND ATORY_LABEL) + GetLengthSid(integritySid)); |
68 | 107 |
69 STARTUPINFO startupInfo = {}; | 108 STARTUPINFO startupInfo = {}; |
70 PROCESS_INFORMATION processInformation = {}; | 109 PROCESS_INFORMATION processInformation = {}; |
71 | 110 |
72 createProcRes = CreateProcessAsUserW(newToken, engineExecutablePath.c_str( ), params.GetBuffer(params.GetLength() + 1), | 111 createProcRes = CreateProcessAsUserW(newToken, engineExecutablePath.c_str( ), (LPWSTR) params, |
sergei
2014/07/08 11:58:34
First of all, the compile should understand that t
Eric
2014/07/08 17:46:37
I have to admit that the C-style cast is copied fr
| |
73 0, 0, false, 0, 0, 0, (STARTUPINFOW*)&startupInfo, &processInformation); | 112 0, 0, false, 0, 0, 0, (STARTUPINFOW*)&startupInfo, &processInformation); |
74 } | 113 } |
75 | 114 |
76 if (!createProcRes) | 115 if (!createProcRes) |
77 { | 116 { |
78 throw std::runtime_error("Failed to start Adblock Plus Engine"); | 117 throw std::runtime_error("Failed to start Adblock Plus Engine"); |
79 } | 118 } |
80 | 119 |
81 CloseHandle(processInformation.hProcess); | 120 CloseHandle(processInformation.hProcess); |
82 CloseHandle(processInformation.hThread); | 121 CloseHandle(processInformation.hThread); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 | 189 |
151 CAdblockPlusClient* CAdblockPlusClient::s_instance = NULL; | 190 CAdblockPlusClient* CAdblockPlusClient::s_instance = NULL; |
152 | 191 |
153 CAdblockPlusClient::CAdblockPlusClient() : CPluginClientBase() | 192 CAdblockPlusClient::CAdblockPlusClient() : CPluginClientBase() |
154 { | 193 { |
155 m_filter = std::auto_ptr<CPluginFilter>(new CPluginFilter()); | 194 m_filter = std::auto_ptr<CPluginFilter>(new CPluginFilter()); |
156 } | 195 } |
157 | 196 |
158 bool CAdblockPlusClient::CallEngine(Communication::OutputBuffer& message, Commun ication::InputBuffer& inputBuffer) | 197 bool CAdblockPlusClient::CallEngine(Communication::OutputBuffer& message, Commun ication::InputBuffer& inputBuffer) |
159 { | 198 { |
160 DEBUG_GENERAL("CallEngine start"); | 199 DEBUG_GENERAL(L"CallEngine start"); |
161 CriticalSection::Lock lock(enginePipeLock); | 200 CriticalSection::Lock lock(enginePipeLock); |
162 try | 201 try |
163 { | 202 { |
164 if (!enginePipe) | 203 if (!enginePipe) |
165 enginePipe.reset(OpenEnginePipe()); | 204 enginePipe.reset(OpenEnginePipe()); |
166 enginePipe->WriteMessage(message); | 205 enginePipe->WriteMessage(message); |
167 inputBuffer = enginePipe->ReadMessage(); | 206 inputBuffer = enginePipe->ReadMessage(); |
168 } | 207 } |
169 catch (const std::exception& e) | 208 catch (const std::exception& e) |
170 { | 209 { |
171 DEBUG_GENERAL(e.what()); | 210 DEBUG_GENERAL( ABP::debug::widen( e.what() ) ); |
172 return false; | 211 return false; |
173 } | 212 } |
174 DEBUG_GENERAL("CallEngine end"); | 213 DEBUG_GENERAL(L"CallEngine end"); |
175 return true; | 214 return true; |
176 } | 215 } |
177 | 216 |
178 bool CAdblockPlusClient::CallEngine(Communication::ProcType proc, Communication: :InputBuffer& inputBuffer) | 217 bool CAdblockPlusClient::CallEngine(Communication::ProcType proc, Communication: :InputBuffer& inputBuffer) |
179 { | 218 { |
180 Communication::OutputBuffer message; | 219 Communication::OutputBuffer message; |
181 message << proc; | 220 message << proc; |
182 return CallEngine(message, inputBuffer); | 221 return CallEngine(message, inputBuffer); |
183 } | 222 } |
184 | 223 |
(...skipping 17 matching lines...) Expand all Loading... | |
202 } | 241 } |
203 | 242 |
204 instance = s_instance; | 243 instance = s_instance; |
205 } | 244 } |
206 s_criticalSectionLocal.Unlock(); | 245 s_criticalSectionLocal.Unlock(); |
207 | 246 |
208 return instance; | 247 return instance; |
209 } | 248 } |
210 | 249 |
211 | 250 |
212 bool CAdblockPlusClient::ShouldBlock(CString src, int contentType, const CString & domain, bool addDebug) | 251 bool CAdblockPlusClient::ShouldBlock( std::wstring src, int contentType, const s td::wstring & domain, bool addDebug) |
Oleksandr
2014/06/26 00:48:43
Nit: no space after const std::wstring
| |
213 { | 252 { |
214 bool isBlocked = false; | 253 bool isBlocked = false; |
215 | 254 |
216 bool isCached = false; | 255 bool isCached = false; |
217 | 256 |
218 CPluginSettings* settings = CPluginSettings::GetInstance(); | 257 CPluginSettings* settings = CPluginSettings::GetInstance(); |
219 | 258 |
220 m_criticalSectionCache.Lock(); | 259 m_criticalSectionCache.Lock(); |
221 { | 260 { |
222 std::map<CString,bool>::iterator it = m_cacheBlockedSources.find(src); | 261 std::map< std::wstring, bool >::iterator it = m_cacheBlockedSources.find(src ); |
223 | 262 |
224 isCached = it != m_cacheBlockedSources.end(); | 263 isCached = it != m_cacheBlockedSources.end(); |
225 if (isCached) | 264 if (isCached) |
226 { | 265 { |
227 isBlocked = it->second; | 266 isBlocked = it->second; |
228 } | 267 } |
229 } | 268 } |
230 m_criticalSectionCache.Unlock(); | 269 m_criticalSectionCache.Unlock(); |
231 | 270 |
232 if (!isCached) | 271 if (!isCached) |
(...skipping 13 matching lines...) Expand all Loading... | |
246 m_cacheBlockedSources[src] = isBlocked; | 285 m_cacheBlockedSources[src] = isBlocked; |
247 } | 286 } |
248 m_criticalSectionCache.Unlock(); | 287 m_criticalSectionCache.Unlock(); |
249 } | 288 } |
250 } | 289 } |
251 | 290 |
252 | 291 |
253 return isBlocked; | 292 return isBlocked; |
254 } | 293 } |
255 | 294 |
256 bool CAdblockPlusClient::IsElementHidden(const CString& tag, IHTMLElement* pEl, const CString& domain, const CString& indent, CPluginFilter* filter) | 295 bool CAdblockPlusClient::IsElementHidden(const std::wstring & tag, IHTMLElement* pEl, const std::wstring & domain, const std::wstring & indent, CPluginFilter* f ilter) |
257 { | 296 { |
258 bool isHidden; | 297 bool isHidden; |
259 m_criticalSectionFilter.Lock(); | 298 m_criticalSectionFilter.Lock(); |
260 { | 299 { |
261 isHidden = filter && filter->IsElementHidden(tag, pEl, domain, indent); | 300 isHidden = filter && filter->IsElementHidden(tag, pEl, domain, indent); |
262 } | 301 } |
263 m_criticalSectionFilter.Unlock(); | 302 m_criticalSectionFilter.Unlock(); |
264 return isHidden; | 303 return isHidden; |
265 } | 304 } |
266 | 305 |
267 bool CAdblockPlusClient::IsWhitelistedUrl(const std::wstring& url) | 306 bool CAdblockPlusClient::IsWhitelistedUrl(const std::wstring& url) |
268 { | 307 { |
269 DEBUG_GENERAL((L"IsWhitelistedUrl: " + url + L" start").c_str()); | 308 DEBUG_GENERAL(L"IsWhitelistedUrl: " + url + L" start"); |
270 Communication::OutputBuffer request; | 309 Communication::OutputBuffer request; |
271 request << Communication::PROC_IS_WHITELISTED_URL << ToUtf8String(url); | 310 request << Communication::PROC_IS_WHITELISTED_URL << ToUtf8String(url); |
272 | 311 |
273 Communication::InputBuffer response; | 312 Communication::InputBuffer response; |
274 if (!CallEngine(request, response)) | 313 if (!CallEngine(request, response)) |
275 return false; | 314 return false; |
276 | 315 |
277 bool isWhitelisted; | 316 bool isWhitelisted; |
278 response >> isWhitelisted; | 317 response >> isWhitelisted; |
279 | 318 |
280 DEBUG_GENERAL((L"IsWhitelistedUrl: " + url + L" end").c_str()); | 319 DEBUG_GENERAL(L"IsWhitelistedUrl: " + url + L" end"); |
281 return isWhitelisted; | 320 return isWhitelisted; |
282 } | 321 } |
283 | 322 |
284 int CAdblockPlusClient::GetIEVersion() | 323 int CAdblockPlusClient::GetIEVersion() |
285 { | 324 { |
286 //HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer | 325 //HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer |
287 HKEY hKey; | 326 HKEY hKey; |
288 LSTATUS status = RegOpenKey(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Interne t Explorer", &hKey); | 327 LSTATUS status = RegOpenKey(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Interne t Explorer", &hKey); |
289 if (status != 0) | 328 if (status != 0) |
290 { | 329 { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
358 std::vector<std::wstring> CAdblockPlusClient::GetExceptionDomains() | 397 std::vector<std::wstring> CAdblockPlusClient::GetExceptionDomains() |
359 { | 398 { |
360 Communication::InputBuffer response; | 399 Communication::InputBuffer response; |
361 if (!CallEngine(Communication::PROC_GET_EXCEPTION_DOMAINS, response)) | 400 if (!CallEngine(Communication::PROC_GET_EXCEPTION_DOMAINS, response)) |
362 return std::vector<std::wstring>(); | 401 return std::vector<std::wstring>(); |
363 return ReadStrings(response); | 402 return ReadStrings(response); |
364 } | 403 } |
365 | 404 |
366 bool CAdblockPlusClient::IsFirstRun() | 405 bool CAdblockPlusClient::IsFirstRun() |
367 { | 406 { |
368 DEBUG_GENERAL("IsFirstRun"); | 407 DEBUG_GENERAL(L"IsFirstRun"); |
369 Communication::InputBuffer response; | 408 Communication::InputBuffer response; |
370 if (!CallEngine(Communication::PROC_IS_FIRST_RUN_ACTION_NEEDED, response)) ret urn false; | 409 if (!CallEngine(Communication::PROC_IS_FIRST_RUN_ACTION_NEEDED, response)) ret urn false; |
371 bool res; | 410 bool res; |
372 response >> res; | 411 response >> res; |
373 return res; | 412 return res; |
374 } | 413 } |
375 void CAdblockPlusClient::AddFilter(const std::wstring& text) | 414 void CAdblockPlusClient::AddFilter(const std::wstring& text) |
376 { | 415 { |
377 Communication::OutputBuffer request; | 416 Communication::OutputBuffer request; |
378 request << Communication::PROC_ADD_FILTER << ToUtf8String(text); | 417 request << Communication::PROC_ADD_FILTER << ToUtf8String(text); |
(...skipping 27 matching lines...) Expand all Loading... | |
406 request << Communication::PROC_SET_PREF << ToUtf8String(name) << value; | 445 request << Communication::PROC_SET_PREF << ToUtf8String(name) << value; |
407 CallEngine(request); | 446 CallEngine(request); |
408 } | 447 } |
409 | 448 |
410 std::wstring CAdblockPlusClient::GetPref(const std::wstring& name, const wchar_t * defaultValue) | 449 std::wstring CAdblockPlusClient::GetPref(const std::wstring& name, const wchar_t * defaultValue) |
411 { | 450 { |
412 return GetPref(name, std::wstring(defaultValue)); | 451 return GetPref(name, std::wstring(defaultValue)); |
413 } | 452 } |
414 std::wstring CAdblockPlusClient::GetPref(const std::wstring& name, const std::ws tring& defaultValue) | 453 std::wstring CAdblockPlusClient::GetPref(const std::wstring& name, const std::ws tring& defaultValue) |
415 { | 454 { |
416 DEBUG_GENERAL((L"GetPref: " + name + L" start").c_str()); | 455 DEBUG_GENERAL(L"GetPref: " + name + L" start"); |
417 Communication::OutputBuffer request; | 456 Communication::OutputBuffer request; |
418 request << Communication::PROC_GET_PREF << ToUtf8String(name); | 457 request << Communication::PROC_GET_PREF << ToUtf8String(name); |
419 | 458 |
420 Communication::InputBuffer response; | 459 Communication::InputBuffer response; |
421 if (!CallEngine(request, response)) | 460 if (!CallEngine(request, response)) |
422 return defaultValue; | 461 return defaultValue; |
423 bool success; | 462 bool success; |
424 response >> success; | 463 response >> success; |
425 if (success) | 464 if (success) |
426 { | 465 { |
427 std::string value; | 466 std::string value; |
428 response >> value; | 467 response >> value; |
429 DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str()); | 468 DEBUG_GENERAL(L"GetPref: " + name + L" end"); |
430 return ToUtf16String(value); | 469 return ToUtf16String(value); |
431 } | 470 } |
432 else | 471 else |
433 { | 472 { |
434 DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str()); | 473 DEBUG_GENERAL(L"GetPref: " + name + L" end"); |
435 return defaultValue; | 474 return defaultValue; |
436 } | 475 } |
437 } | 476 } |
438 | 477 |
439 bool CAdblockPlusClient::GetPref(const std::wstring& name, bool defaultValue) | 478 bool CAdblockPlusClient::GetPref(const std::wstring& name, bool defaultValue) |
440 { | 479 { |
441 DEBUG_GENERAL((L"GetPref: " + name + L" start").c_str()); | 480 DEBUG_GENERAL(L"GetPref: " + name + L" start"); |
442 Communication::OutputBuffer request; | 481 Communication::OutputBuffer request; |
443 request << Communication::PROC_GET_PREF << ToUtf8String(name); | 482 request << Communication::PROC_GET_PREF << ToUtf8String(name); |
444 | 483 |
445 Communication::InputBuffer response; | 484 Communication::InputBuffer response; |
446 if (!CallEngine(request, response)) | 485 if (!CallEngine(request, response)) |
447 return defaultValue; | 486 return defaultValue; |
448 bool success; | 487 bool success; |
449 response >> success; | 488 response >> success; |
450 if (success) | 489 if (success) |
451 { | 490 { |
452 bool value; | 491 bool value; |
453 response >> value; | 492 response >> value; |
454 DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str()); | 493 DEBUG_GENERAL(L"GetPref: " + name + L" end"); |
455 return value; | 494 return value; |
456 } | 495 } |
457 else | 496 else |
458 { | 497 { |
459 DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str()); | 498 DEBUG_GENERAL(L"GetPref: " + name + L" end"); |
460 return defaultValue; | 499 return defaultValue; |
461 } | 500 } |
462 } | 501 } |
463 int64_t CAdblockPlusClient::GetPref(const std::wstring& name, int64_t defaultVal ue) | 502 int64_t CAdblockPlusClient::GetPref(const std::wstring& name, int64_t defaultVal ue) |
464 { | 503 { |
465 DEBUG_GENERAL((L"GetPref: " + name + L" start").c_str()); | 504 DEBUG_GENERAL(L"GetPref: " + name + L" start"); |
466 Communication::OutputBuffer request; | 505 Communication::OutputBuffer request; |
467 request << Communication::PROC_GET_PREF << ToUtf8String(name); | 506 request << Communication::PROC_GET_PREF << ToUtf8String(name); |
468 | 507 |
469 Communication::InputBuffer response; | 508 Communication::InputBuffer response; |
470 if (!CallEngine(request, response)) | 509 if (!CallEngine(request, response)) |
471 return defaultValue; | 510 return defaultValue; |
472 bool success; | 511 bool success; |
473 response >> success; | 512 response >> success; |
474 if (success) | 513 if (success) |
475 { | 514 { |
476 int64_t value; | 515 int64_t value; |
477 response >> value; | 516 response >> value; |
478 DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str()); | 517 DEBUG_GENERAL(L"GetPref: " + name + L" end"); |
479 return value; | 518 return value; |
480 } | 519 } |
481 else | 520 else |
482 { | 521 { |
483 DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str()); | 522 DEBUG_GENERAL(L"GetPref: " + name + L" end"); |
484 return defaultValue; | 523 return defaultValue; |
485 } | 524 } |
486 } | 525 } |
487 | 526 |
488 void CAdblockPlusClient::CheckForUpdates(HWND callbackWindow) | 527 void CAdblockPlusClient::CheckForUpdates(HWND callbackWindow) |
489 { | 528 { |
490 Communication::OutputBuffer request; | 529 Communication::OutputBuffer request; |
491 request << Communication::PROC_CHECK_FOR_UPDATES << reinterpret_cast<int32_t>( callbackWindow); | 530 request << Communication::PROC_CHECK_FOR_UPDATES << reinterpret_cast<int32_t>( callbackWindow); |
492 CallEngine(request); | 531 CallEngine(request); |
493 } | 532 } |
494 | 533 |
495 std::wstring CAdblockPlusClient::GetDocumentationLink() | 534 std::wstring CAdblockPlusClient::GetDocumentationLink() |
496 { | 535 { |
497 DEBUG_GENERAL("GetDocumentationLink"); | 536 DEBUG_GENERAL(L"GetDocumentationLink"); |
498 Communication::InputBuffer response; | 537 Communication::InputBuffer response; |
499 if (!CallEngine(Communication::PROC_GET_DOCUMENTATION_LINK, response)) | 538 if (!CallEngine(Communication::PROC_GET_DOCUMENTATION_LINK, response)) |
500 return L""; | 539 return L""; |
501 std::wstring docLink; | 540 std::wstring docLink; |
502 response >> docLink; | 541 response >> docLink; |
503 return docLink; | 542 return docLink; |
504 } | 543 } |
505 | 544 |
506 bool CAdblockPlusClient::TogglePluginEnabled() | 545 bool CAdblockPlusClient::TogglePluginEnabled() |
507 { | 546 { |
508 DEBUG_GENERAL("TogglePluginEnabled"); | 547 DEBUG_GENERAL(L"TogglePluginEnabled"); |
509 Communication::InputBuffer response; | 548 Communication::InputBuffer response; |
510 if (!CallEngine(Communication::PROC_TOGGLE_PLUGIN_ENABLED, response)) | 549 if (!CallEngine(Communication::PROC_TOGGLE_PLUGIN_ENABLED, response)) |
511 return false; | 550 return false; |
512 bool currentEnabledState; | 551 bool currentEnabledState; |
513 response >> currentEnabledState; | 552 response >> currentEnabledState; |
514 return currentEnabledState; | 553 return currentEnabledState; |
515 } | 554 } |
516 std::wstring CAdblockPlusClient::GetHostFromUrl(const std::wstring& url) | 555 std::wstring CAdblockPlusClient::GetHostFromUrl(const std::wstring& url) |
517 { | 556 { |
518 DEBUG_GENERAL("GetHostFromUrl"); | 557 DEBUG_GENERAL(L"GetHostFromUrl"); |
519 Communication::OutputBuffer request; | 558 Communication::OutputBuffer request; |
520 request << Communication::PROC_GET_HOST << ToUtf8String(url); | 559 request << Communication::PROC_GET_HOST << ToUtf8String(url); |
521 | 560 |
522 Communication::InputBuffer response; | 561 Communication::InputBuffer response; |
523 if (!CallEngine(request, response)) | 562 if (!CallEngine(request, response)) |
524 return L""; | 563 return L""; |
525 std::string host; | 564 std::string host; |
526 response >> host; | 565 response >> host; |
527 return ToUtf16String(host); | 566 return ToUtf16String(host); |
528 } | 567 } |
OLD | NEW |