refactor: eliminate duplicate code (#29174)

This commit is contained in:
Milan Burda 2021-05-24 04:32:55 +02:00 committed by GitHub
parent 6330f8be9f
commit 241cceb2c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 66 additions and 151 deletions

View file

@ -2217,10 +2217,8 @@ void WebContents::EnableDeviceEmulation(
DCHECK(web_contents());
auto* frame_host = web_contents()->GetMainFrame();
if (frame_host) {
auto* widget_host_impl =
frame_host ? static_cast<content::RenderWidgetHostImpl*>(
frame_host->GetView()->GetRenderWidgetHost())
: nullptr;
auto* widget_host_impl = static_cast<content::RenderWidgetHostImpl*>(
frame_host->GetView()->GetRenderWidgetHost());
if (widget_host_impl) {
auto& frame_widget = widget_host_impl->GetAssociatedFrameWidget();
frame_widget->EnableDeviceEmulation(params);
@ -2235,10 +2233,8 @@ void WebContents::DisableDeviceEmulation() {
DCHECK(web_contents());
auto* frame_host = web_contents()->GetMainFrame();
if (frame_host) {
auto* widget_host_impl =
frame_host ? static_cast<content::RenderWidgetHostImpl*>(
frame_host->GetView()->GetRenderWidgetHost())
: nullptr;
auto* widget_host_impl = static_cast<content::RenderWidgetHostImpl*>(
frame_host->GetView()->GetRenderWidgetHost());
if (widget_host_impl) {
auto& frame_widget = widget_host_impl->GetAssociatedFrameWidget();
frame_widget->DisableDeviceEmulation();