bool CEFManager::Initialize(CoreApiPtr pCore) { m_pCore = pCore; #ifdef WIN32 CefMainArgs main_args(GetModuleHandle(NULL)); #endif #ifdef __APPLE__ CefMainArgs main_args; #endif m_pApp = new CEFApp; CefSettings settings; settings.command_line_args_disabled = false; const char* szSub = "./cef_sub_process_x64.exe"; CefString(&settings.browser_subprocess_path).FromASCII(szSub); CefString(&settings.log_file).FromString("./log/cef.log"); #ifdef __APPLE__ if(false == CefInitialize(main_args, settings, m_pApp.get(), nullptr)) #endif #ifdef WIN32 if(false == CefInitialize(main_args, settings, m_pApp.get())) #endif { return false; } return true; }
WebBrowserHost::WebBrowserHost(Context* context) : Object (context) { const Vector<String>& arguments = GetArguments(); #ifdef ATOMIC_PLATFORM_LINUX XSetErrorHandler(XErrorHandlerImpl); XSetIOErrorHandler(XIOErrorHandlerImpl); // Install a signal handler so we clean up after ourselves. signal(SIGINT, TerminationSignalHandler); signal(SIGTERM, TerminationSignalHandler); #endif // IMPORTANT: See flags being set in implementation of void WebAppBrowser::OnBeforeCommandLineProcessing // these include "--enable-media-stream", "--enable-usermedia-screen-capturing", "--off-screen-rendering-enabled", "--transparent-painting-enabled" #ifdef ATOMIC_PLATFORM_LINUX static const char* _argv[3] = { "AtomicWebView", "--disable-setuid-sandbox" }; CefMainArgs args(3, (char**) &_argv); #else CefMainArgs args; #endif CefSettings settings; settings.windowless_rendering_enabled = 1; // default background is white, add a setting // settings.background_color = 0; if (productVersion_.Length()) { CefString(&settings.product_version).FromASCII(productVersion_.CString()); } if (userAgent_.Length()) { CefString(&settings.user_agent).FromASCII(userAgent_.CString()); } settings.remote_debugging_port = debugPort_; d_ = new WebBrowserHostPrivate(this); // If losing OSX system menu, it means we're calling this // before initializing graphics subsystem if (!CefInitialize(args, settings, d_->app_, nullptr)) { LOGERROR("CefInitialize - Error"); } RegisterWebSchemeHandlers(this); SubscribeToEvent(E_UPDATE, HANDLER(WebBrowserHost, HandleUpdate)); instance_ = this; }
void ClientAppInit() { // Init ======================================================= HINSTANCE hInstance = GetModuleHandle(nullptr); hInst = hInstance; CefMainArgs main_args(hInstance); // Create the v8-binding app so we can communicate // between html/js, the cef client, and ofx sClientApp = new ClientApp(); // Parse command line arguments. The passed in values are ignored on Windows. AppInitCommandLine(0, NULL); CefSettings appSettings; // The CEF client launches multiples threads from this single process appSettings.single_process = true; // Populate the settings based on command line arguments. AppGetSettings(appSettings); CefInitialize(main_args, appSettings, sClientApp.get()); }
void __stdcall Init(HINSTANCE hInstance,bool bSingleProcess =true) { CefMainArgs main_args(hInstance); CefRefPtr<ClientApp> app(new ClientApp); int exit_code = CefExecuteProcess(main_args, app.get(), NULL); if (exit_code >= 0){ exit(exit_code); } CefSettings settings; CefSettingsTraits::init(&settings); settings.multi_threaded_message_loop = true; settings.single_process = bSingleProcess; TCHAR szBuffer[MAX_PATH]; SHGetSpecialFolderPath(NULL, szBuffer, CSIDL_INTERNET_CACHE, FALSE); _stprintf(szBuffer,_T("%s\\cache"), szBuffer); //CefString(&settings.cache_path) = szBuffer; CefString(&settings.cache_path).FromWString(szBuffer); settings.log_severity = LOGSEVERITY_DISABLE; CefString(&settings.locale) = "zh-CN"; CefInitialize(main_args, settings, app.get(), NULL); }
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) { CefEnableHighDPISupport(); CefMainArgs mainArgs(hInst); CefRefPtr<CefCommandLine> cmdLine = CefCommandLine::CreateCommandLine(); cmdLine->InitFromString(::GetCommandLineW()); CefRefPtr<CefApp> app; auto appType = GetAppType(cmdLine); if (appType == AppType::BROWSER) app = new BrowserApp(); else if (appType == AppType::RENDERER) app = new RendererApp(); int exitCode = CefExecuteProcess(mainArgs, app, nullptr); if (exitCode >= 0) return exitCode; CefSettings settings; settings.no_sandbox = true; settings.remote_debugging_port = 1337; CefString(&settings.cache_path).FromASCII("./cache/"); CefInitialize(mainArgs, settings, app, nullptr); CefRunMessageLoop(); CefShutdown(); return 0; }
// Entry point function for all processes. int main(int argc, char* argv[]) { // Provide CEF with command-line arguments. CefMainArgs main_args(argc, argv); // SimpleApp implements application-level callbacks. It will create the first // browser instance in OnContextInitialized() after CEF has initialized. CefRefPtr<SimpleApp> app(new SimpleApp); // 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.get(), NULL); if (exit_code >= 0) { // The sub-process has completed so return here. return exit_code; } // Specify CEF global settings here. CefSettings settings; // Initialize CEF for the browser process. CefInitialize(main_args, settings, app.get(), NULL); // Run the CEF message loop. This will block until CefQuitMessageLoop() is // called. CefRunMessageLoop(); // Shut down CEF. CefShutdown(); return 0; }
void __stdcall Init(HINSTANCE hInstance,bool bSingleProcess =true) { SetErrorMode(SEM_NOGPFAULTERRORBOX|SEM_FAILCRITICALERRORS|SEM_NOALIGNMENTFAULTEXCEPT|SEM_NOOPENFILEERRORBOX); CefMainArgs main_args(hInstance); CefRefPtr<ClientApp> app(new ClientApp); int exit_code = CefExecuteProcess(main_args, app.get(), NULL); if (exit_code >= 0){ exit(exit_code); } CefSettings settings; CefSettingsTraits::init(&settings); settings.multi_threaded_message_loop = true; settings.single_process = bSingleProcess; TCHAR szBuffer[MAX_PATH]; SHGetSpecialFolderPath(NULL, szBuffer, CSIDL_INTERNET_CACHE, FALSE); _stprintf(szBuffer,_T("%s\\cache"), szBuffer); //CefString(&settings.cache_path) = szBuffer; CefString(&settings.cache_path).FromWString(szBuffer); settings.log_severity = LOGSEVERITY_DISABLE; CefString(&settings.locale) = "zh-CN"; settings.ignore_certificate_errors = s_ignore_Cert_Err; CefInitialize(main_args, settings, app.get(), NULL); }
/** IModuleInterface implementation */ virtual void StartupModule() override { FString GameDir = FPaths::ConvertRelativePathToFull(FPaths::GameDir() + "BluCache"); CefString GameDirCef = *GameDir; // Setup the default settings for BluManager BluManager::settings.windowless_rendering_enabled = true; BluManager::settings.no_sandbox = true; BluManager::settings.remote_debugging_port = 7777; #if PLATFORM_LINUX CefString(&BluManager::settings.browser_subprocess_path).FromASCII("./blu_ue4_process"); #endif #if PLATFORM_MAC CefString(&BluManager::settings.browser_subprocess_path).FromASCII("./blu_ue4_process.app/Contents/MacOS/blu_ue4_process"); #endif #if PLATFORM_WINDOWS CefString(&BluManager::settings.browser_subprocess_path).FromASCII("./blu_ue4_process.exe"); #endif CefString(&BluManager::settings.cache_path).FromString(GameDirCef); // Make a new manager instance CefRefPtr<BluManager> BluApp = new BluManager(); //CefExecuteProcess(BluManager::main_args, BluApp, NULL); CefInitialize(BluManager::main_args, BluManager::settings, BluApp, NULL); UE_LOG(LogBlu, Log, TEXT(" STATUS: Loaded")); }
int PlexabilityApp::run() { TRACE(); // First up; we see if we're running as a child process (in which case, CEF takes care of business // for us in a blocking manner). int exitCode = CefExecuteProcess(this->args, (CefRefPtr<CefApp>)this->chromiumApp); if (exitCode >= 0) { LOG("Ran as a child process. Exited with: %d", exitCode); return exitCode; } // Nope; we're the master process. Initialize CEF. if (!CefInitialize(this->args, this->chromiumSettings, (CefRefPtr<CefApp>)this->chromiumApp)) { LOG("CEF failed to initialize! Aborting."); return 127; } // Set up the platform-specific GUI and friends. this->initializeNativeApp(); // And then kick off the run loop (this blocks until the app is ready to exit) CefRunMessageLoop(); return 0; }
int CefInit(int &argc, char **argv) { qDebug() << __FUNCTION__; HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL); CefMainArgs main_args(hInstance); CefRefPtr<ClientApp> app(new ClientApp); #ifdef SUB_PROCESS_DISABLED // Execute the secondary process, if any. int exit_code = CefExecuteProcess(main_args, app.get()); if (exit_code >= 0) return exit_code; #endif CefSettings settings; CefInitSettings(settings); #ifndef SUB_PROCESS_DISABLED // Specify the path for the sub-process executable. CefString(&settings.browser_subprocess_path).FromASCII("cefclient_process.exe"); #endif // Initialize CEF. CefInitialize(main_args, settings, app.get()); g_handler = new ClientHandler(); return -1; }
int main(int argc, char** argv) { HINSTANCE hInstance = GetModuleHandle(0); // Provide CEF with command-line arguments CefMainArgs args(hInstance); // TestApp implements application-level callbacks. It will create the first // browser instance in the `OnContextInitialized` callback after CEF has // initialized CefRefPtr<CefApp> app(new TestApp); // CEF applications have multiple sub-processes (render, plugin, GPU, etc) // that share can the same executable. // Create sub-process //int exit_code = CefExecuteProcess(args, app.get(), NULL); //if (exit_code >= 0) { // sub-process // // sub-process has completed, so return here // return exit_code; //} // However, separate sub-process executable is used here, so // 'browser_subprocess_path' must be set in CefSettings CefSettings settings; CefString(&settings.browser_subprocess_path).FromASCII("test_subprocess.exe"); settings.no_sandbox = true; // Initialize CEF CefInitialize(args, settings, app.get(), NULL); // Run the CEF message loop. This will block until `CefQuiMessageLoop` is // invoked. CefRunMessageLoop(); // Shutdown CEF CefShutdown(); return 0; }
void Cef::Init() { if( !Cef::initialized_ ) { CefLoop::Init(); CefSettings settings; CefRefPtr<CefApp> app; // TODO: Use settings.pack_file_path to set the correct chrome.pak path // since it searches in execute path ( where node exists ) to find // the pack file in linux and it won't work. // settings.pack_file_path = filePath; settings.pack_loading_disabled = true; settings.multi_threaded_message_loop = false; g_handler = new ClientHandler(); CefInitialize(settings, app); // Accoding to this thread [1], I changed appjs scheme to // normal http scheme with a special domain name. // [1] http://code.google.com/p/chromiumembedded/issues/detail?id=404 //CefRegisterCustomScheme("appjs", true, false, false); CefRegisterSchemeHandlerFactory("http", "appjs", new AppjsSchemeHandlerFactory()); CefBase::Init(); Cef::initialized_ = true; } };
CefFacade::CefFacade(const char* startUrl,HINSTANCE hInstance,HWND pParent) { CefMainArgs main_args(hInstance); CefRefPtr<ClientApp> app(new ClientApp); int exit_code = CefExecuteProcess(main_args, app.get(), NULL); if (exit_code >= 0){ exit(exit_code); } CefSettings settings; CefSettingsTraits::init(&settings); settings.multi_threaded_message_loop = true; settings.single_process = true; TCHAR szBuffer[MAX_PATH]; SHGetSpecialFolderPath(NULL, szBuffer, CSIDL_INTERNET_CACHE, FALSE); _stprintf(szBuffer,_T("%s\\cache"), szBuffer); CefString(&settings.cache_path) = szBuffer; settings.log_severity = LOGSEVERITY_DISABLE; CefString(&settings.locale) = "zh-CN"; CefInitialize(main_args, settings, app.get(), NULL); CreateBrowser(pParent,startUrl); }
// Cef的初始化接口,同时备注了使用各个版本的Cef时遇到的各种坑 // Cef1916版本较稳定,各个功能使用正常,但是某些在debug模式网页打开时会出中断警告(但并不是错误),可能是因为对新html标准支持不够,但是在release模式下正常使用 // Cef2357版本无法使用,当程序处理重定向信息并且重新加载页面后,渲染进程会崩掉 // Cef2526、2623版本对各种新页面都支持,唯一的坑就是debug模式在多线程消息循环开启下,程序退出时会中断,但是release模式正常。 // (PS:如果开发者不使用负责Cef功能的开发,可以切换到release模式的cef dll文件,这样即使在deubg下也不会报错,修改AddCefDllToPath代码可以切换到release目录) bool CefManager::Initialize(const std::wstring& app_data_dir, CefSettings &settings, bool is_enable_offset_render /*= true*/) { #if !defined(SUPPORT_CEF) return true; #endif is_enable_offset_render_ = is_enable_offset_render; CefMainArgs main_args(GetModuleHandle(NULL)); CefRefPtr<ClientApp> app(new ClientApp); // 如果是在子进程中调用,会堵塞直到子进程退出,并且exit_code返回大于等于0 // 如果在Browser进程中调用,则立即返回-1 int exit_code = CefExecuteProcess(main_args, app.get(), NULL); if (exit_code >= 0) return false; GetCefSetting(app_data_dir, settings); bool bRet = CefInitialize(main_args, settings, app.get(), NULL); if (is_enable_offset_render_) { HWND hwnd = CreateWindow(L"Static", L"", WS_POPUP, 0, 0, 0, 0, NULL, NULL, NULL, NULL); CefPostTask(TID_UI, base::Bind(&FixContextMenuBug, hwnd)); } return bRet; }
BOOL CCefBrowserApp::InitInstance() { { CefMainArgs main_args(::GetModuleHandle(NULL)); CefRefPtr<XClientApp> app(new XClientApp); // Execute the secondary process, if any. int exit_code = CefExecuteProcess(main_args, app.get(), nullptr); if (exit_code >= 0) return exit_code; // Parse command line arguments. The passed in values are ignored on Windows. AppInitCommandLine(0, NULL); CefSettings settings; // Populate the settings based on command line arguments. AppGetSettings(settings); // Initialize CEF. CefInitialize(main_args, settings, app.get(), nullptr); // Init plugins, like Flash etc. InitWebPlugins(); } // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); AfxEnableControlContainer(); CCefBrowserDlg* pDlg = new CCefBrowserDlg; m_pMainWnd = pDlg; pDlg->Create(MAKEINTRESOURCE(IDD_CEFBROWSER_DIALOG), NULL); m_pMainWnd->ShowWindow(SW_SHOWNORMAL); m_pMainWnd->UpdateWindow(); { // Run the CEF message loop. This function will block until the application // recieves a WM_QUIT message. CefRunMessageLoop(); CefShutdown(); } // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, // 而不是启动应用程序的消息泵。 return FALSE; }
//using std::ios_base; //using std::ios; int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow){ bool one_time_do = false; std::string folder_to_put_downloads; if (!one_time_do){ one_time_do = true; std::string path_config_file = "xxxx-geheimes-Wort!!_dl_config_file.conf3000.txt"; //std::fstream config_file_check(path+path_config_file, ios_base::binary | ios_base::in); //http://stackoverflow.com/questions/875249/how-to-get-current-directory Config_File_IO cfio(get_current_application_path()+"\\"+path_config_file); auto check = cfio.check_if_exists(); if (check.result_operation){// nur 3000 warum nicht mehr //na drauslesen,was denn sonst,was will er denn sonst mit machen??überleg.hmm.kein Rätsel.kein Quiz //std::stringstream cff_StreaM; cff_StreaM << config_file_check.rdbuf(); //folder_to_put_downloads = cff_StreaM.str(); config_file_check.close(); folder_to_put_downloads = check.contents_get(); } else{//select dir.the choice(stage)is yours /up to you //config_file_check.close(); //std::ofstream of(path + path_config_file, ios::binary | ios::out); Folder_Select_Dialog_like_FileName*fsdlf = new Folder_Select_Dialog_like_FileName(); File_Select_Result fsr; do{ fsr = fsdlf->performOpen("C:\\", "Ort wo die Downloads zu speichern sind"); } while (fsr.status != true); folder_to_put_downloads = std::string(fsr.location); //of << fsr.location; //of.close(); check.put_contents(folder_to_put_downloads); } } //CefScopedSandboxInfo scoped_sandbox; //void*sandbox_info = scoped_sandbox.sandbox_info();//sandbox hier aktiviert,muss man aber net void*sandbox_info = NULL;//sandbox deaktiviert,da bei allen winapi/file calls permission denied kommt CefMainArgs main_args(hInstance); CefRefPtr<MainApp> app(new MainApp(folder_to_put_downloads)); int exit_code = CefExecuteProcess(main_args, app.get(), sandbox_info); if (exit_code >= 0) { return exit_code; } CefSettings settings;//wird fürs initialize gebraucht settings.no_sandbox = true; CefInitialize(main_args, settings, app.get(), sandbox_info); CefRunMessageLoop(); CefShutdown(); return 0; }
int CTransChatWebWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!theApp.GetWindowManager()->Attach(GetSafeHwnd(), _T("trans_chat_web_wnd"))) return -1; SetWindowText(_T("专人翻译")); g_SessionData.chat_hwnd = GetSafeHwnd(); m_shadow_win.create(GetSafeHwnd()); m_Recorder.Attach(GetSafeHwnd()); //m_pV8Exthandler = new ClientV8ExtHandler(this); CefRefPtr<CefWebClient> client(new CefWebClient()); m_cWebClient = client; CefSettings cSettings; CefSettingsTraits::init(&cSettings); cSettings.multi_threaded_message_loop = true; CefRefPtr<CefApp> spApp; CefInitialize(cSettings, spApp); //CefRegisterExtension("v8/Ext", s_JsExt, m_pV8Exthandler); duHwndObj* pWebHwndobj = (duHwndObj*)GetPluginByName(GetSafeHwnd(), _T("chat_web_hwndobj")); RECT rc = { 0, 0, 0, 0 }; pWebHwndobj->GetRect(&rc); CefWindowInfo info; info.SetAsChild(GetSafeHwnd(), rc); TCHAR szHtml[MAX_PATH] = { 0 }; ::GetModuleFileName(GetModuleHandle(NULL), szHtml, _countof(szHtml)); ::PathRemoveFileSpec(szHtml); ::PathAppend(szHtml, _T("html\\trans.html")); CefBrowserSettings browserSettings; CefBrowser::CreateBrowser(info, static_cast<CefRefPtr<CefClient>>(client), szHtml, browserSettings); InitExtension(); //RunExtensionTest(m_cWebClient->GetBrowser()); //pWebHwndobj->Attach(m_cWebClient->GetBrowser()->GetWindowHandle()); //m_Recorder.StartRecord(); //StrCpy(m_szVoicePath, _T("C:\\Users\\Administrator\\AppData\\Roaming\\MyEcho\\oDHO7Q3LRUtxLg4E9R1adjrsv5irzYa8\\task\\test.amr")); return 0; }
// Entry point function for all processes. int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); void* sandbox_info = NULL; #if CEF_ENABLE_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); // SimpleApp implements application-level callbacks. It will create the first // browser instance in OnContextInitialized() after CEF has initialized. CefRefPtr<SimpleApp> app(new SimpleApp); // 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.get(), sandbox_info); if (exit_code >= 0) { // The sub-process has completed so return here. return exit_code; } // Specify CEF global settings here. CefSettings settings; #if !CEF_ENABLE_SANDBOX settings.no_sandbox = true; #endif // Initialize CEF. CefInitialize(main_args, settings, app.get(), sandbox_info); // Run the CEF message loop. This will block until CefQuitMessageLoop() is // called. CefRunMessageLoop(); // Shut down CEF. CefShutdown(); return 0; }
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); breakpad_init(); setUserPWD(); CefSettings settings; #ifdef NDEBUG settings.log_severity = LOGSEVERITY_ERROR; #endif #ifdef TEST_SINGLE_THREADED_MESSAGE_LOOP settings.multi_threaded_message_loop = false; #else settings.multi_threaded_message_loop = true; #endif if(!WindowsVersionOK()) { MessageBox(NULL,L"Pea Search only support Window XP, Vista and Win7 .", L"Pea Search Warn",MB_OK); return 0; } CefInitialize(settings); InitSchemeTest(); InitPlugin(); MyRegisterClass(hInstance); if (!InitInstance (hInstance, nCmdShow)) return FALSE; if(OleInitialize(NULL)!=S_OK) MessageBox(NULL,L"warn",L"ole init failed.",MB_OK); connect_named_pipe(); SetForegroundWindow(hMainWin); SetFocus(hMainWin); MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { #ifdef TEST_SINGLE_THREADED_MESSAGE_LOOP // Allow the CEF to do its message loop processing. CefDoMessageLoopWork(); #endif TranslateMessage(&msg); DispatchMessage(&msg); } close_named_pipe(); OleUninitialize(); CefShutdown(); return (int) msg.wParam; }
//Initialize the CEF library hInstance will be GetModuleHandle(NULL) void SimpleCEFDLL_Initialize( HINSTANCE hInstance ) { g_App = new zSimpleCefApp; CefMainArgs main_args( hInstance ); CefExecuteProcess( main_args, g_App.get() ); CefSettings settings; //This two settings are mandatory for work in Windows XP settings.multi_threaded_message_loop = true; settings.single_process = true; CefInitialize( main_args, settings, g_App.get() ); }
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); CefEnableHighDPISupport(); CefScopedSandboxInfo scoped_sandbox; CefMainArgs main_args(hInstance); CefRefPtr<NgineSlackApp> app(new NgineSlackApp); int exit_code = CefExecuteProcess(main_args, app.get(), scoped_sandbox.sandbox_info()); if (exit_code >= 0) { return exit_code; } LimitSingleInstance lsi(NGINESLACK); if (lsi.IsAnotherInstanceRunning()) { HWND hWnd = FindWindow(NGINESLACK, NULL); if( hWnd==NULL ) { MessageBox(NULL, L"Already running. You need to terminate it manually.", NGINESLACK, MB_OK); } else { ShowWindow(hWnd, SW_SHOW); SetForegroundWindow(hWnd); } return 0; } _AtlBaseModule.SetResourceInstance(hInstance); GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); CefSettings settings; CefSetting_SetCachePath(settings); settings.persist_session_cookies = TRUE; settings.log_severity = LOGSEVERITY_DISABLE; settings.ignore_certificate_errors = TRUE; CefInitialize(main_args, settings, app.get(), scoped_sandbox.sandbox_info()); CefRunMessageLoop(); CefShutdown(); return 0; }
int cef_init(int argc, char *argv[]) { CefMainArgs args(argc, argv); int result = CefExecuteProcess(args, NULL, NULL); if (result >= 0) { /* child proccess has endend, so exit */ exit(result); } CefSettings settings; if (!CefInitialize(args, settings, NULL, NULL)) { return -1; } return 0; }
// // Program entry point function. // int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); // open the log file for writing g_hndLogFile = App::OpenLogFile(); g_hInst = hInstance; CefMainArgs main_args(hInstance); CefRefPtr<ClientApp> app(new ClientApp); // execute the secondary process, if any int exit_code = CefExecuteProcess(main_args, app.get()); if (exit_code >= 0) return exit_code; // parse command line arguments // the passed in values are ignored on Windows App::InitCommandLine(0, NULL); // populate the settings based on command line arguments CefSettings settings; App::GetSettings(settings); g_isMultithreadedMessageLoop = settings.multi_threaded_message_loop; // initialize CEF CefInitialize(main_args, settings, app.get()); // register cookieable schemes with the global cookie manager std::vector<CefString> schemes; schemes.push_back("http"); schemes.push_back("https"); CefCookieManager::GetGlobalManager()->SetSupportedSchemes(schemes); // create the main window and run InitMenuCommands(); int result = CreateMainWindow(); // shut down CEF CefShutdown(); return result; }
bool CWebCore::Initialise () { CefMainArgs mainArgs; void* sandboxInfo = nullptr; CefRefPtr<CCefApp> app { new CCefApp }; #if CEF_ENABLE_SANDBOX CefScopedSandboxInfo scopedSandbox; sandboxInfo = scopedSandbox.sandbox_info(); #endif if ( CefExecuteProcess ( mainArgs, app, sandboxInfo ) >= 0 ) return false; CefSettings settings; #if !CEF_ENABLE_SANDBOX settings.no_sandbox = true; #endif // Specifiy sub process executable path #ifndef MTA_DEBUG CefString ( &settings.browser_subprocess_path ).FromWString( FromUTF8( CalcMTASAPath ( "MTA\\CEF\\CEFLauncher.exe" ) ) ); #else CefString ( &settings.browser_subprocess_path ).FromWString( FromUTF8( CalcMTASAPath ( "MTA\\CEF\\CEFLauncher_d.exe" ) ) ); #endif CefString ( &settings.resources_dir_path ).FromWString ( FromUTF8( CalcMTASAPath( "MTA\\CEF") ) ); CefString ( &settings.locales_dir_path ).FromWString( FromUTF8( CalcMTASAPath( "MTA\\CEF\\locales" ) ) ); CefString ( &settings.log_file ).FromWString ( FromUTF8( CalcMTASAPath ( "MTA\\CEF\\cefdebug.txt" ) ) ); #ifdef MTA_DEBUG settings.log_severity = cef_log_severity_t::LOGSEVERITY_INFO; #else settings.log_severity = cef_log_severity_t::LOGSEVERITY_WARNING; #endif settings.multi_threaded_message_loop = true; settings.windowless_rendering_enabled = true; bool state = CefInitialize ( mainArgs, settings, app, sandboxInfo ); // Register custom scheme handler factory CefRegisterSchemeHandlerFactory ( "mtalocal", "", app ); CefRegisterSchemeHandlerFactory ( "http", "mta", app ); return state; }
int main(int argc, char* argv[]) { CefEnableHighDPISupport(); CefMainArgs mainArgs(argc, argv); auto cmdLine = CefCommandLine::CreateCommandLine(); cmdLine->InitFromArgv(argc, argv); std::string configPath = cmdLine->GetSwitchValue("config").ToString(); if (configPath.empty()) { configPath = "config.default.json"; } AppConfig config; if (!LoadAppConfig(configPath.c_str(), &config)) { return -1; } CefRefPtr<CefApp> app(new App(config)); int exitCode = CefExecuteProcess(mainArgs, app, nullptr); if (exitCode >= 0) { return exitCode; } CefSettings settings; settings.no_sandbox = true; settings.remote_debugging_port = 1337; settings.single_process = false; CefString(&settings.cache_path).FromASCII(CACHE_PATH); CefInitialize(mainArgs, settings, app, nullptr); CefRunMessageLoop(); CefShutdown(); return 0; }
int QCefInit(int& argc, char** argv) { HINSTANCE hInstance = static_cast<HINSTANCE>(GetModuleHandle(nullptr)); CefMainArgs mainArgs(hInstance); CefRefPtr<QCefClientApp> app(new QCefClientApp); int exit_code = CefExecuteProcess(mainArgs, app.get(), nullptr); if (exit_code >= 0) { return exit_code; } CefSettings settings; QCefInitSettings(settings); CefInitialize(mainArgs, settings, app, nullptr); g_handler = new QCefClientHandler(); return -1; }
value cef_init() { CefSettings settings; CefMainArgs args; settings.multi_threaded_message_loop = true; printf("before init\n"); CefInitialize(args, settings, NULL); printf("after init\n"); HWND hWnd; RECT rect; // Init First Chrome CefBrowserSettings browserSettings; CefWindowInfo info; g_handler = new myClientHandler(); DWORD dwProcID = GetCurrentProcessId(); hWnd = GetTopWindow(GetDesktopWindow()); while(hWnd) { DWORD dwWndProcID = 0; GetWindowThreadProcessId(hWnd, &dwWndProcID); if(dwWndProcID == dwProcID) break; hWnd = GetNextWindow(hWnd, GW_HWNDNEXT); } printf("hwnd %d\n", hWnd); GetClientRect(hWnd, &rect); printf("before client rect\n"); info.SetAsChild(hWnd,rect); printf("set as child\n"); CefBrowserHost::CreateBrowser(info,static_cast< CefRefPtr<CefClient> >(g_handler),"http://www.google.com", browserSettings); printf("create browser\n"); return alloc_null(); }
// Entry point int main(int argc, char* argv[]) { CefMainArgs main_args(argc, argv); // This forks itself and does some chrome multi-process magic. int exit_code = CefExecuteProcess(main_args, NULL, NULL); if (exit_code >= 0) { // This sub-process has completed. return exit_code; } // Install xlib error handlers XSetErrorHandler(XErrorHandlerImpl); XSetIOErrorHandler(XIOErrorHandlerImpl); // Specify global CEF settings here. CefSettings settings; CefRefPtr<CHtmlToPdfApp> app(new CHtmlToPdfApp); CefInitialize(main_args, settings, app.get(), NULL); CefRunMessageLoop(); CefShutdown(); return 0; }
/** IModuleInterface implementation */ virtual void StartupModule() override { CefString GameDirCef = *FPaths::ConvertRelativePathToFull(FPaths::GameDir() + "BluCache"); FString ExecutablePath = FPaths::ConvertRelativePathToFull(FPaths::GameDir() + "Plugins/BLUI/ThirdParty/cef/"); // Setup the default settings for BluManager BluManager::settings.windowless_rendering_enabled = true; BluManager::settings.no_sandbox = true; BluManager::settings.remote_debugging_port = 7777; #if PLATFORM_LINUX ExecutablePath = "./blu_ue4_process"; #endif #if PLATFORM_MAC ExecutablePath += "Mac/shipping/blu_ue4_process.app/Contents/MacOS/blu_ue4_process"; #endif #if PLATFORM_WINDOWS ExecutablePath += "Win/shipping/blu_ue4_process.exe"; #endif CefString realExePath = *ExecutablePath; // Set the sub-process path CefString(&BluManager::settings.browser_subprocess_path).FromString(realExePath); // Set the cache path CefString(&BluManager::settings.cache_path).FromString(GameDirCef); // Make a new manager instance CefRefPtr<BluManager> BluApp = new BluManager(); //CefExecuteProcess(BluManager::main_args, BluApp, NULL); CefInitialize(BluManager::main_args, BluManager::settings, BluApp, NULL); UE_LOG(LogBlu, Log, TEXT(" STATUS: Loaded")); }
void BrowserManager::Impl::BrowserManagerEntry() { std::string bootstrapPath = getBootstrap(); bool thread_exit = false; PushEvent([] { CefMainArgs mainArgs; CefSettings settings; settings.log_severity = LOGSEVERITY_VERBOSE; settings.windowless_rendering_enabled = true; settings.no_sandbox = true; CefString(&settings.cache_path).FromASCII(obs_module_config_path("")); CefString(&settings.browser_subprocess_path) = getBootstrap(); CefRefPtr<BrowserApp> app(new BrowserApp()); CefExecuteProcess(mainArgs, app, nullptr); CefInitialize(mainArgs, settings, app, nullptr); CefRegisterSchemeHandlerFactory("http", "absolute", new BrowserSchemeHandlerFactory()); CefRunMessageLoop(); CefShutdown(); }); while (true) { if (os_event_timedwait(dispatchEvent, 10) != ETIMEDOUT) { pthread_mutex_lock(&dispatchLock); while (!queue.empty()) { auto event = queue[0]; event(); queue.erase(queue.begin()); } thread_exit = !threadAlive; pthread_mutex_unlock(&dispatchLock); if (thread_exit) { return; } } } }