diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-07-03 12:59:23 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-07-05 11:38:23 +0200 |
commit | 8f160af577e4d979954a63ab56f56e4d0c8ad0f8 (patch) | |
tree | 0c6cf366f3309c96e43e532527aff362320b7e94 /src/core | |
parent | 601003362c75283e9164e997e3835e7c36c6db00 (diff) | |
parent | fcdde728f0c4b4af5159b993e44eb6089d70aa90 (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Change-Id: Ida702fd5fa05a32d6cd7fc737aa061da74b675a0
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/api/core_api.pro | 8 | ||||
-rw-r--r-- | src/core/api/qtbug-60565.cpp | 9 | ||||
-rw-r--r-- | src/core/browser_context_qt.cpp | 20 | ||||
-rw-r--r-- | src/core/config/linux.pri | 7 | ||||
-rw-r--r-- | src/core/config/windows.pri | 13 | ||||
-rw-r--r-- | src/core/content_main_delegate_qt.cpp | 13 | ||||
-rw-r--r-- | src/core/core.pro | 17 | ||||
-rw-r--r-- | src/core/core_module.pro | 4 | ||||
-rw-r--r-- | src/core/media_capture_devices_dispatcher.cpp | 36 | ||||
-rw-r--r-- | src/core/qtwebengine.gni | 7 | ||||
-rw-r--r-- | src/core/render_widget_host_view_qt.cpp | 16 | ||||
-rw-r--r-- | src/core/resource_bundle_qt.cpp | 3 | ||||
-rw-r--r-- | src/core/url_request_context_getter_qt.cpp | 6 | ||||
-rw-r--r-- | src/core/web_contents_adapter.cpp | 3 | ||||
-rw-r--r-- | src/core/web_contents_adapter_client.h | 4 | ||||
-rw-r--r-- | src/core/web_contents_delegate_qt.cpp | 7 | ||||
-rw-r--r-- | src/core/web_contents_delegate_qt.h | 2 |
17 files changed, 105 insertions, 70 deletions
diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro index 22c165e2a..d3d47e03a 100644 --- a/src/core/api/core_api.pro +++ b/src/core/api/core_api.pro @@ -53,11 +53,3 @@ SOURCES = \ unix:!isEmpty(QMAKE_LFLAGS_VERSION_SCRIPT):!static { SOURCES += qtbug-60565.cpp } - -msvc { - # Create a list of object files that can be used as response file for the linker. - # This is done to simulate -whole-archive on MSVC. - QMAKE_POST_LINK = \ - "if exist $(DESTDIR_TARGET).objects del $(DESTDIR_TARGET).objects$$escape_expand(\\n\\t)" \ - "for %%a in ($(OBJECTS)) do echo $$shell_quote($$shell_path($$OUT_PWD))\\%%a >> $(DESTDIR_TARGET).objects" -} diff --git a/src/core/api/qtbug-60565.cpp b/src/core/api/qtbug-60565.cpp index 21b545cca..be601b7e4 100644 --- a/src/core/api/qtbug-60565.cpp +++ b/src/core/api/qtbug-60565.cpp @@ -47,6 +47,7 @@ #endif #define SHIM_ALIAS_SYMBOL(fn) __attribute__((weak, alias(#fn))) +#define SHIM_HIDDEN __attribute__ ((visibility ("hidden"))) extern "C" { @@ -87,19 +88,19 @@ static void* __shimCppNewArray(size_t size); static void __shimCppDelete(void *address); static void __shimCppDeleteArray(void *address); -static void* ShimCppNew(size_t size) { +SHIM_HIDDEN void* ShimCppNew(size_t size) { return __shimCppNew(size); } -static void* ShimCppNewArray(size_t size) { +SHIM_HIDDEN void* ShimCppNewArray(size_t size) { return __shimCppNewArray(size); } -static void ShimCppDelete(void* address) { +SHIM_HIDDEN void ShimCppDelete(void* address) { __shimCppDelete(address); } -static void ShimCppDeleteArray(void* address) { +SHIM_HIDDEN void ShimCppDeleteArray(void* address) { __shimCppDeleteArray(address); } } // extern "C" diff --git a/src/core/browser_context_qt.cpp b/src/core/browser_context_qt.cpp index 133006d70..ffee001ff 100644 --- a/src/core/browser_context_qt.cpp +++ b/src/core/browser_context_qt.cpp @@ -63,8 +63,9 @@ #include "components/prefs/pref_registry_simple.h" #include "components/user_prefs/user_prefs.h" #if BUILDFLAG(ENABLE_SPELLCHECK) -#include "chrome/common/pref_names.h" #include "chrome/browser/spellchecker/spellcheck_service.h" +#include "chrome/common/pref_names.h" +#include "components/spellcheck/browser/pref_names.h" #endif namespace QtWebEngineCore { @@ -80,12 +81,11 @@ BrowserContextQt::BrowserContextQt(BrowserContextAdapter *adapter) #if BUILDFLAG(ENABLE_SPELLCHECK) // Initial spellcheck settings - registry->RegisterListPref(prefs::kSpellCheckDictionaries, new base::ListValue()); registry->RegisterStringPref(prefs::kAcceptLanguages, std::string()); - registry->RegisterStringPref(prefs::kSpellCheckDictionary, std::string()); - registry->RegisterBooleanPref(prefs::kSpellCheckUseSpellingService, false); - registry->RegisterBooleanPref(prefs::kEnableContinuousSpellcheck, false); - registry->RegisterBooleanPref(prefs::kEnableAutoSpellCorrect, false); + registry->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries, new base::ListValue()); + registry->RegisterStringPref(spellcheck::prefs::kSpellCheckDictionary, std::string()); + registry->RegisterBooleanPref(spellcheck::prefs::kEnableSpellcheck, false); + registry->RegisterBooleanPref(spellcheck::prefs::kSpellCheckUseSpellingService, false); #endif //ENABLE_SPELLCHECK m_prefService = factory.Create(std::move(registry.get())); user_prefs::UserPrefs::Set(this, m_prefService.get()); @@ -216,7 +216,7 @@ void BrowserContextQt::failedToLoadDictionary(const std::string &language) void BrowserContextQt::setSpellCheckLanguages(const QStringList &languages) { StringListPrefMember dictionaries_pref; - dictionaries_pref.Init(prefs::kSpellCheckDictionaries, m_prefService.get()); + dictionaries_pref.Init(spellcheck::prefs::kSpellCheckDictionaries, m_prefService.get()); std::vector<std::string> dictionaries; dictionaries.reserve(languages.size()); for (const auto &language : languages) @@ -227,7 +227,7 @@ void BrowserContextQt::setSpellCheckLanguages(const QStringList &languages) QStringList BrowserContextQt::spellCheckLanguages() const { QStringList spellcheck_dictionaries; - for (const auto &value : *m_prefService->GetList(prefs::kSpellCheckDictionaries)) { + for (const auto &value : *m_prefService->GetList(spellcheck::prefs::kSpellCheckDictionaries)) { std::string dictionary; if (value->GetAsString(&dictionary)) spellcheck_dictionaries.append(QString::fromStdString(dictionary)); @@ -238,12 +238,12 @@ QStringList BrowserContextQt::spellCheckLanguages() const void BrowserContextQt::setSpellCheckEnabled(bool enabled) { - m_prefService->SetBoolean(prefs::kEnableContinuousSpellcheck, enabled); + m_prefService->SetBoolean(spellcheck::prefs::kEnableSpellcheck, enabled); } bool BrowserContextQt::isSpellCheckEnabled() const { - return m_prefService->GetBoolean(prefs::kEnableContinuousSpellcheck); + return m_prefService->GetBoolean(spellcheck::prefs::kEnableSpellcheck); } #endif //ENABLE_SPELLCHECK } // namespace QtWebEngineCore diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri index 24951cd07..60cfa6857 100644 --- a/src/core/config/linux.pri +++ b/src/core/config/linux.pri @@ -98,17 +98,18 @@ contains(QT_ARCH, "mips"):!host_build { host_build { gn_args += custom_toolchain=\"$$QTWEBENGINE_OUT_ROOT/src/toolchain:host\" + GN_HOST_CPU = $$gnArch($$QT_ARCH) + gn_args += host_cpu=\"$$GN_HOST_CPU\" # Don't bother trying to use system libraries in this case gn_args += use_glib=false gn_args += use_system_libffi=false } else { gn_args += custom_toolchain=\"$$QTWEBENGINE_OUT_ROOT/src/toolchain:target\" + gn_args += host_toolchain=\"$$QTWEBENGINE_OUT_ROOT/src/toolchain:host\" cross_compile { - gn_args += host_toolchain=\"$$QTWEBENGINE_OUT_ROOT/src/toolchain:host\" gn_args += v8_snapshot_toolchain=\"$$QTWEBENGINE_OUT_ROOT/src/toolchain:v8_snapshot\" - GN_HOST_CPU = $$gnArch($$QMAKE_HOST.arch) GN_TARGET_CPU = $$gnArch($$QT_ARCH) - gn_args += host_cpu=\"$$GN_HOST_CPU\" target_cpu=\"$$GN_TARGET_CPU\" + gn_args += target_cpu=\"$$GN_TARGET_CPU\" } !contains(QT_CONFIG, no-pkg-config) { # Strip '>2 /dev/null' from $$pkgConfigExecutable() diff --git a/src/core/config/windows.pri b/src/core/config/windows.pri index 49c725475..f5dd4a9d3 100644 --- a/src/core/config/windows.pri +++ b/src/core/config/windows.pri @@ -36,10 +36,8 @@ defineTest(usingMSVC32BitCrossCompiler) { msvc:contains(QT_ARCH, "i386"):!usingMSVC32BitCrossCompiler() { # The 32 bit MSVC linker runs out of memory if we do not remove all debug information. - gn_args += symbol_level=0 -} else { - # Chromium builds with debug info in release by default but Qt doesn't - CONFIG(release, debug|release):!force_debug_info: gn_args += symbol_level=1 + force_debug_info: gn_args -= symbol_level=1 + gn_args *= symbol_level=0 } msvc { @@ -55,10 +53,11 @@ msvc { SDK_PATH = $$(WINDOWSSDKDIR) VS_PATH= $$(VSINSTALLDIR) - gn_args += visual_studio_path=$$shell_quote($$VS_PATH) - gn_args += windows_sdk_path=$$shell_quote($$SDK_PATH) + gn_args += visual_studio_path=\"$$clean_path($$VS_PATH)\" + gn_args += windows_sdk_path=\"$$clean_path($$SDK_PATH)\" - contains(QT_ARCH, "i386"): gn_args += target_cpu=\"x86\" + GN_TARGET_CPU = $$gnArch($$QT_ARCH) + gn_args += target_cpu=\"$$GN_TARGET_CPU\" } else { fatal("Qt WebEngine for Windows can only be built with the Microsoft Visual Studio C++ compiler") diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp index 38f66d641..8284029a0 100644 --- a/src/core/content_main_delegate_qt.cpp +++ b/src/core/content_main_delegate_qt.cpp @@ -139,10 +139,15 @@ content::ContentRendererClient *ContentMainDelegateQt::CreateContentRendererClie { #if defined(OS_LINUX) base::CommandLine *parsedCommandLine = base::CommandLine::ForCurrentProcess(); - - if (parsedCommandLine->HasSwitch(switches::kLang)) { - const std::string &locale = parsedCommandLine->GetSwitchValueASCII(switches::kLang); - ui::ResourceBundle::GetSharedInstance().ReloadLocaleResources(locale); + std::string process_type = parsedCommandLine->GetSwitchValueASCII(switches::kProcessType); + bool no_sandbox = parsedCommandLine->HasSwitch(switches::kNoSandbox); + + // Reload locale if the renderer process is sandboxed + if (process_type == switches::kRendererProcess && !no_sandbox) { + if (parsedCommandLine->HasSwitch(switches::kLang)) { + const std::string &locale = parsedCommandLine->GetSwitchValueASCII(switches::kLang); + ui::ResourceBundle::GetSharedInstance().ReloadLocaleResources(locale); + } } #endif diff --git a/src/core/core.pro b/src/core/core.pro index 6cc8080e0..9709e62c3 100644 --- a/src/core/core.pro +++ b/src/core/core.pro @@ -17,23 +17,6 @@ core_generator.depends = core_headers # core_gn_generator.pro is a dummy .pro file that is used by qmake # to generate our main BUILD.gn file -core_icu.files = $$OUT_PWD/$$getConfigDir()/icudtl.dat -core_icu.path = $$[QT_INSTALL_DATA]/resources -core_icu.CONFIG += no_check_exist - -core_locales.files = $$OUT_PWD/$$getConfigDir()/qtwebengine_locales/*.pak -core_locales.path = $$[QT_INSTALL_TRANSLATIONS]/qtwebengine_locales -core_locales.CONFIG += no_check_exist - -core_resources.files = \ - $$OUT_PWD/$$getConfigDir()/qtwebengine_resources.pak \ - $$OUT_PWD/$$getConfigDir()/qtwebengine_resources_100p.pak \ - $$OUT_PWD/$$getConfigDir()/qtwebengine_resources_200p.pak \ - $$OUT_PWD/$$getConfigDir()/qtwebengine_devtools_resources.pak -core_resources.path = $$[QT_INSTALL_DATA]/resources -core_resources.CONFIG += no_check_exist -INSTALLS += core_resources core_locales core_icu - gn_run.file = gn_run.pro gn_run.depends = core_generator diff --git a/src/core/core_module.pro b/src/core/core_module.pro index 44e8ac613..3785ddc46 100644 --- a/src/core/core_module.pro +++ b/src/core/core_module.pro @@ -47,10 +47,8 @@ CONFIG *= no_smart_library_merge osx { LIBS_PRIVATE += -Wl,-force_load,$${api_library_path}$${QMAKE_DIR_SEP}lib$${api_library_name}.a } else:msvc { - # Simulate -whole-archive by passing the list of object files that belong to the public - # API library as response file to the linker. QMAKE_LFLAGS += /OPT:REF - QMAKE_LFLAGS += @$${api_library_path}$${QMAKE_DIR_SEP}$${api_library_name}.lib.objects + QMAKE_LFLAGS += /WHOLEARCHIVE:$${api_library_path}$${QMAKE_DIR_SEP}$${api_library_name}.lib } else { LIBS_PRIVATE += -Wl,-whole-archive -l$$api_library_name -Wl,-no-whole-archive } diff --git a/src/core/media_capture_devices_dispatcher.cpp b/src/core/media_capture_devices_dispatcher.cpp index b3c42aa08..8bdbaadd2 100644 --- a/src/core/media_capture_devices_dispatcher.cpp +++ b/src/core/media_capture_devices_dispatcher.cpp @@ -62,8 +62,14 @@ #include "content/public/common/media_stream_request.h" #include "media/audio/audio_device_description.h" #include "media/audio/audio_manager_base.h" +#include "media/media_features.h" #include "ui/base/l10n/l10n_util.h" +#if BUILDFLAG(ENABLE_WEBRTC) +#include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" +#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" +#endif + #include <QtCore/qcoreapplication.h> namespace QtWebEngineCore { @@ -330,10 +336,38 @@ void MediaCaptureDevicesDispatcher::handleScreenCaptureAccessRequest(content::We { content::MediaStreamDevices devices; std::unique_ptr<content::MediaStreamUI> ui; +#if BUILDFLAG(ENABLE_WEBRTC) if (userAccepted) { - content::DesktopMediaID screenId = content::DesktopMediaID(content::DesktopMediaID::TYPE_SCREEN, 0); + // Source id patterns are different across platforms. + // On Linux, the hardcoded value "0" is used. + // On Windows, the screens are enumerated consecutively in increasing order from 0. + // On macOS the source ids are randomish numbers assigned by the OS. + webrtc::DesktopCapturer::SourceId id = 0; + + // In order to provide a correct screen id, we query for the available screen ids, and + // select the first one as the main display id. + // The code is based on the file + // src/chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc. + webrtc::DesktopCaptureOptions options = + webrtc::DesktopCaptureOptions::CreateDefault(); + options.set_disable_effects(false); + std::unique_ptr<webrtc::DesktopCapturer> screen_capturer( + webrtc::DesktopCapturer::CreateScreenCapturer(options)); + + if (screen_capturer) { + webrtc::DesktopCapturer::SourceList screens; + if (screen_capturer->GetSourceList(&screens)) { + if (screens.size() > 0) { + id = screens[0].id; + } + } + } + + content::DesktopMediaID screenId = content::DesktopMediaID( + content::DesktopMediaID::TYPE_SCREEN, id); ui = getDevicesForDesktopCapture(&devices, screenId, false/*capture_audio*/, false/*display_notification*/, getContentsUrl(webContents)); } +#endif std::map<content::WebContents*, RequestsQueue>::iterator it = m_pendingRequests.find(webContents); if (it == m_pendingRequests.end()) { diff --git a/src/core/qtwebengine.gni b/src/core/qtwebengine.gni index de1fa1836..c9f766a36 100644 --- a/src/core/qtwebengine.gni +++ b/src/core/qtwebengine.gni @@ -1,3 +1,4 @@ +import("//media/media_options.gni") import("//third_party/widevine/cdm/widevine.gni") chromium_version = exec_script("//build/util/version.py", [ "-f", rebase_path("//chrome/VERSION"), @@ -18,10 +19,12 @@ deps = [ "//components/visitedlink/renderer", "//components/web_cache/browser", "//components/web_cache/renderer", + "//components/spellcheck:build_features", "//content/public/app:browser", "//content/public/browser", "//content/public/common", "//content/public/renderer", + "//media:media_features", "//net:net_browser_services", "//net:net_with_v8", "//skia", @@ -36,6 +39,10 @@ if (enable_widevine) { deps += [ "//components/cdm/renderer"] } +if (enable_webrtc) { + deps += [ "//third_party/webrtc/base:base" ] +} + if (is_linux && !is_desktop_linux) { deps += [ "//ui/events/ozone:events_ozone_evdev"] } diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 3d51d4108..4e98a1016 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -942,10 +942,17 @@ QVariant RenderWidgetHostViewQt::inputMethodQuery(Qt::InputMethodQuery query) case Qt::ImFont: // TODO: Implement this return QVariant(); - case Qt::ImCursorRectangle: - if (!text_input_manager_ || !text_input_manager_->GetActiveWidget()) - return QVariant(); - return toQt(text_input_manager_->GetSelectionRegion()->caret_rect); + case Qt::ImCursorRectangle: { + if (text_input_manager_) { + if (auto *region = text_input_manager_->GetSelectionRegion()) { + gfx::Rect caretRect = gfx::RectBetweenSelectionBounds(region->anchor, region->focus); + if (caretRect.width() == 0) + caretRect.set_width(1); // IME API on Windows expects a width > 0 + return toQt(caretRect); + } + } + return QVariant(); + } case Qt::ImCursorPosition: return m_cursorPosition; case Qt::ImAnchorPosition: @@ -1253,7 +1260,6 @@ void RenderWidgetHostViewQt::handleInputMethodEvent(QInputMethodEvent *ev) // to the same focused object, and cancelling the composition on the next event loop tick. if (!m_receivedEmptyImeText && m_imeInProgress && !hasSelection) { m_receivedEmptyImeText = true; - m_imeInProgress = false; QInputMethodEvent *eventCopy = new QInputMethodEvent(*ev); QGuiApplication::postEvent(qApp->focusObject(), eventCopy); } else { diff --git a/src/core/resource_bundle_qt.cpp b/src/core/resource_bundle_qt.cpp index 52355e996..c37854ea6 100644 --- a/src/core/resource_bundle_qt.cpp +++ b/src/core/resource_bundle_qt.cpp @@ -75,7 +75,8 @@ bool ResourceBundle::LocaleDataPakExists(const std::string& locale) #if defined(OS_LINUX) base::CommandLine *parsed_command_line = base::CommandLine::ForCurrentProcess(); std::string process_type = parsed_command_line->GetSwitchValueASCII(switches::kProcessType); - if (process_type == switches::kRendererProcess) { + bool no_sandbox = parsed_command_line->HasSwitch(switches::kNoSandbox); + if (process_type == switches::kRendererProcess && !no_sandbox) { // The Renderer Process is sandboxed thus only one locale is available in it. // The particular one is passed by the --lang command line option. if (!parsed_command_line->HasSwitch(switches::kLang) || parsed_command_line->GetSwitchValueASCII(switches::kLang) != locale) diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp index 9fc8add01..fe1758655 100644 --- a/src/core/url_request_context_getter_qt.cpp +++ b/src/core/url_request_context_getter_qt.cpp @@ -340,8 +340,7 @@ void URLRequestContextGetterQt::generateCookieStore() cookieMonster->SetCookieableSchemes(cookieableSchemes); m_cookieDelegate->setCookieMonster(cookieMonster); - if (!m_updateAllStorage) { - Q_ASSERT(m_updateHttpCache); + if (!m_updateAllStorage && m_updateHttpCache) { // HttpCache needs to be regenerated when we generate a new channel id service generateHttpCache(); } @@ -469,6 +468,9 @@ void URLRequestContextGetterQt::generateHttpCache() QMutexLocker lock(&m_mutex); m_updateHttpCache = false; + if (m_updateCookieStore) + generateCookieStore(); + net::HttpCache::DefaultBackend* main_backend = 0; switch (m_httpCacheType) { case BrowserContextAdapter::MemoryHttpCache: diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 270096553..399c036a4 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -402,6 +402,7 @@ void WebContentsAdapter::initialize(WebContentsAdapterClient *adapterClient) // We keep a reference to browserContextAdapter to keep it alive as long as we use it. // This is needed in case the QML WebEngineProfile is garbage collected before the WebEnginePage. d->browserContextAdapter = adapterClient->browserContextAdapter(); + Q_ASSERT(d->browserContextAdapter); // Create our own if a WebContents wasn't provided at construction. if (!d->webContents) @@ -1228,7 +1229,7 @@ static void fillDropDataFromMimeData(content::DropData *dropData, const QMimeDat return; if (mimeData->hasHtml()) dropData->html = toNullableString16(mimeData->html()); - else if (mimeData->hasText()) + if (mimeData->hasText()) dropData->text = toNullableString16(mimeData->text()); } diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h index ee7dbe1ce..8d75f24b7 100644 --- a/src/core/web_contents_adapter_client.h +++ b/src/core/web_contents_adapter_client.h @@ -339,7 +339,7 @@ public: virtual void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) = 0; virtual void focusContainer() = 0; virtual void unhandledKeyEvent(QKeyEvent *event) = 0; - virtual void adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect & initialGeometry) = 0; + virtual void adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect & initialGeometry, const QUrl &targetUrl) = 0; virtual bool isBeingAdopted() = 0; virtual void close() = 0; virtual void windowCloseRejected() = 0; @@ -359,9 +359,7 @@ public: virtual void passOnFocus(bool reverse) = 0; // returns the last QObject (QWidget/QQuickItem) based object in the accessibility // hierarchy before going into the BrowserAccessibility tree -#ifndef QT_NO_ACCESSIBILITY virtual QObject *accessibilityParentObject() = 0; -#endif // QT_NO_ACCESSIBILITY virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) = 0; virtual void authenticationRequired(QSharedPointer<AuthenticationDialogController>) = 0; virtual void runGeolocationPermissionRequest(const QUrl &securityOrigin) = 0; diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 5bcb83c6b..a6e1fb438 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -306,6 +306,11 @@ void WebContentsDelegateQt::DidUpdateFaviconURL(const std::vector<content::Favic m_faviconManager->update(faviconCandidates); } +void WebContentsDelegateQt::WebContentsCreated(content::WebContents* /*source_contents*/, int /*opener_render_process_id*/, int /*opener_render_frame_id*/, const std::string& /*frame_name*/, const GURL& target_url, content::WebContents* new_contents) +{ + this->m_initialTargetUrl = toQt(target_url); +} + content::ColorChooser *WebContentsDelegateQt::OpenColorChooser(content::WebContents *source, SkColor color, const std::vector<content::ColorSuggestion> &suggestion) { Q_UNUSED(suggestion); @@ -445,7 +450,7 @@ QWeakPointer<WebContentsAdapter> WebContentsDelegateQt::createWindow(content::We { QSharedPointer<WebContentsAdapter> newAdapter = QSharedPointer<WebContentsAdapter>::create(new_contents); - m_viewClient->adoptNewWindow(newAdapter, static_cast<WebContentsAdapterClient::WindowOpenDisposition>(disposition), user_gesture, toQt(initial_pos)); + m_viewClient->adoptNewWindow(newAdapter, static_cast<WebContentsAdapterClient::WindowOpenDisposition>(disposition), user_gesture, toQt(initial_pos), m_initialTargetUrl); // If the client didn't reference the adapter, it will be deleted now, and the weak pointer zeroed. return newAdapter; diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index 5ae442bbc..84799c2cd 100644 --- a/src/core/web_contents_delegate_qt.h +++ b/src/core/web_contents_delegate_qt.h @@ -104,6 +104,7 @@ public: void LoadProgressChanged(content::WebContents* source, double progress) override; void HandleKeyboardEvent(content::WebContents *source, const content::NativeWebKeyboardEvent &event) override; content::ColorChooser *OpenColorChooser(content::WebContents *source, SkColor color, const std::vector<content::ColorSuggestion> &suggestion) override; + void WebContentsCreated(content::WebContents* source_contents, int opener_render_process_id, int opener_render_frame_id, const std::string& frame_name, const GURL& target_url, content::WebContents* new_contents) override; content::JavaScriptDialogManager *GetJavaScriptDialogManager(content::WebContents *source) override; void EnterFullscreenModeForTab(content::WebContents* web_contents, const GURL& origin) override; void ExitFullscreenModeForTab(content::WebContents*) override; @@ -156,6 +157,7 @@ private: QScopedPointer<FaviconManager> m_faviconManager; SavePageInfo m_savePageInfo; QSharedPointer<FilePickerController> m_filePickerController; + QUrl m_initialTargetUrl; }; } // namespace QtWebEngineCore |