| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 #include "../shared/AutoHandle.h" | 24 #include "../shared/AutoHandle.h" |
| 25 #include "../shared/Communication.h" | 25 #include "../shared/Communication.h" |
| 26 #include "../shared/Dictionary.h" | 26 #include "../shared/Dictionary.h" |
| 27 #include "../shared/Utils.h" | 27 #include "../shared/Utils.h" |
| 28 #include "../shared/Version.h" | 28 #include "../shared/Version.h" |
| 29 #include "../shared/CriticalSection.h" | 29 #include "../shared/CriticalSection.h" |
| 30 #include "IeVersion.h" | 30 #include "IeVersion.h" |
| 31 #include "AdblockPlus.h" | 31 #include "AdblockPlus.h" |
| 32 #include "Debug.h" | 32 #include "Debug.h" |
| 33 #include "Updater.h" | 33 #include "Updater.h" |
| 34 #include "Registry.h" | |
| 34 | 35 |
| 35 namespace | 36 namespace |
| 36 { | 37 { |
| 37 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine; | 38 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine; |
| 38 std::auto_ptr<Updater> updater; | 39 std::auto_ptr<Updater> updater; |
| 39 int activeConnections = 0; | 40 int activeConnections = 0; |
| 40 CriticalSection activeConnectionsLock; | 41 CriticalSection activeConnectionsLock; |
| 41 HWND callbackWindow; | 42 HWND callbackWindow; |
| 42 | 43 |
| 43 void WriteSubscriptions(Communication::OutputBuffer& response, | 44 void WriteSubscriptions(Communication::OutputBuffer& response, |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 { | 424 { |
| 424 Debug("updateAvailable event missing URL"); | 425 Debug("updateAvailable event missing URL"); |
| 425 return; | 426 return; |
| 426 } | 427 } |
| 427 updateAvailable = true; | 428 updateAvailable = true; |
| 428 | 429 |
| 429 updater->Update(params[0]->AsString()); | 430 updater->Update(params[0]->AsString()); |
| 430 } | 431 } |
| 431 } | 432 } |
| 432 | 433 |
| 434 std::wstring LoadPreconfigurationValue(const std::wstring& preconfigName) | |
|
Eric
2015/06/19 14:51:40
This name would be better as "RegistryPreconfigura
Eric
2015/06/19 14:51:40
Also. This function can go in the anonymous namesp
Oleksandr
2015/06/22 08:27:53
Done.
sergei
2015/06/22 09:17:06
However our functions usually contain the verb in
| |
| 435 { | |
| 436 try | |
| 437 { | |
| 438 AdblockPlus::RegistryKey regKey(HKEY_CURRENT_USER, L"Software\\AdblockPlus") ; | |
| 439 return regKey.value_wstring(preconfigName); | |
| 440 } | |
| 441 catch (std::runtime_error&) | |
|
sergei
2015/06/19 12:30:28
`const`
sergei
2015/06/19 12:31:47
And `std::exception` would be better than `std::ru
Eric
2015/06/19 14:51:41
"runtime_error" is correct. If the constructor wer
Oleksandr
2015/06/22 08:27:52
Acknowledged.
| |
| 442 { | |
| 443 return L""; | |
|
sergei
2015/06/19 12:30:28
I would put it after try-catch.
Eric
2015/06/19 14:51:40
The code reads better to have the return statement
Oleksandr
2015/06/22 08:27:53
Acknowledged.
| |
| 444 } | |
| 445 } | |
| 446 | |
| 433 std::auto_ptr<AdblockPlus::FilterEngine> CreateFilterEngine(const std::wstring& locale) | 447 std::auto_ptr<AdblockPlus::FilterEngine> CreateFilterEngine(const std::wstring& locale) |
| 434 { | 448 { |
| 435 AdblockPlus::AppInfo appInfo; | 449 AdblockPlus::AppInfo appInfo; |
| 436 appInfo.version = ToUtf8String(IEPLUGIN_VERSION); | 450 appInfo.version = ToUtf8String(IEPLUGIN_VERSION); |
| 437 appInfo.name = "adblockplusie"; | 451 appInfo.name = "adblockplusie"; |
| 438 #ifdef _WIN64 | 452 #ifdef _WIN64 |
| 439 appInfo.application = "msie64"; | 453 appInfo.application = "msie64"; |
| 440 #else | 454 #else |
| 441 appInfo.application = "msie32"; | 455 appInfo.application = "msie32"; |
| 442 #endif | 456 #endif |
| 443 appInfo.applicationVersion = ToUtf8String(AdblockPlus::IE::InstalledVersionStr ing()); | 457 appInfo.applicationVersion = ToUtf8String(AdblockPlus::IE::InstalledVersionStr ing()); |
| 444 appInfo.locale = ToUtf8String(locale); | 458 appInfo.locale = ToUtf8String(locale); |
| 445 #ifdef ADBLOCK_PLUS_TEST_MODE | 459 #ifdef ADBLOCK_PLUS_TEST_MODE |
| 446 appInfo.developmentBuild = true; | 460 appInfo.developmentBuild = true; |
| 447 #else | 461 #else |
| 448 appInfo.developmentBuild = false; | 462 appInfo.developmentBuild = false; |
| 449 #endif | 463 #endif |
| 450 | 464 |
| 451 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::New(appInfo); | 465 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::New(appInfo); |
| 452 jsEngine->SetEventCallback("updateAvailable", &OnUpdateAvailable); | 466 jsEngine->SetEventCallback("updateAvailable", &OnUpdateAvailable); |
| 453 | 467 |
| 454 std::string dataPath = ToUtf8String(GetAppDataPath()); | 468 std::string dataPath = ToUtf8String(GetAppDataPath()); |
| 455 dynamic_cast<AdblockPlus::DefaultFileSystem*>(jsEngine->GetFileSystem().get()) ->SetBasePath(dataPath); | 469 dynamic_cast<AdblockPlus::DefaultFileSystem*>(jsEngine->GetFileSystem().get()) ->SetBasePath(dataPath); |
| 456 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine(new AdblockPlus::FilterE ngine(jsEngine)); | 470 std::map<std::string, AdblockPlus::JsValuePtr> preconfig; |
| 471 preconfig["disable_auto_updates"] = jsEngine->NewValue( | |
| 472 LoadPreconfigurationValue(L"disable_auto_updates") == L"true"); | |
| 473 preconfig["suppress_first_run_page"] = jsEngine->NewValue( | |
| 474 LoadPreconfigurationValue(L"suppress_first_run_page") == L"true"); | |
| 475 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine(new AdblockPlus::FilterE ngine(jsEngine, preconfig)); | |
| 457 return filterEngine; | 476 return filterEngine; |
| 458 } | 477 } |
| 459 | 478 |
| 460 int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) | 479 int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) |
| 461 { | 480 { |
| 462 AutoHandle mutex(CreateMutexW(0, false, L"AdblockPlusEngine")); | 481 AutoHandle mutex(CreateMutexW(0, false, L"AdblockPlusEngine")); |
| 463 if (!mutex) | 482 if (!mutex) |
| 464 { | 483 { |
| 465 DebugLastError("CreateMutex failed"); | 484 DebugLastError("CreateMutex failed"); |
| 466 return 1; | 485 return 1; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 } | 521 } |
| 503 catch (const std::runtime_error& e) | 522 catch (const std::runtime_error& e) |
| 504 { | 523 { |
| 505 DebugException(e); | 524 DebugException(e); |
| 506 return 1; | 525 return 1; |
| 507 } | 526 } |
| 508 } | 527 } |
| 509 | 528 |
| 510 return 0; | 529 return 0; |
| 511 } | 530 } |
| OLD | NEW |