2020-09-25 03:40:47 +02:00
|
|
|
diff --git chrome/browser/browser_about_handler.cc chrome/browser/browser_about_handler.cc
|
2020-12-02 23:31:49 +01:00
|
|
|
index ba0c5c3fc044..b4df9af95ecd 100644
|
2020-09-25 03:40:47 +02:00
|
|
|
--- chrome/browser/browser_about_handler.cc
|
|
|
|
+++ chrome/browser/browser_about_handler.cc
|
2020-12-02 23:31:49 +01:00
|
|
|
@@ -70,6 +70,9 @@ bool HandleNonNavigationAboutURL(const GURL& url) {
|
2020-09-25 03:40:47 +02:00
|
|
|
FROM_HERE, base::BindOnce(&chrome::AttemptExit));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
+ if (base::LowerCaseEqualsASCII(spec, "chrome://ignore/")) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2020-09-18 00:24:08 +02:00
|
|
|
diff --git chrome/browser/ui/browser.cc chrome/browser/ui/browser.cc
|
2021-04-02 22:53:17 +02:00
|
|
|
index f225525e74eb..2f3d13b087b0 100644
|
2020-09-18 00:24:08 +02:00
|
|
|
--- chrome/browser/ui/browser.cc
|
|
|
|
+++ chrome/browser/ui/browser.cc
|
2021-03-04 23:36:57 +01:00
|
|
|
@@ -256,6 +256,20 @@
|
2020-09-18 00:24:08 +02:00
|
|
|
#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__); \
|
|
|
|
+ }
|
|
|
|
+#else // !BUILDFLAG(ENABLE_CEF)
|
|
|
|
+#define CALL_CEF_DELEGATE(name, ...)
|
|
|
|
+#define CALL_CEF_DELEGATE_RETURN(name, ...)
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
|
|
|
#include "chrome/browser/extensions/extension_browser_window_helper.h"
|
|
|
|
#endif
|
2021-01-28 00:13:12 +01:00
|
|
|
@@ -480,6 +494,13 @@ Browser::Browser(const CreateParams& params)
|
|
|
|
|
2020-12-02 23:31:49 +01:00
|
|
|
tab_strip_model_->AddObserver(this);
|
2020-09-18 00:24:08 +02:00
|
|
|
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ if (cef::IsChromeRuntimeEnabled()) {
|
|
|
|
+ cef_browser_delegate_ =
|
|
|
|
+ cef::BrowserDelegate::Create(this, params.cef_params);
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
location_bar_model_ = std::make_unique<LocationBarModelImpl>(
|
2020-12-02 23:31:49 +01:00
|
|
|
location_bar_model_delegate_.get(), content::kMaxURLDisplayChars);
|
|
|
|
|
2021-03-04 23:36:57 +01:00
|
|
|
@@ -1310,6 +1331,14 @@ content::KeyboardEventProcessingResult Browser::PreHandleKeyboardEvent(
|
2020-09-25 03:40:47 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2021-03-04 23:36:57 +01:00
|
|
|
@@ -1317,8 +1346,18 @@ bool Browser::HandleKeyboardEvent(content::WebContents* source,
|
2020-09-25 03:40:47 +02:00
|
|
|
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() {
|
2021-03-04 23:36:57 +01:00
|
|
|
@@ -1538,6 +1577,14 @@ WebContents* Browser::OpenURLFromTab(WebContents* source,
|
2020-09-25 03:40:47 +02:00
|
|
|
return window->OpenURLFromTab(source, params);
|
|
|
|
}
|
|
|
|
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ if (cef_browser_delegate_) {
|
|
|
|
+ auto web_contents = cef_browser_delegate_->OpenURLFromTab(source, params);
|
|
|
|
+ if (!web_contents)
|
|
|
|
+ return nullptr;
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
NavigateParams nav_params(this, params.url, params.transition);
|
|
|
|
nav_params.FillNavigateParamsFromOpenURLParams(params);
|
|
|
|
nav_params.source_contents = source;
|
2021-04-02 22:53:17 +02:00
|
|
|
@@ -1633,6 +1680,15 @@ void Browser::AddNewContents(WebContents* source,
|
|
|
|
source, disposition);
|
|
|
|
}
|
|
|
|
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ if (cef_browser_delegate_) {
|
|
|
|
+ cef_browser_delegate_->AddNewContents(
|
|
|
|
+ source, std::move(new_contents), target_url, disposition, initial_rect,
|
|
|
|
+ user_gesture, was_blocked);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
chrome::AddWebContents(this, source, std::move(new_contents), target_url,
|
|
|
|
disposition, initial_rect);
|
|
|
|
}
|
|
|
|
@@ -1651,6 +1707,8 @@ void Browser::LoadingStateChanged(WebContents* source,
|
2020-09-18 00:24:08 +02:00
|
|
|
bool to_different_document) {
|
|
|
|
ScheduleUIUpdate(source, content::INVALIDATE_TYPE_LOAD);
|
|
|
|
UpdateWindowForLoadingStateChanged(source, to_different_document);
|
|
|
|
+
|
|
|
|
+ CALL_CEF_DELEGATE(LoadingStateChanged, source, to_different_document);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Browser::CloseContents(WebContents* source) {
|
2021-04-02 22:53:17 +02:00
|
|
|
@@ -1678,6 +1736,8 @@ void Browser::SetContentsBounds(WebContents* source, const gfx::Rect& bounds) {
|
2020-09-18 00:24:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
|
|
|
|
+ CALL_CEF_DELEGATE(UpdateTargetURL, source, url);
|
|
|
|
+
|
|
|
|
if (!GetStatusBubble())
|
|
|
|
return;
|
|
|
|
|
2021-04-02 22:53:17 +02:00
|
|
|
@@ -1685,6 +1745,17 @@ void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
|
2020-09-18 00:24:08 +02:00
|
|
|
GetStatusBubble()->SetURL(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
+bool Browser::DidAddMessageToConsole(
|
|
|
|
+ content::WebContents* source,
|
|
|
|
+ blink::mojom::ConsoleMessageLevel log_level,
|
|
|
|
+ const base::string16& message,
|
|
|
|
+ int32_t line_no,
|
|
|
|
+ const base::string16& source_id) {
|
|
|
|
+ CALL_CEF_DELEGATE_RETURN(DidAddMessageToConsole, source, log_level, message,
|
|
|
|
+ line_no, source_id);
|
|
|
|
+ return false;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
void Browser::ContentsMouseEvent(WebContents* source,
|
|
|
|
bool motion,
|
|
|
|
bool exited) {
|
2021-04-02 22:53:17 +02:00
|
|
|
@@ -1801,6 +1872,10 @@ void Browser::WebContentsCreated(WebContents* source_contents,
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
// 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::PortalWebContentsCreated(WebContents* portal_web_contents) {
|
2021-04-02 22:53:17 +02:00
|
|
|
@@ -1837,6 +1912,8 @@ void Browser::RendererResponsive(
|
2020-09-18 00:24:08 +02:00
|
|
|
void Browser::DidNavigateMainFramePostCommit(WebContents* web_contents) {
|
|
|
|
if (web_contents == tab_strip_model_->GetActiveWebContents())
|
|
|
|
UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE);
|
|
|
|
+
|
|
|
|
+ CALL_CEF_DELEGATE(DidNavigateMainFramePostCommit, web_contents);
|
|
|
|
}
|
|
|
|
|
|
|
|
content::JavaScriptDialogManager* Browser::GetJavaScriptDialogManager(
|
2021-04-02 22:53:17 +02:00
|
|
|
@@ -1883,11 +1960,15 @@ void Browser::EnterFullscreenModeForTab(
|
2020-09-18 00:24:08 +02:00
|
|
|
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) {
|
2021-04-02 22:53:17 +02:00
|
|
|
@@ -2730,6 +2811,8 @@ void Browser::SetAsDelegate(WebContents* web_contents, bool set_delegate) {
|
2021-01-28 00:13:12 +01:00
|
|
|
content_translate_driver->RemoveTranslationObserver(this);
|
2020-09-18 00:24:08 +02:00
|
|
|
BookmarkTabHelper::FromWebContents(web_contents)->RemoveObserver(this);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ CALL_CEF_DELEGATE(SetAsDelegate, web_contents, set_delegate);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Browser::CloseFrame() {
|
|
|
|
diff --git chrome/browser/ui/browser.h chrome/browser/ui/browser.h
|
2021-03-04 23:36:57 +01:00
|
|
|
index 3a0202c2139b..700de9a44461 100644
|
2020-09-18 00:24:08 +02:00
|
|
|
--- chrome/browser/ui/browser.h
|
|
|
|
+++ chrome/browser/ui/browser.h
|
2021-01-28 00:13:12 +01:00
|
|
|
@@ -22,6 +22,7 @@
|
2020-09-18 00:24:08 +02:00
|
|
|
#include "base/timer/elapsed_timer.h"
|
|
|
|
#include "build/build_config.h"
|
2021-01-28 00:13:12 +01:00
|
|
|
#include "build/chromeos_buildflags.h"
|
2020-09-18 00:24:08 +02:00
|
|
|
+#include "cef/libcef/features/runtime.h"
|
|
|
|
#include "chrome/browser/devtools/devtools_toggle_action.h"
|
2021-01-28 00:13:12 +01:00
|
|
|
#include "chrome/browser/profiles/scoped_profile_keep_alive.h"
|
2020-09-18 00:24:08 +02:00
|
|
|
#include "chrome/browser/ui/bookmarks/bookmark_bar.h"
|
2021-01-28 00:13:12 +01:00
|
|
|
@@ -58,6 +59,10 @@
|
2020-09-18 00:24:08 +02:00
|
|
|
#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 defined(OS_ANDROID)
|
|
|
|
#error This file should only be included on desktop.
|
|
|
|
#endif
|
2021-03-04 23:36:57 +01:00
|
|
|
@@ -281,6 +286,11 @@ class Browser : public TabStripModelObserver,
|
|
|
|
// maximizable.
|
|
|
|
bool can_maximize = true;
|
2020-09-18 00:24:08 +02:00
|
|
|
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ // Opaque CEF-specific configuration. Will be propagated to new Browsers.
|
|
|
|
+ scoped_refptr<cef::BrowserDelegate::CreateParams> cef_params;
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
private:
|
|
|
|
friend class Browser;
|
|
|
|
friend class WindowSizerChromeOSTest;
|
2021-03-04 23:36:57 +01:00
|
|
|
@@ -403,6 +413,12 @@ class Browser : public TabStripModelObserver,
|
|
|
|
|
|
|
|
base::WeakPtr<Browser> AsWeakPtr();
|
2020-09-18 00:24:08 +02:00
|
|
|
|
|
|
|
+#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();
|
2021-03-04 23:36:57 +01:00
|
|
|
@@ -783,6 +799,11 @@ class Browser : public TabStripModelObserver,
|
2020-09-18 00:24:08 +02:00
|
|
|
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 base::string16& message,
|
|
|
|
+ int32_t line_no,
|
|
|
|
+ const base::string16& source_id) override;
|
|
|
|
void ContentsMouseEvent(content::WebContents* source,
|
|
|
|
bool motion,
|
|
|
|
bool exited) override;
|
2021-03-04 23:36:57 +01:00
|
|
|
@@ -1242,6 +1263,10 @@ class Browser : public TabStripModelObserver,
|
2020-09-18 00:24:08 +02:00
|
|
|
extension_browser_window_helper_;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ std::unique_ptr<cef::BrowserDelegate> cef_browser_delegate_;
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
const base::ElapsedTimer creation_timer_;
|
|
|
|
|
2021-03-04 23:36:57 +01:00
|
|
|
// The following factory is used for chrome update coalescing.
|
2020-09-25 03:40:47 +02:00
|
|
|
diff --git chrome/browser/ui/browser_navigator.cc chrome/browser/ui/browser_navigator.cc
|
2021-03-04 23:36:57 +01:00
|
|
|
index 019834353c02..894de692f35d 100644
|
2020-09-25 03:40:47 +02:00
|
|
|
--- chrome/browser/ui/browser_navigator.cc
|
|
|
|
+++ chrome/browser/ui/browser_navigator.cc
|
2021-03-04 23:36:57 +01:00
|
|
|
@@ -454,6 +454,13 @@ std::unique_ptr<content::WebContents> CreateTargetContents(
|
2020-09-25 03:40:47 +02:00
|
|
|
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
|
2021-01-28 00:13:12 +01:00
|
|
|
index 899b0e532c45..2fad68ec3e51 100644
|
2020-09-25 03:40:47 +02:00
|
|
|
--- chrome/browser/ui/browser_tabstrip.cc
|
|
|
|
+++ chrome/browser/ui/browser_tabstrip.cc
|
2020-10-08 21:54:42 +02:00
|
|
|
@@ -30,9 +30,13 @@ void AddTabAt(Browser* browser,
|
2020-09-25 03:40:47 +02:00
|
|
|
// 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;
|