forked from cztomczak/cefpython
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
60 lines (49 loc) · 1.91 KB
/
Copy pathmain.cpp
File metadata and controls
60 lines (49 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2013 CEF Python, see the Authors file.
// All rights reserved. Licensed under BSD 3-clause license.
// Project website: https://github.com/cztomczak/cefpython
#include "cefpython_app.h"
#if defined(OS_WIN)
#include <windows.h>
int APIENTRY wWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// lpCmdLine does not include program name argument, must
// use GetCommandLineW(). Cannot use CefCommandLine::GetGlobalCommandLine,
// as CEF was not yet initialized.
CefRefPtr<CefCommandLine> command_line = \
CefCommandLine::CreateCommandLine();
command_line->InitFromString(GetCommandLineW());
CefMainArgs mainArgs(hInstance);
#else // defined(OS_WIN)
#include <string.h>
int main(int argc, char **argv)
{
#if defined(OS_LINUX)
// Chrome 130+ passes --pseudonymization-salt-handle to directly-launched
// (non-zygote) subprocesses, expecting GlobalDescriptors[key] to be
// pre-populated before InitializePseudonymizationSalt() runs.
// CEF 146 does not perform this initialization for the non-zygote path.
// Strip the switch here so Chrome falls back to a per-process random salt.
// This switch is added by the browser process after OnBeforeChildProcessLaunch
// fires, so it cannot be stripped via that callback alone.
{
static const char kSaltSwitch[] = "--pseudonymization-salt-handle";
static const int kSaltSwitchLen = sizeof(kSaltSwitch) - 1;
int new_argc = 0;
for (int i = 0; i < argc; i++) {
if (strncmp(argv[i], kSaltSwitch, kSaltSwitchLen) != 0)
argv[new_argc++] = argv[i];
}
argc = new_argc;
}
#endif
CefMainArgs mainArgs(argc, argv);
#endif // Mac, Linux
CefRefPtr<CefPythonApp> app(new CefPythonApp);
int exitCode = CefExecuteProcess(mainArgs, app.get(), NULL);
return exitCode;
}