mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2024-12-11 09:08:06 +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]`
151 lines
5.3 KiB
C++
151 lines
5.3 KiB
C++
// Copyright 2016 The Chromium Embedded Framework Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be found
|
|
// in the LICENSE file.
|
|
|
|
#ifndef CEF_LIBCEF_BROWSER_VIEWS_BROWSER_VIEW_IMPL_H_
|
|
#define CEF_LIBCEF_BROWSER_VIEWS_BROWSER_VIEW_IMPL_H_
|
|
#pragma once
|
|
|
|
#include "include/cef_client.h"
|
|
#include "include/views/cef_browser_view.h"
|
|
#include "include/views/cef_browser_view_delegate.h"
|
|
#include "libcef/browser/browser_host_base.h"
|
|
#include "libcef/browser/views/browser_view_view.h"
|
|
#include "libcef/browser/views/view_impl.h"
|
|
|
|
#include "base/functional/callback_forward.h"
|
|
#include "base/memory/weak_ptr.h"
|
|
#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
|
|
|
|
class CefBrowserHostBase;
|
|
class CefWidget;
|
|
class CefWindowImpl;
|
|
class ChromeBrowserView;
|
|
class Profile;
|
|
|
|
class CefBrowserViewImpl
|
|
: public CefViewImpl<views::View, CefBrowserView, CefBrowserViewDelegate>,
|
|
public CefBrowserViewView::Delegate {
|
|
public:
|
|
using ParentClass =
|
|
CefViewImpl<views::View, CefBrowserView, CefBrowserViewDelegate>;
|
|
|
|
CefBrowserViewImpl(const CefBrowserViewImpl&) = delete;
|
|
CefBrowserViewImpl& operator=(const CefBrowserViewImpl&) = delete;
|
|
|
|
// Create a new CefBrowserView instance. |delegate| may be nullptr.
|
|
// |window_info| will only be used when creating a Chrome child window.
|
|
static CefRefPtr<CefBrowserViewImpl> Create(
|
|
const CefWindowInfo& window_info,
|
|
CefRefPtr<CefClient> client,
|
|
const CefString& url,
|
|
const CefBrowserSettings& settings,
|
|
CefRefPtr<CefDictionaryValue> extra_info,
|
|
CefRefPtr<CefRequestContext> request_context,
|
|
CefRefPtr<CefBrowserViewDelegate> delegate);
|
|
|
|
// Create a new CefBrowserView instance for a popup. |delegate| may be
|
|
// nullptr.
|
|
static CefRefPtr<CefBrowserViewImpl> CreateForPopup(
|
|
const CefBrowserSettings& settings,
|
|
CefRefPtr<CefBrowserViewDelegate> delegate,
|
|
bool is_devtools);
|
|
|
|
// Called from CefBrowserPlatformDelegate[Chrome]Views.
|
|
void WebContentsCreated(content::WebContents* web_contents);
|
|
void WebContentsDestroyed(content::WebContents* web_contents);
|
|
void BrowserCreated(CefBrowserHostBase* browser,
|
|
base::RepeatingClosure on_bounds_changed);
|
|
void BrowserDestroyed(CefBrowserHostBase* browser);
|
|
|
|
// Called to handle accelerators when the event is unhandled by the web
|
|
// content and the browser client.
|
|
bool HandleKeyboardEvent(const content::NativeWebKeyboardEvent& event);
|
|
|
|
// CefBrowserView methods:
|
|
CefRefPtr<CefBrowser> GetBrowser() override;
|
|
CefRefPtr<CefView> GetChromeToolbar() override;
|
|
void SetPreferAccelerators(bool prefer_accelerators) override;
|
|
cef_runtime_style_t GetRuntimeStyle() override;
|
|
|
|
// CefView methods:
|
|
CefRefPtr<CefBrowserView> AsBrowserView() override { return this; }
|
|
void RequestFocus() override;
|
|
void SetBackgroundColor(cef_color_t color) override;
|
|
|
|
// CefViewAdapter methods:
|
|
void Detach() override;
|
|
std::string GetDebugType() override { return "BrowserView"; }
|
|
void GetDebugInfo(base::Value::Dict* info, bool include_children) override;
|
|
|
|
// CefBrowserViewView::Delegate methods:
|
|
void AddedToWidget() override;
|
|
void RemovedFromWidget() override;
|
|
void OnBoundsChanged() override;
|
|
bool OnGestureEvent(ui::GestureEvent* event) override;
|
|
|
|
// Return the WebView representation of this object.
|
|
views::WebView* web_view() const;
|
|
|
|
// Return the CEF specialization of BrowserView.
|
|
ChromeBrowserView* chrome_browser_view() const;
|
|
|
|
// Return the CefWindowImpl hosting this object.
|
|
CefWindowImpl* cef_window_impl() const;
|
|
|
|
bool IsAlloyStyle() const { return is_alloy_style_; }
|
|
bool IsChromeStyle() const { return !is_alloy_style_; }
|
|
|
|
private:
|
|
// Create a new implementation object.
|
|
// Always call Initialize() after creation.
|
|
// |delegate| may be nullptr.
|
|
CefBrowserViewImpl(CefRefPtr<CefBrowserViewDelegate> delegate,
|
|
bool is_devtools_popup);
|
|
|
|
void SetPendingBrowserCreateParams(
|
|
const CefWindowInfo& window_info,
|
|
CefRefPtr<CefClient> client,
|
|
const CefString& url,
|
|
const CefBrowserSettings& settings,
|
|
CefRefPtr<CefDictionaryValue> extra_info,
|
|
CefRefPtr<CefRequestContext> request_context);
|
|
|
|
void SetDefaults(const CefBrowserSettings& settings);
|
|
|
|
// CefViewImpl methods:
|
|
views::View* CreateRootView() override;
|
|
void InitializeRootView() override;
|
|
|
|
// Logic extracted from UnhandledKeyboardEventHandler::HandleKeyboardEvent for
|
|
// the handling of accelerators. Returns true if the event was handled by the
|
|
// accelerator.
|
|
bool HandleAccelerator(const content::NativeWebKeyboardEvent& event,
|
|
views::FocusManager* focus_manager);
|
|
|
|
void RequestFocusInternal();
|
|
|
|
void DisassociateFromWidget();
|
|
|
|
// True if the browser is Alloy style, otherwise Chrome style.
|
|
const bool is_alloy_style_;
|
|
|
|
std::unique_ptr<CefBrowserCreateParams> pending_browser_create_params_;
|
|
|
|
CefRefPtr<CefBrowserHostBase> browser_;
|
|
|
|
views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_;
|
|
bool ignore_next_char_event_ = false;
|
|
|
|
base::RepeatingClosure on_bounds_changed_;
|
|
|
|
CefWidget* cef_widget_ = nullptr;
|
|
Profile* profile_ = nullptr;
|
|
|
|
base::WeakPtrFactory<CefBrowserViewImpl> weak_ptr_factory_;
|
|
|
|
IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(CefBrowserViewImpl);
|
|
};
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_VIEWS_BROWSER_VIEW_IMPL_H_
|