-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathmain_win.cc
89 lines (69 loc) · 2.74 KB
/
main_win.cc
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright (c) 2017 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "examples/shared/main.h"
#include <windows.h>
#include "include/cef_sandbox_win.h"
#include "examples/shared/app_factory.h"
#include "examples/shared/client_manager.h"
#include "examples/shared/main_util.h"
// When generating projects with CMake the CEF_USE_SANDBOX value will be defined
// automatically if using the required compiler version. Pass -DUSE_SANDBOX=OFF
// to the CMake command-line to disable use of the sandbox.
namespace shared {
// Entry point function for all processes.
int APIENTRY wWinMain(HINSTANCE hInstance) {
void* sandbox_info = nullptr;
#if defined(CEF_USE_SANDBOX)
// Manage the life span of the sandbox information object. This is necessary
// for sandbox support on Windows. See cef_sandbox_win.h for complete details.
CefScopedSandboxInfo scoped_sandbox;
sandbox_info = scoped_sandbox.sandbox_info();
#endif
// Provide CEF with command-line arguments.
CefMainArgs main_args(hInstance);
// Create a temporary CommandLine object.
CefRefPtr<CefCommandLine> command_line = CreateCommandLine(main_args);
// Create a CefApp of the correct process type.
CefRefPtr<CefApp> app;
switch (GetProcessType(command_line)) {
case PROCESS_TYPE_BROWSER:
app = CreateBrowserProcessApp();
break;
case PROCESS_TYPE_RENDERER:
app = CreateRendererProcessApp();
break;
case PROCESS_TYPE_OTHER:
app = CreateOtherProcessApp();
break;
}
// CEF applications have multiple sub-processes (render, plugin, GPU, etc)
// that share the same executable. This function checks the command-line and,
// if this is a sub-process, executes the appropriate logic.
int exit_code = CefExecuteProcess(main_args, app, sandbox_info);
if (exit_code >= 0) {
// The sub-process has completed so return here.
return exit_code;
}
// Create the singleton manager instance.
ClientManager manager;
// Specify CEF global settings here.
CefSettings settings;
#if !defined(CEF_USE_SANDBOX)
settings.no_sandbox = true;
#endif
// Initialize the CEF browser process. The first browser instance will be
// created in CefBrowserProcessHandler::OnContextInitialized() after CEF has
// been initialized. May return false if initialization fails or if early exit
// is desired (for example, due to process singleton relaunch behavior).
if (!CefInitialize(main_args, settings, app, sandbox_info)) {
return 1;
}
// Run the CEF message loop. This will block until CefQuitMessageLoop() is
// called.
CefRunMessageLoop();
// Shut down CEF.
CefShutdown();
return 0;
}
} // namespace shared