cef/libcef/common/alloy/alloy_main_runner_delegate.cc
Marshall Greenblatt 240b869db5 widevine: Use component updater with the Alloy runtime (fixes issue #3149)
Widevine CDM binaries will be downloaded on supported platforms shortly after
application startup. Widevine support will then become available within a few
seconds after successful installation on Windows or after the next application
restart on other platforms. The CDM files will be downloaded to a "WidevineCdm"
directory inside the `CefSettings.user_data_path` directory.

Pass the `--disable-component-update` command-line flag to disable Widevine
download and installation. Pass the `--component-updater=fast-update` command-
line flag to force Widevine download immediately after application startup.

See the related issue for additional usage details.
2021-08-09 21:10:45 -04:00

64 lines
2.2 KiB
C++

// Copyright 2020 The Chromium Embedded Framework Authors.
// Portions copyright 2012 The Chromium 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 "libcef/common/alloy/alloy_main_runner_delegate.h"
#include "libcef/browser/alloy/chrome_browser_process_alloy.h"
#include "libcef/common/alloy/alloy_main_delegate.h"
#include "libcef/renderer/alloy/alloy_content_renderer_client.h"
#include "content/public/browser/render_process_host.h"
#include "ui/base/resource/resource_bundle.h"
AlloyMainRunnerDelegate::AlloyMainRunnerDelegate(CefMainRunnerHandler* runner,
CefSettings* settings,
CefRefPtr<CefApp> application)
: runner_(runner), settings_(settings), application_(application) {}
AlloyMainRunnerDelegate::~AlloyMainRunnerDelegate() = default;
content::ContentMainDelegate*
AlloyMainRunnerDelegate::GetContentMainDelegate() {
if (!main_delegate_) {
main_delegate_ =
std::make_unique<AlloyMainDelegate>(runner_, settings_, application_);
}
return main_delegate_.get();
}
void AlloyMainRunnerDelegate::BeforeMainThreadInitialize(
const CefMainArgs& args) {
g_browser_process = new ChromeBrowserProcessAlloy();
}
void AlloyMainRunnerDelegate::BeforeMainThreadRun() {
static_cast<ChromeBrowserProcessAlloy*>(g_browser_process)->Initialize();
}
void AlloyMainRunnerDelegate::AfterUIThreadInitialize() {
static_cast<ChromeBrowserProcessAlloy*>(g_browser_process)
->OnContextInitialized();
}
void AlloyMainRunnerDelegate::AfterUIThreadShutdown() {
static_cast<ChromeBrowserProcessAlloy*>(g_browser_process)
->CleanupOnUIThread();
ui::ResourceBundle::GetSharedInstance().CleanupOnUIThread();
}
void AlloyMainRunnerDelegate::BeforeMainThreadShutdown() {
if (content::RenderProcessHost::run_renderer_in_process()) {
// Blocks until RenderProcess cleanup is complete.
AlloyContentRendererClient::Get()->RunSingleProcessCleanup();
}
}
void AlloyMainRunnerDelegate::AfterMainThreadShutdown() {
if (g_browser_process) {
delete g_browser_process;
g_browser_process = nullptr;
}
}