Compare commits

..

No commits in common. "e23264eedc546243b910dbecca0c3bb935284133" and "f8ad36e72c4fc0ed19097ecf42f028c961fea884" have entirely different histories.

9 changed files with 9 additions and 76 deletions

View File

@ -551,10 +551,6 @@ void AlloyBrowserHostImpl::WindowDestroyed() {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
DCHECK(!window_destroyed_); DCHECK(!window_destroyed_);
window_destroyed_ = true; window_destroyed_ = true;
// Destroy objects that may reference the window.
menu_manager_.reset(nullptr);
CloseBrowser(true); CloseBrowser(true);
} }
@ -933,10 +929,9 @@ void AlloyBrowserHostImpl::PrintCrossProcessSubframe(
int document_cookie, int document_cookie,
content::RenderFrameHost* subframe_host) const { content::RenderFrameHost* subframe_host) const {
auto* client = printing::PrintCompositeClient::FromWebContents(web_contents); auto* client = printing::PrintCompositeClient::FromWebContents(web_contents);
if (client) { if (client)
client->PrintCrossProcessSubframe(rect, document_cookie, subframe_host); client->PrintCrossProcessSubframe(rect, document_cookie, subframe_host);
} }
}
content::WebContents* AlloyBrowserHostImpl::OpenURLFromTab( content::WebContents* AlloyBrowserHostImpl::OpenURLFromTab(
content::WebContents* source, content::WebContents* source,

View File

@ -140,8 +140,6 @@ void HandleExternalProtocolHelper(
const std::optional<url::Origin>& initiating_origin, const std::optional<url::Origin>& initiating_origin,
content::WeakDocumentPtr initiator_document, content::WeakDocumentPtr initiator_document,
const net::IsolationInfo& isolation_info) { const net::IsolationInfo& isolation_info) {
CEF_REQUIRE_UIT();
// May return nullptr if frame has been deleted or a cross-document navigation // May return nullptr if frame has been deleted or a cross-document navigation
// has committed in the same RenderFrameHost. // has committed in the same RenderFrameHost.
auto initiator_rfh = initiator_document.AsRenderFrameHostIfValid(); auto initiator_rfh = initiator_document.AsRenderFrameHostIfValid();

View File

@ -1116,7 +1116,7 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
init_state_->browser_, init_state_->frame_, init_state_->browser_, init_state_->frame_,
state->pending_request_.get(), allow_os_execution); state->pending_request_.get(), allow_os_execution);
if (allow_os_execution && init_state_->unhandled_request_callback_) { if (allow_os_execution && init_state_->unhandled_request_callback_) {
CEF_POST_TASK(TID_UI, init_state_->unhandled_request_callback_); init_state_->unhandled_request_callback_.Run();
} }
} }
} }

View File

@ -500,8 +500,8 @@ bool CefWindowImpl::AcceleratorPressed(const ui::Accelerator& accelerator) {
} }
bool CefWindowImpl::CanHandleAccelerators() const { bool CefWindowImpl::CanHandleAccelerators() const {
if (delegate() && widget_ && root_view()) { if (delegate() && widget_) {
return root_view()->CanHandleAccelerators(); return widget_->IsActive();
} }
return false; return false;
} }

View File

@ -4,9 +4,6 @@
#include "tests/cefclient/browser/base_client_handler.h" #include "tests/cefclient/browser/base_client_handler.h"
#include "tests/cefclient/browser/main_context.h"
#include "tests/cefclient/browser/root_window_manager.h"
namespace client { namespace client {
BaseClientHandler::BaseClientHandler() { BaseClientHandler::BaseClientHandler() {
@ -52,10 +49,6 @@ void BaseClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
message_router_->AddHandler(message_handler, false); message_router_->AddHandler(message_handler, false);
} }
} }
if (track_as_other_browser_) {
MainContext::Get()->GetRootWindowManager()->OtherBrowserCreated();
}
} }
void BaseClientHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) { void BaseClientHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
@ -70,10 +63,6 @@ void BaseClientHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
message_handler_set_.clear(); message_handler_set_.clear();
message_router_ = nullptr; message_router_ = nullptr;
} }
if (track_as_other_browser_) {
MainContext::Get()->GetRootWindowManager()->OtherBrowserClosed();
}
} }
bool BaseClientHandler::OnBeforeBrowse(CefRefPtr<CefBrowser> browser, bool BaseClientHandler::OnBeforeBrowse(CefRefPtr<CefBrowser> browser,

View File

@ -103,13 +103,7 @@ class BaseClientHandler : public CefClient,
return resource_manager_; return resource_manager_;
} }
void set_track_as_other_browser(bool val) { track_as_other_browser_ = val; }
private: private:
// True if this handler should call
// RootWindowManager::OtherBrowser[Created|Closed].
bool track_as_other_browser_ = true;
// The current number of browsers using this handler. // The current number of browsers using this handler.
int browser_count_ = 0; int browser_count_ = 0;

View File

@ -464,10 +464,6 @@ ClientHandler::ClientHandler(Delegate* delegate,
startup_url_(startup_url), startup_url_(startup_url),
delegate_(delegate), delegate_(delegate),
console_log_file_(MainContext::Get()->GetConsoleLogPath()) { console_log_file_(MainContext::Get()->GetConsoleLogPath()) {
// This handler is used with RootWindows that are explicitly tracked by
// RootWindowManager.
set_track_as_other_browser(false);
DCHECK(!console_log_file_.empty()); DCHECK(!console_log_file_.empty());
// Read command line settings. // Read command line settings.

View File

@ -202,31 +202,6 @@ void RootWindowManager::CloseAllWindows(bool force) {
} }
} }
void RootWindowManager::OtherBrowserCreated() {
if (!CURRENTLY_ON_MAIN_THREAD()) {
// Execute this method on the main thread.
MAIN_POST_CLOSURE(base::BindOnce(&RootWindowManager::OtherBrowserCreated,
base::Unretained(this)));
return;
}
other_browser_ct_++;
}
void RootWindowManager::OtherBrowserClosed() {
if (!CURRENTLY_ON_MAIN_THREAD()) {
// Execute this method on the main thread.
MAIN_POST_CLOSURE(base::BindOnce(&RootWindowManager::OtherBrowserClosed,
base::Unretained(this)));
return;
}
DCHECK_GT(other_browser_ct_, 0);
other_browser_ct_--;
MaybeCleanup();
}
void RootWindowManager::OnRootWindowCreated( void RootWindowManager::OnRootWindowCreated(
scoped_refptr<RootWindow> root_window) { scoped_refptr<RootWindow> root_window) {
if (!CURRENTLY_ON_MAIN_THREAD()) { if (!CURRENTLY_ON_MAIN_THREAD()) {
@ -343,7 +318,11 @@ void RootWindowManager::OnRootWindowDestroyed(RootWindow* root_window) {
active_root_window_ = nullptr; active_root_window_ = nullptr;
} }
MaybeCleanup(); if (terminate_when_all_windows_closed_ && root_windows_.empty()) {
// All windows have closed. Clean up on the UI thread.
CefPostTask(TID_UI, base::BindOnce(&RootWindowManager::CleanupOnUIThread,
base::Unretained(this)));
}
} }
void RootWindowManager::OnRootWindowActivated(RootWindow* root_window) { void RootWindowManager::OnRootWindowActivated(RootWindow* root_window) {
@ -356,16 +335,6 @@ void RootWindowManager::OnRootWindowActivated(RootWindow* root_window) {
active_root_window_ = root_window; active_root_window_ = root_window;
} }
void RootWindowManager::MaybeCleanup() {
REQUIRE_MAIN_THREAD();
if (terminate_when_all_windows_closed_ && root_windows_.empty() &&
other_browser_ct_ == 0) {
// All windows and browsers have closed. Clean up on the UI thread.
CefPostTask(TID_UI, base::BindOnce(&RootWindowManager::CleanupOnUIThread,
base::Unretained(this)));
}
}
void RootWindowManager::CleanupOnUIThread() { void RootWindowManager::CleanupOnUIThread() {
CEF_REQUIRE_UI_THREAD(); CEF_REQUIRE_UI_THREAD();

View File

@ -62,10 +62,6 @@ class RootWindowManager : public RootWindow::Delegate {
return request_context_per_browser_; return request_context_per_browser_;
} }
// Track other browsers that are not directly associated with a RootWindow.
void OtherBrowserCreated();
void OtherBrowserClosed();
private: private:
// Allow deletion via std::unique_ptr only. // Allow deletion via std::unique_ptr only.
friend std::default_delete<RootWindowManager>; friend std::default_delete<RootWindowManager>;
@ -87,7 +83,6 @@ class RootWindowManager : public RootWindow::Delegate {
CefRefPtr<CefRequestContext> CreateRequestContext( CefRefPtr<CefRequestContext> CreateRequestContext(
RequestContextCallback callback); RequestContextCallback callback);
void MaybeCleanup();
void CleanupOnUIThread(); void CleanupOnUIThread();
const bool terminate_when_all_windows_closed_; const bool terminate_when_all_windows_closed_;
@ -98,9 +93,6 @@ class RootWindowManager : public RootWindow::Delegate {
typedef std::set<scoped_refptr<RootWindow>> RootWindowSet; typedef std::set<scoped_refptr<RootWindow>> RootWindowSet;
RootWindowSet root_windows_; RootWindowSet root_windows_;
// Count of other browsers. Only accessed on the main thread.
int other_browser_ct_ = 0;
// The currently active/foreground RootWindow. Only accessed on the main // The currently active/foreground RootWindow. Only accessed on the main
// thread. // thread.
scoped_refptr<RootWindow> active_root_window_; scoped_refptr<RootWindow> active_root_window_;