mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-23 23:47:43 +01: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:
parent
d470cf8204
commit
3acdbac061
@ -587,7 +587,7 @@ void AlloyBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (contents_delegate_->OnSetFocus(source)) {
|
||||
if (contents_delegate_.OnSetFocus(source)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -599,13 +599,13 @@ void AlloyBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
|
||||
void AlloyBrowserHostImpl::EnterFullscreenModeForTab(
|
||||
content::RenderFrameHost* requesting_frame,
|
||||
const blink::mojom::FullscreenOptions& options) {
|
||||
contents_delegate_->EnterFullscreenModeForTab(requesting_frame, options);
|
||||
contents_delegate_.EnterFullscreenModeForTab(requesting_frame, options);
|
||||
WasResized();
|
||||
}
|
||||
|
||||
void AlloyBrowserHostImpl::ExitFullscreenModeForTab(
|
||||
content::WebContents* web_contents) {
|
||||
contents_delegate_->ExitFullscreenModeForTab(web_contents);
|
||||
contents_delegate_.ExitFullscreenModeForTab(web_contents);
|
||||
WasResized();
|
||||
}
|
||||
|
||||
@ -877,7 +877,7 @@ content::WebContents* AlloyBrowserHostImpl::OpenURLFromTab(
|
||||
const content::OpenURLParams& params,
|
||||
base::OnceCallback<void(content::NavigationHandle&)>
|
||||
navigation_handle_callback) {
|
||||
auto target_contents = contents_delegate_->OpenURLFromTabEx(
|
||||
auto target_contents = contents_delegate_.OpenURLFromTabEx(
|
||||
source, params, navigation_handle_callback);
|
||||
if (target_contents) {
|
||||
// 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,
|
||||
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) {
|
||||
@ -958,7 +958,7 @@ void AlloyBrowserHostImpl::CloseContents(content::WebContents* source) {
|
||||
|
||||
void AlloyBrowserHostImpl::UpdateTargetURL(content::WebContents* source,
|
||||
const GURL& url) {
|
||||
contents_delegate_->UpdateTargetURL(source, url);
|
||||
contents_delegate_.UpdateTargetURL(source, url);
|
||||
}
|
||||
|
||||
bool AlloyBrowserHostImpl::DidAddMessageToConsole(
|
||||
@ -967,7 +967,7 @@ bool AlloyBrowserHostImpl::DidAddMessageToConsole(
|
||||
const std::u16string& message,
|
||||
int32_t line_no,
|
||||
const std::u16string& source_id) {
|
||||
return contents_delegate_->DidAddMessageToConsole(source, level, message,
|
||||
return contents_delegate_.DidAddMessageToConsole(source, level, message,
|
||||
line_no, source_id);
|
||||
}
|
||||
|
||||
@ -1003,13 +1003,13 @@ void AlloyBrowserHostImpl::CanDownload(
|
||||
const GURL& url,
|
||||
const std::string& request_method,
|
||||
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(
|
||||
content::WebContents* source,
|
||||
const input::NativeWebKeyboardEvent& event) {
|
||||
return contents_delegate_->PreHandleKeyboardEvent(source, event);
|
||||
return contents_delegate_.PreHandleKeyboardEvent(source, event);
|
||||
}
|
||||
|
||||
bool AlloyBrowserHostImpl::HandleKeyboardEvent(
|
||||
@ -1020,7 +1020,7 @@ bool AlloyBrowserHostImpl::HandleKeyboardEvent(
|
||||
return false;
|
||||
}
|
||||
|
||||
if (contents_delegate_->HandleKeyboardEvent(source, event)) {
|
||||
if (contents_delegate_.HandleKeyboardEvent(source, event)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1215,7 +1215,7 @@ content::PreloadingEligibility AlloyBrowserHostImpl::IsPrerender2Supported(
|
||||
void AlloyBrowserHostImpl::DraggableRegionsChanged(
|
||||
const std::vector<blink::mojom::DraggableRegionPtr>& regions,
|
||||
content::WebContents* contents) {
|
||||
contents_delegate_->DraggableRegionsChanged(regions, contents);
|
||||
contents_delegate_.DraggableRegionsChanged(regions, contents);
|
||||
}
|
||||
|
||||
// content::WebContentsObserver methods.
|
||||
@ -1289,7 +1289,7 @@ void AlloyBrowserHostImpl::WebContentsDestroyed() {
|
||||
// In case we're notified before the CefBrowserContentsDelegate,
|
||||
// reset it first for consistent state in DestroyWebContents.
|
||||
if (GetWebContents()) {
|
||||
contents_delegate_->WebContentsDestroyed();
|
||||
contents_delegate_.WebContentsDestroyed();
|
||||
}
|
||||
|
||||
auto wc = web_contents();
|
||||
@ -1347,7 +1347,7 @@ AlloyBrowserHostImpl::AlloyBrowserHostImpl(
|
||||
content::WebContentsObserver(web_contents),
|
||||
opener_(kNullWindowHandle),
|
||||
is_windowless_(platform_delegate_->IsWindowless()) {
|
||||
contents_delegate_->ObserveWebContents(web_contents);
|
||||
contents_delegate_.ObserveWebContents(web_contents);
|
||||
|
||||
if (opener.get() && !is_views_hosted_) {
|
||||
// GetOpenerWindowHandle() only returns a value for non-views-hosted
|
||||
|
@ -82,9 +82,7 @@ class CefWidgetHostInterceptor
|
||||
|
||||
CefBrowserContentsDelegate::CefBrowserContentsDelegate(
|
||||
scoped_refptr<CefBrowserInfo> browser_info)
|
||||
: browser_info_(browser_info) {
|
||||
DCHECK(browser_info_->browser());
|
||||
}
|
||||
: browser_info_(browser_info) {}
|
||||
|
||||
void CefBrowserContentsDelegate::ObserveWebContents(
|
||||
content::WebContents* new_contents) {
|
||||
|
@ -244,14 +244,13 @@ CefBrowserHostBase::CefBrowserHostBase(
|
||||
platform_delegate_(std::move(platform_delegate)),
|
||||
browser_info_(browser_info),
|
||||
request_context_(request_context),
|
||||
is_views_hosted_(platform_delegate_->IsViewsHosted()) {
|
||||
is_views_hosted_(platform_delegate_->IsViewsHosted()),
|
||||
contents_delegate_(browser_info_) {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(!browser_info_->browser().get());
|
||||
browser_info_->SetBrowser(this);
|
||||
|
||||
contents_delegate_ =
|
||||
std::make_unique<CefBrowserContentsDelegate>(browser_info_);
|
||||
contents_delegate_->AddObserver(this);
|
||||
contents_delegate_.AddObserver(this);
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::InitializeBrowser() {
|
||||
@ -300,13 +299,13 @@ void CefBrowserHostBase::DestroyBrowser() {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
// The WebContents should no longer be observed.
|
||||
DCHECK(!contents_delegate_->web_contents());
|
||||
DCHECK(!contents_delegate_.web_contents());
|
||||
|
||||
media_stream_registrar_.reset();
|
||||
|
||||
platform_delegate_.reset();
|
||||
|
||||
contents_delegate_->RemoveObserver(this);
|
||||
contents_delegate_.RemoveObserver(this);
|
||||
|
||||
if (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_);
|
||||
if ((state_changed & CefBrowserContentsState::kNavigation) ==
|
||||
CefBrowserContentsState::kNavigation) {
|
||||
is_loading_ = contents_delegate_->is_loading();
|
||||
can_go_back_ = contents_delegate_->can_go_back();
|
||||
can_go_forward_ = contents_delegate_->can_go_forward();
|
||||
is_loading_ = contents_delegate_.is_loading();
|
||||
can_go_back_ = contents_delegate_.can_go_back();
|
||||
can_go_forward_ = contents_delegate_.can_go_forward();
|
||||
}
|
||||
if ((state_changed & CefBrowserContentsState::kDocument) ==
|
||||
CefBrowserContentsState::kDocument) {
|
||||
has_document_ = contents_delegate_->has_document();
|
||||
has_document_ = contents_delegate_.has_document();
|
||||
}
|
||||
if ((state_changed & CefBrowserContentsState::kFullscreen) ==
|
||||
CefBrowserContentsState::kFullscreen) {
|
||||
is_fullscreen_ = contents_delegate_->is_fullscreen();
|
||||
is_fullscreen_ = contents_delegate_.is_fullscreen();
|
||||
}
|
||||
if ((state_changed & 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 {
|
||||
CEF_REQUIRE_UIT();
|
||||
return contents_delegate_->web_contents();
|
||||
return contents_delegate_.web_contents();
|
||||
}
|
||||
|
||||
content::BrowserContext* CefBrowserHostBase::GetBrowserContext() const {
|
||||
@ -1418,7 +1417,7 @@ bool CefBrowserHostBase::IsVisible() const {
|
||||
|
||||
bool CefBrowserHostBase::EnsureDevToolsProtocolManager() {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (!contents_delegate_->web_contents()) {
|
||||
if (!contents_delegate_.web_contents()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1448,7 +1447,7 @@ void CefBrowserHostBase::InitializeDevToolsRegistrationOnUIThread(
|
||||
|
||||
bool CefBrowserHostBase::EnsureFileDialogManager() {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (!contents_delegate_->web_contents()) {
|
||||
if (!contents_delegate_.web_contents()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -369,8 +369,8 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
CefBrowserPlatformDelegate* platform_delegate() const {
|
||||
return platform_delegate_.get();
|
||||
}
|
||||
CefBrowserContentsDelegate* contents_delegate() const {
|
||||
return contents_delegate_.get();
|
||||
CefBrowserContentsDelegate* contents_delegate() {
|
||||
return &contents_delegate_;
|
||||
}
|
||||
CefMediaStreamRegistrar* GetMediaStreamRegistrar();
|
||||
CefDevToolsWindowRunner* GetDevToolsWindowRunner();
|
||||
@ -439,7 +439,7 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
const bool is_views_hosted_;
|
||||
|
||||
// Only accessed on the UI thread.
|
||||
std::unique_ptr<CefBrowserContentsDelegate> contents_delegate_;
|
||||
CefBrowserContentsDelegate contents_delegate_;
|
||||
CefRefPtr<CefUnresponsiveProcessCallback> unresponsive_process_callback_;
|
||||
raw_ptr<RenderViewContextMenuObserver> context_menu_observer_ = nullptr;
|
||||
|
||||
|
@ -148,7 +148,7 @@ void ChromeBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (contents_delegate_->OnSetFocus(source)) {
|
||||
if (contents_delegate_.OnSetFocus(source)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -470,7 +470,7 @@ void ChromeBrowserHostImpl::Attach(content::WebContents* web_contents,
|
||||
|
||||
platform_delegate_->WebContentsCreated(web_contents,
|
||||
/*own_web_contents=*/false);
|
||||
contents_delegate_->ObserveWebContents(web_contents);
|
||||
contents_delegate_.ObserveWebContents(web_contents);
|
||||
|
||||
// Associate the platform delegate with this browser.
|
||||
platform_delegate_->BrowserCreated(this);
|
||||
|
Loading…
x
Reference in New Issue
Block a user