summaryrefslogtreecommitdiffstats
path: root/src/core/web_contents_adapter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/web_contents_adapter.cpp')
-rw-r--r--src/core/web_contents_adapter.cpp59
1 files changed, 50 insertions, 9 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 5850b07b5..668e791c1 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -48,6 +48,7 @@
#include "browser_context_adapter.h"
#include "browser_context_adapter_client.h"
#include "browser_context_qt.h"
+#include "devtools_frontend_qt.h"
#include "download_manager_delegate_qt.h"
#include "media_capture_devices_dispatcher.h"
#include "print_view_manager_qt.h"
@@ -60,7 +61,8 @@
#include "web_engine_context.h"
#include "web_engine_settings.h"
-#include <base/run_loop.h>
+#include "base/command_line.h"
+#include "base/run_loop.h"
#include "base/values.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
@@ -80,6 +82,7 @@
#include "content/public/common/resource_request_body.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/web_preferences.h"
+#include "content/public/common/webrtc_ip_handling_policy.h"
#include "third_party/WebKit/public/web/WebFindOptions.h"
#include "printing/features/features.h"
#include "ui/base/clipboard/clipboard.h"
@@ -358,6 +361,7 @@ WebContentsAdapterPrivate::WebContentsAdapterPrivate()
, nextRequestId(CallbackDirectory::ReservedCallbackIdsEnd)
, lastFindRequestId(0)
, currentDropAction(blink::kWebDragOperationNone)
+ , devToolsFrontend(nullptr)
{
}
@@ -429,10 +433,14 @@ void WebContentsAdapter::initialize(WebContentsAdapterClient *adapterClient)
rendererPrefs->caret_blink_interval = 0.5 * static_cast<double>(qtCursorFlashTime) / 1000;
rendererPrefs->user_agent_override = d->browserContextAdapter->httpUserAgent().toStdString();
rendererPrefs->accept_languages = d->browserContextAdapter->httpAcceptLanguageWithoutQualities().toStdString();
-#if defined(ENABLE_WEBRTC)
+#if BUILDFLAG(ENABLE_WEBRTC)
base::CommandLine* commandLine = base::CommandLine::ForCurrentProcess();
if (commandLine->HasSwitch(switches::kForceWebRtcIPHandlingPolicy))
rendererPrefs->webrtc_ip_handling_policy = commandLine->GetSwitchValueASCII(switches::kForceWebRtcIPHandlingPolicy);
+ else
+ rendererPrefs->webrtc_ip_handling_policy = adapterClient->webEngineSettings()->testAttribute(WebEngineSettings::WebRTCPublicInterfacesOnly)
+ ? content::kWebRTCIPHandlingDefaultPublicInterfaceOnly
+ : content::kWebRTCIPHandlingDefault;
#endif
// Set web-contents font settings to the default font settings as Chromium constantly overrides
// the global font defaults with the font settings of the latest web-contents created.
@@ -969,14 +977,10 @@ void WebContentsAdapter::download(const QUrl &url, const QString &suggestedFileN
Q_D(WebContentsAdapter);
content::BrowserContext *bctx = webContents()->GetBrowserContext();
content::DownloadManager *dlm = content::BrowserContext::GetDownloadManager(bctx);
- DownloadManagerDelegateQt *dlmd = d->browserContextAdapter->downloadManagerDelegate();
if (!dlm)
return;
- dlmd->setDownloadType(BrowserContextAdapterClient::UserRequested);
- dlm->SetDelegate(dlmd);
-
net::NetworkTrafficAnnotationTag traffic_annotation =
net::DefineNetworkTrafficAnnotation(
"WebContentsAdapter::download", R"(
@@ -1050,19 +1054,56 @@ void WebContentsAdapter::executeMediaPlayerActionAt(const QPoint &location, Medi
void WebContentsAdapter::inspectElementAt(const QPoint &location)
{
Q_D(WebContentsAdapter);
- if (content::DevToolsAgentHost::HasFor(d->webContents.get())) {
- content::DevToolsAgentHost::GetOrCreateFor(d->webContents.get())->InspectElement(nullptr, location.x(), location.y());
+ if (d->devToolsFrontend) {
+ d->devToolsFrontend->InspectElementAt(location.x(), location.y());
+ return;
}
+ if (content::DevToolsAgentHost::HasFor(d->webContents.get()))
+ content::DevToolsAgentHost::GetOrCreateFor(d->webContents.get())->InspectElement(nullptr, location.x(), location.y());
}
bool WebContentsAdapter::hasInspector() const
{
- const Q_D(WebContentsAdapter);
+ Q_D(const WebContentsAdapter);
+ if (d->devToolsFrontend)
+ return true;
if (content::DevToolsAgentHost::HasFor(d->webContents.get()))
return content::DevToolsAgentHost::GetOrCreateFor(d->webContents.get())->IsAttached();
return false;
}
+void WebContentsAdapter::openDevToolsFrontend(QSharedPointer<WebContentsAdapter> frontendAdapter)
+{
+ Q_D(WebContentsAdapter);
+ if (d->devToolsFrontend &&
+ d->devToolsFrontend->frontendDelegate() == frontendAdapter->webContents()->GetDelegate())
+ return;
+
+ if (d->devToolsFrontend) {
+ d->devToolsFrontend->DisconnectFromTarget();
+ d->devToolsFrontend->Close();
+ }
+
+ d->devToolsFrontend = DevToolsFrontendQt::Show(frontendAdapter, d->webContents.get());
+}
+
+void WebContentsAdapter::closeDevToolsFrontend()
+{
+ Q_D(WebContentsAdapter);
+ if (d->devToolsFrontend) {
+ d->devToolsFrontend->DisconnectFromTarget();
+ d->devToolsFrontend->Close();
+ }
+}
+
+void WebContentsAdapter::devToolsFrontendDestroyed(DevToolsFrontendQt *frontend)
+{
+ Q_D(WebContentsAdapter);
+ Q_ASSERT(frontend == d->devToolsFrontend);
+ Q_UNUSED(frontend);
+ d->devToolsFrontend = nullptr;
+}
+
void WebContentsAdapter::exitFullScreen()
{
Q_D(WebContentsAdapter);