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

Side by Side Diff: src/engine/Main.cpp

Issue 29317083: Issue 1490 - Enable pre-configurable properties in Internet Explorer (Closed)
Patch Set: Comments addressed Created June 22, 2015, 8:25 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « .hgsubstate ('k') | src/plugin/PluginClass.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 { 422 {
422 if (params.size() < 1) 423 if (params.size() < 1)
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 }
432
433 std::wstring PreconfigurationValueFromRegistry(const std::wstring& preconfigNa me)
434 {
435 try
436 {
437 AdblockPlus::RegistryKey regKey(HKEY_CURRENT_USER, L"Software\\AdblockPlus ");
438 return regKey.value_wstring(preconfigName);
439 }
440 catch (const std::runtime_error&)
441 {
442 return L"";
443 }
444 }
431 } 445 }
432 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 PreconfigurationValueFromRegistry(L"disable_auto_updates") == L"true");
473 preconfig["suppress_first_run_page"] = jsEngine->NewValue(
474 PreconfigurationValueFromRegistry(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
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 }
OLDNEW
« no previous file with comments | « .hgsubstate ('k') | src/plugin/PluginClass.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld