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

Side by Side Diff: src/plugin/AdblockPlusClient.cpp

Issue 10897028: Create a shared dictionary class for plugin and engine (Closed)
Patch Set: Created June 7, 2013, 12:42 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 #include "PluginStdAfx.h" 1 #include "PluginStdAfx.h"
2 2
3 #include "PluginSettings.h" 3 #include "PluginSettings.h"
4 #include "PluginSystem.h" 4 #include "PluginSystem.h"
5 #include "PluginFilter.h" 5 #include "PluginFilter.h"
6 #include "PluginClientFactory.h" 6 #include "PluginClientFactory.h"
7 #include "PluginDictionary.h"
8 #include "PluginHttpRequest.h" 7 #include "PluginHttpRequest.h"
9 #include "PluginMutex.h" 8 #include "PluginMutex.h"
10 #include "PluginClass.h" 9 #include "PluginClass.h"
11 #include "PluginUtil.h"
12 10
13 #include "AdblockPlusClient.h" 11 #include "AdblockPlusClient.h"
14 12
15 #include "../shared/Communication.h" 13 #include "../shared/Communication.h"
14 #include "../shared/Utils.h"
16 15
17 namespace 16 namespace
18 { 17 {
19 void SpawnAdblockPlusEngine() 18 void SpawnAdblockPlusEngine()
20 { 19 {
21 std::wstring engineExecutablePath = DllDir() + L"AdblockPlusEngine.exe"; 20 std::wstring engineExecutablePath = GetDllDir() + L"AdblockPlusEngine.exe";
22 CString browserLanguage = CPluginSystem::GetInstance()->GetBrowserLanguage() ; 21 CString params = L"AdblockPlusEngine.exe " + CPluginSystem::GetInstance()->G etBrowserLanguage();
Felix Dahlke 2013/06/11 12:31:14 From the documentation (http://msdn.microsoft.com/
Wladimir Palant 2013/06/12 13:46:07 I would be opposed to that idea given that engineE
Felix Dahlke 2013/06/13 18:07:37 Fair enough.
22
23 STARTUPINFO startupInfo = {}; 23 STARTUPINFO startupInfo = {};
24 PROCESS_INFORMATION processInformation = {}; 24 PROCESS_INFORMATION processInformation = {};
25 25
26 HANDLE token; 26 HANDLE token;
27 OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE | TOKEN_ADJUST_DEFAULT | TOKEN_QUERY | TOKEN_ASSIGN_PRIMARY, &token); 27 OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE | TOKEN_ADJUST_DEFAULT | TOKEN_QUERY | TOKEN_ASSIGN_PRIMARY, &token);
28 HANDLE newToken; 28 HANDLE newToken;
29 DuplicateTokenEx(token, 0, 0, SecurityImpersonation, TokenPrimary, &newToken ); 29 DuplicateTokenEx(token, 0, 0, SecurityImpersonation, TokenPrimary, &newToken );
30 30
31 if (!CreateProcessAsUserW(newToken, engineExecutablePath.c_str(), 31 if (!CreateProcessAsUserW(newToken, engineExecutablePath.c_str(),
32 browserLanguage.GetBuffer(browserLanguage.GetLengt h() + 1), 32 params.GetBuffer(params.GetLength() + 1),
33 0, 0, 0, 0, 0, 0, &startupInfo, &processInformatio n)) 33 0, 0, 0, 0, 0, 0, &startupInfo, &processInformatio n))
34 { 34 {
35 DWORD error = GetLastError(); 35 DWORD error = GetLastError();
36 throw std::runtime_error("Failed to start Adblock Plus Engine"); 36 throw std::runtime_error("Failed to start Adblock Plus Engine");
37 } 37 }
38 38
39 CloseHandle(processInformation.hProcess); 39 CloseHandle(processInformation.hProcess);
40 CloseHandle(processInformation.hThread); 40 CloseHandle(processInformation.hThread);
41 } 41 }
42 42
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 try 363 try
364 { 364 {
365 CallAdblockPlusEngineProcedure(request); 365 CallAdblockPlusEngineProcedure(request);
366 } 366 }
367 catch (const std::exception& e) 367 catch (const std::exception& e)
368 { 368 {
369 DEBUG_GENERAL(e.what()); 369 DEBUG_GENERAL(e.what());
370 } 370 }
371 } 371 }
372 372
OLDNEW

Powered by Google App Engine
This is Rietveld