diff --git a/libcef/browser/browser_host_base.h b/libcef/browser/browser_host_base.h index 0b9e45f3b..9ddc18aed 100644 --- a/libcef/browser/browser_host_base.h +++ b/libcef/browser/browser_host_base.h @@ -51,8 +51,13 @@ struct CefBrowserCreateParams { #if defined(TOOLKIT_VIEWS) // The BrowserView that will own a Views-hosted browser. Will be nullptr for - // popup browsers (the BrowserView will be created later in that case). + // popup browsers. CefRefPtr browser_view; + + // True if this browser is a popup and has a Views-hosted opener, in which + // case the BrowserView for this browser will be created later (from + // PopupWebContentsCreated). + bool popup_with_views_hosted_opener = false; #endif // Client implementation. May be nullptr. diff --git a/libcef/browser/browser_info_manager.cc b/libcef/browser/browser_info_manager.cc index edd421e1c..4193972c9 100644 --- a/libcef/browser/browser_info_manager.cc +++ b/libcef/browser/browser_info_manager.cc @@ -181,8 +181,11 @@ bool CefBrowserInfoManager::CanCreateWindow( if (allow) { CefBrowserCreateParams create_params; - if (!browser->HasView()) + if (browser->HasView()) { + create_params.popup_with_views_hosted_opener = true; + } else { create_params.window_info = std::move(window_info); + } create_params.settings = pending_popup->settings; create_params.client = pending_popup->client; diff --git a/libcef/browser/browser_platform_delegate_create.cc b/libcef/browser/browser_platform_delegate_create.cc index f91943293..f28582495 100644 --- a/libcef/browser/browser_platform_delegate_create.cc +++ b/libcef/browser/browser_platform_delegate_create.cc @@ -84,7 +84,8 @@ std::unique_ptr CefBrowserPlatformDelegate::Create( std::unique_ptr native_delegate = CreateNativeDelegate(CefWindowInfo(), background_color); #if defined(TOOLKIT_VIEWS) - if (create_params.browser_view) { + if (create_params.browser_view || + create_params.popup_with_views_hosted_opener) { return std::make_unique( std::move(native_delegate), static_cast(create_params.browser_view.get())); diff --git a/libcef/browser/chrome/chrome_browser_delegate.cc b/libcef/browser/chrome/chrome_browser_delegate.cc index 25e8a5e9b..ff5d1d2da 100644 --- a/libcef/browser/chrome/chrome_browser_delegate.cc +++ b/libcef/browser/chrome/chrome_browser_delegate.cc @@ -16,6 +16,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_tabstrip.h" #include "content/public/browser/keyboard_event_processing_result.h" #include "content/public/browser/native_web_keyboard_event.h" @@ -65,7 +66,7 @@ void ChromeBrowserDelegate::SetAsDelegate(content::WebContents* web_contents, create_params_.request_context); CreateBrowser(web_contents, create_params_.settings, create_params_.client, - std::move(platform_delegate), browser_info, + std::move(platform_delegate), browser_info, /*opener=*/nullptr, request_context_impl); } @@ -103,7 +104,28 @@ void ChromeBrowserDelegate::WebContentsCreated( // We don't officially own |new_contents| until AddNewContents() is called. // However, we need to install observers/delegates here. CreateBrowser(new_contents, settings, client, std::move(platform_delegate), - browser_info, request_context_impl); + browser_info, opener, request_context_impl); +} + +void ChromeBrowserDelegate::AddNewContents( + content::WebContents* source_contents, + std::unique_ptr new_contents, + const GURL& target_url, + WindowOpenDisposition disposition, + const gfx::Rect& initial_rect, + bool user_gesture, + bool* was_blocked) { + auto new_browser = + ChromeBrowserHostImpl::GetBrowserForContents(new_contents.get()); + if (new_browser) { + // Create a new Browser and give it ownership of the WebContents. + new_browser->AddNewContents(std::move(new_contents)); + return; + } + + // Fall back to default behavior from Browser::AddNewContents. + chrome::AddWebContents(browser_, source_contents, std::move(new_contents), + target_url, disposition, initial_rect); } content::WebContents* ChromeBrowserDelegate::OpenURLFromTab( @@ -195,6 +217,7 @@ void ChromeBrowserDelegate::CreateBrowser( CefRefPtr client, std::unique_ptr platform_delegate, scoped_refptr browser_info, + CefRefPtr opener, CefRefPtr request_context_impl) { CEF_REQUIRE_UIT(); DCHECK(web_contents); @@ -202,6 +225,9 @@ void ChromeBrowserDelegate::CreateBrowser( DCHECK(browser_info); DCHECK(request_context_impl); + // If |opener| is non-nullptr it must be a popup window. + DCHECK(!opener.get() || browser_info->is_popup()); + if (!client) { if (auto app = CefAppManager::Get()->GetApplication()) { if (auto bph = app->GetBrowserProcessHandler()) { @@ -226,7 +252,12 @@ void ChromeBrowserDelegate::CreateBrowser( CefRefPtr browser_host = new ChromeBrowserHostImpl(settings, client, std::move(platform_delegate), browser_info, request_context_impl); - browser_host->Attach(browser_, web_contents); + browser_host->Attach(web_contents, opener); + + // The Chrome browser for a popup won't be created until AddNewContents(). + if (!opener) { + browser_host->SetBrowser(browser_); + } } CefBrowserContentsDelegate* ChromeBrowserDelegate::GetDelegateForWebContents( diff --git a/libcef/browser/chrome/chrome_browser_delegate.h b/libcef/browser/chrome/chrome_browser_delegate.h index 566ca278a..2d6285e3f 100644 --- a/libcef/browser/chrome/chrome_browser_delegate.h +++ b/libcef/browser/chrome/chrome_browser_delegate.h @@ -55,6 +55,13 @@ class ChromeBrowserDelegate : public cef::BrowserDelegate { const std::string& frame_name, const GURL& target_url, content::WebContents* new_contents) override; + void AddNewContents(content::WebContents* source_contents, + std::unique_ptr new_contents, + const GURL& target_url, + WindowOpenDisposition disposition, + const gfx::Rect& initial_rect, + bool user_gesture, + bool* was_blocked) override; content::WebContents* OpenURLFromTab( content::WebContents* source, const content::OpenURLParams& params) override; @@ -88,6 +95,7 @@ class ChromeBrowserDelegate : public cef::BrowserDelegate { CefRefPtr client, std::unique_ptr platform_delegate, scoped_refptr browser_info, + CefRefPtr opener, CefRefPtr request_context_impl); CefBrowserContentsDelegate* GetDelegateForWebContents( diff --git a/libcef/browser/chrome/chrome_browser_host_impl.cc b/libcef/browser/chrome/chrome_browser_host_impl.cc index 4bd7e7879..337dcab4f 100644 --- a/libcef/browser/chrome/chrome_browser_host_impl.cc +++ b/libcef/browser/chrome/chrome_browser_host_impl.cc @@ -32,60 +32,7 @@ // static CefRefPtr ChromeBrowserHostImpl::Create( const CefBrowserCreateParams& params) { - // Get or create the request context and profile. - CefRefPtr request_context_impl = - CefRequestContextImpl::GetOrCreateForRequestContext( - params.request_context); - CHECK(request_context_impl); - auto cef_browser_context = request_context_impl->GetBrowserContext(); - CHECK(cef_browser_context); - auto profile = cef_browser_context->AsProfile(); - - Browser::CreateParams chrome_params = - Browser::CreateParams(profile, /*user_gesture=*/false); - - // Pass |params| to cef::BrowserDelegate::Create from the Browser constructor. - chrome_params.cef_params = base::MakeRefCounted(params); - -#if defined(TOOLKIT_VIEWS) - // Configure Browser creation to use the existing Views-based - // Widget/BrowserFrame (ChromeBrowserFrame) and BrowserView/BrowserWindow - // (ChromeBrowserView). See views/chrome_browser_frame.h for related - // documentation. - ChromeBrowserView* chrome_browser_view = nullptr; - if (params.browser_view) { - // Don't show most controls. - chrome_params.type = Browser::TYPE_POPUP; - // Don't show title bar or address. - chrome_params.trusted_source = true; - - auto view_impl = - static_cast(params.browser_view.get()); - - chrome_browser_view = - static_cast(view_impl->root_view()); - chrome_params.window = chrome_browser_view; - - auto chrome_widget = - static_cast(chrome_browser_view->GetWidget()); - chrome_browser_view->set_frame(chrome_widget); - } -#endif // defined(TOOLKIT_VIEWS) - - // Create the Browser. This will indirectly create the ChomeBrowserDelegate. - // The same params will be used to create a new Browser if the tab is dragged - // out of the existing Browser. The returned Browser is owned by the - // associated BrowserView. - auto browser = Browser::Create(chrome_params); - -#if defined(TOOLKIT_VIEWS) - if (chrome_browser_view) { - // Initialize the BrowserFrame and BrowserView and create the controls that - // require access to the Browser. - chrome_browser_view->InitBrowser(base::WrapUnique(browser), - params.browser_view); - } -#endif + auto browser = CreateBrowser(params); GURL url = params.url; if (url.is_empty()) { @@ -98,7 +45,8 @@ CefRefPtr ChromeBrowserHostImpl::Create( // Add a new tab. This will indirectly create a new tab WebContents and // call ChromeBrowserDelegate::OnWebContentsCreated to create the associated // ChromeBrowserHostImpl. - chrome::AddTabAt(browser, url, /*idx=*/-1, /*foreground=*/true); + chrome::AddTabAt(browser, url, /*index=*/TabStripModel::kNoTab, + /*foreground=*/true); // The new tab WebContents. auto web_contents = browser->tab_strip_model()->GetActiveWebContents(); @@ -159,6 +107,34 @@ CefRefPtr ChromeBrowserHostImpl::GetBrowserForFrameRoute( ChromeBrowserHostImpl::~ChromeBrowserHostImpl() = default; +void ChromeBrowserHostImpl::AddNewContents( + std::unique_ptr contents) { + DCHECK(contents); + DCHECK(!browser_); + + // We should already be associated with the WebContents. + DCHECK_EQ(GetWebContents(), contents.get()); + + CefBrowserCreateParams params; + params.request_context = request_context(); +#if defined(TOOLKIT_VIEWS) + params.browser_view = GetBrowserView(); +#endif + + // Create the new Browser representation. + auto browser = CreateBrowser(params); + + // Add the WebContents to the Browser. + browser->tab_strip_model()->AddWebContents( + std::move(contents), /*index=*/TabStripModel::kNoTab, + ui::PageTransition::PAGE_TRANSITION_AUTO_TOPLEVEL, + TabStripModel::ADD_ACTIVE); + + SetBrowser(browser); + + browser->window()->Show(); +} + void ChromeBrowserHostImpl::OnWebContentsDestroyed( content::WebContents* web_contents) { platform_delegate_->WebContentsDestroyed(web_contents); @@ -461,17 +437,112 @@ ChromeBrowserHostImpl::ChromeBrowserHostImpl( browser_info, request_context) {} -void ChromeBrowserHostImpl::Attach(Browser* browser, - content::WebContents* web_contents) { - DCHECK(browser); +// static +Browser* ChromeBrowserHostImpl::CreateBrowser( + const CefBrowserCreateParams& params) { + // Get or create the request context and profile. + CefRefPtr request_context_impl = + CefRequestContextImpl::GetOrCreateForRequestContext( + params.request_context); + CHECK(request_context_impl); + auto cef_browser_context = request_context_impl->GetBrowserContext(); + CHECK(cef_browser_context); + auto profile = cef_browser_context->AsProfile(); + + Browser::CreateParams chrome_params = + Browser::CreateParams(profile, /*user_gesture=*/false); + + // Pass |params| to cef::BrowserDelegate::Create from the Browser constructor. + chrome_params.cef_params = base::MakeRefCounted(params); + +#if defined(TOOLKIT_VIEWS) + // Configure Browser creation to use the existing Views-based + // Widget/BrowserFrame (ChromeBrowserFrame) and BrowserView/BrowserWindow + // (ChromeBrowserView). See views/chrome_browser_frame.h for related + // documentation. + ChromeBrowserView* chrome_browser_view = nullptr; + if (params.browser_view) { + // Don't show most controls. + chrome_params.type = Browser::TYPE_POPUP; + // Don't show title bar or address. + chrome_params.trusted_source = true; + + auto view_impl = + static_cast(params.browser_view.get()); + + chrome_browser_view = + static_cast(view_impl->root_view()); + chrome_params.window = chrome_browser_view; + + auto chrome_widget = + static_cast(chrome_browser_view->GetWidget()); + chrome_browser_view->set_frame(chrome_widget); + } +#endif // defined(TOOLKIT_VIEWS) + + // Create the Browser. This will indirectly create the ChomeBrowserDelegate. + // The same params will be used to create a new Browser if the tab is dragged + // out of the existing Browser. The returned Browser is owned by the + // associated BrowserView. + auto browser = Browser::Create(chrome_params); + +#if defined(TOOLKIT_VIEWS) + if (chrome_browser_view) { + // Initialize the BrowserFrame and BrowserView and create the controls that + // require access to the Browser. + chrome_browser_view->InitBrowser(base::WrapUnique(browser), + params.browser_view); + } +#endif + + return browser; +} + +void ChromeBrowserHostImpl::Attach(content::WebContents* web_contents, + CefRefPtr opener) { DCHECK(web_contents); - SetBrowser(browser); + if (opener) { + // Give the opener browser's platform delegate an opportunity to modify the + // new browser's platform delegate. + opener->platform_delegate_->PopupWebContentsCreated( + settings_, client_, web_contents, platform_delegate_.get(), + /*is_devtools_popup=*/false); + } platform_delegate_->WebContentsCreated(web_contents, /*own_web_contents=*/false); contents_delegate_->ObserveWebContents(web_contents); + + // Associate the platform delegate with this browser. + platform_delegate_->BrowserCreated(this); + + // Associate the base class with the WebContents. InitializeBrowser(); + + // Notify that the browser has been created. These must be delivered in the + // expected order. + + // 1. Notify the browser's LifeSpanHandler. This must always be the first + // notification for the browser. + { + // The WebContents won't be added to the Browser's TabStripModel until later + // in the current call stack. Block navigation until that time. + auto navigation_lock = browser_info_->CreateNavigationLock(); + OnAfterCreated(); + } + + // 2. Notify the platform delegate. With Views this will result in a call to + // CefBrowserViewDelegate::OnBrowserCreated(). + platform_delegate_->NotifyBrowserCreated(); + + if (opener && opener->platform_delegate_) { + // 3. Notify the opener browser's platform delegate. With Views this will + // result in a call to CefBrowserViewDelegate::OnPopupBrowserViewCreated(). + opener->platform_delegate_->PopupBrowserCreated( + this, + /*is_devtools_popup=*/false); + } } void ChromeBrowserHostImpl::SetBrowser(Browser* browser) { @@ -481,21 +552,6 @@ void ChromeBrowserHostImpl::SetBrowser(Browser* browser) { ->set_chrome_browser(browser); } -void ChromeBrowserHostImpl::InitializeBrowser() { - CEF_REQUIRE_UIT(); - DCHECK(browser_); - - // Associate the platform delegate with this browser. - platform_delegate_->BrowserCreated(this); - - CefBrowserHostBase::InitializeBrowser(); - - // The WebContents won't be added to the Browser's TabStripModel until later - // in the current call stack. Block navigation until that time. - auto navigation_lock = browser_info_->CreateNavigationLock(); - OnAfterCreated(); -} - void ChromeBrowserHostImpl::WindowDestroyed() { CEF_REQUIRE_UIT(); #if defined(TOOLKIT_VIEWS) diff --git a/libcef/browser/chrome/chrome_browser_host_impl.h b/libcef/browser/chrome/chrome_browser_host_impl.h index 4f0e952f2..c15352b30 100644 --- a/libcef/browser/chrome/chrome_browser_host_impl.h +++ b/libcef/browser/chrome/chrome_browser_host_impl.h @@ -142,17 +142,24 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase { scoped_refptr browser_info, CefRefPtr request_context); - // Called from ChromeBrowserDelegate::SetAsDelegate when this object is first - // created. Must be called on the UI thread. - void Attach(Browser* browser, content::WebContents* web_contents); + // Create a new Browser without initializing the WebContents. + static Browser* CreateBrowser(const CefBrowserCreateParams& params); - // Called from ChromeBrowserDelegate::SetAsDelegate when this object changes - // Browser ownership (e.g. dragging between windows). The old Browser will be - // cleared before the new Browser is added. Must be called on the UI thread. + // Called from ChromeBrowserDelegate::CreateBrowser when this object is first + // created. Must be called on the UI thread. + void Attach(content::WebContents* web_contents, + CefRefPtr opener); + + // Called from ChromeBrowserDelegate::AddNewContents to take ownership of a + // popup WebContents. + void AddNewContents(std::unique_ptr contents); + + // Called when this object changes Browser ownership (e.g. initially created, + // dragging between windows, etc). The old Browser, if any, will be cleared + // before the new Browser is added. Must be called on the UI thread. void SetBrowser(Browser* browser); // CefBrowserHostBase methods: - void InitializeBrowser() override; void WindowDestroyed() override; void DestroyBrowser() override; diff --git a/libcef/browser/chrome/views/browser_platform_delegate_chrome_views.cc b/libcef/browser/chrome/views/browser_platform_delegate_chrome_views.cc index f2c01ee17..6bfdef9c3 100644 --- a/libcef/browser/chrome/views/browser_platform_delegate_chrome_views.cc +++ b/libcef/browser/chrome/views/browser_platform_delegate_chrome_views.cc @@ -4,14 +4,59 @@ #include "libcef/browser/chrome/views/browser_platform_delegate_chrome_views.h" +#include "include/views/cef_window.h" + #include "chrome/browser/ui/browser.h" #include "ui/views/widget/widget.h" +namespace { + +// Default popup window delegate implementation. +class PopupWindowDelegate : public CefWindowDelegate { + public: + explicit PopupWindowDelegate(CefRefPtr browser_view) + : browser_view_(browser_view) {} + + void OnWindowCreated(CefRefPtr window) override { + window->AddChildView(browser_view_); + window->Show(); + browser_view_->RequestFocus(); + } + + void OnWindowDestroyed(CefRefPtr window) override { + browser_view_ = nullptr; + } + + bool CanClose(CefRefPtr window) override { + CefRefPtr browser = browser_view_->GetBrowser(); + if (browser) + return browser->GetHost()->TryCloseBrowser(); + return true; + } + + private: + CefRefPtr browser_view_; + + IMPLEMENT_REFCOUNTING(PopupWindowDelegate); + DISALLOW_COPY_AND_ASSIGN(PopupWindowDelegate); +}; + +} // namespace + CefBrowserPlatformDelegateChromeViews::CefBrowserPlatformDelegateChromeViews( std::unique_ptr native_delegate, CefRefPtr browser_view) - : CefBrowserPlatformDelegateChrome(std::move(native_delegate)), - browser_view_(browser_view) {} + : CefBrowserPlatformDelegateChrome(std::move(native_delegate)) { + if (browser_view) + SetBrowserView(browser_view); +} + +void CefBrowserPlatformDelegateChromeViews::SetBrowserView( + CefRefPtr browser_view) { + DCHECK(!browser_view_); + DCHECK(browser_view); + browser_view_ = browser_view; +} void CefBrowserPlatformDelegateChromeViews::WebContentsCreated( content::WebContents* web_contents, @@ -59,6 +104,50 @@ CefBrowserPlatformDelegateChromeViews::GetBrowserView() const { return browser_view_.get(); } +void CefBrowserPlatformDelegateChromeViews::PopupWebContentsCreated( + const CefBrowserSettings& settings, + CefRefPtr client, + content::WebContents* new_web_contents, + CefBrowserPlatformDelegate* new_platform_delegate, + bool is_devtools) { + DCHECK(new_platform_delegate->IsViewsHosted()); + auto* new_platform_delegate_impl = + static_cast( + new_platform_delegate); + + CefRefPtr new_delegate; + if (browser_view_->delegate()) { + new_delegate = browser_view_->delegate()->GetDelegateForPopupBrowserView( + browser_view_.get(), settings, client, is_devtools); + } + + // Create a new BrowserView for the popup. + CefRefPtr new_browser_view = + CefBrowserViewImpl::CreateForPopup(settings, new_delegate); + + // Associate the PlatformDelegate with the new BrowserView. + new_platform_delegate_impl->SetBrowserView(new_browser_view); +} + +void CefBrowserPlatformDelegateChromeViews::PopupBrowserCreated( + CefBrowserHostBase* new_browser, + bool is_devtools) { + CefRefPtr new_browser_view = + CefBrowserView::GetForBrowser(new_browser); + DCHECK(new_browser_view); + + bool popup_handled = false; + if (browser_view_->delegate()) { + popup_handled = browser_view_->delegate()->OnPopupBrowserViewCreated( + browser_view_.get(), new_browser_view.get(), is_devtools); + } + + if (!popup_handled) { + CefWindow::CreateTopLevelWindow( + new PopupWindowDelegate(new_browser_view.get())); + } +} + bool CefBrowserPlatformDelegateChromeViews::IsViewsHosted() const { return true; } diff --git a/libcef/browser/chrome/views/browser_platform_delegate_chrome_views.h b/libcef/browser/chrome/views/browser_platform_delegate_chrome_views.h index 2c66017e0..2b8400aec 100644 --- a/libcef/browser/chrome/views/browser_platform_delegate_chrome_views.h +++ b/libcef/browser/chrome/views/browser_platform_delegate_chrome_views.h @@ -26,9 +26,19 @@ class CefBrowserPlatformDelegateChromeViews void CloseHostWindow() override; views::Widget* GetWindowWidget() const override; CefRefPtr GetBrowserView() const override; + void PopupWebContentsCreated( + const CefBrowserSettings& settings, + CefRefPtr client, + content::WebContents* new_web_contents, + CefBrowserPlatformDelegate* new_platform_delegate, + bool is_devtools) override; + void PopupBrowserCreated(CefBrowserHostBase* new_browser, + bool is_devtools) override; bool IsViewsHosted() const override; private: + void SetBrowserView(CefRefPtr browser_view); + CefRefPtr browser_view_; }; diff --git a/libcef/browser/views/browser_view_impl.cc b/libcef/browser/views/browser_view_impl.cc index cbf5fa560..bc7d23ce1 100644 --- a/libcef/browser/views/browser_view_impl.cc +++ b/libcef/browser/views/browser_view_impl.cc @@ -10,8 +10,6 @@ #include "libcef/browser/context.h" #include "libcef/browser/thread_util.h" #include "libcef/browser/views/window_impl.h" -#include "libcef/features/runtime.h" -#include "libcef/features/runtime_checks.h" #include "content/public/browser/native_web_keyboard_event.h" #include "ui/content_accelerators/accelerator_util.h" @@ -62,7 +60,6 @@ CefRefPtr CefBrowserViewImpl::Create( CefRefPtr CefBrowserViewImpl::CreateForPopup( const CefBrowserSettings& settings, CefRefPtr delegate) { - REQUIRE_ALLOY_RUNTIME(); CEF_REQUIRE_UIT_RETURN(nullptr); CefRefPtr browser_view = new CefBrowserViewImpl(delegate); diff --git a/patch/patches/chrome_browser_browser.patch b/patch/patches/chrome_browser_browser.patch index 9efc2873b..780480f7f 100644 --- a/patch/patches/chrome_browser_browser.patch +++ b/patch/patches/chrome_browser_browser.patch @@ -13,7 +13,7 @@ index ba0c5c3fc044..b4df9af95ecd 100644 return false; } diff --git chrome/browser/ui/browser.cc chrome/browser/ui/browser.cc -index 2f2862c42612..b90c7363412b 100644 +index 2f2862c42612..f11579501774 100644 --- chrome/browser/ui/browser.cc +++ chrome/browser/ui/browser.cc @@ -256,6 +256,20 @@ @@ -102,7 +102,23 @@ index 2f2862c42612..b90c7363412b 100644 NavigateParams nav_params(this, params.url, params.transition); nav_params.FillNavigateParamsFromOpenURLParams(params); nav_params.source_contents = source; -@@ -1652,6 +1699,8 @@ void Browser::LoadingStateChanged(WebContents* source, +@@ -1634,6 +1681,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); + } +@@ -1652,6 +1708,8 @@ void Browser::LoadingStateChanged(WebContents* source, bool to_different_document) { ScheduleUIUpdate(source, content::INVALIDATE_TYPE_LOAD); UpdateWindowForLoadingStateChanged(source, to_different_document); @@ -111,7 +127,7 @@ index 2f2862c42612..b90c7363412b 100644 } void Browser::CloseContents(WebContents* source) { -@@ -1679,6 +1728,8 @@ void Browser::SetContentsBounds(WebContents* source, const gfx::Rect& bounds) { +@@ -1679,6 +1737,8 @@ void Browser::SetContentsBounds(WebContents* source, const gfx::Rect& bounds) { } void Browser::UpdateTargetURL(WebContents* source, const GURL& url) { @@ -120,7 +136,7 @@ index 2f2862c42612..b90c7363412b 100644 if (!GetStatusBubble()) return; -@@ -1686,6 +1737,17 @@ void Browser::UpdateTargetURL(WebContents* source, const GURL& url) { +@@ -1686,6 +1746,17 @@ void Browser::UpdateTargetURL(WebContents* source, const GURL& url) { GetStatusBubble()->SetURL(url); } @@ -138,7 +154,7 @@ index 2f2862c42612..b90c7363412b 100644 void Browser::ContentsMouseEvent(WebContents* source, bool motion, bool exited) { -@@ -1802,6 +1864,10 @@ void Browser::WebContentsCreated(WebContents* source_contents, +@@ -1802,6 +1873,10 @@ void Browser::WebContentsCreated(WebContents* source_contents, // Make the tab show up in the task manager. task_manager::WebContentsTags::CreateForTabContents(new_contents); @@ -149,7 +165,7 @@ index 2f2862c42612..b90c7363412b 100644 } void Browser::PortalWebContentsCreated(WebContents* portal_web_contents) { -@@ -1838,6 +1904,8 @@ void Browser::RendererResponsive( +@@ -1838,6 +1913,8 @@ void Browser::RendererResponsive( void Browser::DidNavigateMainFramePostCommit(WebContents* web_contents) { if (web_contents == tab_strip_model_->GetActiveWebContents()) UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); @@ -158,7 +174,7 @@ index 2f2862c42612..b90c7363412b 100644 } content::JavaScriptDialogManager* Browser::GetJavaScriptDialogManager( -@@ -1884,11 +1952,15 @@ void Browser::EnterFullscreenModeForTab( +@@ -1884,11 +1961,15 @@ void Browser::EnterFullscreenModeForTab( const blink::mojom::FullscreenOptions& options) { exclusive_access_manager_->fullscreen_controller()->EnterFullscreenModeForTab( requesting_frame, options.display_id); @@ -174,7 +190,7 @@ index 2f2862c42612..b90c7363412b 100644 } bool Browser::IsFullscreenForTabOrPending(const WebContents* web_contents) { -@@ -2731,6 +2803,8 @@ void Browser::SetAsDelegate(WebContents* web_contents, bool set_delegate) { +@@ -2731,6 +2812,8 @@ void Browser::SetAsDelegate(WebContents* web_contents, bool set_delegate) { content_translate_driver->RemoveTranslationObserver(this); BookmarkTabHelper::FromWebContents(web_contents)->RemoveObserver(this); } diff --git a/tests/ceftests/client_app_delegates.cc b/tests/ceftests/client_app_delegates.cc index 36a55639d..166944500 100644 --- a/tests/ceftests/client_app_delegates.cc +++ b/tests/ceftests/client_app_delegates.cc @@ -13,11 +13,6 @@ void CreateBrowserDelegates(ClientAppBrowser::DelegateSet& delegates) { extern void CreateAudioOutputTests(ClientAppBrowser::DelegateSet & delegates); CreateAudioOutputTests(delegates); - // Bring in navigation tests. - extern void CreateNavigationBrowserTests(ClientAppBrowser::DelegateSet & - delegates); - CreateNavigationBrowserTests(delegates); - // Bring in the plugin tests. extern void CreatePluginBrowserTests(ClientAppBrowser::DelegateSet & delegates); diff --git a/tests/ceftests/navigation_unittest.cc b/tests/ceftests/navigation_unittest.cc index 0b31b124a..f4b1a368e 100644 --- a/tests/ceftests/navigation_unittest.cc +++ b/tests/ceftests/navigation_unittest.cc @@ -20,22 +20,6 @@ using client::ClientAppRenderer; namespace { -// Browser-side app delegate. -class NavigationBrowserTest : public client::ClientAppBrowser::Delegate { - public: - NavigationBrowserTest() {} - - void OnBeforeCommandLineProcessing( - CefRefPtr app, - CefRefPtr command_line) override { - // Disable popup blocking for the chrome runtime. - command_line->AppendSwitch("disable-popup-blocking"); - } - - private: - IMPLEMENT_REFCOUNTING(NavigationBrowserTest); -}; - const char kHNav1[] = "http://tests-hnav.com/nav1.html"; const char kHNav2[] = "http://tests-hnav.com/nav2.html"; const char kHNav3[] = "http://tests-hnav.com/nav3.html"; @@ -3548,10 +3532,3 @@ void CreateNavigationRendererTests(ClientAppRenderer::DelegateSet& delegates) { delegates.insert(new LoadNavRendererTest); delegates.insert(new ExtraInfoNavRendererTest); } - -// Entry point for creating plugin browser test objects. -// Called from client_app_delegates.cc. -void CreateNavigationBrowserTests( - client::ClientAppBrowser::DelegateSet& delegates) { - delegates.insert(new NavigationBrowserTest); -} diff --git a/tests/shared/browser/client_app_browser.cc b/tests/shared/browser/client_app_browser.cc index 9db60ab21..a69f26cd9 100644 --- a/tests/shared/browser/client_app_browser.cc +++ b/tests/shared/browser/client_app_browser.cc @@ -47,6 +47,9 @@ void ClientAppBrowser::OnBeforeCommandLineProcessing( command_line->AppendSwitch("disable-gpu-shader-disk-cache"); } + // Disable popup blocking for the chrome runtime. + command_line->AppendSwitch("disable-popup-blocking"); + #if defined(OS_MAC) // Disable the toolchain prompt on macOS. command_line->AppendSwitch("use-mock-keychain");