summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/access_token_store_qt.cpp7
-rw-r--r--src/core/access_token_store_qt.h6
-rw-r--r--src/core/api/core_api.pro4
-rw-r--r--src/core/api/qtwebenginecoreglobal.cpp11
-rw-r--r--src/core/authentication_dialog_controller_p.h3
-rw-r--r--src/core/browser_accessibility_manager_qt.cpp5
-rw-r--r--src/core/browser_accessibility_manager_qt.h15
-rw-r--r--src/core/browser_accessibility_qt.cpp4
-rw-r--r--src/core/browser_context_adapter.cpp21
-rw-r--r--src/core/browser_context_adapter.h5
-rw-r--r--src/core/browser_context_adapter_client.h8
-rw-r--r--src/core/browser_context_qt.cpp90
-rw-r--r--src/core/browser_context_qt.h45
-rw-r--r--src/core/certificate_error_controller.cpp3
-rw-r--r--src/core/certificate_error_controller.h3
-rw-r--r--src/core/chrome_qt.gyp58
-rw-r--r--src/core/chromium_gpu_helper.cpp7
-rw-r--r--src/core/chromium_overrides.cpp8
-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/desktop_linux.pri4
-rw-r--r--src/core/config/embedded_linux.pri4
-rw-r--r--src/core/config/embedded_qnx.pri1
-rw-r--r--src/core/config/linux.pri19
-rw-r--r--src/core/config/mac_osx.pri8
-rw-r--r--src/core/config/windows.pri11
-rw-r--r--src/core/content_browser_client_qt.cpp138
-rw-r--r--src/core/content_browser_client_qt.h18
-rw-r--r--src/core/content_client_qt.cpp9
-rw-r--r--src/core/content_client_qt.h1
-rw-r--r--src/core/content_main_delegate_qt.cpp19
-rw-r--r--src/core/content_main_delegate_qt.h3
-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_common.pri1
-rw-r--r--src/core/core_gyp_generator.pro63
-rw-r--r--src/core/core_module.pro8
-rw-r--r--src/core/delegated_frame_node.cpp129
-rw-r--r--src/core/delegated_frame_node.h7
-rw-r--r--src/core/desktop_screen_qt.cpp31
-rw-r--r--src/core/desktop_screen_qt.h20
-rw-r--r--src/core/dev_tools_http_handler_delegate_qt.cpp17
-rw-r--r--src/core/dev_tools_http_handler_delegate_qt.h2
-rw-r--r--src/core/doc/src/qtwebenginecore-index.qdoc1
-rw-r--r--src/core/doc/src/qtwebenginecore-module.qdoc1
-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.cpp8
-rw-r--r--src/core/file_picker_controller.h8
-rw-r--r--src/core/gl_context_qt.cpp24
-rw-r--r--src/core/gl_context_qt.h6
-rw-r--r--src/core/gl_surface_qt.cpp88
-rw-r--r--src/core/gl_surface_qt.h2
-rw-r--r--src/core/global_descriptors_qt.h10
-rw-r--r--src/core/gyp_run.pro18
-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/media_capture_devices_dispatcher.cpp62
-rw-r--r--src/core/media_capture_devices_dispatcher.h8
-rw-r--r--src/core/network_delegate_qt.cpp14
-rw-r--r--src/core/network_delegate_qt.h9
-rw-r--r--src/core/ozone_platform_eglfs.cpp26
-rw-r--r--src/core/ozone_platform_eglfs.h23
-rw-r--r--src/core/pdfium_printing_wrapper_qt.cpp231
-rw-r--r--src/core/pdfium_printing_wrapper_qt.h66
-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.cpp5
-rw-r--r--src/core/print_view_manager_base_qt.h4
-rw-r--r--src/core/print_view_manager_qt.cpp34
-rw-r--r--src/core/print_view_manager_qt.h8
-rw-r--r--src/core/printing_message_filter_qt.cpp16
-rw-r--r--src/core/printing_message_filter_qt.h8
-rw-r--r--src/core/proxy_config_service_qt.cpp5
-rw-r--r--src/core/proxy_config_service_qt.h5
-rw-r--r--src/core/qtwebengine.gypi12
-rw-r--r--src/core/qtwebengine_extras.gypi17
-rw-r--r--src/core/render_widget_host_view_qt.cpp82
-rw-r--r--src/core/render_widget_host_view_qt.h28
-rw-r--r--src/core/render_widget_host_view_qt_delegate.h19
-rw-r--r--src/core/renderer/content_renderer_client_qt.cpp237
-rw-r--r--src/core/renderer/content_renderer_client_qt.h14
-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_flash_renderer_host_qt.cpp77
-rw-r--r--src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp50
-rw-r--r--src/core/renderer/pepper/pepper_renderer_host_factory_qt.h2
-rw-r--r--src/core/renderer/render_frame_observer_qt.cpp20
-rw-r--r--src/core/renderer/render_frame_observer_qt.h12
-rw-r--r--src/core/renderer/render_view_observer_qt.cpp34
-rw-r--r--src/core/renderer/render_view_observer_qt.h7
-rw-r--r--src/core/renderer/user_resource_controller.cpp68
-rw-r--r--src/core/renderer/user_resource_controller.h19
-rw-r--r--src/core/renderer/web_channel_ipc_transport.cpp19
-rw-r--r--src/core/renderer/web_channel_ipc_transport.h13
-rw-r--r--src/core/renderer_host/pepper/pepper_flash_browser_host_qt.cpp (renamed from src/core/renderer/pepper/pepper_flash_browser_host_qt.cpp)0
-rw-r--r--src/core/renderer_host/pepper/pepper_flash_browser_host_qt.h (renamed from src/core/renderer/pepper/pepper_flash_browser_host_qt.h)0
-rw-r--r--src/core/renderer_host/pepper/pepper_host_factory_qt.cpp (renamed from src/core/renderer/pepper/pepper_host_factory_qt.cpp)20
-rw-r--r--src/core/renderer_host/pepper/pepper_host_factory_qt.h (renamed from src/core/renderer/pepper/pepper_host_factory_qt.h)2
-rw-r--r--src/core/renderer_host/pepper/pepper_isolated_file_system_message_filter.cpp (renamed from src/core/renderer/pepper/pepper_isolated_file_system_message_filter.cpp)0
-rw-r--r--src/core/renderer_host/pepper/pepper_isolated_file_system_message_filter.h (renamed from src/core/renderer/pepper/pepper_isolated_file_system_message_filter.h)0
-rw-r--r--src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp (renamed from src/core/resource_dispatcher_host_delegate_qt.cpp)3
-rw-r--r--src/core/renderer_host/resource_dispatcher_host_delegate_qt.h (renamed from src/core/resource_dispatcher_host_delegate_qt.h)8
-rw-r--r--src/core/renderer_host/user_resource_controller_host.cpp (renamed from src/core/user_resource_controller_host.cpp)0
-rw-r--r--src/core/renderer_host/user_resource_controller_host.h (renamed from src/core/user_resource_controller_host.h)0
-rw-r--r--src/core/renderer_host/web_channel_ipc_transport_host.cpp (renamed from src/core/web_channel_ipc_transport_host.cpp)0
-rw-r--r--src/core/renderer_host/web_channel_ipc_transport_host.h (renamed from src/core/web_channel_ipc_transport_host.h)2
-rw-r--r--src/core/resource_bundle_qt.cpp70
-rw-r--r--src/core/resource_context_qt.cpp3
-rw-r--r--src/core/resources/resources.gyp4
-rw-r--r--src/core/surface_factory_qt.cpp8
-rw-r--r--src/core/type_conversion.cpp2
-rw-r--r--src/core/type_conversion.h2
-rw-r--r--src/core/url_request_context_getter_qt.cpp73
-rw-r--r--src/core/url_request_context_getter_qt.h14
-rw-r--r--src/core/user_script.cpp105
-rw-r--r--src/core/user_script.h3
-rw-r--r--src/core/web_contents_adapter.cpp128
-rw-r--r--src/core/web_contents_adapter.h14
-rw-r--r--src/core/web_contents_adapter_client.h167
-rw-r--r--src/core/web_contents_adapter_p.h9
-rw-r--r--src/core/web_contents_delegate_qt.cpp13
-rw-r--r--src/core/web_contents_delegate_qt.h25
-rw-r--r--src/core/web_contents_view_qt.cpp26
-rw-r--r--src/core/web_engine_context.cpp31
-rw-r--r--src/core/web_engine_context.h18
-rw-r--r--src/core/web_engine_library_info.cpp82
-rw-r--r--src/core/web_engine_settings.cpp3
-rw-r--r--src/core/web_engine_settings.h2
-rw-r--r--src/core/web_engine_visited_links_manager.cpp1
-rw-r--r--src/core/web_event_factory.cpp556
-rw-r--r--src/core/yuv_video_node.cpp31
-rw-r--r--src/core/yuv_video_node.h9
134 files changed, 2928 insertions, 1457 deletions
diff --git a/src/core/access_token_store_qt.cpp b/src/core/access_token_store_qt.cpp
index 6c4cbc610..5b8fe83f7 100644
--- a/src/core/access_token_store_qt.cpp
+++ b/src/core/access_token_store_qt.cpp
@@ -47,6 +47,7 @@
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/storage_partition.h"
#include "browser_context_qt.h"
#include "browser_context_adapter.h"
@@ -67,7 +68,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)
@@ -76,10 +77,10 @@ void AccessTokenStoreQt::LoadAccessTokens(const LoadAccessTokensCallbackType& ca
void AccessTokenStoreQt::performWorkOnUIThread()
{
- m_systemRequestContext = WebEngineContext::current()->defaultBrowserContext()->browserContext()->GetRequestContext();
+ m_systemRequestContext = content::BrowserContext::GetDefaultStoragePartition(WebEngineContext::current()->defaultBrowserContext()->browserContext())->GetURLRequestContext();
}
-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/api/core_api.pro b/src/core/api/core_api.pro
index 6e2d606b2..37f8885bb 100644
--- a/src/core/api/core_api.pro
+++ b/src/core/api/core_api.pro
@@ -15,9 +15,7 @@ CONFIG -= create_prl
# Copy this logic from qt_module.prf so that the intermediate library can be
# created to the same rules as the final module linking in core_module.pro.
!host_build:if(win32|mac):!macx-xcode {
- contains(QT_CONFIG, simulator_and_device): CONFIG += simulator_and_device
- contains(QT_CONFIG, debug_and_release):CONFIG += debug_and_release
- contains(QT_CONFIG, build_all):CONFIG += build_all
+ qtConfig(debug_and_release): CONFIG += debug_and_release build_all
}
DEFINES += \
diff --git a/src/core/api/qtwebenginecoreglobal.cpp b/src/core/api/qtwebenginecoreglobal.cpp
index f5d1e6d39..072f27967 100644
--- a/src/core/api/qtwebenginecoreglobal.cpp
+++ b/src/core/api/qtwebenginecoreglobal.cpp
@@ -40,16 +40,20 @@
#include "qtwebenginecoreglobal_p.h"
#include <QGuiApplication>
-#include <QOpenGLContext>
+#ifndef QT_NO_OPENGL
+# include <QOpenGLContext>
+#endif
#include <QThread>
+#ifndef QT_NO_OPENGL
QT_BEGIN_NAMESPACE
Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context);
Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
QT_END_NAMESPACE
+#endif
namespace QtWebEngineCore {
-
+#ifndef QT_NO_OPENGL
static QOpenGLContext *shareContext;
static void deleteShareContext()
@@ -58,6 +62,7 @@ static void deleteShareContext()
shareContext = 0;
}
+#endif
// ### Qt 6: unify this logic and Qt::AA_ShareOpenGLContexts.
// QtWebEngine::initialize was introduced first and meant to be called
// after the QGuiApplication creation, when AA_ShareOpenGLContexts fills
@@ -65,6 +70,7 @@ static void deleteShareContext()
QWEBENGINE_PRIVATE_EXPORT void initialize()
{
+#ifndef QT_NO_OPENGL
#ifdef Q_OS_WIN32
qputenv("QT_D3DCREATE_MULTITHREADED", "1");
#endif
@@ -100,5 +106,6 @@ QWEBENGINE_PRIVATE_EXPORT void initialize()
// Classes like QOpenGLWidget check for the attribute
app->setAttribute(Qt::AA_ShareOpenGLContexts);
+#endif // QT_NO_OPENGL
}
} // namespace QtWebEngineCore
diff --git a/src/core/authentication_dialog_controller_p.h b/src/core/authentication_dialog_controller_p.h
index 2acc588e1..af5d92530 100644
--- a/src/core/authentication_dialog_controller_p.h
+++ b/src/core/authentication_dialog_controller_p.h
@@ -41,7 +41,8 @@
#define AUTHENTICATION_DIALOG_CONTROLLER_P_H
#include "base/memory/ref_counted.h"
-#include "resource_dispatcher_host_delegate_qt.h"
+
+#include "renderer_host/resource_dispatcher_host_delegate_qt.h"
namespace QtWebEngineCore {
diff --git a/src/core/browser_accessibility_manager_qt.cpp b/src/core/browser_accessibility_manager_qt.cpp
index bd3c5e7d9..730786bbd 100644
--- a/src/core/browser_accessibility_manager_qt.cpp
+++ b/src/core/browser_accessibility_manager_qt.cpp
@@ -82,8 +82,9 @@ QAccessibleInterface *BrowserAccessibilityManagerQt::rootParentAccessible()
return QAccessible::queryAccessibleInterface(m_parentObject);
}
-void BrowserAccessibilityManagerQt::NotifyAccessibilityEvent(ui::AXEvent event_type,
- BrowserAccessibility* node)
+void BrowserAccessibilityManagerQt::NotifyAccessibilityEvent(BrowserAccessibilityEvent::Source source,
+ ui::AXEvent event_type,
+ BrowserAccessibility* node)
{
BrowserAccessibilityQt *iface = static_cast<BrowserAccessibilityQt*>(node);
diff --git a/src/core/browser_accessibility_manager_qt.h b/src/core/browser_accessibility_manager_qt.h
index 4ff9fb699..da50de9cb 100644
--- a/src/core/browser_accessibility_manager_qt.h
+++ b/src/core/browser_accessibility_manager_qt.h
@@ -59,15 +59,14 @@ public:
class BrowserAccessibilityManagerQt : public BrowserAccessibilityManager
{
public:
- BrowserAccessibilityManagerQt(
- QObject* parentObject,
- const ui::AXTreeUpdate& initialTree,
- BrowserAccessibilityDelegate* delegate,
- BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactoryQt());
+ BrowserAccessibilityManagerQt(QObject* parentObject,
+ const ui::AXTreeUpdate& initialTree,
+ BrowserAccessibilityDelegate* delegate,
+ BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactoryQt());
- void NotifyAccessibilityEvent(
- ui::AXEvent event_type,
- BrowserAccessibility* node) Q_DECL_OVERRIDE;
+ void NotifyAccessibilityEvent(BrowserAccessibilityEvent::Source source,
+ ui::AXEvent event_type,
+ BrowserAccessibility* node) Q_DECL_OVERRIDE;
QAccessibleInterface *rootParentAccessible();
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..3396f73ef 100644
--- a/src/core/browser_context_adapter.cpp
+++ b/src/core/browser_context_adapter.cpp
@@ -41,17 +41,21 @@
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_thread.h"
+
#include "browser_context_qt.h"
#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"
-#include "user_resource_controller_host.h"
+#include "renderer_host/user_resource_controller_host.h"
#include "net/proxy/proxy_service.h"
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
+
#include <QCoreApplication>
#include <QDir>
#include <QString>
@@ -78,6 +82,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 +95,15 @@ 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());
+ BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(m_browserContext.data());
}
void BrowserContextAdapter::setStorageName(const QString &storageName)
@@ -482,19 +491,19 @@ void BrowserContextAdapter::clearHttpCache()
m_browserContext->url_request_getter_->clearHttpCache();
}
-void BrowserContextAdapter::setSpellCheckLanguage(const QString &language)
+void BrowserContextAdapter::setSpellCheckLanguages(const QStringList &languages)
{
#if defined(ENABLE_SPELLCHECK)
- m_browserContext->setSpellCheckLanguage(language);
+ m_browserContext->setSpellCheckLanguages(languages);
#endif
}
-QString BrowserContextAdapter::spellCheckLanguage() const
+QStringList BrowserContextAdapter::spellCheckLanguages() const
{
#if defined(ENABLE_SPELLCHECK)
- return m_browserContext->spellCheckLanguage();
+ return m_browserContext->spellCheckLanguages();
#else
- return QString();
+ return QStringList();
#endif
}
diff --git a/src/core/browser_context_adapter.h b/src/core/browser_context_adapter.h
index a6e5a2a3e..39b9db61c 100644
--- a/src/core/browser_context_adapter.h
+++ b/src/core/browser_context_adapter.h
@@ -108,9 +108,8 @@ public:
QString httpUserAgent() const;
void setHttpUserAgent(const QString &userAgent);
- QStringList spellCheckLanguages(const QStringList &acceptLanguages);
- void setSpellCheckLanguage(const QString &language);
- QString spellCheckLanguage() const;
+ void setSpellCheckLanguages(const QStringList &language);
+ QStringList spellCheckLanguages() const;
void setSpellCheckEnabled(bool enabled);
bool isSpellCheckEnabled() const;
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..a6801e1d7 100644
--- a/src/core/browser_context_qt.cpp
+++ b/src/core/browser_context_qt.cpp
@@ -54,31 +54,31 @@
#include "content/public/browser/storage_partition.h"
#include "net/proxy/proxy_config_service.h"
-#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"
+#if defined(ENABLE_SPELLCHECK)
#include "chrome/common/pref_names.h"
#include "chrome/browser/spellchecker/spellcheck_service.h"
#endif
namespace QtWebEngineCore {
-#if defined(ENABLE_SPELLCHECK)
BrowserContextQt::BrowserContextQt(BrowserContextAdapter *adapter)
: m_adapter(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());
+#if defined(ENABLE_SPELLCHECK)
// Initial spellcheck settings
registry->RegisterListPref(prefs::kSpellCheckDictionaries, new base::ListValue());
registry->RegisterStringPref(prefs::kAcceptLanguages, std::string());
@@ -86,15 +86,10 @@ BrowserContextQt::BrowserContextQt(BrowserContextAdapter *adapter)
registry->RegisterBooleanPref(prefs::kSpellCheckUseSpellingService, false);
registry->RegisterBooleanPref(prefs::kEnableContinuousSpellcheck, false);
registry->RegisterBooleanPref(prefs::kEnableAutoSpellCorrect, false);
+#endif //ENABLE_SPELLCHECK
m_prefService = factory.Create(std::move(registry.get()));
user_prefs::UserPrefs::Set(this, m_prefService.get());
}
-#else
-BrowserContextQt::BrowserContextQt(BrowserContextAdapter *adapter)
- : m_adapter(adapter)
-{
-}
-#endif //ENABLE_SPELLCHECK
BrowserContextQt::~BrowserContextQt()
{
@@ -102,6 +97,16 @@ BrowserContextQt::~BrowserContextQt()
content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE, resourceContext.release());
}
+PrefService* BrowserContextQt::GetPrefs()
+{
+ return m_prefService.get();
+}
+
+const PrefService* BrowserContextQt::GetPrefs() const
+{
+ return m_prefService.get();
+}
+
base::FilePath BrowserContextQt::GetPath() const
{
return toFilePath(m_adapter->dataPath());
@@ -122,24 +127,15 @@ net::URLRequestContextGetter *BrowserContextQt::GetRequestContext()
return url_request_getter_.get();
}
-net::URLRequestContextGetter *BrowserContextQt::GetRequestContextForRenderProcess(int)
-{
- return GetRequestContext();
-}
-
-net::URLRequestContextGetter *BrowserContextQt::GetMediaRequestContext()
-{
- return GetRequestContext();
-}
-
-net::URLRequestContextGetter *BrowserContextQt::GetMediaRequestContextForRenderProcess(int)
+net::URLRequestContextGetter *BrowserContextQt::CreateMediaRequestContext()
{
- return GetRequestContext();
+ return url_request_getter_.get();
}
-net::URLRequestContextGetter *BrowserContextQt::GetMediaRequestContextForStoragePartition(const base::FilePath&, bool)
+net::URLRequestContextGetter *BrowserContextQt::CreateMediaRequestContextForStoragePartition(const base::FilePath&, bool)
{
- return GetRequestContext();
+ Q_UNIMPLEMENTED();
+ return nullptr;
}
content::ResourceContext *BrowserContextQt::GetResourceContext()
@@ -177,7 +173,7 @@ content::SSLHostStateDelegate* BrowserContextQt::GetSSLHostStateDelegate()
return sslHostStateDelegate.get();
}
-scoped_ptr<content::ZoomLevelDelegate> BrowserContextQt::CreateZoomLevelDelegate(const base::FilePath&)
+std::unique_ptr<content::ZoomLevelDelegate> BrowserContextQt::CreateZoomLevelDelegate(const base::FilePath&)
{
return nullptr;
}
@@ -200,6 +196,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)
{
@@ -208,18 +213,27 @@ void BrowserContextQt::failedToLoadDictionary(const std::string &language)
<< "Make sure that correct bdic file is in:" << toQt(WebEngineLibraryInfo::getPath(base::DIR_APP_DICTIONARIES).value());
}
-void BrowserContextQt::setSpellCheckLanguage(const QString &language)
+void BrowserContextQt::setSpellCheckLanguages(const QStringList &languages)
{
- base::ListValue dictionaries;
- dictionaries.AppendString(language.toStdString());
- m_prefService->Set(prefs::kSpellCheckDictionaries, dictionaries);
+ StringListPrefMember dictionaries_pref;
+ dictionaries_pref.Init(prefs::kSpellCheckDictionaries, m_prefService.get());
+ std::vector<std::string> dictionaries;
+ dictionaries.reserve(languages.size());
+ for (const auto &language : languages)
+ dictionaries.push_back(language.toStdString());
+ dictionaries_pref.SetValue(dictionaries);
}
-QString BrowserContextQt::spellCheckLanguage() const
+QStringList BrowserContextQt::spellCheckLanguages() const
{
- std::string dictionary;
- m_prefService->GetList(prefs::kSpellCheckDictionaries)->GetString(0, &dictionary);
- return QString::fromStdString(dictionary);
+ QStringList spellcheck_dictionaries;
+ for (const auto &value : *m_prefService->GetList(prefs::kSpellCheckDictionaries)) {
+ std::string dictionary;
+ if (value->GetAsString(&dictionary))
+ spellcheck_dictionaries.append(QString::fromStdString(dictionary));
+ }
+
+ return spellcheck_dictionaries;
}
void BrowserContextQt::setSpellCheckEnabled(bool enabled)
diff --git a/src/core/browser_context_qt.h b/src/core/browser_context_qt.h
index e2156f147..ca65552be 100644
--- a/src/core/browser_context_qt.h
+++ b/src/core/browser_context_qt.h
@@ -40,20 +40,18 @@
#ifndef BROWSER_CONTEXT_QT_H
#define BROWSER_CONTEXT_QT_H
-#include "content/public/browser/browser_context.h"
+#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/resource_context.h"
#include "net/url_request/url_request_context.h"
#include <QtCore/qcompilerdetection.h> // Needed for Q_DECL_OVERRIDE
-#if defined(ENABLE_SPELLCHECK)
QT_BEGIN_NAMESPACE
class QStringList;
QT_END_NAMESPACE
class TestingPrefStore;
class PrefService;
-#endif
namespace QtWebEngineCore {
@@ -62,39 +60,50 @@ class PermissionManagerQt;
class SSLHostStateDelegateQt;
class URLRequestContextGetterQt;
-class BrowserContextQt : public content::BrowserContext
+class BrowserContextQt : public Profile
{
public:
explicit BrowserContextQt(BrowserContextAdapter *);
virtual ~BrowserContextQt();
+ // BrowserContext implementation:
virtual base::FilePath GetPath() const Q_DECL_OVERRIDE;
base::FilePath GetCachePath() const;
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;
+ net::URLRequestContextGetter *GetRequestContext();
+
+ virtual net::URLRequestContextGetter *CreateMediaRequestContext() Q_DECL_OVERRIDE;
+ virtual net::URLRequestContextGetter *CreateMediaRequestContextForStoragePartition(const base::FilePath& partition_path, bool in_memory) Q_DECL_OVERRIDE;
+
virtual content::ResourceContext *GetResourceContext() Q_DECL_OVERRIDE;
virtual content::DownloadManagerDelegate *GetDownloadManagerDelegate() Q_DECL_OVERRIDE;
virtual content::BrowserPluginGuestManager* GetGuestManager() Q_DECL_OVERRIDE;
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);
- virtual scoped_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(const base::FilePath& partition_path) Q_DECL_OVERRIDE;
+ 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 std::unique_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;
+ // Profile implementation:
+ PrefService* GetPrefs() override;
+ const PrefService* GetPrefs() const override;
+
BrowserContextAdapter *adapter() { return m_adapter; }
#if defined(ENABLE_SPELLCHECK)
void failedToLoadDictionary(const std::string& language) override;
- void setSpellCheckLanguage(const QString &language);
- QString spellCheckLanguage() const;
+ void setSpellCheckLanguages(const QStringList &languages);
+ QStringList spellCheckLanguages() const;
void setSpellCheckEnabled(bool enabled);
bool isSpellCheckEnabled() const;
#endif
@@ -102,15 +111,13 @@ public:
private:
friend class ContentBrowserClientQt;
friend class WebContentsAdapter;
- scoped_ptr<content::ResourceContext> resourceContext;
+ std::unique_ptr<content::ResourceContext> resourceContext;
scoped_refptr<URLRequestContextGetterQt> url_request_getter_;
- scoped_ptr<PermissionManagerQt> permissionManager;
- scoped_ptr<SSLHostStateDelegateQt> sslHostStateDelegate;
+ std::unique_ptr<PermissionManagerQt> permissionManager;
+ std::unique_ptr<SSLHostStateDelegateQt> sslHostStateDelegate;
BrowserContextAdapter *m_adapter;
-#if defined(ENABLE_SPELLCHECK)
scoped_refptr<TestingPrefStore> m_prefStore;
- scoped_ptr<PrefService> m_prefService;
-#endif
+ std::unique_ptr<PrefService> m_prefService;
friend class BrowserContextAdapter;
DISALLOW_COPY_AND_ASSIGN(BrowserContextQt);
diff --git a/src/core/certificate_error_controller.cpp b/src/core/certificate_error_controller.cpp
index 65bba733a..18835a5c7 100644
--- a/src/core/certificate_error_controller.cpp
+++ b/src/core/certificate_error_controller.cpp
@@ -66,6 +66,7 @@ ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateNonUniqueName, net::ER
ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateWeakKey, net::ERR_CERT_WEAK_KEY)
ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateNameConstraintViolation, net::ERR_CERT_NAME_CONSTRAINT_VIOLATION)
ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateValidityTooLong, net::ERR_CERT_VALIDITY_TOO_LONG)
+ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateTransparencyRequired, net::ERR_CERTIFICATE_TRANSPARENCY_REQUIRED)
ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateErrorEnd, net::ERR_CERT_END)
void CertificateErrorControllerPrivate::accept(bool accepted)
@@ -174,6 +175,8 @@ QString CertificateErrorController::errorString() const
return getQStringForMessageId(IDS_CERT_ERROR_NAME_CONSTRAINT_VIOLATION_DESCRIPTION);
case CertificateValidityTooLong:
return getQStringForMessageId(IDS_CERT_ERROR_VALIDITY_TOO_LONG_DESCRIPTION);
+ case CertificateTransparencyRequired:
+ return getQStringForMessageId(IDS_CERT_ERROR_CERTIFICATE_TRANSPARENCY_REQUIRED_DESCRIPTION);
case CertificateUnableToCheckRevocation: // Deprecated in Chromium.
default:
break;
diff --git a/src/core/certificate_error_controller.h b/src/core/certificate_error_controller.h
index 27f18946f..554281644 100644
--- a/src/core/certificate_error_controller.h
+++ b/src/core/certificate_error_controller.h
@@ -71,8 +71,9 @@ public:
CertificateWeakKey = -211,
CertificateNameConstraintViolation = -212,
CertificateValidityTooLong = -213,
+ CertificateTransparencyRequired = -214,
- CertificateErrorEnd = -214 // not an error, just an enum boundary
+ CertificateErrorEnd = -215 // not an error, just an enum boundary
};
CertificateError error() const;
diff --git a/src/core/chrome_qt.gyp b/src/core/chrome_qt.gyp
index f2d7c5831..89f1fe188 100644
--- a/src/core/chrome_qt.gyp
+++ b/src/core/chrome_qt.gyp
@@ -2,8 +2,6 @@
'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)/chrome/browser/spellchecker/feedback.cc',
'<(DEPTH)/chrome/browser/spellchecker/feedback.h',
'<(DEPTH)/chrome/browser/spellchecker/feedback_sender.cc',
@@ -63,6 +61,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,43 +69,60 @@
'<(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',
'<(DEPTH)/chrome/browser/media/desktop_streams_registry.cc',
'<(DEPTH)/chrome/browser/media/desktop_streams_registry.h',
+ '<(DEPTH)/chrome/browser/profiles/profile.cc',
+ '<(DEPTH)/chrome/browser/profiles/profile.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)/components/prefs/testing_pref_store.cc',
+ '<(DEPTH)/components/prefs/testing_pref_store.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_flash_font_file_host.cc',
+ '<(DEPTH)/chrome/renderer/pepper/pepper_flash_font_file_host.h',
+ '<(DEPTH)/chrome/renderer/pepper/pepper_shared_memory_message_filter.cc',
+ '<(DEPTH)/chrome/renderer/pepper/pepper_shared_memory_message_filter.h',
+ ],
+ }],
+ ['enable_pdf==1', {
+ 'dependencies': [
+ '<(chromium_src_dir)/pdf/pdf.gyp:pdf',
+ '<(chromium_src_dir)/components/components.gyp:pdf_renderer',
+ '<(chromium_src_dir)/components/components.gyp:pdf_browser',
+ ],
+ }],
['enable_spellcheck==1', {
'sources': [ '<@(chrome_spellchecker_sources)' ],
'include_dirs': [
- '<(chromium_src_dir)/third_party/WebKit',
+ '<(chromium_src_dir)/third_party/WebKit',
],
'dependencies': [
- '<(chromium_src_dir)/components/components.gyp:keyed_service_content',
- '<(chromium_src_dir)/components/components.gyp:keyed_service_core',
- '<(chromium_src_dir)/components/components.gyp:pref_registry',
- '<(chromium_src_dir)/components/components.gyp:user_prefs',
- '<(chromium_src_dir)/third_party/hunspell/hunspell.gyp:hunspell',
- '<(chromium_src_dir)/third_party/icu/icu.gyp:icui18n',
- '<(chromium_src_dir)/third_party/icu/icu.gyp:icuuc',
+ '<(chromium_src_dir)/chrome/tools/convert_dict/convert_dict.gyp:convert_dict',
+ '<(chromium_src_dir)/third_party/hunspell/hunspell.gyp:hunspell',
+ '<(chromium_src_dir)/third_party/icu/icu.gyp:icui18n',
+ '<(chromium_src_dir)/third_party/icu/icu.gyp:icuuc',
],
'defines': [
'__STDC_CONSTANT_MACROS',
'__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?)$'],
@@ -116,6 +132,8 @@
'sources!': [
'<(DEPTH)/chrome/renderer/spellchecker/platform_spelling_engine.cc',
'<(DEPTH)/chrome/renderer/spellchecker/platform_spelling_engine.h',
+ '<(DEPTH)/chrome/browser/spellchecker/spellcheck_message_filter_platform.h',
+ '<(DEPTH)/chrome/browser/spellchecker/spellcheck_message_filter_platform_mac.cc',
],
}],
],
@@ -134,7 +152,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/chromium_overrides.cpp b/src/core/chromium_overrides.cpp
index 18596c337..882f5b1dd 100644
--- a/src/core/chromium_overrides.cpp
+++ b/src/core/chromium_overrides.cpp
@@ -119,9 +119,9 @@ void RenderWidgetHostViewBase::GetDefaultScreenInfo(blink::WebScreenInfo* result
namespace content {
// content/common/font_list.h
-scoped_ptr<base::ListValue> GetFontList_SlowBlocking()
+std::unique_ptr<base::ListValue> GetFontList_SlowBlocking()
{
- scoped_ptr<base::ListValue> font_list(new base::ListValue);
+ std::unique_ptr<base::ListValue> font_list(new base::ListValue);
QFontDatabase database;
for (auto family : database.families()){
@@ -166,9 +166,9 @@ namespace net {
class SSLPrivateKey { };
class X509Certificate;
-scoped_ptr<SSLPrivateKey> FetchClientCertPrivateKey(X509Certificate* certificate)
+std::unique_ptr<SSLPrivateKey> FetchClientCertPrivateKey(X509Certificate* certificate)
{
- return scoped_ptr<SSLPrivateKey>();
+ return std::unique_ptr<SSLPrivateKey>();
}
} // namespace net
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/desktop_linux.pri b/src/core/config/desktop_linux.pri
index de0fbbc6b..a72452b90 100644
--- a/src/core/config/desktop_linux.pri
+++ b/src/core/config/desktop_linux.pri
@@ -4,9 +4,11 @@ include(linux.pri)
GYP_CONFIG += \
desktop_linux=1 \
- enable_widevine=1
+ enable_widevine=1 \
+ enable_pdf=1
clang {
+ GYP_CONFIG += werror=
GYP_CONFIG += clang=1 host_clang=1 clang_use_chrome_plugins=0 make_clang_dir=/usr
linux-clang-libc++: GYP_CONFIG += use_system_libcxx=1
} else {
diff --git a/src/core/config/embedded_linux.pri b/src/core/config/embedded_linux.pri
index 4cb7d89fb..7a909f1e2 100644
--- a/src/core/config/embedded_linux.pri
+++ b/src/core/config/embedded_linux.pri
@@ -15,9 +15,10 @@ GYP_CONFIG += \
enable_google_now=0 \
enable_language_detection=0 \
enable_managed_users=0 \
+ enable_pdf=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 \
@@ -38,5 +39,6 @@ GYP_CONFIG += \
use_x11=0 \
v8_use_snapshot=false \
want_separate_host_toolset=1 \
+ angle_enable_gl=0 \
WEBENGINE_CONFIG *= reduce_binary_size
diff --git a/src/core/config/embedded_qnx.pri b/src/core/config/embedded_qnx.pri
index c05e8bb59..3effdb816 100644
--- a/src/core/config/embedded_qnx.pri
+++ b/src/core/config/embedded_qnx.pri
@@ -5,6 +5,7 @@ include(common.pri)
GYP_CONFIG += \
disable_nacl=1 \
enable_basic_printing=0 \
+ enable_pdf=0 \
enable_plugins=0 \
enable_webrtc=0 \
use_ash=0 \
diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri
index a318e170c..fc2b124fb 100644
--- a/src/core/config/linux.pri
+++ b/src/core/config/linux.pri
@@ -1,4 +1,5 @@
include(common.pri)
+QT_FOR_CONFIG += gui-private
# linux_use_bundled_gold currently relies on a hardcoded relative path from chromium/src/out/(Release|Debug)
# Disable it along with the -Wl,--threads flag just in case gold isn't installed on the system.
@@ -22,19 +23,24 @@ 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
}
gcc:!clang: greaterThan(QT_GCC_MAJOR_VERSION, 5): GYP_CONFIG += no_delete_null_pointer_checks=1
-contains(QT_CONFIG, system-zlib): use?(system_minizip): GYP_CONFIG += use_system_zlib=1
-contains(QT_CONFIG, system-png): GYP_CONFIG += use_system_libpng=1
-contains(QT_CONFIG, system-jpeg): GYP_CONFIG += use_system_libjpeg=1
-contains(QT_CONFIG, system-harfbuzz): GYP_CONFIG += use_system_harfbuzz=1
+qtConfig(system-zlib): use?(system_minizip): GYP_CONFIG += use_system_zlib=1
+qtConfig(system-png): GYP_CONFIG += use_system_libpng=1
+qtConfig(system-jpeg): GYP_CONFIG += use_system_libjpeg=1
+qtConfig(system-harfbuzz): GYP_CONFIG += use_system_harfbuzz=1
+!qtConfig(glib): GYP_CONFIG += use_glib=0
contains(QT_CONFIG, pulseaudio) {
GYP_CONFIG += use_pulseaudio=1
} else {
@@ -45,7 +51,6 @@ contains(QT_CONFIG, alsa) {
} else {
GYP_CONFIG += use_alsa=0
}
-!contains(QT_CONFIG, glib): GYP_CONFIG += use_glib=0
use?(system_libevent): GYP_CONFIG += use_system_libevent=1
use?(system_libwebp): GYP_CONFIG += use_system_libwebp=1
use?(system_libsrtp): GYP_CONFIG += use_system_libsrtp=1
diff --git a/src/core/config/mac_osx.pri b/src/core/config/mac_osx.pri
index c447add4a..be037cbde 100644
--- a/src/core/config/mac_osx.pri
+++ b/src/core/config/mac_osx.pri
@@ -25,11 +25,17 @@ GYP_CONFIG += \
mac_deployment_target=\"$${QMAKE_MACOSX_DEPLOYMENT_TARGET}\" \
make_clang_dir=\"$${QMAKE_CLANG_DIR}\" \
clang_use_chrome_plugins=0 \
- enable_widevine=1
+ enable_widevine=1 \
+ enable_pdf=1
# Force touch API is used in 49-based Chromium, which is included starting with 10.10.3 SDK, so we
# disable the API usage if the SDK version is lower.
!isMinOSXSDKVersion(10, 10, 3): GYP_CONFIG += disable_force_touch=1
+# Pass a supported -fstack-protect flag depending on Xcode version.
+lessThan(QMAKE_XCODE_VERSION, 6.3) {
+ GYP_CONFIG += use_xcode_stack_protector_strong=0
+}
+
QMAKE_MAC_SDK_PATH = "$$eval(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.path)"
exists($$QMAKE_MAC_SDK_PATH): GYP_CONFIG += mac_sdk_path=\"$${QMAKE_MAC_SDK_PATH}\"
diff --git a/src/core/config/windows.pri b/src/core/config/windows.pri
index a99bc5303..5b9551b5a 100644
--- a/src/core/config/windows.pri
+++ b/src/core/config/windows.pri
@@ -6,7 +6,8 @@ GYP_CONFIG += \
disable_nacl=1 \
remoting=0 \
use_ash=0 \
- enable_widevine=1
+ enable_widevine=1 \
+ enable_pdf=1
# Libvpx build needs additional search path on Windows.
GYP_ARGS += "-D qtwe_chromium_obj_dir=\"$$OUT_PWD/$$getConfigDir()/obj/$${getChromiumSrcDir()}\""
@@ -17,7 +18,7 @@ GYP_ARGS += "-D perl_exe=\"perl.exe\" -D bison_exe=\"bison.exe\" -D gperf_exe=\"
# Gyp's parallel processing is broken on Windows
GYP_ARGS += "--no-parallel"
-contains(QT_CONFIG, angle) {
+qtConfig(angle) {
CONFIG(release, debug|release) {
GYP_ARGS += "-D qt_egl_library=\"libEGL.lib\" -D qt_glesv2_library=\"libGLESv2.lib\""
} else {
@@ -56,9 +57,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 +65,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 fd6bd1f86..c3800e9ff 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -39,14 +39,19 @@
#include "content_browser_client_qt.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/threading/thread_restrictions.h"
#if defined(ENABLE_SPELLCHECK)
#include "chrome/browser/spellchecker/spellcheck_message_filter.h"
+#if defined(USE_BROWSER_SPELLCHECKER)
+#include "chrome/browser/spellchecker/spellcheck_message_filter_platform.h"
+#endif
#endif
#include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/public/browser/browser_main_parts.h"
#include "content/public/browser/child_process_security_policy.h"
+#include "content/public/browser/geolocation_delegate.h"
#include "content/public/browser/client_certificate_delegate.h"
#include "content/public/browser/media_observer.h"
#include "content/public/browser/quota_permission_context.h"
@@ -59,7 +64,7 @@
#include "content/public/common/main_function_params.h"
#include "content/public/common/url_constants.h"
#include "ui/base/ui_base_switches.h"
-#include "ui/gfx/screen.h"
+#include "ui/display/screen.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_share_group.h"
@@ -80,21 +85,28 @@
#if defined(ENABLE_BASIC_PRINTING)
#include "printing_message_filter_qt.h"
#endif // defined(ENABLE_BASIC_PRINTING)
-#include "resource_dispatcher_host_delegate_qt.h"
-#include "user_resource_controller_host.h"
+#include "renderer_host/resource_dispatcher_host_delegate_qt.h"
+#include "renderer_host/user_resource_controller_host.h"
#include "web_contents_delegate_qt.h"
#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"
-#include "renderer/pepper/pepper_host_factory_qt.h"
+#include "renderer_host/pepper/pepper_host_factory_qt.h"
#endif
#include <QGuiApplication>
#include <QLocale>
-#include <QOpenGLContext>
+#ifndef QT_NO_OPENGL
+# include <QOpenGLContext>
+#endif
#include <qpa/qplatformnativeinterface.h>
QT_BEGIN_NAMESPACE
@@ -212,9 +224,9 @@ private:
base::TimeTicks m_timerScheduledTime;
};
-scoped_ptr<base::MessagePump> messagePumpFactory()
+std::unique_ptr<base::MessagePump> messagePumpFactory()
{
- return scoped_ptr<base::MessagePump>(new MessagePumpForUIQt);
+ return base::WrapUnique(new MessagePumpForUIQt);
}
} // namespace
@@ -245,8 +257,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.
+ display::Screen::SetScreenInstance(new DesktopScreenQt);
+
return 0;
}
@@ -254,16 +267,16 @@ private:
DISALLOW_COPY_AND_ASSIGN(BrowserMainPartsQt);
};
-class QtShareGLContext : public gfx::GLContext {
+class QtShareGLContext : public gl::GLContext {
public:
QtShareGLContext(QOpenGLContext *qtContext)
- : gfx::GLContext(0)
+ : gl::GLContext(0)
, m_handle(0)
{
QString platform = qApp->platformName().toLower();
QPlatformNativeInterface *pni = QGuiApplication::platformNativeInterface();
if (platform == QLatin1String("xcb")) {
- if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2)
+ if (gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2)
m_handle = pni->nativeResourceForContext(QByteArrayLiteral("eglcontext"), qtContext);
else
m_handle = pni->nativeResourceForContext(QByteArrayLiteral("glxcontext"), qtContext);
@@ -275,7 +288,7 @@ public:
|| platform == QLatin1String("wayland-egl"))
m_handle = pni->nativeResourceForContext(QByteArrayLiteral("eglcontext"), qtContext);
else if (platform == QLatin1String("windows")) {
- if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2)
+ if (gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2)
m_handle = pni->nativeResourceForContext(QByteArrayLiteral("eglContext"), qtContext);
else
m_handle = pni->nativeResourceForContext(QByteArrayLiteral("renderingcontext"), qtContext);
@@ -291,12 +304,12 @@ public:
virtual bool WasAllocatedUsingRobustnessExtension() { return false; }
// We don't care about the rest, this context shouldn't be used except for its handle.
- virtual bool Initialize(gfx::GLSurface *, gfx::GpuPreference) Q_DECL_OVERRIDE { Q_UNREACHABLE(); return false; }
- virtual bool MakeCurrent(gfx::GLSurface *) Q_DECL_OVERRIDE { Q_UNREACHABLE(); return false; }
- virtual void ReleaseCurrent(gfx::GLSurface *) Q_DECL_OVERRIDE { Q_UNREACHABLE(); }
- virtual bool IsCurrent(gfx::GLSurface *) Q_DECL_OVERRIDE { Q_UNREACHABLE(); return false; }
+ virtual bool Initialize(gl::GLSurface *, gl::GpuPreference) Q_DECL_OVERRIDE { Q_UNREACHABLE(); return false; }
+ virtual bool MakeCurrent(gl::GLSurface *) Q_DECL_OVERRIDE { Q_UNREACHABLE(); return false; }
+ virtual void ReleaseCurrent(gl::GLSurface *) Q_DECL_OVERRIDE { Q_UNREACHABLE(); }
+ virtual bool IsCurrent(gl::GLSurface *) Q_DECL_OVERRIDE { Q_UNREACHABLE(); return false; }
virtual void OnSetSwapInterval(int) Q_DECL_OVERRIDE { Q_UNREACHABLE(); }
- virtual scoped_refptr<gfx::GPUTimingClient> CreateGPUTimingClient() Q_DECL_OVERRIDE
+ virtual scoped_refptr<gl::GPUTimingClient> CreateGPUTimingClient() Q_DECL_OVERRIDE
{
return nullptr;
}
@@ -305,9 +318,9 @@ private:
void *m_handle;
};
-class ShareGroupQtQuick : public gfx::GLShareGroup {
+class ShareGroupQtQuick : public gl::GLShareGroup {
public:
- virtual gfx::GLContext* GetContext() Q_DECL_OVERRIDE { return m_shareContextQtQuick.get(); }
+ virtual gl::GLContext* GetContext() Q_DECL_OVERRIDE { return m_shareContextQtQuick.get(); }
virtual void AboutToAddFirstContext() Q_DECL_OVERRIDE;
private:
@@ -316,12 +329,14 @@ private:
void ShareGroupQtQuick::AboutToAddFirstContext()
{
+#ifndef QT_NO_OPENGL
// This currently has to be setup by ::main in all applications using QQuickWebEngineView with delegated rendering.
QOpenGLContext *shareContext = qt_gl_global_share_context();
if (!shareContext) {
qFatal("QWebEngine: OpenGL resource sharing is not set up in QtQuick. Please make sure to call QtWebEngine::initialize() in your main() function.");
}
m_shareContextQtQuick = make_scoped_refptr(new QtShareGLContext(shareContext));
+#endif
}
class QuotaPermissionContextQt : public content::QuotaPermissionContext {
@@ -353,7 +368,7 @@ ContentBrowserClientQt *ContentBrowserClientQt::Get()
content::BrowserMainParts *ContentBrowserClientQt::CreateBrowserMainParts(const content::MainFunctionParams&)
{
- m_browserMainParts = new BrowserMainPartsQt;
+ m_browserMainParts = new BrowserMainPartsQt();
return m_browserMainParts;
}
@@ -367,8 +382,12 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost*
host->AddFilter(new BrowserMessageFilterQt(id));
#endif
#if defined(ENABLE_SPELLCHECK)
+ // SpellCheckMessageFilter is required for both Hunspell and Native configurations.
host->AddFilter(new SpellCheckMessageFilter(id));
#endif
+#if defined(Q_OS_MACOS) && defined(USE_BROWSER_SPELLCHECKER)
+ host->AddFilter(new SpellCheckMessageFilterPlatform(id));
+#endif
#if defined(ENABLE_BASIC_PRINTING)
host->AddFilter(new PrintingMessageFilterQt(host->GetID()));
#endif // defined(ENABLE_BASIC_PRINTING)
@@ -380,7 +399,7 @@ void ContentBrowserClientQt::ResourceDispatcherHostCreated()
content::ResourceDispatcherHost::Get()->SetDelegate(m_resourceDispatcherHostDelegate.get());
}
-gfx::GLShareGroup *ContentBrowserClientQt::GetInProcessGpuShareGroup()
+gl::GLShareGroup *ContentBrowserClientQt::GetInProcessGpuShareGroup()
{
if (!m_shareGroupQtQuick.get())
m_shareGroupQtQuick = new ShareGroupQtQuick;
@@ -398,14 +417,41 @@ void ContentBrowserClientQt::OverrideWebkitPrefs(content::RenderViewHost *rvh, c
static_cast<WebContentsDelegateQt*>(webContents->GetDelegate())->overrideWebPreferences(webContents, web_prefs);
}
-content::AccessTokenStore *ContentBrowserClientQt::CreateAccessTokenStore()
-{
- return new AccessTokenStoreQt;
-}
+namespace {
+
+// A provider of services needed by Geolocation.
+class GeolocationDelegateQt : public content::GeolocationDelegate {
+public:
+ GeolocationDelegateQt() {}
+ content::AccessTokenStore* CreateAccessTokenStore() final
+ {
+ return new AccessTokenStoreQt;
+ }
+
+ content::LocationProvider* OverrideSystemLocationProvider() final
+ {
+#ifdef QT_USE_POSITIONING
+ if (!m_location_provider)
+ m_location_provider = base::WrapUnique(new LocationProviderQt);
+ return m_location_provider.get();
+#else
+ return nullptr;
+#endif
+ }
-net::URLRequestContextGetter* ContentBrowserClientQt::CreateRequestContext(content::BrowserContext* browser_context, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors)
+private:
+#ifdef QT_USE_POSITIONING
+ std::unique_ptr<LocationProviderQt> m_location_provider;
+#endif
+
+ DISALLOW_COPY_AND_ASSIGN(GeolocationDelegateQt);
+};
+
+} // anonymous namespace
+
+content::GeolocationDelegate *ContentBrowserClientQt::CreateGeolocationDelegate()
{
- return static_cast<BrowserContextQt*>(browser_context)->CreateRequestContext(protocol_handlers, std::move(request_interceptors));
+ return new GeolocationDelegateQt;
}
content::QuotaPermissionContext *ContentBrowserClientQt::CreateQuotaPermissionContext()
@@ -437,20 +483,11 @@ void ContentBrowserClientQt::AllowCertificateError(content::WebContents *webCont
void ContentBrowserClientQt::SelectClientCertificate(content::WebContents * /*webContents*/,
net::SSLCertRequestInfo * /*certRequestInfo*/,
- scoped_ptr<content::ClientCertificateDelegate> delegate)
+ std::unique_ptr<content::ClientCertificateDelegate> delegate)
{
delegate->ContinueWithCertificate(nullptr);
}
-content::LocationProvider *ContentBrowserClientQt::OverrideSystemLocationProvider()
-{
-#ifdef QT_USE_POSITIONING
- return new LocationProviderQt;
-#else
- return 0; // Leave it up to Chromium to figure something out.
-#endif
-}
-
std::string ContentBrowserClientQt::GetApplicationLocale()
{
return WebEngineLibraryInfo::getApplicationLocale();
@@ -470,11 +507,28 @@ 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(
- scoped_ptr<ppapi::host::HostFactory>(new QtWebEngineCore::PepperHostFactoryQt(browser_host)));
- }
+void ContentBrowserClientQt::DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host)
+{
+ browser_host->GetPpapiHost()->AddHostFactoryFilter(
+ base::WrapUnique(new QtWebEngineCore::PepperHostFactoryQt(browser_host)));
+}
#endif
content::DevToolsManagerDelegate* ContentBrowserClientQt::GetDevToolsManagerDelegate()
diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h
index 2b023db5f..47b880643 100644
--- a/src/core/content_browser_client_qt.h
+++ b/src/core/content_browser_client_qt.h
@@ -41,9 +41,7 @@
#define CONTENT_BROWSER_CLIENT_QT_H
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "content/public/browser/content_browser_client.h"
-#include "third_party/WebKit/public/platform/modules/notifications/WebNotificationPermission.h"
#include <QtCore/qcompilerdetection.h> // Needed for Q_DECL_OVERRIDE
@@ -68,7 +66,7 @@ class WebContents;
struct MainFunctionParams;
}
-namespace gfx {
+namespace gl {
class GLShareGroup;
}
@@ -87,9 +85,9 @@ public:
virtual content::BrowserMainParts* CreateBrowserMainParts(const content::MainFunctionParams&) Q_DECL_OVERRIDE;
virtual void RenderProcessWillLaunch(content::RenderProcessHost* host) Q_DECL_OVERRIDE;
virtual void ResourceDispatcherHostCreated() Q_DECL_OVERRIDE;
- virtual gfx::GLShareGroup* GetInProcessGpuShareGroup() Q_DECL_OVERRIDE;
+ virtual gl::GLShareGroup* GetInProcessGpuShareGroup() Q_DECL_OVERRIDE;
virtual content::MediaObserver* GetMediaObserver() Q_DECL_OVERRIDE;
- virtual content::AccessTokenStore* CreateAccessTokenStore() Q_DECL_OVERRIDE;
+ virtual content::GeolocationDelegate* CreateGeolocationDelegate() Q_DECL_OVERRIDE;
virtual content::QuotaPermissionContext *CreateQuotaPermissionContext() Q_DECL_OVERRIDE;
virtual void OverrideWebkitPrefs(content::RenderViewHost *, content::WebPreferences *) Q_DECL_OVERRIDE;
virtual void AllowCertificateError(content::WebContents* web_contents,
@@ -104,22 +102,24 @@ public:
content::CertificateRequestResultType* result) Q_DECL_OVERRIDE;
virtual void SelectClientCertificate(content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,
- scoped_ptr<content::ClientCertificateDelegate> delegate) Q_DECL_OVERRIDE;
- content::LocationProvider* OverrideSystemLocationProvider() Q_DECL_OVERRIDE;
+ std::unique_ptr<content::ClientCertificateDelegate> delegate) 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
private:
BrowserMainPartsQt* m_browserMainParts;
- scoped_ptr<ResourceDispatcherHostDelegateQt> m_resourceDispatcherHostDelegate;
+ std::unique_ptr<ResourceDispatcherHostDelegateQt> m_resourceDispatcherHostDelegate;
scoped_refptr<ShareGroupQtQuick> m_shareGroupQtQuick;
};
diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp
index 2afd8c3ae..5d51f65aa 100644
--- a/src/core/content_client_qt.cpp
+++ b/src/core/content_client_qt.cpp
@@ -92,8 +92,6 @@ const char kPpapiFlashVersion[] = "ppapi-flash-version";
const char kPpapiWidevinePath[] = "ppapi-widevine-path";
}
-static const base::FilePath::CharType kWidevineCdmBaseDirectory[] = FILE_PATH_LITERAL("WidevineCDM");
-
static const char kWidevineCdmPluginExtension[] = "";
static const int32_t kWidevineCdmPluginPermissions = ppapi::PERMISSION_DEV
@@ -248,11 +246,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 =
@@ -297,6 +293,11 @@ base::StringPiece ContentClientQt::GetDataResource(int resource_id, ui::ScaleFac
return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(resource_id, scale_factor);
}
+base::RefCountedMemory *ContentClientQt::GetDataResourceBytes(int resource_id) const
+{
+ return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id);
+}
+
base::string16 ContentClientQt::GetLocalizedString(int message_id) const
{
return l10n_util::GetStringUTF16(message_id);
diff --git a/src/core/content_client_qt.h b/src/core/content_client_qt.h
index 6a5584cc7..4fd539bf3 100644
--- a/src/core/content_client_qt.h
+++ b/src/core/content_client_qt.h
@@ -56,6 +56,7 @@ public:
#endif
virtual base::StringPiece GetDataResource(int, ui::ScaleFactor) const Q_DECL_OVERRIDE;
+ virtual base::RefCountedMemory* GetDataResourceBytes(int resource_id) const Q_DECL_OVERRIDE;
virtual std::string GetUserAgent() const Q_DECL_OVERRIDE { return getUserAgent(); }
virtual base::string16 GetLocalizedString(int message_id) const Q_DECL_OVERRIDE;
virtual std::string GetProduct() const Q_DECL_OVERRIDE;
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/content_main_delegate_qt.h b/src/core/content_main_delegate_qt.h
index dd7f38f69..3cb3b3bb3 100644
--- a/src/core/content_main_delegate_qt.h
+++ b/src/core/content_main_delegate_qt.h
@@ -42,7 +42,6 @@
#include "content/public/app/content_main_delegate.h"
-#include "base/memory/scoped_ptr.h"
#include <QtCore/qcompilerdetection.h>
#include "content_browser_client_qt.h"
@@ -63,7 +62,7 @@ public:
bool BasicStartupComplete(int* /*exit_code*/) Q_DECL_OVERRIDE;
private:
- scoped_ptr<ContentBrowserClientQt> m_browserClient;
+ std::unique_ptr<ContentBrowserClientQt> m_browserClient;
};
} // namespace QtWebEngineCore
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_common.pri b/src/core/core_common.pri
index 9c29aea71..721e8c71a 100644
--- a/src/core/core_common.pri
+++ b/src/core/core_common.pri
@@ -10,3 +10,4 @@ CHROMIUM_SRC_DIR = $$QTWEBENGINE_ROOT/$$getChromiumSrcDir()
INCLUDEPATH += $$CHROMIUM_SRC_DIR
qtHaveModule(positioning):QT += positioning
+qtHaveModule(printsupport):QT += printsupport
diff --git a/src/core/core_gyp_generator.pro b/src/core/core_gyp_generator.pro
index 7351b108c..2fae21c4d 100644
--- a/src/core/core_gyp_generator.pro
+++ b/src/core/core_gyp_generator.pro
@@ -10,10 +10,18 @@ TEMPLATE = lib
include(core_common.pri)
+macos {
+ # This fixes namespace builds on macOS. Specifically namespace ambiguity issues between Qt and
+ # Chromium forward declarations of NSString.
+ forward_declaration_macro = $$shell_quote(\"Q_FORWARD_DECLARE_OBJC_CLASS(name)=class name;\")
+} else {
+ forward_declaration_macro = "Q_FORWARD_DECLARE_OBJC_CLASS=QT_FORWARD_DECLARE_CLASS"
+}
+
# Defining keywords such as 'signal' clashes with the chromium code base.
DEFINES += QT_NO_KEYWORDS \
QT_USE_QSTRINGBUILDER \
- Q_FORWARD_DECLARE_OBJC_CLASS=QT_FORWARD_DECLARE_CLASS \
+ $$forward_declaration_macro \
QTWEBENGINECORE_VERSION_STR=\\\"$$MODULE_VERSION\\\" \
BUILDING_CHROMIUM
@@ -25,8 +33,7 @@ RCC_DIR = $$OUT_PWD/$$getConfigDir()/.rcc
# whenever we are cross compiling.
cross_compile: DEFINES += QTWEBENGINE_EMBEDDED_SWITCHES
-contains(QT_CONFIG, egl): CONFIG += egl
-else: DEFINES += QT_NO_EGL
+qtConfig(egl): CONFIG += egl
RESOURCES += devtools.qrc
@@ -74,30 +81,28 @@ SOURCES = \
render_view_observer_host_qt.cpp \
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 \
renderer/pepper/pepper_renderer_host_factory_qt.cpp \
renderer/render_frame_observer_qt.cpp \
renderer/render_view_observer_qt.cpp \
renderer/user_resource_controller.cpp \
renderer/web_channel_ipc_transport.cpp \
+ renderer_host/pepper/pepper_flash_browser_host_qt.cpp \
+ renderer_host/pepper/pepper_host_factory_qt.cpp \
+ renderer_host/pepper/pepper_isolated_file_system_message_filter.cpp \
+ renderer_host/resource_dispatcher_host_delegate_qt.cpp \
+ renderer_host/user_resource_controller_host.cpp \
+ renderer_host/web_channel_ipc_transport_host.cpp \
resource_bundle_qt.cpp \
resource_context_qt.cpp \
- resource_dispatcher_host_delegate_qt.cpp \
ssl_host_state_delegate_qt.cpp \
- stream_video_node.cpp \
surface_factory_qt.cpp \
type_conversion.cpp \
url_request_context_getter_qt.cpp \
url_request_custom_job.cpp \
url_request_custom_job_delegate.cpp \
url_request_qrc_job_qt.cpp \
- user_resource_controller_host.cpp \
user_script.cpp \
- web_channel_ipc_transport_host.cpp \
web_contents_adapter.cpp \
web_contents_delegate_qt.cpp \
web_contents_view_qt.cpp \
@@ -106,8 +111,7 @@ SOURCES = \
web_engine_library_info.cpp \
web_engine_settings.cpp \
web_engine_visited_links_manager.cpp \
- web_event_factory.cpp \
- yuv_video_node.cpp
+ web_event_factory.cpp
HEADERS = \
access_token_store_qt.h \
@@ -143,6 +147,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 \
@@ -157,29 +162,27 @@ HEADERS = \
render_widget_host_view_qt.h \
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 \
renderer/pepper/pepper_renderer_host_factory_qt.h \
renderer/render_frame_observer_qt.h \
renderer/render_view_observer_qt.h \
renderer/user_resource_controller.h \
renderer/web_channel_ipc_transport.h \
+ renderer_host/pepper/pepper_flash_browser_host_qt.h \
+ renderer_host/pepper/pepper_host_factory_qt.h \
+ renderer_host/pepper/pepper_isolated_file_system_message_filter.h \
+ renderer_host/resource_dispatcher_host_delegate_qt.h \
+ renderer_host/user_resource_controller_host.h \
+ renderer_host/web_channel_ipc_transport_host.h \
resource_context_qt.h \
- resource_dispatcher_host_delegate_qt.h \
ssl_host_state_delegate_qt.h \
- stream_video_node.h \
surface_factory_qt.h \
type_conversion.h \
url_request_context_getter_qt.h \
url_request_custom_job.h \
url_request_custom_job_delegate.h \
url_request_qrc_job_qt.h \
- user_resource_controller_host.h \
user_script.h \
- web_channel_ipc_transport_host.h \
web_contents_adapter.h \
web_contents_adapter_client.h \
web_contents_adapter_p.h \
@@ -190,11 +193,25 @@ HEADERS = \
web_engine_library_info.h \
web_engine_settings.h \
web_engine_visited_links_manager.h \
- web_event_factory.h \
- yuv_video_node.h
+ web_event_factory.h
+
+contains(QT_CONFIG, opengl) {
+ SOURCES += \
+ yuv_video_node.cpp \
+ stream_video_node.cpp
+
+ HEADERS += \
+ yuv_video_node.h \
+ stream_video_node.h
+}
qtHaveModule(positioning) {
SOURCES += location_provider_qt.cpp
HEADERS += location_provider_qt.h
DEFINES += QT_USE_POSITIONING=1
}
+
+qtHaveModule(printsupport) {
+ SOURCES += pdfium_printing_wrapper_qt.cpp
+ HEADERS += pdfium_printing_wrapper_qt.h
+}
diff --git a/src/core/core_module.pro b/src/core/core_module.pro
index 3b9dab457..65e46dcec 100644
--- a/src/core/core_module.pro
+++ b/src/core/core_module.pro
@@ -40,9 +40,9 @@ win32-msvc* {
# and doesn't let Chromium get access to libc symbols through dlsym.
CONFIG -= bsymbolic_functions
-contains(QT_CONFIG, egl): CONFIG += egl
+qtConfig(egl): CONFIG += egl
-linux: contains(QT_CONFIG, separate_debug_info): QMAKE_POST_LINK="cd $(DESTDIR) && $(STRIP) --strip-unneeded $(TARGET)"
+linux:qtConfig(separate_debug_info): QMAKE_POST_LINK="cd $(DESTDIR) && $(STRIP) --strip-unneeded $(TARGET)"
REPACK_DIR = $$OUT_PWD/$$getConfigDir()/gen/repack
# Duplicated from resources/resources.gyp
@@ -58,7 +58,7 @@ resources.files = $$REPACK_DIR/qtwebengine_resources.pak \
icu.files = $$OUT_PWD/$$getConfigDir()/icudtl.dat
!debug_and_release|!build_all|CONFIG(release, debug|release) {
- contains(QT_CONFIG, qt_framework) {
+ qtConfig(framework) {
locales.version = Versions
locales.path = Resources/qtwebengine_locales
resources.version = Versions
@@ -83,7 +83,7 @@ icu.files = $$OUT_PWD/$$getConfigDir()/icudtl.dat
}
}
- !contains(QT_CONFIG, qt_framework):!force_independent {
+ !qtConfig(framework):!force_independent {
#
# Copy essential files to the qtbase build directory for non-prefix builds
#
diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp
index 8d0b8166a..44e37aeb6 100644
--- a/src/core/delegated_frame_node.cpp
+++ b/src/core/delegated_frame_node.cpp
@@ -59,7 +59,6 @@
#include "cc/output/delegated_frame_data.h"
#include "cc/quads/debug_border_draw_quad.h"
#include "cc/quads/draw_quad.h"
-#include "cc/quads/io_surface_draw_quad.h"
#include "cc/quads/render_pass_draw_quad.h"
#include "cc/quads/solid_color_draw_quad.h"
#include "cc/quads/stream_video_draw_quad.h"
@@ -71,13 +70,22 @@
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_fence.h"
-#include <QOpenGLContext>
-#include <QOpenGLFunctions>
-#include <QSGSimpleRectNode>
-#include <QSGSimpleTextureNode>
+#ifndef QT_NO_OPENGL
+# include <QOpenGLContext>
+# include <QOpenGLFunctions>
+# include <QSGFlatColorMaterial>
+#endif
#include <QSGTexture>
#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>
@@ -91,8 +99,20 @@
#define GL_TEXTURE_RECTANGLE 0x84F5
#endif
-namespace QtWebEngineCore {
+#ifndef GL_LINEAR
+#define GL_LINEAR 0x2601
+#endif
+
+#ifndef GL_RGBA
+#define GL_RGBA 0x1908
+#endif
+#ifndef GL_RGB
+#define GL_RGB 0x1907
+#endif
+
+namespace QtWebEngineCore {
+#ifndef QT_NO_OPENGL
class MailboxTexture : public QSGTexture, protected QOpenGLFunctions {
public:
MailboxTexture(const gpu::MailboxHolder &mailboxHolder, const QSize textureSize);
@@ -122,7 +142,7 @@ private:
#endif
friend class DelegatedFrameNode;
};
-
+#endif // QT_NO_OPENGL
class ResourceHolder {
public:
ResourceHolder(const cc::TransferableResource &resource);
@@ -196,22 +216,23 @@ static QSGNode *buildLayerChain(QSGNode *chainParent, const cc::SharedQuadState
return layerChain;
}
-static void waitChromiumSync(gfx::TransferableFence *sync)
+#ifndef QT_NO_OPENGL
+static void waitChromiumSync(gl::TransferableFence *sync)
{
// Chromium uses its own GL bindings and stores in in thread local storage.
// For that reason, let chromium_gpu_helper.cpp contain the producing code that will run in the Chromium
// GPU thread, and put the sync consuming code here that will run in the QtQuick SG or GUI thread.
switch (sync->type) {
- case gfx::TransferableFence::NoSync:
+ case gl::TransferableFence::NoSync:
break;
- case gfx::TransferableFence::EglSync:
+ case gl::TransferableFence::EglSync:
#ifdef EGL_KHR_reusable_sync
{
static bool resolved = false;
static PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR = 0;
if (!resolved) {
- if (gfx::GLSurfaceQt::HasEGLExtension("EGL_KHR_fence_sync")) {
+ if (gl::GLSurfaceQt::HasEGLExtension("EGL_KHR_fence_sync")) {
QOpenGLContext *context = QOpenGLContext::currentContext();
eglClientWaitSyncKHR = (PFNEGLCLIENTWAITSYNCKHRPROC)context->getProcAddress("eglClientWaitSyncKHR");
}
@@ -224,7 +245,7 @@ static void waitChromiumSync(gfx::TransferableFence *sync)
}
#endif
break;
- case gfx::TransferableFence::ArbSync:
+ case gl::TransferableFence::ArbSync:
typedef void (QOPENGLF_APIENTRYP WaitSyncPtr)(GLsync sync, GLbitfield flags, GLuint64 timeout);
static WaitSyncPtr glWaitSync_ = 0;
if (!glWaitSync_) {
@@ -237,22 +258,22 @@ static void waitChromiumSync(gfx::TransferableFence *sync)
}
}
-static void deleteChromiumSync(gfx::TransferableFence *sync)
+static void deleteChromiumSync(gl::TransferableFence *sync)
{
// Chromium uses its own GL bindings and stores in in thread local storage.
// For that reason, let chromium_gpu_helper.cpp contain the producing code that will run in the Chromium
// GPU thread, and put the sync consuming code here that will run in the QtQuick SG or GUI thread.
switch (sync->type) {
- case gfx::TransferableFence::NoSync:
+ case gl::TransferableFence::NoSync:
break;
- case gfx::TransferableFence::EglSync:
+ case gl::TransferableFence::EglSync:
#ifdef EGL_KHR_reusable_sync
{
static bool resolved = false;
static PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR = 0;
if (!resolved) {
- if (gfx::GLSurfaceQt::HasEGLExtension("EGL_KHR_fence_sync")) {
+ if (gl::GLSurfaceQt::HasEGLExtension("EGL_KHR_fence_sync")) {
QOpenGLContext *context = QOpenGLContext::currentContext();
eglDestroySyncKHR = (PFNEGLDESTROYSYNCKHRPROC)context->getProcAddress("eglDestroySyncKHR");
}
@@ -267,7 +288,7 @@ static void deleteChromiumSync(gfx::TransferableFence *sync)
}
#endif
break;
- case gfx::TransferableFence::ArbSync:
+ case gl::TransferableFence::ArbSync:
typedef void (QOPENGLF_APIENTRYP DeleteSyncPtr)(GLsync sync);
static DeleteSyncPtr glDeleteSync_ = 0;
if (!glDeleteSync_) {
@@ -355,6 +376,7 @@ void MailboxTexture::fetchTexture(gpu::gles2::MailboxManager *mailboxManager)
#endif
}
}
+#endif //QT_NO_OPENGL
ResourceHolder::ResourceHolder(const cc::TransferableResource &resource)
: m_resource(resource)
@@ -368,7 +390,7 @@ QSharedPointer<QSGTexture> ResourceHolder::initTexture(bool quadNeedsBlending, R
if (!texture) {
if (m_resource.is_software) {
Q_ASSERT(apiDelegate);
- scoped_ptr<cc::SharedBitmap> sharedBitmap = content::HostSharedBitmapManager::current()->GetSharedBitmapFromId(m_resource.size, m_resource.mailbox_holder.mailbox);
+ std::unique_ptr<cc::SharedBitmap> sharedBitmap = content::HostSharedBitmapManager::current()->GetSharedBitmapFromId(m_resource.size, m_resource.mailbox_holder.mailbox);
// QSG interprets QImage::hasAlphaChannel meaning that a node should enable blending
// to draw it but Chromium keeps this information in the quads.
// The input format is currently always Format_ARGB32_Premultiplied, so assume that all
@@ -379,8 +401,12 @@ QSharedPointer<QSGTexture> ResourceHolder::initTexture(bool quadNeedsBlending, R
QImage image(sharedBitmap->pixels(), m_resource.size.width(), m_resource.size.height(), format);
texture.reset(apiDelegate->createTextureFromImage(image.copy()));
} else {
+#ifndef QT_NO_OPENGL
texture.reset(new MailboxTexture(m_resource.mailbox_holder, toQt(m_resource.size)));
static_cast<MailboxTexture *>(texture.data())->setHasAlphaChannel(quadNeedsBlending);
+#else
+ Q_UNREACHABLE();
+#endif
}
m_texture = texture;
}
@@ -416,12 +442,12 @@ RectClipNode::RectClipNode(const QRectF &rect)
DelegatedFrameNode::DelegatedFrameNode()
: m_numPendingSyncPoints(0)
-#if defined(USE_X11)
+#if defined(USE_X11) && !defined(QT_NO_OPENGL)
, m_contextShared(true)
#endif
{
setFlag(UsePreprocess);
-#if defined(USE_X11)
+#if defined(USE_X11) && !defined(QT_NO_OPENGL)
QOpenGLContext *currentContext = QOpenGLContext::currentContext() ;
QOpenGLContext *sharedContext = qt_gl_global_share_context();
if (!QOpenGLContext::areSharing(currentContext, sharedContext)) {
@@ -443,6 +469,7 @@ DelegatedFrameNode::~DelegatedFrameNode()
void DelegatedFrameNode::preprocess()
{
+#ifndef QT_NO_OPENGL
// With the threaded render loop the GUI thread has been unlocked at this point.
// We can now wait for the Chromium GPU thread to produce textures that will be
// rendered on our quads and fetch the IDs from the mailboxes we were given.
@@ -465,6 +492,7 @@ void DelegatedFrameNode::preprocess()
// Proceed with the actual update.
pair.second->updateTexture();
}
+#endif
}
static YUVVideoMaterial::ColorSpace toQt(cc::YUVVideoDrawQuad::ColorSpace color_space)
@@ -576,8 +604,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);
@@ -588,8 +616,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));
@@ -597,7 +625,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
@@ -608,12 +636,13 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
rectangleNode->setColor(toQt(scquad->color));
currentLayerChain->appendChildNode(rectangleNode);
break;
+#ifndef QT_NO_OPENGL
} case cc::DrawQuad::DEBUG_BORDER: {
const cc::DebugBorderDrawQuad *dbquad = cc::DebugBorderDrawQuad::MaterialCast(quad);
QSGGeometryNode *geometryNode = new QSGGeometryNode;
QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 4);
- geometry->setDrawingMode(GL_LINE_LOOP);
+ geometry->setDrawingMode(QSGGeometry::DrawLineLoop);
geometry->setLineWidth(dbquad->width);
// QSGGeometry::updateRectGeometry would actually set the corners in the following order:
// top-left, bottom-left, top-right, bottom-right, leading to a nice criss cross, instead
@@ -632,17 +661,19 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
geometryNode->setFlags(QSGNode::OwnsGeometry | QSGNode::OwnsMaterial);
currentLayerChain->appendChildNode(geometryNode);
break;
+#endif
} case cc::DrawQuad::TILED_CONTENT: {
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);
textureNode->setTexture(initAndHoldTexture(resource, quad->ShouldDrawWithBlending(), apiDelegate));
currentLayerChain->appendChildNode(textureNode);
break;
+#ifndef QT_NO_OPENGL
} case cc::DrawQuad::YUV_VIDEO_CONTENT: {
const cc::YUVVideoDrawQuad *vquad = cc::YUVVideoDrawQuad::MaterialCast(quad);
ResourceHolder *yResource = findAndHoldResource(vquad->y_plane_resource_id(), resourceCandidates);
@@ -658,8 +689,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;
@@ -675,23 +708,10 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
svideoNode->setTextureMatrix(toQt(squad->matrix.matrix()));
currentLayerChain->appendChildNode(svideoNode);
break;
-#endif
- }
- case cc::DrawQuad::IO_SURFACE_CONTENT: {
- const cc::IOSurfaceDrawQuad *ioquad = cc::IOSurfaceDrawQuad::MaterialCast(quad);
- ResourceHolder *resource = findAndHoldResource(ioquad->io_surface_resource_id(), resourceCandidates);
- MailboxTexture *texture = static_cast<MailboxTexture *>(initAndHoldTexture(resource, quad->ShouldDrawWithBlending()));
- texture->setTarget(GL_TEXTURE_RECTANGLE);
-
- bool flip = ioquad->orientation != cc::IOSurfaceDrawQuad::FLIPPED;
- StreamVideoNode *svideoNode = new StreamVideoNode(texture, flip, RectangleTarget);
- QMatrix4x4 matrix;
- matrix.scale(ioquad->io_surface_size.width(), ioquad->io_surface_size.height());
- svideoNode->setRect(toQt(ioquad->rect));
- svideoNode->setTextureMatrix(matrix);
- currentLayerChain->appendChildNode(svideoNode);
- break;
- }
+#endif // GL_OES_EGL_image_external
+#endif // QT_NO_OPENGL
+ } case cc::DrawQuad::SURFACE_CONTENT:
+ Q_UNREACHABLE();
default:
qWarning("Unimplemented quad material: %d", quad->material);
}
@@ -727,7 +747,8 @@ QSGTexture *DelegatedFrameNode::initAndHoldTexture(ResourceHolder *resource, boo
void DelegatedFrameNode::fetchAndSyncMailboxes(QList<MailboxTexture *> &mailboxesToFetch)
{
- QList<gfx::TransferableFence> transferredFences;
+#ifndef QT_NO_OPENGL
+ QList<gl::TransferableFence> transferredFences;
{
QMutexLocker lock(&m_mutex);
@@ -759,7 +780,7 @@ void DelegatedFrameNode::fetchAndSyncMailboxes(QList<MailboxTexture *> &mailboxe
m_textureFences.swap(transferredFences);
}
- Q_FOREACH (gfx::TransferableFence sync, transferredFences) {
+ Q_FOREACH (gl::TransferableFence sync, transferredFences) {
// We need to wait on the fences on the Qt current context, and
// can therefore not use GLFence routines that uses a different
// concept of current context.
@@ -822,25 +843,33 @@ void DelegatedFrameNode::fetchAndSyncMailboxes(QList<MailboxTexture *> &mailboxe
currentContext->makeCurrent(surface);
}
#endif
+#else
+ Q_UNUSED(mailboxesToFetch)
+#endif //QT_NO_OPENGL
}
void DelegatedFrameNode::pullTexture(DelegatedFrameNode *frameNode, MailboxTexture *texture)
{
+#ifndef QT_NO_OPENGL
gpu::gles2::MailboxManager *mailboxManager = mailbox_manager();
gpu::SyncToken &syncToken = texture->mailboxHolder().sync_token;
if (syncToken.HasData())
mailboxManager->PullTextureUpdates(syncToken);
texture->fetchTexture(mailboxManager);
- if (!!gfx::GLContext::GetCurrent() && gfx::GLFence::IsSupported()) {
+ if (!!gl::GLContext::GetCurrent() && gl::GLFence::IsSupported()) {
// Create a fence on the Chromium GPU-thread and context
- gfx::GLFence *fence = gfx::GLFence::Create();
+ gl::GLFence *fence = gl::GLFence::Create();
// But transfer it to something generic since we need to read it using Qt's OpenGL.
frameNode->m_textureFences.append(fence->Transfer());
delete fence;
}
if (--frameNode->m_numPendingSyncPoints == 0)
base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&DelegatedFrameNode::fenceAndUnlockQt, frameNode));
+#else
+ Q_UNUSED(frameNode)
+ Q_UNUSED(texture)
+#endif
}
void DelegatedFrameNode::fenceAndUnlockQt(DelegatedFrameNode *frameNode)
diff --git a/src/core/delegated_frame_node.h b/src/core/delegated_frame_node.h
index 005f4c768..36ec20f1d 100644
--- a/src/core/delegated_frame_node.h
+++ b/src/core/delegated_frame_node.h
@@ -40,7 +40,6 @@
#ifndef DELEGATED_FRAME_NODE_H
#define DELEGATED_FRAME_NODE_H
-#include "base/memory/scoped_ptr.h"
#include "cc/quads/render_pass.h"
#include "cc/resources/transferable_resource.h"
#include "gpu/command_buffer/service/sync_point_manager.h"
@@ -74,7 +73,7 @@ class ChromiumCompositorData : public QSharedData {
public:
ChromiumCompositorData() : frameDevicePixelRatio(1) { }
QHash<unsigned, QSharedPointer<ResourceHolder> > resourceHolders;
- scoped_ptr<cc::DelegatedFrameData> frameData;
+ std::unique_ptr<cc::DelegatedFrameData> frameData;
qreal frameDevicePixelRatio;
};
@@ -104,8 +103,8 @@ private:
int m_numPendingSyncPoints;
QWaitCondition m_mailboxesFetchedWaitCond;
QMutex m_mutex;
- QList<gfx::TransferableFence> m_textureFences;
- scoped_ptr<gpu::SyncPointClient> m_syncPointClient;
+ QList<gl::TransferableFence> m_textureFences;
+ std::unique_ptr<gpu::SyncPointClient> m_syncPointClient;
#if defined(USE_X11)
bool m_contextShared;
QScopedPointer<QOffscreenSurface> m_offsurface;
diff --git a/src/core/desktop_screen_qt.cpp b/src/core/desktop_screen_qt.cpp
index 0904aec59..f18a27ed7 100644
--- a/src/core/desktop_screen_qt.cpp
+++ b/src/core/desktop_screen_qt.cpp
@@ -39,6 +39,9 @@
#include "desktop_screen_qt.h"
+#include "ui/display/display.h"
+#include "ui/gfx/geometry/point.h"
+
namespace QtWebEngineCore {
gfx::Point DesktopScreenQt::GetCursorScreenPoint()
@@ -47,10 +50,10 @@ gfx::Point DesktopScreenQt::GetCursorScreenPoint()
return gfx::Point();
}
-gfx::NativeWindow DesktopScreenQt::GetWindowUnderCursor()
+bool DesktopScreenQt::IsWindowUnderCursor(gfx::NativeWindow)
{
Q_UNREACHABLE();
- return gfx::NativeWindow();
+ return false;
}
gfx::NativeWindow DesktopScreenQt::GetWindowAtScreenPoint(const gfx::Point& point)
@@ -65,42 +68,42 @@ int DesktopScreenQt::GetNumDisplays() const
return 0;
}
-std::vector<gfx::Display> DesktopScreenQt::GetAllDisplays() const
+std::vector<display::Display> DesktopScreenQt::GetAllDisplays() const
{
Q_UNREACHABLE();
- return std::vector<gfx::Display>();
+ return std::vector<display::Display>();
}
-gfx::Display DesktopScreenQt::GetDisplayNearestWindow(gfx::NativeView window) const
+display::Display DesktopScreenQt::GetDisplayNearestWindow(gfx::NativeView window) const
{
// RenderViewHostImpl::OnStartDragging uses this to determine
// the scale factor for the view.
- return gfx::Display();
+ return display::Display();
}
-gfx::Display DesktopScreenQt::GetDisplayNearestPoint(const gfx::Point& point) const
+display::Display DesktopScreenQt::GetDisplayNearestPoint(const gfx::Point& point) const
{
Q_UNREACHABLE();
- return gfx::Display();
+ return display::Display();
}
-gfx::Display DesktopScreenQt::GetDisplayMatching(const gfx::Rect& match_rect) const
+display::Display DesktopScreenQt::GetDisplayMatching(const gfx::Rect& match_rect) const
{
Q_UNREACHABLE();
- return gfx::Display();
+ return display::Display();
}
-gfx::Display DesktopScreenQt::GetPrimaryDisplay() const
+display::Display DesktopScreenQt::GetPrimaryDisplay() const
{
- return gfx::Display();
+ return display::Display();
}
-void DesktopScreenQt::AddObserver(gfx::DisplayObserver* observer)
+void DesktopScreenQt::AddObserver(display::DisplayObserver* observer)
{
Q_UNREACHABLE();
}
-void DesktopScreenQt::RemoveObserver(gfx::DisplayObserver* observer)
+void DesktopScreenQt::RemoveObserver(display::DisplayObserver* observer)
{
Q_UNREACHABLE();
}
diff --git a/src/core/desktop_screen_qt.h b/src/core/desktop_screen_qt.h
index ec7fe2e32..0e7588ae2 100644
--- a/src/core/desktop_screen_qt.h
+++ b/src/core/desktop_screen_qt.h
@@ -40,26 +40,26 @@
#ifndef DESKTOP_SCREEN_QT_H
#define DESKTOP_SCREEN_QT_H
-#include "ui/gfx/screen.h"
+#include "ui/display/screen.h"
#include <QtGlobal>
namespace QtWebEngineCore {
-class DesktopScreenQt : public gfx::Screen {
+class DesktopScreenQt : public display::Screen {
public:
// Overridden from gfx::Screen:
virtual gfx::Point GetCursorScreenPoint() Q_DECL_OVERRIDE;
- virtual gfx::NativeWindow GetWindowUnderCursor() Q_DECL_OVERRIDE;
+ virtual bool IsWindowUnderCursor(gfx::NativeWindow) Q_DECL_OVERRIDE;
virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) Q_DECL_OVERRIDE;
virtual int GetNumDisplays() const Q_DECL_OVERRIDE;
- virtual std::vector<gfx::Display> GetAllDisplays() const Q_DECL_OVERRIDE;
- virtual gfx::Display GetDisplayNearestWindow(gfx::NativeView window) const Q_DECL_OVERRIDE;
- virtual gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const Q_DECL_OVERRIDE;
- virtual gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const Q_DECL_OVERRIDE;
- virtual gfx::Display GetPrimaryDisplay() const Q_DECL_OVERRIDE;
- virtual void AddObserver(gfx::DisplayObserver* observer) Q_DECL_OVERRIDE;
- virtual void RemoveObserver(gfx::DisplayObserver* observer) Q_DECL_OVERRIDE;
+ virtual std::vector<display::Display> GetAllDisplays() const Q_DECL_OVERRIDE;
+ virtual display::Display GetDisplayNearestWindow(gfx::NativeView window) const Q_DECL_OVERRIDE;
+ virtual display::Display GetDisplayNearestPoint(const gfx::Point& point) const Q_DECL_OVERRIDE;
+ virtual display::Display GetDisplayMatching(const gfx::Rect& match_rect) const Q_DECL_OVERRIDE;
+ virtual display::Display GetPrimaryDisplay() const Q_DECL_OVERRIDE;
+ virtual void AddObserver(display::DisplayObserver* observer) Q_DECL_OVERRIDE;
+ virtual void RemoveObserver(display::DisplayObserver* observer) Q_DECL_OVERRIDE;
};
} // namespace QtWebEngineCore
diff --git a/src/core/dev_tools_http_handler_delegate_qt.cpp b/src/core/dev_tools_http_handler_delegate_qt.cpp
index f3ffcc86d..5fd35ee29 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"
@@ -85,10 +86,10 @@ public:
: m_address(address), m_port(port), m_backlog(backlog)
{}
private:
- scoped_ptr<net::ServerSocket> CreateForHttpServer() override {
- scoped_ptr<net::ServerSocket> socket(new net::TCPServerSocket(nullptr, net::NetLog::Source()));
+ std::unique_ptr<net::ServerSocket> CreateForHttpServer() override {
+ std::unique_ptr<net::ServerSocket> socket(new net::TCPServerSocket(nullptr, net::NetLog::Source()));
if (socket->ListenWithAddressAndPort(m_address, m_port, m_backlog) != net::OK)
- return scoped_ptr<net::ServerSocket>();
+ return std::unique_ptr<net::ServerSocket>();
return socket;
}
@@ -178,18 +179,18 @@ DevToolsTargetDescriptor::List DevToolsDiscoveryProviderQt::GetDescriptors()
namespace QtWebEngineCore {
-scoped_ptr<DevToolsHttpHandler> createDevToolsHttpHandler()
+std::unique_ptr<DevToolsHttpHandler> createDevToolsHttpHandler()
{
DevToolsHttpHandlerDelegateQt *delegate = new DevToolsHttpHandlerDelegateQt();
if (!delegate->isValid()) {
delete delegate;
return nullptr;
}
- scoped_ptr<DevToolsHttpHandler::ServerSocketFactory> factory(new TCPServerSocketFactory(delegate->bindAddress().toStdString(), delegate->port(), 1));
+ std::unique_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()));
- DevToolsDiscoveryManager::GetInstance()->AddProvider(scoped_ptr<DevToolsDiscoveryManager::Provider>(new DevToolsDiscoveryProviderQt()));
- return handler;
+ std::unique_ptr<DevToolsHttpHandler> handler(new DevToolsHttpHandler(std::move(factory), std::string(), delegate, base::FilePath(), base::FilePath(), std::string(), std::string()));
+ DevToolsDiscoveryManager::GetInstance()->AddProvider(base::WrapUnique(new DevToolsDiscoveryProviderQt()));
+ 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/doc/src/qtwebenginecore-index.qdoc b/src/core/doc/src/qtwebenginecore-index.qdoc
index 70af397ce..4d540e277 100644
--- a/src/core/doc/src/qtwebenginecore-index.qdoc
+++ b/src/core/doc/src/qtwebenginecore-index.qdoc
@@ -28,7 +28,6 @@
/*!
\page qtwebenginecore-index.html
\title Qt WebEngine Core
- \ingroup modules
\brief Provides common API shared by Qt WebEngine and Qt WebEngine Widgets.
diff --git a/src/core/doc/src/qtwebenginecore-module.qdoc b/src/core/doc/src/qtwebenginecore-module.qdoc
index 6dc2478fc..0ac20a794 100644
--- a/src/core/doc/src/qtwebenginecore-module.qdoc
+++ b/src/core/doc/src/qtwebenginecore-module.qdoc
@@ -32,6 +32,7 @@
\brief Provides public API shared by both QtWebEngine and QtWebEngineWidgets
\since 5.6
\ingroup qtwebengine-modules
+ \ingroup modules
To include the definitions of the module's classes, use the
following directive:
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..74b097ef6 100644
--- a/src/core/file_picker_controller.cpp
+++ b/src/core/file_picker_controller.cpp
@@ -111,20 +111,20 @@ void FilePickerController::filesSelectedInChooser(const QStringList &filesList,
if (this->m_mode == UploadFolder && !filesList.isEmpty()
&& QFileInfo(filesList.first()).isDir()) // Enumerate the directory
files = listRecursively(QDir(filesList.first()));
- rvh->FilesSelectedInChooser(toVector<content::FileChooserFileInfo>(files), static_cast<content::FileChooserParams::Mode>(this->m_mode));
+ rvh->GetMainFrame()->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_context_qt.cpp b/src/core/gl_context_qt.cpp
index b7d82e77a..a1855b060 100644
--- a/src/core/gl_context_qt.cpp
+++ b/src/core/gl_context_qt.cpp
@@ -63,11 +63,15 @@ namespace {
inline void *resourceForContext(const QByteArray &resource)
{
+#ifndef QT_NO_OPENGL
QOpenGLContext *shareContext = qt_gl_global_share_context();
if (!shareContext) {
qFatal("QWebEngine: OpenGL resource sharing is not set up in QtQuick. Please make sure to call QtWebEngine::initialize() in your main() function.");
}
return qApp->platformNativeInterface()->nativeResourceForContext(resource, shareContext);
+#else
+ return nullptr;
+#endif
}
inline void *resourceForIntegration(const QByteArray &resource)
@@ -89,19 +93,19 @@ void GLContextHelper::destroy()
contextHelper = 0;
}
-bool GLContextHelper::initializeContextOnBrowserThread(gfx::GLContext* context, gfx::GLSurface* surface)
+bool GLContextHelper::initializeContextOnBrowserThread(gl::GLContext* context, gl::GLSurface* surface)
{
- return context->Initialize(surface, gfx::PreferDiscreteGpu);
+ return context->Initialize(surface, gl::PreferDiscreteGpu);
}
-bool GLContextHelper::initializeContext(gfx::GLContext* context, gfx::GLSurface* surface)
+bool GLContextHelper::initializeContext(gl::GLContext* context, gl::GLSurface* surface)
{
bool ret = false;
Qt::ConnectionType connType = (QThread::currentThread() == qApp->thread()) ? Qt::DirectConnection : Qt::BlockingQueuedConnection;
QMetaObject::invokeMethod(contextHelper, "initializeContextOnBrowserThread", connType,
Q_RETURN_ARG(bool, ret),
- Q_ARG(gfx::GLContext*, context),
- Q_ARG(gfx::GLSurface*, surface));
+ Q_ARG(gl::GLContext*, context),
+ Q_ARG(gl::GLSurface*, surface));
return ret;
}
@@ -143,9 +147,11 @@ QT_END_NAMESPACE
#if defined(USE_OZONE) || defined(OS_WIN)
-namespace gfx {
+namespace gl {
-scoped_refptr<GLContext> GLContext::CreateGLContext(GLShareGroup* share_group, GLSurface* compatible_surface, GpuPreference gpu_preference)
+namespace init {
+
+scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group, GLSurface* compatible_surface, GpuPreference gpu_preference)
{
#if defined(OS_WIN)
scoped_refptr<GLContext> context;
@@ -167,6 +173,8 @@ scoped_refptr<GLContext> GLContext::CreateGLContext(GLShareGroup* share_group, G
return context;
}
-} // namespace gfx
+} // namespace init
+
+} // namespace gl
#endif // defined(USE_OZONE) || defined(OS_WIN)
diff --git a/src/core/gl_context_qt.h b/src/core/gl_context_qt.h
index 2c04641d4..47cd7dc7f 100644
--- a/src/core/gl_context_qt.h
+++ b/src/core/gl_context_qt.h
@@ -42,7 +42,7 @@
#include <QObject>
-namespace gfx {
+namespace gl {
class GLContext;
class GLSurface;
}
@@ -54,7 +54,7 @@ class GLContextHelper : public QObject {
public:
static void initialize();
static void destroy();
- static bool initializeContext(gfx::GLContext* context, gfx::GLSurface* surface);
+ static bool initializeContext(gl::GLContext* context, gl::GLSurface* surface);
static void* getEGLConfig();
static void* getXConfig();
@@ -63,7 +63,7 @@ public:
static void* getNativeDisplay();
private:
- Q_INVOKABLE bool initializeContextOnBrowserThread(gfx::GLContext* context, gfx::GLSurface* surface);
+ Q_INVOKABLE bool initializeContextOnBrowserThread(gl::GLContext* context, gl::GLSurface* surface);
static GLContextHelper* contextHelper;
};
diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp
index a82143525..74bb32d1f 100644
--- a/src/core/gl_surface_qt.cpp
+++ b/src/core/gl_surface_qt.cpp
@@ -50,12 +50,13 @@
#include "qtwebenginecoreglobal_p.h"
#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"
#include "ui/gl/gl_surface_egl.h"
+#include "ui/gl/init/gl_initializer.h"
+#include "ui/gl/init/gl_factory.h"
#if defined(USE_X11)
#include "ui/gl/gl_surface_glx.h"
@@ -68,6 +69,7 @@ extern "C" {
#if defined(OS_WIN)
#include "ui/gl/gl_surface_wgl.h"
#include "ui/gl/gl_context_wgl.h"
+#include "ui/gl/vsync_provider_win.h"
#endif
// From ANGLE's egl/eglext.h.
@@ -78,7 +80,7 @@ extern "C" {
using ui::GetLastEGLErrorString;
-namespace gfx {
+namespace gl {
namespace {
@@ -313,7 +315,7 @@ bool GLSurfaceQtWGL::Initialize()
{
m_surfaceBuffer = new PbufferGLSurfaceWGL(m_size);
- return m_surfaceBuffer->Initialize();
+ return m_surfaceBuffer->Initialize(gl::GLSurface::SURFACE_DEFAULT);
}
void GLSurfaceQtWGL::Destroy()
@@ -368,8 +370,8 @@ bool GLSurfaceQtEGL::InitializeOneOff()
g_egl_surfaceless_context_supported = ExtensionsContain(g_extensions, "EGL_KHR_surfaceless_context");
if (g_egl_surfaceless_context_supported) {
- scoped_refptr<GLSurface> surface = new GLSurfacelessQtEGL(Size(1, 1));
- scoped_refptr<GLContext> context = GLContext::CreateGLContext(
+ scoped_refptr<GLSurface> surface = new GLSurfacelessQtEGL(gfx::Size(1, 1));
+ scoped_refptr<GLContext> context = init::CreateGLContext(
NULL, surface.get(), PreferIntegratedGpu);
if (!context->MakeCurrent(surface.get()))
@@ -387,31 +389,6 @@ bool GLSurfaceQtEGL::InitializeOneOff()
return true;
}
-bool GLSurface::InitializeOneOffInternal()
-{
- if (GetGLImplementation() == kGLImplementationOSMesaGL)
- return false;
-
- if (GetGLImplementation() == kGLImplementationEGLGLES2)
- return GLSurfaceQtEGL::InitializeOneOff();
-
- if (GetGLImplementation() == kGLImplementationDesktopGL) {
-#if defined(OS_WIN)
- return GLSurfaceQtWGL::InitializeOneOff();
-#elif defined(USE_X11)
- if (GLSurfaceQtGLX::InitializeOneOff())
- return true;
-#endif
- // Fallback to trying EGL with desktop GL.
- if (GLSurfaceQtEGL::InitializeOneOff()) {
- g_initializedEGL = true;
- return true;
- }
- }
-
- return false;
-}
-
EGLDisplay GLSurfaceEGL::GetHardwareDisplay()
{
return static_cast<EGLDisplay>(g_display);
@@ -584,12 +561,43 @@ void* GLSurfacelessQtEGL::GetShareHandle()
return NULL;
}
-// static
+namespace init {
+
+bool InitializeGLOneOffPlatform()
+{
+#if defined(OS_WIN)
+ VSyncProviderWin::InitializeOneOff();
+#endif
+
+ if (GetGLImplementation() == kGLImplementationOSMesaGL)
+ return false;
+
+ if (GetGLImplementation() == kGLImplementationEGLGLES2)
+ return GLSurfaceQtEGL::InitializeOneOff();
+
+ if (GetGLImplementation() == kGLImplementationDesktopGL) {
+#if defined(OS_WIN)
+ return GLSurfaceQtWGL::InitializeOneOff();
+#elif defined(USE_X11)
+ if (GLSurfaceQtGLX::InitializeOneOff())
+ return true;
+#endif
+ // Fallback to trying EGL with desktop GL.
+ if (GLSurfaceQtEGL::InitializeOneOff()) {
+ g_initializedEGL = true;
+ return true;
+ }
+ }
+
+ return false;
+}
+
scoped_refptr<GLSurface>
-GLSurface::CreateOffscreenGLSurface(const gfx::Size& size)
+CreateOffscreenGLSurface(const gfx::Size& size)
{
scoped_refptr<GLSurface> surface;
switch (GetGLImplementation()) {
+ case kGLImplementationDesktopGLCoreProfile:
case kGLImplementationDesktopGL: {
#if defined(OS_WIN)
surface = new GLSurfaceQtWGL(size);
@@ -623,14 +631,15 @@ GLSurface::CreateOffscreenGLSurface(const gfx::Size& size)
return NULL;
}
-// static
scoped_refptr<GLSurface>
-GLSurface::CreateViewGLSurface(gfx::AcceleratedWidget window)
+CreateViewGLSurface(gfx::AcceleratedWidget window)
{
QT_NOT_USED
return NULL;
}
+} // namespace init
+
std::string DriverEGL::GetPlatformExtensions()
{
EGLDisplay display = GLContextHelper::getEGLDisplay();
@@ -642,15 +651,16 @@ std::string DriverEGL::GetPlatformExtensions()
return str ? std::string(str) : "";
}
-} // namespace gfx
+} // namespace gl
-namespace content {
+namespace gpu {
class GpuCommandBufferStub;
class GpuChannelManager;
-scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface(GpuChannelManager*, GpuCommandBufferStub*, const gfx::GLSurfaceHandle&)
+scoped_refptr<gl::GLSurface> ImageTransportSurface::CreateNativeSurface(GpuChannelManager*, GpuCommandBufferStub*,
+ SurfaceHandle, gl::GLSurface::Format)
{
QT_NOT_USED
- return scoped_refptr<gfx::GLSurface>();
+ return scoped_refptr<gl::GLSurface>();
}
}
diff --git a/src/core/gl_surface_qt.h b/src/core/gl_surface_qt.h
index 33ea2a1da..9e0692c60 100644
--- a/src/core/gl_surface_qt.h
+++ b/src/core/gl_surface_qt.h
@@ -47,7 +47,7 @@
#include <QtCore/qcompilerdetection.h> // Needed for Q_DECL_OVERRIDE
-namespace gfx {
+namespace gl {
class GLSurfaceQt: public GLSurface {
public:
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/gyp_run.pro b/src/core/gyp_run.pro
index 4fab6cb97..233737751 100644
--- a/src/core/gyp_run.pro
+++ b/src/core/gyp_run.pro
@@ -24,7 +24,7 @@ GYP_CONFIG += disable_glibcxx_debug=1
!webcore_debug: GYP_CONFIG += remove_webcore_debug_symbols=1
!v8base_debug: GYP_CONFIG += remove_v8base_debug_symbols=1
-linux:contains(QT_CONFIG, separate_debug_info): GYP_CONFIG += linux_dump_symbols=1
+linux:qtConfig(separate_debug_info): GYP_CONFIG += linux_dump_symbols=1
force_debug_info {
win32: GYP_CONFIG += win_release_extra_cflags=-Zi
@@ -36,9 +36,7 @@ force_debug_info {
# Copy this logic from qt_module.prf so that ninja can run according
# to the same rules as the final module linking in core_module.pro.
!host_build:if(win32|mac):!macx-xcode {
- contains(QT_CONFIG, simulator_and_device): CONFIG += simulator_and_device
- contains(QT_CONFIG, debug_and_release):CONFIG += debug_and_release
- contains(QT_CONFIG, build_all):CONFIG += build_all
+ qtConfig(debug_and_release): CONFIG += debug_and_release build_all
}
cross_compile {
@@ -124,13 +122,19 @@ contains(WEBENGINE_CONFIG, reduce_binary_size): GYP_CONFIG += release_optimize=s
contains(WEBENGINE_CONFIG, no_spellcheck): {
GYP_CONFIG += enable_spellcheck=0
- osx: GYP_CONFIG += use_browser_spellchecker=0
+ macos: GYP_CONFIG += use_browser_spellchecker=0
} else {
GYP_CONFIG += enable_spellcheck=1
- osx: GYP_CONFIG += use_browser_spellchecker=1
+ macos {
+ contains(WEBENGINE_CONFIG, use_native_spellchecker) {
+ GYP_CONFIG += use_browser_spellchecker=1
+ } else {
+ GYP_CONFIG += use_browser_spellchecker=0
+ }
+ }
}
-!contains(QT_CONFIG, qt_framework): contains(QT_CONFIG, private_tests) {
+!qtConfig(framework):qtConfig(private_tests) {
GYP_CONFIG += qt_install_data=\"$$[QT_INSTALL_DATA/get]\"
GYP_CONFIG += qt_install_translations=\"$$[QT_INSTALL_TRANSLATIONS/get]\"
}
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/media_capture_devices_dispatcher.cpp b/src/core/media_capture_devices_dispatcher.cpp
index 9683245a0..f06f0150f 100644
--- a/src/core/media_capture_devices_dispatcher.cpp
+++ b/src/core/media_capture_devices_dispatcher.cpp
@@ -60,6 +60,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/common/origin_util.h"
#include "content/public/common/media_stream_request.h"
+#include "media/audio/audio_device_description.h"
#include "media/audio/audio_manager_base.h"
#include "ui/base/l10n/l10n_util.h"
@@ -89,27 +90,34 @@ base::string16 getContentsUrl(content::WebContents *webContents)
}
// Based on chrome/browser/media/desktop_capture_access_handler.cc:
-scoped_ptr<content::MediaStreamUI> getDevicesForDesktopCapture(content::MediaStreamDevices &devices, content::DesktopMediaID mediaId
+std::unique_ptr<content::MediaStreamUI> getDevicesForDesktopCapture(content::MediaStreamDevices *devices, content::DesktopMediaID mediaId
, bool captureAudio, bool /*display_notification*/, base::string16 /*application_title*/)
{
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- scoped_ptr<content::MediaStreamUI> ui;
-
- // Add selected desktop source to the list.
- devices.push_back(content::MediaStreamDevice(
- content::MEDIA_DESKTOP_VIDEO_CAPTURE, mediaId.ToString(), "Screen"));
- if (captureAudio) {
- devices.push_back(content::MediaStreamDevice(
- content::MEDIA_DESKTOP_AUDIO_CAPTURE,
- media::AudioManagerBase::kLoopbackInputDeviceId, "System Audio"));
- }
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ std::unique_ptr<content::MediaStreamUI> ui;
+
+ // Add selected desktop source to the list.
+ devices->push_back(content::MediaStreamDevice(content::MEDIA_DESKTOP_VIDEO_CAPTURE, mediaId.ToString(), "Screen"));
+ if (captureAudio) {
+ if (mediaId.type == content::DesktopMediaID::TYPE_WEB_CONTENTS) {
+ devices->push_back(
+ content::MediaStreamDevice(content::MEDIA_DESKTOP_AUDIO_CAPTURE,
+ mediaId.ToString(), "Tab audio"));
+ } else {
+ // Use the special loopback device ID for system audio capture.
+ devices->push_back(content::MediaStreamDevice(
+ content::MEDIA_DESKTOP_AUDIO_CAPTURE,
+ media::AudioDeviceDescription::kLoopbackInputDeviceId,
+ "System Audio"));
+ }
+ }
- return std::move(ui);
+ return std::move(ui);
}
WebContentsAdapterClient::MediaRequestFlags mediaRequestFlagsForRequest(const content::MediaStreamRequest &request)
{
- WebContentsAdapterClient::MediaRequestFlags requestFlags;
+ WebContentsAdapterClient::MediaRequestFlags requestFlags = WebContentsAdapterClient::MediaNone;
if (request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE)
requestFlags |= WebContentsAdapterClient::MediaAudioCapture;
if (request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE)
@@ -187,7 +195,7 @@ void MediaCaptureDevicesDispatcher::handleMediaAccessPermissionResponse(content:
BrowserThread::UI, FROM_HERE, base::Bind(&MediaCaptureDevicesDispatcher::ProcessQueuedAccessRequest, base::Unretained(this), webContents));
}
- callback.Run(devices, devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE : content::MEDIA_DEVICE_OK, scoped_ptr<content::MediaStreamUI>());
+ callback.Run(devices, devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE : content::MEDIA_DEVICE_OK, std::unique_ptr<content::MediaStreamUI>());
}
@@ -247,7 +255,7 @@ void MediaCaptureDevicesDispatcher::processDesktopCaptureAccessRequest(content::
, const content::MediaResponseCallback &callback)
{
content::MediaStreamDevices devices;
- scoped_ptr<content::MediaStreamUI> ui;
+ std::unique_ptr<content::MediaStreamUI> ui;
if (request.video_type != content::MEDIA_DESKTOP_VIDEO_CAPTURE) {
callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, std::move(ui));
@@ -288,8 +296,8 @@ void MediaCaptureDevicesDispatcher::processDesktopCaptureAccessRequest(content::
request.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE);
ui = getDevicesForDesktopCapture(
- devices, mediaId, capture_audio, true,
- getContentsUrl(webContents));
+ &devices, mediaId, capture_audio, true,
+ getContentsUrl(webContents));
callback.Run(devices, devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE : content::MEDIA_DEVICE_OK, std::move(ui));
}
@@ -316,16 +324,16 @@ void MediaCaptureDevicesDispatcher::processScreenCaptureAccessRequest(content::W
JavaScriptDialogManagerQt::GetInstance()->runDialogForContents(webContents, WebContentsAdapterClient::InternalAuthorizationDialog, message
, QString(), securityOrigin, dialogCallback, title);
} else
- callback.Run(content::MediaStreamDevices(), content::MEDIA_DEVICE_INVALID_STATE, scoped_ptr<content::MediaStreamUI>());
+ callback.Run(content::MediaStreamDevices(), content::MEDIA_DEVICE_INVALID_STATE, std::unique_ptr<content::MediaStreamUI>());
}
void MediaCaptureDevicesDispatcher::handleScreenCaptureAccessRequest(content::WebContents *webContents, bool userAccepted, const base::string16 &)
{
content::MediaStreamDevices devices;
- scoped_ptr<content::MediaStreamUI> ui;
+ std::unique_ptr<content::MediaStreamUI> ui;
if (userAccepted) {
content::DesktopMediaID screenId = content::DesktopMediaID(content::DesktopMediaID::TYPE_SCREEN, 0);
- ui = getDevicesForDesktopCapture(devices, screenId, false/*capture_audio*/, false/*display_notification*/, getContentsUrl(webContents));
+ ui = getDevicesForDesktopCapture(&devices, screenId, false/*capture_audio*/, false/*display_notification*/, getContentsUrl(webContents));
}
std::map<content::WebContents*, RequestsQueue>::iterator it =
m_pendingRequests.find(webContents);
@@ -416,13 +424,19 @@ void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(int render_proces
page_request_id, security_origin, stream_type, state));
}
-void MediaCaptureDevicesDispatcher::updateMediaRequestStateOnUIThread(int render_process_id, int render_frame_id, int page_request_id
- , const GURL& security_origin, content::MediaStreamType stream_type, content::MediaRequestState state)
+void MediaCaptureDevicesDispatcher::updateMediaRequestStateOnUIThread(int render_process_id,
+ int render_frame_id,
+ int page_request_id,
+ const GURL& security_origin,
+ content::MediaStreamType stream_type,
+ content::MediaRequestState state)
{
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
// Track desktop capture sessions. Tracking is necessary to avoid unbalanced
// session counts since not all requests will reach MEDIA_REQUEST_STATE_DONE,
// but they will all reach MEDIA_REQUEST_STATE_CLOSING.
- if (stream_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE) {
+ if (stream_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE || stream_type == content::MEDIA_TAB_VIDEO_CAPTURE) {
if (state == content::MEDIA_REQUEST_STATE_DONE) {
DesktopCaptureSession session = { render_process_id, render_frame_id,
page_request_id };
diff --git a/src/core/media_capture_devices_dispatcher.h b/src/core/media_capture_devices_dispatcher.h
index b13a9da2c..b21d40b87 100644
--- a/src/core/media_capture_devices_dispatcher.h
+++ b/src/core/media_capture_devices_dispatcher.h
@@ -49,7 +49,6 @@
#include "web_contents_adapter_client.h"
#include "base/callback.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/observer_list.h"
#include "content/public/browser/media_observer.h"
@@ -83,6 +82,11 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver,
virtual void OnMediaRequestStateChanged(int render_process_id, int render_frame_id, int page_request_id, const GURL& security_origin, content::MediaStreamType stream_type, content::MediaRequestState state) Q_DECL_OVERRIDE;
virtual void OnCreatingAudioStream(int /*render_process_id*/, int /*render_frame_id*/) Q_DECL_OVERRIDE { }
+ virtual void OnSetCapturingLinkSecured(int /*render_process_id*/,
+ int /*render_frame_id*/,
+ int /*page_request_id*/,
+ content::MediaStreamType /*stream_type*/,
+ bool /*is_secure*/) Q_DECL_OVERRIDE { }
DesktopStreamsRegistry *getDesktopStreamsRegistry();
@@ -118,7 +122,7 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver,
RequestsQueues m_pendingRequests;
- scoped_ptr<DesktopStreamsRegistry> m_desktopStreamsRegistry;
+ std::unique_ptr<DesktopStreamsRegistry> m_desktopStreamsRegistry;
content::NotificationRegistrar m_notificationsRegistrar;
diff --git a/src/core/network_delegate_qt.cpp b/src/core/network_delegate_qt.cpp
index ff0e8320c..ed54f2ec8 100644
--- a/src/core/network_delegate_qt.cpp
+++ b/src/core/network_delegate_qt.cpp
@@ -230,24 +230,18 @@ 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*)
+int NetworkDelegateQt::OnBeforeStartTransaction(net::URLRequest *request, const net::CompletionCallback &callback, net::HttpRequestHeaders *headers)
{
return net::OK;
}
-void NetworkDelegateQt::OnBeforeSendProxyHeaders(net::URLRequest*, const net::ProxyInfo&, net::HttpRequestHeaders*)
+void NetworkDelegateQt::OnBeforeSendHeaders(net::URLRequest* request, const net::ProxyInfo& proxy_info,
+ const net::ProxyRetryInfoMap& proxy_retry_info, net::HttpRequestHeaders* headers)
{
}
-void NetworkDelegateQt::OnSendHeaders(net::URLRequest*, const net::HttpRequestHeaders&)
+void NetworkDelegateQt::OnStartTransaction(net::URLRequest *request, const net::HttpRequestHeaders &headers)
{
}
diff --git a/src/core/network_delegate_qt.h b/src/core/network_delegate_qt.h
index 1324e0da3..4ded56a9d 100644
--- a/src/core/network_delegate_qt.h
+++ b/src/core/network_delegate_qt.h
@@ -76,11 +76,10 @@ 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;
+ virtual int OnBeforeStartTransaction(net::URLRequest *request, const net::CompletionCallback &callback, net::HttpRequestHeaders *headers) override;
+ virtual void OnBeforeSendHeaders(net::URLRequest* request, const net::ProxyInfo& proxy_info,
+ const net::ProxyRetryInfoMap& proxy_retry_info, net::HttpRequestHeaders* headers) override;
+ virtual void OnStartTransaction(net::URLRequest *request, const net::HttpRequestHeaders &headers) override;
virtual int OnHeadersReceived(net::URLRequest*, const net::CompletionCallback&, const net::HttpResponseHeaders*, scoped_refptr<net::HttpResponseHeaders>*, GURL*) override;
virtual void OnBeforeRedirect(net::URLRequest*, const GURL&) override;
virtual void OnResponseStarted(net::URLRequest*) override;
diff --git a/src/core/ozone_platform_eglfs.cpp b/src/core/ozone_platform_eglfs.cpp
index 6fea4259e..0b560da6c 100644
--- a/src/core/ozone_platform_eglfs.cpp
+++ b/src/core/ozone_platform_eglfs.cpp
@@ -42,7 +42,7 @@
#if defined(USE_OZONE)
#include "base/bind.h"
-#include "media/ozone/media_ozone_platform.h"
+#include "base/memory/ptr_util.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 +57,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 {
@@ -157,11 +148,11 @@ GpuPlatformSupportHost* OzonePlatformEglfs::GetGpuPlatformSupportHost() {
return gpu_platform_support_host_.get();
}
-scoped_ptr<PlatformWindow> OzonePlatformEglfs::CreatePlatformWindow(
+std::unique_ptr<PlatformWindow> OzonePlatformEglfs::CreatePlatformWindow(
PlatformWindowDelegate* delegate,
const gfx::Rect& bounds)
{
- return make_scoped_ptr<PlatformWindow>(
+ return base::WrapUnique(
new EglfsWindow(delegate,
event_factory_ozone_.get(),
bounds));
@@ -171,7 +162,7 @@ ui::InputController* OzonePlatformEglfs::GetInputController() {
return input_controller_.get();
}
-scoped_ptr<ui::SystemInputInjector> OzonePlatformEglfs::CreateSystemInputInjector() {
+std::unique_ptr<ui::SystemInputInjector> OzonePlatformEglfs::CreateSystemInputInjector() {
return nullptr; // no input injection support.
}
@@ -179,14 +170,9 @@ ui::OverlayManagerOzone* OzonePlatformEglfs::GetOverlayManager() {
return overlay_manager_.get();
}
-scoped_ptr<ui::NativeDisplayDelegate> OzonePlatformEglfs::CreateNativeDisplayDelegate()
-{
- return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone());
-}
-
-base::ScopedFD OzonePlatformEglfs::OpenClientNativePixmapDevice() const
+std::unique_ptr<ui::NativeDisplayDelegate> OzonePlatformEglfs::CreateNativeDisplayDelegate()
{
- return base::ScopedFD();
+ return base::WrapUnique(new NativeDisplayDelegateOzone());
}
OzonePlatform* CreateOzonePlatformEglfs() { return new OzonePlatformEglfs; }
diff --git a/src/core/ozone_platform_eglfs.h b/src/core/ozone_platform_eglfs.h
index 3a2dfbcf0..cdc2bd1ce 100644
--- a/src/core/ozone_platform_eglfs.h
+++ b/src/core/ozone_platform_eglfs.h
@@ -61,28 +61,27 @@ class OzonePlatformEglfs : public OzonePlatform {
virtual ui::CursorFactoryOzone* GetCursorFactoryOzone() override;
virtual GpuPlatformSupport* GetGpuPlatformSupport() override;
virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() override;
- virtual scoped_ptr<PlatformWindow> CreatePlatformWindow(
+ virtual std::unique_ptr<PlatformWindow> CreatePlatformWindow(
PlatformWindowDelegate* delegate,
const gfx::Rect& bounds) override;
- virtual scoped_ptr<ui::NativeDisplayDelegate> CreateNativeDisplayDelegate() override;
- virtual base::ScopedFD OpenClientNativePixmapDevice() const override;
+ virtual std::unique_ptr<ui::NativeDisplayDelegate> CreateNativeDisplayDelegate() override;
virtual ui::InputController* GetInputController() override;
- virtual scoped_ptr<ui::SystemInputInjector> CreateSystemInputInjector() override;
+ virtual std::unique_ptr<ui::SystemInputInjector> CreateSystemInputInjector() override;
virtual ui::OverlayManagerOzone* GetOverlayManager() override;
private:
virtual void InitializeUI() override;
virtual void InitializeGPU() override;
- scoped_ptr<DeviceManager> device_manager_;
+ std::unique_ptr<DeviceManager> device_manager_;
- scoped_ptr<QtWebEngineCore::SurfaceFactoryQt> surface_factory_ozone_;
- scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_;
- scoped_ptr<EventFactoryEvdev> event_factory_ozone_;
+ std::unique_ptr<QtWebEngineCore::SurfaceFactoryQt> surface_factory_ozone_;
+ std::unique_ptr<CursorFactoryOzone> cursor_factory_ozone_;
+ std::unique_ptr<EventFactoryEvdev> event_factory_ozone_;
- scoped_ptr<GpuPlatformSupport> gpu_platform_support_;
- scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_;
- scoped_ptr<InputController> input_controller_;
- scoped_ptr<OverlayManagerOzone> overlay_manager_;
+ std::unique_ptr<GpuPlatformSupport> gpu_platform_support_;
+ std::unique_ptr<GpuPlatformSupportHost> gpu_platform_support_host_;
+ std::unique_ptr<InputController> input_controller_;
+ std::unique_ptr<OverlayManagerOzone> overlay_manager_;
DISALLOW_COPY_AND_ASSIGN(OzonePlatformEglfs);
};
diff --git a/src/core/pdfium_printing_wrapper_qt.cpp b/src/core/pdfium_printing_wrapper_qt.cpp
new file mode 100644
index 000000000..165ac743f
--- /dev/null
+++ b/src/core/pdfium_printing_wrapper_qt.cpp
@@ -0,0 +1,231 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include "pdfium_printing_wrapper_qt.h"
+
+#include <QtCore/qhash.h>
+#include <QtGui/qimage.h>
+#include <QtGui/qpainter.h>
+#include <QtPrintSupport/qprinter.h>
+
+#include "third_party/pdfium/public/fpdf_doc.h"
+#include "third_party/pdfium/public/fpdfview.h"
+
+namespace QtWebEngineCore {
+int PdfiumPrintingWrapperQt::m_libraryUsers = 0;
+
+class PDFiumPageWrapper {
+public:
+ PDFiumPageWrapper(void *data, int pageIndex, int targetWidth, int targetHeight)
+ : m_pageData(FPDF_LoadPage(data, pageIndex))
+ , m_width(FPDF_GetPageWidth(m_pageData))
+ , m_height(FPDF_GetPageHeight(m_pageData))
+ , m_index(pageIndex)
+ , m_image(createImage(targetWidth, targetHeight))
+ {
+ }
+
+ PDFiumPageWrapper()
+ : m_pageData(nullptr)
+ , m_width(-1)
+ , m_height(-1)
+ , m_index(-1)
+ , m_image(QImage())
+ {
+ }
+
+ virtual ~PDFiumPageWrapper()
+ {
+ FPDF_ClosePage(m_pageData);
+ }
+
+ QImage image()
+ {
+ return m_image;
+ }
+
+private:
+ QImage createImage(int targetWidth, int targetHeight)
+ {
+ Q_ASSERT(m_pageData);
+ if (targetWidth <= 0)
+ targetWidth = m_width;
+
+ if (targetHeight <= 0)
+ targetHeight = m_height;
+
+ QImage image(targetWidth, targetHeight, QImage::Format_RGBA8888);
+ Q_ASSERT(!image.isNull());
+ image.fill(0xFFFFFFFF);
+
+ FPDF_BITMAP bitmap = FPDFBitmap_CreateEx(image.width(), image.height(),
+ FPDFBitmap_BGRA,
+ image.scanLine(0), image.bytesPerLine());
+ Q_ASSERT(bitmap);
+
+ FPDF_RenderPageBitmap(bitmap, m_pageData,
+ 0, 0, image.width(), image.height(),
+ 0, 0);
+ FPDFBitmap_Destroy(bitmap);
+ bitmap = nullptr;
+
+ // Map BGRA to RGBA as PDFium currently does not support RGBA bitmaps directly
+ for (int i = 0; i < image.height(); i++) {
+ uchar *pixels = image.scanLine(i);
+ for (int j = 0; j < image.width(); j++) {
+ qSwap(pixels[0], pixels[2]);
+ pixels += 4;
+ }
+ }
+ return image;
+ }
+
+private:
+ void *m_pageData;
+ int m_width;
+ int m_height;
+ int m_index;
+ QImage m_image;
+};
+
+
+PdfiumPrintingWrapperQt::PdfiumPrintingWrapperQt(const void *pdfData, size_t size, const char *password)
+{
+ Q_ASSERT(pdfData);
+ Q_ASSERT(size);
+ if (m_libraryUsers++ == 0)
+ FPDF_InitLibrary();
+
+ m_documentHandle = FPDF_LoadMemDocument(pdfData, static_cast<int>(size), password);
+ m_pageCount = FPDF_GetPageCount(m_documentHandle);
+}
+
+bool PdfiumPrintingWrapperQt::printOnPrinter(QPrinter &printer)
+{
+ if (!m_documentHandle || !m_pageCount) {
+ qWarning("Failure to print on printer %ls: invalid document.\n", qUtf16Printable(printer.printerName()));
+ return false;
+ }
+
+ int toPage = printer.toPage();
+ int fromPage = printer.fromPage();
+ bool ascendingOrder = true;
+
+ if (fromPage == 0 && toPage == 0) {
+ fromPage = 1;
+ toPage = m_pageCount;
+ }
+ fromPage = qMax(1, fromPage);
+ toPage = qMin(m_pageCount, toPage);
+
+ if (printer.pageOrder() == QPrinter::LastPageFirst) {
+ qSwap(fromPage, toPage);
+ ascendingOrder = false;
+ }
+
+ int documentCopies = printer.copyCount();
+ int pageCopies = 1;
+ if (printer.collateCopies()) {
+ pageCopies = documentCopies;
+ documentCopies = 1;
+ }
+
+ QRect printerPageRect = printer.pageRect();
+ int doubledPrinterWidth = 2 * printerPageRect.width();
+ int doubledPrinterHeight = 2 * printerPageRect.height();
+
+ QPainter painter;
+ if (!painter.begin(&printer)) {
+ qWarning("Failure to print on printer %ls: Could not open printer for painting.\n", qUtf16Printable(printer.printerName()));
+ return false;
+ }
+
+ QHash<int, PDFiumPageWrapper*> cachedPages;
+ for (int printedDocuments = 0; printedDocuments < documentCopies; printedDocuments++) {
+ int currentPageIndex = fromPage;
+ while (true) {
+ for (int printedPages = 0; printedPages < pageCopies; printedPages++) {
+ if (printer.printerState() == QPrinter::Aborted
+ || printer.printerState() == QPrinter::Error)
+ return false;
+
+ PDFiumPageWrapper *currentPageWrapper;
+ if (!cachedPages.contains(currentPageIndex - 1)) {
+ currentPageWrapper
+ = new PDFiumPageWrapper(m_documentHandle, currentPageIndex - 1
+ , doubledPrinterWidth, doubledPrinterHeight);
+ cachedPages.insert(currentPageIndex - 1, currentPageWrapper);
+ } else {
+ currentPageWrapper = cachedPages.value(currentPageIndex - 1);
+ }
+
+ QImage currentImage = currentPageWrapper->image();
+ painter.drawImage(printerPageRect, currentImage, currentImage.rect());
+ if (printedPages < pageCopies - 1)
+ printer.newPage();
+ }
+
+ if (currentPageIndex == toPage)
+ break;
+
+ if (ascendingOrder)
+ currentPageIndex++;
+ else
+ currentPageIndex--;
+
+ printer.newPage();
+ }
+ if (printedDocuments < documentCopies - 1)
+ printer.newPage();
+ }
+ painter.end();
+
+ qDeleteAll(cachedPages);
+
+ return true;
+}
+
+PdfiumPrintingWrapperQt::~PdfiumPrintingWrapperQt()
+{
+ FPDF_CloseDocument(m_documentHandle);
+ if (--m_libraryUsers == 0)
+ FPDF_DestroyLibrary();
+}
+
+}
diff --git a/src/core/pdfium_printing_wrapper_qt.h b/src/core/pdfium_printing_wrapper_qt.h
new file mode 100644
index 000000000..3aaf2b461
--- /dev/null
+++ b/src/core/pdfium_printing_wrapper_qt.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#ifndef PDFIUM_PRINTING_WRAPPER_QT_H
+#define PDFIUM_PRINTING_WRAPPER_QT_H
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+class QPrinter;
+QT_END_NAMESPACE
+
+namespace QtWebEngineCore {
+
+class PdfiumPrintingWrapperQt
+{
+public:
+ PdfiumPrintingWrapperQt(const void *pdfData, size_t size, const char *password = nullptr);
+ virtual ~PdfiumPrintingWrapperQt();
+ bool printOnPrinter(QPrinter &printer);
+ int pageCount() const { return m_pageCount; }
+
+private:
+ static int m_libraryUsers;
+ void *m_documentHandle;
+ int m_pageCount;
+};
+
+} // namespace QtWebEngineCore
+#endif // PDFIUM_PRINTING_WRAPPER_QT_H
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.cpp b/src/core/print_view_manager_base_qt.cpp
index 3e12901b9..8c52e1b18 100644
--- a/src/core/print_view_manager_base_qt.cpp
+++ b/src/core/print_view_manager_base_qt.cpp
@@ -45,7 +45,6 @@
#include "web_engine_context.h"
#include "base/single_thread_task_runner.h"
-#include "base/thread_task_runner_handle.h"
#include "base/timer/timer.h"
#include "base/values.h"
#include "chrome/browser/chrome_notification_types.h"
@@ -246,7 +245,7 @@ void PrintViewManagerBaseQt::OnDidPrintPage(
#endif
// Only used when |metafile_must_be_valid| is true.
- scoped_ptr<base::SharedMemory> shared_buf;
+ std::unique_ptr<base::SharedMemory> shared_buf;
if (metafile_must_be_valid) {
if (!base::SharedMemory::IsHandleValid(params.metafile_data_handle)) {
NOTREACHED() << "invalid memory handle";
@@ -268,7 +267,7 @@ void PrintViewManagerBaseQt::OnDidPrintPage(
}
}
- scoped_ptr<printing::PdfMetafileSkia> metafile(new printing::PdfMetafileSkia);
+ std::unique_ptr<printing::PdfMetafileSkia> metafile(new printing::PdfMetafileSkia(printing::PDF_SKIA_DOCUMENT_TYPE));
if (metafile_must_be_valid) {
if (!metafile->InitFromData(shared_buf->memory(), params.data_size)) {
NOTREACHED() << "Invalid metafile header";
diff --git a/src/core/print_view_manager_base_qt.h b/src/core/print_view_manager_base_qt.h
index f1e001eee..a8b4b5fc8 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"
@@ -97,7 +97,7 @@ protected:
int number_pages_; // Number of pages to print in the print job.
int cookie_;
- scoped_ptr<base::DictionaryValue> m_printSettings;
+ std::unique_ptr<base::DictionaryValue> m_printSettings;
// content::NotificationObserver implementation.
void Observe(int,
diff --git a/src/core/print_view_manager_qt.cpp b/src/core/print_view_manager_qt.cpp
index f657b8289..0231df8bd 100644
--- a/src/core/print_view_manager_qt.cpp
+++ b/src/core/print_view_manager_qt.cpp
@@ -43,14 +43,17 @@
#include "type_conversion.h"
#include "web_engine_context.h"
-#include <QtGui/QPageLayout>
-#include <QtGui/QPageSize>
+#include <QtGui/qpagelayout.h>
+#include <QtGui/qpagesize.h>
#include "base/values.h"
+#include "base/memory/ref_counted_memory.h"
#include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/printing/printer_query.h"
#include "components/printing/common/print_messages.h"
+#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/common/web_preferences.h"
#include "printing/pdf_metafile_skia.h"
#include "printing/print_job_constants.h"
@@ -61,7 +64,7 @@ static const qreal kMicronsToMillimeter = 1000.0f;
static std::vector<char>
GetStdVectorFromHandle(base::SharedMemoryHandle handle, uint32_t data_size) {
- scoped_ptr<base::SharedMemory> shared_buf(
+ std::unique_ptr<base::SharedMemory> shared_buf(
new base::SharedMemory(handle, true));
if (!shared_buf->Map(data_size)) {
@@ -74,7 +77,7 @@ GetStdVectorFromHandle(base::SharedMemoryHandle handle, uint32_t data_size) {
static scoped_refptr<base::RefCountedBytes>
GetBytesFromHandle(base::SharedMemoryHandle handle, uint32_t data_size) {
- scoped_ptr<base::SharedMemory> shared_buf(
+ std::unique_ptr<base::SharedMemory> shared_buf(
new base::SharedMemory(handle, true));
if (!shared_buf->Map(data_size)) {
@@ -92,7 +95,7 @@ static void SavePdfFile(scoped_refptr<base::RefCountedBytes> data,
DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
DCHECK_GT(data->size(), 0U);
- printing::PdfMetafileSkia metafile;
+ printing::PdfMetafileSkia metafile(printing::PDF_SKIA_DOCUMENT_TYPE);
metafile.InitFromData(static_cast<const void*>(data->front()), data->size());
base::File file(path,
@@ -139,18 +142,19 @@ static base::DictionaryValue *createPrintSettingsFromQPageLayout(const QPageLayo
//Set page size attributes, chromium expects these in micrometers
QSizeF pageSizeInMilimeter = pageLayout.pageSize().size(QPageSize::Millimeter);
- scoped_ptr<base::DictionaryValue> sizeDict(new base::DictionaryValue);
+ std::unique_ptr<base::DictionaryValue> sizeDict(new base::DictionaryValue);
sizeDict->SetInteger(printing::kSettingMediaSizeWidthMicrons, pageSizeInMilimeter.width() * kMicronsToMillimeter);
sizeDict->SetInteger(printing::kSettingMediaSizeHeightMicrons, pageSizeInMilimeter.height() * kMicronsToMillimeter);
printSettings->Set(printing::kSettingMediaSize, std::move(sizeDict));
// Apply page margins
QMargins pageMarginsInPoints = pageLayout.marginsPoints();
- scoped_ptr<base::DictionaryValue> marginsDict(new base::DictionaryValue);
+ std::unique_ptr<base::DictionaryValue> marginsDict(new base::DictionaryValue);
marginsDict->SetInteger(printing::kSettingMarginTop, pageMarginsInPoints.top());
marginsDict->SetInteger(printing::kSettingMarginBottom, pageMarginsInPoints.bottom());
marginsDict->SetInteger(printing::kSettingMarginLeft, pageMarginsInPoints.left());
marginsDict->SetInteger(printing::kSettingMarginRight, pageMarginsInPoints.right());
+
printSettings->Set(printing::kSettingMarginsCustom, std::move(marginsDict));
printSettings->SetInteger(printing::kSettingMarginsType, printing::CUSTOM_MARGINS);
@@ -168,20 +172,20 @@ PrintViewManagerQt::~PrintViewManagerQt()
}
#if defined(ENABLE_BASIC_PRINTING)
-bool PrintViewManagerQt::PrintToPDF(const QPageLayout &pageLayout, const QString &filePath)
+bool PrintViewManagerQt::PrintToPDF(const QPageLayout &pageLayout, bool printInColor, const QString &filePath)
{
if (m_printSettings || !filePath.length())
return false;
m_pdfOutputPath = toFilePath(filePath);
- if (!PrintToPDFInternal(pageLayout)) {
+ if (!PrintToPDFInternal(pageLayout, printInColor)) {
resetPdfState();
return false;
}
return true;
}
-bool PrintViewManagerQt::PrintToPDFWithCallback(const QPageLayout &pageLayout, const PrintToPDFCallback& callback)
+bool PrintViewManagerQt::PrintToPDFWithCallback(const QPageLayout &pageLayout, bool printInColor, const PrintToPDFCallback& callback)
{
if (callback.is_null())
return false;
@@ -195,7 +199,7 @@ bool PrintViewManagerQt::PrintToPDFWithCallback(const QPageLayout &pageLayout, c
}
m_pdfPrintCallback = callback;
- if (!PrintToPDFInternal(pageLayout)) {
+ if (!PrintToPDFInternal(pageLayout, printInColor)) {
content::BrowserThread::PostTask(content::BrowserThread::UI,
FROM_HERE,
base::Bind(callback, std::vector<char>()));
@@ -206,13 +210,15 @@ bool PrintViewManagerQt::PrintToPDFWithCallback(const QPageLayout &pageLayout, c
return true;
}
-bool PrintViewManagerQt::PrintToPDFInternal(const QPageLayout &pageLayout)
+bool PrintViewManagerQt::PrintToPDFInternal(const QPageLayout &pageLayout, bool printInColor)
{
if (!pageLayout.isValid())
return false;
- m_printSettings.reset(createPrintSettingsFromQPageLayout(pageLayout));
- m_printSettings->SetInteger(printing::kSettingColor, printing::COLOR);
+ m_printSettings.reset(createPrintSettingsFromQPageLayout(pageLayout));
+ m_printSettings->SetBoolean(printing::kSettingShouldPrintBackgrounds
+ , web_contents()->GetRenderViewHost()->GetWebkitPreferences().should_print_backgrounds);
+ m_printSettings->SetInteger(printing::kSettingColor, printInColor ? printing::COLOR : printing::GRAYSCALE);
return Send(new PrintMsg_InitiatePrintPreview(routing_id(), false));
}
diff --git a/src/core/print_view_manager_qt.h b/src/core/print_view_manager_qt.h
index 88a499f1b..668516096 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"
@@ -83,8 +83,8 @@ public:
typedef base::Callback<void(const std::vector<char> &result)> PrintToPDFCallback;
#if defined(ENABLE_BASIC_PRINTING)
// Method to print a page to a Pdf document with page size \a pageSize in location \a filePath.
- bool PrintToPDF(const QPageLayout& pageLayout, const QString& filePath);
- bool PrintToPDFWithCallback(const QPageLayout& pageLayout, const PrintToPDFCallback& callback);
+ bool PrintToPDF(const QPageLayout &pageLayout, bool printInColor, const QString &filePath);
+ bool PrintToPDFWithCallback(const QPageLayout &pageLayout, bool printInColor, const PrintToPDFCallback &callback);
#endif // ENABLE_BASIC_PRINTING
// PrintedPagesSource implementation.
@@ -109,7 +109,7 @@ protected:
void OnMetafileReadyForPrinting(const PrintHostMsg_DidPreviewDocument_Params& params);
#if defined(ENABLE_BASIC_PRINTING)
- bool PrintToPDFInternal(const QPageLayout &);
+ bool PrintToPDFInternal(const QPageLayout &, bool printInColor);
#endif //
base::FilePath m_pdfOutputPath;
diff --git a/src/core/printing_message_filter_qt.cpp b/src/core/printing_message_filter_qt.cpp
index ba4d5c6e6..a84ec491f 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;
@@ -201,7 +187,7 @@ void PrintingMessageFilterQt::OnScriptedPrintReply(
void PrintingMessageFilterQt::OnUpdatePrintSettings(
int document_cookie, const base::DictionaryValue& job_settings,
IPC::Message* reply_msg) {
- scoped_ptr<base::DictionaryValue> new_settings(job_settings.DeepCopy());
+ std::unique_ptr<base::DictionaryValue> new_settings(job_settings.DeepCopy());
scoped_refptr<printing::PrinterQuery> printer_query;
printer_query = queue_->PopPrinterQuery(document_cookie);
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/proxy_config_service_qt.cpp b/src/core/proxy_config_service_qt.cpp
index bd5d0375d..5bc30b6bc 100644
--- a/src/core/proxy_config_service_qt.cpp
+++ b/src/core/proxy_config_service_qt.cpp
@@ -69,7 +69,7 @@ net::ProxyServer ProxyConfigServiceQt::fromQNetworkProxy(const QNetworkProxy &qt
//================ Based on ChromeProxyConfigService =======================
-ProxyConfigServiceQt::ProxyConfigServiceQt(scoped_ptr<ProxyConfigService> baseService)
+ProxyConfigServiceQt::ProxyConfigServiceQt(std::unique_ptr<ProxyConfigService> baseService)
: m_baseService(baseService.release()),
m_registeredObserver(false)
{
@@ -109,7 +109,8 @@ net::ProxyConfigService::ConfigAvailability ProxyConfigServiceQt::GetLatestProxy
}
m_qtApplicationProxy = qtProxy;
m_qtProxyConfig = net::ProxyConfig();
- if (qtProxy.type() == QNetworkProxy::NoProxy) {
+ if (qtProxy.type() == QNetworkProxy::NoProxy
+ && QNetworkProxyFactory::usesSystemConfiguration()) {
*config = systemConfig;
return systemAvailability;
}
diff --git a/src/core/proxy_config_service_qt.h b/src/core/proxy_config_service_qt.h
index da24e3337..f2f9a2210 100644
--- a/src/core/proxy_config_service_qt.h
+++ b/src/core/proxy_config_service_qt.h
@@ -41,7 +41,6 @@
#define PROXY_CONFIG_SERVICE_QT_H
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "net/proxy/proxy_config.h"
@@ -56,7 +55,7 @@ public:
static net::ProxyServer fromQNetworkProxy(const QNetworkProxy &);
- explicit ProxyConfigServiceQt(scoped_ptr<ProxyConfigService> baseService);
+ explicit ProxyConfigServiceQt(std::unique_ptr<ProxyConfigService> baseService);
~ProxyConfigServiceQt() override;
// ProxyConfigService implementation:
@@ -73,7 +72,7 @@ private:
// Makes sure that the observer registration with the base service is set up.
void RegisterObserver();
- scoped_ptr<net::ProxyConfigService> m_baseService;
+ std::unique_ptr<net::ProxyConfigService> m_baseService;
base::ObserverList<net::ProxyConfigService::Observer, true> m_observers;
// Keep the last QNetworkProxy::applicationProxy state around.
diff --git a/src/core/qtwebengine.gypi b/src/core/qtwebengine.gypi
index 816962d3d..d0ab01534 100644
--- a/src/core/qtwebengine.gypi
+++ b/src/core/qtwebengine.gypi
@@ -8,15 +8,18 @@
'dependencies': [
'<(chromium_src_dir)/base/base.gyp:base',
'<(chromium_src_dir)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
- '<(chromium_src_dir)/chrome/tools/convert_dict/convert_dict.gyp:convert_dict_lib',
+ '<(chromium_src_dir)/components/components.gyp:cdm_renderer',
'<(chromium_src_dir)/components/components.gyp:devtools_discovery',
'<(chromium_src_dir)/components/components.gyp:devtools_http_handler',
'<(chromium_src_dir)/components/components.gyp:error_page_renderer',
+ '<(chromium_src_dir)/components/components.gyp:keyed_service_content',
+ '<(chromium_src_dir)/components/components.gyp:keyed_service_core',
+ '<(chromium_src_dir)/components/components.gyp:pref_registry',
+ '<(chromium_src_dir)/components/components.gyp:user_prefs',
'<(chromium_src_dir)/components/components.gyp:visitedlink_browser',
'<(chromium_src_dir)/components/components.gyp:visitedlink_renderer',
'<(chromium_src_dir)/components/components.gyp:web_cache_browser',
'<(chromium_src_dir)/components/components.gyp:web_cache_renderer',
- '<(chromium_src_dir)/components/components.gyp:cdm_renderer',
'<(chromium_src_dir)/content/content.gyp:content',
'<(chromium_src_dir)/content/content.gyp:content_app_browser',
'<(chromium_src_dir)/content/content.gyp:content_browser',
@@ -36,7 +39,7 @@
'<(chromium_src_dir)/ui/base/ui_base.gyp:ui_base',
'<(chromium_src_dir)/ui/gl/gl.gyp:gl',
'<(chromium_src_dir)/url/url.gyp:url_lib',
- '<(chromium_src_dir)/v8/tools/gyp/v8.gyp:v8',
+ '<(chromium_src_dir)/v8/src/v8.gyp:v8',
'<(qtwebengine_root)/src/core/chrome_qt.gyp:chrome_qt',
],
@@ -85,7 +88,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/qtwebengine_extras.gypi b/src/core/qtwebengine_extras.gypi
index 229421efa..8e4c655a9 100644
--- a/src/core/qtwebengine_extras.gypi
+++ b/src/core/qtwebengine_extras.gypi
@@ -32,21 +32,28 @@
['exclude', 'browser/renderer_host/render_widget_host_view_mac\\.(mm|h)$'],
['exclude', 'browser/renderer_host/render_widget_host_view_win\\.(cc|h)$'],
['exclude', 'common/font_list_pango\\.cc$'],
- ['exclude', 'browser/accessibility/browser_accessibility_cocoa\\.(cc|h)$'],
+ ['exclude', 'browser/accessibility/browser_accessibility_cocoa\\.(mm|h)$'],
['exclude', 'browser/accessibility/browser_accessibility_gtk\\.(cc|h)$'],
- ['exclude', 'browser/accessibility/browser_accessibility_mac\\.(cc|h)$'],
+ ['exclude', 'browser/accessibility/browser_accessibility_mac\\.(mm|h)$'],
['exclude', 'browser/accessibility/browser_accessibility_win\\.(cc|h)$'],
+ ['exclude', 'browser/accessibility/browser_accessibility_event_win\\.(cc|h)$'],
['exclude', 'browser/accessibility/browser_accessibility_manager_gtk\\.(cc|h)$'],
- ['exclude', 'browser/accessibility/browser_accessibility_manager_mac\\.(cc|h)$'],
+ ['exclude', 'browser/accessibility/browser_accessibility_manager_mac\\.(mm|h)$'],
['exclude', 'browser/accessibility/browser_accessibility_manager_win\\.(cc|h)$'],
['exclude', 'command_buffer/service/async_pixel_transfer_manager_egl\\.(cc|h)$'],
['exclude', 'common/gpu/image_transport_surface_linux\\.cc$'],
['exclude', 'common/gpu/image_transport_surface_win\\.cc$'],
['exclude', 'gl_surface_egl\\.cc$'],
+ ['exclude', 'gl_surface_egl_ozone\\.cc$'],
+ ['exclude', 'gl_surface_egl_win\\.cc$'],
+ ['exclude', 'gl_surface_egl_x11\\.cc$'],
['exclude', 'gl_surface_glx\\.cc$'],
- ['exclude', 'gl_surface_x11\\.cc$'],
- ['exclude', 'gl_surface_win\\.cc$'],
['exclude', 'gl_surface_ozone\\.cc$'],
+ ['exclude', 'gl_factory_ozone\\.cc$'],
+ ['exclude', 'gl_factory_win\\.cc$'],
+ ['exclude', 'gl_initializer_ozone\\.cc$'],
+ ['exclude', 'gl_initializer_win\\.cc$'],
+ ['exclude', 'gl_initializer_x11\\.cc$'],
# Avoid the ATL dependency to allow building with VS Express
['exclude', 'browser/accessibility/accessibility_tree_formatter\\.(cc|h)$',],
['exclude', 'browser/accessibility/accessibility_tree_formatter_mac\\.(mm|h)$',],
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index f45db6bf4..097dda1cd 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -343,18 +343,14 @@ gfx::NativeView RenderWidgetHostViewQt::GetNativeView() const
return gfx::NativeView();
}
-gfx::NativeViewId RenderWidgetHostViewQt::GetNativeViewId() const
-{
- return 0;
-}
-
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 +431,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;
@@ -580,7 +571,7 @@ void RenderWidgetHostViewQt::SetIsLoading(bool)
// We use WebContentsDelegateQt::LoadingStateChanged to notify about loading state.
}
-void RenderWidgetHostViewQt::TextInputStateChanged(const ViewHostMsg_TextInputState_Params &params)
+void RenderWidgetHostViewQt::TextInputStateChanged(const content::TextInputState &params)
{
m_currentInputType = params.type;
m_delegate->inputMethodStateChanged(params.type != ui::TEXT_INPUT_TYPE_NONE);
@@ -612,7 +603,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)
@@ -664,19 +655,19 @@ void RenderWidgetHostViewQt::UnlockCompositingSurface()
{
}
-void RenderWidgetHostViewQt::OnSwapCompositorFrame(uint32_t output_surface_id, scoped_ptr<cc::CompositorFrame> frame)
+void RenderWidgetHostViewQt::OnSwapCompositorFrame(uint32_t output_surface_id, cc::CompositorFrame frame)
{
- bool scrollOffsetChanged = (m_lastScrollOffset != frame->metadata.root_scroll_offset);
- bool contentsSizeChanged = (m_lastContentsSize != frame->metadata.root_layer_size);
- m_lastScrollOffset = frame->metadata.root_scroll_offset;
- m_lastContentsSize = frame->metadata.root_layer_size;
+ bool scrollOffsetChanged = (m_lastScrollOffset != frame.metadata.root_scroll_offset);
+ bool contentsSizeChanged = (m_lastContentsSize != frame.metadata.root_layer_size);
+ m_lastScrollOffset = frame.metadata.root_scroll_offset;
+ m_lastContentsSize = frame.metadata.root_layer_size;
Q_ASSERT(!m_needsDelegatedFrameAck);
m_needsDelegatedFrameAck = true;
m_pendingOutputSurfaceId = output_surface_id;
- Q_ASSERT(frame->delegated_frame_data);
+ Q_ASSERT(frame.delegated_frame_data);
Q_ASSERT(!m_chromiumCompositorData->frameData || m_chromiumCompositorData->frameData->resource_list.empty());
- m_chromiumCompositorData->frameData = std::move(frame->delegated_frame_data);
- m_chromiumCompositorData->frameDevicePixelRatio = frame->metadata.device_scale_factor;
+ m_chromiumCompositorData->frameData = std::move(frame.delegated_frame_data);
+ m_chromiumCompositorData->frameDevicePixelRatio = frame.metadata.device_scale_factor;
// Support experimental.viewport.devicePixelRatio, see GetScreenInfo implementation below.
float dpiScale = this->dpiScale();
@@ -720,11 +711,6 @@ void RenderWidgetHostViewQt::ClearCompositorFrame()
{
}
-bool RenderWidgetHostViewQt::GetScreenColorProfile(std::vector<char>*)
-{
- return false;
-}
-
void RenderWidgetHostViewQt::SelectionChanged(const base::string16 &text, size_t offset, const gfx::Range &range)
{
content::RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
@@ -882,7 +868,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 +1018,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: {
@@ -1048,7 +1026,25 @@ void RenderWidgetHostViewQt::handleInputMethodEvent(QInputMethodEvent *ev)
int start = qMin(attribute.start, (attribute.start + attribute.length));
int end = qMax(attribute.start, (attribute.start + attribute.length));
- underlines.push_back(blink::WebCompositionUnderline(start, end, /*color*/ SK_ColorBLACK, /*thick*/ false, /*backgroundColor*/ SK_ColorTRANSPARENT));
+
+ // Blink does not support negative position values. Adjust start and end positions
+ // to non-negative values.
+ if (start < 0) {
+ start = 0;
+ end = qMax(0, start + end);
+ }
+
+ QTextCharFormat format = qvariant_cast<QTextFormat>(attribute.value).toCharFormat();
+
+ QColor underlineColor(0, 0, 0, 0);
+ if (format.underlineStyle() != QTextCharFormat::NoUnderline)
+ underlineColor = format.underlineColor();
+
+ QColor backgroundColor(0, 0, 0, 0);
+ if (format.background().style() != Qt::NoBrush)
+ backgroundColor = format.background().color();
+
+ underlines.push_back(blink::WebCompositionUnderline(start, end, toSk(underlineColor), /*thick*/ false, toSk(backgroundColor)));
break;
}
case QInputMethodEvent::Cursor:
@@ -1067,9 +1063,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..d6c77fada 100644
--- a/src/core/render_widget_host_view_qt.h
+++ b/src/core/render_widget_host_view_qt.h
@@ -42,13 +42,12 @@
#include "render_widget_host_view_qt_delegate.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#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>
@@ -120,7 +119,6 @@ public:
virtual gfx::Vector2dF GetLastScrollOffset() const Q_DECL_OVERRIDE;
virtual gfx::Size GetPhysicalBackingSize() const Q_DECL_OVERRIDE;
virtual gfx::NativeView GetNativeView() const Q_DECL_OVERRIDE;
- virtual gfx::NativeViewId GetNativeViewId() const Q_DECL_OVERRIDE;
virtual gfx::NativeViewAccessible GetNativeViewAccessible() Q_DECL_OVERRIDE;
virtual void Focus() Q_DECL_OVERRIDE;
virtual bool HasFocus() const Q_DECL_OVERRIDE;
@@ -132,10 +130,9 @@ 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;
+ virtual void TextInputStateChanged(const content::TextInputState& params) Q_DECL_OVERRIDE;
virtual void ImeCancelComposition() Q_DECL_OVERRIDE;
virtual void ImeCompositionRangeChanged(const gfx::Range&, const std::vector<gfx::Rect>&) Q_DECL_OVERRIDE;
virtual void RenderProcessGone(base::TerminationStatus, int) Q_DECL_OVERRIDE;
@@ -147,12 +144,12 @@ public:
virtual bool CanCopyToVideoFrame() const Q_DECL_OVERRIDE;
virtual bool HasAcceleratedSurface(const gfx::Size&) Q_DECL_OVERRIDE;
- virtual void OnSwapCompositorFrame(uint32_t output_surface_id, scoped_ptr<cc::CompositorFrame> frame) Q_DECL_OVERRIDE;
+ virtual void OnSwapCompositorFrame(uint32_t output_surface_id, cc::CompositorFrame frame) Q_DECL_OVERRIDE;
+
virtual void GetScreenInfo(blink::WebScreenInfo* results) Q_DECL_OVERRIDE;
virtual gfx::Rect GetBoundsInRootWindow() Q_DECL_OVERRIDE;
virtual void ProcessAckedTouchEvent(const content::TouchEventWithLatencyInfo &touch, content::InputEventAckState ack_result) Q_DECL_OVERRIDE;
virtual void ClearCompositorFrame() Q_DECL_OVERRIDE;
- virtual bool GetScreenColorProfile(std::vector<char>*) Q_DECL_OVERRIDE;
virtual void LockCompositingSurface() Q_DECL_OVERRIDE;
virtual void UnlockCompositingSurface() Q_DECL_OVERRIDE;
@@ -184,26 +181,15 @@ 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 }
+ virtual ui::AcceleratedWidgetMac *GetAcceleratedWidgetMac() const Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED; return nullptr; }
#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
@@ -227,7 +213,7 @@ private:
bool m_touchMotionStarted;
QMap<int, int> m_touchIdMapping;
QList<QTouchEvent::TouchPoint> m_previousTouchPoints;
- scoped_ptr<RenderWidgetHostViewQtDelegate> m_delegate;
+ std::unique_ptr<RenderWidgetHostViewQtDelegate> m_delegate;
QExplicitlySharedDataPointer<ChromiumCompositorData> m_chromiumCompositorData;
cc::ReturnedResourceArray m_resourcesToRelease;
diff --git a/src/core/render_widget_host_view_qt_delegate.h b/src/core/render_widget_host_view_qt_delegate.h
index ce6ec730a..1e50c8f08 100644
--- a/src/core/render_widget_host_view_qt_delegate.h
+++ b/src/core/render_widget_host_view_qt_delegate.h
@@ -49,13 +49,25 @@ QT_BEGIN_NAMESPACE
class QCursor;
class QEvent;
class QPainter;
-class QSGImageNode;
class QSGLayer;
class QSGNode;
+class QSGRectangleNode;
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;
+#else
+class QSGInternalImageNode;
+class QSGImageNode;
+typedef QSGImageNode QSGTextureNode;
+#endif
+
QT_END_NAMESPACE
namespace QtWebEngineCore {
@@ -92,13 +104,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..69f5bfefe 100644
--- a/src/core/renderer/content_renderer_client_qt.cpp
+++ b/src/core/renderer/content_renderer_client_qt.cpp
@@ -43,18 +43,18 @@
#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/cdm/renderer/widevine_key_system_properties.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)
#include "components/visitedlink/renderer/visitedlink_slave.h"
-#include "components/web_cache/renderer/web_cache_render_process_observer.h"
+#include "components/web_cache/renderer/web_cache_impl.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_thread.h"
#include "content/public/renderer/render_view.h"
@@ -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()
{
}
@@ -108,23 +97,24 @@ 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());
+ m_webCacheImpl.reset(new web_cache::WebCacheImpl());
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)
{
// RenderViewObservers destroy themselves with their RenderView.
- new RenderViewObserverQt(render_view, m_webCacheObserver.data());
+ new RenderViewObserverQt(render_view, m_webCacheImpl.data());
new WebChannelIPCTransport(render_view);
UserResourceController::instance()->renderViewCreated(render_view);
#if defined(ENABLE_SPELLCHECK)
@@ -133,9 +123,8 @@ void ContentRendererClientQt::RenderViewCreated(content::RenderView* render_view
#if defined(ENABLE_BASIC_PRINTING)
new printing::PrintWebViewHelper(
- render_view,
- scoped_ptr<printing::PrintWebViewHelper::Delegate>(
- new PrintWebViewHelperDelegateQt()));
+ render_view,
+ base::WrapUnique(new PrintWebViewHelperDelegateQt()));
#endif // defined(ENABLE_BASIC_PRINTING)
}
@@ -144,14 +133,38 @@ void ContentRendererClientQt::RenderFrameCreated(content::RenderFrame* render_fr
new QtWebEngineCore::RenderFrameObserverQt(render_frame);
}
+void ContentRendererClientQt::RunScriptsAtDocumentStart(content::RenderFrame* render_frame)
+{
+ // Check whether the render_frame has been created and has not been detached yet.
+ // Otherwise the WebFrame is not available.
+ RenderFrameObserverQt *render_frame_observer = RenderFrameObserverQt::Get(render_frame);
+ if (!render_frame_observer || render_frame_observer->isFrameDetached())
+ return; // The frame is invisible to scripts.
+
+ if (WebChannelIPCTransport *transport = WebChannelIPCTransport::Get(render_frame->GetRenderView()))
+ transport->RunScriptsAtDocumentStart(render_frame);
+ UserResourceController::instance()->RunScriptsAtDocumentStart(render_frame);
+}
+
+void ContentRendererClientQt::RunScriptsAtDocumentEnd(content::RenderFrame* render_frame)
+{
+ // Check whether the render_frame has been created and has not been detached yet.
+ // Otherwise the WebFrame is not available.
+ RenderFrameObserverQt *render_frame_observer = RenderFrameObserverQt::Get(render_frame);
+ if (!render_frame_observer || render_frame_observer->isFrameDetached())
+ return; // The frame is invisible to scripts.
+
+ 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,9 +186,10 @@ 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()
- , scoped_ptr<error_page::ErrorPageParams>(), &errorStrings);
+
+ error_page::LocalizedError::GetStrings(error.reason, error.domain.utf8(), error.unreachableURL, isPost
+ , error.staleCopyInCache && !isPost, false, false, locale
+ , std::unique_ptr<error_page::ErrorPageParams>(), &errorStrings);
resourceId = IDR_NET_ERROR_HTML;
@@ -187,7 +201,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)
@@ -206,6 +220,8 @@ bool ContentRendererClientQt::IsLinkVisited(unsigned long long linkHash)
// found in the LICENSE file.
#if defined(ENABLE_PEPPER_CDMS)
+static const char kExternalClearKeyPepperType[] = "application/x-ppapi-clearkey-cdm";
+
static bool IsPepperCdmAvailable(const std::string& pepper_type,
std::vector<base::string16>* additional_param_names,
std::vector<base::string16>* additional_param_values)
@@ -221,21 +237,94 @@ static bool IsPepperCdmAvailable(const std::string& pepper_type,
return is_available;
}
+// KeySystemProperties implementation for external Clear Key systems.
+class ExternalClearKeyProperties : public media::KeySystemProperties
+{
+public:
+ explicit ExternalClearKeyProperties(const std::string& key_system_name)
+ : key_system_name_(key_system_name) {}
+
+ std::string GetKeySystemName() const override { return key_system_name_; }
+ bool IsSupportedInitDataType(media::EmeInitDataType init_data_type) const override
+ {
+ switch (init_data_type) {
+ case media::EmeInitDataType::WEBM:
+ case media::EmeInitDataType::KEYIDS:
+ return true;
+
+ case media::EmeInitDataType::CENC:
+#if defined(USE_PROPRIETARY_CODECS)
+ return true;
+#else
+ return false;
+#endif // defined(USE_PROPRIETARY_CODECS)
+
+ case media::EmeInitDataType::UNKNOWN:
+ return false;
+ }
+ NOTREACHED();
+ return false;
+ }
+
+ media::SupportedCodecs GetSupportedCodecs() const override
+ {
+#if defined(USE_PROPRIETARY_CODECS)
+ return media::EME_CODEC_MP4_ALL | media::EME_CODEC_WEBM_ALL;
+#else
+ return media::EME_CODEC_WEBM_ALL;
+#endif
+ }
+
+ media::EmeConfigRule GetRobustnessConfigRule(
+ media::EmeMediaType media_type,
+ const std::string& requested_robustness) const override
+ {
+ return requested_robustness.empty() ? media::EmeConfigRule::SUPPORTED
+ : media::EmeConfigRule::NOT_SUPPORTED;
+ }
+
+ // Persistent license sessions are faked.
+ media::EmeSessionTypeSupport GetPersistentLicenseSessionSupport() const override
+ {
+ return media::EmeSessionTypeSupport::SUPPORTED;
+ }
+
+ media::EmeSessionTypeSupport GetPersistentReleaseMessageSessionSupport() const override {
+ return media::EmeSessionTypeSupport::NOT_SUPPORTED;
+ }
+
+ media::EmeFeatureSupport GetPersistentStateSupport() const override
+ {
+ return media::EmeFeatureSupport::REQUESTABLE;
+ }
+
+ media::EmeFeatureSupport GetDistinctiveIdentifierSupport() const override
+ {
+ return media::EmeFeatureSupport::NOT_SUPPORTED;
+ }
+
+ std::string GetPepperType() const override
+ {
+ return kExternalClearKeyPepperType;
+ }
+
+private:
+ const std::string key_system_name_;
+};
+
// External Clear Key (used for testing).
-static void AddExternalClearKey(std::vector<media::KeySystemInfo>* concrete_key_systems)
+static void AddExternalClearKey(std::vector<std::unique_ptr<media::KeySystemProperties>>* concrete_key_systems)
{
- static const char kExternalClearKeyKeySystem[] =
- "org.chromium.externalclearkey";
- static const char kExternalClearKeyDecryptOnlyKeySystem[] =
- "org.chromium.externalclearkey.decryptonly";
- static const char kExternalClearKeyFileIOTestKeySystem[] =
- "org.chromium.externalclearkey.fileiotest";
- static const char kExternalClearKeyInitializeFailKeySystem[] =
- "org.chromium.externalclearkey.initializefail";
- static const char kExternalClearKeyCrashKeySystem[] =
- "org.chromium.externalclearkey.crash";
- static const char kExternalClearKeyPepperType[] =
- "application/x-ppapi-clearkey-cdm";
+ static const char kExternalClearKeyKeySystem[] =
+ "org.chromium.externalclearkey";
+ static const char kExternalClearKeyDecryptOnlyKeySystem[] =
+ "org.chromium.externalclearkey.decryptonly";
+ static const char kExternalClearKeyFileIOTestKeySystem[] =
+ "org.chromium.externalclearkey.fileiotest";
+ static const char kExternalClearKeyInitializeFailKeySystem[] =
+ "org.chromium.externalclearkey.initializefail";
+ static const char kExternalClearKeyCrashKeySystem[] =
+ "org.chromium.externalclearkey.crash";
std::vector<base::string16> additional_param_names;
std::vector<base::string16> additional_param_values;
@@ -244,53 +333,31 @@ static void AddExternalClearKey(std::vector<media::KeySystemInfo>* concrete_key_
&additional_param_values))
return;
- media::KeySystemInfo info;
- info.key_system = kExternalClearKeyKeySystem;
-
- info.supported_init_data_types =
- media::kInitDataTypeMaskWebM | media::kInitDataTypeMaskKeyIds;
- info.supported_codecs = media::EME_CODEC_WEBM_ALL;
-#if defined(USE_PROPRIETARY_CODECS)
- info.supported_init_data_types |= media::kInitDataTypeMaskCenc;
- info.supported_codecs |= media::EME_CODEC_MP4_ALL;
-#endif // defined(USE_PROPRIETARY_CODECS)
-
- info.max_audio_robustness = media::EmeRobustness::EMPTY;
- info.max_video_robustness = media::EmeRobustness::EMPTY;
-
- // Persistent sessions are faked.
- info.persistent_license_support = media::EmeSessionTypeSupport::SUPPORTED;
- info.persistent_release_message_support =
- media::EmeSessionTypeSupport::NOT_SUPPORTED;
- info.persistent_state_support = media::EmeFeatureSupport::REQUESTABLE;
- info.distinctive_identifier_support = media::EmeFeatureSupport::NOT_SUPPORTED;
-
- info.pepper_type = kExternalClearKeyPepperType;
-
- concrete_key_systems->push_back(info);
+ concrete_key_systems->emplace_back(
+ new ExternalClearKeyProperties(kExternalClearKeyKeySystem));
// Add support of decrypt-only mode in ClearKeyCdm.
- info.key_system = kExternalClearKeyDecryptOnlyKeySystem;
- concrete_key_systems->push_back(info);
+ concrete_key_systems->emplace_back(
+ new ExternalClearKeyProperties(kExternalClearKeyDecryptOnlyKeySystem));
// A key system that triggers FileIO test in ClearKeyCdm.
- info.key_system = kExternalClearKeyFileIOTestKeySystem;
- concrete_key_systems->push_back(info);
+ concrete_key_systems->emplace_back(
+ new ExternalClearKeyProperties(kExternalClearKeyFileIOTestKeySystem));
// A key system that Chrome thinks is supported by ClearKeyCdm, but actually
// will be refused by ClearKeyCdm. This is to test the CDM initialization
// failure case.
- info.key_system = kExternalClearKeyInitializeFailKeySystem;
- concrete_key_systems->push_back(info);
+ concrete_key_systems->emplace_back(
+ new ExternalClearKeyProperties(kExternalClearKeyInitializeFailKeySystem));
// A key system that triggers a crash in ClearKeyCdm.
- info.key_system = kExternalClearKeyCrashKeySystem;
- concrete_key_systems->push_back(info);
+ concrete_key_systems->emplace_back(
+ new ExternalClearKeyProperties(kExternalClearKeyCrashKeySystem));
}
#if defined(WIDEVINE_CDM_AVAILABLE)
-static void AddPepperBasedWidevine(std::vector<media::KeySystemInfo>* concrete_key_systems)
+static void AddPepperBasedWidevine(std::vector<std::unique_ptr<media::KeySystemProperties>> *concrete_key_systems)
{
//#if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
// Version glibc_version(gnu_get_libc_version());
@@ -319,26 +386,26 @@ static void AddPepperBasedWidevine(std::vector<media::KeySystemInfo>* concrete_k
supported_codecs |= media::EME_CODEC_MP4_AAC;
#endif // defined(USE_PROPRIETARY_CODECS)
- cdm::AddWidevineWithCodecs(
- cdm::WIDEVINE, supported_codecs,
- media::EmeRobustness::SW_SECURE_CRYPTO, // Maximum audio robustness.
- media::EmeRobustness::SW_SECURE_DECODE, // Maximum video robustness.
+ using Robustness = cdm::WidevineKeySystemProperties::Robustness;
+ concrete_key_systems->emplace_back(new cdm::WidevineKeySystemProperties(
+ supported_codecs,
+ Robustness::SW_SECURE_CRYPTO, // Maximum audio robustness.
+ Robustness::SW_SECURE_DECODE, // Maximum video robustness.
media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license.
media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-release-message.
- media::EmeFeatureSupport::REQUESTABLE, // Persistent state.
- media::EmeFeatureSupport::NOT_SUPPORTED, // Distinctive identifier.
- concrete_key_systems);
+ media::EmeFeatureSupport::REQUESTABLE, // Persistent state.
+ media::EmeFeatureSupport::NOT_SUPPORTED)); // Distinctive identifier.
}
#endif // defined(WIDEVINE_CDM_AVAILABLE)
#endif // defined(ENABLE_PEPPER_CDMS)
-void ContentRendererClientQt::AddKeySystems(std::vector<media::KeySystemInfo>* key_systems_info)
+void ContentRendererClientQt::AddSupportedKeySystems(std::vector<std::unique_ptr<media::KeySystemProperties>> *key_systems)
{
#if defined(ENABLE_PEPPER_CDMS)
- AddExternalClearKey(key_systems_info);
+ AddExternalClearKey(key_systems);
#if defined(WIDEVINE_CDM_AVAILABLE)
- AddPepperBasedWidevine(key_systems_info);
+ AddPepperBasedWidevine(key_systems);
#endif // defined(WIDEVINE_CDM_AVAILABLE)
#endif // defined(ENABLE_PEPPER_CDMS)
}
diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h
index d475c7801..72b4e4061 100644
--- a/src/core/renderer/content_renderer_client_qt.h
+++ b/src/core/renderer/content_renderer_client_qt.h
@@ -44,16 +44,12 @@
#include <QtGlobal>
#include <QScopedPointer>
-namespace content {
-class RenderProcessObserver;
-}
-
namespace visitedlink {
class VisitedLinkSlave;
}
namespace web_cache {
-class WebCacheRenderProcessObserver;
+class WebCacheImpl;
}
#if defined(ENABLE_SPELLCHECK)
@@ -76,12 +72,14 @@ public:
virtual unsigned long long VisitedLinkHash(const char *canonicalUrl, size_t length) Q_DECL_OVERRIDE;
virtual bool IsLinkVisited(unsigned long long linkHash) Q_DECL_OVERRIDE;
- virtual void AddKeySystems(std::vector<media::KeySystemInfo>* key_systems) Q_DECL_OVERRIDE;
+ virtual void AddSupportedKeySystems(std::vector<std::unique_ptr<media::KeySystemProperties>>* 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;
+ QScopedPointer<web_cache::WebCacheImpl> m_webCacheImpl;
#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_flash_renderer_host_qt.cpp b/src/core/renderer/pepper/pepper_flash_renderer_host_qt.cpp
index 37ce4b5f3..a46454407 100644
--- a/src/core/renderer/pepper/pepper_flash_renderer_host_qt.cpp
+++ b/src/core/renderer/pepper/pepper_flash_renderer_host_qt.cpp
@@ -250,6 +250,83 @@ int32_t PepperFlashRendererHostQt::OnDrawGlyphs(
params.glyph_indices.empty())
return PP_ERROR_FAILED;
+ int style = SkTypeface::kNormal;
+ if (static_cast<PP_BrowserFont_Trusted_Weight>(params.font_desc.weight) >= PP_BROWSERFONT_TRUSTED_WEIGHT_BOLD)
+ style |= SkTypeface::kBold;
+ if (params.font_desc.italic)
+ style |= SkTypeface::kItalic;
+ sk_sp<SkTypeface> typeface(SkTypeface::MakeFromName(params.font_desc.face.c_str(), SkFontStyle::FromOldStyle(style)));
+ if (!typeface)
+ return PP_ERROR_FAILED;
+
+ EnterResourceNoLock<PPB_ImageData_API> enter(params.image_data.host_resource(), true);
+ if (enter.failed())
+ return PP_ERROR_FAILED;
+
+ PPB_ImageData_API* image = static_cast<PPB_ImageData_API*>(enter.object());
+ SkCanvas* canvas = image->GetCanvas();
+ bool needs_unmapping = false;
+ if (!canvas) {
+ needs_unmapping = true;
+ image->Map();
+ canvas = image->GetCanvas();
+ if (!canvas)
+ return PP_ERROR_FAILED; // Failure mapping.
+ }
+
+ SkAutoCanvasRestore acr(canvas, true);
+
+ // Clip is applied in pixels before the transform.
+ SkRect clip_rect = {
+ SkIntToScalar(params.clip.point.x), SkIntToScalar(params.clip.point.y),
+ SkIntToScalar(params.clip.point.x + params.clip.size.width),
+ SkIntToScalar(params.clip.point.y + params.clip.size.height)};
+ canvas->clipRect(clip_rect);
+
+ SkMatrix matrix;
+ matrix.set(SkMatrix::kMScaleX, SkFloatToScalar(params.transformation[0][0]));
+ matrix.set(SkMatrix::kMSkewX, SkFloatToScalar(params.transformation[0][1]));
+ matrix.set(SkMatrix::kMTransX, SkFloatToScalar(params.transformation[0][2]));
+ matrix.set(SkMatrix::kMSkewY, SkFloatToScalar(params.transformation[1][0]));
+ matrix.set(SkMatrix::kMScaleY, SkFloatToScalar(params.transformation[1][1]));
+ matrix.set(SkMatrix::kMTransY, SkFloatToScalar(params.transformation[1][2]));
+ matrix.set(SkMatrix::kMPersp0, SkFloatToScalar(params.transformation[2][0]));
+ matrix.set(SkMatrix::kMPersp1, SkFloatToScalar(params.transformation[2][1]));
+ matrix.set(SkMatrix::kMPersp2, SkFloatToScalar(params.transformation[2][2]));
+ canvas->concat(matrix);
+
+ SkPaint paint;
+ paint.setColor(params.color);
+ paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
+ paint.setAntiAlias(true);
+ paint.setHinting(SkPaint::kFull_Hinting);
+ paint.setTextSize(SkIntToScalar(params.font_desc.size));
+ paint.setTypeface(std::move(typeface));
+ if (params.allow_subpixel_aa) {
+ paint.setSubpixelText(true);
+ paint.setLCDRenderText(true);
+ }
+
+ SkScalar x = SkIntToScalar(params.position.x);
+ SkScalar y = SkIntToScalar(params.position.y);
+
+ // Build up the skia advances.
+ size_t glyph_count = params.glyph_indices.size();
+ if (glyph_count) {
+ std::vector<SkPoint> sk_positions(glyph_count);
+ for (uint32_t i = 0; i < glyph_count; i++) {
+ sk_positions[i].set(x, y);
+ x += SkFloatToScalar(params.glyph_advances[i].x);
+ y += SkFloatToScalar(params.glyph_advances[i].y);
+ }
+
+ canvas->drawPosText(
+ &params.glyph_indices[0], glyph_count * 2, &sk_positions[0], paint);
+ }
+
+ if (needs_unmapping)
+ image->Unmap();
+
return PP_OK;
}
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..febde84f7 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,9 @@
#include "pepper_renderer_host_factory_qt.h"
#include "pepper_flash_renderer_host_qt.h"
+
+#include "base/memory/ptr_util.h"
+#include "chrome/renderer/pepper/pepper_flash_font_file_host.h"
#include "content/public/renderer/renderer_ppapi_host.h"
#include "ppapi/host/ppapi_host.h"
#include "ppapi/host/resource_host.h"
@@ -63,7 +66,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 +75,47 @@ 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)) {
+ switch (message.type()) {
+ case PpapiHostMsg_Flash_Create::ID:
+ return base::WrapUnique(new PepperFlashRendererHostQt(host_, instance, resource));
+ case PpapiHostMsg_FlashFullscreen_Create::ID:
+ case PpapiHostMsg_FlashMenu_Create::ID:
+ // Not implemented
+ break;
+ }
+ }
+ // TODO(raymes): PDF also needs access to the FlashFontFileHost currently.
+ // We should either rename PPB_FlashFont_File to PPB_FontFile_Private or get
+ // rid of its use in PDF if possible.
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));
+ || host_->GetPpapiHost()->permissions().HasPermission(ppapi::PERMISSION_PRIVATE)) {
+ switch (message.type()) {
+ case PpapiHostMsg_FlashFontFile_Create::ID: {
+ ppapi::proxy::SerializedFontDescription description;
+ PP_PrivateFontCharset charset;
+ if (ppapi::UnpackMessage<PpapiHostMsg_FlashFontFile_Create>(message, &description, &charset))
+ return base::WrapUnique(new PepperFlashFontFileHost(host_, instance, resource, description, charset));
+ break;
+ }
+ case PpapiHostMsg_FlashDRM_Create::ID:
+ // Not implemented
+ break;
+ }
+ }
+
+ if (host_->GetPpapiHost()->permissions().HasPermission(ppapi::PERMISSION_PRIVATE)) {
+ switch (message.type()) {
+ case PpapiHostMsg_PDF_Create::ID:
+ // Not implemented
+ break;
+ }
+ }
- 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..53e9407db 100644
--- a/src/core/renderer/render_frame_observer_qt.cpp
+++ b/src/core/renderer/render_frame_observer_qt.cpp
@@ -44,16 +44,19 @@
#include "render_frame_observer_qt.h"
+#include "base/memory/ptr_util.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 {
RenderFrameObserverQt::RenderFrameObserverQt(content::RenderFrame* render_frame)
: RenderFrameObserver(render_frame)
+ , RenderFrameObserverTracker<RenderFrameObserverQt>(render_frame)
+ , m_isFrameDetached(false)
{
}
@@ -65,9 +68,20 @@ RenderFrameObserverQt::~RenderFrameObserverQt()
void RenderFrameObserverQt::DidCreatePepperPlugin(content::RendererPpapiHost* host)
{
host->GetPpapiHost()->AddHostFactoryFilter(
- scoped_ptr<ppapi::host::HostFactory>(
- new PepperRendererHostFactoryQt(host)));
+ base::WrapUnique(new PepperRendererHostFactoryQt(host)));
+ host->GetPpapiHost()->AddInstanceMessageFilter(
+ base::WrapUnique(new PepperSharedMemoryMessageFilter(host)));
}
#endif
+void RenderFrameObserverQt::FrameDetached()
+{
+ m_isFrameDetached = true;
+}
+
+bool RenderFrameObserverQt::isFrameDetached() const
+{
+ return m_isFrameDetached;
+}
+
} // namespace QtWebEngineCore
diff --git a/src/core/renderer/render_frame_observer_qt.h b/src/core/renderer/render_frame_observer_qt.h
index b1d59d8c5..b74be5cd1 100644
--- a/src/core/renderer/render_frame_observer_qt.h
+++ b/src/core/renderer/render_frame_observer_qt.h
@@ -42,6 +42,7 @@
#include "base/compiler_specific.h"
#include "content/public/renderer/render_frame_observer.h"
+#include "content/public/renderer/render_frame_observer_tracker.h"
namespace content {
@@ -50,7 +51,10 @@ class RenderFrame;
namespace QtWebEngineCore {
-class RenderFrameObserverQt : public content::RenderFrameObserver {
+class RenderFrameObserverQt
+ : public content::RenderFrameObserver
+ , public content::RenderFrameObserverTracker<RenderFrameObserverQt>
+{
public:
explicit RenderFrameObserverQt(content::RenderFrame* render_frame);
~RenderFrameObserverQt();
@@ -58,9 +62,15 @@ public:
#if defined(ENABLE_PLUGINS)
void DidCreatePepperPlugin(content::RendererPpapiHost* host) override;
#endif
+ void OnDestruct() override { }
+ void FrameDetached() override;
+
+ bool isFrameDetached() const;
private:
DISALLOW_COPY_AND_ASSIGN(RenderFrameObserverQt);
+
+ bool m_isFrameDetached;
};
} // namespace QtWebEngineCore
diff --git a/src/core/renderer/render_view_observer_qt.cpp b/src/core/renderer/render_view_observer_qt.cpp
index 4b44a9bd9..393b4752c 100644
--- a/src/core/renderer/render_view_observer_qt.cpp
+++ b/src/core/renderer/render_view_observer_qt.cpp
@@ -41,40 +41,46 @@
#include "common/qt_messages.h"
-#include "components/web_cache/renderer/web_cache_render_process_observer.h"
+#include "components/web_cache/renderer/web_cache_impl.h"
#include "content/public/renderer/render_view.h"
#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(
content::RenderView* render_view,
- web_cache::WebCacheRenderProcessObserver* web_cache_render_process_observer)
+ web_cache::WebCacheImpl* web_cache_impl)
: content::RenderViewObserver(render_view)
- , m_web_cache_render_process_observer(web_cache_render_process_observer)
+ , m_web_cache_impl(web_cache_impl)
{
}
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::dumpWebViewAsText(
+ render_view()->GetWebView(),
+ 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()
@@ -96,6 +102,6 @@ bool RenderViewObserverQt::OnMessageReceived(const IPC::Message& message)
void RenderViewObserverQt::Navigate(const GURL &)
{
- if (m_web_cache_render_process_observer)
- m_web_cache_render_process_observer->ExecutePendingClearCache();
+ if (m_web_cache_impl)
+ m_web_cache_impl->ExecutePendingClearCache();
}
diff --git a/src/core/renderer/render_view_observer_qt.h b/src/core/renderer/render_view_observer_qt.h
index 4839ae064..b62c815af 100644
--- a/src/core/renderer/render_view_observer_qt.h
+++ b/src/core/renderer/render_view_observer_qt.h
@@ -44,13 +44,13 @@
#include <QtGlobal>
namespace web_cache {
-class WebCacheRenderProcessObserver;
+class WebCacheImpl;
}
class RenderViewObserverQt : public content::RenderViewObserver {
public:
RenderViewObserverQt(content::RenderView* render_view,
- web_cache::WebCacheRenderProcessObserver* web_cache_render_process_observer);
+ web_cache::WebCacheImpl* web_cache_impl);
private:
void onFetchDocumentMarkup(quint64 requestId);
@@ -58,11 +58,12 @@ private:
void onSetBackgroundColor(quint32 color);
void OnFirstVisuallyNonEmptyLayout() Q_DECL_OVERRIDE;
+ void OnDestruct() Q_DECL_OVERRIDE { }
virtual bool OnMessageReceived(const IPC::Message& message) Q_DECL_OVERRIDE;
virtual void Navigate(const GURL& url) Q_DECL_OVERRIDE;
- web_cache::WebCacheRenderProcessObserver* m_web_cache_render_process_observer;
+ web_cache::WebCacheImpl* m_web_cache_impl;
DISALLOW_COPY_AND_ASSIGN(RenderViewObserverQt);
};
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..d0b5088d6 100644
--- a/src/core/renderer/user_resource_controller.h
+++ b/src/core/renderer/user_resource_controller.h
@@ -40,7 +40,7 @@
#ifndef USER_RESOURCE_CONTROLLER_H
#define USER_RESOURCE_CONTROLLER_H
-#include "content/public/renderer/render_process_observer.h"
+#include "content/public/renderer/render_thread_observer.h"
#include "common/user_script_data.h"
@@ -48,12 +48,16 @@
#include <QtCore/QHash>
#include <QtCore/QSet>
+namespace blink {
+class WebLocalFrame;
+}
+
namespace content {
+class RenderFrame;
class RenderView;
}
-
-class UserResourceController : public content::RenderProcessObserver {
+class UserResourceController : public content::RenderThreadObserver {
public:
static UserResourceController *instance();
@@ -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..2ca6640c6 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,21 @@ 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
+ if (m_installed && render_frame->IsMainFrame())
+ WebChannelTransport::Install(render_frame->GetWebFrame(), m_installedWorldId);
+}
+
+
void WebChannelIPCTransport::installWebChannel(uint worldId)
{
blink::WebView *webView = render_view()->GetWebView();
@@ -170,6 +181,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 +234,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..e949d1c99 100644
--- a/src/core/renderer/web_channel_ipc_transport.h
+++ b/src/core/renderer/web_channel_ipc_transport.h
@@ -42,24 +42,33 @@
#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;
+ virtual void OnDestruct() Q_DECL_OVERRIDE { }
bool m_installed;
uint m_installedWorldId;
diff --git a/src/core/renderer/pepper/pepper_flash_browser_host_qt.cpp b/src/core/renderer_host/pepper/pepper_flash_browser_host_qt.cpp
index 4427a67f2..4427a67f2 100644
--- a/src/core/renderer/pepper/pepper_flash_browser_host_qt.cpp
+++ b/src/core/renderer_host/pepper/pepper_flash_browser_host_qt.cpp
diff --git a/src/core/renderer/pepper/pepper_flash_browser_host_qt.h b/src/core/renderer_host/pepper/pepper_flash_browser_host_qt.h
index 5d1107dfb..5d1107dfb 100644
--- a/src/core/renderer/pepper/pepper_flash_browser_host_qt.h
+++ b/src/core/renderer_host/pepper/pepper_flash_browser_host_qt.h
diff --git a/src/core/renderer/pepper/pepper_host_factory_qt.cpp b/src/core/renderer_host/pepper/pepper_host_factory_qt.cpp
index 9b7236d8a..4a25e7756 100644
--- a/src/core/renderer/pepper/pepper_host_factory_qt.cpp
+++ b/src/core/renderer_host/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_host/pepper/pepper_host_factory_qt.h
index e73e097c0..0446cf9e3 100644
--- a/src/core/renderer/pepper/pepper_host_factory_qt.h
+++ b/src/core/renderer_host/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_isolated_file_system_message_filter.cpp b/src/core/renderer_host/pepper/pepper_isolated_file_system_message_filter.cpp
index 7e8b2fdda..7e8b2fdda 100644
--- a/src/core/renderer/pepper/pepper_isolated_file_system_message_filter.cpp
+++ b/src/core/renderer_host/pepper/pepper_isolated_file_system_message_filter.cpp
diff --git a/src/core/renderer/pepper/pepper_isolated_file_system_message_filter.h b/src/core/renderer_host/pepper/pepper_isolated_file_system_message_filter.h
index 750f7cea0..750f7cea0 100644
--- a/src/core/renderer/pepper/pepper_isolated_file_system_message_filter.h
+++ b/src/core/renderer_host/pepper/pepper_isolated_file_system_message_filter.h
diff --git a/src/core/resource_dispatcher_host_delegate_qt.cpp b/src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp
index af8b02e1b..16a4e7265 100644
--- a/src/core/resource_dispatcher_host_delegate_qt.cpp
+++ b/src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp
@@ -151,7 +151,8 @@ static void LaunchURL(const GURL& url, int render_process_id,
bool ResourceDispatcherHostDelegateQt::HandleExternalProtocol(const GURL& url, int child_id,
const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
- bool is_main_frame, ui::PageTransition page_transition, bool has_user_gesture)
+ bool is_main_frame, ui::PageTransition page_transition, bool has_user_gesture,
+ content::ResourceContext* /*resource_context*/)
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
// We don't want to launch external applications unless it is based on a user action
diff --git a/src/core/resource_dispatcher_host_delegate_qt.h b/src/core/renderer_host/resource_dispatcher_host_delegate_qt.h
index 90797dbbf..6690f9a0f 100644
--- a/src/core/resource_dispatcher_host_delegate_qt.h
+++ b/src/core/renderer_host/resource_dispatcher_host_delegate_qt.h
@@ -89,10 +89,10 @@ private:
class ResourceDispatcherHostDelegateQt : public content::ResourceDispatcherHostDelegate {
public:
- virtual bool HandleExternalProtocol(const GURL& url,int child_id,
- const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
- bool is_main_frame, ui::PageTransition page_transition, bool has_user_gesture)
- Q_DECL_OVERRIDE;
+ bool HandleExternalProtocol(const GURL& url, int child_id,
+ const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
+ bool is_main_frame, ui::PageTransition page_transition, bool has_user_gesture,
+ content::ResourceContext* resource_context) override;
virtual content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(net::AuthChallengeInfo *authInfo, net::URLRequest *request) Q_DECL_OVERRIDE;
};
diff --git a/src/core/user_resource_controller_host.cpp b/src/core/renderer_host/user_resource_controller_host.cpp
index 9d2ba8eb8..9d2ba8eb8 100644
--- a/src/core/user_resource_controller_host.cpp
+++ b/src/core/renderer_host/user_resource_controller_host.cpp
diff --git a/src/core/user_resource_controller_host.h b/src/core/renderer_host/user_resource_controller_host.h
index 8e6e1e3bf..8e6e1e3bf 100644
--- a/src/core/user_resource_controller_host.h
+++ b/src/core/renderer_host/user_resource_controller_host.h
diff --git a/src/core/web_channel_ipc_transport_host.cpp b/src/core/renderer_host/web_channel_ipc_transport_host.cpp
index aef16f0a0..aef16f0a0 100644
--- a/src/core/web_channel_ipc_transport_host.cpp
+++ b/src/core/renderer_host/web_channel_ipc_transport_host.cpp
diff --git a/src/core/web_channel_ipc_transport_host.h b/src/core/renderer_host/web_channel_ipc_transport_host.h
index 9cc1f3104..75b40477e 100644
--- a/src/core/web_channel_ipc_transport_host.h
+++ b/src/core/renderer_host/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/resource_bundle_qt.cpp b/src/core/resource_bundle_qt.cpp
index fa5c04524..5f5cead96 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) {
+ std::unique_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();
+ }
+
+ std::unique_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/resource_context_qt.cpp b/src/core/resource_context_qt.cpp
index 5cb217605..1ab1ea223 100644
--- a/src/core/resource_context_qt.cpp
+++ b/src/core/resource_context_qt.cpp
@@ -39,6 +39,7 @@
#include "resource_context_qt.h"
+#include "content/public/browser/storage_partition.h"
#include "net/url_request/url_request_context_getter.h"
#include "browser_context_qt.h"
@@ -53,6 +54,8 @@ net::HostResolver *ResourceContextQt::GetHostResolver()
net::URLRequestContext* ResourceContextQt::GetRequestContext()
{
Q_ASSERT(context);
+ // FIXME: This is the only remaining use of GetRequestContext(),
+ // but we are on the wrong thread for calling BrowserContext::GetDefaultStoragePartition
return context->GetRequestContext()->GetURLRequestContext();
}
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/surface_factory_qt.cpp b/src/core/surface_factory_qt.cpp
index 48c91bfcf..97a304730 100644
--- a/src/core/surface_factory_qt.cpp
+++ b/src/core/surface_factory_qt.cpp
@@ -85,7 +85,7 @@ bool SurfaceFactoryQt::LoadEGLGLES2Bindings(AddGLLibraryCallback add_gl_library,
if (!gles2Library)
return false;
- gfx::GLGetProcAddressProc get_proc_address = reinterpret_cast<gfx::GLGetProcAddressProc>(base::GetFunctionPointerFromNativeLibrary(eglLibrary, "eglGetProcAddress"));
+ gl::GLGetProcAddressProc get_proc_address = reinterpret_cast<gl::GLGetProcAddressProc>(base::GetFunctionPointerFromNativeLibrary(eglLibrary, "eglGetProcAddress"));
if (!get_proc_address) {
LOG(ERROR) << "eglGetProcAddress not found.";
base::UnloadNativeLibrary(eglLibrary);
@@ -93,9 +93,9 @@ bool SurfaceFactoryQt::LoadEGLGLES2Bindings(AddGLLibraryCallback add_gl_library,
return false;
}
- gfx::SetGLGetProcAddressProc(get_proc_address);
- gfx::AddGLNativeLibrary(eglLibrary);
- gfx::AddGLNativeLibrary(gles2Library);
+ gl::SetGLGetProcAddressProc(get_proc_address);
+ gl::AddGLNativeLibrary(eglLibrary);
+ gl::AddGLNativeLibrary(gles2Library);
return true;
}
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/type_conversion.h b/src/core/type_conversion.h
index e96a544e5..ed02a9db9 100644
--- a/src/core/type_conversion.h
+++ b/src/core/type_conversion.h
@@ -60,7 +60,7 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkPixelRef.h"
-#include "third_party/skia/include/utils/SkMatrix44.h"
+#include "third_party/skia/include/core/SkMatrix44.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_f.h"
#include "url/gurl.h"
diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp
index bf32c75a4..61f359a87 100644
--- a/src/core/url_request_context_getter_qt.cpp
+++ b/src/core/url_request_context_getter_qt.cpp
@@ -40,6 +40,7 @@
#include "url_request_context_getter_qt.h"
#include "base/command_line.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/string_util.h"
#include "base/threading/worker_pool.h"
#include "base/threading/sequenced_worker_pool.h"
@@ -48,6 +49,10 @@
#include "content/public/common/content_switches.h"
#include "net/base/cache_type.h"
#include "net/cert/cert_verifier.h"
+#include "net/cert/ct_known_logs.h"
+#include "net/cert/ct_log_verifier.h"
+#include "net/cert/ct_policy_enforcer.h"
+#include "net/cert/multi_log_ct_verifier.h"
#include "net/disk_cache/disk_cache.h"
#include "net/dns/host_resolver.h"
#include "net/dns/mapped_host_resolver.h"
@@ -216,6 +221,7 @@ void URLRequestContextGetterQt::generateStorage()
cancelAllUrlRequests();
// we need to get rid of dangling pointer due to coming storage deletion
m_urlRequestContext->set_http_transaction_factory(0);
+ m_httpNetworkSession.reset();
}
m_storage.reset(new net::URLRequestContextStorage(m_urlRequestContext.get()));
@@ -224,8 +230,12 @@ void URLRequestContextGetterQt::generateStorage()
Q_ASSERT(proxyConfigService);
m_storage->set_cert_verifier(net::CertVerifier::CreateDefault());
+ std::unique_ptr<net::MultiLogCTVerifier> ct_verifier(new net::MultiLogCTVerifier());
+ ct_verifier->AddLogs(net::ct::CreateLogVerifiersForKnownLogs());
+ m_storage->set_cert_transparency_verifier(std::move(ct_verifier));
+ m_storage->set_ct_policy_enforcer(base::WrapUnique(new net::CTPolicyEnforcer));
- scoped_ptr<net::HostResolver> host_resolver(net::HostResolver::CreateDefaultResolver(NULL));
+ std::unique_ptr<net::HostResolver> host_resolver(net::HostResolver::CreateDefaultResolver(NULL));
// The System Proxy Resolver has issues on Windows with unconfigured network cards,
// which is why we want to use the v8 one
@@ -233,7 +243,7 @@ void URLRequestContextGetterQt::generateStorage()
m_dhcpProxyScriptFetcherFactory.reset(new net::DhcpProxyScriptFetcherFactory);
m_storage->set_proxy_service(net::CreateProxyServiceUsingV8ProxyResolver(
- scoped_ptr<net::ProxyConfigService>(proxyConfigService),
+ std::unique_ptr<net::ProxyConfigService>(proxyConfigService),
new net::ProxyScriptFetcherImpl(m_urlRequestContext.get()),
m_dhcpProxyScriptFetcherFactory->Create(m_urlRequestContext.get()),
host_resolver.get(),
@@ -241,10 +251,10 @@ void URLRequestContextGetterQt::generateStorage()
m_networkDelegate.get()));
m_storage->set_ssl_config_service(new net::SSLConfigServiceDefaults);
- m_storage->set_transport_security_state(scoped_ptr<net::TransportSecurityState>(new net::TransportSecurityState()));
+ m_storage->set_transport_security_state(std::unique_ptr<net::TransportSecurityState>(new net::TransportSecurityState()));
m_storage->set_http_auth_handler_factory(net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get()));
- m_storage->set_http_server_properties(scoped_ptr<net::HttpServerProperties>(new net::HttpServerPropertiesImpl));
+ m_storage->set_http_server_properties(std::unique_ptr<net::HttpServerProperties>(new net::HttpServerPropertiesImpl));
// Give |m_storage| ownership at the end in case it's |mapped_host_resolver|.
m_storage->set_host_resolver(std::move(host_resolver));
@@ -283,7 +293,7 @@ void URLRequestContextGetterQt::generateCookieStore()
}
m_storage->set_channel_id_service(
- scoped_ptr<net::ChannelIDService>(new net::ChannelIDService(
+ base::WrapUnique(new net::ChannelIDService(
new net::DefaultChannelIDStore(channel_id_db.get()),
base::WorkerPool::GetTaskRunner(true))));
@@ -291,7 +301,7 @@ void URLRequestContextGetterQt::generateCookieStore()
m_storage->set_cookie_store(0);
m_cookieDelegate->setCookieMonster(0);
- net::CookieStore* cookieStore = 0;
+ std::unique_ptr<net::CookieStore> cookieStore;
switch (m_persistentCookiesPolicy) {
case BrowserContextAdapter::NoPersistentCookies:
cookieStore =
@@ -321,10 +331,13 @@ 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());
+ cookieStore->SetChannelIDServiceID(m_urlRequestContext->channel_id_service()->GetUniqueID());
+ 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);
}
@@ -351,7 +364,7 @@ void URLRequestContextGetterQt::generateUserAgent()
QMutexLocker lock(&m_mutex);
m_updateUserAgent = true;
- m_storage->set_http_user_agent_settings(scoped_ptr<net::HttpUserAgentSettings>(
+ m_storage->set_http_user_agent_settings(std::unique_ptr<net::HttpUserAgentSettings>(
new net::StaticHttpUserAgentSettings(m_httpAcceptLanguage.toStdString(), m_httpUserAgent.toStdString())));
}
@@ -406,14 +419,16 @@ 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())
+ if (first.http_server_properties != second.http_server_properties)
return false;
if (first.ignore_certificate_errors != second.ignore_certificate_errors)
return false;
if (first.host_resolver != second.host_resolver)
return false;
+ if (first.cert_transparency_verifier != second.cert_transparency_verifier)
+ return false;
+ if (first.ct_policy_enforcer != second.ct_policy_enforcer)
+ return false;
return true;
}
@@ -430,10 +445,11 @@ 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();
+ network_session_params.cert_transparency_verifier = m_urlRequestContext->cert_transparency_verifier();
+ network_session_params.ct_policy_enforcer = m_urlRequestContext->ct_policy_enforcer();
return network_session_params;
}
@@ -482,9 +498,9 @@ void URLRequestContextGetterQt::generateHttpCache()
m_httpNetworkSession.reset(new net::HttpNetworkSession(network_session_params));
}
- cache = new net::HttpCache(m_httpNetworkSession.get(), scoped_ptr<net::HttpCache::DefaultBackend>(main_backend), false);
+ cache = new net::HttpCache(m_httpNetworkSession.get(), std::unique_ptr<net::HttpCache::DefaultBackend>(main_backend), false);
- m_storage->set_http_transaction_factory(scoped_ptr<net::HttpCache>(cache));
+ m_storage->set_http_transaction_factory(std::unique_ptr<net::HttpCache>(cache));
}
void URLRequestContextGetterQt::clearHttpCache()
@@ -513,36 +529,39 @@ void URLRequestContextGetterQt::generateJobFactory()
QMutexLocker lock(&m_mutex);
m_updateJobFactory = false;
- scoped_ptr<net::URLRequestJobFactoryImpl> jobFactory(new net::URLRequestJobFactoryImpl());
+ std::unique_ptr<net::URLRequestJobFactoryImpl> jobFactory(new net::URLRequestJobFactoryImpl());
{
- // Chromium has a few protocol handlers ready for us, only pick blob: and throw away the rest.
+ // Chromium has transferred a few protocol handlers to us, only pick blob: and chrome: and ignore the rest.
content::ProtocolHandlerMap::iterator it = m_protocolHandlers.find(url::kBlobScheme);
Q_ASSERT(it != m_protocolHandlers.end());
- jobFactory->SetProtocolHandler(it->first, scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>(it->second.release()));
+ jobFactory->SetProtocolHandler(it->first, std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(it->second.release()));
+ it = m_protocolHandlers.find(content::kChromeUIScheme);
+ Q_ASSERT(it != m_protocolHandlers.end());
+ jobFactory->SetProtocolHandler(it->first, std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(it->second.release()));
m_protocolHandlers.clear();
}
- jobFactory->SetProtocolHandler(url::kDataScheme, scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>(new net::DataProtocolHandler()));
- jobFactory->SetProtocolHandler(url::kFileScheme, scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>(new net::FileProtocolHandler(
+ jobFactory->SetProtocolHandler(url::kDataScheme, std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(new net::DataProtocolHandler()));
+ jobFactory->SetProtocolHandler(url::kFileScheme, std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(new net::FileProtocolHandler(
content::BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))));
- jobFactory->SetProtocolHandler(kQrcSchemeQt, scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>(new QrcProtocolHandlerQt()));
+ jobFactory->SetProtocolHandler(kQrcSchemeQt, std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(new QrcProtocolHandlerQt()));
jobFactory->SetProtocolHandler(url::kFtpScheme,
- scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>(new net::FtpProtocolHandler(new net::FtpNetworkLayer(m_urlRequestContext->host_resolver()))));
+ std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(new net::FtpProtocolHandler(new net::FtpNetworkLayer(m_urlRequestContext->host_resolver()))));
m_installedCustomSchemes = m_customUrlSchemes;
Q_FOREACH (const QByteArray &scheme, m_installedCustomSchemes) {
- jobFactory->SetProtocolHandler(scheme.toStdString(), scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>(new CustomProtocolHandler(m_browserContext)));
+ jobFactory->SetProtocolHandler(scheme.toStdString(), std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(new CustomProtocolHandler(m_browserContext)));
}
m_baseJobFactory = jobFactory.get();
// Set up interceptors in the reverse order.
- scoped_ptr<net::URLRequestJobFactory> topJobFactory = std::move(jobFactory);
+ std::unique_ptr<net::URLRequestJobFactory> topJobFactory = std::move(jobFactory);
for (content::URLRequestInterceptorScopedVector::reverse_iterator i = m_requestInterceptors.rbegin(); i != m_requestInterceptors.rend(); ++i)
- topJobFactory.reset(new net::URLRequestInterceptingJobFactory(std::move(topJobFactory), make_scoped_ptr(*i)));
+ topJobFactory.reset(new net::URLRequestInterceptingJobFactory(std::move(topJobFactory), std::unique_ptr<net::URLRequestInterceptor>(*i)));
m_requestInterceptors.weak_clear();
@@ -570,7 +589,7 @@ void URLRequestContextGetterQt::regenerateJobFactory()
m_installedCustomSchemes = m_customUrlSchemes;
Q_FOREACH (const QByteArray &scheme, m_installedCustomSchemes) {
- m_baseJobFactory->SetProtocolHandler(scheme.toStdString(), scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>(new CustomProtocolHandler(m_browserContext)));
+ m_baseJobFactory->SetProtocolHandler(scheme.toStdString(), std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(new CustomProtocolHandler(m_browserContext)));
}
}
diff --git a/src/core/url_request_context_getter_qt.h b/src/core/url_request_context_getter_qt.h
index dd51fd72c..8cfa8d759 100644
--- a/src/core/url_request_context_getter_qt.h
+++ b/src/core/url_request_context_getter_qt.h
@@ -44,8 +44,8 @@
#include "base/files/file_path.h"
#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,15 +116,15 @@ 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;
+ std::unique_ptr<net::HttpNetworkSession> m_httpNetworkSession;
QList<QByteArray> m_installedCustomSchemes;
QWebEngineUrlRequestInterceptor* m_requestInterceptor;
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_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index fc54c98ed..03b62d190 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -46,14 +46,16 @@
#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"
+#include "pdfium_printing_wrapper_qt.h"
#include "print_view_manager_qt.h"
#include "qwebenginecallback_p.h"
+#include "renderer_host/web_channel_ipc_transport_host.h"
#include "render_view_observer_host_qt.h"
#include "type_conversion.h"
-#include "web_channel_ipc_transport_host.h"
#include "web_contents_adapter_client.h"
#include "web_contents_view_qt.h"
#include "web_engine_context.h"
@@ -90,6 +92,9 @@
#include <QtGui/qaccessible.h>
#include <QtGui/qdrag.h>
#include <QtGui/qpixmap.h>
+#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER)
+#include <QtPrintSupport/qprinter.h>
+#endif // QT_NO_PRINTER
#include <QtWebChannel/QWebChannel>
namespace QtWebEngineCore {
@@ -188,6 +193,17 @@ static void callbackOnPrintingFinished(WebContentsAdapterClient *adapterClient,
}
}
+#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER)
+static void callbackOnPrintingOnPrinterFinished(WebContentsAdapterClient *adapterClient, int requestId, QPrinter *printer, const std::vector<char> &result)
+{
+ if (requestId) {
+ PdfiumPrintingWrapperQt printWrapper(result.data(), result.size());
+ bool printerResult = printWrapper.printOnPrinter(*printer);
+ adapterClient->didPrintPageOnPrinter(requestId, printerResult);
+ }
+}
+#endif // QT_NO_PRINTER
+
static content::WebContents *createBlankWebContents(WebContentsAdapterClient *adapterClient, content::BrowserContext *browserContext)
{
content::WebContents::CreateParams create_params(browserContext, NULL);
@@ -231,7 +247,7 @@ static void serializeNavigationHistory(const content::NavigationController &cont
}
}
-static void deserializeNavigationHistory(QDataStream &input, int *currentIndex, std::vector<scoped_ptr<content::NavigationEntry>> *entries, content::BrowserContext *browserContext)
+static void deserializeNavigationHistory(QDataStream &input, int *currentIndex, std::vector<std::unique_ptr<content::NavigationEntry>> *entries, content::BrowserContext *browserContext)
{
int version;
input >> version;
@@ -280,7 +296,7 @@ static void deserializeNavigationHistory(QDataStream &input, int *currentIndex,
return;
}
- scoped_ptr<content::NavigationEntry> entry = content::NavigationController::CreateNavigationEntry(
+ std::unique_ptr<content::NavigationEntry> entry = content::NavigationController::CreateNavigationEntry(
toGurl(virtualUrl),
content::Referrer(toGurl(referrerUrl), static_cast<blink::WebReferrerPolicy>(referrerPolicy)),
// Use a transition type of reload so that we don't incorrectly
@@ -351,7 +367,7 @@ WebContentsAdapterPrivate::~WebContentsAdapterPrivate()
QSharedPointer<WebContentsAdapter> WebContentsAdapter::createFromSerializedNavigationHistory(QDataStream &input, WebContentsAdapterClient *adapterClient)
{
int currentIndex;
- std::vector<scoped_ptr<content::NavigationEntry>> entries;
+ std::vector<std::unique_ptr<content::NavigationEntry>> entries;
deserializeNavigationHistory(input, &currentIndex, &entries, adapterClient->browserContextAdapter()->browserContext());
if (currentIndex == -1)
@@ -469,21 +485,21 @@ void WebContentsAdapter::stop()
controller.RemoveEntryAtIndex(index);
d->webContents->Stop();
- d->webContents->Focus();
+ focusIfNecessary();
}
void WebContentsAdapter::reload()
{
Q_D(WebContentsAdapter);
d->webContents->GetController().Reload(/*checkRepost = */false);
- d->webContents->Focus();
+ focusIfNecessary();
}
void WebContentsAdapter::reloadAndBypassCache()
{
Q_D(WebContentsAdapter);
- d->webContents->GetController().ReloadIgnoringCache(/*checkRepost = */false);
- d->webContents->Focus();
+ d->webContents->GetController().ReloadBypassingCache(/*checkRepost = */false);
+ focusIfNecessary();
}
void WebContentsAdapter::load(const QUrl &url)
@@ -502,11 +518,23 @@ void WebContentsAdapter::load(const QUrl &url)
Q_UNUSED(guard);
Q_D(WebContentsAdapter);
- content::NavigationController::LoadURLParams params(toGurl(url));
+ GURL gurl = toGurl(url);
+
+ // Add URL scheme if missing from view-source URL.
+ if (url.scheme() == content::kViewSourceScheme) {
+ QUrl pageUrl = QUrl(url.toString().remove(0, strlen(content::kViewSourceScheme) + 1));
+ if (pageUrl.scheme().isEmpty()) {
+ QUrl extendedUrl = QUrl::fromUserInput(pageUrl.toString());
+ extendedUrl = QUrl(QString("%1:%2").arg(content::kViewSourceScheme, extendedUrl.toString()));
+ gurl = toGurl(extendedUrl);
+ }
+ }
+
+ content::NavigationController::LoadURLParams params(gurl);
params.transition_type = ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR);
params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
d->webContents->GetController().LoadURLWithParams(params);
- d->webContents->Focus();
+ focusIfNecessary();
}
void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
@@ -519,7 +547,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;
}
@@ -531,13 +559,14 @@ void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeT
params.transition_type = ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_API);
params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
d->webContents->GetController().LoadURLWithParams(params);
- d->webContents->Focus();
+ focusIfNecessary();
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();
}
@@ -631,7 +660,7 @@ void WebContentsAdapter::selectAll()
void WebContentsAdapter::requestClose()
{
Q_D(WebContentsAdapter);
- d->webContents->DispatchBeforeUnload(false);
+ d->webContents->DispatchBeforeUnload();
}
void WebContentsAdapter::unselect()
@@ -644,14 +673,14 @@ void WebContentsAdapter::navigateToIndex(int offset)
{
Q_D(WebContentsAdapter);
d->webContents->GetController().GoToIndex(offset);
- d->webContents->Focus();
+ focusIfNecessary();
}
void WebContentsAdapter::navigateToOffset(int offset)
{
Q_D(WebContentsAdapter);
d->webContents->GetController().GoToOffset(offset);
- d->webContents->Focus();
+ focusIfNecessary();
}
int WebContentsAdapter::navigationEntryCount()
@@ -849,13 +878,19 @@ 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;
- scoped_ptr<content::DownloadUrlParameters> params(
- content::DownloadUrlParameters::FromWebContents(webContents(), toGurl(url)));
+ dlmd->setDownloadType(BrowserContextAdapterClient::UserRequested);
+ dlm->SetDelegate(dlmd);
+
+ std::unique_ptr<content::DownloadUrlParameters> params(
+ content::DownloadUrlParameters::CreateForWebContentsMainFrame(webContents(), toGurl(url)));
params->set_suggested_name(toString16(suggestedFileName));
dlm->DownloadUrl(std::move(params));
}
@@ -881,7 +916,7 @@ bool WebContentsAdapter::recentlyAudible()
void WebContentsAdapter::copyImageAt(const QPoint &location)
{
Q_D(WebContentsAdapter);
- d->webContents->GetRenderViewHost()->CopyImageAt(location.x(), location.y());
+ d->webContents->GetRenderViewHost()->GetMainFrame()->CopyImageAt(location.x(), location.y());
}
ASSERT_ENUMS_MATCH(WebContentsAdapter::MediaPlayerNoAction, blink::WebMediaPlayerAction::Unknown)
@@ -916,13 +951,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()
@@ -940,7 +975,7 @@ void WebContentsAdapter::wasHidden()
void WebContentsAdapter::printToPDF(const QPageLayout &pageLayout, const QString &filePath)
{
#if defined(ENABLE_BASIC_PRINTING)
- PrintViewManagerQt::FromWebContents(webContents())->PrintToPDF(pageLayout, filePath);
+ PrintViewManagerQt::FromWebContents(webContents())->PrintToPDF(pageLayout, true, filePath);
#endif // if defined(ENABLE_BASIC_PRINTING)
}
@@ -948,13 +983,33 @@ quint64 WebContentsAdapter::printToPDFCallbackResult(const QPageLayout &pageLayo
{
#if defined(ENABLE_BASIC_PRINTING)
Q_D(WebContentsAdapter);
- PrintViewManagerQt::PrintToPDFCallback callback = base::Bind(&callbackOnPrintingFinished, d->adapterClient, d->nextRequestId);
- PrintViewManagerQt::FromWebContents(webContents())->PrintToPDFWithCallback(pageLayout, callback);
+ PrintViewManagerQt::PrintToPDFCallback callback = base::Bind(&callbackOnPrintingFinished
+ , d->adapterClient
+ , d->nextRequestId);
+ PrintViewManagerQt::FromWebContents(webContents())->PrintToPDFWithCallback(pageLayout, true
+ , callback);
+ return d->nextRequestId++;
+#else
+ return 0;
+#endif // if defined(ENABLE_BASIC_PRINTING)
+}
+
+#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER)
+quint64 WebContentsAdapter::printOnPrinterCallbackResult(QPrinter *printer)
+{
+#if defined(ENABLE_BASIC_PRINTING)
+ Q_D(WebContentsAdapter);
+ PrintViewManagerQt::PrintToPDFCallback callback
+ = base::Bind(&callbackOnPrintingOnPrinterFinished, d->adapterClient
+ , d->nextRequestId, printer);
+ PrintViewManagerQt::FromWebContents(webContents())->PrintToPDFWithCallback(
+ printer->pageLayout(), printer->colorMode() == QPrinter::Color, callback);
return d->nextRequestId++;
#else
return 0;
#endif // if defined(ENABLE_BASIC_PRINTING)
}
+#endif // QT_NO_PRINTER
QPointF WebContentsAdapter::lastScrollOffset() const
{
@@ -1137,7 +1192,7 @@ void WebContentsAdapter::enterDrag(QDragEnterEvent *e, const QPoint &screenPos)
{
Q_D(WebContentsAdapter);
- scoped_ptr<content::DropData> ownedDropData;
+ std::unique_ptr<content::DropData> ownedDropData;
const content::DropData *rvhDropData = d->currentDropData;
if (!rvhDropData) {
// The drag originated outside the WebEngineView.
@@ -1203,7 +1258,7 @@ void WebContentsAdapter::endDragging(const QPoint &clientPos, const QPoint &scre
Q_D(WebContentsAdapter);
finishDragUpdate();
content::RenderViewHost *rvh = d->webContents->GetRenderViewHost();
- rvh->DragTargetDrop(toGfx(clientPos), toGfx(screenPos), 0);
+ rvh->DragTargetDrop(*d->currentDropData, toGfx(clientPos), toGfx(screenPos), 0);
}
void WebContentsAdapter::leaveDrag()
@@ -1242,6 +1297,15 @@ void WebContentsAdapter::replaceMisspelling(const QString &word)
#endif
}
+void WebContentsAdapter::focusIfNecessary()
+{
+ Q_D(WebContentsAdapter);
+ const WebEngineSettings *settings = d->adapterClient->webEngineSettings();
+ bool focusOnNavigation = settings->testAttribute(WebEngineSettings::FocusOnNavigationEnabled);
+ if (focusOnNavigation)
+ d->webContents->Focus();
+}
+
WebContentsAdapterClient::RenderProcessTerminationStatus
WebContentsAdapterClient::renderProcessExitStatus(int terminationStatus) {
auto status = WebContentsAdapterClient::RenderProcessTerminationStatus(-1);
@@ -1280,4 +1344,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..7a109770e 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -58,6 +58,9 @@ class QAccessibleInterface;
class QDragEnterEvent;
class QDragMoveEvent;
class QPageLayout;
+#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER)
+class QPrinter;
+#endif // QT_NO_PRINTER
class QString;
class QWebChannel;
QT_END_NAMESPACE
@@ -85,7 +88,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;
@@ -174,10 +177,19 @@ public:
void printToPDF(const QPageLayout&, const QString&);
quint64 printToPDFCallbackResult(const QPageLayout &);
+#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER)
+ quint64 printOnPrinterCallbackResult(QPrinter *printer);
+#endif
+
// meant to be used within WebEngineCore only
content::WebContents *webContents() const;
void replaceMisspelling(const QString &word);
+ void viewSource();
+ bool canViewSource();
+ void focusIfNecessary();
+
+
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..85a379409 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -71,23 +71,43 @@ class WebContentsAdapter;
class WebContentsDelegateQt;
class WebEngineSettings;
-// FIXME: make this ref-counted and implicitely shared and expose as public API maybe ?
-class WebEngineContextMenuData {
+
+class WebEngineContextMenuSharedData : public QSharedData {
public:
- WebEngineContextMenuData()
- : mediaType(MediaTypeNone)
- , hasImageContent(false)
- , mediaFlags(0)
+ WebEngineContextMenuSharedData()
+ : hasImageContent(false)
, isEditable(false)
, isSpellCheckerEnabled(false)
+ , mediaType(0)
+ , mediaFlags(0)
{
}
+ bool hasImageContent;
+ bool isEditable;
+ bool isSpellCheckerEnabled;
+ uint mediaType;
+ uint mediaFlags;
+ QPoint pos;
+ QUrl linkUrl;
+ QUrl mediaUrl;
+ QString linkText;
+ QString selectedText;
+ QString suggestedFileName;
+ QString misspelledWord;
+ QStringList spellCheckerSuggestions;
+ // Some likely candidates for future additions as we add support for the related actions:
+ // bool isImageBlocked;
+ // <enum tbd> mediaType;
+ // ...
+};
+class WebEngineContextMenuData {
+public:
// Must match blink::WebContextMenuData::MediaType:
enum MediaType {
// No special node is in context.
- MediaTypeNone,
+ MediaTypeNone = 0x0,
// An image node is selected.
MediaTypeImage,
// A video node is selected.
@@ -117,25 +137,118 @@ public:
MediaCanRotate = 0x200,
};
- QPoint pos;
- QUrl linkUrl;
- QString linkText;
- QString selectedText;
- QUrl mediaUrl;
- MediaType mediaType;
- bool hasImageContent;
- uint mediaFlags;
- QString suggestedFileName;
- bool isEditable;
- bool isSpellCheckerEnabled;
- QString misspelledWord;
- QStringList spellCheckerSuggestions;
-// Some likely candidates for future additions as we add support for the related actions:
-// bool isImageBlocked;
-// <enum tbd> mediaType;
-// ...
+ WebEngineContextMenuData():d(new WebEngineContextMenuSharedData) {
+ }
+
+ void setPosition(const QPoint &pos) {
+ d->pos = pos;
+ }
+
+ QPoint position() const {
+ return d->pos;
+ }
+
+ void setLinkUrl(const QUrl &url) {
+ d->linkUrl = url;
+ }
+
+ QUrl linkUrl() const {
+ return d->linkUrl;
+ }
+
+ void setLinkText(const QString &text) {
+ d->linkText = text;
+ }
+
+ QString linkText() const {
+ return d->linkText;
+ }
+
+ void setSelectedText(const QString &text) {
+ d->selectedText = text;
+ }
+
+ QString selectedText() const {
+ return d->selectedText;
+ }
+
+ void setMediaUrl(const QUrl &url) {
+ d->mediaUrl = url;
+ }
+
+ QUrl mediaUrl() const {
+ return d->mediaUrl;
+ }
+
+ void setMediaType(MediaType type) {
+ d->mediaType = type;
+ }
+
+ MediaType mediaType() const {
+ return MediaType(d->mediaType);
+ }
+
+ void setHasImageContent(bool imageContent) {
+ d->hasImageContent = imageContent;
+ }
+
+ bool hasImageContent() const {
+ return d->hasImageContent;
+ }
+
+ void setMediaFlags(MediaFlags flags) {
+ d->mediaFlags = flags;
+ }
+
+ MediaFlags mediaFlags() const {
+ return MediaFlags(d->mediaFlags);
+ }
+
+ void setSuggestedFileName(const QString &filename) {
+ d->suggestedFileName = filename;
+ }
+
+ QString suggestedFileName() const {
+ return d->suggestedFileName;
+ }
+
+ void setIsEditable(bool editable) {
+ d->isEditable = editable;
+ }
+
+ bool isEditable() const {
+ return d->isEditable;
+ }
+
+ void setIsSpellCheckerEnabled(bool spellCheckerEnabled) {
+ d->isSpellCheckerEnabled = spellCheckerEnabled;
+ }
+
+ bool isSpellCheckerEnabled() const {
+ return d->isSpellCheckerEnabled;
+ }
+
+ void setMisspelledWord(const QString &word) {
+ d->misspelledWord = word;
+ }
+
+ QString misspelledWord() const {
+ return d->misspelledWord;
+ }
+
+ void setSpellCheckerSuggestions(const QStringList &suggestions) {
+ d->spellCheckerSuggestions = suggestions;
+ }
+
+ QStringList spellCheckerSuggestions() const {
+ return d->spellCheckerSuggestions;
+ }
+
+private:
+ QSharedDataPointer<WebEngineContextMenuSharedData> d;
};
+
class QWEBENGINE_EXPORT WebContentsAdapterClient {
public:
// This must match window_open_disposition_list.h.
@@ -227,13 +340,16 @@ public:
virtual void requestFullScreenMode(const QUrl &origin, bool fullscreen) = 0;
virtual bool isFullScreenMode() const = 0;
virtual void javascriptDialog(QSharedPointer<JavaScriptDialogController>) = 0;
- virtual void runFileChooser(FilePickerController *controller) = 0;
+ virtual void runFileChooser(QSharedPointer<FilePickerController>) = 0;
virtual void showColorDialog(QSharedPointer<ColorChooserController>) = 0;
virtual void didRunJavaScript(quint64 requestId, const QVariant& result) = 0;
virtual void didFetchDocumentMarkup(quint64 requestId, const QString& result) = 0;
virtual void didFetchDocumentInnerText(quint64 requestId, const QString& result) = 0;
virtual void didFindText(quint64 requestId, int matchCount) = 0;
virtual void didPrintPage(quint64 requestId, const QByteArray &result) = 0;
+#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER)
+ virtual void didPrintPageOnPrinter(quint64 requestId, bool result) = 0;
+#endif
virtual void passOnFocus(bool reverse) = 0;
// returns the last QObject (QWidget/QQuickItem) based object in the accessibility
// hierarchy before going into the BrowserAccessibility tree
@@ -259,6 +375,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_adapter_p.h b/src/core/web_contents_adapter_p.h
index 5c0e83298..77522d299 100644
--- a/src/core/web_contents_adapter_p.h
+++ b/src/core/web_contents_adapter_p.h
@@ -55,7 +55,6 @@
#include <base/callback.h>
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include <QScopedPointer>
#include <QSharedPointer>
@@ -84,10 +83,10 @@ public:
~WebContentsAdapterPrivate();
scoped_refptr<WebEngineContext> engineContext;
QSharedPointer<BrowserContextAdapter> browserContextAdapter;
- scoped_ptr<content::WebContents> webContents;
- scoped_ptr<WebContentsDelegateQt> webContentsDelegate;
- scoped_ptr<RenderViewObserverHostQt> renderViewObserverHost;
- scoped_ptr<WebChannelIPCTransportHost> webChannelTransport;
+ std::unique_ptr<content::WebContents> webContents;
+ std::unique_ptr<WebContentsDelegateQt> webContentsDelegate;
+ std::unique_ptr<RenderViewObserverHostQt> renderViewObserverHost;
+ std::unique_ptr<WebChannelIPCTransportHost> webChannelTransport;
QWebChannel *webChannel;
unsigned int webChannelWorld;
WebContentsAdapterClient *adapterClient;
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index 757ae853c..36acfe62e 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -118,8 +118,8 @@ content::WebContents *WebContentsDelegateQt::OpenURLFromTab(content::WebContents
load_url_params.is_renderer_initiated = params.is_renderer_initiated;
load_url_params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
if (params.uses_post) {
- load_url_params.load_type = content::NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST;
- load_url_params.browser_initiated_post_data = params.browser_initiated_post_data;
+ load_url_params.load_type = content::NavigationController::LOAD_TYPE_HTTP_POST;
+ load_url_params.post_data = params.post_data;
}
target->GetController().LoadURLWithParams(load_url_params);
@@ -318,18 +318,19 @@ ASSERT_ENUMS_MATCH(FilePickerController::OpenMultiple, content::FileChooserParam
ASSERT_ENUMS_MATCH(FilePickerController::UploadFolder, content::FileChooserParams::UploadFolder)
ASSERT_ENUMS_MATCH(FilePickerController::Save, content::FileChooserParams::Save)
-void WebContentsDelegateQt::RunFileChooser(content::WebContents *web_contents, const content::FileChooserParams &params)
+void WebContentsDelegateQt::RunFileChooser(content::RenderFrameHost *frameHost, const content::FileChooserParams &params)
{
QStringList acceptedMimeTypes;
acceptedMimeTypes.reserve(params.accept_types.size());
for (std::vector<base::string16>::const_iterator it = params.accept_types.begin(); it < params.accept_types.end(); ++it)
acceptedMimeTypes.append(toQt(*it));
- FilePickerController *controller = new FilePickerController(static_cast<FilePickerController::FileChooserMode>(params.mode), web_contents, toQt(params.default_file_name.value()), acceptedMimeTypes);
+ m_filePickerController.reset(new FilePickerController(static_cast<FilePickerController::FileChooserMode>(params.mode),
+ web_contents(), toQt(params.default_file_name.value()), acceptedMimeTypes));
// Defer the call to not block base::MessageLoop::RunTask with modal dialogs.
- QTimer::singleShot(0, [this, controller] () {
- m_viewClient->runFileChooser(controller);
+ QTimer::singleShot(0, [this] () {
+ m_viewClient->runFileChooser(m_filePickerController);
});
}
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index d523aa16b..dad1e50f1 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
{
@@ -92,7 +108,7 @@ public:
virtual void EnterFullscreenModeForTab(content::WebContents* web_contents, const GURL& origin) Q_DECL_OVERRIDE;
virtual void ExitFullscreenModeForTab(content::WebContents*) Q_DECL_OVERRIDE;
virtual bool IsFullscreenForTabOrPending(const content::WebContents* web_contents) const Q_DECL_OVERRIDE;
- virtual void RunFileChooser(content::WebContents *, const content::FileChooserParams &params) Q_DECL_OVERRIDE;
+ virtual void RunFileChooser(content::RenderFrameHost* render_frame_host, const content::FileChooserParams& params) Q_DECL_OVERRIDE;
virtual bool AddMessageToConsole(content::WebContents* source, int32_t level, const base::string16& message, int32_t line_no, const base::string16& source_id) Q_DECL_OVERRIDE;
virtual void FindReply(content::WebContents *source, int request_id, int number_of_matches, const gfx::Rect& selection_rect, int active_match_ordinal, bool final_update) Q_DECL_OVERRIDE;
virtual void RequestMediaAccessPermission(content::WebContents* web_contents, const content::MediaStreamRequest& request, const content::MediaResponseCallback& callback) Q_DECL_OVERRIDE;
@@ -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,8 @@ private:
int m_lastReceivedFindReply;
QVector<int64_t> m_loadingErrorFrameList;
QScopedPointer<FaviconManager> m_faviconManager;
+ SavePageInfo m_savePageInfo;
+ QSharedPointer<FilePickerController> m_filePickerController;
};
} // namespace QtWebEngineCore
diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp
index e487fca46..ed6fdabff 100644
--- a/src/core/web_contents_view_qt.cpp
+++ b/src/core/web_contents_view_qt.cpp
@@ -155,19 +155,19 @@ ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanRotate, blink::WebContextMe
static inline WebEngineContextMenuData fromParams(const content::ContextMenuParams &params)
{
WebEngineContextMenuData ret;
- ret.pos = QPoint(params.x, params.y);
- ret.linkUrl = toQt(params.link_url);
- ret.linkText = toQt(params.link_text.data());
- ret.selectedText = toQt(params.selection_text.data());
- ret.mediaUrl = toQt(params.src_url);
- ret.mediaType = (WebEngineContextMenuData::MediaType)params.media_type;
- ret.hasImageContent = params.has_image_contents;
- ret.mediaFlags = params.media_flags;
- ret.suggestedFileName = toQt(params.suggested_filename.data());
- ret.isEditable = params.is_editable;
+ ret.setPosition(QPoint(params.x, params.y));
+ ret.setLinkUrl(toQt(params.link_url));
+ ret.setLinkText(toQt(params.link_text.data()));
+ ret.setSelectedText(toQt(params.selection_text.data()));
+ ret.setMediaUrl(toQt(params.src_url));
+ ret.setMediaType((WebEngineContextMenuData::MediaType)params.media_type);
+ ret.setHasImageContent(params.has_image_contents);
+ ret.setMediaFlags((WebEngineContextMenuData::MediaFlags)params.media_flags);
+ ret.setSuggestedFileName(toQt(params.suggested_filename.data()));
+ ret.setIsEditable(params.is_editable);
#if defined(ENABLE_SPELLCHECK)
- ret.misspelledWord = toQt(params.misspelled_word);
- ret.spellCheckerSuggestions = fromVector(params.dictionary_suggestions);
+ ret.setMisspelledWord(toQt(params.misspelled_word));
+ ret.setSpellCheckerSuggestions(fromVector(params.dictionary_suggestions));
#endif
return ret;
}
@@ -183,7 +183,7 @@ void WebContentsViewQt::ShowContextMenu(content::RenderFrameHost *, const conten
// must be initialized to true due to the way how the initialization sequence
// in SpellCheck works ie. typing the first word triggers the creation
// of the SpellcheckService. Use user preference store instead.
- contextMenuData.isSpellCheckerEnabled = m_client->browserContextAdapter()->isSpellCheckEnabled();
+ contextMenuData.setIsSpellCheckerEnabled(m_client->browserContextAdapter()->isSpellCheckEnabled());
#endif
m_client->contextMenuRequested(contextMenuData);
}
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index 0d1d7b127..491835e45 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -51,6 +51,7 @@
#if defined(ENABLE_BASIC_PRINTING)
#include "chrome/browser/printing/print_job_manager.h"
#endif // defined(ENABLE_BASIC_PRINTING)
+#include "components/devtools_http_handler/devtools_http_handler.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/utility_process_host_impl.h"
@@ -87,7 +88,9 @@
#include <QFileInfo>
#include <QGuiApplication>
#include <QOffscreenSurface>
-#include <QOpenGLContext>
+#ifndef QT_NO_OPENGL
+# include <QOpenGLContext>
+#endif
#include <QStringList>
#include <QSurfaceFormat>
#include <QVector>
@@ -95,9 +98,11 @@
using namespace QtWebEngineCore;
+#ifndef QT_NO_OPENGL
QT_BEGIN_NAMESPACE
Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
QT_END_NAMESPACE
+#endif
namespace {
@@ -114,6 +119,7 @@ void destroyContext()
s_destroyed = true;
}
+#ifndef QT_NO_OPENGL
bool usingANGLE()
{
#if defined(Q_OS_WIN)
@@ -150,12 +156,16 @@ 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");
}
-
+#endif //QT_NO_OPENGL
#if defined(ENABLE_PLUGINS)
void dummyGetPluginCallback(const std::vector<content::WebPluginInfo>&)
{
@@ -294,6 +304,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
if (!parsedCommandLine->HasSwitch(switches::kDisableOverlayScrollbar))
@@ -312,11 +325,12 @@ WebEngineContext::WebEngineContext()
GLContextHelper::initialize();
const char *glType = 0;
+#ifndef QT_NO_OPENGL
if (!usingANGLE() && !usingSoftwareDynamicGL() && !usingQtQuick2DRenderer()) {
if (qt_gl_global_share_context() && qt_gl_global_share_context()->isValid()) {
if (!strcmp(qt_gl_global_share_context()->nativeHandle().typeName(), "QEGLNativeContext")) {
if (qt_gl_global_share_context()->isOpenGLES()) {
- glType = gfx::kGLImplementationEGLName;
+ glType = gl::kGLImplementationEGLName;
} else {
QOpenGLContext context;
QSurfaceFormat format;
@@ -334,7 +348,7 @@ WebEngineContext::WebEngineContext()
if (context.makeCurrent(&surface)) {
if (context.hasExtension("GL_ARB_ES2_compatibility"))
- glType = gfx::kGLImplementationEGLName;
+ glType = gl::kGLImplementationEGLName;
context.doneCurrent();
}
@@ -344,12 +358,13 @@ WebEngineContext::WebEngineContext()
}
} else {
if (!qt_gl_global_share_context()->isOpenGLES())
- glType = gfx::kGLImplementationDesktopName;
+ glType = gl::kGLImplementationDesktopName;
}
} else {
qWarning("WebEngineContext used before QtWebEngine::initialize() or OpenGL context creation failed.");
}
}
+#endif
if (glType)
parsedCommandLine->AppendSwitchASCII(switches::kUseGL, glType);
@@ -380,6 +395,8 @@ WebEngineContext::WebEngineContext()
// first gets referenced on the IO thread.
MediaCaptureDevicesDispatcher::GetInstance();
+ base::ThreadRestrictions::SetIOAllowed(true);
+
#if defined(ENABLE_PLUGINS)
// Creating pepper plugins from the page (which calls PluginService::GetPluginInfoArray)
// might fail unless the page queried the list of available plugins at least once
diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h
index 960f8ed47..878b651de 100644
--- a/src/core/web_engine_context.h
+++ b/src/core/web_engine_context.h
@@ -43,9 +43,7 @@
#include "qtwebenginecoreglobal.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
-#include "components/devtools_http_handler/devtools_http_handler.h"
#include <QSharedPointer>
@@ -58,6 +56,10 @@ class BrowserMainRunner;
class ContentMainRunner;
}
+namespace devtools_http_handler {
+class DevToolsHttpHandler;
+}
+
#if defined(ENABLE_BASIC_PRINTING)
namespace printing {
class PrintJobManager;
@@ -89,15 +91,15 @@ private:
WebEngineContext();
~WebEngineContext();
- scoped_ptr<base::RunLoop> m_runLoop;
- scoped_ptr<ContentMainDelegateQt> m_mainDelegate;
- scoped_ptr<content::ContentMainRunner> m_contentRunner;
- scoped_ptr<content::BrowserMainRunner> m_browserRunner;
+ std::unique_ptr<base::RunLoop> m_runLoop;
+ std::unique_ptr<ContentMainDelegateQt> m_mainDelegate;
+ std::unique_ptr<content::ContentMainRunner> m_contentRunner;
+ std::unique_ptr<content::BrowserMainRunner> m_browserRunner;
QObject* m_globalQObject;
QSharedPointer<QtWebEngineCore::BrowserContextAdapter> m_defaultBrowserContext;
- scoped_ptr<devtools_http_handler::DevToolsHttpHandler> m_devtools;
+ std::unique_ptr<devtools_http_handler::DevToolsHttpHandler> m_devtools;
#if defined(ENABLE_BASIC_PRINTING)
- scoped_ptr<printing::PrintJobManager> m_printJobManager;
+ std::unique_ptr<printing::PrintJobManager> m_printJobManager;
#endif // defined(ENABLE_BASIC_PRINTING)
};
diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp
index 399e36765..40977812d 100644
--- a/src/core/web_engine_library_info.cpp
+++ b/src/core/web_engine_library_info.cpp
@@ -69,7 +69,7 @@ QString fallbackDir() {
return directory;
}
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD)
static inline CFBundleRef frameworkBundle()
{
return CFBundleGetBundleWithIdentifier(CFSTR("org.qt-project.Qt.QtWebEngineCore"));
@@ -112,6 +112,34 @@ static QString getResourcesPath(CFBundleRef frameworkBundle)
}
#endif
+#if defined(OS_MACOSX)
+static QString getMainApplicationResourcesPath()
+{
+ QString resourcesPath;
+ CFBundleRef mainBundle = CFBundleGetMainBundle();
+ if (!mainBundle)
+ return resourcesPath;
+
+ // Will point to Resources inside an app bundle, or in case if the application is not packaged
+ // as a bundle, will point to the application directory, where the resources are assumed to be
+ // found.
+ CFURLRef resourcesRelativeUrl = CFBundleCopyResourcesDirectoryURL(mainBundle);
+ if (!resourcesRelativeUrl)
+ return resourcesPath;
+
+ CFURLRef resourcesAbsoluteUrl = CFURLCopyAbsoluteURL(resourcesRelativeUrl);
+ CFStringRef resourcesAbolutePath = CFURLCopyFileSystemPath(resourcesAbsoluteUrl,
+ kCFURLPOSIXPathStyle);
+ resourcesPath = QString::fromCFString(resourcesAbolutePath);
+ CFRelease(resourcesAbolutePath);
+ CFRelease(resourcesAbsoluteUrl);
+ CFRelease(resourcesRelativeUrl);
+
+ return resourcesPath;
+}
+
+#endif
+
QString subProcessPath()
{
static QString processPath;
@@ -181,18 +209,42 @@ QString localesPath()
#if defined(ENABLE_SPELLCHECK)
QString dictionariesPath()
{
+ static QString potentialDictionariesPath;
+ static bool initialized = false;
+ QStringList candidatePaths;
+ if (!initialized) {
+ initialized = true;
+
+ // First try to find dictionaries near the application.
+#ifdef OS_MACOSX
+ QString resourcesDictionariesPath = getMainApplicationResourcesPath()
+ % QDir::separator() % QLatin1String("qtwebengine_dictionaries");
+ candidatePaths << resourcesDictionariesPath;
+#endif
+ QString applicationDictionariesPath = QCoreApplication::applicationDirPath()
+ % QDir::separator() % QLatin1String("qtwebengine_dictionaries");
+ candidatePaths << applicationDictionariesPath;
+
+ // Then try to find dictionaries near the installed library.
#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD)
- return getResourcesPath(frameworkBundle()) % QLatin1String("/qtwebengine_dictionaries");
-#else
- // first local path
- static QString potentialDictionariesPath = QCoreApplication::applicationDirPath() % QDir::separator() % QLatin1String("qtwebengine_dictionaries");
+ QString frameworkDictionariesPath = getResourcesPath(frameworkBundle())
+ % QLatin1String("/qtwebengine_dictionaries");
+ candidatePaths << frameworkDictionariesPath;
+#endif
- // now global one
- if (!QFileInfo::exists(potentialDictionariesPath))
- potentialDictionariesPath = QLibraryInfo::location(QLibraryInfo::DataPath) % QDir::separator() % QLatin1String("qtwebengine_dictionaries");
+ QString libraryDictionariesPath = QLibraryInfo::location(QLibraryInfo::DataPath)
+ % QDir::separator() % QLatin1String("qtwebengine_dictionaries");
+ candidatePaths << libraryDictionariesPath;
+
+ Q_FOREACH (const QString &candidate, candidatePaths) {
+ if (QFileInfo::exists(candidate)) {
+ potentialDictionariesPath = candidate;
+ break;
+ }
+ }
+ }
return potentialDictionariesPath;
-#endif
}
#endif // ENABLE_SPELLCHECK
@@ -303,8 +355,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/web_engine_settings.cpp b/src/core/web_engine_settings.cpp
index fb0f7e839..c17177745 100644
--- a/src/core/web_engine_settings.cpp
+++ b/src/core/web_engine_settings.cpp
@@ -239,6 +239,8 @@ void WebEngineSettings::initDefaults(bool offTheRecord)
s_defaultAttributes.insert(Accelerated2dCanvasEnabled, accelerated2dCanvas);
s_defaultAttributes.insert(AutoLoadIconsForPage, true);
s_defaultAttributes.insert(TouchIconsEnabled, false);
+ s_defaultAttributes.insert(FocusOnNavigationEnabled, true);
+ s_defaultAttributes.insert(PrintElementBackgrounds, true);
s_defaultAttributes.insert(AllowRunningInsecureContent, allowRunningInsecureContent);
}
if (offTheRecord)
@@ -316,6 +318,7 @@ void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *p
prefs->fullscreen_supported = testAttribute(FullScreenSupportEnabled);
prefs->accelerated_2d_canvas_enabled = testAttribute(Accelerated2dCanvasEnabled);
prefs->experimental_webgl_enabled = testAttribute(WebGLEnabled);
+ prefs->should_print_backgrounds = testAttribute(PrintElementBackgrounds);
prefs->allow_running_insecure_content = testAttribute(AllowRunningInsecureContent);
// Fonts settings.
diff --git a/src/core/web_engine_settings.h b/src/core/web_engine_settings.h
index e131af50c..8459ba75b 100644
--- a/src/core/web_engine_settings.h
+++ b/src/core/web_engine_settings.h
@@ -80,6 +80,8 @@ public:
Accelerated2dCanvasEnabled,
AutoLoadIconsForPage,
TouchIconsEnabled,
+ FocusOnNavigationEnabled,
+ PrintElementBackgrounds,
AllowRunningInsecureContent
};
diff --git a/src/core/web_engine_visited_links_manager.cpp b/src/core/web_engine_visited_links_manager.cpp
index ded9d5d24..0cf76d456 100644
--- a/src/core/web_engine_visited_links_manager.cpp
+++ b/src/core/web_engine_visited_links_manager.cpp
@@ -44,7 +44,6 @@
#include "content_browser_client_qt.h"
#include "type_conversion.h"
-#include "base/memory/scoped_ptr.h"
#include "components/visitedlink/browser/visitedlink_delegate.h"
#include "components/visitedlink/browser/visitedlink_master.h"
diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp
index 80850af70..4f5023376 100644
--- a/src/core/web_event_factory.cpp
+++ b/src/core/web_event_factory.cpp
@@ -66,6 +66,9 @@
#include "web_event_factory.h"
#include "third_party/WebKit/Source/platform/WindowsKeyboardCodes.h"
+#include "ui/events/keycodes/dom/dom_code.h"
+#include "ui/events/keycodes/dom/dom_key.h"
+#include "ui/events/keycodes/dom/keycode_converter.h"
#include <QCoreApplication>
#include <QElapsedTimer>
@@ -471,6 +474,552 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode, bool isKeypad)
}
}
+/*
+ * List of the available DOM key values can be found in the
+ * chromium/ui/events/keycodes/dom/dom_key_data_inc file.
+ * Some of the DOM keys are currently unsupported in Qt:
+ *
+ * Modifier Keys:
+ * - ui::DomKey::ACCEL
+ * - ui::DomKey::FN
+ * - ui::DomKey::FN_LOCK
+ * - ui::DomKey::SYMBOL
+ * - ui::DomKey::SYMBOL_LOCK
+ * - ui::DomKey::SHIFT_LEVEL5
+ * - ui::DomKey::ALT_GRAPH_LATCH
+ *
+ * Editing Keys:
+ * - ui::DomKey::CR_SEL
+ * - ui::DomKey::ERASE_OF
+ * - ui::DomKey::EX_SEL
+ *
+ * UI Keys:
+ * - ui::DomKey::ACCEPT
+ * - ui::DomKey::AGAIN
+ * - ui::DomKey::ATTN
+ * - ui::DomKey::PROPS
+ *
+ * Device Keys:
+ * - ui::DomKey::POWER
+ *
+ * IME and Composition Keys:
+ * - ui::DomKey::ALL_CANDIDATES
+ * - ui::DomKey::ALPHANUMERIC
+ * - ui::DomKey::FINAL_MODE
+ * - ui::DomKey::GROUP_FIRST
+ * - ui::DomKey::GROUP_LAST
+ * - ui::DomKey::GROUP_NEXT
+ * - ui::DomKey::GROUP_PREVIOUS
+ * - ui::DomKey::NEXT_CANDIDATE
+ * - ui::DomKey::PREVIOUS_CANDIDATE
+ * - ui::DomKey::PROCESS
+ * - ui::DomKey::JUNJA_MODE
+ *
+ * General-Purpose Function Keys:
+ * - ui::DomKey::SOFT1
+ * - ui::DomKey::SOFT2
+ * - ui::DomKey::SOFT3
+ * - ui::DomKey::SOFT4
+ * - ui::DomKey::SOFT5
+ * - ui::DomKey::SOFT6
+ * - ui::DomKey::SOFT7
+ * - ui::DomKey::SOFT8
+ *
+ * Multimedia Numpad Keys:
+ * - ui::DomKey::KEY11
+ * - ui::DomKey::KEY12
+ *
+ * Audio Keys:
+ * - ui::DomKey::AUDIO_BALANCE_LEFT
+ * - ui::DomKey::AUDIO_BALANCE_RIGHT
+ * - ui::DomKey::AUDIO_BASS_BOOST_DOWN
+ * - ui::DomKey::AUDIO_BASS_BOOST_UP
+ * - ui::DomKey::AUDIO_FADER_FRONT
+ * - ui::DomKey::AUDIO_FADER_REAR
+ * - ui::DomKey::AUDIO_SURROUND_MODE_NEXT
+ * - ui::DomKey::MICROPHONE_TOGGLE
+ *
+ * Speech Keys:
+ * - ui::DomKey::SPEECH_CORRECTION_LIST
+ * - ui::DomKey::SPEECH_INPUT_TOGGLE
+ *
+ * Application Keys:
+ * - ui::DomKey::LAUNCH_CONTACTS
+ *
+ * Mobile Phone Keys:
+ * - ui::DomKey::APP_SWITCH
+ * - ui::DomKey::GO_BACK
+ * - ui::DomKey::GO_HOME
+ * - ui::DomKey::HEADSET_HOOK
+ * - ui::DomKey::NOTIFICATION
+ * - ui::DomKey::MANNER_MODE
+ *
+ * TV Keys:
+ * - ui::DomKey::TV
+ * - ui::DomKey::TV_3D_MODE
+ * - ui::DomKey::TV_ANTENNA_CABLE
+ * - ui::DomKey::TV_AUDIO_DESCRIPTION
+ * - ui::DomKey::TV_AUDIO_DESCRIPTION_MIX_DOWN
+ * - ui::DomKey::TV_AUDIO_DESCRIPTION_MIX_UP
+ * - ui::DomKey::TV_CONTENTS_MENU
+ * - ui::DomKey::TV_DATA_SERVICE
+ * - ui::DomKey::TV_INPUT
+ * - ui::DomKey::TV_INPUT_COMPONENT1
+ * - ui::DomKey::TV_INPUT_COMPONENT2
+ * - ui::DomKey::TV_INPUT_COMPOSITE1
+ * - ui::DomKey::TV_INPUT_COMPOSITE2
+ * - ui::DomKey::TV_INPUT_HDMI1
+ * - ui::DomKey::TV_INPUT_HDMI2
+ * - ui::DomKey::TV_INPUT_HDMI3
+ * - ui::DomKey::TV_INPUT_HDMI4
+ * - ui::DomKey::TV_INPUT_VGA1
+ * - ui::DomKey::TV_MEDIA_CONTEXT
+ * - ui::DomKey::TV_NETWORK
+ * - ui::DomKey::TV_NUMBER_ENTRY
+ * - ui::DomKey::TV_POWER
+ * - ui::DomKey::TV_RADIO_SERVICE
+ * - ui::DomKey::TV_SATELLITE
+ * - ui::DomKey::TV_SATELLITE_BC
+ * - ui::DomKey::TV_SATELLITE_CS
+ * - ui::DomKey::TV_SATELLITE_TOGGLE
+ * - ui::DomKey::TV_TERRESTRIAL_ANALOG
+ * - ui::DomKey::TV_TERRESTRIAL_DIGITAL
+ * - ui::DomKey::TV_TIMER
+ *
+ * Media Controller Keys:
+ * - ui::DomKey::AVR_INPUT
+ * - ui::DomKey::AVR_POWER
+ * - ui::DomKey::COLOR_F4_GREY
+ * - ui::DomKey::COLOR_F5_BROWN
+ * - ui::DomKey::CLOSED_CAPTION_TOGGLE
+ * - ui::DomKey::DVR
+ * - ui::DomKey::FAVORITE_CLEAR0
+ * - ui::DomKey::FAVORITE_CLEAR1
+ * - ui::DomKey::FAVORITE_CLEAR2
+ * - ui::DomKey::FAVORITE_CLEAR3
+ * - ui::DomKey::FAVORITE_RECALL0
+ * - ui::DomKey::FAVORITE_RECALL1
+ * - ui::DomKey::FAVORITE_RECALL2
+ * - ui::DomKey::FAVORITE_RECALL3
+ * - ui::DomKey::FAVORITE_STORE0
+ * - ui::DomKey::FAVORITE_STORE1
+ * - ui::DomKey::FAVORITE_STORE2
+ * - ui::DomKey::FAVORITE_STORE3
+ * - ui::DomKey::GUIDE_NEXT_DAY
+ * - ui::DomKey::GUIDE_PREVIOUS_DAY
+ * - ui::DomKey::INSTANT_REPLAY
+ * - ui::DomKey::LINK
+ * - ui::DomKey::LIST_PROGRAM
+ * - ui::DomKey::LIVE_CONTENT
+ * - ui::DomKey::LOCK
+ * - ui::DomKey::MEDIA_APPS
+ * - ui::DomKey::MEDIA_AUDIO_TRACK
+ * - ui::DomKey::MEDIA_SKIP_BACKWARD
+ * - ui::DomKey::MEDIA_SKIP_FORWARD
+ * - ui::DomKey::MEDIA_SKIP
+ * - ui::DomKey::MEDIA_STEP_BACKWARD
+ * - ui::DomKey::MEDIA_STEP_FORWARD
+ * - ui::DomKey::NAVIGATE_IN
+ * - ui::DomKey::NAVIGATE_NEXT
+ * - ui::DomKey::NAVIGATE_OUT
+ * - ui::DomKey::NAVIGATE_PREVIOUS
+ * - ui::DomKey::NEXT_FAVORITE_CHANNEL
+ * - ui::DomKey::NEXT_USER_PROFILE
+ * - ui::DomKey::ON_DEMAND
+ * - ui::DomKey::PAIRING
+ * - ui::DomKey::PINP_DOWN
+ * - ui::DomKey::PINP_MOVE
+ * - ui::DomKey::PINP_TOGGLE
+ * - ui::DomKey::PINP_UP
+ * - ui::DomKey::PLAY_SPEED_DOWN
+ * - ui::DomKey::PLAY_SPEED_RESET
+ * - ui::DomKey::PLAY_SPEED_UP
+ * - ui::DomKey::RC_LOW_BATTERY
+ * - ui::DomKey::RECORD_SPEED_NEXT
+ * - ui::DomKey::RF_BYPASS
+ * - ui::DomKey::SCAN_CHANNELS_TOGGLE
+ * - ui::DomKey::SCREEN_MODE_NEXT
+ * - ui::DomKey::STB_INPUT
+ * - ui::DomKey::STB_POWER
+ * - ui::DomKey::TELETEXT
+ * - ui::DomKey::VIDEO_MODE_NEXT
+ * - ui::DomKey::WINK
+ */
+static ui::DomKey getDomKeyFromQKeyEvent(QKeyEvent *ev)
+{
+ if (!ev->text().isEmpty())
+ return ui::DomKey::FromCharacter(ev->text().toUcs4().first());
+
+ switch (ev->key()) {
+ case Qt::Key_Backspace:
+ return ui::DomKey::BACKSPACE;
+ case Qt::Key_Tab:
+ case Qt::Key_Backtab:
+ return ui::DomKey::TAB;
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
+ return ui::DomKey::ENTER;
+ case Qt::Key_Escape:
+ return ui::DomKey::ESCAPE;
+ case Qt::Key_Delete:
+ return ui::DomKey::DEL;
+
+ // Special Key Values
+ case Qt::Key_unknown:
+ return ui::DomKey::UNIDENTIFIED;
+
+ // Modifier Keys
+ case Qt::Key_Alt:
+ return ui::DomKey::ALT;
+ case Qt::Key_AltGr:
+ return ui::DomKey::ALT_GRAPH;
+ case Qt::Key_CapsLock:
+ return ui::DomKey::CAPS_LOCK;
+ case Qt::Key_Control:
+ return ui::DomKey::CONTROL;
+ case Qt::Key_Hyper_L:
+ case Qt::Key_Hyper_R:
+ return ui::DomKey::HYPER;
+ case Qt::Key_Meta:
+ return ui::DomKey::META;
+ case Qt::Key_NumLock:
+ return ui::DomKey::NUM_LOCK;
+ case Qt::Key_ScrollLock:
+ return ui::DomKey::SCROLL_LOCK;
+ case Qt::Key_Shift:
+ return ui::DomKey::SHIFT;
+ case Qt::Key_Super_L:
+ case Qt::Key_Super_R:
+ return ui::DomKey::SUPER;
+
+ // Navigation Keys
+ case Qt::Key_Down:
+ return ui::DomKey::ARROW_DOWN;
+ case Qt::Key_Left:
+ return ui::DomKey::ARROW_LEFT;
+ case Qt::Key_Right:
+ return ui::DomKey::ARROW_RIGHT;
+ case Qt::Key_Up:
+ return ui::DomKey::ARROW_UP;
+ case Qt::Key_End:
+ return ui::DomKey::END;
+ case Qt::Key_Home:
+ return ui::DomKey::HOME;
+ case Qt::Key_PageUp:
+ return ui::DomKey::PAGE_UP;
+ case Qt::Key_PageDown:
+ return ui::DomKey::PAGE_DOWN;
+
+ // Editing Keys
+ case Qt::Key_Clear:
+ return ui::DomKey::CLEAR;
+ case Qt::Key_Copy:
+ return ui::DomKey::COPY;
+ case Qt::Key_Cut:
+ return ui::DomKey::CUT;
+ case Qt::Key_Insert:
+ return ui::DomKey::INSERT;
+ case Qt::Key_Paste:
+ return ui::DomKey::PASTE;
+ case Qt::Key_Redo:
+ return ui::DomKey::REDO;
+ case Qt::Key_Undo:
+ return ui::DomKey::UNDO;
+
+ // UI Keys
+ case Qt::Key_Cancel:
+ return ui::DomKey::CANCEL;
+ case Qt::Key_Menu:
+ return ui::DomKey::CONTEXT_MENU;
+ case Qt::Key_Execute:
+ return ui::DomKey::EXECUTE;
+ case Qt::Key_Find:
+ return ui::DomKey::FIND;
+ case Qt::Key_Help:
+ return ui::DomKey::HELP;
+ case Qt::Key_Pause:
+ return ui::DomKey::PAUSE;
+ case Qt::Key_Play:
+ return ui::DomKey::PLAY;
+ case Qt::Key_Select:
+ return ui::DomKey::SELECT;
+ case Qt::Key_ZoomIn:
+ return ui::DomKey::ZOOM_IN;
+ case Qt::Key_ZoomOut:
+ return ui::DomKey::ZOOM_OUT;
+
+ // Device Keys
+ case Qt::Key_MonBrightnessDown:
+ return ui::DomKey::BRIGHTNESS_DOWN;
+ case Qt::Key_MonBrightnessUp:
+ return ui::DomKey::BRIGHTNESS_UP;
+ case Qt::Key_Eject:
+ return ui::DomKey::EJECT;
+ case Qt::Key_LogOff:
+ return ui::DomKey::LOG_OFF;
+ case Qt::Key_PowerDown:
+ case Qt::Key_PowerOff:
+ return ui::DomKey::POWER_OFF;
+ case Qt::Key_Print:
+ return ui::DomKey::PRINT_SCREEN;
+ case Qt::Key_Hibernate:
+ return ui::DomKey::HIBERNATE;
+ case Qt::Key_Standby:
+ return ui::DomKey::STANDBY;
+ case Qt::Key_WakeUp:
+ return ui::DomKey::WAKE_UP;
+
+ // IME and Composition Keys
+ case Qt::Key_Codeinput:
+ return ui::DomKey::CODE_INPUT;
+ case Qt::Key_Multi_key:
+ return ui::DomKey::COMPOSE;
+ case Qt::Key_Henkan:
+ return ui::DomKey::CONVERT;
+ case Qt::Key_Mode_switch:
+ return ui::DomKey::MODE_CHANGE;
+ case Qt::Key_Muhenkan:
+ return ui::DomKey::NON_CONVERT;
+ case Qt::Key_SingleCandidate:
+ return ui::DomKey::SINGLE_CANDIDATE;
+ case Qt::Key_Hangul:
+ return ui::DomKey::HANGUL_MODE;
+ case Qt::Key_Hangul_Hanja:
+ return ui::DomKey::HANJA_MODE;
+ case Qt::Key_Eisu_Shift:
+ case Qt::Key_Eisu_toggle:
+ return ui::DomKey::EISU;
+ case Qt::Key_Hankaku:
+ return ui::DomKey::HANKAKU;
+ case Qt::Key_Hiragana:
+ return ui::DomKey::HIRAGANA;
+ case Qt::Key_Hiragana_Katakana:
+ return ui::DomKey::HIRAGANA_KATAKANA;
+ case Qt::Key_Kana_Lock:
+ case Qt::Key_Kana_Shift:
+ return ui::DomKey::KANA_MODE;
+ case Qt::Key_Kanji:
+ return ui::DomKey::KANJI_MODE;
+ case Qt::Key_Katakana:
+ return ui::DomKey::KATAKANA;
+ case Qt::Key_Romaji:
+ return ui::DomKey::ROMAJI;
+ case Qt::Key_Zenkaku:
+ return ui::DomKey::ZENKAKU;
+ case Qt::Key_Zenkaku_Hankaku:
+ return ui::DomKey::ZENKAKU_HANKAKU;
+
+ // General-Purpose Function Keys
+ case Qt::Key_F1:
+ return ui::DomKey::F1;
+ case Qt::Key_F2:
+ return ui::DomKey::F2;
+ case Qt::Key_F3:
+ return ui::DomKey::F3;
+ case Qt::Key_F4:
+ return ui::DomKey::F4;
+ case Qt::Key_F5:
+ return ui::DomKey::F5;
+ case Qt::Key_F6:
+ return ui::DomKey::F6;
+ case Qt::Key_F7:
+ return ui::DomKey::F7;
+ case Qt::Key_F8:
+ return ui::DomKey::F8;
+ case Qt::Key_F9:
+ return ui::DomKey::F9;
+ case Qt::Key_F10:
+ return ui::DomKey::F10;
+ case Qt::Key_F11:
+ return ui::DomKey::F11;
+ case Qt::Key_F12:
+ return ui::DomKey::F12;
+ case Qt::Key_F13:
+ return ui::DomKey::F13;
+ case Qt::Key_F14:
+ return ui::DomKey::F14;
+ case Qt::Key_F15:
+ return ui::DomKey::F15;
+ case Qt::Key_F16:
+ return ui::DomKey::F16;
+ case Qt::Key_F17:
+ return ui::DomKey::F17;
+ case Qt::Key_F18:
+ return ui::DomKey::F18;
+ case Qt::Key_F19:
+ return ui::DomKey::F19;
+ case Qt::Key_F20:
+ return ui::DomKey::F20;
+ case Qt::Key_F21:
+ return ui::DomKey::F21;
+ case Qt::Key_F22:
+ return ui::DomKey::F22;
+ case Qt::Key_F23:
+ return ui::DomKey::F23;
+ case Qt::Key_F24:
+ return ui::DomKey::F24;
+
+ // Multimedia Keys
+ case Qt::Key_ChannelDown:
+ return ui::DomKey::CHANNEL_DOWN;
+ case Qt::Key_ChannelUp:
+ return ui::DomKey::CHANNEL_UP;
+ case Qt::Key_Close:
+ return ui::DomKey::CLOSE;
+ case Qt::Key_MailForward:
+ return ui::DomKey::MAIL_FORWARD;
+ case Qt::Key_Reply:
+ return ui::DomKey::MAIL_REPLY;
+ case Qt::Key_Send:
+ return ui::DomKey::MAIL_SEND;
+ case Qt::Key_AudioForward:
+ return ui::DomKey::MEDIA_FAST_FORWARD;
+ case Qt::Key_MediaPause:
+ return ui::DomKey::MEDIA_PAUSE;
+ case Qt::Key_MediaPlay:
+ return ui::DomKey::MEDIA_PLAY;
+ case Qt::Key_MediaTogglePlayPause:
+ return ui::DomKey::MEDIA_PLAY_PAUSE;
+ case Qt::Key_MediaRecord:
+ return ui::DomKey::MEDIA_RECORD;
+ case Qt::Key_AudioRewind:
+ return ui::DomKey::MEDIA_REWIND;
+ case Qt::Key_MediaStop:
+ return ui::DomKey::MEDIA_STOP;
+ case Qt::Key_MediaNext:
+ return ui::DomKey::MEDIA_TRACK_NEXT;
+ case Qt::Key_MediaPrevious:
+ return ui::DomKey::MEDIA_TRACK_PREVIOUS;
+ case Qt::Key_New:
+ return ui::DomKey::NEW;
+ case Qt::Key_Open:
+ return ui::DomKey::OPEN;
+ case Qt::Key_Printer:
+ return ui::DomKey::PRINT;
+ case Qt::Key_Save:
+ return ui::DomKey::SAVE;
+ case Qt::Key_Spell:
+ return ui::DomKey::SPELL_CHECK;
+
+ // Audio Keys
+ case Qt::Key_BassDown:
+ return ui::DomKey::AUDIO_BASS_DOWN;
+ case Qt::Key_BassBoost:
+ return ui::DomKey::AUDIO_BASS_BOOST_TOGGLE;
+ case Qt::Key_BassUp:
+ return ui::DomKey::AUDIO_BASS_UP;
+ case Qt::Key_TrebleDown:
+ return ui::DomKey::AUDIO_TREBLE_DOWN;
+ case Qt::Key_TrebleUp:
+ return ui::DomKey::AUDIO_TREBLE_UP;
+ case Qt::Key_VolumeDown:
+ return ui::DomKey::AUDIO_VOLUME_DOWN;
+ case Qt::Key_VolumeUp:
+ return ui::DomKey::AUDIO_VOLUME_UP;
+ case Qt::Key_VolumeMute:
+ return ui::DomKey::AUDIO_VOLUME_MUTE;
+ case Qt::Key_MicVolumeDown:
+ return ui::DomKey::MICROPHONE_VOLUME_DOWN;
+ case Qt::Key_MicVolumeUp:
+ return ui::DomKey::MICROPHONE_VOLUME_UP;
+ case Qt::Key_MicMute:
+ return ui::DomKey::MICROPHONE_VOLUME_MUTE;
+
+ // Application Keys
+ case Qt::Key_Calculator:
+ return ui::DomKey::LAUNCH_CALCULATOR;
+ case Qt::Key_Calendar:
+ return ui::DomKey::LAUNCH_CALENDAR;
+ case Qt::Key_LaunchMail:
+ return ui::DomKey::LAUNCH_MAIL;
+ case Qt::Key_LaunchMedia:
+ return ui::DomKey::LAUNCH_MEDIA_PLAYER;
+ case Qt::Key_Music:
+ return ui::DomKey::LAUNCH_MUSIC_PLAYER;
+ case Qt::Key_Launch0:
+ return ui::DomKey::LAUNCH_MY_COMPUTER;
+ case Qt::Key_Phone:
+ return ui::DomKey::LAUNCH_PHONE;
+ case Qt::Key_ScreenSaver:
+ return ui::DomKey::LAUNCH_SCREEN_SAVER;
+ case Qt::Key_Excel:
+ return ui::DomKey::LAUNCH_SPREADSHEET;
+ case Qt::Key_WWW:
+ return ui::DomKey::LAUNCH_WEB_BROWSER;
+ case Qt::Key_WebCam:
+ return ui::DomKey::LAUNCH_WEB_CAM;
+ case Qt::Key_Word:
+ return ui::DomKey::LAUNCH_WORD_PROCESSOR;
+
+ // Browser Keys
+ case Qt::Key_Back:
+ return ui::DomKey::BROWSER_BACK;
+ case Qt::Key_Favorites:
+ return ui::DomKey::BROWSER_FAVORITES;
+ case Qt::Key_Forward:
+ return ui::DomKey::BROWSER_FORWARD;
+ case Qt::Key_HomePage:
+ return ui::DomKey::BROWSER_HOME;
+ case Qt::Key_Refresh:
+ return ui::DomKey::BROWSER_REFRESH;
+ case Qt::Key_Search:
+ return ui::DomKey::BROWSER_SEARCH;
+ case Qt::Key_Stop:
+ return ui::DomKey::BROWSER_STOP;
+
+ // Mobile Phone Keys
+ case Qt::Key_Call:
+ return ui::DomKey::CALL;
+ case Qt::Key_Camera:
+ return ui::DomKey::CAMERA;
+ case Qt::Key_CameraFocus:
+ return ui::DomKey::CAMERA_FOCUS;
+ case Qt::Key_Hangup:
+ return ui::DomKey::END_CALL;
+ case Qt::Key_LastNumberRedial:
+ return ui::DomKey::LAST_NUMBER_REDIAL;
+ case Qt::Key_VoiceDial:
+ return ui::DomKey::VOICE_DIAL;
+
+ // Media Controller Keys
+ case Qt::Key_Red:
+ return ui::DomKey::COLOR_F0_RED;
+ case Qt::Key_Green:
+ return ui::DomKey::COLOR_F1_GREEN;
+ case Qt::Key_Yellow:
+ return ui::DomKey::COLOR_F2_YELLOW;
+ case Qt::Key_Blue:
+ return ui::DomKey::COLOR_F3_BLUE;
+ case Qt::Key_BrightnessAdjust:
+ return ui::DomKey::DIMMER;
+ case Qt::Key_Display:
+ return ui::DomKey::DISPLAY_SWAP;
+ case Qt::Key_Exit:
+ return ui::DomKey::EXIT;
+ case Qt::Key_Guide:
+ return ui::DomKey::GUIDE;
+ case Qt::Key_Info:
+ return ui::DomKey::INFO;
+ case Qt::Key_MediaLast:
+ return ui::DomKey::MEDIA_LAST;
+ case Qt::Key_TopMenu:
+ return ui::DomKey::MEDIA_TOP_MENU;
+ case Qt::Key_AudioRandomPlay:
+ return ui::DomKey::RANDOM_TOGGLE;
+ case Qt::Key_Settings:
+ return ui::DomKey::SETTINGS;
+ case Qt::Key_SplitScreen:
+ return ui::DomKey::SPLIT_SCREEN_TOGGLE;
+ case Qt::Key_Subtitle:
+ return ui::DomKey::SUBTITLE;
+ case Qt::Key_Zoom:
+ return ui::DomKey::ZOOM_TOGGLE;
+
+ default:
+ return ui::DomKey::NONE;
+ }
+}
+
static inline double currentTimeForEvent(const QInputEvent* event)
{
Q_ASSERT(event);
@@ -699,6 +1248,13 @@ content::NativeWebKeyboardEvent WebEventFactory::toWebKeyboardEvent(QKeyEvent *e
webKitEvent.nativeKeyCode = ev->nativeVirtualKey();
webKitEvent.windowsKeyCode = windowsKeyCodeForKeyEvent(ev->key(), ev->modifiers() & Qt::KeypadModifier);
webKitEvent.setKeyIdentifierFromWindowsKeyCode();
+ webKitEvent.domKey = getDomKeyFromQKeyEvent(ev);
+
+ ui::DomCode domCode = ui::DomCode::NONE;
+ int scanCode = ev->nativeScanCode();
+ if (scanCode)
+ domCode = ui::KeycodeConverter::NativeKeycodeToDomCode(scanCode);
+ webKitEvent.domCode = static_cast<int>(domCode);
const ushort* text = ev->text().utf16();
memcpy(&webKitEvent.text, text, std::min(sizeof(webKitEvent.text), size_t(ev->text().length() * 2)));
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: