mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Use direct member for CefBrowserHostBase::contents_delegate_
There's no reason to use unique_ptr here as the lifespan of |contents_delegate_| exactly matches CefBrowserHostBase.
This commit is contained in:
@@ -587,7 +587,7 @@ void AlloyBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contents_delegate_->OnSetFocus(source)) {
|
if (contents_delegate_.OnSetFocus(source)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -599,13 +599,13 @@ void AlloyBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
|
|||||||
void AlloyBrowserHostImpl::EnterFullscreenModeForTab(
|
void AlloyBrowserHostImpl::EnterFullscreenModeForTab(
|
||||||
content::RenderFrameHost* requesting_frame,
|
content::RenderFrameHost* requesting_frame,
|
||||||
const blink::mojom::FullscreenOptions& options) {
|
const blink::mojom::FullscreenOptions& options) {
|
||||||
contents_delegate_->EnterFullscreenModeForTab(requesting_frame, options);
|
contents_delegate_.EnterFullscreenModeForTab(requesting_frame, options);
|
||||||
WasResized();
|
WasResized();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::ExitFullscreenModeForTab(
|
void AlloyBrowserHostImpl::ExitFullscreenModeForTab(
|
||||||
content::WebContents* web_contents) {
|
content::WebContents* web_contents) {
|
||||||
contents_delegate_->ExitFullscreenModeForTab(web_contents);
|
contents_delegate_.ExitFullscreenModeForTab(web_contents);
|
||||||
WasResized();
|
WasResized();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -877,7 +877,7 @@ content::WebContents* AlloyBrowserHostImpl::OpenURLFromTab(
|
|||||||
const content::OpenURLParams& params,
|
const content::OpenURLParams& params,
|
||||||
base::OnceCallback<void(content::NavigationHandle&)>
|
base::OnceCallback<void(content::NavigationHandle&)>
|
||||||
navigation_handle_callback) {
|
navigation_handle_callback) {
|
||||||
auto target_contents = contents_delegate_->OpenURLFromTabEx(
|
auto target_contents = contents_delegate_.OpenURLFromTabEx(
|
||||||
source, params, navigation_handle_callback);
|
source, params, navigation_handle_callback);
|
||||||
if (target_contents) {
|
if (target_contents) {
|
||||||
// Start a navigation in the current browser that will result in the
|
// Start a navigation in the current browser that will result in the
|
||||||
@@ -905,7 +905,7 @@ void AlloyBrowserHostImpl::AddNewContents(
|
|||||||
|
|
||||||
void AlloyBrowserHostImpl::LoadingStateChanged(content::WebContents* source,
|
void AlloyBrowserHostImpl::LoadingStateChanged(content::WebContents* source,
|
||||||
bool should_show_loading_ui) {
|
bool should_show_loading_ui) {
|
||||||
contents_delegate_->LoadingStateChanged(source, should_show_loading_ui);
|
contents_delegate_.LoadingStateChanged(source, should_show_loading_ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::CloseContents(content::WebContents* source) {
|
void AlloyBrowserHostImpl::CloseContents(content::WebContents* source) {
|
||||||
@@ -958,7 +958,7 @@ void AlloyBrowserHostImpl::CloseContents(content::WebContents* source) {
|
|||||||
|
|
||||||
void AlloyBrowserHostImpl::UpdateTargetURL(content::WebContents* source,
|
void AlloyBrowserHostImpl::UpdateTargetURL(content::WebContents* source,
|
||||||
const GURL& url) {
|
const GURL& url) {
|
||||||
contents_delegate_->UpdateTargetURL(source, url);
|
contents_delegate_.UpdateTargetURL(source, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AlloyBrowserHostImpl::DidAddMessageToConsole(
|
bool AlloyBrowserHostImpl::DidAddMessageToConsole(
|
||||||
@@ -967,8 +967,8 @@ bool AlloyBrowserHostImpl::DidAddMessageToConsole(
|
|||||||
const std::u16string& message,
|
const std::u16string& message,
|
||||||
int32_t line_no,
|
int32_t line_no,
|
||||||
const std::u16string& source_id) {
|
const std::u16string& source_id) {
|
||||||
return contents_delegate_->DidAddMessageToConsole(source, level, message,
|
return contents_delegate_.DidAddMessageToConsole(source, level, message,
|
||||||
line_no, source_id);
|
line_no, source_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::ContentsZoomChange(bool zoom_in) {
|
void AlloyBrowserHostImpl::ContentsZoomChange(bool zoom_in) {
|
||||||
@@ -1003,13 +1003,13 @@ void AlloyBrowserHostImpl::CanDownload(
|
|||||||
const GURL& url,
|
const GURL& url,
|
||||||
const std::string& request_method,
|
const std::string& request_method,
|
||||||
base::OnceCallback<void(bool)> callback) {
|
base::OnceCallback<void(bool)> callback) {
|
||||||
contents_delegate_->CanDownload(url, request_method, std::move(callback));
|
contents_delegate_.CanDownload(url, request_method, std::move(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyboardEventProcessingResult AlloyBrowserHostImpl::PreHandleKeyboardEvent(
|
KeyboardEventProcessingResult AlloyBrowserHostImpl::PreHandleKeyboardEvent(
|
||||||
content::WebContents* source,
|
content::WebContents* source,
|
||||||
const input::NativeWebKeyboardEvent& event) {
|
const input::NativeWebKeyboardEvent& event) {
|
||||||
return contents_delegate_->PreHandleKeyboardEvent(source, event);
|
return contents_delegate_.PreHandleKeyboardEvent(source, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AlloyBrowserHostImpl::HandleKeyboardEvent(
|
bool AlloyBrowserHostImpl::HandleKeyboardEvent(
|
||||||
@@ -1020,7 +1020,7 @@ bool AlloyBrowserHostImpl::HandleKeyboardEvent(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contents_delegate_->HandleKeyboardEvent(source, event)) {
|
if (contents_delegate_.HandleKeyboardEvent(source, event)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1215,7 +1215,7 @@ content::PreloadingEligibility AlloyBrowserHostImpl::IsPrerender2Supported(
|
|||||||
void AlloyBrowserHostImpl::DraggableRegionsChanged(
|
void AlloyBrowserHostImpl::DraggableRegionsChanged(
|
||||||
const std::vector<blink::mojom::DraggableRegionPtr>& regions,
|
const std::vector<blink::mojom::DraggableRegionPtr>& regions,
|
||||||
content::WebContents* contents) {
|
content::WebContents* contents) {
|
||||||
contents_delegate_->DraggableRegionsChanged(regions, contents);
|
contents_delegate_.DraggableRegionsChanged(regions, contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
// content::WebContentsObserver methods.
|
// content::WebContentsObserver methods.
|
||||||
@@ -1289,7 +1289,7 @@ void AlloyBrowserHostImpl::WebContentsDestroyed() {
|
|||||||
// In case we're notified before the CefBrowserContentsDelegate,
|
// In case we're notified before the CefBrowserContentsDelegate,
|
||||||
// reset it first for consistent state in DestroyWebContents.
|
// reset it first for consistent state in DestroyWebContents.
|
||||||
if (GetWebContents()) {
|
if (GetWebContents()) {
|
||||||
contents_delegate_->WebContentsDestroyed();
|
contents_delegate_.WebContentsDestroyed();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto wc = web_contents();
|
auto wc = web_contents();
|
||||||
@@ -1347,7 +1347,7 @@ AlloyBrowserHostImpl::AlloyBrowserHostImpl(
|
|||||||
content::WebContentsObserver(web_contents),
|
content::WebContentsObserver(web_contents),
|
||||||
opener_(kNullWindowHandle),
|
opener_(kNullWindowHandle),
|
||||||
is_windowless_(platform_delegate_->IsWindowless()) {
|
is_windowless_(platform_delegate_->IsWindowless()) {
|
||||||
contents_delegate_->ObserveWebContents(web_contents);
|
contents_delegate_.ObserveWebContents(web_contents);
|
||||||
|
|
||||||
if (opener.get() && !is_views_hosted_) {
|
if (opener.get() && !is_views_hosted_) {
|
||||||
// GetOpenerWindowHandle() only returns a value for non-views-hosted
|
// GetOpenerWindowHandle() only returns a value for non-views-hosted
|
||||||
|
@@ -82,9 +82,7 @@ class CefWidgetHostInterceptor
|
|||||||
|
|
||||||
CefBrowserContentsDelegate::CefBrowserContentsDelegate(
|
CefBrowserContentsDelegate::CefBrowserContentsDelegate(
|
||||||
scoped_refptr<CefBrowserInfo> browser_info)
|
scoped_refptr<CefBrowserInfo> browser_info)
|
||||||
: browser_info_(browser_info) {
|
: browser_info_(browser_info) {}
|
||||||
DCHECK(browser_info_->browser());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefBrowserContentsDelegate::ObserveWebContents(
|
void CefBrowserContentsDelegate::ObserveWebContents(
|
||||||
content::WebContents* new_contents) {
|
content::WebContents* new_contents) {
|
||||||
|
@@ -244,14 +244,13 @@ CefBrowserHostBase::CefBrowserHostBase(
|
|||||||
platform_delegate_(std::move(platform_delegate)),
|
platform_delegate_(std::move(platform_delegate)),
|
||||||
browser_info_(browser_info),
|
browser_info_(browser_info),
|
||||||
request_context_(request_context),
|
request_context_(request_context),
|
||||||
is_views_hosted_(platform_delegate_->IsViewsHosted()) {
|
is_views_hosted_(platform_delegate_->IsViewsHosted()),
|
||||||
|
contents_delegate_(browser_info_) {
|
||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
DCHECK(!browser_info_->browser().get());
|
DCHECK(!browser_info_->browser().get());
|
||||||
browser_info_->SetBrowser(this);
|
browser_info_->SetBrowser(this);
|
||||||
|
|
||||||
contents_delegate_ =
|
contents_delegate_.AddObserver(this);
|
||||||
std::make_unique<CefBrowserContentsDelegate>(browser_info_);
|
|
||||||
contents_delegate_->AddObserver(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserHostBase::InitializeBrowser() {
|
void CefBrowserHostBase::InitializeBrowser() {
|
||||||
@@ -300,13 +299,13 @@ void CefBrowserHostBase::DestroyBrowser() {
|
|||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
|
|
||||||
// The WebContents should no longer be observed.
|
// The WebContents should no longer be observed.
|
||||||
DCHECK(!contents_delegate_->web_contents());
|
DCHECK(!contents_delegate_.web_contents());
|
||||||
|
|
||||||
media_stream_registrar_.reset();
|
media_stream_registrar_.reset();
|
||||||
|
|
||||||
platform_delegate_.reset();
|
platform_delegate_.reset();
|
||||||
|
|
||||||
contents_delegate_->RemoveObserver(this);
|
contents_delegate_.RemoveObserver(this);
|
||||||
|
|
||||||
if (unresponsive_process_callback_) {
|
if (unresponsive_process_callback_) {
|
||||||
hang_monitor::Detach(unresponsive_process_callback_);
|
hang_monitor::Detach(unresponsive_process_callback_);
|
||||||
@@ -1131,21 +1130,21 @@ void CefBrowserHostBase::OnStateChanged(CefBrowserContentsState state_changed) {
|
|||||||
base::AutoLock lock_scope(state_lock_);
|
base::AutoLock lock_scope(state_lock_);
|
||||||
if ((state_changed & CefBrowserContentsState::kNavigation) ==
|
if ((state_changed & CefBrowserContentsState::kNavigation) ==
|
||||||
CefBrowserContentsState::kNavigation) {
|
CefBrowserContentsState::kNavigation) {
|
||||||
is_loading_ = contents_delegate_->is_loading();
|
is_loading_ = contents_delegate_.is_loading();
|
||||||
can_go_back_ = contents_delegate_->can_go_back();
|
can_go_back_ = contents_delegate_.can_go_back();
|
||||||
can_go_forward_ = contents_delegate_->can_go_forward();
|
can_go_forward_ = contents_delegate_.can_go_forward();
|
||||||
}
|
}
|
||||||
if ((state_changed & CefBrowserContentsState::kDocument) ==
|
if ((state_changed & CefBrowserContentsState::kDocument) ==
|
||||||
CefBrowserContentsState::kDocument) {
|
CefBrowserContentsState::kDocument) {
|
||||||
has_document_ = contents_delegate_->has_document();
|
has_document_ = contents_delegate_.has_document();
|
||||||
}
|
}
|
||||||
if ((state_changed & CefBrowserContentsState::kFullscreen) ==
|
if ((state_changed & CefBrowserContentsState::kFullscreen) ==
|
||||||
CefBrowserContentsState::kFullscreen) {
|
CefBrowserContentsState::kFullscreen) {
|
||||||
is_fullscreen_ = contents_delegate_->is_fullscreen();
|
is_fullscreen_ = contents_delegate_.is_fullscreen();
|
||||||
}
|
}
|
||||||
if ((state_changed & CefBrowserContentsState::kFocusedFrame) ==
|
if ((state_changed & CefBrowserContentsState::kFocusedFrame) ==
|
||||||
CefBrowserContentsState::kFocusedFrame) {
|
CefBrowserContentsState::kFocusedFrame) {
|
||||||
focused_frame_ = contents_delegate_->focused_frame();
|
focused_frame_ = contents_delegate_.focused_frame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1338,7 +1337,7 @@ SkColor CefBrowserHostBase::GetBackgroundColor() const {
|
|||||||
|
|
||||||
content::WebContents* CefBrowserHostBase::GetWebContents() const {
|
content::WebContents* CefBrowserHostBase::GetWebContents() const {
|
||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
return contents_delegate_->web_contents();
|
return contents_delegate_.web_contents();
|
||||||
}
|
}
|
||||||
|
|
||||||
content::BrowserContext* CefBrowserHostBase::GetBrowserContext() const {
|
content::BrowserContext* CefBrowserHostBase::GetBrowserContext() const {
|
||||||
@@ -1418,7 +1417,7 @@ bool CefBrowserHostBase::IsVisible() const {
|
|||||||
|
|
||||||
bool CefBrowserHostBase::EnsureDevToolsProtocolManager() {
|
bool CefBrowserHostBase::EnsureDevToolsProtocolManager() {
|
||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
if (!contents_delegate_->web_contents()) {
|
if (!contents_delegate_.web_contents()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1448,7 +1447,7 @@ void CefBrowserHostBase::InitializeDevToolsRegistrationOnUIThread(
|
|||||||
|
|
||||||
bool CefBrowserHostBase::EnsureFileDialogManager() {
|
bool CefBrowserHostBase::EnsureFileDialogManager() {
|
||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
if (!contents_delegate_->web_contents()) {
|
if (!contents_delegate_.web_contents()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -369,8 +369,8 @@ class CefBrowserHostBase : public CefBrowserHost,
|
|||||||
CefBrowserPlatformDelegate* platform_delegate() const {
|
CefBrowserPlatformDelegate* platform_delegate() const {
|
||||||
return platform_delegate_.get();
|
return platform_delegate_.get();
|
||||||
}
|
}
|
||||||
CefBrowserContentsDelegate* contents_delegate() const {
|
CefBrowserContentsDelegate* contents_delegate() {
|
||||||
return contents_delegate_.get();
|
return &contents_delegate_;
|
||||||
}
|
}
|
||||||
CefMediaStreamRegistrar* GetMediaStreamRegistrar();
|
CefMediaStreamRegistrar* GetMediaStreamRegistrar();
|
||||||
CefDevToolsWindowRunner* GetDevToolsWindowRunner();
|
CefDevToolsWindowRunner* GetDevToolsWindowRunner();
|
||||||
@@ -439,7 +439,7 @@ class CefBrowserHostBase : public CefBrowserHost,
|
|||||||
const bool is_views_hosted_;
|
const bool is_views_hosted_;
|
||||||
|
|
||||||
// Only accessed on the UI thread.
|
// Only accessed on the UI thread.
|
||||||
std::unique_ptr<CefBrowserContentsDelegate> contents_delegate_;
|
CefBrowserContentsDelegate contents_delegate_;
|
||||||
CefRefPtr<CefUnresponsiveProcessCallback> unresponsive_process_callback_;
|
CefRefPtr<CefUnresponsiveProcessCallback> unresponsive_process_callback_;
|
||||||
raw_ptr<RenderViewContextMenuObserver> context_menu_observer_ = nullptr;
|
raw_ptr<RenderViewContextMenuObserver> context_menu_observer_ = nullptr;
|
||||||
|
|
||||||
|
@@ -148,7 +148,7 @@ void ChromeBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contents_delegate_->OnSetFocus(source)) {
|
if (contents_delegate_.OnSetFocus(source)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,7 +470,7 @@ void ChromeBrowserHostImpl::Attach(content::WebContents* web_contents,
|
|||||||
|
|
||||||
platform_delegate_->WebContentsCreated(web_contents,
|
platform_delegate_->WebContentsCreated(web_contents,
|
||||||
/*own_web_contents=*/false);
|
/*own_web_contents=*/false);
|
||||||
contents_delegate_->ObserveWebContents(web_contents);
|
contents_delegate_.ObserveWebContents(web_contents);
|
||||||
|
|
||||||
// Associate the platform delegate with this browser.
|
// Associate the platform delegate with this browser.
|
||||||
platform_delegate_->BrowserCreated(this);
|
platform_delegate_->BrowserCreated(this);
|
||||||
|
Reference in New Issue
Block a user