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

Unified Diff: src/engine/main.cpp

Issue 10783032: Pass browser locale to the JS code (Closed)
Patch Set: Fixed review comments Created June 4, 2013, 11:25 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/plugin/AdblockPlusClient.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/engine/main.cpp
===================================================================
--- a/src/engine/main.cpp
+++ b/src/engine/main.cpp
@@ -1,12 +1,13 @@
#include "stdafx.h"
#include "../shared/AutoHandle.h"
#include "../shared/Communication.h"
+#include "../shared/Version.h"
#include "Debug.h"
#include "Utils.h"
namespace
{
std::auto_ptr<AdblockPlus::FilterEngine> filterEngine;
std::string ToUtf8String(std::wstring str)
@@ -157,36 +158,46 @@ namespace
}
// TODO: Keep the pipe open until the client disconnects
return 0;
}
}
-std::auto_ptr<AdblockPlus::FilterEngine> CreateFilterEngine()
+std::auto_ptr<AdblockPlus::FilterEngine> CreateFilterEngine(const std::wstring& locale)
{
- // TODO: Pass appInfo in, which should be sent by the client
- AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::New();
+ AdblockPlus::AppInfo appInfo;
+ appInfo.version = ToUtf8String(IEPLUGIN_VERSION);
+ appInfo.name = "adblockplusie";
+ appInfo.platform = "msie";
+ appInfo.locale = ToUtf8String(locale);
+
+ AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::New(appInfo);
std::string dataPath = ToUtf8String(GetAppDataPath());
dynamic_cast<AdblockPlus::DefaultFileSystem*>(jsEngine->GetFileSystem().get())->SetBasePath(dataPath);
std::auto_ptr<AdblockPlus::FilterEngine> filterEngine(new AdblockPlus::FilterEngine(jsEngine));
return filterEngine;
}
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
// TODO: Attempt to create the pipe first, and exit immediately if this
// fails. Since multiple instances of the engine could be running,
// this may need named mutices to avoid race conditions.
// Note that as soon as the pipe is created first, we can reduce the
// client timeout after CreateProcess(), but should increase the one
// in WaitNamedPipe().
- filterEngine = CreateFilterEngine();
+ int argc;
+ LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc);
+ std::wstring locale(argc >= 1 ? argv[0] : L"");
+ LocalFree(argv);
+
+ filterEngine = CreateFilterEngine(locale);
for (;;)
{
try
{
Communication::Pipe* pipe = new Communication::Pipe(Communication::pipeName,
Communication::Pipe::MODE_CREATE);
« no previous file with comments | « no previous file | src/plugin/AdblockPlusClient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld