mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2024-12-13 01:56:20 +01:00
dca0435d2f
Split the Alloy runtime into bootstrap and style components. Support creation of Alloy style browsers and windows with the Chrome runtime. Chrome runtime (`--enable-chrome-runtime`) + Alloy style (`--use-alloy-style`) supports Views (`--use-views`), native parent (`--use-native`) and windowless rendering (`--off-screen-rendering-enabled`). Print preview is supported in all cases except with windowless rendering on all platforms and native parent on MacOS. It is disabled by default with Alloy style for legacy compatibility. Where supported it can be enabled or disabled globally using `--[enable|disable]-print-preview` or configured on a per-RequestContext basis using the `printing.print_preview_disabled` preference. It also behaves as expected when triggered via the PDF viewer print button. Chrome runtime + Alloy style behavior differs from Alloy runtime in the following significant ways: - Supports Chrome error pages by default. - DevTools popups are Chrome style only (cannot be windowless). - The Alloy extension API will not supported. Chrome runtime + Alloy style passes all expected Alloy ceftests except the following: - `DisplayTest.AutoResize` (Alloy extension API not supported) - `DownloadTest.*` (Download API not yet supported) - `ExtensionTest.*` (Alloy extension API not supported) This change also adds Chrome runtime support for CefContextMenuHandler::RunContextMenu (see #3293). This change also explicitly blocks (and doesn't retry) FrameAttached requests from PDF viewer and print preview excluded frames (see #3664). Known issues specific to Chrome runtime + Alloy style: - DevTools popup with windowless rendering doesn't load successfully. Use windowed rendering or remote debugging as a workaround. - Chrome style Window with Alloy style BrowserView (`--use-alloy-style --use-chrome-style-window`) does not show Chrome theme changes. To test: - Run `ceftests --enable-chrome-runtime --use-alloy-style [--use-chrome-style-window] [--use-views|--use-native] --gtest_filter=...` - Run `cefclient --enable-chrome-runtime --use-alloy-style [--use-chrome-style-window] [--use-views|--use-native|--off-screen-rendering-enabled]` - Run `cefsimple --enable-chrome-runtime --use-alloy-style [--use-views]`
90 lines
3.3 KiB
C++
90 lines
3.3 KiB
C++
// Copyright 2019 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/browser/chrome/chrome_browser_main_extra_parts_cef.h"
|
|
|
|
#include "libcef/browser/alloy/dialogs/alloy_constrained_window_views_client.h"
|
|
#include "libcef/browser/chrome/chrome_context_menu_handler.h"
|
|
#include "libcef/browser/chrome/chrome_startup_browser_creator.h"
|
|
#include "libcef/browser/context.h"
|
|
#include "libcef/browser/file_dialog_runner.h"
|
|
#include "libcef/browser/net/chrome_scheme_handler.h"
|
|
#include "libcef/browser/permission_prompt.h"
|
|
|
|
#include "base/task/thread_pool.h"
|
|
#include "chrome/browser/profiles/profile.h"
|
|
#include "chrome/browser/ui/views/chrome_constrained_window_views_client.h"
|
|
#include "components/constrained_window/constrained_window_views.h"
|
|
|
|
#if BUILDFLAG(IS_LINUX)
|
|
#include "base/linux_util.h"
|
|
#endif
|
|
|
|
#if BUILDFLAG(IS_WIN)
|
|
#include "chrome/browser/win/app_icon.h"
|
|
#endif
|
|
|
|
ChromeBrowserMainExtraPartsCef::ChromeBrowserMainExtraPartsCef() = default;
|
|
|
|
ChromeBrowserMainExtraPartsCef::~ChromeBrowserMainExtraPartsCef() = default;
|
|
|
|
void ChromeBrowserMainExtraPartsCef::PostProfileInit(Profile* profile,
|
|
bool is_initial_profile) {
|
|
if (!is_initial_profile) {
|
|
return;
|
|
}
|
|
|
|
CefRequestContextSettings settings;
|
|
CefContext::Get()->PopulateGlobalRequestContextSettings(&settings);
|
|
|
|
// Use the existing path for the initial profile.
|
|
CefString(&settings.cache_path) = profile->GetPath().value();
|
|
|
|
// Create the global RequestContext.
|
|
global_request_context_ =
|
|
CefRequestContextImpl::CreateGlobalRequestContext(settings);
|
|
}
|
|
|
|
void ChromeBrowserMainExtraPartsCef::PostBrowserStart() {
|
|
// Register the callback before ChromeBrowserMainParts::PostBrowserStart
|
|
// allows ProcessSingleton to begin processing messages.
|
|
startup_browser_creator::RegisterProcessCommandLineCallback();
|
|
|
|
#if BUILDFLAG(IS_LINUX)
|
|
// This may be called indirectly via StartupBrowserCreator::LaunchBrowser.
|
|
// Call it here before blocking is disallowed to avoid assertions.
|
|
base::GetLinuxDistro();
|
|
#endif
|
|
}
|
|
|
|
void ChromeBrowserMainExtraPartsCef::PreMainMessageLoopRun() {
|
|
background_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
|
|
{base::TaskPriority::BEST_EFFORT,
|
|
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
|
|
user_visible_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
|
|
{base::TaskPriority::USER_VISIBLE,
|
|
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
|
|
user_blocking_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
|
|
{base::TaskPriority::USER_BLOCKING,
|
|
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
|
|
|
|
scheme::RegisterWebUIControllerFactory();
|
|
context_menu::RegisterCallbacks();
|
|
file_dialog_runner::RegisterFactory();
|
|
permission_prompt::RegisterCreateCallback();
|
|
|
|
#if BUILDFLAG(IS_WIN)
|
|
const auto& settings = CefContext::Get()->settings();
|
|
if (settings.chrome_app_icon_id > 0) {
|
|
SetExeAppIconResourceId(settings.chrome_app_icon_id);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
void ChromeBrowserMainExtraPartsCef::ToolkitInitialized() {
|
|
// Override the default Chrome client.
|
|
SetConstrainedWindowViewsClient(CreateAlloyConstrainedWindowViewsClient(
|
|
CreateChromeConstrainedWindowViewsClient()));
|
|
}
|