mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add initial chrome runtime support (see issue #2969)
Running `cefsimple --enable-chrome-runtime` will create and run a Chrome browser window using the CEF app methods, and call CefApp::OnContextInitialized as expected. CEF task methods also work as expected in the main process. No browser-related methods or callbacks are currently supported for the Chrome window, and the application will exit when the last Chrome window closes. The Chrome runtime requires resources.pak, chrome_100_percent.pak and chrome_200_percent.pak files which were not previously built with CEF. It shares the existing locales pak files which have been updated to include additional Chrome-specific strings. On Linux, the Chrome runtime requires GTK so use_gtk=true must be specified via GN_DEFINES when building. This change also refactors the CEF runtime, which can be tested in the various supported modes by running: $ cefclient $ cefclient --multi-threaded-message-loop $ cefclient --external-message-pump
This commit is contained in:
@@ -23,7 +23,6 @@
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "chrome/chrome_elf/chrome_elf_main.h"
|
||||
#include "chrome/install_static/initialize_from_primary_module.h"
|
||||
#include "components/crash/core/app/crashpad.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
@@ -267,8 +266,7 @@ void CefRunMessageLoop() {
|
||||
return;
|
||||
}
|
||||
|
||||
base::RunLoop run_loop;
|
||||
run_loop.Run();
|
||||
g_context->RunMessageLoop();
|
||||
}
|
||||
|
||||
void CefQuitMessageLoop() {
|
||||
@@ -284,8 +282,7 @@ void CefQuitMessageLoop() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Quit the CefBrowserMessageLoop.
|
||||
base::RunLoop::QuitCurrentWhenIdleDeprecated();
|
||||
g_context->QuitMessageLoop();
|
||||
}
|
||||
|
||||
void CefSetOSModalLoop(bool osModalLoop) {
|
||||
@@ -321,6 +318,7 @@ bool CefContext::Initialize(const CefMainArgs& args,
|
||||
void* windows_sandbox_info) {
|
||||
init_thread_id_ = base::PlatformThread::CurrentId();
|
||||
settings_ = settings;
|
||||
application_ = application;
|
||||
|
||||
#if !(defined(OS_WIN) || defined(OS_LINUX))
|
||||
if (settings.multi_threaded_message_loop) {
|
||||
@@ -361,6 +359,21 @@ bool CefContext::Initialize(const CefMainArgs& args,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
|
||||
void CefContext::RunMessageLoop() {
|
||||
// Must always be called on the same thread as Initialize.
|
||||
DCHECK(OnInitThread());
|
||||
|
||||
// Blocks until QuitMessageLoop() is called.
|
||||
main_runner_->RunMessageLoop();
|
||||
}
|
||||
|
||||
void CefContext::QuitMessageLoop() {
|
||||
// Must always be called on the same thread as Initialize.
|
||||
DCHECK(OnInitThread());
|
||||
|
||||
main_runner_->QuitMessageLoop();
|
||||
}
|
||||
|
||||
void CefContext::Shutdown() {
|
||||
// Must always be called on the same thread as Initialize.
|
||||
DCHECK(OnInitThread());
|
||||
@@ -457,11 +470,10 @@ void CefContext::OnContextInitialized() {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
// Notify the handler.
|
||||
CefRefPtr<CefApp> app = CefContentClient::Get()->application();
|
||||
if (app.get()) {
|
||||
if (application_) {
|
||||
CefRefPtr<CefBrowserProcessHandler> handler =
|
||||
app->GetBrowserProcessHandler();
|
||||
if (handler.get())
|
||||
application_->GetBrowserProcessHandler();
|
||||
if (handler)
|
||||
handler->OnContextInitialized();
|
||||
}
|
||||
}
|
||||
@@ -480,4 +492,5 @@ void CefContext::ShutdownOnUIThread() {
|
||||
|
||||
void CefContext::FinalizeShutdown() {
|
||||
browser_info_manager_.reset(nullptr);
|
||||
application_ = nullptr;
|
||||
}
|
||||
|
Reference in New Issue
Block a user