diff --git a/gui/cefdisplay/src/simple_app.cxx b/gui/cefdisplay/src/simple_app.cxx index c7732b96ef8dbfd9ac0f0fa41b406cb3fb8771a6..16afb918c6e86c7a05d18e88bd7247a5f4c3df56 100644 --- a/gui/cefdisplay/src/simple_app.cxx +++ b/gui/cefdisplay/src/simple_app.cxx @@ -84,9 +84,10 @@ public: int fTransferOffset{0}; - explicit TGuiResourceHandler() + explicit TGuiResourceHandler(bool dummy = false) { - fArg = std::make_shared<TCefHttpCallArg>(); + if (!dummy) + fArg = std::make_shared<TCefHttpCallArg>(); } virtual ~TGuiResourceHandler() {} @@ -97,9 +98,12 @@ public: { CEF_REQUIRE_IO_THREAD(); - fArg->AssignCallback(callback); - - gHandlingServer->SubmitHttp(fArg); + if (fArg) { + fArg->AssignCallback(callback); + gHandlingServer->SubmitHttp(fArg); + } else { + callback->Continue(); + } return true; } @@ -108,7 +112,7 @@ public: { CEF_REQUIRE_IO_THREAD(); - if (fArg->Is404()) { + if (!fArg || fArg->Is404()) { response->SetMimeType("text/html"); response->SetStatus(404); response_length = 0; @@ -117,16 +121,14 @@ public: response->SetStatus(200); response_length = fArg->GetContentLength(); - printf("SET RESPONSE len %d type %s\n", (int) response_length, fArg->GetContentType()); - if (fArg->NumHeader() > 0) { - printf("******* Response with extra headers\n"); + // printf("******* Response with extra headers\n"); CefResponse::HeaderMap headers; for (Int_t n = 0; n < fArg->NumHeader(); ++n) { TString name = fArg->GetHeaderName(n); TString value = fArg->GetHeader(name.Data()); headers.emplace(CefString(name.Data()), CefString(value.Data())); - printf(" header %s %s\n", name.Data(), value.Data()); + // printf(" header %s %s\n", name.Data(), value.Data()); } response->SetHeaderMap(headers); } @@ -216,8 +218,6 @@ public: { std::string addr = request->GetURL().ToString(); - printf("REQUEST %s\n", addr.c_str()); - TUrl url(addr.c_str()); const char *inp_path = url.GetFile(); @@ -229,15 +229,11 @@ public: if (gHandlingServer->IsFileRequested(inp_path, fname)) { // process file - no need for special requests handling - const char *mime = THttpServer::GetMimeType(fname.Data()); - - // static std::string str_content = THttpServer::ReadFileContent(fname.Data()); - - printf("Sending file %s mime %s\n", fname.Data(), mime); + // when file not exists - return nullptr + if (gSystem->AccessPathName(fname.Data())) + return new TGuiResourceHandler(true); - // Create a stream reader for |html_content|. - //CefRefPtr<CefStreamReader> stream = CefStreamReader::CreateForData( - // static_cast<void *>(const_cast<char *>(str_content.c_str())), str_content.size()); + const char *mime = THttpServer::GetMimeType(fname.Data()); CefRefPtr<CefStreamReader> stream = CefStreamReader::CreateForFile(fname.Data()); @@ -248,7 +244,7 @@ public: std::string inp_method = request->GetMethod().ToString(); - printf("REQUEST METHOD %s\n", inp_method.c_str()); + // printf("REQUEST METHOD %s\n", inp_method.c_str()); TGuiResourceHandler *handler = new TGuiResourceHandler(); handler->fArg->SetMethod(inp_method.c_str()); @@ -311,7 +307,7 @@ void SimpleApp::OnBeforeCommandLineProcessing(const CefString &process_type, Cef { std::string name = process_type.ToString(); std::string prog = command_line->GetProgram().ToString(); - printf("OnBeforeCommandLineProcessing %s %s\n", name.c_str(), prog.c_str()); + // printf("OnBeforeCommandLineProcessing %s %s\n", name.c_str(), prog.c_str()); // if (fBatch) { // command_line->AppendSwitch("disable-gpu"); // command_line->AppendSwitch("disable-gpu-compositing"); @@ -324,8 +320,7 @@ void SimpleApp::OnBeforeChildProcessLaunch(CefRefPtr<CefCommandLine> command_lin std::string newprog = fCefMain; command_line->SetProgram(newprog); - printf("OnBeforeChildProcessLaunch %s LastBatch %s\n", command_line->GetProgram().ToString().c_str(), fLastBatch ? "true" : "false"); - + // printf("OnBeforeChildProcessLaunch %s LastBatch %s\n", command_line->GetProgram().ToString().c_str(), fLastBatch ? "true" : "false"); if (fLastBatch) { command_line->AppendSwitch("disable-webgl"); @@ -334,17 +329,15 @@ void SimpleApp::OnBeforeChildProcessLaunch(CefRefPtr<CefCommandLine> command_lin // command_line->AppendSwitch("disable-gpu-sandbox"); } - auto str = command_line->GetCommandLineString().ToString(); - printf("RUNNING %s\n", str.c_str()); - - + // auto str = command_line->GetCommandLineString().ToString(); + // printf("RUN %s\n", str.c_str()); } void SimpleApp::OnContextInitialized() { CEF_REQUIRE_UI_THREAD(); - // CefRegisterSchemeHandlerFactory("http", "rootserver.local", new ROOTSchemeHandlerFactory()); + CefRegisterSchemeHandlerFactory("http", "rootserver.local", new ROOTSchemeHandlerFactory()); if (!fFirstUrl.empty()) StartWindow(fFirstUrl, fFirstBatch, fFirstRect); @@ -527,19 +520,19 @@ protected: // cef_string_ascii_to_utf16(path2.Data(), path2.Length(), &settings.locales_dir_path); - // settings.no_sandbox = 1; + settings.no_sandbox = 1; // if (gROOT->IsWebDisplayBatch()) settings.single_process = true; // if (batch_mode) // settings.windowless_rendering_enabled = true; - settings.external_message_pump = true; - settings.multi_threaded_message_loop = false; + // settings.external_message_pump = true; + // settings.multi_threaded_message_loop = false; std::string plog = "cef.log"; cef_string_ascii_to_utf16(plog.c_str(), plog.length(), &settings.log_file); - settings.log_severity = LOGSEVERITY_VERBOSE; // LOGSEVERITY_INFO, LOGSEVERITY_WARNING, LOGSEVERITY_ERROR, LOGSEVERITY_DISABLE + settings.log_severity = LOGSEVERITY_VERBOSE; // LOGSEVERITY_VERBOSE, LOGSEVERITY_INFO, LOGSEVERITY_WARNING, LOGSEVERITY_ERROR, LOGSEVERITY_DISABLE // settings.uncaught_exception_stack_size = 100; // settings.ignore_certificate_errors = true;