summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
m---------src/3rdparty0
-rw-r--r--src/core/access_token_store_qt.cpp4
-rw-r--r--src/core/access_token_store_qt.h6
-rw-r--r--src/core/browser_accessibility_qt.cpp4
-rw-r--r--src/core/browser_context_adapter.cpp15
-rw-r--r--src/core/browser_context_adapter_client.h8
-rw-r--r--src/core/browser_context_qt.cpp28
-rw-r--r--src/core/browser_context_qt.h11
-rw-r--r--src/core/chrome_qt.gyp32
-rw-r--r--src/core/chromium_gpu_helper.cpp7
-rw-r--r--src/core/common/qt_messages.h3
-rw-r--r--src/core/common/user_script_data.h3
-rw-r--r--src/core/config/common.pri4
-rw-r--r--src/core/config/embedded_linux.pri2
-rw-r--r--src/core/config/linux.pri8
-rw-r--r--src/core/config/windows.pri6
-rw-r--r--src/core/content_browser_client_qt.cpp33
-rw-r--r--src/core/content_browser_client_qt.h5
-rw-r--r--src/core/content_client_qt.cpp2
-rw-r--r--src/core/content_main_delegate_qt.cpp19
-rw-r--r--src/core/cookie_monster_delegate_qt.cpp70
-rw-r--r--src/core/cookie_monster_delegate_qt.h9
-rw-r--r--src/core/core_gyp_generator.pro3
-rw-r--r--src/core/delegated_frame_node.cpp29
-rw-r--r--src/core/dev_tools_http_handler_delegate_qt.cpp7
-rw-r--r--src/core/dev_tools_http_handler_delegate_qt.h2
-rw-r--r--src/core/download_manager_delegate_qt.cpp48
-rw-r--r--src/core/download_manager_delegate_qt.h4
-rw-r--r--src/core/file_picker_controller.cpp6
-rw-r--r--src/core/file_picker_controller.h8
-rw-r--r--src/core/gl_surface_qt.cpp9
-rw-r--r--src/core/global_descriptors_qt.h10
-rw-r--r--src/core/javascript_dialog_manager_qt.cpp10
-rw-r--r--src/core/javascript_dialog_manager_qt.h10
-rw-r--r--src/core/network_delegate_qt.cpp8
-rw-r--r--src/core/network_delegate_qt.h2
-rw-r--r--src/core/ozone_platform_eglfs.cpp15
-rw-r--r--src/core/ozone_platform_eglfs.h1
-rw-r--r--src/core/permission_manager_qt.cpp33
-rw-r--r--src/core/permission_manager_qt.h12
-rw-r--r--src/core/print_view_manager_base_qt.h2
-rw-r--r--src/core/print_view_manager_qt.h2
-rw-r--r--src/core/printing_message_filter_qt.cpp14
-rw-r--r--src/core/printing_message_filter_qt.h8
-rw-r--r--src/core/qtwebengine.gypi3
-rw-r--r--src/core/render_widget_host_view_qt.cpp34
-rw-r--r--src/core/render_widget_host_view_qt.h17
-rw-r--r--src/core/render_widget_host_view_qt_delegate.h21
-rw-r--r--src/core/renderer/content_renderer_client_qt.cpp47
-rw-r--r--src/core/renderer/content_renderer_client_qt.h8
-rw-r--r--src/core/renderer/pepper/pepper_flash_clipboard_message_filter_qt.cpp401
-rw-r--r--src/core/renderer/pepper/pepper_flash_clipboard_message_filter_qt.h108
-rw-r--r--src/core/renderer/pepper/pepper_host_factory_qt.cpp20
-rw-r--r--src/core/renderer/pepper/pepper_host_factory_qt.h2
-rw-r--r--src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp14
-rw-r--r--src/core/renderer/pepper/pepper_renderer_host_factory_qt.h2
-rw-r--r--src/core/renderer/render_frame_observer_qt.cpp8
-rw-r--r--src/core/renderer/render_view_observer_qt.cpp24
-rw-r--r--src/core/renderer/user_resource_controller.cpp68
-rw-r--r--src/core/renderer/user_resource_controller.h15
-rw-r--r--src/core/renderer/web_channel_ipc_transport.cpp20
-rw-r--r--src/core/renderer/web_channel_ipc_transport.h12
-rw-r--r--src/core/resource_bundle_qt.cpp70
-rw-r--r--src/core/resources/resources.gyp4
-rw-r--r--src/core/type_conversion.cpp2
-rw-r--r--src/core/url_request_context_getter_qt.cpp13
-rw-r--r--src/core/url_request_context_getter_qt.h11
-rw-r--r--src/core/user_script.cpp105
-rw-r--r--src/core/user_script.h3
-rw-r--r--src/core/web_channel_ipc_transport_host.h2
-rw-r--r--src/core/web_contents_adapter.cpp30
-rw-r--r--src/core/web_contents_adapter.h5
-rw-r--r--src/core/web_contents_adapter_client.h1
-rw-r--r--src/core/web_contents_delegate_qt.h22
-rw-r--r--src/core/web_engine_context.cpp11
-rw-r--r--src/core/web_engine_library_info.cpp12
-rw-r--r--src/core/yuv_video_node.cpp31
-rw-r--r--src/core/yuv_video_node.h9
-rw-r--r--src/tools/qwebengine_convert_dict/qwebengine_convert_dict.pro3
-rw-r--r--src/webengine/api/qquickwebenginecontextmenudata.cpp34
-rw-r--r--src/webengine/api/qquickwebenginecontextmenudata_p.h7
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem.cpp24
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p.h11
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p_p.h1
-rw-r--r--src/webengine/api/qquickwebengineprofile.cpp80
-rw-r--r--src/webengine/api/qquickwebengineprofile.h9
-rw-r--r--src/webengine/api/qquickwebengineview.cpp38
-rw-r--r--src/webengine/api/qquickwebengineview_p.h7
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h1
-rw-r--r--src/webengine/doc/qtwebengine.qdocconf1
-rw-r--r--src/webengine/doc/src/external-resources.qdoc15
-rw-r--r--src/webengine/doc/src/qtwebengine-platform-notes.qdoc4
-rw-r--r--src/webengine/doc/src/qtwebengine-qmlmodule.qdoc4
-rw-r--r--src/webengine/doc/src/webengineview.qdoc17
-rw-r--r--src/webengine/plugin/experimental/plugin.cpp5
-rw-r--r--src/webengine/plugin/plugin.cpp4
-rw-r--r--src/webengine/plugin/plugin.pro2
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quick.cpp29
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quick.h5
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp17
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quickwindow.h5
-rw-r--r--src/webengine/ui/ToolTip.qml91
-rw-r--r--src/webengine/ui/ui.pro3
-rw-r--r--src/webengine/ui_delegates_manager.cpp64
-rw-r--r--src/webengine/ui_delegates_manager.h5
-rw-r--r--src/webenginewidgets/api/qwebenginecontextmenudata.cpp24
-rw-r--r--src/webenginewidgets/api/qwebenginecontextmenudata.h2
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.cpp29
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.h9
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem_p.h1
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp108
-rw-r--r--src/webenginewidgets/api/qwebenginepage.h10
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h1
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.cpp65
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.h5
-rw-r--r--src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc1
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp173
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h25
-rw-r--r--src/webenginewidgets/webenginewidgets.pro2
119 files changed, 1644 insertions, 974 deletions
diff --git a/src/3rdparty b/src/3rdparty
-Subproject 7f6555e9921bfff1886f1e63bb802c252281e88
+Subproject 73ce027510183c151bb792433f36eb143aff72f
diff --git a/src/core/access_token_store_qt.cpp b/src/core/access_token_store_qt.cpp
index 6c4cbc610..853170d56 100644
--- a/src/core/access_token_store_qt.cpp
+++ b/src/core/access_token_store_qt.cpp
@@ -67,7 +67,7 @@ AccessTokenStoreQt::~AccessTokenStoreQt()
{
}
-void AccessTokenStoreQt::LoadAccessTokens(const LoadAccessTokensCallbackType& callback)
+void AccessTokenStoreQt::LoadAccessTokens(const LoadAccessTokensCallback& callback)
{
BrowserThread::PostTaskAndReply(BrowserThread::UI, FROM_HERE
, base::Bind(&AccessTokenStoreQt::performWorkOnUIThread, this)
@@ -79,7 +79,7 @@ void AccessTokenStoreQt::performWorkOnUIThread()
m_systemRequestContext = WebEngineContext::current()->defaultBrowserContext()->browserContext()->GetRequestContext();
}
-void AccessTokenStoreQt::respondOnOriginatingThread(const LoadAccessTokensCallbackType& callback)
+void AccessTokenStoreQt::respondOnOriginatingThread(const LoadAccessTokensCallback& callback)
{
callback.Run(m_accessTokenSet, m_systemRequestContext);
m_systemRequestContext = 0;
diff --git a/src/core/access_token_store_qt.h b/src/core/access_token_store_qt.h
index 0f45fd3a0..973f304c0 100644
--- a/src/core/access_token_store_qt.h
+++ b/src/core/access_token_store_qt.h
@@ -58,16 +58,16 @@ public:
AccessTokenStoreQt();
~AccessTokenStoreQt();
- virtual void LoadAccessTokens(const LoadAccessTokensCallbackType& request) Q_DECL_OVERRIDE;
+ virtual void LoadAccessTokens(const LoadAccessTokensCallback& request) Q_DECL_OVERRIDE;
virtual void SaveAccessToken(const GURL& serverUrl, const base::string16& accessToken) Q_DECL_OVERRIDE;
private:
void performWorkOnUIThread();
- void respondOnOriginatingThread(const LoadAccessTokensCallbackType& callback);
+ void respondOnOriginatingThread(const LoadAccessTokensCallback& callback);
net::URLRequestContextGetter *m_systemRequestContext;
- AccessTokenSet m_accessTokenSet;
+ AccessTokenMap m_accessTokenSet;
DISALLOW_COPY_AND_ASSIGN(AccessTokenStoreQt);
};
diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp
index fecbac111..30e6efc2e 100644
--- a/src/core/browser_accessibility_qt.cpp
+++ b/src/core/browser_accessibility_qt.cpp
@@ -418,7 +418,7 @@ QAccessible::State BrowserAccessibilityQt::state() const
state.expanded = true;
if (s & (1 << ui::AX_STATE_FOCUSABLE))
state.focusable = true;
- if (s & (1 << ui::AX_STATE_FOCUSED))
+ if (manager()->GetFocus() == this)
state.focused = true;
if (s & (1 << ui::AX_STATE_HASPOPUP))
state.hasPopup = true;
@@ -480,7 +480,7 @@ QStringList BrowserAccessibilityQt::actionNames() const
void BrowserAccessibilityQt::doAction(const QString &actionName)
{
if (actionName == QAccessibleActionInterface::setFocusAction())
- manager()->SetFocus(this, true);
+ manager()->SetFocus(*this);
}
QStringList BrowserAccessibilityQt::keyBindingsForAction(const QString &actionName) const
diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp
index 24e2dc2c2..03150d322 100644
--- a/src/core/browser_context_adapter.cpp
+++ b/src/core/browser_context_adapter.cpp
@@ -45,6 +45,7 @@
#include "content_client_qt.h"
#include "download_manager_delegate_qt.h"
#include "permission_manager_qt.h"
+#include "type_conversion.h"
#include "web_engine_context.h"
#include "web_engine_visited_links_manager.h"
#include "url_request_context_getter_qt.h"
@@ -52,6 +53,10 @@
#include "net/proxy/proxy_service.h"
+#if defined(ENABLE_SPELLCHECK)
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
+#endif
+
#include <QCoreApplication>
#include <QDir>
#include <QString>
@@ -78,6 +83,8 @@ BrowserContextAdapter::BrowserContextAdapter(bool offTheRecord)
, m_visitedLinksPolicy(TrackVisitedLinksOnDisk)
, m_httpCacheMaxSize(0)
{
+ WebEngineContext::current(); // Ensure the WebEngineContext has been initialized
+ content::BrowserContext::Initialize(m_browserContext.data(), toFilePath(dataPath()));
}
BrowserContextAdapter::BrowserContextAdapter(const QString &storageName)
@@ -89,12 +96,20 @@ BrowserContextAdapter::BrowserContextAdapter(const QString &storageName)
, m_visitedLinksPolicy(TrackVisitedLinksOnDisk)
, m_httpCacheMaxSize(0)
{
+ WebEngineContext::current(); // Ensure the WebEngineContext has been initialized
+ content::BrowserContext::Initialize(m_browserContext.data(), toFilePath(dataPath()));
}
BrowserContextAdapter::~BrowserContextAdapter()
{
if (m_downloadManagerDelegate)
content::BrowserThread::DeleteSoon(content::BrowserThread::UI, FROM_HERE, m_downloadManagerDelegate.take());
+#if defined(ENABLE_SPELLCHECK)
+ // Please note spellchecker is the only keyed service we use so far, therefore
+ // remove this check if there are other serivces also used.
+ BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(
+ m_browserContext.data());
+#endif
}
void BrowserContextAdapter::setStorageName(const QString &storageName)
diff --git a/src/core/browser_context_adapter_client.h b/src/core/browser_context_adapter_client.h
index 2df8c21cb..faba08591 100644
--- a/src/core/browser_context_adapter_client.h
+++ b/src/core/browser_context_adapter_client.h
@@ -69,6 +69,13 @@ public:
MimeHtmlSaveFormat
};
+ enum DownloadType {
+ Attachment = 0,
+ DownloadAttribute,
+ UserRequested,
+ SavePage
+ };
+
struct DownloadItemInfo {
const quint32 id;
const QUrl url;
@@ -80,6 +87,7 @@ public:
QString path;
int savePageFormat;
bool accepted;
+ int downloadType;
};
virtual ~BrowserContextAdapterClient() { }
diff --git a/src/core/browser_context_qt.cpp b/src/core/browser_context_qt.cpp
index 1c326fb83..7ca1c6477 100644
--- a/src/core/browser_context_qt.cpp
+++ b/src/core/browser_context_qt.cpp
@@ -56,12 +56,12 @@
#if defined(ENABLE_SPELLCHECK)
#include "base/base_paths.h"
-#include "base/prefs/pref_member.h"
-#include "base/prefs/pref_service.h"
-#include "base/prefs/testing_pref_store.h"
-#include "base/prefs/pref_service.h"
-#include "base/prefs/pref_service_factory.h"
-#include "base/prefs/pref_registry_simple.h"
+#include "components/prefs/pref_member.h"
+#include "components/prefs/pref_service.h"
+#include "components/prefs/testing_pref_store.h"
+#include "components/prefs/pref_service.h"
+#include "components/prefs/pref_service_factory.h"
+#include "components/prefs/pref_registry_simple.h"
#include "components/user_prefs/user_prefs.h"
#include "chrome/common/pref_names.h"
#include "chrome/browser/spellchecker/spellcheck_service.h"
@@ -75,7 +75,7 @@ BrowserContextQt::BrowserContextQt(BrowserContextAdapter *adapter)
m_prefStore(new TestingPrefStore())
{
m_prefStore->SetInitializationCompleted();
- base::PrefServiceFactory factory;
+ PrefServiceFactory factory;
factory.set_user_prefs(m_prefStore);
scoped_refptr<PrefRegistrySimple> registry(new PrefRegistrySimple());
@@ -122,11 +122,6 @@ net::URLRequestContextGetter *BrowserContextQt::GetRequestContext()
return url_request_getter_.get();
}
-net::URLRequestContextGetter *BrowserContextQt::GetRequestContextForRenderProcess(int)
-{
- return GetRequestContext();
-}
-
net::URLRequestContextGetter *BrowserContextQt::GetMediaRequestContext()
{
return GetRequestContext();
@@ -200,6 +195,15 @@ net::URLRequestContextGetter *BrowserContextQt::CreateRequestContext(content::Pr
return url_request_getter_.get();
}
+net::URLRequestContextGetter *BrowserContextQt::CreateRequestContextForStoragePartition(
+ const base::FilePath& partition_path, bool in_memory,
+ content::ProtocolHandlerMap* protocol_handlers,
+ content::URLRequestInterceptorScopedVector request_interceptors)
+{
+ Q_UNIMPLEMENTED();
+ return nullptr;
+}
+
#if defined(ENABLE_SPELLCHECK)
void BrowserContextQt::failedToLoadDictionary(const std::string &language)
{
diff --git a/src/core/browser_context_qt.h b/src/core/browser_context_qt.h
index e2156f147..13f7220bd 100644
--- a/src/core/browser_context_qt.h
+++ b/src/core/browser_context_qt.h
@@ -74,7 +74,6 @@ public:
virtual bool IsOffTheRecord() const Q_DECL_OVERRIDE;
virtual net::URLRequestContextGetter *GetRequestContext() Q_DECL_OVERRIDE;
- virtual net::URLRequestContextGetter *GetRequestContextForRenderProcess(int) Q_DECL_OVERRIDE;
virtual net::URLRequestContextGetter *GetMediaRequestContext() Q_DECL_OVERRIDE;
virtual net::URLRequestContextGetter *GetMediaRequestContextForRenderProcess(int) Q_DECL_OVERRIDE;
virtual net::URLRequestContextGetter *GetMediaRequestContextForStoragePartition(const base::FilePath&, bool) Q_DECL_OVERRIDE;
@@ -84,7 +83,13 @@ public:
virtual storage::SpecialStoragePolicy *GetSpecialStoragePolicy() Q_DECL_OVERRIDE;
virtual content::PushMessagingService* GetPushMessagingService() Q_DECL_OVERRIDE;
virtual content::SSLHostStateDelegate* GetSSLHostStateDelegate() Q_DECL_OVERRIDE;
- net::URLRequestContextGetter *CreateRequestContext(content::ProtocolHandlerMap *protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors);
+ net::URLRequestContextGetter *CreateRequestContext(
+ content::ProtocolHandlerMap *protocol_handlers,
+ content::URLRequestInterceptorScopedVector request_interceptors) Q_DECL_OVERRIDE;
+ net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
+ const base::FilePath& partition_path, bool in_memory,
+ content::ProtocolHandlerMap* protocol_handlers,
+ content::URLRequestInterceptorScopedVector request_interceptors) Q_DECL_OVERRIDE;
virtual scoped_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(const base::FilePath& partition_path) Q_DECL_OVERRIDE;
virtual content::PermissionManager *GetPermissionManager() Q_DECL_OVERRIDE;
virtual content::BackgroundSyncController* GetBackgroundSyncController() Q_DECL_OVERRIDE;
@@ -92,7 +97,7 @@ public:
BrowserContextAdapter *adapter() { return m_adapter; }
#if defined(ENABLE_SPELLCHECK)
- void failedToLoadDictionary(const std::string& language) override;
+ void failedToLoadDictionary(const std::string& language);
void setSpellCheckLanguage(const QString &language);
QString spellCheckLanguage() const;
void setSpellCheckEnabled(bool enabled);
diff --git a/src/core/chrome_qt.gyp b/src/core/chrome_qt.gyp
index f2d7c5831..d2dfb5a7b 100644
--- a/src/core/chrome_qt.gyp
+++ b/src/core/chrome_qt.gyp
@@ -2,8 +2,8 @@
'variables': {
'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/chrome',
'chrome_spellchecker_sources': [
- '<(DEPTH)/base/prefs/testing_pref_store.cc',
- '<(DEPTH)/base/prefs/testing_pref_store.h',
+ '<(DEPTH)/components/prefs/testing_pref_store.cc',
+ '<(DEPTH)/components/prefs/testing_pref_store.h',
'<(DEPTH)/chrome/browser/spellchecker/feedback.cc',
'<(DEPTH)/chrome/browser/spellchecker/feedback.h',
'<(DEPTH)/chrome/browser/spellchecker/feedback_sender.cc',
@@ -63,6 +63,7 @@
'type': 'static_library',
'dependencies': [
'chrome_resources',
+ '<(chromium_src_dir)/components/components_resources.gyp:components_resources',
'<(chromium_src_dir)/components/components_strings.gyp:components_strings',
],
'include_dirs': [
@@ -70,9 +71,6 @@
'<(chromium_src_dir)',
'<(chromium_src_dir)/skia/config',
'<(chromium_src_dir)/third_party/skia/include/core',
- # Needed to include grit-generated files in localized_error.cc:
- '<(SHARED_INTERMEDIATE_DIR)/chrome',
- '<(SHARED_INTERMEDIATE_DIR)/components/strings',
],
'sources': [
'<(DEPTH)/chrome/browser/media/desktop_media_list.h',
@@ -80,10 +78,24 @@
'<(DEPTH)/chrome/browser/media/desktop_streams_registry.h',
'<(DEPTH)/chrome/common/chrome_switches.cc',
'<(DEPTH)/chrome/common/chrome_switches.h',
- '<(DEPTH)/chrome/common/localized_error.cc',
- '<(DEPTH)/chrome/common/localized_error.h',
+ '<(DEPTH)/extensions/common/constants.cc',
+ '<(DEPTH)/extensions/common/constants.h',
+ '<(DEPTH)/extensions/common/url_pattern.cc',
+ '<(DEPTH)/extensions/common/url_pattern.h',
],
'conditions': [
+ ['OS == "win"', {
+ # crbug.com/167187 fix size_t to int truncations
+ 'msvs_disabled_warnings': [4267, ],
+ }],
+ ['enable_plugins==1', {
+ 'sources': [
+ '<(DEPTH)/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc',
+ '<(DEPTH)/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h',
+ '<(DEPTH)/chrome/renderer/pepper/pepper_shared_memory_message_filter.cc',
+ '<(DEPTH)/chrome/renderer/pepper/pepper_shared_memory_message_filter.h',
+ ],
+ }],
['enable_spellcheck==1', {
'sources': [ '<@(chrome_spellchecker_sources)' ],
'include_dirs': [
@@ -103,10 +115,6 @@
'__STDC_FORMAT_MACROS',
],
'conditions': [
- ['OS == "win"', {
- # crbug.com/167187 fix size_t to int truncations
- 'msvs_disabled_warnings': [4267, ],
- }],
[ 'OS != "mac"', {
'sources/': [
['exclude', '_mac\\.(cc|cpp|mm?)$'],
@@ -134,7 +142,7 @@
'<(DEPTH)/chrome/browser/printing/printer_query.h',
],
'dependencies': [
- '<(chromium_src_dir)/third_party/mojo/mojo_public.gyp:mojo_cpp_bindings',
+ '<(chromium_src_dir)/mojo/mojo_public.gyp:mojo_cpp_bindings',
],
'include_dirs': [
'<(chromium_src_dir)/extensions',
diff --git a/src/core/chromium_gpu_helper.cpp b/src/core/chromium_gpu_helper.cpp
index 349506dbd..d1133f5c2 100644
--- a/src/core/chromium_gpu_helper.cpp
+++ b/src/core/chromium_gpu_helper.cpp
@@ -50,13 +50,14 @@
#include "gpu/command_buffer/service/mailbox_manager.h"
#include "gpu/command_buffer/service/texture_manager.h"
-#include "content/common/gpu/gpu_channel_manager.h"
#include "content/gpu/gpu_child_thread.h"
+#include "gpu/ipc/service/gpu_channel_manager.h"
#ifdef Q_OS_QNX
#include "content/common/gpu/stream_texture_qnx.h"
#endif
+// FIXME: Try using content::GpuChildThread::current()
base::MessageLoop *gpu_message_loop()
{
return content::GpuChildThread::instance()->message_loop();
@@ -64,13 +65,13 @@ base::MessageLoop *gpu_message_loop()
gpu::SyncPointManager *sync_point_manager()
{
- content::GpuChannelManager *gpuChannelManager = content::GpuChildThread::instance()->ChannelManager();
+ gpu::GpuChannelManager *gpuChannelManager = content::GpuChildThread::instance()->ChannelManager();
return gpuChannelManager->sync_point_manager();
}
gpu::gles2::MailboxManager *mailbox_manager()
{
- content::GpuChannelManager *gpuChannelManager = content::GpuChildThread::instance()->ChannelManager();
+ gpu::GpuChannelManager *gpuChannelManager = content::GpuChildThread::instance()->ChannelManager();
return gpuChannelManager->mailbox_manager();
}
diff --git a/src/core/common/qt_messages.h b/src/core/common/qt_messages.h
index b8991a2b3..2c971aab2 100644
--- a/src/core/common/qt_messages.h
+++ b/src/core/common/qt_messages.h
@@ -16,6 +16,9 @@ IPC_STRUCT_TRAITS_BEGIN(UserScriptData)
IPC_STRUCT_TRAITS_MEMBER(injectForSubframes)
IPC_STRUCT_TRAITS_MEMBER(worldId)
IPC_STRUCT_TRAITS_MEMBER(scriptId)
+ IPC_STRUCT_TRAITS_MEMBER(globs)
+ IPC_STRUCT_TRAITS_MEMBER(excludeGlobs)
+ IPC_STRUCT_TRAITS_MEMBER(urlPatterns)
IPC_STRUCT_TRAITS_END()
diff --git a/src/core/common/user_script_data.h b/src/core/common/user_script_data.h
index 943d61798..8d98890e3 100644
--- a/src/core/common/user_script_data.h
+++ b/src/core/common/user_script_data.h
@@ -60,6 +60,9 @@ struct UserScriptData {
bool injectForSubframes;
uint worldId;
uint64_t scriptId;
+ std::vector<std::string> globs;
+ std::vector<std::string> excludeGlobs;
+ std::vector<std::string> urlPatterns;
};
QT_BEGIN_NAMESPACE
diff --git a/src/core/config/common.pri b/src/core/config/common.pri
index 5822bc589..01c942976 100644
--- a/src/core/config/common.pri
+++ b/src/core/config/common.pri
@@ -2,10 +2,10 @@
# Trigger Qt-specific build conditions.
GYP_CONFIG += use_qt=1
+# Enable printing. We enable preview because we use preview logic even if we don't support preview.
+GYP_CONFIG += enable_basic_printing=1 enable_print_preview=1
# We do not want to ship more external binary blobs, so let v8 embed its startup data.
GYP_CONFIG += v8_use_external_startup_data=0
-# Disable printing since we don't support it yet
-GYP_CONFIG += enable_basic_printing=1 enable_print_preview=0
# WebSpeech requires Google API keys and adds dependencies on speex and flac.
GYP_CONFIG += enable_web_speech=0
# We do not use or even include the extensions
diff --git a/src/core/config/embedded_linux.pri b/src/core/config/embedded_linux.pri
index 4cb7d89fb..c8f0b82de 100644
--- a/src/core/config/embedded_linux.pri
+++ b/src/core/config/embedded_linux.pri
@@ -17,7 +17,7 @@ GYP_CONFIG += \
enable_managed_users=0 \
enable_plugin_installation=0 \
enable_plugins=0 \
- enable_printing=0 \
+ enable_print_preview=0 \
enable_session_service=0 \
enable_task_manager=0 \
enable_themes=0 \
diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri
index b579e2a3f..a71d36c53 100644
--- a/src/core/config/linux.pri
+++ b/src/core/config/linux.pri
@@ -22,10 +22,14 @@ GYP_CONFIG += \
use_openssl=1
use?(nss) {
- GYP_CONFIG += use_nss_certs=1 \
+ GYP_CONFIG += \
+ use_nss_certs=1 \
+ use_nss_verifier=1 \
use_openssl_certs=0
} else {
- GYP_CONFIG += use_nss_certs=0 \
+ GYP_CONFIG += \
+ use_nss_certs=0 \
+ use_nss_verifier=0 \
use_openssl_certs=1
}
diff --git a/src/core/config/windows.pri b/src/core/config/windows.pri
index a99bc5303..ff86aea70 100644
--- a/src/core/config/windows.pri
+++ b/src/core/config/windows.pri
@@ -56,9 +56,7 @@ msvc:contains(QT_ARCH, "i386"):!usingMSVC32BitCrossCompiler() {
}
msvc {
- equals(MSVC_VER, 12.0) {
- MSVS_VERSION = 2013
- } else:equals(MSVC_VER, 14.0) {
+ equals(MSVC_VER, 14.0) {
MSVS_VERSION = 2015
} else {
fatal("Visual Studio compiler version \"$$MSVC_VER\" is not supported by Qt WebEngine")
@@ -66,7 +64,7 @@ msvc {
GYP_ARGS += "-G msvs_version=$$MSVS_VERSION"
- isBuildingOnWin32(): GYP_ARGS += "-D windows_sdk_path=\"C:/Program Files/Windows Kits/8.1\""
+ isBuildingOnWin32(): GYP_ARGS += "-D windows_sdk_path=\"C:/Program Files/Windows Kits/10\""
} else {
fatal("Qt WebEngine for Windows can only be built with the Microsoft Visual Studio C++ compiler")
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index f5f490ccf..0c3acd37b 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -85,6 +85,11 @@
#include "web_engine_context.h"
#include "web_engine_library_info.h"
+#if defined(Q_OS_LINUX)
+#include "global_descriptors_qt.h"
+#include "ui/base/resource/resource_bundle.h"
+#endif
+
#if defined(ENABLE_PLUGINS)
#include "content/public/browser/browser_ppapi_host.h"
#include "ppapi/host/ppapi_host.h"
@@ -244,8 +249,9 @@ public:
int PreCreateThreads() Q_DECL_OVERRIDE
{
base::ThreadRestrictions::SetIOAllowed(true);
- // Like ChromeBrowserMainExtraPartsAura::PreCreateThreads does.
- gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, new DesktopScreenQt);
+ // Like ChromeBrowserMainExtraPartsViews::PreCreateThreads does.
+ gfx::Screen::SetScreenInstance(new DesktopScreenQt);
+
return 0;
}
@@ -351,7 +357,7 @@ ContentBrowserClientQt *ContentBrowserClientQt::Get()
content::BrowserMainParts *ContentBrowserClientQt::CreateBrowserMainParts(const content::MainFunctionParams&)
{
- m_browserMainParts = new BrowserMainPartsQt;
+ m_browserMainParts = new BrowserMainPartsQt();
return m_browserMainParts;
}
@@ -401,11 +407,6 @@ content::AccessTokenStore *ContentBrowserClientQt::CreateAccessTokenStore()
return new AccessTokenStoreQt;
}
-net::URLRequestContextGetter* ContentBrowserClientQt::CreateRequestContext(content::BrowserContext* browser_context, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors)
-{
- return static_cast<BrowserContextQt*>(browser_context)->CreateRequestContext(protocol_handlers, std::move(request_interceptors));
-}
-
content::QuotaPermissionContext *ContentBrowserClientQt::CreateQuotaPermissionContext()
{
return new QuotaPermissionContextQt;
@@ -461,6 +462,22 @@ void ContentBrowserClientQt::AppendExtraCommandLineSwitches(base::CommandLine* c
command_line->AppendSwitchASCII(switches::kLang, GetApplicationLocale());
}
+#if defined(Q_OS_LINUX)
+void ContentBrowserClientQt::GetAdditionalMappedFilesForChildProcess(const base::CommandLine& command_line, int child_process_id, content::FileDescriptorInfo* mappings)
+{
+ const std::string &locale = GetApplicationLocale();
+ const base::FilePath &locale_file_path = ui::ResourceBundle::GetSharedInstance().GetLocaleFilePath(locale, true);
+ if (locale_file_path.empty())
+ return;
+
+ // Open pak file of the current locale in the Browser process and pass its file descriptor to the sandboxed
+ // Renderer Process. FileDescriptorInfo is responsible for closing the file descriptor.
+ int flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
+ base::File locale_file = base::File(locale_file_path, flags);
+ mappings->Transfer(kWebEngineLocale, base::ScopedFD(locale_file.TakePlatformFile()));
+}
+#endif
+
#if defined(ENABLE_PLUGINS)
void ContentBrowserClientQt::DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) {
browser_host->GetPpapiHost()->AddHostFactoryFilter(
diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h
index 1878e3d27..098631476 100644
--- a/src/core/content_browser_client_qt.h
+++ b/src/core/content_browser_client_qt.h
@@ -104,12 +104,15 @@ public:
content::CertificateRequestResultType* result) Q_DECL_OVERRIDE;
content::LocationProvider* OverrideSystemLocationProvider() Q_DECL_OVERRIDE;
content::DevToolsManagerDelegate *GetDevToolsManagerDelegate() Q_DECL_OVERRIDE;
- virtual net::URLRequestContextGetter *CreateRequestContext(content::BrowserContext *browser_context, content::ProtocolHandlerMap *protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptorss) Q_DECL_OVERRIDE;
virtual std::string GetApplicationLocale() Q_DECL_OVERRIDE;
std::string GetAcceptLangs(content::BrowserContext* context) Q_DECL_OVERRIDE;
virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line, int child_process_id) Q_DECL_OVERRIDE;
+#if defined(Q_OS_LINUX)
+ virtual void GetAdditionalMappedFilesForChildProcess(const base::CommandLine& command_line, int child_process_id, content::FileDescriptorInfo* mappings) Q_DECL_OVERRIDE;
+#endif
+
#if defined(ENABLE_PLUGINS)
virtual void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) Q_DECL_OVERRIDE;
#endif
diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp
index 0418873be..49c018b23 100644
--- a/src/core/content_client_qt.cpp
+++ b/src/core/content_client_qt.cpp
@@ -247,11 +247,9 @@ void AddPepperWidevine(std::vector<content::PepperPluginInfo>* plugins)
// Add the supported codecs as if they came from the component manifest.
std::vector<std::string> codecs;
- codecs.push_back(kCdmSupportedCodecVorbis);
codecs.push_back(kCdmSupportedCodecVp8);
codecs.push_back(kCdmSupportedCodecVp9);
#if defined(USE_PROPRIETARY_CODECS)
- codecs.push_back(kCdmSupportedCodecAac);
codecs.push_back(kCdmSupportedCodecAvc1);
#endif // defined(USE_PROPRIETARY_CODECS)
std::string codec_string =
diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp
index 8bd07ef75..095e54caa 100644
--- a/src/core/content_main_delegate_qt.cpp
+++ b/src/core/content_main_delegate_qt.cpp
@@ -59,7 +59,9 @@
#include "base/cpu.h"
#endif
-#include <QLocale>
+#if defined(OS_LINUX)
+#include "ui/base/ui_base_switches.h"
+#endif
namespace QtWebEngineCore {
@@ -110,6 +112,12 @@ void ContentMainDelegateQt::PreSandboxStartup()
logging::LoggingSettings settings;
settings.logging_dest = DetermineLogMode(*parsedCommandLine);
logging::InitLogging(settings);
+ // view the logs with process/thread IDs and timestamps
+ logging::SetLogItems(true, //enable_process_id
+ true, //enable_thread_id
+ true, //enable_timestamp
+ false //enable_tickcount
+ );
if (logging::GetMinLogLevel() >= logging::LOG_INFO) {
if (parsedCommandLine->HasSwitch(switches::kLoggingLevel)) {
@@ -129,6 +137,15 @@ content::ContentBrowserClient *ContentMainDelegateQt::CreateContentBrowserClient
content::ContentRendererClient *ContentMainDelegateQt::CreateContentRendererClient()
{
+#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);
+ }
+#endif
+
return new ContentRendererClientQt;
}
diff --git a/src/core/cookie_monster_delegate_qt.cpp b/src/core/cookie_monster_delegate_qt.cpp
index 5a4c8e707..4e52f562a 100644
--- a/src/core/cookie_monster_delegate_qt.cpp
+++ b/src/core/cookie_monster_delegate_qt.cpp
@@ -40,6 +40,7 @@
#include "cookie_monster_delegate_qt.h"
#include "base/bind.h"
+#include "base/memory/ptr_util.h"
#include "content/public/browser/browser_thread.h"
#include "net/cookies/cookie_util.h"
@@ -55,11 +56,14 @@ static GURL sourceUrlForCookie(const QNetworkCookie &cookie) {
}
static void onSetCookieCallback(QWebEngineCookieStorePrivate *client, qint64 callbackId, bool success) {
- client->onSetCallbackResult(callbackId, success);
+
+ content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&QWebEngineCookieStorePrivate::onSetCallbackResult, base::Unretained(client), callbackId, success));
}
static void onDeleteCookiesCallback(QWebEngineCookieStorePrivate *client, qint64 callbackId, int numCookies) {
- client->onDeleteCallbackResult(callbackId, numCookies);
+ content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&QWebEngineCookieStorePrivate::onDeleteCallbackResult, base::Unretained(client), callbackId, numCookies));
}
static void onGetAllCookiesCallback(QWebEngineCookieStorePrivate *client, qint64 callbackId, const net::CookieList& cookies) {
@@ -67,14 +71,14 @@ static void onGetAllCookiesCallback(QWebEngineCookieStorePrivate *client, qint64
for (auto&& cookie: cookies)
rawCookies += toQt(cookie).toRawForm() % QByteArrayLiteral("\n");
- client->onGetAllCallbackResult(callbackId, rawCookies);
+ content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&QWebEngineCookieStorePrivate::onGetAllCallbackResult, base::Unretained(client), callbackId, rawCookies));
}
CookieMonsterDelegateQt::CookieMonsterDelegateQt()
: m_client(0)
- , m_cookieMonster(0)
+ , m_cookieMonster(nullptr)
{
-
}
CookieMonsterDelegateQt::~CookieMonsterDelegateQt()
@@ -84,13 +88,21 @@ CookieMonsterDelegateQt::~CookieMonsterDelegateQt()
bool CookieMonsterDelegateQt::hasCookieMonster()
{
- return m_cookieMonster.get();
+ return m_cookieMonster;
}
void CookieMonsterDelegateQt::getAllCookies(quint64 callbackId)
{
net::CookieMonster::GetCookieListCallback callback = base::Bind(&onGetAllCookiesCallback, m_client->d_func(), callbackId);
- m_cookieMonster->GetAllCookiesAsync(callback);
+
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&CookieMonsterDelegateQt::GetAllCookiesOnIOThread, this, callback));
+}
+
+void CookieMonsterDelegateQt::GetAllCookiesOnIOThread(const net::CookieMonster::GetCookieListCallback& callback)
+{
+ if (m_cookieMonster)
+ m_cookieMonster->GetAllCookiesAsync(callback);
}
void CookieMonsterDelegateQt::setCookie(quint64 callbackId, const QNetworkCookie &cookie, const QUrl &origin)
@@ -102,12 +114,22 @@ void CookieMonsterDelegateQt::setCookie(quint64 callbackId, const QNetworkCookie
if (callbackId != CallbackDirectory::NoCallbackId)
callback = base::Bind(&onSetCookieCallback, m_client->d_func(), callbackId);
+ GURL gurl = origin.isEmpty() ? sourceUrlForCookie(cookie) : toGurl(origin);
+
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&CookieMonsterDelegateQt::SetCookieOnIOThread, this,
+ gurl, cookie.toRawForm().toStdString(), callback));
+}
+
+void CookieMonsterDelegateQt::SetCookieOnIOThread(
+ const GURL& url, const std::string& cookie_line,
+ const net::CookieMonster::SetCookiesCallback& callback)
+{
net::CookieOptions options;
options.set_include_httponly();
- GURL gurl = origin.isEmpty() ? sourceUrlForCookie(cookie) : toGurl(origin);
-
- m_cookieMonster->SetCookieWithOptionsAsync(gurl, cookie.toRawForm().toStdString(), options, callback);
+ if (m_cookieMonster)
+ m_cookieMonster->SetCookieWithOptionsAsync(url, cookie_line, options, callback);
}
void CookieMonsterDelegateQt::deleteCookie(const QNetworkCookie &cookie, const QUrl &origin)
@@ -117,7 +139,15 @@ void CookieMonsterDelegateQt::deleteCookie(const QNetworkCookie &cookie, const Q
GURL gurl = origin.isEmpty() ? sourceUrlForCookie(cookie) : toGurl(origin);
- m_cookieMonster->DeleteCookieAsync(gurl, cookie.name().toStdString(), base::Closure());
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&CookieMonsterDelegateQt::DeleteCookieOnIOThread, this,
+ gurl, cookie.name().toStdString()));
+}
+
+void CookieMonsterDelegateQt::DeleteCookieOnIOThread(const GURL& url, const std::string& cookie_name)
+{
+ if (m_cookieMonster)
+ m_cookieMonster->DeleteCookieAsync(url, cookie_name, base::Closure());
}
void CookieMonsterDelegateQt::deleteSessionCookies(quint64 callbackId)
@@ -126,7 +156,14 @@ void CookieMonsterDelegateQt::deleteSessionCookies(quint64 callbackId)
Q_ASSERT(m_client);
net::CookieMonster::DeleteCallback callback = base::Bind(&onDeleteCookiesCallback, m_client->d_func(), callbackId);
- m_cookieMonster->DeleteSessionCookiesAsync(callback);
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&CookieMonsterDelegateQt::DeleteSessionCookiesOnIOThread, this, callback));
+}
+
+void CookieMonsterDelegateQt::DeleteSessionCookiesOnIOThread(const net::CookieMonster::DeleteCallback& callback)
+{
+ if (m_cookieMonster)
+ m_cookieMonster->DeleteSessionCookiesAsync(callback);
}
void CookieMonsterDelegateQt::deleteAllCookies(quint64 callbackId)
@@ -135,7 +172,14 @@ void CookieMonsterDelegateQt::deleteAllCookies(quint64 callbackId)
Q_ASSERT(m_client);
net::CookieMonster::DeleteCallback callback = base::Bind(&onDeleteCookiesCallback, m_client->d_func(), callbackId);
- m_cookieMonster->DeleteAllAsync(callback);
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&CookieMonsterDelegateQt::DeleteAllOnIOThread, this, callback));
+}
+
+void CookieMonsterDelegateQt::DeleteAllOnIOThread(const net::CookieMonster::DeleteCallback& callback)
+{
+ if (m_cookieMonster)
+ m_cookieMonster->DeleteAllAsync(callback);
}
void CookieMonsterDelegateQt::setCookieMonster(net::CookieMonster* monster)
diff --git a/src/core/cookie_monster_delegate_qt.h b/src/core/cookie_monster_delegate_qt.h
index 2ff5eeaa6..f47dc86df 100644
--- a/src/core/cookie_monster_delegate_qt.h
+++ b/src/core/cookie_monster_delegate_qt.h
@@ -66,7 +66,7 @@ static const char* const kCookieableSchemes[] =
class QWEBENGINE_EXPORT CookieMonsterDelegateQt: public net::CookieMonsterDelegate {
QPointer<QWebEngineCookieStore> m_client;
- scoped_refptr<net::CookieMonster> m_cookieMonster;
+ net::CookieMonster *m_cookieMonster;
public:
CookieMonsterDelegateQt();
~CookieMonsterDelegateQt();
@@ -84,6 +84,13 @@ public:
bool canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url);
void OnCookieChanged(const net::CanonicalCookie& cookie, bool removed, ChangeCause cause) override;
+
+private:
+ void GetAllCookiesOnIOThread(const net::CookieMonster::GetCookieListCallback& callback);
+ void SetCookieOnIOThread(const GURL& url, const std::string& cookie_line, const net::CookieMonster::SetCookiesCallback& callback);
+ void DeleteCookieOnIOThread(const GURL& url, const std::string& cookie_name);
+ void DeleteSessionCookiesOnIOThread(const net::CookieMonster::DeleteCallback& callback);
+ void DeleteAllOnIOThread(const net::CookieMonster::DeleteCallback& callback);
};
}
diff --git a/src/core/core_gyp_generator.pro b/src/core/core_gyp_generator.pro
index 7351b108c..70644e5f6 100644
--- a/src/core/core_gyp_generator.pro
+++ b/src/core/core_gyp_generator.pro
@@ -75,7 +75,6 @@ SOURCES = \
render_widget_host_view_qt.cpp \
renderer/content_renderer_client_qt.cpp \
renderer/pepper/pepper_flash_browser_host_qt.cpp \
- renderer/pepper/pepper_flash_clipboard_message_filter_qt.cpp \
renderer/pepper/pepper_flash_renderer_host_qt.cpp \
renderer/pepper/pepper_host_factory_qt.cpp \
renderer/pepper/pepper_isolated_file_system_message_filter.cpp \
@@ -143,6 +142,7 @@ HEADERS = \
file_picker_controller.h \
gl_context_qt.h \
gl_surface_qt.h \
+ global_descriptors_qt.h \
javascript_dialog_controller_p.h \
javascript_dialog_controller.h \
javascript_dialog_manager_qt.h \
@@ -158,7 +158,6 @@ HEADERS = \
render_widget_host_view_qt_delegate.h \
renderer/content_renderer_client_qt.h \
renderer/pepper/pepper_flash_browser_host_qt.h \
- renderer/pepper/pepper_flash_clipboard_message_filter_qt.h \
renderer/pepper/pepper_flash_renderer_host_qt.h \
renderer/pepper/pepper_host_factory_qt.h \
renderer/pepper/pepper_isolated_file_system_message_filter.h \
diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp
index b181f04e3..0c2b3cdea 100644
--- a/src/core/delegated_frame_node.cpp
+++ b/src/core/delegated_frame_node.cpp
@@ -73,12 +73,19 @@
#include <QOpenGLContext>
#include <QOpenGLFunctions>
-#include <QSGSimpleRectNode>
-#include <QSGSimpleTextureNode>
+#include <QSGFlatColorMaterial>
#include <QSGTexture>
#include <QtGui/QOffscreenSurface>
#include <private/qsgadaptationlayer_p.h>
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
+#include <QSGImageNode>
+#include <QSGRectangleNode>
+#else
+#include <QSGSimpleRectNode>
+#include <QSGSimpleTextureNode>
+#endif
+
#if !defined(QT_NO_EGL)
#include <EGL/egl.h>
#include <EGL/eglext.h>
@@ -538,8 +545,8 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
if (!layer)
continue;
- // Only QSGImageNode currently supports QSGLayer textures.
- QSGImageNode *imageNode = apiDelegate->createImageNode();
+ // Only QSGInternalImageNode currently supports QSGLayer textures.
+ QSGInternalImageNode *imageNode = apiDelegate->createImageNode();
imageNode->setTargetRect(toQt(quad->rect));
imageNode->setInnerTargetRect(toQt(quad->rect));
imageNode->setTexture(layer);
@@ -550,8 +557,8 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
const cc::TextureDrawQuad *tquad = cc::TextureDrawQuad::MaterialCast(quad);
ResourceHolder *resource = findAndHoldResource(tquad->resource_id(), resourceCandidates);
- QSGSimpleTextureNode *textureNode = new QSGSimpleTextureNode;
- textureNode->setTextureCoordinatesTransform(tquad->y_flipped ? QSGSimpleTextureNode::MirrorVertically : QSGSimpleTextureNode::NoTransform);
+ QSGTextureNode *textureNode = apiDelegate->createTextureNode();
+ textureNode->setTextureCoordinatesTransform(tquad->y_flipped ? QSGTextureNode::MirrorVertically : QSGTextureNode::NoTransform);
textureNode->setRect(toQt(quad->rect));
textureNode->setFiltering(resource->transferableResource().filter == GL_LINEAR ? QSGTexture::Linear : QSGTexture::Nearest);
textureNode->setTexture(initAndHoldTexture(resource, quad->ShouldDrawWithBlending(), apiDelegate));
@@ -559,7 +566,7 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
break;
} case cc::DrawQuad::SOLID_COLOR: {
const cc::SolidColorDrawQuad *scquad = cc::SolidColorDrawQuad::MaterialCast(quad);
- QSGSimpleRectNode *rectangleNode = new QSGSimpleRectNode;
+ QSGRectangleNode *rectangleNode = apiDelegate->createRectangleNode();
// Qt only supports MSAA and this flag shouldn't be needed.
// If we ever want to use QSGRectangleNode::setAntialiasing for this we should
@@ -598,7 +605,7 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
const cc::TileDrawQuad *tquad = cc::TileDrawQuad::MaterialCast(quad);
ResourceHolder *resource = findAndHoldResource(tquad->resource_id(), resourceCandidates);
- QSGSimpleTextureNode *textureNode = new QSGSimpleTextureNode;
+ QSGTextureNode *textureNode = apiDelegate->createTextureNode();
textureNode->setRect(toQt(quad->rect));
textureNode->setSourceRect(toQt(tquad->tex_coord_rect));
textureNode->setFiltering(resource->transferableResource().filter == GL_LINEAR ? QSGTexture::Linear : QSGTexture::Nearest);
@@ -620,8 +627,10 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
initAndHoldTexture(uResource, quad->ShouldDrawWithBlending()),
initAndHoldTexture(vResource, quad->ShouldDrawWithBlending()),
aResource ? initAndHoldTexture(aResource, quad->ShouldDrawWithBlending()) : 0,
- toQt(vquad->ya_tex_coord_rect), toQt(vquad->uv_tex_coord_rect),
- toQt(vquad->ya_tex_size), toQt(vquad->uv_tex_size), toQt(vquad->color_space));
+ toQt(vquad->ya_tex_coord_rect), toQt(vquad->uv_tex_coord_rect),
+ toQt(vquad->ya_tex_size), toQt(vquad->uv_tex_size),
+ toQt(vquad->color_space),
+ vquad->resource_multiplier, vquad->resource_offset);
videoNode->setRect(toQt(quad->rect));
currentLayerChain->appendChildNode(videoNode);
break;
diff --git a/src/core/dev_tools_http_handler_delegate_qt.cpp b/src/core/dev_tools_http_handler_delegate_qt.cpp
index f3ffcc86d..0e127d414 100644
--- a/src/core/dev_tools_http_handler_delegate_qt.cpp
+++ b/src/core/dev_tools_http_handler_delegate_qt.cpp
@@ -50,6 +50,7 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "components/devtools_discovery/devtools_discovery_manager.h"
@@ -178,7 +179,7 @@ DevToolsTargetDescriptor::List DevToolsDiscoveryProviderQt::GetDescriptors()
namespace QtWebEngineCore {
-scoped_ptr<DevToolsHttpHandler> createDevToolsHttpHandler()
+std::unique_ptr<DevToolsHttpHandler> createDevToolsHttpHandler()
{
DevToolsHttpHandlerDelegateQt *delegate = new DevToolsHttpHandlerDelegateQt();
if (!delegate->isValid()) {
@@ -187,9 +188,9 @@ scoped_ptr<DevToolsHttpHandler> createDevToolsHttpHandler()
}
scoped_ptr<DevToolsHttpHandler::ServerSocketFactory> factory(new TCPServerSocketFactory(delegate->bindAddress().toStdString(), delegate->port(), 1));
// Ownership of the delegate is taken over the devtools http handler.
- scoped_ptr<DevToolsHttpHandler> handler(new DevToolsHttpHandler(std::move(factory), std::string(), delegate, base::FilePath(), base::FilePath(), std::string(), std::string()));
+ std::unique_ptr<DevToolsHttpHandler> handler(new DevToolsHttpHandler(std::move(factory), std::string(), delegate, base::FilePath(), base::FilePath(), std::string(), std::string()));
DevToolsDiscoveryManager::GetInstance()->AddProvider(scoped_ptr<DevToolsDiscoveryManager::Provider>(new DevToolsDiscoveryProviderQt()));
- return handler;
+ return std::move(handler);
}
DevToolsHttpHandlerDelegateQt::DevToolsHttpHandlerDelegateQt()
diff --git a/src/core/dev_tools_http_handler_delegate_qt.h b/src/core/dev_tools_http_handler_delegate_qt.h
index 96a34a45a..6512146a5 100644
--- a/src/core/dev_tools_http_handler_delegate_qt.h
+++ b/src/core/dev_tools_http_handler_delegate_qt.h
@@ -56,7 +56,7 @@ class DevToolsHttpHandler;
namespace QtWebEngineCore {
-scoped_ptr<devtools_http_handler::DevToolsHttpHandler> createDevToolsHttpHandler();
+std::unique_ptr<devtools_http_handler::DevToolsHttpHandler> createDevToolsHttpHandler();
class DevToolsHttpHandlerDelegateQt : public devtools_http_handler::DevToolsHttpHandlerDelegate {
public:
diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp
index 857af2e18..2cbfd121b 100644
--- a/src/core/download_manager_delegate_qt.cpp
+++ b/src/core/download_manager_delegate_qt.cpp
@@ -56,6 +56,7 @@
#include "browser_context_adapter_client.h"
#include "browser_context_qt.h"
#include "type_conversion.h"
+#include "web_contents_delegate_qt.h"
#include "qtwebenginecoreglobal.h"
namespace QtWebEngineCore {
@@ -74,6 +75,7 @@ DownloadManagerDelegateQt::DownloadManagerDelegateQt(BrowserContextAdapter *cont
: m_contextAdapter(contextAdapter)
, m_currentId(0)
, m_weakPtrFactory(this)
+ , m_downloadType(BrowserContextAdapterClient::Attachment)
{
Q_ASSERT(m_contextAdapter);
}
@@ -115,6 +117,11 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* i
QString suggestedFilename = toQt(item->GetSuggestedFilename());
QString mimeTypeString = toQt(item->GetMimeType());
+ bool isAttachment = net::HttpContentDisposition(item->GetContentDisposition(), std::string()).is_attachment();
+
+ if (!isAttachment || !BrowserContextAdapterClient::UserRequested)
+ m_downloadType = BrowserContextAdapterClient::DownloadAttribute;
+
if (suggestedFilename.isEmpty())
suggestedFilename = toQt(net::HttpContentDisposition(item->GetContentDisposition(), std::string()).filename());
@@ -157,7 +164,8 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* i
mimeTypeString,
suggestedFilePath,
BrowserContextAdapterClient::UnknownSavePageFormat,
- false /* accepted */
+ false /* accepted */,
+ m_downloadType
};
Q_FOREACH (BrowserContextAdapterClient *client, clients) {
@@ -211,12 +219,30 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content
if (clients.isEmpty())
return;
- const QString suggestedFileName
- = QFileInfo(toQt(suggested_path.AsUTF8Unsafe())).completeBaseName()
- + QStringLiteral(".mhtml");
- const QDir defaultDownloadDirectory
- = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
- const QString suggestedFilePath = defaultDownloadDirectory.absoluteFilePath(suggestedFileName);
+ WebContentsDelegateQt *contentsDelegate = static_cast<WebContentsDelegateQt *>(
+ web_contents->GetDelegate());
+ const SavePageInfo &spi = contentsDelegate->savePageInfo();
+
+ bool acceptedByDefault = false;
+ QString suggestedFilePath = spi.requestedFilePath;
+ if (suggestedFilePath.isEmpty()) {
+ suggestedFilePath = QFileInfo(toQt(suggested_path.AsUTF8Unsafe())).completeBaseName()
+ + QStringLiteral(".mhtml");
+ } else {
+ acceptedByDefault = true;
+ }
+ if (QFileInfo(suggestedFilePath).isRelative()) {
+ const QDir downloadDir(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
+ suggestedFilePath = downloadDir.absoluteFilePath(suggestedFilePath);
+ }
+
+ BrowserContextAdapterClient::SavePageFormat suggestedSaveFormat
+ = static_cast<BrowserContextAdapterClient::SavePageFormat>(spi.requestedFormat);
+ if (suggestedSaveFormat == BrowserContextAdapterClient::UnknownSavePageFormat)
+ suggestedSaveFormat = BrowserContextAdapterClient::MimeHtmlSaveFormat;
+
+ // Clear the delegate's SavePageInfo. It's only valid for the page currently being saved.
+ contentsDelegate->setSavePageInfo(SavePageInfo());
BrowserContextAdapterClient::DownloadItemInfo info = {
m_currentId + 1,
@@ -226,8 +252,9 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content
0, /* receivedBytes */
QStringLiteral("application/x-mimearchive"),
suggestedFilePath,
- BrowserContextAdapterClient::MimeHtmlSaveFormat,
- false /* accepted */
+ suggestedSaveFormat,
+ acceptedByDefault,
+ BrowserContextAdapterClient::SavePage
};
Q_FOREACH (BrowserContextAdapterClient *client, clients) {
@@ -263,7 +290,8 @@ void DownloadManagerDelegateQt::OnDownloadUpdated(content::DownloadItem *downloa
toQt(download->GetMimeType()),
QString(),
BrowserContextAdapterClient::UnknownSavePageFormat,
- true /* accepted */
+ true /* accepted */,
+ m_downloadType
};
Q_FOREACH (BrowserContextAdapterClient *client, clients) {
diff --git a/src/core/download_manager_delegate_qt.h b/src/core/download_manager_delegate_qt.h
index e724b4e23..e603724e9 100644
--- a/src/core/download_manager_delegate_qt.h
+++ b/src/core/download_manager_delegate_qt.h
@@ -82,9 +82,10 @@ public:
bool can_save_as_complete,
const content::SavePackagePathPickedCallback &callback) Q_DECL_OVERRIDE;
-
void cancelDownload(quint32 downloadId);
+ void setDownloadType(int downloadType) { m_downloadType = downloadType; }
+
// Inherited from content::DownloadItem::Observer
void OnDownloadUpdated(content::DownloadItem *download) Q_DECL_OVERRIDE;
void OnDownloadDestroyed(content::DownloadItem *download) Q_DECL_OVERRIDE;
@@ -96,6 +97,7 @@ private:
uint64_t m_currentId;
base::WeakPtrFactory<DownloadManagerDelegateQt> m_weakPtrFactory;
+ int m_downloadType;
friend class DownloadManagerDelegateInstance;
DISALLOW_COPY_AND_ASSIGN(DownloadManagerDelegateQt);
diff --git a/src/core/file_picker_controller.cpp b/src/core/file_picker_controller.cpp
index 6c3889907..7eb812347 100644
--- a/src/core/file_picker_controller.cpp
+++ b/src/core/file_picker_controller.cpp
@@ -114,17 +114,17 @@ void FilePickerController::filesSelectedInChooser(const QStringList &filesList,
rvh->FilesSelectedInChooser(toVector<content::FileChooserFileInfo>(files), static_cast<content::FileChooserParams::Mode>(this->m_mode));
}
-QStringList FilePickerController::acceptedMimeTypes()
+QStringList FilePickerController::acceptedMimeTypes() const
{
return m_acceptedMimeTypes;
}
-FilePickerController::FileChooserMode FilePickerController::mode()
+FilePickerController::FileChooserMode FilePickerController::mode() const
{
return m_mode;
}
-QString FilePickerController::defaultFileName()
+QString FilePickerController::defaultFileName() const
{
return m_defaultFileName;
}
diff --git a/src/core/file_picker_controller.h b/src/core/file_picker_controller.h
index 6edee7713..14e8de42d 100644
--- a/src/core/file_picker_controller.h
+++ b/src/core/file_picker_controller.h
@@ -61,10 +61,9 @@ public:
};
FilePickerController(FileChooserMode mode, content::WebContents *contents, const QString &defaultFileName, const QStringList &acceptedMimeTypes, QObject * = 0);
- QStringList acceptedMimeTypes();
- QString defaultFileName();
- FileChooserMode mode();
- void filesSelectedInChooser(const QStringList &filesList, content::WebContents *contents);
+ QStringList acceptedMimeTypes() const;
+ QString defaultFileName() const;
+ FileChooserMode mode() const;
public Q_SLOTS:
void accepted(const QStringList &files);
@@ -72,6 +71,7 @@ public Q_SLOTS:
void rejected();
private:
+ void filesSelectedInChooser(const QStringList &filesList, content::WebContents *contents);
QString m_defaultFileName;
QStringList m_acceptedMimeTypes;
content::WebContents *m_contents;
diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp
index f499d853e..3982b9bd1 100644
--- a/src/core/gl_surface_qt.cpp
+++ b/src/core/gl_surface_qt.cpp
@@ -51,7 +51,7 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
-#include "content/common/gpu/image_transport_surface.h"
+#include "gpu/ipc/service/image_transport_surface.h"
#include "ui/gl/egl_util.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h"
@@ -310,7 +310,7 @@ bool GLSurfaceQtWGL::Initialize()
{
m_surfaceBuffer = new PbufferGLSurfaceWGL(m_size);
- return m_surfaceBuffer->Initialize();
+ return m_surfaceBuffer->Initialize(gfx::GLSurface::SURFACE_DEFAULT);
}
void GLSurfaceQtWGL::Destroy()
@@ -635,10 +635,11 @@ std::string DriverEGL::GetPlatformExtensions()
} // namespace gfx
-namespace content {
+namespace gpu {
class GpuCommandBufferStub;
class GpuChannelManager;
-scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface(GpuChannelManager*, GpuCommandBufferStub*, const gfx::GLSurfaceHandle&)
+scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface(GpuChannelManager*, GpuCommandBufferStub*,
+ SurfaceHandle, gfx::GLSurface::Format)
{
QT_NOT_USED
return scoped_refptr<gfx::GLSurface>();
diff --git a/src/core/global_descriptors_qt.h b/src/core/global_descriptors_qt.h
new file mode 100644
index 000000000..e9d490a2e
--- /dev/null
+++ b/src/core/global_descriptors_qt.h
@@ -0,0 +1,10 @@
+#ifndef GLOBAL_DESCRIPTORS_QT_H
+#define GLOBAL_DESCRIPTORS_QT_H
+
+#include "content/public/common/content_descriptors.h"
+
+enum {
+ kWebEngineLocale = kContentIPCDescriptorMax + 1,
+};
+
+#endif // GLOBAL_DESCRIPTORS_QT_H
diff --git a/src/core/javascript_dialog_manager_qt.cpp b/src/core/javascript_dialog_manager_qt.cpp
index 80a28fb56..2844dba5d 100644
--- a/src/core/javascript_dialog_manager_qt.cpp
+++ b/src/core/javascript_dialog_manager_qt.cpp
@@ -55,10 +55,8 @@ JavaScriptDialogManagerQt *JavaScriptDialogManagerQt::GetInstance()
return base::Singleton<JavaScriptDialogManagerQt>::get();
}
-void JavaScriptDialogManagerQt::RunJavaScriptDialog(content::WebContents *webContents, const GURL &originUrl, const std::string &acceptLang, content::JavaScriptMessageType javascriptMessageType, const base::string16 &messageText, const base::string16 &defaultPromptText, const content::JavaScriptDialogManager::DialogClosedCallback &callback, bool *didSuppressMessage)
+void JavaScriptDialogManagerQt::RunJavaScriptDialog(content::WebContents *webContents, const GURL &originUrl, content::JavaScriptMessageType javascriptMessageType, const base::string16 &messageText, const base::string16 &defaultPromptText, const content::JavaScriptDialogManager::DialogClosedCallback &callback, bool *didSuppressMessage)
{
- Q_UNUSED(acceptLang);
-
WebContentsAdapterClient *client = WebContentsViewQt::from(static_cast<content::WebContentsImpl*>(webContents)->GetView())->client();
if (!client) {
if (didSuppressMessage)
@@ -70,10 +68,10 @@ void JavaScriptDialogManagerQt::RunJavaScriptDialog(content::WebContents *webCon
runDialogForContents(webContents, dialogType, toQt(messageText).toHtmlEscaped(), toQt(defaultPromptText).toHtmlEscaped(), toQt(originUrl.GetOrigin()), callback);
}
-void JavaScriptDialogManagerQt::RunBeforeUnloadDialog(content::WebContents *webContents, const base::string16 &messageText,
- bool isReload, const content::JavaScriptDialogManager::DialogClosedCallback &callback) {
+void JavaScriptDialogManagerQt::RunBeforeUnloadDialog(content::WebContents *webContents, bool isReload,
+ const content::JavaScriptDialogManager::DialogClosedCallback &callback) {
Q_UNUSED(isReload);
- runDialogForContents(webContents, WebContentsAdapterClient::UnloadDialog, toQt(messageText).toHtmlEscaped(), QString() , QUrl(), callback);
+ runDialogForContents(webContents, WebContentsAdapterClient::UnloadDialog, QString()/*toQt(messageText).toHtmlEscaped()*/, QString() , QUrl(), callback);
}
bool JavaScriptDialogManagerQt::HandleJavaScriptDialog(content::WebContents *contents, bool accept, const base::string16 *promptOverride)
diff --git a/src/core/javascript_dialog_manager_qt.h b/src/core/javascript_dialog_manager_qt.h
index aea5a5ec3..8ed86c994 100644
--- a/src/core/javascript_dialog_manager_qt.h
+++ b/src/core/javascript_dialog_manager_qt.h
@@ -61,12 +61,12 @@ public:
// For use with the Singleton helper class from chromium
static JavaScriptDialogManagerQt *GetInstance();
- virtual void RunJavaScriptDialog(content::WebContents *, const GURL &, const std::string &acceptLang, content::JavaScriptMessageType javascriptMessageType,
- const base::string16 &messageText, const base::string16 &defaultPromptText,
- const content::JavaScriptDialogManager::DialogClosedCallback &callback, bool *didSuppressMessage) Q_DECL_OVERRIDE;
+ virtual void RunJavaScriptDialog(content::WebContents *, const GURL &, content::JavaScriptMessageType javascriptMessageType,
+ const base::string16 &messageText, const base::string16 &defaultPromptText,
+ const content::JavaScriptDialogManager::DialogClosedCallback &callback, bool *didSuppressMessage) Q_DECL_OVERRIDE;
- virtual void RunBeforeUnloadDialog(content::WebContents *, const base::string16 &messageText, bool isReload,
- const content::JavaScriptDialogManager::DialogClosedCallback &callback) Q_DECL_OVERRIDE;
+ virtual void RunBeforeUnloadDialog(content::WebContents *, bool isReload,
+ const content::JavaScriptDialogManager::DialogClosedCallback &callback) Q_DECL_OVERRIDE;
virtual bool HandleJavaScriptDialog(content::WebContents *, bool accept, const base::string16 *promptOverride) Q_DECL_OVERRIDE;
virtual void CancelActiveAndPendingDialogs(content::WebContents *contents) Q_DECL_OVERRIDE { takeDialogForContents(contents); }
virtual void ResetDialogState(content::WebContents *contents) Q_DECL_OVERRIDE { takeDialogForContents(contents); }
diff --git a/src/core/network_delegate_qt.cpp b/src/core/network_delegate_qt.cpp
index ff0e8320c..c779a4abe 100644
--- a/src/core/network_delegate_qt.cpp
+++ b/src/core/network_delegate_qt.cpp
@@ -230,14 +230,6 @@ bool NetworkDelegateQt::OnCanSetCookie(const net::URLRequest& request,
return m_requestContextGetter->m_cookieDelegate->canSetCookie(toQt(request.first_party_for_cookies()), QByteArray::fromStdString(cookie_line), toQt(request.url()));
}
-void NetworkDelegateQt::OnResolveProxy(const GURL&, int, const net::ProxyService&, net::ProxyInfo*)
-{
-}
-
-void NetworkDelegateQt::OnProxyFallback(const net::ProxyServer&, int)
-{
-}
-
int NetworkDelegateQt::OnBeforeSendHeaders(net::URLRequest*, const net::CompletionCallback&, net::HttpRequestHeaders*)
{
return net::OK;
diff --git a/src/core/network_delegate_qt.h b/src/core/network_delegate_qt.h
index 1324e0da3..9c2351960 100644
--- a/src/core/network_delegate_qt.h
+++ b/src/core/network_delegate_qt.h
@@ -76,8 +76,6 @@ public:
virtual int OnBeforeURLRequest(net::URLRequest* request, const net::CompletionCallback& callback, GURL* newUrl) override;
virtual void OnURLRequestDestroyed(net::URLRequest* request) override;
virtual bool OnCanSetCookie(const net::URLRequest&, const std::string&, net::CookieOptions*) override;
- virtual void OnResolveProxy(const GURL&, int, const net::ProxyService&, net::ProxyInfo*) override;
- virtual void OnProxyFallback(const net::ProxyServer&, int) override;
virtual int OnBeforeSendHeaders(net::URLRequest*, const net::CompletionCallback&, net::HttpRequestHeaders*) override;
virtual void OnBeforeSendProxyHeaders(net::URLRequest*, const net::ProxyInfo&, net::HttpRequestHeaders*) override;
virtual void OnSendHeaders(net::URLRequest*, const net::HttpRequestHeaders&) override;
diff --git a/src/core/ozone_platform_eglfs.cpp b/src/core/ozone_platform_eglfs.cpp
index 6fea4259e..91848d671 100644
--- a/src/core/ozone_platform_eglfs.cpp
+++ b/src/core/ozone_platform_eglfs.cpp
@@ -42,7 +42,6 @@
#if defined(USE_OZONE)
#include "base/bind.h"
-#include "media/ozone/media_ozone_platform.h"
#include "ui/events/ozone/device/device_manager.h"
#include "ui/events/ozone/evdev/event_factory_evdev.h"
#include "ui/events/ozone/events_ozone.h"
@@ -57,15 +56,6 @@
#include "ui/platform_window/platform_window.h"
#include "ui/platform_window/platform_window_delegate.h"
-
-namespace media {
-
-MediaOzonePlatform* CreateMediaOzonePlatformEglfs() {
- return new MediaOzonePlatform;
-}
-
-}
-
namespace ui {
namespace {
@@ -184,11 +174,6 @@ scoped_ptr<ui::NativeDisplayDelegate> OzonePlatformEglfs::CreateNativeDisplayDel
return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone());
}
-base::ScopedFD OzonePlatformEglfs::OpenClientNativePixmapDevice() const
-{
- return base::ScopedFD();
-}
-
OzonePlatform* CreateOzonePlatformEglfs() { return new OzonePlatformEglfs; }
ClientNativePixmapFactory* CreateClientNativePixmapFactoryEglfs() {
diff --git a/src/core/ozone_platform_eglfs.h b/src/core/ozone_platform_eglfs.h
index 3a2dfbcf0..2ab2298c0 100644
--- a/src/core/ozone_platform_eglfs.h
+++ b/src/core/ozone_platform_eglfs.h
@@ -65,7 +65,6 @@ class OzonePlatformEglfs : public OzonePlatform {
PlatformWindowDelegate* delegate,
const gfx::Rect& bounds) override;
virtual scoped_ptr<ui::NativeDisplayDelegate> CreateNativeDisplayDelegate() override;
- virtual base::ScopedFD OpenClientNativePixmapDevice() const override;
virtual ui::InputController* GetInputController() override;
virtual scoped_ptr<ui::SystemInputInjector> CreateSystemInputInjector() override;
virtual ui::OverlayManagerOzone* GetOverlayManager() override;
diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp
index 9603dc94c..f76f100e6 100644
--- a/src/core/permission_manager_qt.cpp
+++ b/src/core/permission_manager_qt.cpp
@@ -65,6 +65,7 @@ BrowserContextAdapter::PermissionType toQt(content::PermissionType type)
case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER:
case content::PermissionType::MIDI:
case content::PermissionType::DURABLE_STORAGE:
+ case content::PermissionType::BACKGROUND_SYNC:
case content::PermissionType::NUM:
break;
}
@@ -85,7 +86,7 @@ void PermissionManagerQt::permissionRequestReply(const QUrl &origin, BrowserCont
{
QPair<QUrl, BrowserContextAdapter::PermissionType> key(origin, type);
m_permissions[key] = reply;
- content::PermissionStatus status = reply ? content::PERMISSION_STATUS_GRANTED : content::PERMISSION_STATUS_DENIED;
+ blink::mojom::PermissionStatus status = reply ? blink::mojom::PermissionStatus::GRANTED : blink::mojom::PermissionStatus::DENIED;
auto it = m_requests.begin();
while (it != m_requests.end()) {
if (it->origin == origin && it->type == type) {
@@ -109,14 +110,12 @@ bool PermissionManagerQt::checkPermission(const QUrl &origin, BrowserContextAdap
int PermissionManagerQt::RequestPermission(content::PermissionType permission,
content::RenderFrameHost *frameHost,
const GURL& requesting_origin,
- bool user_gesture,
- const base::Callback<void(content::PermissionStatus)>& callback)
+ const base::Callback<void(blink::mojom::PermissionStatus)>& callback)
{
- Q_UNUSED(user_gesture);
int request_id = ++m_requestIdCount;
BrowserContextAdapter::PermissionType permissionType = toQt(permission);
if (permissionType == BrowserContextAdapter::UnsupportedPermission) {
- callback.Run(content::PERMISSION_STATUS_DENIED);
+ callback.Run(blink::mojom::PermissionStatus::DENIED);
return kNoPendingOperation;
}
// Audio and video-capture should not come this way currently
@@ -140,25 +139,23 @@ int PermissionManagerQt::RequestPermission(content::PermissionType permission,
int PermissionManagerQt::RequestPermissions(const std::vector<content::PermissionType>& permissions,
content::RenderFrameHost* frameHost,
const GURL& requesting_origin,
- bool user_gesture,
- const base::Callback<void(const std::vector<content::PermissionStatus>&)>& callback)
+ const base::Callback<void(const std::vector<blink::mojom::PermissionStatus>&)>& callback)
{
NOTIMPLEMENTED() << "RequestPermissions has not been implemented in QtWebEngine";
- Q_UNUSED(user_gesture);
Q_UNUSED(frameHost);
- std::vector<content::PermissionStatus> result(permissions.size());
+ std::vector<blink::mojom::PermissionStatus> result(permissions.size());
for (content::PermissionType permission : permissions) {
const BrowserContextAdapter::PermissionType permissionType = toQt(permission);
if (permissionType == BrowserContextAdapter::UnsupportedPermission)
- result.push_back(content::PERMISSION_STATUS_DENIED);
+ result.push_back(blink::mojom::PermissionStatus::DENIED);
else {
QPair<QUrl, BrowserContextAdapter::PermissionType> key(toQt(requesting_origin), permissionType);
// TODO: Request permission from UI
if (m_permissions.contains(key) && m_permissions[key])
- result.push_back(content::PERMISSION_STATUS_GRANTED);
+ result.push_back(blink::mojom::PermissionStatus::GRANTED);
else
- result.push_back(content::PERMISSION_STATUS_DENIED);
+ result.push_back(blink::mojom::PermissionStatus::DENIED);
}
}
@@ -172,21 +169,21 @@ void PermissionManagerQt::CancelPermissionRequest(int request_id)
m_requests.remove(request_id);
}
-content::PermissionStatus PermissionManagerQt::GetPermissionStatus(
+blink::mojom::PermissionStatus PermissionManagerQt::GetPermissionStatus(
content::PermissionType permission,
const GURL& requesting_origin,
const GURL& /*embedding_origin*/)
{
const BrowserContextAdapter::PermissionType permissionType = toQt(permission);
if (permissionType == BrowserContextAdapter::UnsupportedPermission)
- return content::PERMISSION_STATUS_DENIED;
+ return blink::mojom::PermissionStatus::DENIED;
QPair<QUrl, BrowserContextAdapter::PermissionType> key(toQt(requesting_origin), permissionType);
if (!m_permissions.contains(key))
- return content::PERMISSION_STATUS_ASK;
+ return blink::mojom::PermissionStatus::ASK;
if (m_permissions[key])
- return content::PERMISSION_STATUS_GRANTED;
- return content::PERMISSION_STATUS_DENIED;
+ return blink::mojom::PermissionStatus::GRANTED;
+ return blink::mojom::PermissionStatus::DENIED;
}
void PermissionManagerQt::ResetPermission(
@@ -214,7 +211,7 @@ int PermissionManagerQt::SubscribePermissionStatusChange(
content::PermissionType permission,
const GURL& requesting_origin,
const GURL& /*embedding_origin*/,
- const base::Callback<void(content::PermissionStatus)>& callback)
+ const base::Callback<void(blink::mojom::PermissionStatus)>& callback)
{
int subscriber_id = ++m_subscriberIdCount;
RequestOrSubscription subscriber = {
diff --git a/src/core/permission_manager_qt.h b/src/core/permission_manager_qt.h
index ff35357d8..e4392b01c 100644
--- a/src/core/permission_manager_qt.h
+++ b/src/core/permission_manager_qt.h
@@ -64,12 +64,11 @@ public:
content::PermissionType permission,
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
- bool user_gesture,
- const base::Callback<void(content::PermissionStatus)>& callback) override;
+ const base::Callback<void(blink::mojom::PermissionStatus)>& callback) override;
void CancelPermissionRequest(int request_id) override;
- content::PermissionStatus GetPermissionStatus(
+ blink::mojom::PermissionStatus GetPermissionStatus(
content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) override;
@@ -83,9 +82,8 @@ public:
const std::vector<content::PermissionType>& permission,
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
- bool user_gesture,
const base::Callback<void(
- const std::vector<content::PermissionStatus>&)>& callback) override;
+ const std::vector<blink::mojom::PermissionStatus>&)>& callback) override;
void RegisterPermissionUsage(
content::PermissionType permission,
@@ -96,7 +94,7 @@ public:
content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin,
- const base::Callback<void(content::PermissionStatus)>& callback) override;
+ const base::Callback<void(blink::mojom::PermissionStatus)>& callback) override;
void UnsubscribePermissionStatusChange(int subscription_id) override;
@@ -105,7 +103,7 @@ private:
struct RequestOrSubscription {
PermissionType type;
QUrl origin;
- base::Callback<void(content::PermissionStatus)> callback;
+ base::Callback<void(blink::mojom::PermissionStatus)> callback;
};
QHash<int, RequestOrSubscription> m_requests;
QHash<int, RequestOrSubscription> m_subscribers;
diff --git a/src/core/print_view_manager_base_qt.h b/src/core/print_view_manager_base_qt.h
index f1e001eee..5939a2b43 100644
--- a/src/core/print_view_manager_base_qt.h
+++ b/src/core/print_view_manager_base_qt.h
@@ -42,8 +42,8 @@
#define PRINT_VIEW_MANAGER_BASE_QT_H
#include "base/memory/ref_counted.h"
-#include "base/prefs/pref_member.h"
#include "base/strings/string16.h"
+#include "components/prefs/pref_member.h"
#include "components/printing/browser/print_manager.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
diff --git a/src/core/print_view_manager_qt.h b/src/core/print_view_manager_qt.h
index 88a499f1b..8856a5b2b 100644
--- a/src/core/print_view_manager_qt.h
+++ b/src/core/print_view_manager_qt.h
@@ -45,8 +45,8 @@
#include <QtWebEngineCore/qtwebenginecoreglobal.h>
#include "base/memory/ref_counted.h"
-#include "base/prefs/pref_member.h"
#include "base/strings/string16.h"
+#include "components/prefs/pref_member.h"
#include "components/printing/browser/print_manager.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
diff --git a/src/core/printing_message_filter_qt.cpp b/src/core/printing_message_filter_qt.cpp
index ba4d5c6e6..3c81896c1 100644
--- a/src/core/printing_message_filter_qt.cpp
+++ b/src/core/printing_message_filter_qt.cpp
@@ -76,9 +76,6 @@ void PrintingMessageFilterQt::OverrideThreadForMessage(
bool PrintingMessageFilterQt::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PrintingMessageFilterQt, message)
-#if defined(OS_WIN)
- IPC_MESSAGE_HANDLER(PrintHostMsg_DuplicateSection, OnDuplicateSection)
-#endif
IPC_MESSAGE_HANDLER(PrintHostMsg_IsPrintingEnabled, OnIsPrintingEnabled)
IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_GetDefaultPrintSettings,
OnGetDefaultPrintSettings)
@@ -91,17 +88,6 @@ bool PrintingMessageFilterQt::OnMessageReceived(const IPC::Message& message) {
return handled;
}
-#if defined(OS_WIN)
-void PrintingMessageFilterQt::OnDuplicateSection(
- base::SharedMemoryHandle renderer_handle,
- base::SharedMemoryHandle* browser_handle) {
- // Duplicate the handle in this process right now so the memory is kept alive
- // (even if it is not mapped)
- base::SharedMemory shared_buf(renderer_handle, true, PeerHandle());
- shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), browser_handle);
-}
-#endif
-
void PrintingMessageFilterQt::OnIsPrintingEnabled(bool* is_enabled) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
*is_enabled = true;
diff --git a/src/core/printing_message_filter_qt.h b/src/core/printing_message_filter_qt.h
index 95d63f570..156a31250 100644
--- a/src/core/printing_message_filter_qt.h
+++ b/src/core/printing_message_filter_qt.h
@@ -44,7 +44,7 @@
#include <string>
#include "base/compiler_specific.h"
-#include "base/prefs/pref_member.h"
+#include "components/prefs/pref_member.h"
#include "content/public/browser/browser_message_filter.h"
#if defined(OS_WIN)
@@ -84,12 +84,6 @@ class PrintingMessageFilterQt : public content::BrowserMessageFilter {
private:
~PrintingMessageFilterQt() override;
-#if defined(OS_WIN)
- // Used to pass resulting EMF from renderer to browser in printing.
- void OnDuplicateSection(base::SharedMemoryHandle renderer_handle,
- base::SharedMemoryHandle* browser_handle);
-#endif
-
// GetPrintSettingsForRenderView must be called via PostTask and
// base::Bind. Collapse the settings-specific params into a
// struct to avoid running into issues with too many params
diff --git a/src/core/qtwebengine.gypi b/src/core/qtwebengine.gypi
index 816962d3d..84a9ff564 100644
--- a/src/core/qtwebengine.gypi
+++ b/src/core/qtwebengine.gypi
@@ -85,7 +85,8 @@
},
},
'dependencies': [
- '<(chromium_src_dir)/ui/events/ozone/events_ozone.gyp:events_ozone_evdev'
+ '<(chromium_src_dir)/ui/events/ozone/events_ozone.gyp:events_ozone_evdev',
+ '<(chromium_src_dir)/ui/ozone/ozone.gyp:ozone_common',
]
}],
['qt_os=="win32" and qt_gl=="opengl"', {
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index f45db6bf4..a0ad53c1e 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -353,8 +353,9 @@ gfx::NativeViewAccessible RenderWidgetHostViewQt::GetNativeViewAccessible()
return 0;
}
-content::BrowserAccessibilityManager* RenderWidgetHostViewQt::CreateBrowserAccessibilityManager(content::BrowserAccessibilityDelegate* delegate)
+content::BrowserAccessibilityManager* RenderWidgetHostViewQt::CreateBrowserAccessibilityManager(content::BrowserAccessibilityDelegate* delegate, bool for_root_frame)
{
+ Q_UNUSED(for_root_frame); // FIXME
#ifndef QT_NO_ACCESSIBILITY
return new content::BrowserAccessibilityManagerQt(
m_adapterClient->accessibilityParentObject(),
@@ -435,11 +436,6 @@ void RenderWidgetHostViewQt::UnlockMouse()
m_host->LostMouseLock();
}
-void RenderWidgetHostViewQt::MovePluginWindows(const std::vector<content::WebPluginGeometry>&)
-{
- // QT_NOT_YET_IMPLEMENTED
-}
-
void RenderWidgetHostViewQt::UpdateCursor(const content::WebCursor &webCursor)
{
content::WebCursor::CursorInfo cursorInfo;
@@ -612,7 +608,7 @@ void RenderWidgetHostViewQt::Destroy()
void RenderWidgetHostViewQt::SetTooltipText(const base::string16 &tooltip_text)
{
- m_delegate->setTooltip(toQt(tooltip_text));
+ m_adapterClient->setToolTip(toQt(tooltip_text));
}
void RenderWidgetHostViewQt::SelectionBoundsChanged(const ViewHostMsg_SelectionBounds_Params &params)
@@ -882,7 +878,7 @@ void RenderWidgetHostViewQt::processMotionEvent(const ui::MotionEvent &motionEve
return;
blink::WebTouchEvent touchEvent = ui::CreateWebTouchEventFromMotionEvent(motionEvent,
- result.did_generate_scroll);
+ result.moved_beyond_slop_region);
m_host->ForwardTouchEventWithLatencyInfo(touchEvent, CreateLatencyInfo(touchEvent));
}
@@ -1032,14 +1028,6 @@ void RenderWidgetHostViewQt::handleInputMethodEvent(QInputMethodEvent *ev)
}
};
- auto setCompositionForPreEditString = [&](){
- ensureValidSelectionRange();
- m_host->ImeSetComposition(toString16(preeditString),
- underlines,
- selectionRange.start(),
- selectionRange.end());
- };
-
Q_FOREACH (const QInputMethodEvent::Attribute &attribute, attributes) {
switch (attribute.type) {
case QInputMethodEvent::TextFormat: {
@@ -1067,9 +1055,19 @@ void RenderWidgetHostViewQt::handleInputMethodEvent(QInputMethodEvent *ev)
}
}
+ gfx::Range replacementRange = (replacementLength > 0) ? gfx::Range(replacementStart, replacementStart + replacementLength)
+ : gfx::Range::InvalidRange();
+
+ auto setCompositionForPreEditString = [&](){
+ ensureValidSelectionRange();
+ m_host->ImeSetComposition(toString16(preeditString),
+ underlines,
+ replacementRange,
+ selectionRange.start(),
+ selectionRange.end());
+ };
+
if (!commitString.isEmpty()) {
- gfx::Range replacementRange = (replacementLength > 0) ? gfx::Range(replacementStart, replacementStart + replacementLength)
- : gfx::Range::InvalidRange();
m_host->ImeConfirmComposition(toString16(commitString), replacementRange, false);
// We might get a commit string and a pre-edit string in a single event, which means
diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h
index 523d1c49d..fa698f0ea 100644
--- a/src/core/render_widget_host_view_qt.h
+++ b/src/core/render_widget_host_view_qt.h
@@ -47,8 +47,8 @@
#include "cc/resources/transferable_resource.h"
#include "content/browser/accessibility/browser_accessibility_manager.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
-#include "content/common/gpu/gpu_messages.h"
#include "content/common/view_messages.h"
+#include "gpu/ipc/common/gpu_messages.h"
#include "ui/events/gesture_detection/filtered_gesture_provider.h"
#include "qtwebenginecoreglobal_p.h"
#include <QMap>
@@ -132,7 +132,6 @@ public:
virtual void SetBackgroundColor(SkColor color) Q_DECL_OVERRIDE;
virtual bool LockMouse() Q_DECL_OVERRIDE;
virtual void UnlockMouse() Q_DECL_OVERRIDE;
- virtual void MovePluginWindows(const std::vector<content::WebPluginGeometry>&) Q_DECL_OVERRIDE;
virtual void UpdateCursor(const content::WebCursor&) Q_DECL_OVERRIDE;
virtual void SetIsLoading(bool) Q_DECL_OVERRIDE;
virtual void TextInputStateChanged(const ViewHostMsg_TextInputState_Params&) Q_DECL_OVERRIDE;
@@ -184,26 +183,14 @@ public:
virtual void SetActive(bool active) Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED }
virtual bool IsSpeaking() const Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED; return false; }
virtual void SpeakSelection() Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED }
- virtual bool PostProcessEventForPluginIme(const content::NativeWebKeyboardEvent& event) Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED; return false; }
virtual void StopSpeaking() Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED }
- virtual void SetWindowVisibility(bool visible) Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED }
virtual bool SupportsSpeech() const Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED; return false; }
virtual void ShowDefinitionForSelection() Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED }
- virtual void WindowFrameChanged() Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED }
#endif // defined(OS_MACOSX)
-#if defined(OS_WIN)
-#if defined(USE_AURA)
- virtual void SetParentNativeViewAccessible(gfx::NativeViewAccessible accessible_parent) Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED }
- virtual gfx::NativeViewId GetParentForWindowlessPlugin() const Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED return gfx::NativeViewId(); }
-#else
- virtual void SetClickthroughRegion(SkRegion *) Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED }
- virtual void WillWmDestroy(void) Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED }
-#endif // defined(USE_AURA)
-#endif // defined(OS_WIN)
// Overridden from content::BrowserAccessibilityDelegate
- virtual content::BrowserAccessibilityManager* CreateBrowserAccessibilityManager(content::BrowserAccessibilityDelegate* delegate) Q_DECL_OVERRIDE;
+ virtual content::BrowserAccessibilityManager* CreateBrowserAccessibilityManager(content::BrowserAccessibilityDelegate* delegate, bool for_root_frame) Q_DECL_OVERRIDE;
#ifndef QT_NO_ACCESSIBILITY
virtual void accessibilityActiveChanged(bool active) Q_DECL_OVERRIDE;
#endif // QT_NO_ACCESSIBILITY
diff --git a/src/core/render_widget_host_view_qt_delegate.h b/src/core/render_widget_host_view_qt_delegate.h
index ce6ec730a..39c972f4b 100644
--- a/src/core/render_widget_host_view_qt_delegate.h
+++ b/src/core/render_widget_host_view_qt_delegate.h
@@ -49,13 +49,27 @@ QT_BEGIN_NAMESPACE
class QCursor;
class QEvent;
class QPainter;
-class QSGImageNode;
class QSGLayer;
class QSGNode;
class QSGTexture;
class QVariant;
class QWindow;
class QInputMethodEvent;
+
+#if (QT_VERSION < QT_VERSION_CHECK(5, 8, 0))
+class QSGImageNode;
+typedef QSGImageNode QSGInternalImageNode;
+class QSGSimpleTextureNode;
+typedef QSGSimpleTextureNode QSGTextureNode;
+class QSGSimpleRectNode;
+typedef QSGSimpleRectNode QSGRectangleNode;
+#else
+class QSGInternalImageNode;
+class QSGRectangleNode;
+class QSGImageNode;
+typedef QSGImageNode QSGTextureNode;
+#endif
+
QT_END_NAMESPACE
namespace QtWebEngineCore {
@@ -92,13 +106,14 @@ public:
virtual QWindow* window() const = 0;
virtual QSGTexture *createTextureFromImage(const QImage &) = 0;
virtual QSGLayer *createLayer() = 0;
- virtual QSGImageNode *createImageNode() = 0;
+ virtual QSGInternalImageNode *createImageNode() = 0;
+ virtual QSGTextureNode *createTextureNode() = 0;
+ virtual QSGRectangleNode *createRectangleNode() = 0;
virtual void update() = 0;
virtual void updateCursor(const QCursor &) = 0;
virtual void resize(int width, int height) = 0;
virtual void move(const QPoint &) = 0;
virtual void inputMethodStateChanged(bool editorVisible) = 0;
- virtual void setTooltip(const QString &) = 0;
virtual void setClearColor(const QColor &color) = 0;
};
diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp
index 5d1780cbe..97b0f1dca 100644
--- a/src/core/renderer/content_renderer_client_qt.cpp
+++ b/src/core/renderer/content_renderer_client_qt.cpp
@@ -43,13 +43,13 @@
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/common/localized_error.h"
#if defined(ENABLE_SPELLCHECK)
#include "chrome/renderer/spellchecker/spellcheck.h"
#include "chrome/renderer/spellchecker/spellcheck_provider.h"
#endif
#include "components/cdm/renderer/widevine_key_systems.h"
#include "components/error_page/common/error_page_params.h"
+#include "components/error_page/common/localized_error.h"
#if defined (ENABLE_BASIC_PRINTING)
#include "components/printing/renderer/print_web_view_helper.h"
#endif // if defined(ENABLE_BASIC_PRINTING)
@@ -76,7 +76,7 @@
#include "renderer/render_view_observer_qt.h"
#include "renderer/user_resource_controller.h"
-#include "grit/renderer_resources.h"
+#include "components/grit/components_resources.h"
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
@@ -85,17 +85,6 @@ namespace QtWebEngineCore {
static const char kHttpErrorDomain[] = "http";
static const char kQrcSchemeQt[] = "qrc";
-class RenderProcessObserverQt : public content::RenderProcessObserver {
-public:
- void WebKitInitialized() override
- {
- // Can only be done after blink is initialized.
- blink::WebString qrcScheme(base::ASCIIToUTF16(kQrcSchemeQt));
- // mark qrc as a secure scheme (avoids deprecation warnings)
- blink::WebSecurityPolicy::registerURLSchemeAsSecure(qrcScheme);
- }
-};
-
ContentRendererClientQt::ContentRendererClientQt()
{
}
@@ -109,16 +98,17 @@ void ContentRendererClientQt::RenderThreadStarted()
content::RenderThread *renderThread = content::RenderThread::Get();
m_visitedLinkSlave.reset(new visitedlink::VisitedLinkSlave);
m_webCacheObserver.reset(new web_cache::WebCacheRenderProcessObserver());
- m_renderProcessObserver.reset(new RenderProcessObserverQt());
renderThread->AddObserver(m_visitedLinkSlave.data());
- renderThread->AddObserver(m_webCacheObserver.data());
renderThread->AddObserver(UserResourceController::instance());
- renderThread->AddObserver(m_renderProcessObserver.data());
#if defined(ENABLE_SPELLCHECK)
m_spellCheck.reset(new SpellCheck());
renderThread->AddObserver(m_spellCheck.data());
#endif
+
+ blink::WebString qrcScheme(base::ASCIIToUTF16(kQrcSchemeQt));
+ // mark qrc as a secure scheme (avoids deprecation warnings)
+ blink::WebSecurityPolicy::registerURLSchemeAsSecure(qrcScheme);
}
void ContentRendererClientQt::RenderViewCreated(content::RenderView* render_view)
@@ -144,14 +134,26 @@ void ContentRendererClientQt::RenderFrameCreated(content::RenderFrame* render_fr
new QtWebEngineCore::RenderFrameObserverQt(render_frame);
}
+void ContentRendererClientQt::RunScriptsAtDocumentStart(content::RenderFrame* render_frame)
+{
+ if (WebChannelIPCTransport *transport = WebChannelIPCTransport::Get(render_frame->GetRenderView()))
+ transport->RunScriptsAtDocumentStart(render_frame);
+ UserResourceController::instance()->RunScriptsAtDocumentStart(render_frame);
+}
+
+void ContentRendererClientQt::RunScriptsAtDocumentEnd(content::RenderFrame* render_frame)
+{
+ UserResourceController::instance()->RunScriptsAtDocumentEnd(render_frame);
+}
+
bool ContentRendererClientQt::HasErrorPage(int httpStatusCode, std::string *errorDomain)
{
// Use an internal error page, if we have one for the status code.
- if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain, httpStatusCode)) {
+ if (!error_page::LocalizedError::HasStrings(error_page::LocalizedError::kHttpErrorDomain, httpStatusCode)) {
return false;
}
- *errorDomain = LocalizedError::kHttpErrorDomain;
+ *errorDomain = error_page::LocalizedError::kHttpErrorDomain;
return true;
}
@@ -173,8 +175,9 @@ void ContentRendererClientQt::GetNavigationErrorStrings(content::RenderFrame* re
const std::string locale = content::RenderThread::Get()->GetLocale();
// TODO(elproxy): We could potentially get better diagnostics here by first calling
// NetErrorHelper::GetErrorStringsForDnsProbe, but that one is harder to untangle.
- LocalizedError::GetStrings(error.reason, error.domain.utf8(), error.unreachableURL, isPost
- , error.staleCopyInCache && !isPost, false, error_page::OfflinePageStatus::NONE, locale, renderFrame->GetRenderView()->GetAcceptLanguages()
+
+ error_page::LocalizedError::GetStrings(error.reason, error.domain.utf8(), error.unreachableURL, isPost
+ , error.staleCopyInCache && !isPost, false, false, locale
, scoped_ptr<error_page::ErrorPageParams>(), &errorStrings);
resourceId = IDR_NET_ERROR_HTML;
@@ -187,7 +190,7 @@ void ContentRendererClientQt::GetNavigationErrorStrings(content::RenderFrame* re
}
if (errorDescription)
- *errorDescription = LocalizedError::GetErrorDetails(error.domain.utf8(), error.reason, isPost);
+ *errorDescription = error_page::LocalizedError::GetErrorDetails(error.domain.utf8(), error.reason, isPost);
}
unsigned long long ContentRendererClientQt::VisitedLinkHash(const char *canonicalUrl, size_t length)
@@ -320,7 +323,7 @@ static void AddPepperBasedWidevine(std::vector<media::KeySystemInfo>* concrete_k
#endif // defined(USE_PROPRIETARY_CODECS)
cdm::AddWidevineWithCodecs(
- cdm::WIDEVINE, supported_codecs,
+ supported_codecs,
media::EmeRobustness::SW_SECURE_CRYPTO, // Maximum audio robustness.
media::EmeRobustness::SW_SECURE_DECODE, // Maximum video robustness.
media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license.
diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h
index d475c7801..b17c618c0 100644
--- a/src/core/renderer/content_renderer_client_qt.h
+++ b/src/core/renderer/content_renderer_client_qt.h
@@ -44,10 +44,6 @@
#include <QtGlobal>
#include <QScopedPointer>
-namespace content {
-class RenderProcessObserver;
-}
-
namespace visitedlink {
class VisitedLinkSlave;
}
@@ -78,10 +74,12 @@ public:
virtual bool IsLinkVisited(unsigned long long linkHash) Q_DECL_OVERRIDE;
virtual void AddKeySystems(std::vector<media::KeySystemInfo>* key_systems) Q_DECL_OVERRIDE;
+ virtual void RunScriptsAtDocumentStart(content::RenderFrame* render_frame) Q_DECL_OVERRIDE;
+ virtual void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) Q_DECL_OVERRIDE;
+
private:
QScopedPointer<visitedlink::VisitedLinkSlave> m_visitedLinkSlave;
QScopedPointer<web_cache::WebCacheRenderProcessObserver> m_webCacheObserver;
- QScopedPointer<content::RenderProcessObserver> m_renderProcessObserver;
#if defined(ENABLE_SPELLCHECK)
QScopedPointer<SpellCheck> m_spellCheck;
#endif
diff --git a/src/core/renderer/pepper/pepper_flash_clipboard_message_filter_qt.cpp b/src/core/renderer/pepper/pepper_flash_clipboard_message_filter_qt.cpp
deleted file mode 100644
index c1782844d..000000000
--- a/src/core/renderer/pepper/pepper_flash_clipboard_message_filter_qt.cpp
+++ /dev/null
@@ -1,401 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// based on chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "pepper_flash_clipboard_message_filter_qt.h"
-
-#include "base/pickle.h"
-#include "base/strings/utf_string_conversions.h"
-#include "content/public/browser/browser_thread.h"
-#include "ipc/ipc_message.h"
-#include "ipc/ipc_message_macros.h"
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/c/private/ppb_flash_clipboard.h"
-#include "ppapi/host/dispatch_host_message.h"
-#include "ppapi/host/host_message_context.h"
-#include "ppapi/host/ppapi_host.h"
-#include "ppapi/proxy/ppapi_messages.h"
-#include "ppapi/proxy/resource_message_params.h"
-#include "ui/base/clipboard/scoped_clipboard_writer.h"
-
-using content::BrowserThread;
-
-namespace QtWebEngineCore {
-
-namespace {
-
-const size_t kMaxClipboardWriteSize = 1000000;
-
-ui::ClipboardType ConvertClipboardType(uint32_t type)
-{
- switch (type) {
- case PP_FLASH_CLIPBOARD_TYPE_STANDARD:
- return ui::CLIPBOARD_TYPE_COPY_PASTE;
- case PP_FLASH_CLIPBOARD_TYPE_SELECTION:
- return ui::CLIPBOARD_TYPE_SELECTION;
- }
- NOTREACHED();
- return ui::CLIPBOARD_TYPE_COPY_PASTE;
-}
-
-// Functions to pack/unpack custom data from a pickle. See the header file for
-// more detail on custom formats in Pepper.
-// TODO(raymes): Currently pepper custom formats are stored in their own
-// native format type. However we should be able to store them in the same way
-// as "Web Custom" formats are. This would allow clipboard data to be shared
-// between pepper applications and web applications. However currently web apps
-// assume all data that is placed on the clipboard is UTF16 and pepper allows
-// arbitrary data so this change would require some reworking of the chrome
-// clipboard interface for custom data.
-bool JumpToFormatInPickle(const base::string16& format, base::PickleIterator* iter)
-{
- size_t size = 0;
- if (!iter->ReadSizeT(&size))
- return false;
- for (size_t i = 0; i < size; ++i) {
- base::string16 stored_format;
- if (!iter->ReadString16(&stored_format))
- return false;
- if (stored_format == format)
- return true;
- int skip_length;
- if (!iter->ReadLength(&skip_length))
- return false;
- if (!iter->SkipBytes(skip_length))
- return false;
- }
- return false;
-}
-
-bool IsFormatAvailableInPickle(const base::string16& format, const base::Pickle& pickle)
-{
- base::PickleIterator iter(pickle);
- return JumpToFormatInPickle(format, &iter);
-}
-
-std::string ReadDataFromPickle(const base::string16& format, const base::Pickle& pickle)
-{
- std::string result;
- base::PickleIterator iter(pickle);
- if (!JumpToFormatInPickle(format, &iter) || !iter.ReadString(&result))
- return std::string();
- return result;
-}
-
-bool WriteDataToPickle(const std::map<base::string16, std::string>& data, base::Pickle* pickle)
-{
- pickle->WriteSizeT(data.size());
- for (std::map<base::string16, std::string>::const_iterator it = data.begin(); it != data.end(); ++it) {
- if (!pickle->WriteString16(it->first))
- return false;
- if (!pickle->WriteString(it->second))
- return false;
- }
- return true;
-}
-
-} // namespace
-
-PepperFlashClipboardMessageFilter::PepperFlashClipboardMessageFilter() {}
-
-PepperFlashClipboardMessageFilter::~PepperFlashClipboardMessageFilter() {}
-
-scoped_refptr<base::TaskRunner>
-PepperFlashClipboardMessageFilter::OverrideTaskRunnerForMessage(const IPC::Message& msg)
-{
- // Clipboard writes should always occur on the UI thread due to the
- // restrictions of various platform APIs. In general, the clipboard is not
- // thread-safe, so all clipboard calls should be serviced from the UI thread.
- if (msg.type() == PpapiHostMsg_FlashClipboard_WriteData::ID)
- return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI);
-
- // Windows needs clipboard reads to be serviced from the IO thread because
- // these are sync IPCs which can result in deadlocks with plugins if serviced
- // from the UI thread. Note that Windows clipboard calls ARE thread-safe so it
- // is ok for reads and writes to be serviced from different threads.
-#if !defined(OS_WIN)
- return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI);
-#else
- return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
-#endif
-}
-
-int32_t PepperFlashClipboardMessageFilter::OnResourceMessageReceived(const IPC::Message& msg,
- ppapi::host::HostMessageContext* context)
-{
- PPAPI_BEGIN_MESSAGE_MAP(PepperFlashClipboardMessageFilter, msg)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashClipboard_RegisterCustomFormat,
- OnMsgRegisterCustomFormat)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashClipboard_IsFormatAvailable,
- OnMsgIsFormatAvailable)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashClipboard_ReadData,
- OnMsgReadData)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashClipboard_WriteData,
- OnMsgWriteData)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashClipboard_GetSequenceNumber,
- OnMsgGetSequenceNumber)
- PPAPI_END_MESSAGE_MAP()
- return PP_ERROR_FAILED;
-}
-
-int32_t PepperFlashClipboardMessageFilter::OnMsgRegisterCustomFormat(
- ppapi::host::HostMessageContext* host_context,
- const std::string& format_name)
-{
- uint32_t format = m_custom_formats.RegisterFormat(format_name);
- if (format == PP_FLASH_CLIPBOARD_FORMAT_INVALID)
- return PP_ERROR_FAILED;
- host_context->reply_msg = PpapiPluginMsg_FlashClipboard_RegisterCustomFormatReply(format);
- return PP_OK;
-}
-
-int32_t PepperFlashClipboardMessageFilter::OnMsgIsFormatAvailable(
- ppapi::host::HostMessageContext* host_context,
- uint32_t clipboard_type,
- uint32_t format)
-{
- if (clipboard_type != PP_FLASH_CLIPBOARD_TYPE_STANDARD) {
- NOTIMPLEMENTED();
- return PP_ERROR_FAILED;
- }
-
- ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
- ui::ClipboardType type = ConvertClipboardType(clipboard_type);
- bool available = false;
- switch (format) {
- case PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT: {
- bool plain = clipboard->IsFormatAvailable(ui::Clipboard::GetPlainTextFormatType(), type);
- bool plainw = clipboard->IsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(), type);
- available = plain || plainw;
- break;
- }
- case PP_FLASH_CLIPBOARD_FORMAT_HTML:
- available = clipboard->IsFormatAvailable(ui::Clipboard::GetHtmlFormatType(), type);
- break;
- case PP_FLASH_CLIPBOARD_FORMAT_RTF:
- available = clipboard->IsFormatAvailable(ui::Clipboard::GetRtfFormatType(), type);
- break;
- case PP_FLASH_CLIPBOARD_FORMAT_INVALID:
- break;
- default:
- if (m_custom_formats.IsFormatRegistered(format)) {
- std::string format_name = m_custom_formats.GetFormatName(format);
- std::string clipboard_data;
- clipboard->ReadData(ui::Clipboard::GetPepperCustomDataFormatType(), &clipboard_data);
- base::Pickle pickle(clipboard_data.data(), clipboard_data.size());
- available = IsFormatAvailableInPickle(base::UTF8ToUTF16(format_name), pickle);
- }
- break;
- }
-
- return available ? PP_OK : PP_ERROR_FAILED;
-}
-
-int32_t PepperFlashClipboardMessageFilter::OnMsgReadData(
- ppapi::host::HostMessageContext* host_context,
- uint32_t clipboard_type,
- uint32_t format)
-{
- if (clipboard_type != PP_FLASH_CLIPBOARD_TYPE_STANDARD) {
- NOTIMPLEMENTED();
- return PP_ERROR_FAILED;
- }
-
- ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
- ui::ClipboardType type = ConvertClipboardType(clipboard_type);
- std::string clipboard_string;
- int32_t result = PP_ERROR_FAILED;
- switch (format) {
- case PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT: {
- if (clipboard->IsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(), type)) {
- base::string16 text;
- clipboard->ReadText(type, &text);
- if (!text.empty()) {
- result = PP_OK;
- clipboard_string = base::UTF16ToUTF8(text);
- break;
- }
- }
- // If the PlainTextW format isn't available or is empty, take the
- // ASCII text format.
- if (clipboard->IsFormatAvailable(ui::Clipboard::GetPlainTextFormatType(), type)) {
- result = PP_OK;
- clipboard->ReadAsciiText(type, &clipboard_string);
- }
- break;
- }
- case PP_FLASH_CLIPBOARD_FORMAT_HTML: {
- if (!clipboard->IsFormatAvailable(ui::Clipboard::GetHtmlFormatType(), type)) {
- break;
- }
-
- base::string16 html;
- std::string url;
- uint32_t fragment_start;
- uint32_t fragment_end;
- clipboard->ReadHTML(type, &html, &url, &fragment_start, &fragment_end);
- result = PP_OK;
- clipboard_string = base::UTF16ToUTF8(html.substr(fragment_start, fragment_end - fragment_start));
- break;
- }
- case PP_FLASH_CLIPBOARD_FORMAT_RTF: {
- if (!clipboard->IsFormatAvailable(ui::Clipboard::GetRtfFormatType(), type)) {
- break;
- }
- result = PP_OK;
- clipboard->ReadRTF(type, &clipboard_string);
- break;
- }
- case PP_FLASH_CLIPBOARD_FORMAT_INVALID:
- break;
- default:
- if (m_custom_formats.IsFormatRegistered(format)) {
- base::string16 format_name =
- base::UTF8ToUTF16(m_custom_formats.GetFormatName(format));
- std::string clipboard_data;
- clipboard->ReadData(ui::Clipboard::GetPepperCustomDataFormatType(),
- &clipboard_data);
- base::Pickle pickle(clipboard_data.data(), clipboard_data.size());
- if (IsFormatAvailableInPickle(format_name, pickle)) {
- result = PP_OK;
- clipboard_string = ReadDataFromPickle(format_name, pickle);
- }
- }
- break;
- }
-
- if (result == PP_OK) {
- host_context->reply_msg = PpapiPluginMsg_FlashClipboard_ReadDataReply(clipboard_string);
- }
- return result;
-}
-
-int32_t PepperFlashClipboardMessageFilter::OnMsgWriteData(
- ppapi::host::HostMessageContext* host_context,
- uint32_t clipboard_type,
- const std::vector<uint32_t>& formats,
- const std::vector<std::string>& data)
-{
- if (clipboard_type != PP_FLASH_CLIPBOARD_TYPE_STANDARD) {
- NOTIMPLEMENTED();
- return PP_ERROR_FAILED;
- }
- if (formats.size() != data.size())
- return PP_ERROR_FAILED;
-
- ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
- ui::ClipboardType type = ConvertClipboardType(clipboard_type);
- // If no formats are passed in clear the clipboard.
- if (formats.size() == 0) {
- clipboard->Clear(type);
- return PP_OK;
- }
-
- ui::ScopedClipboardWriter scw(type);
- std::map<base::string16, std::string> custom_data_map;
- int32_t res = PP_OK;
- for (uint32_t i = 0; i < formats.size(); ++i) {
- if (data[i].length() > kMaxClipboardWriteSize) {
- res = PP_ERROR_NOSPACE;
- break;
- }
-
- switch (formats[i]) {
- case PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT:
- scw.WriteText(base::UTF8ToUTF16(data[i]));
- break;
- case PP_FLASH_CLIPBOARD_FORMAT_HTML:
- scw.WriteHTML(base::UTF8ToUTF16(data[i]), std::string());
- break;
- case PP_FLASH_CLIPBOARD_FORMAT_RTF:
- scw.WriteRTF(data[i]);
- break;
- case PP_FLASH_CLIPBOARD_FORMAT_INVALID:
- res = PP_ERROR_BADARGUMENT;
- break;
- default:
- if (m_custom_formats.IsFormatRegistered(formats[i])) {
- std::string format_name = m_custom_formats.GetFormatName(formats[i]);
- custom_data_map[base::UTF8ToUTF16(format_name)] = data[i];
- } else {
- // Invalid format.
- res = PP_ERROR_BADARGUMENT;
- break;
- }
- }
-
- if (res != PP_OK)
- break;
- }
-
- if (custom_data_map.size() > 0) {
- base::Pickle pickle;
- if (WriteDataToPickle(custom_data_map, &pickle)) {
- scw.WritePickledData(pickle, ui::Clipboard::GetPepperCustomDataFormatType());
- } else {
- res = PP_ERROR_BADARGUMENT;
- }
- }
-
- if (res != PP_OK) {
- // Need to clear the objects so nothing is written.
- scw.Reset();
- }
-
- return res;
-}
-
-int32_t PepperFlashClipboardMessageFilter::OnMsgGetSequenceNumber(
- ppapi::host::HostMessageContext* host_context,
- uint32_t clipboard_type)
-{
- if (clipboard_type != PP_FLASH_CLIPBOARD_TYPE_STANDARD) {
- NOTIMPLEMENTED();
- return PP_ERROR_FAILED;
- }
-
- ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
- ui::ClipboardType type = ConvertClipboardType(clipboard_type);
- int64_t sequence_number = clipboard->GetSequenceNumber(type);
- host_context->reply_msg = PpapiPluginMsg_FlashClipboard_GetSequenceNumberReply(sequence_number);
- return PP_OK;
-}
-
-} // namespace QtWebEngineCore
diff --git a/src/core/renderer/pepper/pepper_flash_clipboard_message_filter_qt.h b/src/core/renderer/pepper/pepper_flash_clipboard_message_filter_qt.h
deleted file mode 100644
index c00e668ea..000000000
--- a/src/core/renderer/pepper/pepper_flash_clipboard_message_filter_qt.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// based on chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef PEPPER_FLASH_CLIPBOARD_MESSAGE_FILTER_QT_H
-#define PEPPER_FLASH_CLIPBOARD_MESSAGE_FILTER_QT_H
-
-#include <string>
-#include <vector>
-
-#include "base/compiler_specific.h"
-#include "ppapi/host/resource_message_filter.h"
-#include "ppapi/shared_impl/flash_clipboard_format_registry.h"
-
-namespace ppapi {
-namespace host {
-struct HostMessageContext;
-}
-}
-
-namespace ui {
-class ScopedClipboardWriter;
-}
-
-namespace QtWebEngineCore {
-
-// Resource message filter for accessing the clipboard in Pepper. Pepper
-// supports reading/writing custom formats from the clipboard. Currently, all
-// custom formats that are read/written from the clipboard through pepper are
-// stored in a single real clipboard format (in the same way the "web custom"
-// clipboard formats are). This is done so that we don't have to have use real
-// clipboard types for each custom clipboard format which may be a limited
-// resource on a particular platform.
-class PepperFlashClipboardMessageFilter : public ppapi::host::ResourceMessageFilter {
-public:
- PepperFlashClipboardMessageFilter();
-
-protected:
- // ppapi::host::ResourceMessageFilter overrides.
- scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage(const IPC::Message& msg) override;
- int32_t OnResourceMessageReceived(const IPC::Message& msg, ppapi::host::HostMessageContext* context) override;
-
-private:
- ~PepperFlashClipboardMessageFilter() override;
-
- int32_t OnMsgRegisterCustomFormat(ppapi::host::HostMessageContext* host_context, const std::string& format_name);
- int32_t OnMsgIsFormatAvailable(ppapi::host::HostMessageContext* host_context,
- uint32_t clipboard_type,
- uint32_t format);
- int32_t OnMsgReadData(ppapi::host::HostMessageContext* host_context,
- uint32_t clipoard_type,
- uint32_t format);
- int32_t OnMsgWriteData(ppapi::host::HostMessageContext* host_context,
- uint32_t clipboard_type,
- const std::vector<uint32_t>& formats,
- const std::vector<std::string>& data);
- int32_t OnMsgGetSequenceNumber(ppapi::host::HostMessageContext* host_context,
- uint32_t clipboard_type);
-
- int32_t WriteClipboardDataItem(uint32_t format,
- const std::string& data,
- ui::ScopedClipboardWriter* scw);
-
- ppapi::FlashClipboardFormatRegistry m_custom_formats;
-
- DISALLOW_COPY_AND_ASSIGN(PepperFlashClipboardMessageFilter);
-};
-
-} // namespace QtWebEngineCore
-
-#endif // PEPPER_FLASH_CLIPBOARD_MESSAGE_FILTER_QT_H
diff --git a/src/core/renderer/pepper/pepper_host_factory_qt.cpp b/src/core/renderer/pepper/pepper_host_factory_qt.cpp
index 9b7236d8a..4a25e7756 100644
--- a/src/core/renderer/pepper/pepper_host_factory_qt.cpp
+++ b/src/core/renderer/pepper/pepper_host_factory_qt.cpp
@@ -44,7 +44,9 @@
#include "pepper_host_factory_qt.h"
+#include "base/memory/ptr_util.h"
#include "build/build_config.h"
+#include "chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h"
#include "content/public/browser/browser_ppapi_host.h"
#include "ppapi/host/message_filter_host.h"
#include "ppapi/host/ppapi_host.h"
@@ -53,7 +55,6 @@
#include "ppapi/shared_impl/ppapi_permissions.h"
#include "pepper_flash_browser_host_qt.h"
-#include "pepper_flash_clipboard_message_filter_qt.h"
#include "pepper_isolated_file_system_message_filter.h"
using ppapi::host::MessageFilterHost;
@@ -68,7 +69,7 @@ PepperHostFactoryQt::PepperHostFactoryQt(content::BrowserPpapiHost* host)
PepperHostFactoryQt::~PepperHostFactoryQt() {}
-scoped_ptr<ppapi::host::ResourceHost> PepperHostFactoryQt::CreateResourceHost(ppapi::host::PpapiHost* host,
+std::unique_ptr<ppapi::host::ResourceHost> PepperHostFactoryQt::CreateResourceHost(ppapi::host::PpapiHost* host,
PP_Resource resource,
PP_Instance instance,
const IPC::Message& message)
@@ -77,16 +78,16 @@ scoped_ptr<ppapi::host::ResourceHost> PepperHostFactoryQt::CreateResourceHost(pp
if (!host_->IsValidInstance(instance))
- return scoped_ptr<ppapi::host::ResourceHost>();
+ return nullptr;
// Flash interfaces.
if (host_->GetPpapiHost()->permissions().HasPermission(ppapi::PERMISSION_FLASH)) {
switch (message.type()) {
case PpapiHostMsg_Flash_Create::ID:
- return scoped_ptr<ppapi::host::ResourceHost>(new PepperFlashBrowserHostQt(host_, instance, resource));
+ return base::WrapUnique(new PepperFlashBrowserHostQt(host_, instance, resource));
case PpapiHostMsg_FlashClipboard_Create::ID: {
- scoped_refptr<ResourceMessageFilter> clipboard_filter(new PepperFlashClipboardMessageFilter);
- return scoped_ptr<ppapi::host::ResourceHost>(new MessageFilterHost(
+ scoped_refptr<ResourceMessageFilter> clipboard_filter(new chrome::PepperFlashClipboardMessageFilter);
+ return base::WrapUnique(new MessageFilterHost(
host_->GetPpapiHost(), instance, resource, clipboard_filter));
}
}
@@ -101,11 +102,12 @@ scoped_ptr<ppapi::host::ResourceHost> PepperHostFactoryQt::CreateResourceHost(pp
if (message.type() == PpapiHostMsg_IsolatedFileSystem_Create::ID) {
PepperIsolatedFileSystemMessageFilter* isolated_fs_filter = PepperIsolatedFileSystemMessageFilter::Create(instance, host_);
if (!isolated_fs_filter)
- return scoped_ptr<ppapi::host::ResourceHost>();
- return scoped_ptr<ppapi::host::ResourceHost>(new MessageFilterHost(host, instance, resource, isolated_fs_filter));
+ return nullptr;
+ return base::WrapUnique(
+ new MessageFilterHost(host_->GetPpapiHost(), instance, resource, isolated_fs_filter));
}
- return scoped_ptr<ppapi::host::ResourceHost>();
+ return nullptr;
}
} // namespace QtWebEngineCore
diff --git a/src/core/renderer/pepper/pepper_host_factory_qt.h b/src/core/renderer/pepper/pepper_host_factory_qt.h
index e73e097c0..0446cf9e3 100644
--- a/src/core/renderer/pepper/pepper_host_factory_qt.h
+++ b/src/core/renderer/pepper/pepper_host_factory_qt.h
@@ -57,7 +57,7 @@ public:
explicit PepperHostFactoryQt(content::BrowserPpapiHost* host);
~PepperHostFactoryQt() override;
- virtual scoped_ptr<ppapi::host::ResourceHost> CreateResourceHost(
+ virtual std::unique_ptr<ppapi::host::ResourceHost> CreateResourceHost(
ppapi::host::PpapiHost* host,
PP_Resource resource,
PP_Instance instance,
diff --git a/src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp b/src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp
index 636ca12f1..89f691cef 100644
--- a/src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp
+++ b/src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp
@@ -44,6 +44,8 @@
#include "pepper_renderer_host_factory_qt.h"
#include "pepper_flash_renderer_host_qt.h"
+
+#include "base/memory/ptr_util.h"
#include "content/public/renderer/renderer_ppapi_host.h"
#include "ppapi/host/ppapi_host.h"
#include "ppapi/host/resource_host.h"
@@ -63,7 +65,7 @@ PepperRendererHostFactoryQt::~PepperRendererHostFactoryQt()
{
}
-scoped_ptr<ppapi::host::ResourceHost> PepperRendererHostFactoryQt::CreateResourceHost(
+std::unique_ptr<ppapi::host::ResourceHost> PepperRendererHostFactoryQt::CreateResourceHost(
ppapi::host::PpapiHost* host,
PP_Resource resource,
PP_Instance instance,
@@ -72,16 +74,14 @@ scoped_ptr<ppapi::host::ResourceHost> PepperRendererHostFactoryQt::CreateResourc
DCHECK_EQ(host_->GetPpapiHost(), host);
if (!host_->IsValidInstance(instance))
- return scoped_ptr<ppapi::host::ResourceHost>();
+ return nullptr;
if (host_->GetPpapiHost()->permissions().HasPermission(ppapi::PERMISSION_FLASH)
&& message.type() == PpapiHostMsg_Flash_Create::ID)
- return scoped_ptr<ppapi::host::ResourceHost>(
- new PepperFlashRendererHostQt(host_,
- instance,
- resource));
+ return base::WrapUnique(
+ new PepperFlashRendererHostQt(host_, instance, resource));
- return scoped_ptr<ppapi::host::ResourceHost>();
+ return nullptr;
}
} // QtWebEngineCore
diff --git a/src/core/renderer/pepper/pepper_renderer_host_factory_qt.h b/src/core/renderer/pepper/pepper_renderer_host_factory_qt.h
index bc472a7c6..ec3440a08 100644
--- a/src/core/renderer/pepper/pepper_renderer_host_factory_qt.h
+++ b/src/core/renderer/pepper/pepper_renderer_host_factory_qt.h
@@ -56,7 +56,7 @@ public:
~PepperRendererHostFactoryQt();
// HostFactory.
- scoped_ptr<ppapi::host::ResourceHost> CreateResourceHost(
+ std::unique_ptr<ppapi::host::ResourceHost> CreateResourceHost(
ppapi::host::PpapiHost* host,
PP_Resource resource,
PP_Instance instance,
diff --git a/src/core/renderer/render_frame_observer_qt.cpp b/src/core/renderer/render_frame_observer_qt.cpp
index f2285f298..8f65ea8ff 100644
--- a/src/core/renderer/render_frame_observer_qt.cpp
+++ b/src/core/renderer/render_frame_observer_qt.cpp
@@ -44,11 +44,12 @@
#include "render_frame_observer_qt.h"
+#include "base/memory/scoped_ptr.h"
+#include "chrome/renderer/pepper/pepper_shared_memory_message_filter.h"
#include "content/public/renderer/renderer_ppapi_host.h"
#include "ppapi/host/ppapi_host.h"
#include "renderer/pepper/pepper_renderer_host_factory_qt.h"
-#include "renderer/pepper/pepper_flash_renderer_host_qt.h"
namespace QtWebEngineCore {
@@ -65,8 +66,9 @@ RenderFrameObserverQt::~RenderFrameObserverQt()
void RenderFrameObserverQt::DidCreatePepperPlugin(content::RendererPpapiHost* host)
{
host->GetPpapiHost()->AddHostFactoryFilter(
- scoped_ptr<ppapi::host::HostFactory>(
- new PepperRendererHostFactoryQt(host)));
+ scoped_ptr<ppapi::host::HostFactory>(new PepperRendererHostFactoryQt(host)));
+ host->GetPpapiHost()->AddInstanceMessageFilter(
+ scoped_ptr<ppapi::host::InstanceMessageFilter>(new PepperSharedMemoryMessageFilter(host)));
}
#endif
diff --git a/src/core/renderer/render_view_observer_qt.cpp b/src/core/renderer/render_view_observer_qt.cpp
index 4b44a9bd9..68c0fc08f 100644
--- a/src/core/renderer/render_view_observer_qt.cpp
+++ b/src/core/renderer/render_view_observer_qt.cpp
@@ -46,6 +46,9 @@
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebElement.h"
#include "third_party/WebKit/public/web/WebFrame.h"
+#include "third_party/WebKit/public/web/WebFrameContentDumper.h"
+#include "third_party/WebKit/public/web/WebFrameWidget.h"
+#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebView.h"
RenderViewObserverQt::RenderViewObserverQt(
@@ -58,23 +61,26 @@ RenderViewObserverQt::RenderViewObserverQt(
void RenderViewObserverQt::onFetchDocumentMarkup(quint64 requestId)
{
- Send(new RenderViewObserverHostQt_DidFetchDocumentMarkup(
- routing_id(),
- requestId,
- render_view()->GetWebView()->mainFrame()->contentAsMarkup()));
+ blink::WebString markup;
+ if (render_view()->GetWebView()->mainFrame()->isWebLocalFrame())
+ markup = blink::WebFrameContentDumper::dumpAsMarkup(
+ static_cast<blink::WebLocalFrame*>(render_view()->GetWebView()->mainFrame()));
+ Send(new RenderViewObserverHostQt_DidFetchDocumentMarkup(routing_id(), requestId, markup));
}
void RenderViewObserverQt::onFetchDocumentInnerText(quint64 requestId)
{
- Send(new RenderViewObserverHostQt_DidFetchDocumentInnerText(
- routing_id(),
- requestId,
- render_view()->GetWebView()->mainFrame()->contentAsText(std::numeric_limits<std::size_t>::max())));
+ blink::WebString text;
+ if (render_view()->GetWebView()->mainFrame()->isWebLocalFrame())
+ text = blink::WebFrameContentDumper::deprecatedDumpFrameTreeAsText(
+ static_cast<blink::WebLocalFrame*>(render_view()->GetWebView()->mainFrame()),
+ std::numeric_limits<std::size_t>::max());
+ Send(new RenderViewObserverHostQt_DidFetchDocumentInnerText(routing_id(), requestId, text));
}
void RenderViewObserverQt::onSetBackgroundColor(quint32 color)
{
- render_view()->GetWebView()->setBaseBackgroundColor(color);
+ render_view()->GetWebFrameWidget()->setBaseBackgroundColor(color);
}
void RenderViewObserverQt::OnFirstVisuallyNonEmptyLayout()
diff --git a/src/core/renderer/user_resource_controller.cpp b/src/core/renderer/user_resource_controller.cpp
index 30a04958f..8c603b805 100644
--- a/src/core/renderer/user_resource_controller.cpp
+++ b/src/core/renderer/user_resource_controller.cpp
@@ -39,8 +39,12 @@
#include "user_resource_controller.h"
+#include "base/strings/pattern.h"
+#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_view.h"
#include "content/public/renderer/render_view_observer.h"
+#include "extensions/common/url_pattern.h"
+#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebScriptSource.h"
#include "third_party/WebKit/public/web/WebView.h"
@@ -48,6 +52,8 @@
#include "common/qt_messages.h"
#include "common/user_script_data.h"
+#include "type_conversion.h"
+#include "user_script.h"
Q_GLOBAL_STATIC(UserResourceController, qt_webengine_userResourceController)
@@ -56,13 +62,46 @@ static content::RenderView * const globalScriptsIndex = 0;
// Scripts meant to run after the load event will be run 500ms after DOMContentLoaded if the load event doesn't come within that delay.
static const int afterLoadTimeout = 500;
+static bool scriptMatchesURL(const UserScriptData &scriptData, const GURL &url) {
+ // Logic taken from Chromium (extensions/common/user_script.cc)
+ bool matchFound;
+ if (!scriptData.urlPatterns.empty()) {
+ matchFound = false;
+ for (auto it = scriptData.urlPatterns.begin(), end = scriptData.urlPatterns.end(); it != end; ++it) {
+ URLPattern urlPattern(QtWebEngineCore::UserScript::validUserScriptSchemes(), *it);
+ if (urlPattern.MatchesURL(url))
+ matchFound = true;
+ }
+ if (!matchFound)
+ return false;
+ }
+
+ if (!scriptData.globs.empty()) {
+ matchFound = false;
+ for (auto it = scriptData.globs.begin(), end = scriptData.globs.end(); it != end; ++it) {
+ if (base::MatchPattern(url.spec(), *it))
+ matchFound = true;
+ }
+ if (!matchFound)
+ return false;
+ }
+
+ if (!scriptData.excludeGlobs.empty()) {
+ for (auto it = scriptData.excludeGlobs.begin(), end = scriptData.excludeGlobs.end(); it != end; ++it) {
+ if (base::MatchPattern(url.spec(), *it))
+ return false;
+ }
+ }
+
+ return true;
+}
+
class UserResourceController::RenderViewObserverHelper : public content::RenderViewObserver
{
public:
RenderViewObserverHelper(content::RenderView *);
private:
// RenderViewObserver implementation.
- virtual void DidCreateDocumentElement(blink::WebLocalFrame* frame) Q_DECL_OVERRIDE;
virtual void DidFinishDocumentLoad(blink::WebLocalFrame* frame) Q_DECL_OVERRIDE;
virtual void DidFinishLoad(blink::WebLocalFrame* frame) Q_DECL_OVERRIDE;
virtual void DidStartProvisionalLoad(blink::WebLocalFrame* frame) Q_DECL_OVERRIDE;
@@ -82,17 +121,25 @@ void UserResourceController::RenderViewObserverHelper::runScripts(UserScriptData
{
if (p == UserScriptData::AfterLoad && !m_pendingFrames.remove(frame))
return;
+
+ UserResourceController::instance()->runScripts(p, frame);
+}
+
+void UserResourceController::runScripts(UserScriptData::InjectionPoint p, blink::WebLocalFrame *frame)
+{
content::RenderView *renderView = content::RenderView::FromWebView(frame->view());
const bool isMainFrame = (frame == renderView->GetWebView()->mainFrame());
- QList<uint64_t> scriptsToRun = UserResourceController::instance()->m_viewUserScriptMap.value(globalScriptsIndex).toList();
- scriptsToRun.append(UserResourceController::instance()->m_viewUserScriptMap.value(renderView).toList());
+ QList<uint64_t> scriptsToRun = m_viewUserScriptMap.value(globalScriptsIndex).toList();
+ scriptsToRun.append(m_viewUserScriptMap.value(renderView).toList());
Q_FOREACH (uint64_t id, scriptsToRun) {
- const UserScriptData &script = UserResourceController::instance()->m_scripts.value(id);
+ const UserScriptData &script = m_scripts.value(id);
if (script.injectionPoint != p
|| (!script.injectForSubframes && !isMainFrame))
continue;
+ if (!scriptMatchesURL(script, frame->document().url()))
+ continue;
blink::WebScriptSource source(blink::WebString::fromUTF8(script.source), script.url);
if (script.worldId)
frame->executeScriptInIsolatedWorld(script.worldId, &source, /*numSources = */1, /*contentScriptExtentsionGroup = */ 0);
@@ -101,20 +148,23 @@ void UserResourceController::RenderViewObserverHelper::runScripts(UserScriptData
}
}
+void UserResourceController::RunScriptsAtDocumentStart(content::RenderFrame *render_frame)
+{
+ runScripts(UserScriptData::DocumentElementCreation, render_frame->GetWebFrame());
+}
-UserResourceController::RenderViewObserverHelper::RenderViewObserverHelper(content::RenderView *renderView)
- : content::RenderViewObserver(renderView)
+void UserResourceController::RunScriptsAtDocumentEnd(content::RenderFrame *render_frame)
{
+ runScripts(UserScriptData::DocumentLoadFinished, render_frame->GetWebFrame());
}
-void UserResourceController::RenderViewObserverHelper::DidCreateDocumentElement(blink::WebLocalFrame *frame)
+UserResourceController::RenderViewObserverHelper::RenderViewObserverHelper(content::RenderView *renderView)
+ : content::RenderViewObserver(renderView)
{
- runScripts(UserScriptData::DocumentElementCreation, frame);
}
void UserResourceController::RenderViewObserverHelper::DidFinishDocumentLoad(blink::WebLocalFrame *frame)
{
- runScripts(UserScriptData::DocumentLoadFinished, frame);
m_pendingFrames.insert(frame);
base::MessageLoop::current()->PostDelayedTask(FROM_HERE, base::Bind(&UserResourceController::RenderViewObserverHelper::runScripts,
base::Unretained(this), UserScriptData::AfterLoad, frame),
diff --git a/src/core/renderer/user_resource_controller.h b/src/core/renderer/user_resource_controller.h
index bd3d0ba49..8eba12abc 100644
--- a/src/core/renderer/user_resource_controller.h
+++ b/src/core/renderer/user_resource_controller.h
@@ -48,11 +48,15 @@
#include <QtCore/QHash>
#include <QtCore/QSet>
+namespace blink {
+class WebLocalFrame;
+}
+
namespace content {
+class RenderFrame;
class RenderView;
}
-
class UserResourceController : public content::RenderProcessObserver {
public:
@@ -64,22 +68,29 @@ public:
void removeScriptForView(const UserScriptData &, content::RenderView *);
void clearScriptsForView(content::RenderView *);
+ void RunScriptsAtDocumentStart(content::RenderFrame *render_frame);
+ void RunScriptsAtDocumentEnd(content::RenderFrame *render_frame);
+
private:
Q_DISABLE_COPY(UserResourceController)
class RenderViewObserverHelper;
// RenderProcessObserver implementation.
- virtual bool OnControlMessageReceived(const IPC::Message &message) Q_DECL_OVERRIDE;
+ bool OnControlMessageReceived(const IPC::Message &message) override;
void onAddScript(const UserScriptData &);
void onRemoveScript(const UserScriptData &);
void onClearScripts();
+ void runScripts(UserScriptData::InjectionPoint, blink::WebLocalFrame *);
+
typedef QSet<uint64_t> UserScriptSet;
typedef QHash<const content::RenderView *, UserScriptSet> ViewUserScriptMap;
ViewUserScriptMap m_viewUserScriptMap;
QHash<uint64_t, UserScriptData> m_scripts;
+
+ friend class RenderViewObserverHelper;
};
#endif // USER_RESOURCE_CONTROLLER_H
diff --git a/src/core/renderer/web_channel_ipc_transport.cpp b/src/core/renderer/web_channel_ipc_transport.cpp
index 6bbbe28bd..3a44bb182 100644
--- a/src/core/renderer/web_channel_ipc_transport.cpp
+++ b/src/core/renderer/web_channel_ipc_transport.cpp
@@ -44,6 +44,7 @@
#include "common/qt_messages.h"
+#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_view.h"
#include "gin/arguments.h"
#include "gin/handle.h"
@@ -153,11 +154,22 @@ content::RenderView *WebChannelTransport::GetRenderView(v8::Isolate *isolate)
WebChannelIPCTransport::WebChannelIPCTransport(content::RenderView *renderView)
: content::RenderViewObserver(renderView)
+ , content::RenderViewObserverTracker<WebChannelIPCTransport>(renderView)
, m_installed(false)
, m_installedWorldId(0)
{
}
+void WebChannelIPCTransport::RunScriptsAtDocumentStart(content::RenderFrame *render_frame)
+{
+ // JavaScript run before this point doesn't stick, and needs to be redone.
+ // ### FIXME: we should try no even installing before
+ blink::WebLocalFrame *frame = render_frame->GetWebFrame();
+ if (m_installed && render_frame->IsMainFrame())
+ WebChannelTransport::Install(frame, m_installedWorldId);
+}
+
+
void WebChannelIPCTransport::installWebChannel(uint worldId)
{
blink::WebView *webView = render_view()->GetWebView();
@@ -170,6 +182,7 @@ void WebChannelIPCTransport::installWebChannel(uint worldId)
void WebChannelIPCTransport::uninstallWebChannel(uint worldId)
{
+ Q_ASSERT(worldId = m_installedWorldId);
blink::WebView *webView = render_view()->GetWebView();
if (!webView)
return;
@@ -222,13 +235,6 @@ void WebChannelIPCTransport::dispatchWebChannelMessage(const std::vector<char> &
frame->callFunctionEvenIfScriptDisabled(callback, webChannelObjectValue->ToObject(), argc, argv);
}
-void WebChannelIPCTransport::DidCreateDocumentElement(blink::WebLocalFrame* frame)
-{
- blink::WebFrame* main_frame = render_view()->GetWebView()->mainFrame();
- if (m_installed && frame == main_frame)
- WebChannelTransport::Install(frame, m_installedWorldId);
-}
-
bool WebChannelIPCTransport::OnMessageReceived(const IPC::Message &message)
{
bool handled = true;
diff --git a/src/core/renderer/web_channel_ipc_transport.h b/src/core/renderer/web_channel_ipc_transport.h
index fcee13bda..ae3f16cac 100644
--- a/src/core/renderer/web_channel_ipc_transport.h
+++ b/src/core/renderer/web_channel_ipc_transport.h
@@ -42,23 +42,31 @@
#include "base/values.h"
#include "content/public/renderer/render_view_observer.h"
+#include "content/public/renderer/render_view_observer_tracker.h"
#include <QtCore/qcompilerdetection.h>
+namespace content {
+class RenderFrame;
+}
+
namespace v8 {
class Extension;
}
namespace QtWebEngineCore {
-class WebChannelIPCTransport : public content::RenderViewObserver {
+class WebChannelIPCTransport : public content::RenderViewObserver
+ , public content::RenderViewObserverTracker<WebChannelIPCTransport>
+{
public:
WebChannelIPCTransport(content::RenderView *);
+ void RunScriptsAtDocumentStart(content::RenderFrame *render_frame);
+
private:
void dispatchWebChannelMessage(const std::vector<char> &binaryJSON, uint worldId);
void installWebChannel(uint worldId);
void uninstallWebChannel(uint worldId);
- virtual void DidCreateDocumentElement(blink::WebLocalFrame* frame) override;
virtual bool OnMessageReceived(const IPC::Message &message) Q_DECL_OVERRIDE;
bool m_installed;
diff --git a/src/core/resource_bundle_qt.cpp b/src/core/resource_bundle_qt.cpp
index fa5c04524..115dc56dc 100644
--- a/src/core/resource_bundle_qt.cpp
+++ b/src/core/resource_bundle_qt.cpp
@@ -38,10 +38,20 @@
****************************************************************************/
#include "base/command_line.h"
+#include "base/metrics/histogram.h"
#include "content/public/common/content_switches.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/data_pack.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/ui_base_switches.h"
+
#include "web_engine_library_info.h"
+#if defined(OS_LINUX)
+#include "base/posix/global_descriptors.h"
+#include "global_descriptors_qt.h"
+#endif
+
namespace ui {
void ResourceBundle::LoadCommonResources()
@@ -53,11 +63,69 @@ void ResourceBundle::LoadCommonResources()
AddOptionalDataPackFromPath(WebEngineLibraryInfo::getPath(QT_RESOURCES_DEVTOOLS_PAK), SCALE_FACTOR_NONE);
}
-gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl)
+gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id)
{
LOG(WARNING) << "Unable to load image with id " << resource_id;
NOTREACHED(); // Want to assert in debug mode.
return GetEmptyImage();
}
+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) {
+ // 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)
+ return false;
+
+ auto global_descriptors = base::GlobalDescriptors::GetInstance();
+ return global_descriptors->MaybeGet(kWebEngineLocale) != -1;
+ }
+#endif
+
+ return !GetLocaleFilePath(locale, true).empty();
+}
+
+std::string ResourceBundle::LoadLocaleResources(const std::string& pref_locale)
+{
+ DCHECK(!locale_resources_data_.get()) << "locale.pak already loaded";
+
+ std::string app_locale = l10n_util::GetApplicationLocale(pref_locale);
+
+#if defined(OS_LINUX)
+ int locale_fd = base::GlobalDescriptors::GetInstance()->MaybeGet(kWebEngineLocale);
+ if (locale_fd > -1) {
+ scoped_ptr<DataPack> data_pack(new DataPack(SCALE_FACTOR_100P));
+ data_pack->LoadFromFile(base::File(locale_fd));
+ locale_resources_data_.reset(data_pack.release());
+ return app_locale;
+ }
+#endif
+
+ base::FilePath locale_file_path = GetOverriddenPakPath();
+ if (locale_file_path.empty())
+ locale_file_path = GetLocaleFilePath(app_locale, true);
+
+ if (locale_file_path.empty()) {
+ // It's possible that there is no locale.pak.
+ LOG(WARNING) << "locale_file_path.empty() for locale " << app_locale;
+ return std::string();
+ }
+
+ scoped_ptr<DataPack> data_pack(new DataPack(SCALE_FACTOR_100P));
+ if (!data_pack->LoadFromPath(locale_file_path)) {
+ UMA_HISTOGRAM_ENUMERATION("ResourceBundle.LoadLocaleResourcesError",
+ logging::GetLastSystemErrorCode(), 16000);
+ LOG(ERROR) << "failed to load locale.pak";
+ NOTREACHED();
+ return std::string();
+ }
+
+ locale_resources_data_.reset(data_pack.release());
+ return app_locale;
+}
+
} // namespace ui
diff --git a/src/core/resources/resources.gyp b/src/core/resources/resources.gyp
index 618b4d355..8b7d520a9 100644
--- a/src/core/resources/resources.gyp
+++ b/src/core/resources/resources.gyp
@@ -20,6 +20,7 @@
'dependencies': [
'<(chromium_src_dir)/content/app/strings/content_strings.gyp:content_strings',
'<(chromium_src_dir)/content/browser/devtools/devtools_resources.gyp:devtools_resources',
+ '<(chromium_src_dir)/components/components_resources.gyp:components_resources',
'<(chromium_src_dir)/components/components_strings.gyp:components_strings',
'<(chromium_src_dir)/third_party/WebKit/public/blink_resources.gyp:blink_resources',
'<(qtwebengine_root)/src/core/chrome_qt.gyp:chrome_resources',
@@ -30,6 +31,7 @@
'variables': {
'pak_inputs': [
'<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak',
+ '<(SHARED_INTERMEDIATE_DIR)/components/components_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/content/content_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/blink_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/resources/webui_resources.pak',
@@ -45,6 +47,7 @@
'variables': {
'pak_inputs': [
'<(SHARED_INTERMEDIATE_DIR)/ui/resources/ui_resources_100_percent.pak',
+ '<(SHARED_INTERMEDIATE_DIR)/components/components_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/content/app/resources/content_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/chrome/renderer_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/blink_image_resources_100_percent.pak',
@@ -60,6 +63,7 @@
'variables': {
'pak_inputs': [
'<(SHARED_INTERMEDIATE_DIR)/ui/resources/ui_resources_200_percent.pak',
+ '<(SHARED_INTERMEDIATE_DIR)/components/components_resources_200_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/content/app/resources/content_resources_200_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/chrome/renderer_resources_200_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/blink_image_resources_200_percent.pak',
diff --git a/src/core/type_conversion.cpp b/src/core/type_conversion.cpp
index ef220b86c..a7b5ee831 100644
--- a/src/core/type_conversion.cpp
+++ b/src/core/type_conversion.cpp
@@ -50,6 +50,8 @@ QImage toQImage(const SkBitmap &bitmap)
QImage image;
switch (bitmap.colorType()) {
case kUnknown_SkColorType:
+ case kRGBA_F16_SkColorType:
+ qWarning("Unknown or unsupported skia image format");
break;
case kAlpha_8_SkColorType:
image = toQImage(bitmap, QImage::Format_Alpha8);
diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp
index bf32c75a4..959dd3d95 100644
--- a/src/core/url_request_context_getter_qt.cpp
+++ b/src/core/url_request_context_getter_qt.cpp
@@ -291,7 +291,7 @@ void URLRequestContextGetterQt::generateCookieStore()
m_storage->set_cookie_store(0);
m_cookieDelegate->setCookieMonster(0);
- net::CookieStore* cookieStore = 0;
+ scoped_ptr<net::CookieStore> cookieStore;
switch (m_persistentCookiesPolicy) {
case BrowserContextAdapter::NoPersistentCookies:
cookieStore =
@@ -321,10 +321,12 @@ void URLRequestContextGetterQt::generateCookieStore()
);
break;
}
- m_storage->set_cookie_store(cookieStore);
- net::CookieMonster * const cookieMonster = cookieStore->GetCookieMonster();
- cookieMonster->SetCookieableSchemes(kCookieableSchemes, arraysize(kCookieableSchemes));
+ net::CookieMonster * const cookieMonster = static_cast<net::CookieMonster*>(cookieStore.get());
+ m_storage->set_cookie_store(std::move(cookieStore));
+
+ const std::vector<std::string> cookieableSchemes(kCookieableSchemes, kCookieableSchemes + arraysize(kCookieableSchemes));
+ cookieMonster->SetCookieableSchemes(cookieableSchemes);
m_cookieDelegate->setCookieMonster(cookieMonster);
}
@@ -406,8 +408,6 @@ static bool doNetworkSessionParamsMatch(const net::HttpNetworkSession::Params &f
return false;
if (first.http_auth_handler_factory != second.http_auth_handler_factory)
return false;
- if (first.network_delegate != second.network_delegate)
- return false;
if (first.http_server_properties.get() != second.http_server_properties.get())
return false;
if (first.ignore_certificate_errors != second.ignore_certificate_errors)
@@ -430,7 +430,6 @@ net::HttpNetworkSession::Params URLRequestContextGetterQt::generateNetworkSessio
network_session_params.proxy_service = m_urlRequestContext->proxy_service();
network_session_params.ssl_config_service = m_urlRequestContext->ssl_config_service();
network_session_params.http_auth_handler_factory = m_urlRequestContext->http_auth_handler_factory();
- network_session_params.network_delegate = m_networkDelegate.get();
network_session_params.http_server_properties = m_urlRequestContext->http_server_properties();
network_session_params.ignore_certificate_errors = m_ignoreCertificateErrors;
network_session_params.host_resolver = m_urlRequestContext->host_resolver();
diff --git a/src/core/url_request_context_getter_qt.h b/src/core/url_request_context_getter_qt.h
index dd51fd72c..b6209030b 100644
--- a/src/core/url_request_context_getter_qt.h
+++ b/src/core/url_request_context_getter_qt.h
@@ -46,6 +46,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/single_thread_task_runner.h"
+#include "content/public/browser/browser_context.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/common/url_constants.h"
#include "net/http/http_network_session.h"
@@ -116,12 +117,12 @@ private:
content::ProtocolHandlerMap m_protocolHandlers;
QAtomicPointer<net::ProxyConfigService> m_proxyConfigService;
- scoped_ptr<net::URLRequestContext> m_urlRequestContext;
- scoped_ptr<NetworkDelegateQt> m_networkDelegate;
- scoped_ptr<net::URLRequestContextStorage> m_storage;
- scoped_ptr<net::URLRequestJobFactory> m_jobFactory;
+ std::unique_ptr<net::URLRequestContext> m_urlRequestContext;
+ std::unique_ptr<NetworkDelegateQt> m_networkDelegate;
+ std::unique_ptr<net::URLRequestContextStorage> m_storage;
+ std::unique_ptr<net::URLRequestJobFactory> m_jobFactory;
net::URLRequestJobFactoryImpl *m_baseJobFactory;
- scoped_ptr<net::DhcpProxyScriptFetcherFactory> m_dhcpProxyScriptFetcherFactory;
+ std::unique_ptr<net::DhcpProxyScriptFetcherFactory> m_dhcpProxyScriptFetcherFactory;
scoped_refptr<CookieMonsterDelegateQt> m_cookieDelegate;
content::URLRequestInterceptorScopedVector m_requestInterceptors;
scoped_ptr<net::HttpNetworkSession> m_httpNetworkSession;
diff --git a/src/core/user_script.cpp b/src/core/user_script.cpp
index 839eff366..b33dd6a7d 100644
--- a/src/core/user_script.cpp
+++ b/src/core/user_script.cpp
@@ -38,11 +38,39 @@
****************************************************************************/
#include "common/user_script_data.h"
+#include "extensions/common/url_pattern.h"
#include "user_script.h"
#include "type_conversion.h"
+namespace {
+
+// Helper function to parse Greasemonkey headers
+bool GetDeclarationValue(const base::StringPiece& line,
+ const base::StringPiece& prefix,
+ std::string* value) {
+ base::StringPiece::size_type index = line.find(prefix);
+ if (index == base::StringPiece::npos)
+ return false;
+
+ std::string temp(line.data() + index + prefix.length(),
+ line.length() - index - prefix.length());
+
+ if (temp.empty() || !base::IsUnicodeWhitespace(temp[0]))
+ return false;
+
+ base::TrimWhitespaceASCII(temp, base::TRIM_ALL, value);
+ return true;
+}
+
+} // namespace
+
namespace QtWebEngineCore {
+int UserScript::validUserScriptSchemes()
+{
+ return URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS | URLPattern::SCHEME_FILE;
+}
+
ASSERT_ENUMS_MATCH(UserScript::AfterLoad, UserScriptData::AfterLoad)
ASSERT_ENUMS_MATCH(UserScript::DocumentLoadFinished, UserScriptData::DocumentLoadFinished)
ASSERT_ENUMS_MATCH(UserScript::DocumentElementCreation, UserScriptData::DocumentElementCreation)
@@ -100,6 +128,7 @@ void UserScript::setSourceCode(const QString &source)
{
initData();
scriptData->source = source.toStdString();
+ parseMetadataHeader();
}
UserScript::InjectionPoint UserScript::injectionPoint() const
@@ -169,4 +198,80 @@ UserScriptData &UserScript::data() const
return *(scriptData.data());
}
+void UserScript::parseMetadataHeader()
+{
+ // Logic taken from Chromium (extensions/browser/user_script_loader.cc)
+ // http://wiki.greasespot.net/Metadata_block
+ const std::string &script_text = scriptData->source;
+ base::StringPiece line;
+ size_t line_start = 0;
+ size_t line_end = line_start;
+ bool in_metadata = false;
+
+ static const base::StringPiece kUserScriptBegin("// ==UserScript==");
+ static const base::StringPiece kUserScriptEnd("// ==/UserScript==");
+ static const base::StringPiece kNameDeclaration("// @name");
+ static const base::StringPiece kIncludeDeclaration("// @include");
+ static const base::StringPiece kExcludeDeclaration("// @exclude");
+ static const base::StringPiece kMatchDeclaration("// @match");
+ static const base::StringPiece kRunAtDeclaration("// @run-at");
+ static const base::StringPiece kRunAtDocumentStartValue("document-start");
+ static const base::StringPiece kRunAtDocumentEndValue("document-end");
+ static const base::StringPiece kRunAtDocumentIdleValue("document-idle");
+ // FIXME: Scripts don't run in subframes by default. If we would like to
+ // support @noframes rule, we have to change the current default behavior.
+ // static const base::StringPiece kNoFramesDeclaration("// @noframes");
+
+ static URLPattern urlPatternParser(validUserScriptSchemes());
+
+ while (line_start < script_text.length()) {
+ line_end = script_text.find('\n', line_start);
+
+ // Handle the case where there is no trailing newline in the file.
+ if (line_end == std::string::npos)
+ line_end = script_text.length() - 1;
+
+ line.set(script_text.data() + line_start, line_end - line_start);
+
+ if (!in_metadata) {
+ if (line.starts_with(kUserScriptBegin))
+ in_metadata = true;
+ } else {
+ if (line.starts_with(kUserScriptEnd))
+ break;
+
+ std::string value;
+ if (GetDeclarationValue(line, kNameDeclaration, &value)) {
+ setName(toQt(value));
+ } else if (GetDeclarationValue(line, kIncludeDeclaration, &value)) {
+ // We escape some characters that MatchPattern() considers special.
+ base::ReplaceSubstringsAfterOffset(&value, 0, "\\", "\\\\");
+ base::ReplaceSubstringsAfterOffset(&value, 0, "?", "\\?");
+ scriptData->globs.push_back(value);
+ } else if (GetDeclarationValue(line, kExcludeDeclaration, &value)) {
+ base::ReplaceSubstringsAfterOffset(&value, 0, "\\", "\\\\");
+ base::ReplaceSubstringsAfterOffset(&value, 0, "?", "\\?");
+ scriptData->excludeGlobs.push_back(value);
+ } else if (GetDeclarationValue(line, kMatchDeclaration, &value)) {
+ if (URLPattern::PARSE_SUCCESS == urlPatternParser.Parse(value))
+ scriptData->urlPatterns.push_back(value);
+ } else if (GetDeclarationValue(line, kRunAtDeclaration, &value)) {
+ if (value == kRunAtDocumentStartValue)
+ scriptData->injectionPoint = DocumentElementCreation;
+ else if (value == kRunAtDocumentEndValue)
+ scriptData->injectionPoint = DocumentLoadFinished;
+ else if (value == kRunAtDocumentIdleValue)
+ scriptData->injectionPoint = AfterLoad;
+ }
+ }
+
+ line_start = line_end + 1;
+ }
+
+ // If no patterns were specified, default to @include *. This is what
+ // Greasemonkey does.
+ if (scriptData->globs.empty() && scriptData->urlPatterns.empty())
+ scriptData->globs.push_back("*");
+}
+
} // namespace QtWebEngineCore
diff --git a/src/core/user_script.h b/src/core/user_script.h
index 9d7d66a58..e44efd3e9 100644
--- a/src/core/user_script.h
+++ b/src/core/user_script.h
@@ -85,9 +85,12 @@ public:
bool operator==(const UserScript &) const;
+ static int validUserScriptSchemes();
+
private:
void initData();
UserScriptData &data() const;
+ void parseMetadataHeader();
friend class UserResourceControllerHost;
QScopedPointer<UserScriptData> scriptData;
diff --git a/src/core/web_channel_ipc_transport_host.h b/src/core/web_channel_ipc_transport_host.h
index 9cc1f3104..75b40477e 100644
--- a/src/core/web_channel_ipc_transport_host.h
+++ b/src/core/web_channel_ipc_transport_host.h
@@ -62,7 +62,7 @@ public:
virtual void RenderViewHostChanged(content::RenderViewHost* old_host, content::RenderViewHost* new_host) Q_DECL_OVERRIDE;
// QWebChannelAbstractTransport
- virtual void sendMessage(const QJsonObject &message) Q_DECL_OVERRIDE;
+ void sendMessage(const QJsonObject &message) Q_DECL_OVERRIDE;
void setWorldId(uint worldId);
uint worldId() const { return m_worldId; }
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index bfac6a5b2..b0aae6ca9 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -46,6 +46,7 @@
#include "browser_accessibility_qt.h"
#include "browser_context_adapter.h"
+#include "browser_context_adapter_client.h"
#include "browser_context_qt.h"
#include "download_manager_delegate_qt.h"
#include "media_capture_devices_dispatcher.h"
@@ -482,7 +483,7 @@ void WebContentsAdapter::reload()
void WebContentsAdapter::reloadAndBypassCache()
{
Q_D(WebContentsAdapter);
- d->webContents->GetController().ReloadIgnoringCache(/*checkRepost = */false);
+ d->webContents->GetController().ReloadBypassingCache(/*checkRepost = */false);
d->webContents->Focus();
}
@@ -519,7 +520,7 @@ void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeT
urlString.append(encodedData.constData(), encodedData.length());
GURL dataUrlToLoad(urlString);
- if (dataUrlToLoad.spec().size() > content::kMaxURLChars) {
+ if (dataUrlToLoad.spec().size() > url::kMaxURLChars) {
d->adapterClient->loadFinished(false, baseUrl, false, net::ERR_ABORTED);
return;
}
@@ -535,9 +536,10 @@ void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeT
d->webContents->Unselect();
}
-void WebContentsAdapter::save()
+void WebContentsAdapter::save(const QString &filePath, int savePageFormat)
{
Q_D(WebContentsAdapter);
+ d->webContentsDelegate->setSavePageInfo(SavePageInfo(filePath, savePageFormat));
d->webContents->OnSavePage();
}
@@ -849,11 +851,17 @@ void WebContentsAdapter::updateWebPreferences(const content::WebPreferences & we
void WebContentsAdapter::download(const QUrl &url, const QString &suggestedFileName)
{
+ 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);
+
scoped_ptr<content::DownloadUrlParameters> params(
content::DownloadUrlParameters::FromWebContents(webContents(), toGurl(url)));
params->set_suggested_name(toString16(suggestedFileName));
@@ -916,13 +924,13 @@ bool WebContentsAdapter::hasInspector() const
void WebContentsAdapter::exitFullScreen()
{
Q_D(WebContentsAdapter);
- d->webContents->ExitFullscreen();
+ d->webContents->ExitFullscreen(false);
}
void WebContentsAdapter::changedFullScreen()
{
Q_D(WebContentsAdapter);
- d->webContents->NotifyFullscreenChanged();
+ d->webContents->NotifyFullscreenChanged(false);
}
void WebContentsAdapter::wasShown()
@@ -1276,4 +1284,16 @@ FaviconManager *WebContentsAdapter::faviconManager()
return d->webContentsDelegate->faviconManager();
}
+void WebContentsAdapter::viewSource()
+{
+ Q_D(WebContentsAdapter);
+ d->webContents->ViewSource();
+}
+
+bool WebContentsAdapter::canViewSource()
+{
+ Q_D(WebContentsAdapter);
+ return d->webContents->GetController().CanViewSource();
+}
+
} // namespace QtWebEngineCore
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index ec8cd7914..a29778a7e 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -85,7 +85,7 @@ public:
void reloadAndBypassCache();
void load(const QUrl&);
void setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl);
- void save();
+ void save(const QString &filePath = QString(), int savePageFormat = -1);
QUrl activeUrl() const;
QUrl requestedUrl() const;
QString pageTitle() const;
@@ -178,6 +178,9 @@ public:
content::WebContents *webContents() const;
void replaceMisspelling(const QString &word);
+ void viewSource();
+ bool canViewSource();
+
private:
Q_DISABLE_COPY(WebContentsAdapter)
Q_DECLARE_PRIVATE(WebContentsAdapter)
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index 3952067a7..31786a8f8 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -259,6 +259,7 @@ public:
const QPixmap &pixmap, const QPoint &offset) = 0;
virtual bool isEnabled() const = 0;
virtual const QObject *holdingQObject() const = 0;
+ virtual void setToolTip(const QString& toolTipText) = 0;
virtual QSharedPointer<BrowserContextAdapter> browserContextAdapter() = 0;
virtual WebContentsAdapter* webContentsAdapter() = 0;
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index d523aa16b..9aa584369 100644
--- a/src/core/web_contents_delegate_qt.h
+++ b/src/core/web_contents_delegate_qt.h
@@ -42,7 +42,6 @@
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
-#include "content/public/common/permission_status.mojom.h"
#include "third_party/skia/include/core/SkColor.h"
#include "base/callback.h"
@@ -70,6 +69,23 @@ namespace QtWebEngineCore {
class WebContentsAdapterClient;
+class SavePageInfo
+{
+public:
+ SavePageInfo()
+ : requestedFormat(-1)
+ {
+ }
+
+ SavePageInfo(const QString &filePath, int format)
+ : requestedFilePath(filePath), requestedFormat(format)
+ {
+ }
+
+ QString requestedFilePath;
+ int requestedFormat;
+};
+
class WebContentsDelegateQt : public content::WebContentsDelegate
, public content::WebContentsObserver
{
@@ -126,6 +142,9 @@ public:
void launchExternalURL(const QUrl &url, ui::PageTransition page_transition, bool is_main_frame);
FaviconManager *faviconManager();
+ void setSavePageInfo(const SavePageInfo &spi) { m_savePageInfo = spi; }
+ const SavePageInfo &savePageInfo() { return m_savePageInfo; }
+
private:
QWeakPointer<WebContentsAdapter> createWindow(content::WebContents *new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture);
@@ -134,6 +153,7 @@ private:
int m_lastReceivedFindReply;
QVector<int64_t> m_loadingErrorFrameList;
QScopedPointer<FaviconManager> m_faviconManager;
+ SavePageInfo m_savePageInfo;
};
} // namespace QtWebEngineCore
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index 98fba0897..329f9c9db 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -148,10 +148,14 @@ bool usingQtQuick2DRenderer()
}
if (device.isEmpty())
+ device = QString::fromLocal8Bit(qgetenv("QT_QUICK_BACKEND"));
+ if (device.isEmpty())
device = QString::fromLocal8Bit(qgetenv("QMLSCENE_DEVICE"));
+ if (device.isEmpty())
+ device = QLatin1String("default");
- // This assumes that the plugin is installed and is going to be used by QtQuick.
- return device == QLatin1String("softwarecontext");
+ // Anything other than the default OpenGL device will need to render in 2D mode.
+ return device != QLatin1String("default");
}
#if defined(ENABLE_PLUGINS)
@@ -281,6 +285,9 @@ WebEngineContext::WebEngineContext()
parsedCommandLine->AppendSwitch(switches::kDisableZeroCopy);
parsedCommandLine->AppendSwitch(switches::kDisableGpuMemoryBufferCompositorResources);
+ // Enabled on OS X and Linux but currently not working. It worked in 5.7 on OS X.
+ parsedCommandLine->AppendSwitch(switches::kDisableGpuMemoryBufferVideoFrames);
+
if (useEmbeddedSwitches) {
// Inspired by the Android port's default switches
parsedCommandLine->AppendSwitch(switches::kEnableOverlayScrollbar);
diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp
index 399e36765..2be59d1c6 100644
--- a/src/core/web_engine_library_info.cpp
+++ b/src/core/web_engine_library_info.cpp
@@ -303,8 +303,16 @@ base::string16 WebEngineLibraryInfo::getApplicationName()
std::string WebEngineLibraryInfo::getApplicationLocale()
{
base::CommandLine *parsedCommandLine = base::CommandLine::ForCurrentProcess();
- if (!parsedCommandLine->HasSwitch(switches::kLang))
- return QLocale().bcp47Name().toStdString();
+ if (!parsedCommandLine->HasSwitch(switches::kLang)) {
+ const QString &locale = QLocale().bcp47Name();
+
+ // QLocale::bcp47Name returns "en" for American English locale. Chromium requires the "US" suffix
+ // to clarify the dialect and ignores the shorter version.
+ if (locale == "en")
+ return "en-US";
+
+ return locale.toStdString();
+ }
return parsedCommandLine->GetSwitchValueASCII(switches::kLang);
}
diff --git a/src/core/yuv_video_node.cpp b/src/core/yuv_video_node.cpp
index f8290878b..16e52575d 100644
--- a/src/core/yuv_video_node.cpp
+++ b/src/core/yuv_video_node.cpp
@@ -283,8 +283,19 @@ void YUVVideoMaterialShader::updateState(const RenderState &state, QSGMaterial *
break;
}
- program()->setUniformValue(m_id_yuvMatrix, QMatrix3x3(yuv_to_rgb));
- program()->setUniformValue(m_id_yuvAdjust, QVector3D(yuv_adjust[0], yuv_adjust[1], yuv_adjust[2]));
+ float yuv_to_rgb_multiplied[9];
+ float yuv_adjust_with_offset[3];
+
+ for (int i = 0; i < 9; ++i)
+ yuv_to_rgb_multiplied[i] = yuv_to_rgb[i] * mat->m_resourceMultiplier;
+
+ for (int i = 0; i < 3; ++i)
+ yuv_adjust_with_offset[i] =
+ yuv_adjust[i] / mat->m_resourceMultiplier - mat->m_resourceOffset;
+
+
+ program()->setUniformValue(m_id_yuvMatrix, QMatrix3x3(yuv_to_rgb_multiplied));
+ program()->setUniformValue(m_id_yuvAdjust, QVector3D(yuv_adjust_with_offset[0], yuv_adjust_with_offset[1], yuv_adjust_with_offset[2]));
if (state.isOpacityDirty())
program()->setUniformValue(m_id_opacity, state.opacity());
@@ -312,7 +323,8 @@ void YUVAVideoMaterialShader::updateState(const RenderState &state, QSGMaterial
YUVVideoMaterial::YUVVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture,
const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize,
- YUVVideoMaterial::ColorSpace colorspace)
+ YUVVideoMaterial::ColorSpace colorspace,
+ float rMul, float rOff)
: m_yTexture(yTexture)
, m_uTexture(uTexture)
, m_vTexture(vTexture)
@@ -321,6 +333,8 @@ YUVVideoMaterial::YUVVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, Q
, m_yaTexSize(yaTexSize)
, m_uvTexSize(uvTexSize)
, m_colorSpace(colorspace)
+ , m_resourceMultiplier(rMul)
+ , m_resourceOffset(rOff)
{
}
@@ -341,8 +355,9 @@ int YUVVideoMaterial::compare(const QSGMaterial *other) const
YUVAVideoMaterial::YUVAVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, QSGTexture *aTexture,
const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize,
- YUVVideoMaterial::ColorSpace colorspace)
- : YUVVideoMaterial(yTexture, uTexture, vTexture, yaTexCoordRect, uvTexCoordRect, yaTexSize, uvTexSize, colorspace)
+ YUVVideoMaterial::ColorSpace colorspace,
+ float rMul, float rOff)
+ : YUVVideoMaterial(yTexture, uTexture, vTexture, yaTexCoordRect, uvTexCoordRect, yaTexSize, uvTexSize, colorspace, rMul, rOff)
, m_aTexture(aTexture)
{
setFlag(Blending, aTexture);
@@ -363,15 +378,15 @@ int YUVAVideoMaterial::compare(const QSGMaterial *other) const
YUVVideoNode::YUVVideoNode(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, QSGTexture *aTexture,
const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize,
- YUVVideoMaterial::ColorSpace colorspace)
+ YUVVideoMaterial::ColorSpace colorspace, float rMul, float rOff)
: m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4)
{
setGeometry(&m_geometry);
setFlag(QSGNode::OwnsMaterial);
if (aTexture)
- m_material = new YUVAVideoMaterial(yTexture, uTexture, vTexture, aTexture, yaTexCoordRect, uvTexCoordRect, yaTexSize, uvTexSize, colorspace);
+ m_material = new YUVAVideoMaterial(yTexture, uTexture, vTexture, aTexture, yaTexCoordRect, uvTexCoordRect, yaTexSize, uvTexSize, colorspace, rMul, rOff);
else
- m_material = new YUVVideoMaterial(yTexture, uTexture, vTexture, yaTexCoordRect, uvTexCoordRect, yaTexSize, uvTexSize, colorspace);
+ m_material = new YUVVideoMaterial(yTexture, uTexture, vTexture, yaTexCoordRect, uvTexCoordRect, yaTexSize, uvTexSize, colorspace, rMul, rOff);
setMaterial(m_material);
}
diff --git a/src/core/yuv_video_node.h b/src/core/yuv_video_node.h
index cce204fd3..670ec62b6 100644
--- a/src/core/yuv_video_node.h
+++ b/src/core/yuv_video_node.h
@@ -60,7 +60,7 @@ public:
};
YUVVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture,
const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize,
- ColorSpace colorspace);
+ ColorSpace colorspace, float rMul, float rOff);
virtual QSGMaterialType *type() const Q_DECL_OVERRIDE
{
@@ -79,7 +79,8 @@ public:
QSizeF m_yaTexSize;
QSizeF m_uvTexSize;
ColorSpace m_colorSpace;
-
+ float m_resourceMultiplier;
+ float m_resourceOffset;
};
class YUVAVideoMaterial : public YUVVideoMaterial
@@ -87,7 +88,7 @@ class YUVAVideoMaterial : public YUVVideoMaterial
public:
YUVAVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, QSGTexture *aTexture,
const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize,
- ColorSpace colorspace);
+ ColorSpace colorspace, float rMul, float rOff);
virtual QSGMaterialType *type() const Q_DECL_OVERRIDE
{
@@ -106,7 +107,7 @@ class YUVVideoNode : public QSGGeometryNode
public:
YUVVideoNode(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, QSGTexture *aTexture,
const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize,
- YUVVideoMaterial::ColorSpace colorspace);
+ YUVVideoMaterial::ColorSpace colorspace, float rMul, float rOff);
void setRect(const QRectF &rect);
private:
diff --git a/src/tools/qwebengine_convert_dict/qwebengine_convert_dict.pro b/src/tools/qwebengine_convert_dict/qwebengine_convert_dict.pro
index de125cc76..1781b843d 100644
--- a/src/tools/qwebengine_convert_dict/qwebengine_convert_dict.pro
+++ b/src/tools/qwebengine_convert_dict/qwebengine_convert_dict.pro
@@ -10,6 +10,9 @@ OBJECTS =
# Fixme: -Werror=unused-parameter in core
QMAKE_CXXFLAGS_WARN_ON =
+# Disable MSVC2015 warning C4577 ('noexcept' used with no exception handling mode specified)
+win32: QMAKE_CXXFLAGS_WARN_ON = -wd4577
+
# Issue with some template compliation, smb smart should look at it
win32: DEFINES += NOMINMAX
diff --git a/src/webengine/api/qquickwebenginecontextmenudata.cpp b/src/webengine/api/qquickwebenginecontextmenudata.cpp
index 979d80e34..269d655a2 100644
--- a/src/webengine/api/qquickwebenginecontextmenudata.cpp
+++ b/src/webengine/api/qquickwebenginecontextmenudata.cpp
@@ -170,6 +170,34 @@ bool QQuickWebEngineContextMenuData::isContentEditable() const
return d ? d->isEditable : false;
}
+/*!
+ \qmlproperty QString WebEngineContextMenuData::misspelledWord
+
+ If the context is a word considered misspelled by the spell-checker, returns the misspelled word.
+
+ \since QtWebEngine 1.4
+*/
+QString QQuickWebEngineContextMenuData::misspelledWord() const
+{
+ if (d)
+ return d->misspelledWord;
+ return QString();
+}
+
+/*!
+ \qmlproperty QStringList WebEngineContextMenuData::spellCheckerSuggestions
+
+ If the context is a word considered misspelled by the spell-checker, returns a list of suggested replacements.
+
+ \since QtWebEngine 1.4
+*/
+QStringList QQuickWebEngineContextMenuData::spellCheckerSuggestions() const
+{
+ if (d)
+ return d->spellCheckerSuggestions;
+ return QStringList();
+}
+
void QQuickWebEngineContextMenuData::update(const QtWebEngineCore::WebEngineContextMenuData &update)
{
const QQuickWebEngineContextMenuData old(d);
@@ -198,6 +226,12 @@ void QQuickWebEngineContextMenuData::update(const QtWebEngineCore::WebEngineCont
if (isContentEditable() != old.isContentEditable())
Q_EMIT isContentEditableChanged();
+
+ if (misspelledWord() != old.misspelledWord())
+ Q_EMIT misspelledWordChanged();
+
+ if (spellCheckerSuggestions() != old.spellCheckerSuggestions())
+ Q_EMIT spellCheckerSuggestionsChanged();
}
QQuickWebEngineContextMenuData::QQuickWebEngineContextMenuData(const QQuickWebEngineContextMenuDataPrivate *p, QObject *parent)
diff --git a/src/webengine/api/qquickwebenginecontextmenudata_p.h b/src/webengine/api/qquickwebenginecontextmenudata_p.h
index aa081cbe6..7175838db 100644
--- a/src/webengine/api/qquickwebenginecontextmenudata_p.h
+++ b/src/webengine/api/qquickwebenginecontextmenudata_p.h
@@ -92,6 +92,8 @@ public:
Q_PROPERTY(QUrl mediaUrl READ mediaUrl NOTIFY mediaUrlChanged)
Q_PROPERTY(MediaType mediaType READ mediaType NOTIFY mediaTypeChanged)
Q_PROPERTY(bool isContentEditable READ isContentEditable NOTIFY isContentEditableChanged)
+ Q_PROPERTY(QString misspelledWord READ misspelledWord NOTIFY misspelledWordChanged FINAL REVISION 1)
+ Q_PROPERTY(QStringList spellCheckerSuggestions READ spellCheckerSuggestions NOTIFY spellCheckerSuggestionsChanged FINAL REVISION 1)
bool isValid() const;
@@ -103,6 +105,9 @@ public:
MediaType mediaType() const;
bool isContentEditable() const;
+ QString misspelledWord() const;
+ QStringList spellCheckerSuggestions() const;
+
Q_SIGNALS:
void isValidChanged();
void positionChanged();
@@ -112,6 +117,8 @@ Q_SIGNALS:
void mediaUrlChanged();
void mediaTypeChanged();
void isContentEditableChanged();
+ Q_REVISION(1) void misspelledWordChanged();
+ Q_REVISION(1) void spellCheckerSuggestionsChanged();
private:
void update(const QtWebEngineCore::WebEngineContextMenuData &update);
diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp
index c26255e3a..c0bca8977 100644
--- a/src/webengine/api/qquickwebenginedownloaditem.cpp
+++ b/src/webengine/api/qquickwebenginedownloaditem.cpp
@@ -66,6 +66,7 @@ QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWeb
, downloadId(-1)
, downloadState(QQuickWebEngineDownloadItem::DownloadCancelled)
, savePageFormat(QQuickWebEngineDownloadItem::UnknownSaveFormat)
+ , type(QQuickWebEngineDownloadItem::Attachment)
, totalBytes(-1)
, receivedBytes(0)
{
@@ -295,6 +296,29 @@ void QQuickWebEngineDownloadItem::setSavePageFormat(QQuickWebEngineDownloadItem:
}
}
+/*!
+ \qmlproperty enumeration WebEngineDownloadItem::type
+ \readonly
+ \since QtWebEngine 1.4
+
+ Describes the requested download's type.
+
+ \value Attachment The web server's response includes a \c Content-Disposition header with the \c attachment directive.
+ If \c Content-Disposition is present in the reply, the web server is indicating that
+ the client should prompt the user to save the content regardless of the content type.
+ See \l {RFC 2616 section 19.5.1} for details.
+ \value DownloadAttribute The user clicked the hyperlink.
+ See \l {HTML download Attribute} for details.
+ \value UserRequested The user initiated the download.
+ \value SavePage The user saved a web page.
+ */
+
+QQuickWebEngineDownloadItem::DownloadType QQuickWebEngineDownloadItem::type() const
+{
+ Q_D(const QQuickWebEngineDownloadItem);
+ return d->type;
+}
+
QQuickWebEngineDownloadItem::QQuickWebEngineDownloadItem(QQuickWebEngineDownloadItemPrivate *p, QObject *parent)
: QObject(parent)
, d_ptr(p)
diff --git a/src/webengine/api/qquickwebenginedownloaditem_p.h b/src/webengine/api/qquickwebenginedownloaditem_p.h
index 0b01fe6fc..61e019b9e 100644
--- a/src/webengine/api/qquickwebenginedownloaditem_p.h
+++ b/src/webengine/api/qquickwebenginedownloaditem_p.h
@@ -82,6 +82,14 @@ public:
};
Q_ENUM(SavePageFormat)
+ enum DownloadType {
+ Attachment = 0,
+ DownloadAttribute,
+ UserRequested,
+ SavePage
+ };
+ Q_ENUM(DownloadType)
+
Q_PROPERTY(quint32 id READ id CONSTANT FINAL)
Q_PROPERTY(DownloadState state READ state NOTIFY stateChanged)
Q_PROPERTY(SavePageFormat savePageFormat READ savePageFormat WRITE setSavePageFormat NOTIFY savePageFormatChanged REVISION 2 FINAL)
@@ -89,6 +97,7 @@ public:
Q_PROPERTY(qint64 receivedBytes READ receivedBytes NOTIFY receivedBytesChanged)
Q_PROPERTY(QString mimeType READ mimeType NOTIFY mimeTypeChanged REVISION 1)
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
+ Q_PROPERTY(DownloadType type READ type NOTIFY typeChanged REVISION 3 FINAL)
Q_INVOKABLE void accept();
Q_INVOKABLE void cancel();
@@ -102,6 +111,7 @@ public:
void setPath(QString path);
SavePageFormat savePageFormat() const;
void setSavePageFormat(SavePageFormat format);
+ DownloadType type() const;
Q_SIGNALS:
void stateChanged();
@@ -110,6 +120,7 @@ Q_SIGNALS:
void totalBytesChanged();
Q_REVISION(1) void mimeTypeChanged();
void pathChanged();
+ Q_REVISION(3) void typeChanged();
private:
QQuickWebEngineDownloadItem(QQuickWebEngineDownloadItemPrivate*, QObject *parent = 0);
diff --git a/src/webengine/api/qquickwebenginedownloaditem_p_p.h b/src/webengine/api/qquickwebenginedownloaditem_p_p.h
index bdae54ca4..1789af462 100644
--- a/src/webengine/api/qquickwebenginedownloaditem_p_p.h
+++ b/src/webengine/api/qquickwebenginedownloaditem_p_p.h
@@ -73,6 +73,7 @@ public:
quint32 downloadId;
QQuickWebEngineDownloadItem::DownloadState downloadState;
QQuickWebEngineDownloadItem::SavePageFormat savePageFormat;
+ QQuickWebEngineDownloadItem::DownloadType type;
qint64 totalBytes;
qint64 receivedBytes;
QString mimeType;
diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp
index c1f8f3179..e4141c575 100644
--- a/src/webengine/api/qquickwebengineprofile.cpp
+++ b/src/webengine/api/qquickwebengineprofile.cpp
@@ -180,6 +180,7 @@ void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info)
itemPrivate->downloadPath = info.path;
itemPrivate->savePageFormat = static_cast<QQuickWebEngineDownloadItem::SavePageFormat>(
info.savePageFormat);
+ itemPrivate->type = static_cast<QQuickWebEngineDownloadItem::DownloadType>(info.downloadType);
QQuickWebEngineDownloadItem *download = new QQuickWebEngineDownloadItem(itemPrivate, q);
@@ -613,6 +614,85 @@ QQuickWebEngineProfile *QQuickWebEngineProfile::defaultProfile()
}
/*!
+ \property QQuickWebEngineProfile::spellCheckLanguage
+ \brief the language used by the spell checker.
+
+ \since QtWebEngine 1.4
+*/
+
+/*!
+ \qmlproperty QString WebEngineProfile::spellCheckLanguage
+
+ This property holds the language used by the spell checker.
+ The language should match the name of the \c .bdic dictionary.
+ For example, the \a language \c en-US will load the \c en-US.bdic
+ dictionary file.
+
+ The web engine checks for the \c qtwebengine_dictionaries subdirectory
+ first in the local directory and if it is not found in the Qt
+ installation directory:
+
+ \list
+ \li QCoreApplication::applicationDirPath()/qtwebengine_dictionaries
+ \li [QLibraryInfo::DataPath]/qtwebengine_dictionaries
+ \endlist
+
+ For more information about how to compile \c .bdic dictionaries, see the
+ \l{WebEngine Widgets Spellchecker Example}{Spellchecker Example}.
+
+ \since QtWebEngine 1.4
+*/
+void QQuickWebEngineProfile::setSpellCheckLanguage(const QString &language)
+{
+ Q_D(QQuickWebEngineProfile);
+ if (language != d->browserContext()->spellCheckLanguage()) {
+ d->browserContext()->setSpellCheckLanguage(language);
+ emit spellCheckLanguageChanged();
+ }
+}
+
+/*!
+ \since 5.8
+
+ Returns the language used by the spell checker.
+*/
+QString QQuickWebEngineProfile::spellCheckLanguage() const
+{
+ const Q_D(QQuickWebEngineProfile);
+ return d->browserContext()->spellCheckLanguage();
+}
+
+/*!
+ \property QQuickWebEngineProfile::spellCheckEnabled
+ \brief whether the web engine spell checker is enabled.
+
+ \since QtWebEngine 1.4
+*/
+
+/*!
+ \qmlproperty QString WebEngineProfile::spellCheckEnabled
+
+ This property holds whether the web engine spell checker is enabled.
+
+ \since QtWebEngine 1.4
+*/
+void QQuickWebEngineProfile::setSpellCheckEnabled(bool enable)
+{
+ Q_D(QQuickWebEngineProfile);
+ if (enable != isSpellCheckEnabled()) {
+ d->browserContext()->setSpellCheckEnabled(enable);
+ emit spellCheckEnabledChanged();
+ }
+}
+
+bool QQuickWebEngineProfile::isSpellCheckEnabled() const
+{
+ const Q_D(QQuickWebEngineProfile);
+ return d->browserContext()->isSpellCheckEnabled();
+}
+
+/*!
+
Returns the cookie store for this profile.
*/
QWebEngineCookieStore *QQuickWebEngineProfile::cookieStore() const
diff --git a/src/webengine/api/qquickwebengineprofile.h b/src/webengine/api/qquickwebengineprofile.h
index dc5aa7df8..2b0dbf9d4 100644
--- a/src/webengine/api/qquickwebengineprofile.h
+++ b/src/webengine/api/qquickwebengineprofile.h
@@ -71,6 +71,8 @@ class Q_WEBENGINE_EXPORT QQuickWebEngineProfile : public QObject {
Q_PROPERTY(QString httpAcceptLanguage READ httpAcceptLanguage WRITE setHttpAcceptLanguage NOTIFY httpAcceptLanguageChanged FINAL REVISION 1)
Q_PROPERTY(PersistentCookiesPolicy persistentCookiesPolicy READ persistentCookiesPolicy WRITE setPersistentCookiesPolicy NOTIFY persistentCookiesPolicyChanged FINAL)
Q_PROPERTY(int httpCacheMaximumSize READ httpCacheMaximumSize WRITE setHttpCacheMaximumSize NOTIFY httpCacheMaximumSizeChanged FINAL)
+ Q_PROPERTY(QString spellCheckLanguage READ spellCheckLanguage WRITE setSpellCheckLanguage NOTIFY spellCheckLanguageChanged FINAL REVISION 3)
+ Q_PROPERTY(bool spellCheckEnabled READ isSpellCheckEnabled WRITE setSpellCheckEnabled NOTIFY spellCheckEnabledChanged FINAL REVISION 3)
public:
QQuickWebEngineProfile(QObject *parent = Q_NULLPTR);
@@ -129,6 +131,11 @@ public:
Q_REVISION(2) Q_INVOKABLE void clearHttpCache();
+ Q_REVISION(3) void setSpellCheckLanguage(const QString &language);
+ Q_REVISION(3) QString spellCheckLanguage() const;
+ Q_REVISION(3) void setSpellCheckEnabled(bool enabled);
+ Q_REVISION(3) bool isSpellCheckEnabled() const;
+
static QQuickWebEngineProfile *defaultProfile();
Q_SIGNALS:
@@ -141,6 +148,8 @@ Q_SIGNALS:
void persistentCookiesPolicyChanged();
void httpCacheMaximumSizeChanged();
Q_REVISION(1) void httpAcceptLanguageChanged();
+ Q_REVISION(3) void spellCheckLanguageChanged();
+ Q_REVISION(3) void spellCheckEnabledChanged();
void downloadRequested(QQuickWebEngineDownloadItem *download);
void downloadFinished(QQuickWebEngineDownloadItem *download);
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 67a41f659..02484548b 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -233,7 +233,16 @@ bool QQuickWebEngineViewPrivate::contextMenuRequested(const WebEngineContextMenu
// Populate our menu
MenuItemHandler *item = 0;
-
+ if (contextMenuData.isContentEditable() && !contextMenuData.spellCheckerSuggestions().isEmpty()) {
+ const QPointer<QQuickWebEngineView> qRef(q);
+ for (int i=0; i < contextMenuData.spellCheckerSuggestions().count() && i < 4; i++) {
+ item = new MenuItemHandler(menu);
+ QString replacement = contextMenuData.spellCheckerSuggestions().at(i);
+ QObject::connect(item, &MenuItemHandler::triggered, [qRef, replacement] { qRef->replaceMisspelledWord(replacement); });
+ ui()->addMenuItem(item, replacement);
+ }
+ ui()->addMenuSeparator(menu);
+ }
if (!data.linkText.isEmpty() && data.linkUrl.isValid()) {
item = new MenuItemHandler(menu);
QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::OpenLinkInThisWindow); });
@@ -252,6 +261,10 @@ bool QQuickWebEngineViewPrivate::contextMenuRequested(const WebEngineContextMenu
item = new MenuItemHandler(menu);
QObject::connect(item, &MenuItemHandler::triggered, q, &QQuickWebEngineView::reload);
ui()->addMenuItem(item, QQuickWebEngineView::tr("Reload"), QStringLiteral("view-refresh"));
+
+ item = new MenuItemHandler(menu);
+ QObject::connect(item, &MenuItemHandler::triggered, q, &QQuickWebEngineView::viewSource);
+ ui()->addMenuItem(item, QQuickWebEngineView::tr("View Page Source"), QStringLiteral("view-source"), q->canViewSource());
} else {
item = new MenuItemHandler(menu);
QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::Copy); });
@@ -1131,6 +1144,11 @@ bool QQuickWebEngineViewPrivate::isEnabled() const
return q->isEnabled();
}
+void QQuickWebEngineViewPrivate::setToolTip(const QString &toolTipText)
+{
+ ui()->showToolTip(toolTipText);
+}
+
bool QQuickWebEngineView::isLoading() const
{
Q_D(const QQuickWebEngineView);
@@ -1292,6 +1310,24 @@ void QQuickWebEngineView::printToPdf(const QJSValue &callback, PrintedPageSizeId
d->m_callbacks.insert(requestId, callback);
}
+void QQuickWebEngineView::replaceMisspelledWord(const QString &replacement)
+{
+ Q_D(QQuickWebEngineView);
+ d->adapter->replaceMisspelling(replacement);
+}
+
+void QQuickWebEngineView::viewSource()
+{
+ Q_D(QQuickWebEngineView);
+ d->adapter->viewSource();
+}
+
+bool QQuickWebEngineView::canViewSource() const
+{
+ Q_D(const QQuickWebEngineView);
+ return d->adapter->canViewSource();
+}
+
bool QQuickWebEngineView::isFullScreen() const
{
Q_D(const QQuickWebEngineView);
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index b9555d2d9..dc693a94c 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -94,7 +94,7 @@ private:
const bool m_toggleOn;
};
-#define LATEST_WEBENGINEVIEW_REVISION 3
+#define LATEST_WEBENGINEVIEW_REVISION 4
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_OBJECT
@@ -119,6 +119,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_PROPERTY(bool audioMuted READ isAudioMuted WRITE setAudioMuted NOTIFY audioMutedChanged FINAL REVISION 3)
Q_PROPERTY(bool recentlyAudible READ recentlyAudible NOTIFY recentlyAudibleChanged FINAL REVISION 3)
Q_PROPERTY(uint webChannelWorld READ webChannelWorld WRITE setWebChannelWorld NOTIFY webChannelWorldChanged REVISION 3)
+ Q_PROPERTY(bool canViewSource READ canViewSource FINAL REVISION 4)
#ifdef ENABLE_QML_TESTSUPPORT_API
Q_PROPERTY(QQuickWebEngineTestSupport *testSupport READ testSupport WRITE setTestSupport FINAL)
@@ -145,6 +146,7 @@ public:
void setBackgroundColor(const QColor &color);
QSizeF contentsSize() const;
QPointF scrollPosition() const;
+ bool canViewSource() const;
QQuickWebEngineViewExperimental *experimental() const;
@@ -472,6 +474,9 @@ public Q_SLOTS:
Q_REVISION(2) void triggerWebAction(WebAction action);
Q_REVISION(3) void printToPdf(const QString &filePath, PrintedPageSizeId pageSizeId = PrintedPageSizeId::A4, PrintedPageOrientation orientation = PrintedPageOrientation::Portrait);
Q_REVISION(3) void printToPdf(const QJSValue &callback, PrintedPageSizeId pageSizeId = PrintedPageSizeId::A4, PrintedPageOrientation orientation = PrintedPageOrientation::Portrait);
+ Q_REVISION(4) void replaceMisspelledWord(const QString &replacement);
+ Q_REVISION(4) void viewSource();
+
private Q_SLOTS:
void lazyInitialize();
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 769e41a44..66952ca6e 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -190,6 +190,7 @@ public:
void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions,
const QPixmap &pixmap, const QPoint &offset) Q_DECL_OVERRIDE;
virtual bool isEnabled() const Q_DECL_OVERRIDE;
+ virtual void setToolTip(const QString &toolTipText) Q_DECL_OVERRIDE;
const QObject *holdingQObject() const Q_DECL_OVERRIDE;
virtual QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContextAdapter() Q_DECL_OVERRIDE;
diff --git a/src/webengine/doc/qtwebengine.qdocconf b/src/webengine/doc/qtwebengine.qdocconf
index 009902080..5e738f98d 100644
--- a/src/webengine/doc/qtwebengine.qdocconf
+++ b/src/webengine/doc/qtwebengine.qdocconf
@@ -66,6 +66,7 @@ exampledirs += . \
../../core/doc/snippets \
../../webenginewidgets/doc/snippets
+examples.fileextensions += *.aff *.dic
imagedirs += images
diff --git a/src/webengine/doc/src/external-resources.qdoc b/src/webengine/doc/src/external-resources.qdoc
index c4cfe24af..2ef88e8a4 100644
--- a/src/webengine/doc/src/external-resources.qdoc
+++ b/src/webengine/doc/src/external-resources.qdoc
@@ -90,6 +90,11 @@
\title Shaka Player
*/
+/*!
+ \externalpage https://sourceforge.net/projects/hunspell/
+ \title Hunspell Project
+*/
+
/*
This prevents autolinking of each occurrence of 'WebEngine'
To link to the WebEngine QML type, use explicit linking:
@@ -101,3 +106,13 @@
\title WebEngine
\internal
*/
+
+/*!
+ \externalpage https://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1
+ \title RFC 2616 section 19.5.1
+*/
+
+/*!
+ \externalpage http://www.w3schools.com/tags/att_a_download.asp
+ \title HTML download Attribute
+*/
diff --git a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc
index 66e733fa9..b66e7874d 100644
--- a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc
+++ b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc
@@ -117,8 +117,8 @@
On OS X, the following are required:
\list
- \li OS X 10.9 or later
- \li Xcode 6.1 or later
+ \li OS X 10.10 or later
+ \li Xcode 6.3 or later
\li OS X 10.10 SDK or later
\endlist
diff --git a/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc b/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc
index 87022262d..9d22d3f36 100644
--- a/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc
+++ b/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc
@@ -24,7 +24,7 @@
*/
/*!
- \qmlmodule QtWebEngine 1.3
+ \qmlmodule QtWebEngine 1.4
\title Qt WebEngine QML Types
\brief Provides QML types for rendering web content within a QML application
\ingroup qtwebengine-modules
@@ -33,7 +33,7 @@
your .qml file:
\badcode
- import QtWebEngine 1.3
+ import QtWebEngine 1.4
\endcode
To link against the module, add the following QT variable to your qmake .pro
diff --git a/src/webengine/doc/src/webengineview.qdoc b/src/webengine/doc/src/webengineview.qdoc
index 63b6e30d1..6fd9ba45b 100644
--- a/src/webengine/doc/src/webengineview.qdoc
+++ b/src/webengine/doc/src/webengineview.qdoc
@@ -1117,3 +1117,20 @@
Also if the audio is paused, this signal is emitted with an approximate \b{2 second
delay}, from the moment the audio is paused.
*/
+
+/*!
+ \qmlmethod void WebEngineView::viewSource()
+ \since QtWebEngine 1.4
+
+ Shows the source of the current page in a new tab.
+
+ \sa canViewSource
+*/
+
+/*!
+ \qmlproperty bool WebEngineView::canViewSource
+ \brief This property holds whether the source for the current page can be viewed.
+ \since QtWebEngine 1.4
+
+ \sa viewSource()
+*/
diff --git a/src/webengine/plugin/experimental/plugin.cpp b/src/webengine/plugin/experimental/plugin.cpp
index c45bcee43..d4f68d142 100644
--- a/src/webengine/plugin/experimental/plugin.cpp
+++ b/src/webengine/plugin/experimental/plugin.cpp
@@ -72,9 +72,10 @@ public:
tr("Cannot create a separate instance of WebEngineViewport"));
qmlRegisterUncreatableType<const QQuickWebEngineContextMenuData>(uri, 1, 0, "WebEngineContextMenuData",
tr("Cannot create a separate instance of WebEngineContextMenuData"));
-
+ qmlRegisterUncreatableType<const QQuickWebEngineContextMenuData, 1>(uri, 1, 1, "WebEngineContextMenuData",
+ tr("Cannot create a separate instance of WebEngineContextMenuData"));
// Use the latest revision of QQuickWebEngineView when importing QtWebEngine.experimental 1.0
- qmlRegisterRevision<QQuickWebEngineView, LATEST_WEBENGINEVIEW_REVISION>(uri, 1, 0);
+ qmlRegisterRevision<QQuickWebEngineView, LATEST_WEBENGINEVIEW_REVISION>(uri, 1, 1);
}
};
diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp
index b71689a34..2f7d2c2c4 100644
--- a/src/webengine/plugin/plugin.cpp
+++ b/src/webengine/plugin/plugin.cpp
@@ -81,9 +81,11 @@ public:
qmlRegisterType<QQuickWebEngineView, 1>(uri, 1, 1, "WebEngineView");
qmlRegisterType<QQuickWebEngineView, 2>(uri, 1, 2, "WebEngineView");
qmlRegisterType<QQuickWebEngineView, 3>(uri, 1, 3, "WebEngineView");
+ qmlRegisterType<QQuickWebEngineView, 4>(uri, 1, 4, "WebEngineView");
qmlRegisterType<QQuickWebEngineProfile>(uri, 1, 1, "WebEngineProfile");
qmlRegisterType<QQuickWebEngineProfile, 1>(uri, 1, 2, "WebEngineProfile");
qmlRegisterType<QQuickWebEngineProfile, 2>(uri, 1, 3, "WebEngineProfile");
+ qmlRegisterType<QQuickWebEngineProfile, 3>(uri, 1, 4, "WebEngineProfile");
qmlRegisterType<QQuickWebEngineScript>(uri, 1, 1, "WebEngineScript");
qmlRegisterUncreatableType<QQuickWebEngineCertificateError>(uri, 1, 1, "WebEngineCertificateError", tr("Cannot create separate instance of WebEngineCertificateError"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem>(uri, 1, 1, "WebEngineDownloadItem",
@@ -92,6 +94,8 @@ public:
tr("Cannot create a separate instance of WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 2>(uri, 1, 3, "WebEngineDownloadItem",
tr("Cannot create a separate instance of WebEngineDownloadItem"));
+ qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 3>(uri, 1, 4, "WebEngineDownloadItem",
+ tr("Cannot create a separate instance of WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineNewViewRequest>(uri, 1, 1, "WebEngineNewViewRequest", tr("Cannot create separate instance of WebEngineNewViewRequest"));
qmlRegisterUncreatableType<QQuickWebEngineSettings>(uri, 1, 1, "WebEngineSettings", tr("Cannot create a separate instance of WebEngineSettings"));
qmlRegisterUncreatableType<QQuickWebEngineSettings, 1>(uri, 1, 2, "WebEngineSettings", tr("Cannot create a separate instance of WebEngineSettings"));
diff --git a/src/webengine/plugin/plugin.pro b/src/webengine/plugin/plugin.pro
index 2fbadfc97..56eb7bd3c 100644
--- a/src/webengine/plugin/plugin.pro
+++ b/src/webengine/plugin/plugin.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = qtwebengineplugin
TARGETPATH = QtWebEngine
-IMPORT_VERSION = 1.3
+IMPORT_VERSION = 1.4
QT += webengine qml quick
QT_PRIVATE += webengine-private
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
index d0bd67e6a..c04e20a5e 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
+++ b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
@@ -50,6 +50,11 @@
#include <private/qquickwindow_p.h>
#include <private/qsgcontext_p.h>
+#if (QT_VERSION < QT_VERSION_CHECK(5, 8, 0))
+#include <QSGSimpleRectNode>
+#include <QSGSimpleTextureNode>
+#endif
+
namespace QtWebEngineCore {
RenderWidgetHostViewQtDelegateQuick::RenderWidgetHostViewQtDelegateQuick(RenderWidgetHostViewQtDelegateClient *client, bool isPopup)
@@ -177,10 +182,32 @@ QSGLayer *RenderWidgetHostViewQtDelegateQuick::createLayer()
return renderContext->sceneGraphContext()->createLayer(renderContext);
}
-QSGImageNode *RenderWidgetHostViewQtDelegateQuick::createImageNode()
+QSGInternalImageNode *RenderWidgetHostViewQtDelegateQuick::createImageNode()
{
QSGRenderContext *renderContext = QQuickWindowPrivate::get(QQuickItem::window())->context;
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
+ return renderContext->sceneGraphContext()->createInternalImageNode();
+#else
return renderContext->sceneGraphContext()->createImageNode();
+#endif
+}
+
+QSGTextureNode *RenderWidgetHostViewQtDelegateQuick::createTextureNode()
+{
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
+ return QQuickItem::window()->createImageNode();
+#else
+ return new QSGSimpleTextureNode();
+#endif
+}
+
+QSGRectangleNode *RenderWidgetHostViewQtDelegateQuick::createRectangleNode()
+{
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
+ return QQuickItem::window()->createRectangleNode();
+#else
+ return new QSGSimpleRectNode();
+#endif
}
void RenderWidgetHostViewQtDelegateQuick::update()
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.h b/src/webengine/render_widget_host_view_qt_delegate_quick.h
index c51ca3408..de3aff291 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quick.h
+++ b/src/webengine/render_widget_host_view_qt_delegate_quick.h
@@ -66,13 +66,14 @@ public:
virtual QWindow* window() const Q_DECL_OVERRIDE;
virtual QSGTexture *createTextureFromImage(const QImage &) Q_DECL_OVERRIDE;
virtual QSGLayer *createLayer() Q_DECL_OVERRIDE;
- virtual QSGImageNode *createImageNode() Q_DECL_OVERRIDE;
+ virtual QSGInternalImageNode *createImageNode() Q_DECL_OVERRIDE;
+ virtual QSGTextureNode *createTextureNode() Q_DECL_OVERRIDE;
+ virtual QSGRectangleNode *createRectangleNode() Q_DECL_OVERRIDE;
virtual void update() Q_DECL_OVERRIDE;
virtual void updateCursor(const QCursor &) Q_DECL_OVERRIDE;
virtual void resize(int width, int height) Q_DECL_OVERRIDE;
virtual void move(const QPoint&) Q_DECL_OVERRIDE { }
virtual void inputMethodStateChanged(bool editorVisible) Q_DECL_OVERRIDE;
- virtual void setTooltip(const QString&) Q_DECL_OVERRIDE { }
// The QtQuick view doesn't have a backbuffer of its own and doesn't need this
virtual void setClearColor(const QColor &) Q_DECL_OVERRIDE { }
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp
index 64839c9fa..7b7d32d67 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp
+++ b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp
@@ -111,11 +111,21 @@ QSGLayer *RenderWidgetHostViewQtDelegateQuickWindow::createLayer()
return m_realDelegate->createLayer();
}
-QSGImageNode *RenderWidgetHostViewQtDelegateQuickWindow::createImageNode()
+QSGInternalImageNode *RenderWidgetHostViewQtDelegateQuickWindow::createImageNode()
{
return m_realDelegate->createImageNode();
}
+QSGTextureNode *RenderWidgetHostViewQtDelegateQuickWindow::createTextureNode()
+{
+ return m_realDelegate->createTextureNode();
+}
+
+QSGRectangleNode *RenderWidgetHostViewQtDelegateQuickWindow::createRectangleNode()
+{
+ return m_realDelegate->createRectangleNode();
+}
+
void RenderWidgetHostViewQtDelegateQuickWindow::update()
{
QQuickWindow::update();
@@ -138,9 +148,4 @@ void RenderWidgetHostViewQtDelegateQuickWindow::move(const QPoint &screenPos)
QQuickWindow::setPosition(screenPos);
}
-void RenderWidgetHostViewQtDelegateQuickWindow::setTooltip(const QString &tooltip)
-{
- Q_UNUSED(tooltip);
-}
-
} // namespace QtWebEngineCore
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h
index 699b4ce9e..d0a5e480c 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h
+++ b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h
@@ -69,13 +69,14 @@ public:
virtual QWindow* window() const Q_DECL_OVERRIDE;
virtual QSGTexture *createTextureFromImage(const QImage &) Q_DECL_OVERRIDE;
virtual QSGLayer *createLayer() Q_DECL_OVERRIDE;
- virtual QSGImageNode *createImageNode() Q_DECL_OVERRIDE;
+ virtual QSGInternalImageNode *createImageNode() Q_DECL_OVERRIDE;
+ virtual QSGTextureNode *createTextureNode() Q_DECL_OVERRIDE;
+ virtual QSGRectangleNode *createRectangleNode() Q_DECL_OVERRIDE;
virtual void update() Q_DECL_OVERRIDE;
virtual void updateCursor(const QCursor &) Q_DECL_OVERRIDE;
virtual void resize(int width, int height) Q_DECL_OVERRIDE;
virtual void move(const QPoint &screenPos) Q_DECL_OVERRIDE;
virtual void inputMethodStateChanged(bool) Q_DECL_OVERRIDE {}
- virtual void setTooltip(const QString &tooltip) Q_DECL_OVERRIDE;
virtual void setClearColor(const QColor &) Q_DECL_OVERRIDE { }
private:
diff --git a/src/webengine/ui/ToolTip.qml b/src/webengine/ui/ToolTip.qml
new file mode 100644
index 000000000..96033e8f1
--- /dev/null
+++ b/src/webengine/ui/ToolTip.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.5
+
+Item {
+ id: toolTipContainer
+ z: 9999
+ width: content.width
+ height: content.height
+ visible: false
+
+ property alias text: toolTip.text
+ property int delayTimerInterval: 1000
+ property int hideTimerInterval: 1500
+
+ Timer {
+ id: delayTimer
+ interval: delayTimerInterval
+ onTriggered: {
+ toolTipContainer.visible = true
+ hideTimer.start()
+ }
+ }
+
+ Timer {
+ id: hideTimer
+ interval: hideTimerInterval
+ onTriggered: toolTipContainer.visible = false
+ }
+
+ Rectangle {
+ id: content
+ color: "#f8eabf"
+ border.color: "black"
+ anchors.centerIn: parent
+ width: toolTip.contentWidth + 10
+ height: toolTip.contentHeight + 10
+ radius: 3
+
+ Text {
+ id: toolTip
+ anchors {fill: parent; margins: 5}
+ wrapMode: Text.WrapAnywhere
+ }
+ }
+
+ function open() {
+ delayTimer.start();
+ }
+
+ function hide() {
+ hideTimer.start();
+ }
+}
diff --git a/src/webengine/ui/ui.pro b/src/webengine/ui/ui.pro
index 249d7dcfd..60dab61d6 100644
--- a/src/webengine/ui/ui.pro
+++ b/src/webengine/ui/ui.pro
@@ -14,6 +14,7 @@ QML_FILES += \
MenuItem.qml \
MenuSeparator.qml \
# Message Bubble
- MessageBubble.qml
+ MessageBubble.qml \
+ ToolTip.qml
load(qml_module)
diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp
index 6ff12b53f..769a30016 100644
--- a/src/webengine/ui_delegates_manager.cpp
+++ b/src/webengine/ui_delegates_manager.cpp
@@ -50,6 +50,10 @@
#include <QQmlContext>
#include <QQmlEngine>
#include <QQmlProperty>
+#include <QCursor>
+#include <QList>
+#include <QScreen>
+#include <QGuiApplication>
// Uncomment for QML debugging
//#define UI_DELEGATES_DEBUG
@@ -93,6 +97,31 @@ static QString getUIDelegatesImportDir(QQmlEngine *engine) {
return importDir;
}
+static QPoint calculateToolTipPosition(QPoint &position, QSize &toolTip) {
+ QRect screen;
+ QList<QScreen *> screens = QGuiApplication::screens();
+ Q_FOREACH (const QScreen *src, screens)
+ if (src->availableGeometry().contains(position))
+ screen = src->availableGeometry();
+
+ position += QPoint(2, 16);
+
+ if (position.x() + toolTip.width() > screen.x() + screen.width())
+ position.rx() -= 4 + toolTip.width();
+ if (position.y() + toolTip.height() > screen.y() + screen.height())
+ position.ry() -= 24 + toolTip.height();
+ if (position.y() < screen.y())
+ position.setY(screen.y());
+ if (position.x() + toolTip.width() > screen.x() + screen.width())
+ position.setX(screen.x() + screen.width() - toolTip.width());
+ if (position.x() < screen.x())
+ position.setX(screen.x());
+ if (position.y() + toolTip.height() > screen.y() + screen.height())
+ position.setY(screen.y() + screen.height() - toolTip.height());
+
+ return position;
+}
+
const char *defaultPropertyName(QObject *obj)
{
const QMetaObject *metaObject = obj->metaObject();
@@ -116,6 +145,7 @@ MenuItemHandler::MenuItemHandler(QObject *parent)
UIDelegatesManager::UIDelegatesManager(QQuickWebEngineView *view)
: m_view(view)
, m_messageBubbleItem(0)
+ , m_toolTip(nullptr)
FOR_EACH_COMPONENT_TYPE(COMPONENT_MEMBER_INIT, NO_SEPARATOR)
{
}
@@ -493,4 +523,38 @@ void UIDelegatesManager::moveMessageBubble(const QRect &anchor)
QQmlProperty(m_messageBubbleItem.data(), QStringLiteral("y")).write(anchor.y() + anchor.size().height());
}
+void UIDelegatesManager::showToolTip(const QString &text)
+{
+ if (!ensureComponentLoaded(ToolTip))
+ return;
+
+ if (text.isEmpty()) {
+ m_toolTip.reset();
+ return;
+ }
+
+ if (!m_toolTip.isNull())
+ return;
+
+ QQmlContext *context = qmlContext(m_view);
+ m_toolTip.reset(toolTipComponent->beginCreate(context));
+ if (QQuickItem *item = qobject_cast<QQuickItem *>(m_toolTip.data()))
+ item->setParentItem(m_view);
+ m_toolTip->setParent(m_view);
+ toolTipComponent->completeCreate();
+
+ QQmlProperty(m_toolTip.data(), QStringLiteral("text")).write(text);
+
+ int height = QQmlProperty(m_toolTip.data(), QStringLiteral("height")).read().toInt();
+ int width = QQmlProperty(m_toolTip.data(), QStringLiteral("width")).read().toInt();
+ QSize toolTipSize(width, height);
+ QPoint position = m_view->cursor().pos();
+ position = m_view->mapFromGlobal(calculateToolTipPosition(position, toolTipSize)).toPoint();
+
+ QQmlProperty(m_toolTip.data(), QStringLiteral("x")).write(position.x());
+ QQmlProperty(m_toolTip.data(), QStringLiteral("y")).write(position.y());
+
+ QMetaObject::invokeMethod(m_toolTip.data(), "open");
+}
+
} // namespace QtWebEngineCore
diff --git a/src/webengine/ui_delegates_manager.h b/src/webengine/ui_delegates_manager.h
index b63aa91f1..43d1e6985 100644
--- a/src/webengine/ui_delegates_manager.h
+++ b/src/webengine/ui_delegates_manager.h
@@ -59,7 +59,8 @@
F(PromptDialog, promptDialog) SEPARATOR \
F(FilePicker, filePicker) SEPARATOR \
F(MessageBubble, messageBubble) SEPARATOR \
- F(AuthenticationDialog, authenticationDialog) SEPARATOR
+ F(AuthenticationDialog, authenticationDialog) SEPARATOR \
+ F(ToolTip, toolTip) SEPARATOR \
#define COMMA_SEPARATOR ,
#define SEMICOLON_SEPARATOR ;
@@ -115,12 +116,14 @@ public:
void showMessageBubble(const QRect &anchor, const QString &mainText, const QString &subText);
void hideMessageBubble();
void moveMessageBubble(const QRect &anchor);
+ void showToolTip(const QString &text);
private:
bool ensureComponentLoaded(ComponentType);
QQuickWebEngineView *m_view;
QScopedPointer<QQuickItem> m_messageBubbleItem;
+ QScopedPointer<QObject> m_toolTip;
FOR_EACH_COMPONENT_TYPE(MEMBER_DECLARATION, SEMICOLON_SEPARATOR)
diff --git a/src/webenginewidgets/api/qwebenginecontextmenudata.cpp b/src/webenginewidgets/api/qwebenginecontextmenudata.cpp
index c7019977b..808c6f8b0 100644
--- a/src/webenginewidgets/api/qwebenginecontextmenudata.cpp
+++ b/src/webenginewidgets/api/qwebenginecontextmenudata.cpp
@@ -187,6 +187,30 @@ bool QWebEngineContextMenuData::isContentEditable() const
}
/*!
+ If the context is a word considered misspelled by the spell-checker, returns the misspelled word.
+
+ \since 5.8
+*/
+QString QWebEngineContextMenuData::misspelledWord() const
+{
+ if (d)
+ return d->misspelledWord;
+ return QString();
+}
+
+/*!
+ If the context is a word considered misspelled by the spell-checker, returns a list of suggested replacements.
+
+ \since 5.8
+*/
+QStringList QWebEngineContextMenuData::spellCheckerSuggestions() const
+{
+ if (d)
+ return d->spellCheckerSuggestions;
+ return QStringList();
+}
+
+/*!
\internal
*/
QWebEngineContextMenuData &QWebEngineContextMenuData::operator=(const QWebEngineContextDataPrivate &priv)
diff --git a/src/webenginewidgets/api/qwebenginecontextmenudata.h b/src/webenginewidgets/api/qwebenginecontextmenudata.h
index d04b747c8..1a2ff8de4 100644
--- a/src/webenginewidgets/api/qwebenginecontextmenudata.h
+++ b/src/webenginewidgets/api/qwebenginecontextmenudata.h
@@ -76,6 +76,8 @@ public:
QUrl mediaUrl() const;
MediaType mediaType() const;
bool isContentEditable() const;
+ QString misspelledWord() const;
+ QStringList spellCheckerSuggestions() const;
private:
void reset();
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp
index bfb0dd0e8..6f7865a50 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp
+++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp
@@ -80,6 +80,7 @@ QWebEngineDownloadItemPrivate::QWebEngineDownloadItemPrivate(QWebEngineProfilePr
, downloadId(-1)
, downloadState(QWebEngineDownloadItem::DownloadCancelled)
, savePageFormat(QWebEngineDownloadItem::MimeHtmlSaveFormat)
+ , type(QWebEngineDownloadItem::Attachment)
, downloadUrl(url)
, totalBytes(-1)
, receivedBytes(0)
@@ -218,6 +219,22 @@ quint32 QWebEngineDownloadItem::id() const
*/
/*!
+ \enum QWebEngineDownloadItem::DownloadType
+ \since 5.8
+
+ Describes the requested download's type.
+
+ \value Attachment The web server's response includes a \c Content-Disposition header with the \c attachment directive.
+ If \c Content-Disposition is present in the reply, the web server is indicating that
+ the client should prompt the user to save the content regardless of the content type.
+ See \l {RFC 2616 section 19.5.1} for details.
+ \value DownloadAttribute The user clicked the hyperlink.
+ See \l {HTML download Attribute} for details.
+ \value UserRequested The user initiated the download.
+ \value SavePage The user saved a web page.
+*/
+
+/*!
Returns the download item's current state.
\sa QWebEngineDownloadItem::DownloadState
@@ -342,6 +359,18 @@ void QWebEngineDownloadItem::setSavePageFormat(QWebEngineDownloadItem::SavePageF
d->savePageFormat = format;
}
+/*!
+ Returns the requested download's type.
+ \since 5.8
+
+ */
+
+QWebEngineDownloadItem::DownloadType QWebEngineDownloadItem::type() const
+{
+ Q_D(const QWebEngineDownloadItem);
+ return d->type;
+}
+
QWebEngineDownloadItem::QWebEngineDownloadItem(QWebEngineDownloadItemPrivate *p, QObject *parent)
: QObject(parent)
, d_ptr(p)
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.h b/src/webenginewidgets/api/qwebenginedownloaditem.h
index 80b5c06c5..4b58748ad 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem.h
+++ b/src/webenginewidgets/api/qwebenginedownloaditem.h
@@ -72,6 +72,14 @@ public:
};
Q_ENUM(SavePageFormat)
+ enum DownloadType {
+ Attachment = 0,
+ DownloadAttribute,
+ UserRequested,
+ SavePage
+ };
+ Q_ENUM(DownloadType)
+
quint32 id() const;
DownloadState state() const;
qint64 totalBytes() const;
@@ -83,6 +91,7 @@ public:
bool isFinished() const;
SavePageFormat savePageFormat() const;
void setSavePageFormat(SavePageFormat format);
+ DownloadType type() const;
public Q_SLOTS:
void accept();
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem_p.h b/src/webenginewidgets/api/qwebenginedownloaditem_p.h
index ddb3b443a..9ddb45444 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem_p.h
+++ b/src/webenginewidgets/api/qwebenginedownloaditem_p.h
@@ -72,6 +72,7 @@ public:
quint32 downloadId;
QWebEngineDownloadItem::DownloadState downloadState;
QWebEngineDownloadItem::SavePageFormat savePageFormat;
+ QWebEngineDownloadItem::DownloadType type;
QString downloadPath;
const QUrl downloadUrl;
QString mimeType;
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index e4b10faa6..c180699f3 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -90,6 +90,8 @@ QT_BEGIN_NAMESPACE
using namespace QtWebEngineCore;
+static const int MaxTooltipLength = 1024;
+
static QWebEnginePage::WebWindowType toWindowType(WebContentsAdapterClient::WindowOpenDisposition disposition)
{
switch (disposition) {
@@ -470,6 +472,9 @@ void QWebEnginePagePrivate::updateAction(QWebEnginePage::WebAction action) const
case QWebEnginePage::ReloadAndBypassCache:
enabled = !isLoading;
break;
+ case QWebEnginePage::ViewSource:
+ enabled = adapter->canViewSource();
+ break;
default:
break;
}
@@ -485,6 +490,7 @@ void QWebEnginePagePrivate::updateNavigationActions()
updateAction(QWebEnginePage::Stop);
updateAction(QWebEnginePage::Reload);
updateAction(QWebEnginePage::ReloadAndBypassCache);
+ updateAction(QWebEnginePage::ViewSource);
}
#ifndef QT_NO_ACTION
@@ -769,6 +775,29 @@ void QWebEnginePage::setBackgroundColor(const QColor &color)
}
/*!
+ * Save the currently loaded web page to disk.
+ *
+ * The web page is saved to \a filePath in the specified \a{format}.
+ *
+ * This is a short cut for the following actions:
+ * \list
+ * \li Trigger the Save web action.
+ * \li Accept the next download item and set the specified file path and save format.
+ * \endlist
+ *
+ * This function issues an asynchronous download request for the web page and returns immediately.
+ *
+ * \sa QWebEngineDownloadItem::SavePageFormat
+ * \since 5.8
+ */
+void QWebEnginePage::save(const QString &filePath,
+ QWebEngineDownloadItem::SavePageFormat format) const
+{
+ Q_D(const QWebEnginePage);
+ d->adapter->save(filePath, format);
+}
+
+/*!
\property QWebEnginePage::audioMuted
\brief whether the current page audio is muted.
\since 5.7
@@ -953,6 +982,9 @@ QAction *QWebEnginePage::action(WebAction action) const
case SavePage:
text = tr("Save &Page");
break;
+ case ViewSource:
+ text = tr("&View Page Source");
+ break;
case NoWebAction:
case WebActionCount:
Q_UNREACHABLE();
@@ -1143,6 +1175,17 @@ void QWebEnginePage::triggerAction(WebAction action, bool)
case SavePage:
d->adapter->save();
break;
+ case ViewSource:
+ // This is a workaround to make the ViewSource action working in a context menu.
+ // The WebContentsAdapter::viewSource() method deletes a
+ // RenderWidgetHostViewQtDelegateWidget instance which passes the control to the event
+ // loop. If the QMenu::aboutToHide() signal is connected to the QObject::deleteLater()
+ // slot the QMenu is deleted by the event handler while the ViewSource action is still not
+ // completed. This may lead to a crash. To avoid this the WebContentsAdapter::viewSource()
+ // method is called indirectly via the QTimer::singleShot() function which schedules the
+ // the viewSource() call after the QMenu's destruction.
+ QTimer::singleShot(0, this, [d](){ d->adapter->viewSource(); });
+ break;
case NoWebAction:
break;
case WebActionCount:
@@ -1151,6 +1194,22 @@ void QWebEnginePage::triggerAction(WebAction action, bool)
}
}
+/*!
+ * \since 5.8
+ * Replace the current misspelled word with \a replacement.
+ *
+ * The current misspelled word can be found in QWebEngineContextMenuData::misspelledWord(),
+ * and suggested replacements in QWebEngineContextMenuData::spellCheckerSuggestions().
+ *
+ * \sa contextMenuData(),
+ */
+
+void QWebEnginePage::replaceMisspelledWord(const QString &replacement)
+{
+ Q_D(QWebEnginePage);
+ d->adapter->replaceMisspelling(replacement);
+}
+
void QWebEnginePage::findText(const QString &subString, FindFlags options, const QWebEngineCallback<bool> &resultCallback)
{
Q_D(QWebEnginePage);
@@ -1332,6 +1391,16 @@ bool QWebEnginePagePrivate::isEnabled() const
return true;
}
+void QWebEnginePagePrivate::setToolTip(const QString &toolTipText)
+{
+ if (view) {
+ QString wrappedTip;
+ if (!toolTipText.isEmpty())
+ wrappedTip = QLatin1String("<p>") % toolTipText.toHtmlEscaped().left(MaxTooltipLength) % QLatin1String("</p>");
+ view->setToolTip(wrappedTip);
+ }
+}
+
QMenu *QWebEnginePage::createStandardContextMenu()
{
Q_D(QWebEnginePage);
@@ -1342,6 +1411,18 @@ QMenu *QWebEnginePage::createStandardContextMenu()
QAction *action = 0;
const WebEngineContextMenuData &contextMenuData = *d->contextData.d;
+ if (contextMenuData.isEditable && !contextMenuData.spellCheckerSuggestions.isEmpty()) {
+ QPointer<QWebEnginePage> thisRef(this);
+ for (int i=0; i < contextMenuData.spellCheckerSuggestions.count() && i < 4; i++) {
+ QAction *action = new QAction(menu);
+ QString replacement = contextMenuData.spellCheckerSuggestions.at(i);
+ QObject::connect(action, &QAction::triggered, [thisRef, replacement] { if (thisRef) thisRef->replaceMisspelledWord(replacement); });
+ action->setText(replacement);
+ menu->addAction(action);
+ }
+ menu->addSeparator();
+ }
+
if (!contextMenuData.linkText.isEmpty() && contextMenuData.linkUrl.isValid()) {
action = QWebEnginePage::action(OpenLinkInThisWindow);
action->setText(tr("Follow Link"));
@@ -1362,6 +1443,8 @@ QMenu *QWebEnginePage::createStandardContextMenu()
action = new QAction(QIcon::fromTheme(QStringLiteral("view-refresh")), tr("&Reload"), menu);
connect(action, &QAction::triggered, d->view, &QWebEngineView::reload);
menu->addAction(action);
+
+ menu->addAction(QWebEnginePage::action(ViewSource));
} else {
menu->addAction(QWebEnginePage::action(Copy));
menu->addAction(QWebEnginePage::action(Unselect));
@@ -1772,6 +1855,31 @@ const QWebEngineContextMenuData &QWebEnginePage::contextMenuData() const
return d->contextData;
}
+/*!
+ \since 5.8
+
+ Shows the source of the current page in a new tab.
+
+ \sa canViewSource
+*/
+void QWebEnginePage::viewSource()
+{
+ triggerAction(QWebEnginePage::ViewSource);
+}
+
+/*!
+ \property QWebEnginePage::canViewSource
+ \brief whether the source for the current page can be viewed.
+ \since 5.8
+
+ \sa viewSource()
+*/
+bool QWebEnginePage::canViewSource() const
+{
+ Q_D(const QWebEnginePage);
+ return d->adapter->canViewSource();
+}
+
QT_END_NAMESPACE
#include "moc_qwebenginepage.cpp"
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index 2ac8e0f3e..bb46cd9fb 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -42,6 +42,7 @@
#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
#include <QtWebEngineWidgets/qwebenginecertificateerror.h>
+#include <QtWebEngineWidgets/qwebenginedownloaditem.h>
#include <QtWebEngineCore/qwebenginecallback.h>
#include <QtCore/qobject.h>
@@ -80,6 +81,7 @@ class QWEBENGINEWIDGETS_EXPORT QWebEnginePage : public QObject {
Q_PROPERTY(QPointF scrollPosition READ scrollPosition NOTIFY scrollPositionChanged)
Q_PROPERTY(bool audioMuted READ isAudioMuted WRITE setAudioMuted NOTIFY audioMutedChanged)
Q_PROPERTY(bool recentlyAudible READ recentlyAudible NOTIFY recentlyAudibleChanged)
+ Q_PROPERTY(bool canViewSource READ canViewSource)
public:
enum WebAction {
@@ -123,6 +125,7 @@ public:
Unselect,
SavePage,
OpenLinkInNewBackgroundTab,
+ ViewSource,
WebActionCount
};
@@ -206,6 +209,8 @@ public:
#endif
virtual void triggerAction(WebAction action, bool checked = false);
+ void replaceMisspelledWord(const QString &replacement);
+
virtual bool event(QEvent*);
#ifdef Q_QDOC
void findText(const QString &subString, FindFlags options = FindFlags());
@@ -261,6 +266,9 @@ public:
QColor backgroundColor() const;
void setBackgroundColor(const QColor &color);
+ void save(const QString &filePath, QWebEngineDownloadItem::SavePageFormat format
+ = QWebEngineDownloadItem::MimeHtmlSaveFormat) const;
+
bool isAudioMuted() const;
void setAudioMuted(bool muted);
bool recentlyAudible() const;
@@ -273,6 +281,8 @@ public:
#endif
const QWebEngineContextMenuData &contextMenuData() const;
+ void viewSource();
+ bool canViewSource() const;
Q_SIGNALS:
void loadStarted();
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 96640a63a..03883bb44 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -141,6 +141,7 @@ public:
void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions,
const QPixmap &pixmap, const QPoint &offset) Q_DECL_OVERRIDE;
virtual bool isEnabled() const Q_DECL_OVERRIDE;
+ virtual void setToolTip(const QString &toolTipText) Q_DECL_OVERRIDE;
const QObject *holdingQObject() const Q_DECL_OVERRIDE;
virtual QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContextAdapter() Q_DECL_OVERRIDE;
diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp
index 664323034..b35fb0cc1 100644
--- a/src/webenginewidgets/api/qwebengineprofile.cpp
+++ b/src/webenginewidgets/api/qwebengineprofile.cpp
@@ -180,10 +180,12 @@ void QWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info)
Q_ASSERT(!m_ongoingDownloads.contains(info.id));
QWebEngineDownloadItemPrivate *itemPrivate = new QWebEngineDownloadItemPrivate(this, info.url);
itemPrivate->downloadId = info.id;
- itemPrivate->downloadState = QWebEngineDownloadItem::DownloadRequested;
+ itemPrivate->downloadState = info.accepted ? QWebEngineDownloadItem::DownloadInProgress
+ : QWebEngineDownloadItem::DownloadRequested;
itemPrivate->downloadPath = info.path;
itemPrivate->mimeType = info.mimeType;
itemPrivate->savePageFormat = static_cast<QWebEngineDownloadItem::SavePageFormat>(info.savePageFormat);
+ itemPrivate->type = static_cast<QWebEngineDownloadItem::DownloadType>(info.downloadType);
QWebEngineDownloadItem *download = new QWebEngineDownloadItem(itemPrivate, q);
@@ -556,6 +558,67 @@ QWebEngineProfile *QWebEngineProfile::defaultProfile()
}
/*!
+ \since 5.8
+
+ Sets the current \a language for the spell checker.
+ The language should match the name of the \c .bdic dictionary.
+ For example, the \a language \c en-US will load the \c en-US.bdic
+ dictionary file.
+
+ The web engine checks for the \c qtwebengine_dictionaries subdirectory
+ first in the local directory and if it is not found in the Qt
+ installation directory:
+
+ \list
+ \li QCoreApplication::applicationDirPath()/qtwebengine_dictionaries
+ \li [QLibraryInfo::DataPath]/qtwebengine_dictionaries
+ \endlist
+
+ For more information about how to compile \c .bdic dictionaries, see the
+ \l{WebEngine Widgets Spellchecker Example}{Spellchecker Example}.
+
+*/
+void QWebEngineProfile::setSpellCheckLanguage(const QString &language)
+{
+ Q_D(QWebEngineProfile);
+ d->browserContext()->setSpellCheckLanguage(language);
+}
+
+/*!
+ \since 5.8
+
+ Returns the language used by the spell checker.
+*/
+QString QWebEngineProfile::spellCheckLanguage() const
+{
+ const Q_D(QWebEngineProfile);
+ return d->browserContext()->spellCheckLanguage();
+}
+
+/*!
+ \since 5.8
+
+ Enables spell checker if \a enable is \c true, otherwise disables it.
+ \sa isSpellCheckEnabled()
+ */
+void QWebEngineProfile::setSpellCheckEnabled(bool enable)
+{
+ Q_D(QWebEngineProfile);
+ d->browserContext()->setSpellCheckEnabled(enable);
+}
+/*!
+ \since 5.8
+
+ Returns \c true if the spell checker is enabled; otherwise returns \c false.
+ \sa setSpellCheckEnabled()
+ */
+bool QWebEngineProfile::isSpellCheckEnabled() const
+{
+ const Q_D(QWebEngineProfile);
+ return d->browserContext()->isSpellCheckEnabled();
+}
+
+/*!
Returns the default settings for all pages in this profile.
*/
QWebEngineSettings *QWebEngineProfile::settings() const
diff --git a/src/webenginewidgets/api/qwebengineprofile.h b/src/webenginewidgets/api/qwebengineprofile.h
index d981fa5bb..704414bcf 100644
--- a/src/webenginewidgets/api/qwebengineprofile.h
+++ b/src/webenginewidgets/api/qwebengineprofile.h
@@ -121,6 +121,11 @@ public:
void clearHttpCache();
+ void setSpellCheckLanguage(const QString &language);
+ QString spellCheckLanguage() const;
+ void setSpellCheckEnabled(bool enabled);
+ bool isSpellCheckEnabled() const;
+
static QWebEngineProfile *defaultProfile();
Q_SIGNALS:
diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
index 539e809d4..a0dc49d0a 100644
--- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
@@ -152,6 +152,7 @@
\value Unselect Clear the current selection. (Added in Qt 5.7)
\value SavePage Save the current page to disk. MHTML is the default format that is used to store
the web page on disk. (Added in Qt 5.7)
+ \value ViewSource Shows the source of the current page in a new tab. (Added in Qt 5.8)
\omitvalue WebActionCount
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
index 28c40fed5..c7b825854 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -49,20 +49,51 @@
#include <QSGAbstractRenderer>
#include <QSGNode>
#include <QWindow>
-#include <private/qsgcontext_p.h>
-#include <private/qsgengine_p.h>
+#include <private/qquickwindow_p.h>
+
+#if (QT_VERSION < QT_VERSION_CHECK(5, 8, 0))
+#include <QSGSimpleRectNode>
+#include <QSGSimpleTextureNode>
+#endif
namespace QtWebEngineCore {
-static const int MaxTooltipLength = 1024;
+class RenderWidgetHostViewQuickItem : public QQuickItem {
+public:
+ RenderWidgetHostViewQuickItem(RenderWidgetHostViewQtDelegateClient *client) : m_client(client)
+ {
+ setFlag(ItemHasContents, true);
+ }
+protected:
+ void focusInEvent(QFocusEvent *event) override
+ {
+ m_client->forwardEvent(event);
+ }
+ void focusOutEvent(QFocusEvent *event) override
+ {
+ m_client->forwardEvent(event);
+ }
+ void keyPressEvent(QKeyEvent *event) override
+ {
+ m_client->forwardEvent(event);
+ }
+ void keyReleaseEvent(QKeyEvent *event) override
+ {
+ m_client->forwardEvent(event);
+ }
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override
+ {
+ return m_client->updatePaintNode(oldNode);
+ }
+private:
+ RenderWidgetHostViewQtDelegateClient *m_client;
+};
RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQtDelegateClient *client, QWidget *parent)
- : QOpenGLWidget(parent)
+ : QQuickWidget(parent)
, m_client(client)
- , m_rootNode(new QSGRootNode)
- , m_sgEngine(new QSGEngine)
+ , m_rootItem(new RenderWidgetHostViewQuickItem(client))
, m_isPopup(false)
- , m_clearColor(Qt::white)
{
setFocusPolicy(Qt::StrongFocus);
@@ -90,7 +121,7 @@ RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(Rende
}
#endif
- // Make sure the OpenGL profile of the QOpenGLWidget matches the shared context profile.
+ // Make sure the OpenGL profile of the QQuickWidget matches the shared context profile.
if (sharedFormat.profile() == QSurfaceFormat::CoreProfile) {
format.setMajorVersion(sharedFormat.majorVersion());
format.setMinorVersion(sharedFormat.minorVersion());
@@ -109,6 +140,8 @@ RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(Rende
void RenderWidgetHostViewQtDelegateWidget::initAsChild(WebContentsAdapterClient* container)
{
+ setContent(QUrl(), nullptr, m_rootItem.data());
+
QWebEnginePagePrivate *pagePrivate = static_cast<QWebEnginePagePrivate *>(container);
if (pagePrivate->view) {
pagePrivate->view->layout()->addWidget(this);
@@ -121,6 +154,8 @@ void RenderWidgetHostViewQtDelegateWidget::initAsChild(WebContentsAdapterClient*
void RenderWidgetHostViewQtDelegateWidget::initAsPopup(const QRect& screenRect)
{
m_isPopup = true;
+ setContent(QUrl(), nullptr, m_rootItem.data());
+
// The keyboard events are supposed to go to the parent RenderHostView
// so the WebUI popups should never have focus. Besides, if the parent view
// loses focus, WebKit will cause its associated popups (including this one)
@@ -146,12 +181,12 @@ QRectF RenderWidgetHostViewQtDelegateWidget::contentsRect() const
void RenderWidgetHostViewQtDelegateWidget::setKeyboardFocus()
{
- setFocus();
+ m_rootItem->forceActiveFocus();
}
bool RenderWidgetHostViewQtDelegateWidget::hasKeyboardFocus()
{
- return hasFocus();
+ return m_rootItem->hasActiveFocus();
}
void RenderWidgetHostViewQtDelegateWidget::lockMouse()
@@ -169,65 +204,84 @@ void RenderWidgetHostViewQtDelegateWidget::show()
// Check if we're attached to a QWebEngineView, we don't
// want to show anything else than popups as top-level.
if (parent() || m_isPopup) {
- QOpenGLWidget::show();
+ QQuickWidget::show();
}
}
void RenderWidgetHostViewQtDelegateWidget::hide()
{
- QOpenGLWidget::hide();
+ QQuickWidget::hide();
}
bool RenderWidgetHostViewQtDelegateWidget::isVisible() const
{
- return QOpenGLWidget::isVisible();
+ return QQuickWidget::isVisible();
}
QWindow* RenderWidgetHostViewQtDelegateWidget::window() const
{
- const QWidget* root = QOpenGLWidget::window();
+ const QWidget* root = QQuickWidget::window();
return root ? root->windowHandle() : 0;
}
QSGTexture *RenderWidgetHostViewQtDelegateWidget::createTextureFromImage(const QImage &image)
{
- return m_sgEngine->createTextureFromImage(image, QSGEngine::TextureCanUseAtlas);
+ return quickWindow()->createTextureFromImage(image, QQuickWindow::TextureCanUseAtlas);
}
QSGLayer *RenderWidgetHostViewQtDelegateWidget::createLayer()
{
- QSGEnginePrivate *enginePrivate = QSGEnginePrivate::get(m_sgEngine.data());
- return enginePrivate->sgContext->createLayer(enginePrivate->sgRenderContext.data());
+ QSGRenderContext *renderContext = QQuickWindowPrivate::get(quickWindow())->context;
+ return renderContext->sceneGraphContext()->createLayer(renderContext);
}
-QSGImageNode *RenderWidgetHostViewQtDelegateWidget::createImageNode()
+QSGInternalImageNode *RenderWidgetHostViewQtDelegateWidget::createImageNode()
{
- return QSGEnginePrivate::get(m_sgEngine.data())->sgContext->createImageNode();
+ QSGRenderContext *renderContext = QQuickWindowPrivate::get(quickWindow())->context;
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
+ return renderContext->sceneGraphContext()->createInternalImageNode();
+#else
+ return renderContext->sceneGraphContext()->createImageNode();
+#endif
}
-void RenderWidgetHostViewQtDelegateWidget::update()
+QSGTextureNode *RenderWidgetHostViewQtDelegateWidget::createTextureNode()
{
-#if (QT_VERSION < QT_VERSION_CHECK(5, 4, 0))
- updateGL();
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
+ return quickWindow()->createImageNode();
#else
- QOpenGLWidget::update();
+ return new QSGSimpleTextureNode();
#endif
}
+QSGRectangleNode *RenderWidgetHostViewQtDelegateWidget::createRectangleNode()
+{
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
+ return quickWindow()->createRectangleNode();
+#else
+ return new QSGSimpleRectNode();
+#endif
+}
+
+void RenderWidgetHostViewQtDelegateWidget::update()
+{
+ m_rootItem->update();
+}
+
void RenderWidgetHostViewQtDelegateWidget::updateCursor(const QCursor &cursor)
{
- QOpenGLWidget::setCursor(cursor);
+ QQuickWidget::setCursor(cursor);
}
void RenderWidgetHostViewQtDelegateWidget::resize(int width, int height)
{
- QOpenGLWidget::resize(width, height);
+ QQuickWidget::resize(width, height);
}
void RenderWidgetHostViewQtDelegateWidget::move(const QPoint &screenPos)
{
Q_ASSERT(m_isPopup);
- QOpenGLWidget::move(screenPos);
+ QQuickWidget::move(screenPos);
}
void RenderWidgetHostViewQtDelegateWidget::inputMethodStateChanged(bool editorVisible)
@@ -235,23 +289,15 @@ void RenderWidgetHostViewQtDelegateWidget::inputMethodStateChanged(bool editorVi
if (qApp->inputMethod()->isVisible() == editorVisible)
return;
- QOpenGLWidget::setAttribute(Qt::WA_InputMethodEnabled, editorVisible);
+ QQuickWidget::setAttribute(Qt::WA_InputMethodEnabled, editorVisible);
qApp->inputMethod()->update(Qt::ImQueryInput | Qt::ImEnabled | Qt::ImHints);
qApp->inputMethod()->setVisible(editorVisible);
}
-void RenderWidgetHostViewQtDelegateWidget::setTooltip(const QString &tooltip)
-{
- QString wrappedTip;
- if (!tooltip.isEmpty())
- wrappedTip = QLatin1String("<p>") % tooltip.toHtmlEscaped().left(MaxTooltipLength) % QLatin1String("</p>");
- setToolTip(wrappedTip);
-}
-
void RenderWidgetHostViewQtDelegateWidget::setClearColor(const QColor &color)
{
- m_clearColor = color;
- // QOpenGLWidget is usually blended by punching holes into widgets
+ QQuickWidget::setClearColor(color);
+ // QQuickWidget is usually blended by punching holes into widgets
// above it to simulate the visual stacking order. If we want it to be
// transparent we have to throw away the proper stacking order and always
// blend the complete normal widgets backing store under it.
@@ -268,7 +314,7 @@ QVariant RenderWidgetHostViewQtDelegateWidget::inputMethodQuery(Qt::InputMethodQ
void RenderWidgetHostViewQtDelegateWidget::resizeEvent(QResizeEvent *resizeEvent)
{
- QOpenGLWidget::resizeEvent(resizeEvent);
+ QQuickWidget::resizeEvent(resizeEvent);
const QPoint globalPos = mapToGlobal(pos());
if (globalPos != m_lastGlobalPos) {
@@ -281,7 +327,7 @@ void RenderWidgetHostViewQtDelegateWidget::resizeEvent(QResizeEvent *resizeEvent
void RenderWidgetHostViewQtDelegateWidget::showEvent(QShowEvent *event)
{
- QOpenGLWidget::showEvent(event);
+ QQuickWidget::showEvent(event);
// We don't have a way to catch a top-level window change with QWidget
// but a widget will most likely be shown again if it changes, so do
// the reconnection at this point.
@@ -298,7 +344,7 @@ void RenderWidgetHostViewQtDelegateWidget::showEvent(QShowEvent *event)
void RenderWidgetHostViewQtDelegateWidget::hideEvent(QHideEvent *event)
{
- QOpenGLWidget::hideEvent(event);
+ QQuickWidget::hideEvent(event);
m_client->notifyHidden();
}
@@ -333,11 +379,19 @@ bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event)
}
}
- if (event->type() == QEvent::ShortcutOverride) {
+ switch (event->type()) {
+ case QEvent::FocusIn:
+ case QEvent::FocusOut:
+ // We forward focus events later, once they have made it to the m_rootItem.
+ return QQuickWidget::event(event);
+ case QEvent::ShortcutOverride:
if (editorActionForKeyEvent(static_cast<QKeyEvent*>(event)) != QWebEnginePage::NoWebAction) {
event->accept();
return true;
}
+ break;
+ default:
+ break;
}
if (event->type() == QEvent::MouseButtonDblClick) {
@@ -353,45 +407,10 @@ bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event)
handled = m_client->forwardEvent(event);
if (!handled)
- return QOpenGLWidget::event(event);
+ return QQuickWidget::event(event);
return true;
}
-void RenderWidgetHostViewQtDelegateWidget::initializeGL()
-{
- m_sgEngine->initialize(QOpenGLContext::currentContext());
- m_sgRenderer.reset(m_sgEngine->createRenderer());
- m_sgRenderer->setRootNode(m_rootNode.data());
- m_sgRenderer->setClearColor(m_clearColor);
-
- // When RenderWidgetHostViewQt::GetScreenInfo is called for the first time, the associated
- // QWindow is NULL, and the screen device pixel ratio can not be queried.
- // Re-initialize the screen information after the QWindow handle is available,
- // so Chromium receives the correct device pixel ratio.
- m_client->windowChanged();
-}
-
-void RenderWidgetHostViewQtDelegateWidget::paintGL()
-{
-#if (QT_VERSION < QT_VERSION_CHECK(5, 3, 1))
- // A workaround for a missing check in 5.3.0 when updating an unparented delegate.
- if (!QOpenGLContext::currentContext())
- return;
-#endif
- QSGNode *paintNode = m_client->updatePaintNode(m_rootNode->firstChild());
- if (paintNode != m_rootNode->firstChild()) {
- delete m_rootNode->firstChild();
- m_rootNode->appendChildNode(paintNode);
- }
-
- QSize deviceSize = size() * devicePixelRatio();
- m_sgRenderer->setDeviceRect(deviceSize);
- m_sgRenderer->setViewportRect(deviceSize);
- m_sgRenderer->setProjectionMatrixToRect(QRectF(QPointF(), size()));
-
- m_sgRenderer->renderScene(defaultFramebufferObject());
-}
-
void RenderWidgetHostViewQtDelegateWidget::onWindowPosChanged()
{
m_lastGlobalPos = mapToGlobal(pos());
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
index 7307bcd55..77907ec5a 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
@@ -43,19 +43,12 @@
#include "render_widget_host_view_qt_delegate.h"
#include "web_contents_adapter_client.h"
-#include <QSGAbstractRenderer>
-#include <QSGEngine>
-#include <QSGNode>
-
-#if (QT_VERSION < QT_VERSION_CHECK(5, 4, 0))
-#include <QtWidgets/private/qopenglwidget_p.h>
-#else
-#include <QtWidgets/QOpenGLWidget>
-#endif
+#include <QQuickItem>
+#include <QQuickWidget>
namespace QtWebEngineCore {
-class RenderWidgetHostViewQtDelegateWidget : public QOpenGLWidget, public RenderWidgetHostViewQtDelegate {
+class RenderWidgetHostViewQtDelegateWidget : public QQuickWidget, public RenderWidgetHostViewQtDelegate {
Q_OBJECT
public:
RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQtDelegateClient *client, QWidget *parent = 0);
@@ -74,13 +67,14 @@ public:
virtual QWindow* window() const Q_DECL_OVERRIDE;
virtual QSGTexture *createTextureFromImage(const QImage &) Q_DECL_OVERRIDE;
virtual QSGLayer *createLayer() Q_DECL_OVERRIDE;
- virtual QSGImageNode *createImageNode() Q_DECL_OVERRIDE;
+ virtual QSGInternalImageNode *createImageNode() Q_DECL_OVERRIDE;
+ virtual QSGTextureNode *createTextureNode() Q_DECL_OVERRIDE;
+ virtual QSGRectangleNode *createRectangleNode() Q_DECL_OVERRIDE;
virtual void update() Q_DECL_OVERRIDE;
virtual void updateCursor(const QCursor &) Q_DECL_OVERRIDE;
virtual void resize(int width, int height) Q_DECL_OVERRIDE;
virtual void move(const QPoint &screenPos) Q_DECL_OVERRIDE;
virtual void inputMethodStateChanged(bool editorVisible) Q_DECL_OVERRIDE;
- virtual void setTooltip(const QString &tooltip) Q_DECL_OVERRIDE;
virtual void setClearColor(const QColor &color) Q_DECL_OVERRIDE;
protected:
@@ -88,8 +82,6 @@ protected:
void resizeEvent(QResizeEvent *resizeEvent) Q_DECL_OVERRIDE;
void showEvent(QShowEvent *) Q_DECL_OVERRIDE;
void hideEvent(QHideEvent *) Q_DECL_OVERRIDE;
- void initializeGL() Q_DECL_OVERRIDE;
- void paintGL() Q_DECL_OVERRIDE;
QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE;
@@ -98,10 +90,7 @@ private slots:
private:
RenderWidgetHostViewQtDelegateClient *m_client;
- // Put the root node first to make sure it gets destroyed after the SG renderer.
- QScopedPointer<QSGRootNode> m_rootNode;
- QScopedPointer<QSGEngine> m_sgEngine;
- QScopedPointer<QSGAbstractRenderer> m_sgRenderer;
+ QScopedPointer<QQuickItem> m_rootItem;
bool m_isPopup;
QColor m_clearColor;
QPoint m_lastGlobalPos;
diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro
index cd9a2d10b..f1bb86df4 100644
--- a/src/webenginewidgets/webenginewidgets.pro
+++ b/src/webenginewidgets/webenginewidgets.pro
@@ -4,7 +4,7 @@ TARGET = QtWebEngineWidgets
DEFINES += QT_BUILD_WEBENGINEWIDGETS_LIB
QT += webenginecore widgets network quick
-QT_PRIVATE += quick-private gui-private core-private
+QT_PRIVATE += quick-private gui-private core-private quickwidgets
INCLUDEPATH += $$PWD api ../core ../core/api ../webengine/api