cef/patch/patches/chrome_browser_browser.patch

663 lines
25 KiB
Diff

diff --git chrome/browser/browser_about_handler.cc chrome/browser/browser_about_handler.cc
index 2480282a19d12..dbd1fbf8a15b5 100644
--- chrome/browser/browser_about_handler.cc
+++ chrome/browser/browser_about_handler.cc
@@ -72,6 +72,9 @@ bool HandleNonNavigationAboutURL(const GURL& url) {
FROM_HERE, base::BindOnce(&chrome::AttemptExit));
return true;
}
+ if (base::EqualsCaseInsensitiveASCII(spec, "chrome://ignore/")) {
+ return true;
+ }
return false;
}
diff --git chrome/browser/devtools/devtools_window.cc chrome/browser/devtools/devtools_window.cc
index b4a11f0509df7..04f615abc4404 100644
--- chrome/browser/devtools/devtools_window.cc
+++ chrome/browser/devtools/devtools_window.cc
@@ -38,6 +38,7 @@
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/task_manager/web_contents_tags.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
@@ -1223,6 +1224,13 @@ DevToolsWindow* DevToolsWindow::Create(
!browser->is_type_normal()) {
can_dock = false;
}
+
+#if BUILDFLAG(ENABLE_CEF)
+ if (can_dock && browser && browser->cef_delegate()) {
+ // Don't dock DevTools for CEF-managed browsers.
+ can_dock = false;
+ }
+#endif
}
// Create WebContents with devtools.
@@ -1687,9 +1695,13 @@ void DevToolsWindow::OpenInNewTab(const GURL& url) {
if (!inspected_web_contents ||
!inspected_web_contents->OpenURL(params,
/*navigation_handle_callback=*/{})) {
+#if !BUILDFLAG(ENABLE_CEF)
+ // Remove default behavior when CEF handles the open via OnOpenURLFromTab.
+ // See CEF issue #3735.
chrome::ScopedTabbedBrowserDisplayer displayer(profile_);
chrome::AddSelectedTabWithURL(displayer.browser(), fixed_url,
ui::PAGE_TRANSITION_LINK);
+#endif
}
}
@@ -1852,12 +1864,28 @@ void DevToolsWindow::CreateDevToolsBrowser() {
Browser::CreationStatus::kOk) {
return;
}
- browser_ =
- Browser::Create(Browser::CreateParams::CreateForDevTools(profile_));
- browser_->tab_strip_model()->AddWebContents(
- OwnedMainWebContents::TakeWebContents(
- std::move(owned_main_web_contents_)),
- -1, ui::PAGE_TRANSITION_AUTO_TOPLEVEL, AddTabTypes::ADD_ACTIVE);
+
+ auto* inspected_web_contents = GetInspectedWebContents();
+ auto* opener = chrome::FindBrowserWithTab(inspected_web_contents);
+ auto devtools_contents = OwnedMainWebContents::TakeWebContents(
+ std::move(owned_main_web_contents_));
+
+#if BUILDFLAG(ENABLE_CEF)
+ // If a Browser is created, it will take ownership of |devtools_contents|.
+ browser_ = cef::BrowserDelegate::CreateDevToolsBrowser(
+ profile_, opener, inspected_web_contents, devtools_contents);
+#endif
+
+ if (!browser_) {
+ auto create_params = Browser::CreateParams::CreateForDevTools(profile_);
+ create_params.opener = opener;
+
+ browser_ = Browser::Create(std::move(create_params));
+ browser_->tab_strip_model()->AddWebContents(
+ std::move(devtools_contents),
+ -1, ui::PAGE_TRANSITION_AUTO_TOPLEVEL, AddTabTypes::ADD_ACTIVE);
+ }
+
OverrideAndSyncDevToolsRendererPrefs();
}
diff --git chrome/browser/ui/BUILD.gn chrome/browser/ui/BUILD.gn
index bc6e4008f2c5a..1b6b33e96b46c 100644
--- chrome/browser/ui/BUILD.gn
+++ chrome/browser/ui/BUILD.gn
@@ -8,6 +8,7 @@ import("//build/config/compiler/compiler.gni")
import("//build/config/features.gni")
import("//build/config/ozone.gni")
import("//build/config/ui.gni")
+import("//cef/libcef/features/features.gni")
import("//chrome/browser/buildflags.gni")
import("//chrome/common/features.gni")
import("//chromeos/ash/components/assistant/assistant.gni")
@@ -354,6 +355,10 @@ static_library("ui") {
"//build/config/compiler:wexit_time_destructors",
]
+ if (enable_cef) {
+ configs += [ "//cef/libcef/features:config" ]
+ }
+
public_deps = [
# WARNING WARNING WARNING
# New dependencies outside of //chrome/browser should be added to
@@ -379,6 +384,7 @@ static_library("ui") {
"//build:chromeos_buildflags",
"//build/config/chromebox_for_meetings:buildflags",
"//cc/paint",
+ "//cef/libcef/features",
"//chrome:resources",
"//chrome:strings",
"//chrome/app:chrome_dll_resources",
@@ -717,6 +723,10 @@ static_library("ui") {
deps += [ "//components/plus_addresses/resources:vector_icons" ]
}
+ if (enable_cef) {
+ deps += [ "//cef:cef_resources" ]
+ }
+
# TODO(crbug.com/41437292): Remove this circular dependency.
# Any circular includes must depend on the target "//chrome/browser:browser_public_dependencies".
# These are all-platform circular includes.
@@ -1009,8 +1019,6 @@ static_library("ui") {
sources += [
"app_icon_loader.cc",
"app_icon_loader.h",
- "bluetooth/chrome_bluetooth_chooser_controller.cc",
- "bluetooth/chrome_bluetooth_chooser_controller.h",
"bookmarks/bookmark_bar.h",
"bookmarks/bookmark_context_menu_controller.cc",
"bookmarks/bookmark_context_menu_controller.h",
@@ -1466,7 +1474,6 @@ static_library("ui") {
"tabs/tab_menu_model_factory.h",
"tabs/tab_model.cc",
"tabs/tab_model.h",
- "tabs/tab_network_state.cc",
"tabs/tab_network_state.h",
"tabs/tab_renderer_data.cc",
"tabs/tab_renderer_data.h",
@@ -3208,8 +3215,6 @@ static_library("ui") {
if (is_win || is_mac || is_linux || is_chromeos) {
sources += [
- "frame/window_frame_util.cc",
- "frame/window_frame_util.h",
"incognito_clear_browsing_data_dialog_interface.h",
"passwords/password_cross_domain_confirmation_popup_controller_impl.cc",
"passwords/password_cross_domain_confirmation_popup_controller_impl.h",
@@ -5535,8 +5540,6 @@ static_library("ui") {
if (use_aura) {
sources += [
- "aura/accessibility/automation_manager_aura.cc",
- "aura/accessibility/automation_manager_aura.h",
"overscroll_pref_manager.cc",
"overscroll_pref_manager.h",
"views/accelerator_utils_aura.cc",
@@ -5788,6 +5791,7 @@ static_library("ui") {
if (enable_printing) {
deps += [
"//components/printing/browser",
+ "//components/printing/common:mojo_interfaces",
"//printing",
]
}
diff --git chrome/browser/ui/browser.cc chrome/browser/ui/browser.cc
index e1ebde9b491c3..ce2a8d8a79747 100644
--- chrome/browser/ui/browser.cc
+++ chrome/browser/ui/browser.cc
@@ -272,6 +272,25 @@
#include "components/captive_portal/content/captive_portal_tab_helper.h"
#endif
+#if BUILDFLAG(ENABLE_CEF)
+#define CALL_CEF_DELEGATE(name, ...) \
+ if (cef_browser_delegate_) { \
+ cef_browser_delegate_->name(__VA_ARGS__); \
+ }
+#define CALL_CEF_DELEGATE_RETURN(name, ...) \
+ if (cef_browser_delegate_) { \
+ return cef_browser_delegate_->name(__VA_ARGS__); \
+ }
+#define CALL_CEF_DELEGATE_RESULT(name, result, ...) \
+ if (cef_browser_delegate_) { \
+ result = cef_browser_delegate_->name(__VA_ARGS__); \
+ }
+#else // !BUILDFLAG(ENABLE_CEF)
+#define CALL_CEF_DELEGATE(name, ...)
+#define CALL_CEF_DELEGATE_RETURN(name, ...)
+#define CALL_CEF_DELEGATE_RESULT(name, result, ...)
+#endif
+
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "chrome/browser/extensions/extension_browser_window_helper.h"
#endif
@@ -537,6 +556,10 @@ Browser::Browser(const CreateParams& params)
type_(params.type),
profile_(params.profile),
window_(nullptr),
+#if BUILDFLAG(ENABLE_CEF)
+ cef_browser_delegate_(
+ cef::BrowserDelegate::Create(this, params.cef_params, params.opener)),
+#endif
tab_strip_model_delegate_(
std::make_unique<chrome::BrowserTabStripModelDelegate>(this)),
tab_strip_model_(std::make_unique<TabStripModel>(
@@ -763,6 +786,12 @@ Browser::~Browser() {
// away so they don't try and call back to us.
if (select_file_dialog_.get())
select_file_dialog_->ListenerDestroyed();
+
+ // Clean up any objects attached via UserData before implicit destruction
+ // of CreateParams. Destruction of those objects may call into something
+ // (ProfileImpl, PrefService, etc) that will be destroyed when the last
+ // CefRequestContextImpl reference (held by CreateParams) is released.
+ ClearAllUserData();
}
///////////////////////////////////////////////////////////////////////////////
@@ -1305,6 +1334,8 @@ void Browser::WindowFullscreenStateChanged() {
->WindowFullscreenStateChanged();
command_controller_->FullscreenStateChanged();
UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN);
+
+ CALL_CEF_DELEGATE(WindowFullscreenStateChanged);
}
void Browser::FullscreenTopUIStateChanged() {
@@ -1635,6 +1666,14 @@ content::KeyboardEventProcessingResult Browser::PreHandleKeyboardEvent(
if (exclusive_access_manager_->HandleUserKeyEvent(event))
return content::KeyboardEventProcessingResult::HANDLED;
+#if BUILDFLAG(ENABLE_CEF)
+ if (cef_browser_delegate_) {
+ auto result = cef_browser_delegate_->PreHandleKeyboardEvent(source, event);
+ if (result != content::KeyboardEventProcessingResult::NOT_HANDLED)
+ return result;
+ }
+#endif
+
return window()->PreHandleKeyboardEvent(event);
}
@@ -1642,8 +1681,18 @@ bool Browser::HandleKeyboardEvent(content::WebContents* source,
const NativeWebKeyboardEvent& event) {
DevToolsWindow* devtools_window =
DevToolsWindow::GetInstanceForInspectedWebContents(source);
- return (devtools_window && devtools_window->ForwardKeyboardEvent(event)) ||
- window()->HandleKeyboardEvent(event);
+ if (devtools_window && devtools_window->ForwardKeyboardEvent(event)) {
+ return true;
+ }
+
+#if BUILDFLAG(ENABLE_CEF)
+ if (cef_browser_delegate_ &&
+ cef_browser_delegate_->HandleKeyboardEvent(source, event)) {
+ return true;
+ }
+#endif
+
+ return window()->HandleKeyboardEvent(event);
}
bool Browser::TabsNeedBeforeUnloadFired() const {
@@ -1798,6 +1847,14 @@ WebContents* Browser::OpenURLFromTab(
std::move(navigation_handle_callback));
}
+#if BUILDFLAG(ENABLE_CEF)
+ if (cef_browser_delegate_ &&
+ !cef_browser_delegate_->OpenURLFromTabEx(source, params,
+ navigation_handle_callback)) {
+ return nullptr;
+ }
+#endif
+
NavigateParams nav_params(this, params.url, params.transition);
nav_params.FillNavigateParamsFromOpenURLParams(params);
nav_params.source_contents = source;
@@ -1964,6 +2021,8 @@ void Browser::LoadingStateChanged(WebContents* source,
bool should_show_loading_ui) {
ScheduleUIUpdate(source, content::INVALIDATE_TYPE_LOAD);
UpdateWindowForLoadingStateChanged(source, should_show_loading_ui);
+
+ CALL_CEF_DELEGATE(LoadingStateChanged, source, should_show_loading_ui);
}
void Browser::CloseContents(WebContents* source) {
@@ -1992,6 +2051,8 @@ void Browser::SetContentsBounds(WebContents* source, const gfx::Rect& bounds) {
}
void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
+ CALL_CEF_DELEGATE(UpdateTargetURL, source, url);
+
if (!GetStatusBubble())
return;
@@ -1999,6 +2060,17 @@ void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
GetStatusBubble()->SetURL(url);
}
+bool Browser::DidAddMessageToConsole(
+ content::WebContents* source,
+ blink::mojom::ConsoleMessageLevel log_level,
+ const std::u16string& message,
+ int32_t line_no,
+ const std::u16string& source_id) {
+ CALL_CEF_DELEGATE_RETURN(DidAddMessageToConsole, source, log_level, message,
+ line_no, source_id);
+ return false;
+}
+
void Browser::ContentsMouseEvent(WebContents* source, const ui::Event& event) {
const ui::EventType type = event.type();
const bool exited = type == ui::EventType::kMouseExited;
@@ -2027,6 +2099,19 @@ bool Browser::TakeFocus(content::WebContents* source, bool reverse) {
return false;
}
+void Browser::CanDownload(const GURL& url,
+ const std::string& request_method,
+ base::OnceCallback<void(bool)> callback) {
+#if BUILDFLAG(ENABLE_CEF)
+ if (cef_browser_delegate_) {
+ cef_browser_delegate_->CanDownload(url, request_method,
+ std::move(callback));
+ return;
+ }
+#endif
+ std::move(callback).Run(true);
+}
+
void Browser::BeforeUnloadFired(WebContents* web_contents,
bool proceed,
bool* proceed_to_fire_unload) {
@@ -2126,12 +2211,24 @@ void Browser::WebContentsCreated(WebContents* source_contents,
// Make the tab show up in the task manager.
task_manager::WebContentsTags::CreateForTabContents(new_contents);
+
+ CALL_CEF_DELEGATE(WebContentsCreated, source_contents,
+ opener_render_process_id, opener_render_frame_id,
+ frame_name, target_url, new_contents);
}
void Browser::RendererUnresponsive(
WebContents* source,
content::RenderWidgetHost* render_widget_host,
base::RepeatingClosure hang_monitor_restarter) {
+#if BUILDFLAG(ENABLE_CEF)
+ if (cef_browser_delegate_ &&
+ cef_browser_delegate_->RendererUnresponsiveEx(source, render_widget_host,
+ hang_monitor_restarter)) {
+ return;
+ }
+#endif
+
// Don't show the page hung dialog when a HTML popup hangs because
// the dialog will take the focus and immediately close the popup.
RenderWidgetHostView* view = render_widget_host->GetView();
@@ -2144,6 +2241,13 @@ void Browser::RendererUnresponsive(
void Browser::RendererResponsive(
WebContents* source,
content::RenderWidgetHost* render_widget_host) {
+#if BUILDFLAG(ENABLE_CEF)
+ if (cef_browser_delegate_ &&
+ cef_browser_delegate_->RendererResponsiveEx(source, render_widget_host)) {
+ return;
+ }
+#endif
+
RenderWidgetHostView* view = render_widget_host->GetView();
if (view && !render_widget_host->GetView()->IsHTMLFormPopup()) {
TabDialogs::FromWebContents(source)->HideHungRendererDialog(
@@ -2153,6 +2257,15 @@ void Browser::RendererResponsive(
content::JavaScriptDialogManager* Browser::GetJavaScriptDialogManager(
WebContents* source) {
+#if BUILDFLAG(ENABLE_CEF)
+ if (cef_browser_delegate_) {
+ auto* cef_js_dialog_manager =
+ cef_browser_delegate_->GetJavaScriptDialogManager(source);
+ if (cef_js_dialog_manager) {
+ return cef_js_dialog_manager;
+ }
+ }
+#endif
return javascript_dialogs::TabModalDialogManager::FromWebContents(source);
}
@@ -2188,6 +2301,11 @@ void Browser::DraggableRegionsChanged(
if (app_controller_) {
app_controller_->DraggableRegionsChanged(regions, contents);
}
+#if BUILDFLAG(ENABLE_CEF)
+ else if (cef_delegate()) {
+ cef_delegate()->DraggableRegionsChanged(regions, contents);
+ }
+#endif
}
void Browser::DidFinishNavigation(
@@ -2268,11 +2386,15 @@ void Browser::EnterFullscreenModeForTab(
const blink::mojom::FullscreenOptions& options) {
exclusive_access_manager_->fullscreen_controller()->EnterFullscreenModeForTab(
requesting_frame, options.display_id);
+
+ CALL_CEF_DELEGATE(EnterFullscreenModeForTab, requesting_frame, options);
}
void Browser::ExitFullscreenModeForTab(WebContents* web_contents) {
exclusive_access_manager_->fullscreen_controller()->ExitFullscreenModeForTab(
web_contents);
+
+ CALL_CEF_DELEGATE(ExitFullscreenModeForTab, web_contents);
}
bool Browser::IsFullscreenForTabOrPending(const WebContents* web_contents) {
@@ -2470,6 +2592,15 @@ void Browser::RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
content::MediaResponseCallback callback) {
+#if BUILDFLAG(ENABLE_CEF)
+ if (cef_browser_delegate_) {
+ callback = cef_browser_delegate_->RequestMediaAccessPermissionEx(
+ web_contents, request, std::move(callback));
+ if (callback.is_null())
+ return;
+ }
+#endif
+
const extensions::Extension* extension =
GetExtensionForOrigin(profile_, request.security_origin);
MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest(
@@ -3026,9 +3157,10 @@ void Browser::RemoveScheduledUpdatesFor(WebContents* contents) {
// Browser, Getters for UI (private):
StatusBubble* Browser::GetStatusBubble() {
+ bool show_by_default = true;
// For kiosk and exclusive app mode we want to always hide the status bubble.
if (IsRunningInAppMode()) {
- return nullptr;
+ show_by_default = false;
}
// We hide the status bar for web apps windows as this matches native
@@ -3036,6 +3168,12 @@ StatusBubble* Browser::GetStatusBubble() {
// mode, as the minimal browser UI includes the status bar.
if (web_app::AppBrowserController::IsWebApp(this) &&
!app_controller()->HasMinimalUiButtons()) {
+ show_by_default = false;
+ }
+
+ bool show = show_by_default;
+ CALL_CEF_DELEGATE_RESULT(ShowStatusBubble, show, show_by_default);
+ if (!show) {
return nullptr;
}
@@ -3185,6 +3323,8 @@ void Browser::SetAsDelegate(WebContents* web_contents, bool set_delegate) {
BookmarkTabHelper::FromWebContents(web_contents)->RemoveObserver(this);
web_contents_collection_.StopObserving(web_contents);
}
+
+ CALL_CEF_DELEGATE(SetAsDelegate, web_contents, set_delegate);
}
void Browser::TabDetachedAtImpl(content::WebContents* contents,
@@ -3339,6 +3479,14 @@ bool Browser::PictureInPictureBrowserSupportsWindowFeature(
bool Browser::SupportsWindowFeatureImpl(WindowFeature feature,
bool check_can_support) const {
+#if BUILDFLAG(ENABLE_CEF)
+ if (cef_delegate()) {
+ if (auto value = cef_delegate()->SupportsWindowFeature(feature)) {
+ return *value;
+ }
+ }
+#endif
+
switch (type_) {
case TYPE_NORMAL:
return NormalBrowserSupportsWindowFeature(feature, check_can_support);
diff --git chrome/browser/ui/browser.h chrome/browser/ui/browser.h
index 85b6845aa871c..b2975ce19ac95 100644
--- chrome/browser/ui/browser.h
+++ chrome/browser/ui/browser.h
@@ -24,6 +24,7 @@
#include "base/timer/elapsed_timer.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
+#include "cef/libcef/features/features.h"
#include "chrome/browser/tab_contents/web_contents_collection.h"
#include "chrome/browser/themes/theme_service_observer.h"
#include "chrome/browser/ui/bookmarks/bookmark_bar.h"
@@ -53,6 +54,10 @@
#include "ui/gfx/geometry/rect.h"
#include "ui/shell_dialogs/select_file_dialog.h"
+#if BUILDFLAG(ENABLE_CEF)
+#include "cef/libcef/browser/chrome/browser_delegate.h"
+#endif
+
#if BUILDFLAG(IS_ANDROID)
#error This file should only be included on desktop.
#endif
@@ -337,6 +342,15 @@ class Browser : public TabStripModelObserver,
// Document Picture in Picture options, specific to TYPE_PICTURE_IN_PICTURE.
std::optional<blink::mojom::PictureInPictureWindowOptions> pip_options;
+#if BUILDFLAG(ENABLE_CEF)
+ // Opaque CEF-specific configuration. Will be propagated to new Browsers.
+ scoped_refptr<cef::BrowserDelegate::CreateParams> cef_params;
+
+ // Specify the Browser that is opening this popup.
+ // Currently only used with TYPE_PICTURE_IN_PICTURE and TYPE_DEVTOOLS.
+ raw_ptr<Browser, DanglingUntriaged> opener = nullptr;
+#endif
+
private:
friend class Browser;
friend class WindowSizerChromeOSTest;
@@ -418,6 +432,13 @@ class Browser : public TabStripModelObserver,
update_ui_immediately_for_testing_ = true;
}
+ // Return true if CEF will expose the toolbar to the client. This value is
+ // used to selectively enable toolbar behaviors such as command processing
+ // and omnibox focus without also including the toolbar in BrowserView layout
+ // calculations.
+ void set_toolbar_overridden(bool val) { toolbar_overridden_ = val; }
+ bool toolbar_overridden() const { return toolbar_overridden_; }
+
// Accessors ////////////////////////////////////////////////////////////////
const CreateParams& create_params() const { return create_params_; }
@@ -519,6 +540,12 @@ class Browser : public TabStripModelObserver,
base::WeakPtr<Browser> AsWeakPtr();
base::WeakPtr<const Browser> AsWeakPtr() const;
+#if BUILDFLAG(ENABLE_CEF)
+ cef::BrowserDelegate* cef_delegate() const {
+ return cef_browser_delegate_.get();
+ }
+#endif
+
// Get the FindBarController for this browser, creating it if it does not
// yet exist.
FindBarController* GetFindBarController();
@@ -947,10 +974,18 @@ class Browser : public TabStripModelObserver,
void SetContentsBounds(content::WebContents* source,
const gfx::Rect& bounds) override;
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
+ bool DidAddMessageToConsole(content::WebContents* source,
+ blink::mojom::ConsoleMessageLevel log_level,
+ const std::u16string& message,
+ int32_t line_no,
+ const std::u16string& source_id) override;
void ContentsMouseEvent(content::WebContents* source,
const ui::Event& event) override;
void ContentsZoomChange(bool zoom_in) override;
bool TakeFocus(content::WebContents* source, bool reverse) override;
+ void CanDownload(const GURL& url,
+ const std::string& request_method,
+ base::OnceCallback<void(bool)> callback) override;
void BeforeUnloadFired(content::WebContents* source,
bool proceed,
bool* proceed_to_fire_unload) override;
@@ -1285,6 +1320,10 @@ class Browser : public TabStripModelObserver,
// This Browser's window.
raw_ptr<BrowserWindow, DanglingUntriaged> window_;
+#if BUILDFLAG(ENABLE_CEF)
+ std::unique_ptr<cef::BrowserDelegate> cef_browser_delegate_;
+#endif
+
std::unique_ptr<TabStripModelDelegate> const tab_strip_model_delegate_;
std::unique_ptr<TabStripModel> const tab_strip_model_;
@@ -1351,6 +1390,8 @@ class Browser : public TabStripModelObserver,
const std::string initial_workspace_;
bool initial_visible_on_all_workspaces_state_;
+ bool toolbar_overridden_ = false;
+
CreationSource creation_source_ = CreationSource::kUnknown;
UnloadController unload_controller_;
diff --git chrome/browser/ui/browser_navigator.cc chrome/browser/ui/browser_navigator.cc
index 061432f5974e1..46de9334a4daa 100644
--- chrome/browser/ui/browser_navigator.cc
+++ chrome/browser/ui/browser_navigator.cc
@@ -270,6 +270,10 @@ std::tuple<Browser*, int> GetBrowserAndTabForDisposition(
browser_params.pip_options = pip_options;
+#if BUILDFLAG(ENABLE_CEF)
+ browser_params.opener = params.browser;
+#endif
+
const BrowserWindow* const browser_window = params.browser->window();
const gfx::NativeWindow native_window =
browser_window ? browser_window->GetNativeWindow()
@@ -558,6 +562,13 @@ std::unique_ptr<content::WebContents> CreateTargetContents(
std::unique_ptr<WebContents> target_contents =
WebContents::Create(create_params);
+#if BUILDFLAG(ENABLE_CEF)
+ auto cef_delegate = params.browser->cef_delegate();
+ if (cef_delegate) {
+ cef_delegate->OnWebContentsCreated(target_contents.get());
+ }
+#endif
+
// New tabs can have WebUI URLs that will make calls back to arbitrary
// tab helpers, so the entire set of tab helpers needs to be set up
// immediately.
diff --git chrome/browser/ui/browser_tabstrip.cc chrome/browser/ui/browser_tabstrip.cc
index e4b6094c5197e..4d2d12ae5725e 100644
--- chrome/browser/ui/browser_tabstrip.cc
+++ chrome/browser/ui/browser_tabstrip.cc
@@ -33,9 +33,13 @@ content::WebContents* AddAndReturnTabAt(
// Time new tab page creation time. We keep track of the timing data in
// WebContents, but we want to include the time it takes to create the
// WebContents object too.
+ // For CEF use a PageTransition that matches
+ // CefFrameHostImpl::kPageTransitionExplicit.
base::TimeTicks new_tab_start_time = base::TimeTicks::Now();
NavigateParams params(browser, url.is_empty() ? browser->GetNewTabURL() : url,
- ui::PAGE_TRANSITION_TYPED);
+ static_cast<ui::PageTransition>(
+ ui::PAGE_TRANSITION_TYPED |
+ ui::PAGE_TRANSITION_FROM_ADDRESS_BAR));
params.disposition = foreground ? WindowOpenDisposition::NEW_FOREGROUND_TAB
: WindowOpenDisposition::NEW_BACKGROUND_TAB;
params.tabstrip_index = idx;
@@ -82,6 +86,16 @@ content::WebContents* AddWebContents(
// Can't create a new contents for the current tab - invalid case.
DCHECK(disposition != WindowOpenDisposition::CURRENT_TAB);
+#if BUILDFLAG(ENABLE_CEF)
+ if (browser && browser->cef_delegate() && new_contents) {
+ new_contents = browser->cef_delegate()->AddWebContents(
+ std::move(new_contents));
+ if (!new_contents) {
+ return nullptr;
+ }
+ }
+#endif
+
NavigateParams params(browser, std::move(new_contents));
params.source_contents = source_contents;
params.url = target_url;