• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that can
3 // be found in the LICENSE file.
4 
5 #include "include/cef_app.h"
6 #include "include/wrapper/cef_library_loader.h"
7 
8 #include "tests/shared/common/client_app_other.h"
9 #include "tests/shared/renderer/client_app_renderer.h"
10 
11 // When generating projects with CMake the CEF_USE_SANDBOX value will be defined
12 // automatically. Pass -DUSE_SANDBOX=OFF to the CMake command-line to disable
13 // use of the sandbox.
14 #if defined(CEF_USE_SANDBOX)
15 #include "include/cef_sandbox_mac.h"
16 #endif
17 
18 namespace client {
19 
RunMain(int argc,char * argv[])20 int RunMain(int argc, char* argv[]) {
21 #if defined(CEF_USE_SANDBOX)
22   // Initialize the macOS sandbox for this helper process.
23   CefScopedSandboxContext sandbox_context;
24   if (!sandbox_context.Initialize(argc, argv))
25     return 1;
26 #endif
27 
28   // Load the CEF framework library at runtime instead of linking directly
29   // as required by the macOS sandbox implementation.
30   CefScopedLibraryLoader library_loader;
31   if (!library_loader.LoadInHelper())
32     return 1;
33 
34   CefMainArgs main_args(argc, argv);
35 
36   // Parse command-line arguments.
37   CefRefPtr<CefCommandLine> command_line = CefCommandLine::CreateCommandLine();
38   command_line->InitFromArgv(argc, argv);
39 
40   // Create a ClientApp of the correct type.
41   CefRefPtr<CefApp> app;
42   ClientApp::ProcessType process_type = ClientApp::GetProcessType(command_line);
43   if (process_type == ClientApp::RendererProcess)
44     app = new ClientAppRenderer();
45   else if (process_type == ClientApp::OtherProcess)
46     app = new ClientAppOther();
47 
48   // Execute the secondary process.
49   return CefExecuteProcess(main_args, app, nullptr);
50 }
51 
52 }  // namespace client
53 
54 // Entry point function for sub-processes.
main(int argc,char * argv[])55 int main(int argc, char* argv[]) {
56   return client::RunMain(argc, argv);
57 }
58