diff options
69 files changed, 799 insertions, 409 deletions
diff --git a/.qmake.conf b/.qmake.conf index 52fc5b4ea..5237fb5fd 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -2,4 +2,4 @@ QMAKEPATH += $$PWD/tools/qmake load(qt_build_config) CONFIG += warning_clean -MODULE_VERSION = 5.7.0 +MODULE_VERSION = 5.8.0 diff --git a/src/3rdparty b/src/3rdparty -Subproject 168cc2b83c53e4e68bf89b331d92da88a99d2bf +Subproject bb91a70e24ac49fd21c1d7c8c91a216961da1e2 diff --git a/src/core/access_token_store_qt.cpp b/src/core/access_token_store_qt.cpp index 6c4cbc610..853170d56 100644 --- a/src/core/access_token_store_qt.cpp +++ b/src/core/access_token_store_qt.cpp @@ -67,7 +67,7 @@ AccessTokenStoreQt::~AccessTokenStoreQt() { } -void AccessTokenStoreQt::LoadAccessTokens(const LoadAccessTokensCallbackType& callback) +void AccessTokenStoreQt::LoadAccessTokens(const LoadAccessTokensCallback& callback) { BrowserThread::PostTaskAndReply(BrowserThread::UI, FROM_HERE , base::Bind(&AccessTokenStoreQt::performWorkOnUIThread, this) @@ -79,7 +79,7 @@ void AccessTokenStoreQt::performWorkOnUIThread() m_systemRequestContext = WebEngineContext::current()->defaultBrowserContext()->browserContext()->GetRequestContext(); } -void AccessTokenStoreQt::respondOnOriginatingThread(const LoadAccessTokensCallbackType& callback) +void AccessTokenStoreQt::respondOnOriginatingThread(const LoadAccessTokensCallback& callback) { callback.Run(m_accessTokenSet, m_systemRequestContext); m_systemRequestContext = 0; diff --git a/src/core/access_token_store_qt.h b/src/core/access_token_store_qt.h index 0f45fd3a0..973f304c0 100644 --- a/src/core/access_token_store_qt.h +++ b/src/core/access_token_store_qt.h @@ -58,16 +58,16 @@ public: AccessTokenStoreQt(); ~AccessTokenStoreQt(); - virtual void LoadAccessTokens(const LoadAccessTokensCallbackType& request) Q_DECL_OVERRIDE; + virtual void LoadAccessTokens(const LoadAccessTokensCallback& request) Q_DECL_OVERRIDE; virtual void SaveAccessToken(const GURL& serverUrl, const base::string16& accessToken) Q_DECL_OVERRIDE; private: void performWorkOnUIThread(); - void respondOnOriginatingThread(const LoadAccessTokensCallbackType& callback); + void respondOnOriginatingThread(const LoadAccessTokensCallback& callback); net::URLRequestContextGetter *m_systemRequestContext; - AccessTokenSet m_accessTokenSet; + AccessTokenMap m_accessTokenSet; DISALLOW_COPY_AND_ASSIGN(AccessTokenStoreQt); }; diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp index fecbac111..30e6efc2e 100644 --- a/src/core/browser_accessibility_qt.cpp +++ b/src/core/browser_accessibility_qt.cpp @@ -418,7 +418,7 @@ QAccessible::State BrowserAccessibilityQt::state() const state.expanded = true; if (s & (1 << ui::AX_STATE_FOCUSABLE)) state.focusable = true; - if (s & (1 << ui::AX_STATE_FOCUSED)) + if (manager()->GetFocus() == this) state.focused = true; if (s & (1 << ui::AX_STATE_HASPOPUP)) state.hasPopup = true; @@ -480,7 +480,7 @@ QStringList BrowserAccessibilityQt::actionNames() const void BrowserAccessibilityQt::doAction(const QString &actionName) { if (actionName == QAccessibleActionInterface::setFocusAction()) - manager()->SetFocus(this, true); + manager()->SetFocus(*this); } QStringList BrowserAccessibilityQt::keyBindingsForAction(const QString &actionName) const diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp index e3b757587..6563c017f 100644 --- a/src/core/browser_context_adapter.cpp +++ b/src/core/browser_context_adapter.cpp @@ -45,6 +45,7 @@ #include "content_client_qt.h" #include "download_manager_delegate_qt.h" #include "permission_manager_qt.h" +#include "type_conversion.h" #include "web_engine_context.h" #include "web_engine_visited_links_manager.h" #include "url_request_context_getter_qt.h" @@ -78,6 +79,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,6 +92,8 @@ 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() diff --git a/src/core/browser_context_qt.cpp b/src/core/browser_context_qt.cpp index 1c326fb83..7ca1c6477 100644 --- a/src/core/browser_context_qt.cpp +++ b/src/core/browser_context_qt.cpp @@ -56,12 +56,12 @@ #if defined(ENABLE_SPELLCHECK) #include "base/base_paths.h" -#include "base/prefs/pref_member.h" -#include "base/prefs/pref_service.h" -#include "base/prefs/testing_pref_store.h" -#include "base/prefs/pref_service.h" -#include "base/prefs/pref_service_factory.h" -#include "base/prefs/pref_registry_simple.h" +#include "components/prefs/pref_member.h" +#include "components/prefs/pref_service.h" +#include "components/prefs/testing_pref_store.h" +#include "components/prefs/pref_service.h" +#include "components/prefs/pref_service_factory.h" +#include "components/prefs/pref_registry_simple.h" #include "components/user_prefs/user_prefs.h" #include "chrome/common/pref_names.h" #include "chrome/browser/spellchecker/spellcheck_service.h" @@ -75,7 +75,7 @@ BrowserContextQt::BrowserContextQt(BrowserContextAdapter *adapter) m_prefStore(new TestingPrefStore()) { m_prefStore->SetInitializationCompleted(); - base::PrefServiceFactory factory; + PrefServiceFactory factory; factory.set_user_prefs(m_prefStore); scoped_refptr<PrefRegistrySimple> registry(new PrefRegistrySimple()); @@ -122,11 +122,6 @@ net::URLRequestContextGetter *BrowserContextQt::GetRequestContext() return url_request_getter_.get(); } -net::URLRequestContextGetter *BrowserContextQt::GetRequestContextForRenderProcess(int) -{ - return GetRequestContext(); -} - net::URLRequestContextGetter *BrowserContextQt::GetMediaRequestContext() { return GetRequestContext(); @@ -200,6 +195,15 @@ net::URLRequestContextGetter *BrowserContextQt::CreateRequestContext(content::Pr return url_request_getter_.get(); } +net::URLRequestContextGetter *BrowserContextQt::CreateRequestContextForStoragePartition( + const base::FilePath& partition_path, bool in_memory, + content::ProtocolHandlerMap* protocol_handlers, + content::URLRequestInterceptorScopedVector request_interceptors) +{ + Q_UNIMPLEMENTED(); + return nullptr; +} + #if defined(ENABLE_SPELLCHECK) void BrowserContextQt::failedToLoadDictionary(const std::string &language) { diff --git a/src/core/browser_context_qt.h b/src/core/browser_context_qt.h index e2156f147..13f7220bd 100644 --- a/src/core/browser_context_qt.h +++ b/src/core/browser_context_qt.h @@ -74,7 +74,6 @@ public: virtual bool IsOffTheRecord() const Q_DECL_OVERRIDE; virtual net::URLRequestContextGetter *GetRequestContext() Q_DECL_OVERRIDE; - virtual net::URLRequestContextGetter *GetRequestContextForRenderProcess(int) Q_DECL_OVERRIDE; virtual net::URLRequestContextGetter *GetMediaRequestContext() Q_DECL_OVERRIDE; virtual net::URLRequestContextGetter *GetMediaRequestContextForRenderProcess(int) Q_DECL_OVERRIDE; virtual net::URLRequestContextGetter *GetMediaRequestContextForStoragePartition(const base::FilePath&, bool) Q_DECL_OVERRIDE; @@ -84,7 +83,13 @@ public: virtual storage::SpecialStoragePolicy *GetSpecialStoragePolicy() Q_DECL_OVERRIDE; virtual content::PushMessagingService* GetPushMessagingService() Q_DECL_OVERRIDE; virtual content::SSLHostStateDelegate* GetSSLHostStateDelegate() Q_DECL_OVERRIDE; - net::URLRequestContextGetter *CreateRequestContext(content::ProtocolHandlerMap *protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors); + net::URLRequestContextGetter *CreateRequestContext( + content::ProtocolHandlerMap *protocol_handlers, + content::URLRequestInterceptorScopedVector request_interceptors) Q_DECL_OVERRIDE; + net::URLRequestContextGetter* CreateRequestContextForStoragePartition( + const base::FilePath& partition_path, bool in_memory, + content::ProtocolHandlerMap* protocol_handlers, + content::URLRequestInterceptorScopedVector request_interceptors) Q_DECL_OVERRIDE; virtual scoped_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(const base::FilePath& partition_path) Q_DECL_OVERRIDE; virtual content::PermissionManager *GetPermissionManager() Q_DECL_OVERRIDE; virtual content::BackgroundSyncController* GetBackgroundSyncController() Q_DECL_OVERRIDE; @@ -92,7 +97,7 @@ public: BrowserContextAdapter *adapter() { return m_adapter; } #if defined(ENABLE_SPELLCHECK) - void failedToLoadDictionary(const std::string& language) override; + void failedToLoadDictionary(const std::string& language); void setSpellCheckLanguage(const QString &language); QString spellCheckLanguage() const; void setSpellCheckEnabled(bool enabled); diff --git a/src/core/chrome_qt.gyp b/src/core/chrome_qt.gyp index f2d7c5831..394e72733 100644 --- a/src/core/chrome_qt.gyp +++ b/src/core/chrome_qt.gyp @@ -2,8 +2,8 @@ 'variables': { 'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/chrome', 'chrome_spellchecker_sources': [ - '<(DEPTH)/base/prefs/testing_pref_store.cc', - '<(DEPTH)/base/prefs/testing_pref_store.h', + '<(DEPTH)/components/prefs/testing_pref_store.cc', + '<(DEPTH)/components/prefs/testing_pref_store.h', '<(DEPTH)/chrome/browser/spellchecker/feedback.cc', '<(DEPTH)/chrome/browser/spellchecker/feedback.h', '<(DEPTH)/chrome/browser/spellchecker/feedback_sender.cc', @@ -63,6 +63,7 @@ 'type': 'static_library', 'dependencies': [ 'chrome_resources', + '<(chromium_src_dir)/components/components_resources.gyp:components_resources', '<(chromium_src_dir)/components/components_strings.gyp:components_strings', ], 'include_dirs': [ @@ -70,9 +71,6 @@ '<(chromium_src_dir)', '<(chromium_src_dir)/skia/config', '<(chromium_src_dir)/third_party/skia/include/core', - # Needed to include grit-generated files in localized_error.cc: - '<(SHARED_INTERMEDIATE_DIR)/chrome', - '<(SHARED_INTERMEDIATE_DIR)/components/strings', ], 'sources': [ '<(DEPTH)/chrome/browser/media/desktop_media_list.h', @@ -80,8 +78,6 @@ '<(DEPTH)/chrome/browser/media/desktop_streams_registry.h', '<(DEPTH)/chrome/common/chrome_switches.cc', '<(DEPTH)/chrome/common/chrome_switches.h', - '<(DEPTH)/chrome/common/localized_error.cc', - '<(DEPTH)/chrome/common/localized_error.h', ], 'conditions': [ ['enable_spellcheck==1', { @@ -134,7 +130,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/config/common.pri b/src/core/config/common.pri index 5822bc589..01c942976 100644 --- a/src/core/config/common.pri +++ b/src/core/config/common.pri @@ -2,10 +2,10 @@ # Trigger Qt-specific build conditions. GYP_CONFIG += use_qt=1 +# Enable printing. We enable preview because we use preview logic even if we don't support preview. +GYP_CONFIG += enable_basic_printing=1 enable_print_preview=1 # We do not want to ship more external binary blobs, so let v8 embed its startup data. GYP_CONFIG += v8_use_external_startup_data=0 -# Disable printing since we don't support it yet -GYP_CONFIG += enable_basic_printing=1 enable_print_preview=0 # WebSpeech requires Google API keys and adds dependencies on speex and flac. GYP_CONFIG += enable_web_speech=0 # We do not use or even include the extensions diff --git a/src/core/config/embedded_linux.pri b/src/core/config/embedded_linux.pri index 4cb7d89fb..c8f0b82de 100644 --- a/src/core/config/embedded_linux.pri +++ b/src/core/config/embedded_linux.pri @@ -17,7 +17,7 @@ GYP_CONFIG += \ enable_managed_users=0 \ enable_plugin_installation=0 \ enable_plugins=0 \ - enable_printing=0 \ + enable_print_preview=0 \ enable_session_service=0 \ enable_task_manager=0 \ enable_themes=0 \ diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri index 8854a4bdf..fcbdbe27a 100644 --- a/src/core/config/linux.pri +++ b/src/core/config/linux.pri @@ -22,10 +22,14 @@ GYP_CONFIG += \ use_openssl=1 use?(nss) { - GYP_CONFIG += use_nss_certs=1 \ + GYP_CONFIG += \ + use_nss_certs=1 \ + use_nss_verifier=1 \ use_openssl_certs=0 } else { - GYP_CONFIG += use_nss_certs=0 \ + GYP_CONFIG += \ + use_nss_certs=0 \ + use_nss_verifier=0 \ use_openssl_certs=1 } diff --git a/src/core/config/windows.pri b/src/core/config/windows.pri index a99bc5303..ff86aea70 100644 --- a/src/core/config/windows.pri +++ b/src/core/config/windows.pri @@ -56,9 +56,7 @@ msvc:contains(QT_ARCH, "i386"):!usingMSVC32BitCrossCompiler() { } msvc { - equals(MSVC_VER, 12.0) { - MSVS_VERSION = 2013 - } else:equals(MSVC_VER, 14.0) { + equals(MSVC_VER, 14.0) { MSVS_VERSION = 2015 } else { fatal("Visual Studio compiler version \"$$MSVC_VER\" is not supported by Qt WebEngine") @@ -66,7 +64,7 @@ msvc { GYP_ARGS += "-G msvs_version=$$MSVS_VERSION" - isBuildingOnWin32(): GYP_ARGS += "-D windows_sdk_path=\"C:/Program Files/Windows Kits/8.1\"" + isBuildingOnWin32(): GYP_ARGS += "-D windows_sdk_path=\"C:/Program Files/Windows Kits/10\"" } else { fatal("Qt WebEngine for Windows can only be built with the Microsoft Visual Studio C++ compiler") diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index f5f490ccf..8da5e2611 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -244,8 +244,9 @@ public: int PreCreateThreads() Q_DECL_OVERRIDE { base::ThreadRestrictions::SetIOAllowed(true); - // Like ChromeBrowserMainExtraPartsAura::PreCreateThreads does. - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, new DesktopScreenQt); + // Like ChromeBrowserMainExtraPartsViews::PreCreateThreads does. + gfx::Screen::SetScreenInstance(new DesktopScreenQt); + return 0; } @@ -351,7 +352,7 @@ ContentBrowserClientQt *ContentBrowserClientQt::Get() content::BrowserMainParts *ContentBrowserClientQt::CreateBrowserMainParts(const content::MainFunctionParams&) { - m_browserMainParts = new BrowserMainPartsQt; + m_browserMainParts = new BrowserMainPartsQt(); return m_browserMainParts; } @@ -401,11 +402,6 @@ content::AccessTokenStore *ContentBrowserClientQt::CreateAccessTokenStore() return new AccessTokenStoreQt; } -net::URLRequestContextGetter* ContentBrowserClientQt::CreateRequestContext(content::BrowserContext* browser_context, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors) -{ - return static_cast<BrowserContextQt*>(browser_context)->CreateRequestContext(protocol_handlers, std::move(request_interceptors)); -} - content::QuotaPermissionContext *ContentBrowserClientQt::CreateQuotaPermissionContext() { return new QuotaPermissionContextQt; diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h index 1878e3d27..58924eb30 100644 --- a/src/core/content_browser_client_qt.h +++ b/src/core/content_browser_client_qt.h @@ -104,7 +104,6 @@ public: content::CertificateRequestResultType* result) Q_DECL_OVERRIDE; content::LocationProvider* OverrideSystemLocationProvider() Q_DECL_OVERRIDE; content::DevToolsManagerDelegate *GetDevToolsManagerDelegate() Q_DECL_OVERRIDE; - virtual net::URLRequestContextGetter *CreateRequestContext(content::BrowserContext *browser_context, content::ProtocolHandlerMap *protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptorss) Q_DECL_OVERRIDE; virtual std::string GetApplicationLocale() Q_DECL_OVERRIDE; std::string GetAcceptLangs(content::BrowserContext* context) Q_DECL_OVERRIDE; diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp index 0418873be..49c018b23 100644 --- a/src/core/content_client_qt.cpp +++ b/src/core/content_client_qt.cpp @@ -247,11 +247,9 @@ void AddPepperWidevine(std::vector<content::PepperPluginInfo>* plugins) // Add the supported codecs as if they came from the component manifest. std::vector<std::string> codecs; - codecs.push_back(kCdmSupportedCodecVorbis); codecs.push_back(kCdmSupportedCodecVp8); codecs.push_back(kCdmSupportedCodecVp9); #if defined(USE_PROPRIETARY_CODECS) - codecs.push_back(kCdmSupportedCodecAac); codecs.push_back(kCdmSupportedCodecAvc1); #endif // defined(USE_PROPRIETARY_CODECS) std::string codec_string = diff --git a/src/core/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/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp index b181f04e3..ad1aff6d4 100644 --- a/src/core/delegated_frame_node.cpp +++ b/src/core/delegated_frame_node.cpp @@ -620,8 +620,10 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, initAndHoldTexture(uResource, quad->ShouldDrawWithBlending()), initAndHoldTexture(vResource, quad->ShouldDrawWithBlending()), aResource ? initAndHoldTexture(aResource, quad->ShouldDrawWithBlending()) : 0, - toQt(vquad->ya_tex_coord_rect), toQt(vquad->uv_tex_coord_rect), - toQt(vquad->ya_tex_size), toQt(vquad->uv_tex_size), toQt(vquad->color_space)); + toQt(vquad->ya_tex_coord_rect), toQt(vquad->uv_tex_coord_rect), + toQt(vquad->ya_tex_size), toQt(vquad->uv_tex_size), + toQt(vquad->color_space), + vquad->resource_multiplier, vquad->resource_offset); videoNode->setRect(toQt(quad->rect)); currentLayerChain->appendChildNode(videoNode); break; diff --git a/src/core/dev_tools_http_handler_delegate_qt.cpp b/src/core/dev_tools_http_handler_delegate_qt.cpp index f3ffcc86d..0e127d414 100644 --- a/src/core/dev_tools_http_handler_delegate_qt.cpp +++ b/src/core/dev_tools_http_handler_delegate_qt.cpp @@ -50,6 +50,7 @@ #include "base/command_line.h" #include "base/files/file_path.h" +#include "base/memory/ptr_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "components/devtools_discovery/devtools_discovery_manager.h" @@ -178,7 +179,7 @@ DevToolsTargetDescriptor::List DevToolsDiscoveryProviderQt::GetDescriptors() namespace QtWebEngineCore { -scoped_ptr<DevToolsHttpHandler> createDevToolsHttpHandler() +std::unique_ptr<DevToolsHttpHandler> createDevToolsHttpHandler() { DevToolsHttpHandlerDelegateQt *delegate = new DevToolsHttpHandlerDelegateQt(); if (!delegate->isValid()) { @@ -187,9 +188,9 @@ scoped_ptr<DevToolsHttpHandler> createDevToolsHttpHandler() } scoped_ptr<DevToolsHttpHandler::ServerSocketFactory> factory(new TCPServerSocketFactory(delegate->bindAddress().toStdString(), delegate->port(), 1)); // Ownership of the delegate is taken over the devtools http handler. - scoped_ptr<DevToolsHttpHandler> handler(new DevToolsHttpHandler(std::move(factory), std::string(), delegate, base::FilePath(), base::FilePath(), std::string(), std::string())); + std::unique_ptr<DevToolsHttpHandler> handler(new DevToolsHttpHandler(std::move(factory), std::string(), delegate, base::FilePath(), base::FilePath(), std::string(), std::string())); DevToolsDiscoveryManager::GetInstance()->AddProvider(scoped_ptr<DevToolsDiscoveryManager::Provider>(new DevToolsDiscoveryProviderQt())); - return handler; + return std::move(handler); } DevToolsHttpHandlerDelegateQt::DevToolsHttpHandlerDelegateQt() diff --git a/src/core/dev_tools_http_handler_delegate_qt.h b/src/core/dev_tools_http_handler_delegate_qt.h index 96a34a45a..6512146a5 100644 --- a/src/core/dev_tools_http_handler_delegate_qt.h +++ b/src/core/dev_tools_http_handler_delegate_qt.h @@ -56,7 +56,7 @@ class DevToolsHttpHandler; namespace QtWebEngineCore { -scoped_ptr<devtools_http_handler::DevToolsHttpHandler> createDevToolsHttpHandler(); +std::unique_ptr<devtools_http_handler::DevToolsHttpHandler> createDevToolsHttpHandler(); class DevToolsHttpHandlerDelegateQt : public devtools_http_handler::DevToolsHttpHandlerDelegate { public: diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp index f499d853e..3982b9bd1 100644 --- a/src/core/gl_surface_qt.cpp +++ b/src/core/gl_surface_qt.cpp @@ -51,7 +51,7 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" -#include "content/common/gpu/image_transport_surface.h" +#include "gpu/ipc/service/image_transport_surface.h" #include "ui/gl/egl_util.h" #include "ui/gl/gl_context.h" #include "ui/gl/gl_implementation.h" @@ -310,7 +310,7 @@ bool GLSurfaceQtWGL::Initialize() { m_surfaceBuffer = new PbufferGLSurfaceWGL(m_size); - return m_surfaceBuffer->Initialize(); + return m_surfaceBuffer->Initialize(gfx::GLSurface::SURFACE_DEFAULT); } void GLSurfaceQtWGL::Destroy() @@ -635,10 +635,11 @@ std::string DriverEGL::GetPlatformExtensions() } // namespace gfx -namespace content { +namespace gpu { class GpuCommandBufferStub; class GpuChannelManager; -scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface(GpuChannelManager*, GpuCommandBufferStub*, const gfx::GLSurfaceHandle&) +scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface(GpuChannelManager*, GpuCommandBufferStub*, + SurfaceHandle, gfx::GLSurface::Format) { QT_NOT_USED return scoped_refptr<gfx::GLSurface>(); diff --git a/src/core/javascript_dialog_manager_qt.cpp b/src/core/javascript_dialog_manager_qt.cpp index 80a28fb56..2844dba5d 100644 --- a/src/core/javascript_dialog_manager_qt.cpp +++ b/src/core/javascript_dialog_manager_qt.cpp @@ -55,10 +55,8 @@ JavaScriptDialogManagerQt *JavaScriptDialogManagerQt::GetInstance() return base::Singleton<JavaScriptDialogManagerQt>::get(); } -void JavaScriptDialogManagerQt::RunJavaScriptDialog(content::WebContents *webContents, const GURL &originUrl, const std::string &acceptLang, content::JavaScriptMessageType javascriptMessageType, const base::string16 &messageText, const base::string16 &defaultPromptText, const content::JavaScriptDialogManager::DialogClosedCallback &callback, bool *didSuppressMessage) +void JavaScriptDialogManagerQt::RunJavaScriptDialog(content::WebContents *webContents, const GURL &originUrl, content::JavaScriptMessageType javascriptMessageType, const base::string16 &messageText, const base::string16 &defaultPromptText, const content::JavaScriptDialogManager::DialogClosedCallback &callback, bool *didSuppressMessage) { - Q_UNUSED(acceptLang); - WebContentsAdapterClient *client = WebContentsViewQt::from(static_cast<content::WebContentsImpl*>(webContents)->GetView())->client(); if (!client) { if (didSuppressMessage) @@ -70,10 +68,10 @@ void JavaScriptDialogManagerQt::RunJavaScriptDialog(content::WebContents *webCon runDialogForContents(webContents, dialogType, toQt(messageText).toHtmlEscaped(), toQt(defaultPromptText).toHtmlEscaped(), toQt(originUrl.GetOrigin()), callback); } -void JavaScriptDialogManagerQt::RunBeforeUnloadDialog(content::WebContents *webContents, const base::string16 &messageText, - bool isReload, const content::JavaScriptDialogManager::DialogClosedCallback &callback) { +void JavaScriptDialogManagerQt::RunBeforeUnloadDialog(content::WebContents *webContents, bool isReload, + const content::JavaScriptDialogManager::DialogClosedCallback &callback) { Q_UNUSED(isReload); - runDialogForContents(webContents, WebContentsAdapterClient::UnloadDialog, toQt(messageText).toHtmlEscaped(), QString() , QUrl(), callback); + runDialogForContents(webContents, WebContentsAdapterClient::UnloadDialog, QString()/*toQt(messageText).toHtmlEscaped()*/, QString() , QUrl(), callback); } bool JavaScriptDialogManagerQt::HandleJavaScriptDialog(content::WebContents *contents, bool accept, const base::string16 *promptOverride) diff --git a/src/core/javascript_dialog_manager_qt.h b/src/core/javascript_dialog_manager_qt.h index aea5a5ec3..8ed86c994 100644 --- a/src/core/javascript_dialog_manager_qt.h +++ b/src/core/javascript_dialog_manager_qt.h @@ -61,12 +61,12 @@ public: // For use with the Singleton helper class from chromium static JavaScriptDialogManagerQt *GetInstance(); - virtual void RunJavaScriptDialog(content::WebContents *, const GURL &, const std::string &acceptLang, content::JavaScriptMessageType javascriptMessageType, - const base::string16 &messageText, const base::string16 &defaultPromptText, - const content::JavaScriptDialogManager::DialogClosedCallback &callback, bool *didSuppressMessage) Q_DECL_OVERRIDE; + virtual void RunJavaScriptDialog(content::WebContents *, const GURL &, content::JavaScriptMessageType javascriptMessageType, + const base::string16 &messageText, const base::string16 &defaultPromptText, + const content::JavaScriptDialogManager::DialogClosedCallback &callback, bool *didSuppressMessage) Q_DECL_OVERRIDE; - virtual void RunBeforeUnloadDialog(content::WebContents *, const base::string16 &messageText, bool isReload, - const content::JavaScriptDialogManager::DialogClosedCallback &callback) Q_DECL_OVERRIDE; + virtual void RunBeforeUnloadDialog(content::WebContents *, bool isReload, + const content::JavaScriptDialogManager::DialogClosedCallback &callback) Q_DECL_OVERRIDE; virtual bool HandleJavaScriptDialog(content::WebContents *, bool accept, const base::string16 *promptOverride) Q_DECL_OVERRIDE; virtual void CancelActiveAndPendingDialogs(content::WebContents *contents) Q_DECL_OVERRIDE { takeDialogForContents(contents); } virtual void ResetDialogState(content::WebContents *contents) Q_DECL_OVERRIDE { takeDialogForContents(contents); } diff --git a/src/core/network_delegate_qt.cpp b/src/core/network_delegate_qt.cpp index ff0e8320c..c779a4abe 100644 --- a/src/core/network_delegate_qt.cpp +++ b/src/core/network_delegate_qt.cpp @@ -230,14 +230,6 @@ bool NetworkDelegateQt::OnCanSetCookie(const net::URLRequest& request, return m_requestContextGetter->m_cookieDelegate->canSetCookie(toQt(request.first_party_for_cookies()), QByteArray::fromStdString(cookie_line), toQt(request.url())); } -void NetworkDelegateQt::OnResolveProxy(const GURL&, int, const net::ProxyService&, net::ProxyInfo*) -{ -} - -void NetworkDelegateQt::OnProxyFallback(const net::ProxyServer&, int) -{ -} - int NetworkDelegateQt::OnBeforeSendHeaders(net::URLRequest*, const net::CompletionCallback&, net::HttpRequestHeaders*) { return net::OK; diff --git a/src/core/network_delegate_qt.h b/src/core/network_delegate_qt.h index 1324e0da3..9c2351960 100644 --- a/src/core/network_delegate_qt.h +++ b/src/core/network_delegate_qt.h @@ -76,8 +76,6 @@ public: virtual int OnBeforeURLRequest(net::URLRequest* request, const net::CompletionCallback& callback, GURL* newUrl) override; virtual void OnURLRequestDestroyed(net::URLRequest* request) override; virtual bool OnCanSetCookie(const net::URLRequest&, const std::string&, net::CookieOptions*) override; - virtual void OnResolveProxy(const GURL&, int, const net::ProxyService&, net::ProxyInfo*) override; - virtual void OnProxyFallback(const net::ProxyServer&, int) override; virtual int OnBeforeSendHeaders(net::URLRequest*, const net::CompletionCallback&, net::HttpRequestHeaders*) override; virtual void OnBeforeSendProxyHeaders(net::URLRequest*, const net::ProxyInfo&, net::HttpRequestHeaders*) override; virtual void OnSendHeaders(net::URLRequest*, const net::HttpRequestHeaders&) override; diff --git a/src/core/ozone_platform_eglfs.cpp b/src/core/ozone_platform_eglfs.cpp index 6fea4259e..91848d671 100644 --- a/src/core/ozone_platform_eglfs.cpp +++ b/src/core/ozone_platform_eglfs.cpp @@ -42,7 +42,6 @@ #if defined(USE_OZONE) #include "base/bind.h" -#include "media/ozone/media_ozone_platform.h" #include "ui/events/ozone/device/device_manager.h" #include "ui/events/ozone/evdev/event_factory_evdev.h" #include "ui/events/ozone/events_ozone.h" @@ -57,15 +56,6 @@ #include "ui/platform_window/platform_window.h" #include "ui/platform_window/platform_window_delegate.h" - -namespace media { - -MediaOzonePlatform* CreateMediaOzonePlatformEglfs() { - return new MediaOzonePlatform; -} - -} - namespace ui { namespace { @@ -184,11 +174,6 @@ scoped_ptr<ui::NativeDisplayDelegate> OzonePlatformEglfs::CreateNativeDisplayDel return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone()); } -base::ScopedFD OzonePlatformEglfs::OpenClientNativePixmapDevice() const -{ - return base::ScopedFD(); -} - OzonePlatform* CreateOzonePlatformEglfs() { return new OzonePlatformEglfs; } ClientNativePixmapFactory* CreateClientNativePixmapFactoryEglfs() { diff --git a/src/core/ozone_platform_eglfs.h b/src/core/ozone_platform_eglfs.h index 3a2dfbcf0..2ab2298c0 100644 --- a/src/core/ozone_platform_eglfs.h +++ b/src/core/ozone_platform_eglfs.h @@ -65,7 +65,6 @@ class OzonePlatformEglfs : public OzonePlatform { PlatformWindowDelegate* delegate, const gfx::Rect& bounds) override; virtual scoped_ptr<ui::NativeDisplayDelegate> CreateNativeDisplayDelegate() override; - virtual base::ScopedFD OpenClientNativePixmapDevice() const override; virtual ui::InputController* GetInputController() override; virtual scoped_ptr<ui::SystemInputInjector> CreateSystemInputInjector() override; virtual ui::OverlayManagerOzone* GetOverlayManager() override; diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp index 36ce476cd..1be276306 100644 --- a/src/core/permission_manager_qt.cpp +++ b/src/core/permission_manager_qt.cpp @@ -63,6 +63,7 @@ BrowserContextAdapter::PermissionType toQt(content::PermissionType type) case content::PermissionType::DURABLE_STORAGE: case content::PermissionType::AUDIO_CAPTURE: case content::PermissionType::VIDEO_CAPTURE: + case content::PermissionType::BACKGROUND_SYNC: case content::PermissionType::NUM: break; } @@ -83,7 +84,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) { @@ -107,14 +108,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; } @@ -135,25 +134,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); } } @@ -167,21 +164,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( @@ -209,7 +206,7 @@ int PermissionManagerQt::SubscribePermissionStatusChange( content::PermissionType permission, const GURL& requesting_origin, const GURL& /*embedding_origin*/, - const base::Callback<void(content::PermissionStatus)>& callback) + const base::Callback<void(blink::mojom::PermissionStatus)>& callback) { int subscriber_id = ++m_subscriberIdCount; RequestOrSubscription subscriber = { diff --git a/src/core/permission_manager_qt.h b/src/core/permission_manager_qt.h index ff35357d8..e4392b01c 100644 --- a/src/core/permission_manager_qt.h +++ b/src/core/permission_manager_qt.h @@ -64,12 +64,11 @@ public: content::PermissionType permission, content::RenderFrameHost* render_frame_host, const GURL& requesting_origin, - bool user_gesture, - const base::Callback<void(content::PermissionStatus)>& callback) override; + const base::Callback<void(blink::mojom::PermissionStatus)>& callback) override; void CancelPermissionRequest(int request_id) override; - content::PermissionStatus GetPermissionStatus( + blink::mojom::PermissionStatus GetPermissionStatus( content::PermissionType permission, const GURL& requesting_origin, const GURL& embedding_origin) override; @@ -83,9 +82,8 @@ public: const std::vector<content::PermissionType>& permission, content::RenderFrameHost* render_frame_host, const GURL& requesting_origin, - bool user_gesture, const base::Callback<void( - const std::vector<content::PermissionStatus>&)>& callback) override; + const std::vector<blink::mojom::PermissionStatus>&)>& callback) override; void RegisterPermissionUsage( content::PermissionType permission, @@ -96,7 +94,7 @@ public: content::PermissionType permission, const GURL& requesting_origin, const GURL& embedding_origin, - const base::Callback<void(content::PermissionStatus)>& callback) override; + const base::Callback<void(blink::mojom::PermissionStatus)>& callback) override; void UnsubscribePermissionStatusChange(int subscription_id) override; @@ -105,7 +103,7 @@ private: struct RequestOrSubscription { PermissionType type; QUrl origin; - base::Callback<void(content::PermissionStatus)> callback; + base::Callback<void(blink::mojom::PermissionStatus)> callback; }; QHash<int, RequestOrSubscription> m_requests; QHash<int, RequestOrSubscription> m_subscribers; diff --git a/src/core/print_view_manager_base_qt.h b/src/core/print_view_manager_base_qt.h index f1e001eee..5939a2b43 100644 --- a/src/core/print_view_manager_base_qt.h +++ b/src/core/print_view_manager_base_qt.h @@ -42,8 +42,8 @@ #define PRINT_VIEW_MANAGER_BASE_QT_H #include "base/memory/ref_counted.h" -#include "base/prefs/pref_member.h" #include "base/strings/string16.h" +#include "components/prefs/pref_member.h" #include "components/printing/browser/print_manager.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" diff --git a/src/core/print_view_manager_qt.h b/src/core/print_view_manager_qt.h index 88a499f1b..8856a5b2b 100644 --- a/src/core/print_view_manager_qt.h +++ b/src/core/print_view_manager_qt.h @@ -45,8 +45,8 @@ #include <QtWebEngineCore/qtwebenginecoreglobal.h> #include "base/memory/ref_counted.h" -#include "base/prefs/pref_member.h" #include "base/strings/string16.h" +#include "components/prefs/pref_member.h" #include "components/printing/browser/print_manager.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" diff --git a/src/core/printing_message_filter_qt.cpp b/src/core/printing_message_filter_qt.cpp index ba4d5c6e6..3c81896c1 100644 --- a/src/core/printing_message_filter_qt.cpp +++ b/src/core/printing_message_filter_qt.cpp @@ -76,9 +76,6 @@ void PrintingMessageFilterQt::OverrideThreadForMessage( bool PrintingMessageFilterQt::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PrintingMessageFilterQt, message) -#if defined(OS_WIN) - IPC_MESSAGE_HANDLER(PrintHostMsg_DuplicateSection, OnDuplicateSection) -#endif IPC_MESSAGE_HANDLER(PrintHostMsg_IsPrintingEnabled, OnIsPrintingEnabled) IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_GetDefaultPrintSettings, OnGetDefaultPrintSettings) @@ -91,17 +88,6 @@ bool PrintingMessageFilterQt::OnMessageReceived(const IPC::Message& message) { return handled; } -#if defined(OS_WIN) -void PrintingMessageFilterQt::OnDuplicateSection( - base::SharedMemoryHandle renderer_handle, - base::SharedMemoryHandle* browser_handle) { - // Duplicate the handle in this process right now so the memory is kept alive - // (even if it is not mapped) - base::SharedMemory shared_buf(renderer_handle, true, PeerHandle()); - shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), browser_handle); -} -#endif - void PrintingMessageFilterQt::OnIsPrintingEnabled(bool* is_enabled) { DCHECK_CURRENTLY_ON(BrowserThread::IO); *is_enabled = true; diff --git a/src/core/printing_message_filter_qt.h b/src/core/printing_message_filter_qt.h index 95d63f570..156a31250 100644 --- a/src/core/printing_message_filter_qt.h +++ b/src/core/printing_message_filter_qt.h @@ -44,7 +44,7 @@ #include <string> #include "base/compiler_specific.h" -#include "base/prefs/pref_member.h" +#include "components/prefs/pref_member.h" #include "content/public/browser/browser_message_filter.h" #if defined(OS_WIN) @@ -84,12 +84,6 @@ class PrintingMessageFilterQt : public content::BrowserMessageFilter { private: ~PrintingMessageFilterQt() override; -#if defined(OS_WIN) - // Used to pass resulting EMF from renderer to browser in printing. - void OnDuplicateSection(base::SharedMemoryHandle renderer_handle, - base::SharedMemoryHandle* browser_handle); -#endif - // GetPrintSettingsForRenderView must be called via PostTask and // base::Bind. Collapse the settings-specific params into a // struct to avoid running into issues with too many params diff --git a/src/core/qtwebengine.gypi b/src/core/qtwebengine.gypi index 4077431b1..00c65fdd4 100644 --- a/src/core/qtwebengine.gypi +++ b/src/core/qtwebengine.gypi @@ -85,7 +85,8 @@ }, }, 'dependencies': [ - '<(chromium_src_dir)/ui/events/ozone/events_ozone.gyp:events_ozone_evdev' + '<(chromium_src_dir)/ui/events/ozone/events_ozone.gyp:events_ozone_evdev', + '<(chromium_src_dir)/ui/ozone/ozone.gyp:ozone_common', ] }], ['qt_os=="win32" and qt_gl=="opengl"', { diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index a78e3a2c3..d6f88f74f 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -343,8 +343,9 @@ gfx::NativeViewAccessible RenderWidgetHostViewQt::GetNativeViewAccessible() return 0; } -content::BrowserAccessibilityManager* RenderWidgetHostViewQt::CreateBrowserAccessibilityManager(content::BrowserAccessibilityDelegate* delegate) +content::BrowserAccessibilityManager* RenderWidgetHostViewQt::CreateBrowserAccessibilityManager(content::BrowserAccessibilityDelegate* delegate, bool for_root_frame) { + Q_UNUSED(for_root_frame); // FIXME #ifndef QT_NO_ACCESSIBILITY return new content::BrowserAccessibilityManagerQt( m_adapterClient->accessibilityParentObject(), @@ -425,11 +426,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; @@ -839,7 +835,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)); } @@ -974,9 +970,9 @@ void RenderWidgetHostViewQt::handleInputMethodEvent(QInputMethodEvent *ev) } } + gfx::Range replacementRange = (replacementLength > 0) ? gfx::Range(replacementStart, replacementStart + replacementLength) + : gfx::Range::InvalidRange(); if (!commitString.isEmpty()) { - gfx::Range replacementRange = (replacementLength > 0) ? gfx::Range(replacementStart, replacementStart + replacementLength) - : gfx::Range::InvalidRange(); m_host->ImeConfirmComposition(toString16(commitString), replacementRange, false); m_imeInProgress = false; } else if (!preeditString.isEmpty()) { @@ -986,7 +982,7 @@ void RenderWidgetHostViewQt::handleInputMethodEvent(QInputMethodEvent *ev) selectionRange.set_start(newCursorPosition); selectionRange.set_end(newCursorPosition); } - m_host->ImeSetComposition(toString16(preeditString), underlines, selectionRange.start(), selectionRange.end()); + m_host->ImeSetComposition(toString16(preeditString), underlines, replacementRange, selectionRange.start(), selectionRange.end()); m_imeInProgress = true; } } diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h index 8c9e6b9f3..befc86530 100644 --- a/src/core/render_widget_host_view_qt.h +++ b/src/core/render_widget_host_view_qt.h @@ -47,8 +47,8 @@ #include "cc/resources/transferable_resource.h" #include "content/browser/accessibility/browser_accessibility_manager.h" #include "content/browser/renderer_host/render_widget_host_view_base.h" -#include "content/common/gpu/gpu_messages.h" #include "content/common/view_messages.h" +#include "gpu/ipc/common/gpu_messages.h" #include "ui/events/gesture_detection/filtered_gesture_provider.h" #include "qtwebenginecoreglobal_p.h" #include <QMap> @@ -132,7 +132,6 @@ public: virtual void SetBackgroundColor(SkColor color) Q_DECL_OVERRIDE; virtual bool LockMouse() Q_DECL_OVERRIDE; virtual void UnlockMouse() Q_DECL_OVERRIDE; - virtual void MovePluginWindows(const std::vector<content::WebPluginGeometry>&) Q_DECL_OVERRIDE; virtual void UpdateCursor(const content::WebCursor&) Q_DECL_OVERRIDE; virtual void SetIsLoading(bool) Q_DECL_OVERRIDE; virtual void TextInputStateChanged(const ViewHostMsg_TextInputState_Params&) Q_DECL_OVERRIDE; @@ -184,26 +183,14 @@ public: virtual void SetActive(bool active) Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED } virtual bool IsSpeaking() const Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED; return false; } virtual void SpeakSelection() Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED } - virtual bool PostProcessEventForPluginIme(const content::NativeWebKeyboardEvent& event) Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED; return false; } virtual void StopSpeaking() Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED } - virtual void SetWindowVisibility(bool visible) Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED } virtual bool SupportsSpeech() const Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED; return false; } virtual void ShowDefinitionForSelection() Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED } - virtual void WindowFrameChanged() Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED } #endif // defined(OS_MACOSX) -#if defined(OS_WIN) -#if defined(USE_AURA) - virtual void SetParentNativeViewAccessible(gfx::NativeViewAccessible accessible_parent) Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED } - virtual gfx::NativeViewId GetParentForWindowlessPlugin() const Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED return gfx::NativeViewId(); } -#else - virtual void SetClickthroughRegion(SkRegion *) Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED } - virtual void WillWmDestroy(void) Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED } -#endif // defined(USE_AURA) -#endif // defined(OS_WIN) // Overridden from content::BrowserAccessibilityDelegate - virtual content::BrowserAccessibilityManager* CreateBrowserAccessibilityManager(content::BrowserAccessibilityDelegate* delegate) Q_DECL_OVERRIDE; + virtual content::BrowserAccessibilityManager* CreateBrowserAccessibilityManager(content::BrowserAccessibilityDelegate* delegate, bool for_root_frame) Q_DECL_OVERRIDE; #ifndef QT_NO_ACCESSIBILITY virtual void accessibilityActiveChanged(bool active) Q_DECL_OVERRIDE; #endif // QT_NO_ACCESSIBILITY diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index 5d1780cbe..97b0f1dca 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -43,13 +43,13 @@ #include "base/strings/string_split.h" #include "base/strings/utf_string_conversions.h" -#include "chrome/common/localized_error.h" #if defined(ENABLE_SPELLCHECK) #include "chrome/renderer/spellchecker/spellcheck.h" #include "chrome/renderer/spellchecker/spellcheck_provider.h" #endif #include "components/cdm/renderer/widevine_key_systems.h" #include "components/error_page/common/error_page_params.h" +#include "components/error_page/common/localized_error.h" #if defined (ENABLE_BASIC_PRINTING) #include "components/printing/renderer/print_web_view_helper.h" #endif // if defined(ENABLE_BASIC_PRINTING) @@ -76,7 +76,7 @@ #include "renderer/render_view_observer_qt.h" #include "renderer/user_resource_controller.h" -#include "grit/renderer_resources.h" +#include "components/grit/components_resources.h" #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. @@ -85,17 +85,6 @@ namespace QtWebEngineCore { static const char kHttpErrorDomain[] = "http"; static const char kQrcSchemeQt[] = "qrc"; -class RenderProcessObserverQt : public content::RenderProcessObserver { -public: - void WebKitInitialized() override - { - // Can only be done after blink is initialized. - blink::WebString qrcScheme(base::ASCIIToUTF16(kQrcSchemeQt)); - // mark qrc as a secure scheme (avoids deprecation warnings) - blink::WebSecurityPolicy::registerURLSchemeAsSecure(qrcScheme); - } -}; - ContentRendererClientQt::ContentRendererClientQt() { } @@ -109,16 +98,17 @@ void ContentRendererClientQt::RenderThreadStarted() content::RenderThread *renderThread = content::RenderThread::Get(); m_visitedLinkSlave.reset(new visitedlink::VisitedLinkSlave); m_webCacheObserver.reset(new web_cache::WebCacheRenderProcessObserver()); - m_renderProcessObserver.reset(new RenderProcessObserverQt()); renderThread->AddObserver(m_visitedLinkSlave.data()); - renderThread->AddObserver(m_webCacheObserver.data()); renderThread->AddObserver(UserResourceController::instance()); - renderThread->AddObserver(m_renderProcessObserver.data()); #if defined(ENABLE_SPELLCHECK) m_spellCheck.reset(new SpellCheck()); renderThread->AddObserver(m_spellCheck.data()); #endif + + blink::WebString qrcScheme(base::ASCIIToUTF16(kQrcSchemeQt)); + // mark qrc as a secure scheme (avoids deprecation warnings) + blink::WebSecurityPolicy::registerURLSchemeAsSecure(qrcScheme); } void ContentRendererClientQt::RenderViewCreated(content::RenderView* render_view) @@ -144,14 +134,26 @@ void ContentRendererClientQt::RenderFrameCreated(content::RenderFrame* render_fr new QtWebEngineCore::RenderFrameObserverQt(render_frame); } +void ContentRendererClientQt::RunScriptsAtDocumentStart(content::RenderFrame* render_frame) +{ + if (WebChannelIPCTransport *transport = WebChannelIPCTransport::Get(render_frame->GetRenderView())) + transport->RunScriptsAtDocumentStart(render_frame); + UserResourceController::instance()->RunScriptsAtDocumentStart(render_frame); +} + +void ContentRendererClientQt::RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) +{ + UserResourceController::instance()->RunScriptsAtDocumentEnd(render_frame); +} + bool ContentRendererClientQt::HasErrorPage(int httpStatusCode, std::string *errorDomain) { // Use an internal error page, if we have one for the status code. - if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain, httpStatusCode)) { + if (!error_page::LocalizedError::HasStrings(error_page::LocalizedError::kHttpErrorDomain, httpStatusCode)) { return false; } - *errorDomain = LocalizedError::kHttpErrorDomain; + *errorDomain = error_page::LocalizedError::kHttpErrorDomain; return true; } @@ -173,8 +175,9 @@ void ContentRendererClientQt::GetNavigationErrorStrings(content::RenderFrame* re const std::string locale = content::RenderThread::Get()->GetLocale(); // TODO(elproxy): We could potentially get better diagnostics here by first calling // NetErrorHelper::GetErrorStringsForDnsProbe, but that one is harder to untangle. - LocalizedError::GetStrings(error.reason, error.domain.utf8(), error.unreachableURL, isPost - , error.staleCopyInCache && !isPost, false, error_page::OfflinePageStatus::NONE, locale, renderFrame->GetRenderView()->GetAcceptLanguages() + + error_page::LocalizedError::GetStrings(error.reason, error.domain.utf8(), error.unreachableURL, isPost + , error.staleCopyInCache && !isPost, false, false, locale , scoped_ptr<error_page::ErrorPageParams>(), &errorStrings); resourceId = IDR_NET_ERROR_HTML; @@ -187,7 +190,7 @@ void ContentRendererClientQt::GetNavigationErrorStrings(content::RenderFrame* re } if (errorDescription) - *errorDescription = LocalizedError::GetErrorDetails(error.domain.utf8(), error.reason, isPost); + *errorDescription = error_page::LocalizedError::GetErrorDetails(error.domain.utf8(), error.reason, isPost); } unsigned long long ContentRendererClientQt::VisitedLinkHash(const char *canonicalUrl, size_t length) @@ -320,7 +323,7 @@ static void AddPepperBasedWidevine(std::vector<media::KeySystemInfo>* concrete_k #endif // defined(USE_PROPRIETARY_CODECS) cdm::AddWidevineWithCodecs( - cdm::WIDEVINE, supported_codecs, + supported_codecs, media::EmeRobustness::SW_SECURE_CRYPTO, // Maximum audio robustness. media::EmeRobustness::SW_SECURE_DECODE, // Maximum video robustness. media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license. diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h index d475c7801..b17c618c0 100644 --- a/src/core/renderer/content_renderer_client_qt.h +++ b/src/core/renderer/content_renderer_client_qt.h @@ -44,10 +44,6 @@ #include <QtGlobal> #include <QScopedPointer> -namespace content { -class RenderProcessObserver; -} - namespace visitedlink { class VisitedLinkSlave; } @@ -78,10 +74,12 @@ public: virtual bool IsLinkVisited(unsigned long long linkHash) Q_DECL_OVERRIDE; virtual void AddKeySystems(std::vector<media::KeySystemInfo>* key_systems) Q_DECL_OVERRIDE; + virtual void RunScriptsAtDocumentStart(content::RenderFrame* render_frame) Q_DECL_OVERRIDE; + virtual void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) Q_DECL_OVERRIDE; + private: QScopedPointer<visitedlink::VisitedLinkSlave> m_visitedLinkSlave; QScopedPointer<web_cache::WebCacheRenderProcessObserver> m_webCacheObserver; - QScopedPointer<content::RenderProcessObserver> m_renderProcessObserver; #if defined(ENABLE_SPELLCHECK) QScopedPointer<SpellCheck> m_spellCheck; #endif diff --git a/src/core/renderer/pepper/pepper_flash_clipboard_message_filter_qt.cpp b/src/core/renderer/pepper/pepper_flash_clipboard_message_filter_qt.cpp index c1782844d..3202548ae 100644 --- a/src/core/renderer/pepper/pepper_flash_clipboard_message_filter_qt.cpp +++ b/src/core/renderer/pepper/pepper_flash_clipboard_message_filter_qt.cpp @@ -86,10 +86,10 @@ ui::ClipboardType ConvertClipboardType(uint32_t type) // clipboard interface for custom data. bool JumpToFormatInPickle(const base::string16& format, base::PickleIterator* iter) { - size_t size = 0; - if (!iter->ReadSizeT(&size)) + uint32_t size = 0; + if (!iter->ReadUInt32(&size)) return false; - for (size_t i = 0; i < size; ++i) { + for (uint32_t i = 0; i < size; ++i) { base::string16 stored_format; if (!iter->ReadString16(&stored_format)) return false; @@ -121,7 +121,7 @@ std::string ReadDataFromPickle(const base::string16& format, const base::Pickle& bool WriteDataToPickle(const std::map<base::string16, std::string>& data, base::Pickle* pickle) { - pickle->WriteSizeT(data.size()); + pickle->WriteUInt32(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; diff --git a/src/core/renderer/pepper/pepper_host_factory_qt.cpp b/src/core/renderer/pepper/pepper_host_factory_qt.cpp index 9b7236d8a..9aece100c 100644 --- a/src/core/renderer/pepper/pepper_host_factory_qt.cpp +++ b/src/core/renderer/pepper/pepper_host_factory_qt.cpp @@ -44,6 +44,7 @@ #include "pepper_host_factory_qt.h" +#include "base/memory/ptr_util.h" #include "build/build_config.h" #include "content/public/browser/browser_ppapi_host.h" #include "ppapi/host/message_filter_host.h" @@ -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( + return base::WrapUnique(new MessageFilterHost( host_->GetPpapiHost(), instance, resource, clipboard_filter)); } } @@ -101,11 +102,12 @@ scoped_ptr<ppapi::host::ResourceHost> PepperHostFactoryQt::CreateResourceHost(pp if (message.type() == PpapiHostMsg_IsolatedFileSystem_Create::ID) { PepperIsolatedFileSystemMessageFilter* isolated_fs_filter = PepperIsolatedFileSystemMessageFilter::Create(instance, host_); if (!isolated_fs_filter) - return scoped_ptr<ppapi::host::ResourceHost>(); - return scoped_ptr<ppapi::host::ResourceHost>(new MessageFilterHost(host, instance, resource, isolated_fs_filter)); + return nullptr; + return base::WrapUnique( + new MessageFilterHost(host_->GetPpapiHost(), instance, resource, isolated_fs_filter)); } - return scoped_ptr<ppapi::host::ResourceHost>(); + return nullptr; } } // namespace QtWebEngineCore diff --git a/src/core/renderer/pepper/pepper_host_factory_qt.h b/src/core/renderer/pepper/pepper_host_factory_qt.h index e73e097c0..0446cf9e3 100644 --- a/src/core/renderer/pepper/pepper_host_factory_qt.h +++ b/src/core/renderer/pepper/pepper_host_factory_qt.h @@ -57,7 +57,7 @@ public: explicit PepperHostFactoryQt(content::BrowserPpapiHost* host); ~PepperHostFactoryQt() override; - virtual scoped_ptr<ppapi::host::ResourceHost> CreateResourceHost( + virtual std::unique_ptr<ppapi::host::ResourceHost> CreateResourceHost( ppapi::host::PpapiHost* host, PP_Resource resource, PP_Instance instance, diff --git a/src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp b/src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp index 636ca12f1..89f691cef 100644 --- a/src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp +++ b/src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp @@ -44,6 +44,8 @@ #include "pepper_renderer_host_factory_qt.h" #include "pepper_flash_renderer_host_qt.h" + +#include "base/memory/ptr_util.h" #include "content/public/renderer/renderer_ppapi_host.h" #include "ppapi/host/ppapi_host.h" #include "ppapi/host/resource_host.h" @@ -63,7 +65,7 @@ PepperRendererHostFactoryQt::~PepperRendererHostFactoryQt() { } -scoped_ptr<ppapi::host::ResourceHost> PepperRendererHostFactoryQt::CreateResourceHost( +std::unique_ptr<ppapi::host::ResourceHost> PepperRendererHostFactoryQt::CreateResourceHost( ppapi::host::PpapiHost* host, PP_Resource resource, PP_Instance instance, @@ -72,16 +74,14 @@ scoped_ptr<ppapi::host::ResourceHost> PepperRendererHostFactoryQt::CreateResourc DCHECK_EQ(host_->GetPpapiHost(), host); if (!host_->IsValidInstance(instance)) - return scoped_ptr<ppapi::host::ResourceHost>(); + return nullptr; if (host_->GetPpapiHost()->permissions().HasPermission(ppapi::PERMISSION_FLASH) && message.type() == PpapiHostMsg_Flash_Create::ID) - return scoped_ptr<ppapi::host::ResourceHost>( - new PepperFlashRendererHostQt(host_, - instance, - resource)); + return base::WrapUnique( + new PepperFlashRendererHostQt(host_, instance, resource)); - return scoped_ptr<ppapi::host::ResourceHost>(); + return nullptr; } } // QtWebEngineCore diff --git a/src/core/renderer/pepper/pepper_renderer_host_factory_qt.h b/src/core/renderer/pepper/pepper_renderer_host_factory_qt.h index bc472a7c6..ec3440a08 100644 --- a/src/core/renderer/pepper/pepper_renderer_host_factory_qt.h +++ b/src/core/renderer/pepper/pepper_renderer_host_factory_qt.h @@ -56,7 +56,7 @@ public: ~PepperRendererHostFactoryQt(); // HostFactory. - scoped_ptr<ppapi::host::ResourceHost> CreateResourceHost( + std::unique_ptr<ppapi::host::ResourceHost> CreateResourceHost( ppapi::host::PpapiHost* host, PP_Resource resource, PP_Instance instance, diff --git a/src/core/renderer/render_view_observer_qt.cpp b/src/core/renderer/render_view_observer_qt.cpp index 4b44a9bd9..68c0fc08f 100644 --- a/src/core/renderer/render_view_observer_qt.cpp +++ b/src/core/renderer/render_view_observer_qt.cpp @@ -46,6 +46,9 @@ #include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebElement.h" #include "third_party/WebKit/public/web/WebFrame.h" +#include "third_party/WebKit/public/web/WebFrameContentDumper.h" +#include "third_party/WebKit/public/web/WebFrameWidget.h" +#include "third_party/WebKit/public/web/WebLocalFrame.h" #include "third_party/WebKit/public/web/WebView.h" RenderViewObserverQt::RenderViewObserverQt( @@ -58,23 +61,26 @@ RenderViewObserverQt::RenderViewObserverQt( void RenderViewObserverQt::onFetchDocumentMarkup(quint64 requestId) { - Send(new RenderViewObserverHostQt_DidFetchDocumentMarkup( - routing_id(), - requestId, - render_view()->GetWebView()->mainFrame()->contentAsMarkup())); + blink::WebString markup; + if (render_view()->GetWebView()->mainFrame()->isWebLocalFrame()) + markup = blink::WebFrameContentDumper::dumpAsMarkup( + static_cast<blink::WebLocalFrame*>(render_view()->GetWebView()->mainFrame())); + Send(new RenderViewObserverHostQt_DidFetchDocumentMarkup(routing_id(), requestId, markup)); } void RenderViewObserverQt::onFetchDocumentInnerText(quint64 requestId) { - Send(new RenderViewObserverHostQt_DidFetchDocumentInnerText( - routing_id(), - requestId, - render_view()->GetWebView()->mainFrame()->contentAsText(std::numeric_limits<std::size_t>::max()))); + blink::WebString text; + if (render_view()->GetWebView()->mainFrame()->isWebLocalFrame()) + text = blink::WebFrameContentDumper::deprecatedDumpFrameTreeAsText( + static_cast<blink::WebLocalFrame*>(render_view()->GetWebView()->mainFrame()), + std::numeric_limits<std::size_t>::max()); + Send(new RenderViewObserverHostQt_DidFetchDocumentInnerText(routing_id(), requestId, text)); } void RenderViewObserverQt::onSetBackgroundColor(quint32 color) { - render_view()->GetWebView()->setBaseBackgroundColor(color); + render_view()->GetWebFrameWidget()->setBaseBackgroundColor(color); } void RenderViewObserverQt::OnFirstVisuallyNonEmptyLayout() diff --git a/src/core/renderer/user_resource_controller.cpp b/src/core/renderer/user_resource_controller.cpp index 30a04958f..68b5f3d40 100644 --- a/src/core/renderer/user_resource_controller.cpp +++ b/src/core/renderer/user_resource_controller.cpp @@ -39,6 +39,7 @@ #include "user_resource_controller.h" +#include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_view.h" #include "content/public/renderer/render_view_observer.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" @@ -62,7 +63,6 @@ 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,14 +82,20 @@ 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; @@ -101,20 +107,23 @@ void UserResourceController::RenderViewObserverHelper::runScripts(UserScriptData } } +void UserResourceController::RunScriptsAtDocumentStart(content::RenderFrame *render_frame) +{ + runScripts(UserScriptData::DocumentElementCreation, render_frame->GetWebFrame()); +} -UserResourceController::RenderViewObserverHelper::RenderViewObserverHelper(content::RenderView *renderView) - : content::RenderViewObserver(renderView) +void UserResourceController::RunScriptsAtDocumentEnd(content::RenderFrame *render_frame) { + runScripts(UserScriptData::DocumentLoadFinished, render_frame->GetWebFrame()); } -void UserResourceController::RenderViewObserverHelper::DidCreateDocumentElement(blink::WebLocalFrame *frame) +UserResourceController::RenderViewObserverHelper::RenderViewObserverHelper(content::RenderView *renderView) + : content::RenderViewObserver(renderView) { - runScripts(UserScriptData::DocumentElementCreation, frame); } void UserResourceController::RenderViewObserverHelper::DidFinishDocumentLoad(blink::WebLocalFrame *frame) { - runScripts(UserScriptData::DocumentLoadFinished, frame); m_pendingFrames.insert(frame); base::MessageLoop::current()->PostDelayedTask(FROM_HERE, base::Bind(&UserResourceController::RenderViewObserverHelper::runScripts, base::Unretained(this), UserScriptData::AfterLoad, frame), diff --git a/src/core/renderer/user_resource_controller.h b/src/core/renderer/user_resource_controller.h index bd3d0ba49..8eba12abc 100644 --- a/src/core/renderer/user_resource_controller.h +++ b/src/core/renderer/user_resource_controller.h @@ -48,11 +48,15 @@ #include <QtCore/QHash> #include <QtCore/QSet> +namespace blink { +class WebLocalFrame; +} + namespace content { +class RenderFrame; class RenderView; } - class UserResourceController : public content::RenderProcessObserver { public: @@ -64,22 +68,29 @@ public: void removeScriptForView(const UserScriptData &, content::RenderView *); void clearScriptsForView(content::RenderView *); + void RunScriptsAtDocumentStart(content::RenderFrame *render_frame); + void RunScriptsAtDocumentEnd(content::RenderFrame *render_frame); + private: Q_DISABLE_COPY(UserResourceController) class RenderViewObserverHelper; // RenderProcessObserver implementation. - virtual bool OnControlMessageReceived(const IPC::Message &message) Q_DECL_OVERRIDE; + bool OnControlMessageReceived(const IPC::Message &message) override; void onAddScript(const UserScriptData &); void onRemoveScript(const UserScriptData &); void onClearScripts(); + void runScripts(UserScriptData::InjectionPoint, blink::WebLocalFrame *); + typedef QSet<uint64_t> UserScriptSet; typedef QHash<const content::RenderView *, UserScriptSet> ViewUserScriptMap; ViewUserScriptMap m_viewUserScriptMap; QHash<uint64_t, UserScriptData> m_scripts; + + friend class RenderViewObserverHelper; }; #endif // USER_RESOURCE_CONTROLLER_H diff --git a/src/core/renderer/web_channel_ipc_transport.cpp b/src/core/renderer/web_channel_ipc_transport.cpp index d1e5f2245..f965c2cc7 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,26 @@ content::RenderView *WebChannelTransport::GetRenderView(v8::Isolate *isolate) WebChannelIPCTransport::WebChannelIPCTransport(content::RenderView *renderView) : content::RenderViewObserver(renderView) + , content::RenderViewObserverTracker<WebChannelIPCTransport>(renderView) + , m_worldId(0) + , m_installed(false) { } +void WebChannelIPCTransport::RunScriptsAtDocumentStart(content::RenderFrame *render_frame) +{ + // JavaScript run before this point doesn't stick, and needs to be redone. + // ### FIXME: we should try no even installing before + blink::WebLocalFrame *frame = render_frame->GetWebFrame(); + if (m_installed && render_frame->IsMainFrame()) + WebChannelTransport::Install(frame, m_worldId); +} + + void WebChannelIPCTransport::installWebChannel(uint worldId) { + m_worldId = worldId; + m_installed = true; blink::WebView *webView = render_view()->GetWebView(); if (!webView) return; @@ -166,6 +182,8 @@ void WebChannelIPCTransport::installWebChannel(uint worldId) void WebChannelIPCTransport::uninstallWebChannel(uint worldId) { + Q_ASSERT(worldId = m_worldId); + m_installed = false; blink::WebView *webView = render_view()->GetWebView(); if (!webView) return; diff --git a/src/core/renderer/web_channel_ipc_transport.h b/src/core/renderer/web_channel_ipc_transport.h index f799f47af..81e64bb0f 100644 --- a/src/core/renderer/web_channel_ipc_transport.h +++ b/src/core/renderer/web_channel_ipc_transport.h @@ -42,23 +42,35 @@ #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 bool OnMessageReceived(const IPC::Message &message) Q_DECL_OVERRIDE; + + uint m_worldId; + bool m_installed; }; } // namespace diff --git a/src/core/resource_bundle_qt.cpp b/src/core/resource_bundle_qt.cpp index 2a482c52d..5872e778a 100644 --- a/src/core/resource_bundle_qt.cpp +++ b/src/core/resource_bundle_qt.cpp @@ -53,7 +53,7 @@ void ResourceBundle::LoadCommonResources() AddDataPackFromPath(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. diff --git a/src/core/resources/resources.gyp b/src/core/resources/resources.gyp index 88c5bb4be..7c22c8d9f 100644 --- a/src/core/resources/resources.gyp +++ b/src/core/resources/resources.gyp @@ -17,6 +17,7 @@ '<(chromium_src_dir)/content/app/strings/content_strings.gyp:content_strings', '<(chromium_src_dir)/blink/public/blink_resources.gyp:blink_resources', '<(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', '../chrome_qt.gyp:chrome_resources', ], @@ -30,6 +31,7 @@ 'variables': { 'pak_inputs': [ '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak', + '<(SHARED_INTERMEDIATE_DIR)/components/components_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/content/content_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/blink_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/ui/resources/webui_resources.pak', @@ -45,6 +47,7 @@ 'variables': { 'pak_inputs': [ '<(SHARED_INTERMEDIATE_DIR)/ui/resources/ui_resources_100_percent.pak', + '<(SHARED_INTERMEDIATE_DIR)/components/components_resources_100_percent.pak', '<(SHARED_INTERMEDIATE_DIR)/content/app/resources/content_resources_100_percent.pak', '<(SHARED_INTERMEDIATE_DIR)/chrome/renderer_resources_100_percent.pak', '<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/blink_image_resources_100_percent.pak', @@ -60,6 +63,7 @@ 'variables': { 'pak_inputs': [ '<(SHARED_INTERMEDIATE_DIR)/ui/resources/ui_resources_200_percent.pak', + '<(SHARED_INTERMEDIATE_DIR)/components/components_resources_200_percent.pak', '<(SHARED_INTERMEDIATE_DIR)/content/app/resources/content_resources_200_percent.pak', '<(SHARED_INTERMEDIATE_DIR)/chrome/renderer_resources_200_percent.pak', '<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/blink_image_resources_200_percent.pak', diff --git a/src/core/type_conversion.cpp b/src/core/type_conversion.cpp index ef220b86c..a7b5ee831 100644 --- a/src/core/type_conversion.cpp +++ b/src/core/type_conversion.cpp @@ -50,6 +50,8 @@ QImage toQImage(const SkBitmap &bitmap) QImage image; switch (bitmap.colorType()) { case kUnknown_SkColorType: + case kRGBA_F16_SkColorType: + qWarning("Unknown or unsupported skia image format"); break; case kAlpha_8_SkColorType: image = toQImage(bitmap, QImage::Format_Alpha8); diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp index 579e33b66..5fb324b6c 100644 --- a/src/core/url_request_context_getter_qt.cpp +++ b/src/core/url_request_context_getter_qt.cpp @@ -280,7 +280,7 @@ void URLRequestContextGetterQt::generateCookieStore() m_storage->set_cookie_store(0); m_cookieDelegate->setCookieMonster(0); - net::CookieStore* cookieStore = 0; + scoped_ptr<net::CookieStore> cookieStore; switch (m_persistentCookiesPolicy) { case BrowserContextAdapter::NoPersistentCookies: cookieStore = @@ -310,10 +310,12 @@ void URLRequestContextGetterQt::generateCookieStore() ); break; } - m_storage->set_cookie_store(cookieStore); - net::CookieMonster * const cookieMonster = cookieStore->GetCookieMonster(); - cookieMonster->SetCookieableSchemes(kCookieableSchemes, arraysize(kCookieableSchemes)); + net::CookieMonster * const cookieMonster = static_cast<net::CookieMonster*>(cookieStore.get()); + m_storage->set_cookie_store(std::move(cookieStore)); + + const std::vector<std::string> cookieableSchemes(kCookieableSchemes, kCookieableSchemes + arraysize(kCookieableSchemes)); + cookieMonster->SetCookieableSchemes(cookieableSchemes); m_cookieDelegate->setCookieMonster(cookieMonster); } @@ -395,8 +397,6 @@ static bool doNetworkSessionParamsMatch(const net::HttpNetworkSession::Params &f return false; if (first.http_auth_handler_factory != second.http_auth_handler_factory) return false; - if (first.network_delegate != second.network_delegate) - return false; if (first.http_server_properties.get() != second.http_server_properties.get()) return false; if (first.ignore_certificate_errors != second.ignore_certificate_errors) @@ -419,7 +419,6 @@ net::HttpNetworkSession::Params URLRequestContextGetterQt::generateNetworkSessio network_session_params.proxy_service = m_urlRequestContext->proxy_service(); network_session_params.ssl_config_service = m_urlRequestContext->ssl_config_service(); network_session_params.http_auth_handler_factory = m_urlRequestContext->http_auth_handler_factory(); - network_session_params.network_delegate = m_networkDelegate.get(); network_session_params.http_server_properties = m_urlRequestContext->http_server_properties(); network_session_params.ignore_certificate_errors = m_ignoreCertificateErrors; network_session_params.host_resolver = m_urlRequestContext->host_resolver(); diff --git a/src/core/url_request_context_getter_qt.h b/src/core/url_request_context_getter_qt.h index eca956ea6..b4bd3fdfe 100644 --- a/src/core/url_request_context_getter_qt.h +++ b/src/core/url_request_context_getter_qt.h @@ -46,6 +46,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/single_thread_task_runner.h" +#include "content/public/browser/browser_context.h" #include "content/public/browser/content_browser_client.h" #include "content/public/common/url_constants.h" #include "net/http/http_network_session.h" @@ -116,12 +117,12 @@ private: content::ProtocolHandlerMap m_protocolHandlers; QAtomicPointer<net::ProxyConfigService> m_proxyConfigService; - scoped_ptr<net::URLRequestContext> m_urlRequestContext; - scoped_ptr<NetworkDelegateQt> m_networkDelegate; - scoped_ptr<net::URLRequestContextStorage> m_storage; - scoped_ptr<net::URLRequestJobFactory> m_jobFactory; + std::unique_ptr<net::URLRequestContext> m_urlRequestContext; + std::unique_ptr<NetworkDelegateQt> m_networkDelegate; + std::unique_ptr<net::URLRequestContextStorage> m_storage; + std::unique_ptr<net::URLRequestJobFactory> m_jobFactory; net::URLRequestJobFactoryImpl *m_baseJobFactory; - scoped_ptr<net::DhcpProxyScriptFetcherFactory> m_dhcpProxyScriptFetcherFactory; + std::unique_ptr<net::DhcpProxyScriptFetcherFactory> m_dhcpProxyScriptFetcherFactory; scoped_refptr<CookieMonsterDelegateQt> m_cookieDelegate; content::URLRequestInterceptorScopedVector m_requestInterceptors; scoped_ptr<net::HttpNetworkSession> m_httpNetworkSession; diff --git a/src/core/web_channel_ipc_transport_host.h b/src/core/web_channel_ipc_transport_host.h index 9c499ad78..51adcb95f 100644 --- a/src/core/web_channel_ipc_transport_host.h +++ b/src/core/web_channel_ipc_transport_host.h @@ -59,7 +59,7 @@ public: virtual ~WebChannelIPCTransportHost(); // QWebChannelAbstractTransport - virtual void sendMessage(const QJsonObject &message) Q_DECL_OVERRIDE; + void sendMessage(const QJsonObject &message) Q_DECL_OVERRIDE; void setWorldId(uint worldId); uint worldId() const { return m_worldId; } diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 260efc081..15125b9d8 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -482,7 +482,7 @@ void WebContentsAdapter::reload() void WebContentsAdapter::reloadAndBypassCache() { Q_D(WebContentsAdapter); - d->webContents->GetController().ReloadIgnoringCache(/*checkRepost = */false); + d->webContents->GetController().ReloadBypassingCache(/*checkRepost = */false); d->webContents->Focus(); } @@ -519,7 +519,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; } @@ -913,13 +913,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() diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index e6deaa409..73ad5a9ac 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" diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 6da80e94d..c3d12a5ce 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -279,6 +279,9 @@ WebEngineContext::WebEngineContext() parsedCommandLine->AppendSwitch(switches::kDisableZeroCopy); parsedCommandLine->AppendSwitch(switches::kDisableGpuMemoryBufferCompositorResources); + // Enabled on OS X and Linux but currently not working. It worked in 5.7 on OS X. + parsedCommandLine->AppendSwitch(switches::kDisableGpuMemoryBufferVideoFrames); + if (useEmbeddedSwitches) { // Inspired by the Android port's default switches parsedCommandLine->AppendSwitch(switches::kEnableOverlayScrollbar); diff --git a/src/core/yuv_video_node.cpp b/src/core/yuv_video_node.cpp index f8290878b..16e52575d 100644 --- a/src/core/yuv_video_node.cpp +++ b/src/core/yuv_video_node.cpp @@ -283,8 +283,19 @@ void YUVVideoMaterialShader::updateState(const RenderState &state, QSGMaterial * break; } - program()->setUniformValue(m_id_yuvMatrix, QMatrix3x3(yuv_to_rgb)); - program()->setUniformValue(m_id_yuvAdjust, QVector3D(yuv_adjust[0], yuv_adjust[1], yuv_adjust[2])); + float yuv_to_rgb_multiplied[9]; + float yuv_adjust_with_offset[3]; + + for (int i = 0; i < 9; ++i) + yuv_to_rgb_multiplied[i] = yuv_to_rgb[i] * mat->m_resourceMultiplier; + + for (int i = 0; i < 3; ++i) + yuv_adjust_with_offset[i] = + yuv_adjust[i] / mat->m_resourceMultiplier - mat->m_resourceOffset; + + + program()->setUniformValue(m_id_yuvMatrix, QMatrix3x3(yuv_to_rgb_multiplied)); + program()->setUniformValue(m_id_yuvAdjust, QVector3D(yuv_adjust_with_offset[0], yuv_adjust_with_offset[1], yuv_adjust_with_offset[2])); if (state.isOpacityDirty()) program()->setUniformValue(m_id_opacity, state.opacity()); @@ -312,7 +323,8 @@ void YUVAVideoMaterialShader::updateState(const RenderState &state, QSGMaterial YUVVideoMaterial::YUVVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize, - YUVVideoMaterial::ColorSpace colorspace) + YUVVideoMaterial::ColorSpace colorspace, + float rMul, float rOff) : m_yTexture(yTexture) , m_uTexture(uTexture) , m_vTexture(vTexture) @@ -321,6 +333,8 @@ YUVVideoMaterial::YUVVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, Q , m_yaTexSize(yaTexSize) , m_uvTexSize(uvTexSize) , m_colorSpace(colorspace) + , m_resourceMultiplier(rMul) + , m_resourceOffset(rOff) { } @@ -341,8 +355,9 @@ int YUVVideoMaterial::compare(const QSGMaterial *other) const YUVAVideoMaterial::YUVAVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, QSGTexture *aTexture, const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize, - YUVVideoMaterial::ColorSpace colorspace) - : YUVVideoMaterial(yTexture, uTexture, vTexture, yaTexCoordRect, uvTexCoordRect, yaTexSize, uvTexSize, colorspace) + YUVVideoMaterial::ColorSpace colorspace, + float rMul, float rOff) + : YUVVideoMaterial(yTexture, uTexture, vTexture, yaTexCoordRect, uvTexCoordRect, yaTexSize, uvTexSize, colorspace, rMul, rOff) , m_aTexture(aTexture) { setFlag(Blending, aTexture); @@ -363,15 +378,15 @@ int YUVAVideoMaterial::compare(const QSGMaterial *other) const YUVVideoNode::YUVVideoNode(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, QSGTexture *aTexture, const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize, - YUVVideoMaterial::ColorSpace colorspace) + YUVVideoMaterial::ColorSpace colorspace, float rMul, float rOff) : m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4) { setGeometry(&m_geometry); setFlag(QSGNode::OwnsMaterial); if (aTexture) - m_material = new YUVAVideoMaterial(yTexture, uTexture, vTexture, aTexture, yaTexCoordRect, uvTexCoordRect, yaTexSize, uvTexSize, colorspace); + m_material = new YUVAVideoMaterial(yTexture, uTexture, vTexture, aTexture, yaTexCoordRect, uvTexCoordRect, yaTexSize, uvTexSize, colorspace, rMul, rOff); else - m_material = new YUVVideoMaterial(yTexture, uTexture, vTexture, yaTexCoordRect, uvTexCoordRect, yaTexSize, uvTexSize, colorspace); + m_material = new YUVVideoMaterial(yTexture, uTexture, vTexture, yaTexCoordRect, uvTexCoordRect, yaTexSize, uvTexSize, colorspace, rMul, rOff); setMaterial(m_material); } diff --git a/src/core/yuv_video_node.h b/src/core/yuv_video_node.h index cce204fd3..670ec62b6 100644 --- a/src/core/yuv_video_node.h +++ b/src/core/yuv_video_node.h @@ -60,7 +60,7 @@ public: }; YUVVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize, - ColorSpace colorspace); + ColorSpace colorspace, float rMul, float rOff); virtual QSGMaterialType *type() const Q_DECL_OVERRIDE { @@ -79,7 +79,8 @@ public: QSizeF m_yaTexSize; QSizeF m_uvTexSize; ColorSpace m_colorSpace; - + float m_resourceMultiplier; + float m_resourceOffset; }; class YUVAVideoMaterial : public YUVVideoMaterial @@ -87,7 +88,7 @@ class YUVAVideoMaterial : public YUVVideoMaterial public: YUVAVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, QSGTexture *aTexture, const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize, - ColorSpace colorspace); + ColorSpace colorspace, float rMul, float rOff); virtual QSGMaterialType *type() const Q_DECL_OVERRIDE { @@ -106,7 +107,7 @@ class YUVVideoNode : public QSGGeometryNode public: YUVVideoNode(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, QSGTexture *aTexture, const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize, - YUVVideoMaterial::ColorSpace colorspace); + YUVVideoMaterial::ColorSpace colorspace, float rMul, float rOff); void setRect(const QRectF &rect); private: diff --git a/tests/auto/quick/qmltests/data/forms.html b/tests/auto/quick/qmltests/data/forms.html index 8dc3472f2..d137c98f0 100644 --- a/tests/auto/quick/qmltests/data/forms.html +++ b/tests/auto/quick/qmltests/data/forms.html @@ -19,10 +19,6 @@ <input type="url" value="invalid" required/> <input type="submit" name="url_invalid"/> </form> - <form> - <input type="url" value="invalid" title="url_title" required/> - <input type="submit" name="url_title"/> - </form> <form> <input type="email" required/> @@ -32,9 +28,5 @@ <input type="email" value="invalid" required/> <input type="submit" name="email_invalid"/> </form> - <form> - <input type="email" value="invalid" title="email_title" required/> - <input type="submit" name="email_title"/> - </form> </body> </html> diff --git a/tests/auto/quick/qmltests/data/tst_formValidation.qml b/tests/auto/quick/qmltests/data/tst_formValidation.qml index 6da8af7ff..f8d6c4e15 100644 --- a/tests/auto/quick/qmltests/data/tst_formValidation.qml +++ b/tests/auto/quick/qmltests/data/tst_formValidation.qml @@ -71,15 +71,6 @@ TestWebEngineView { keyPress(Qt.Key_Enter) showSpy.wait() compare(showSpy.signalArguments[1][0], "Please enter a URL.") - - webEngineView.url = Qt.resolvedUrl("about:blank") - verify(webEngineView.waitForLoadSucceeded()) - - webEngineView.url = Qt.resolvedUrl("forms.html#url_title") - verify(webEngineView.waitForLoadSucceeded()) - keyPress(Qt.Key_Enter) - showSpy.wait() - compare(showSpy.signalArguments[2][1], "url_title") } function test_emailForm() { @@ -97,15 +88,6 @@ TestWebEngineView { keyPress(Qt.Key_Enter) showSpy.wait() compare(showSpy.signalArguments[1][0], "Please include an '@' in the email address. 'invalid' is missing an '@'.") - - webEngineView.url = Qt.resolvedUrl("about:blank") - verify(webEngineView.waitForLoadSucceeded()) - - webEngineView.url = Qt.resolvedUrl("forms.html#email_title") - verify(webEngineView.waitForLoadSucceeded()) - keyPress(Qt.Key_Enter) - showSpy.wait() - compare(showSpy.signalArguments[2][1], "email_title") } } } diff --git a/tests/auto/quick/qquickwebengineview/BLACKLIST b/tests/auto/quick/qquickwebengineview/BLACKLIST index d4d5c9844..2cde59454 100644 --- a/tests/auto/quick/qquickwebengineview/BLACKLIST +++ b/tests/auto/quick/qquickwebengineview/BLACKLIST @@ -1,2 +1,5 @@ [transparentWebEngineViews] windows + +[inputEventForwardingDisabledWhenActiveFocusOnPressDisabled] +* diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index dbaa63f86..e50692226 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -153,7 +153,6 @@ private Q_SLOTS: void inputMethods(); void inputMethodsTextFormat_data(); void inputMethodsTextFormat(); - void defaultTextEncoding(); void errorPageExtension(); void errorPageExtensionLoadFinished(); void userAgentNewlineStripping(); @@ -180,7 +179,6 @@ private Q_SLOTS: // [Qt] tst_QWebEnginePage::infiniteLoopJS() timeouts with DFG JIT // https://bugs.webkit.org/show_bug.cgi?id=79040 // void infiniteLoopJS(); - void navigatorCookieEnabled(); void deleteQWebEngineViewTwice(); void renderOnRepaintRequestedShouldNotRecurse(); void loadSignalsOrder_data(); @@ -410,7 +408,7 @@ void tst_QWebEnginePage::geolocationRequestJS() newPage, SLOT(requestPermission(const QUrl&, QWebEnginePage::Feature))); QSignalSpy spyLoadFinished(newPage, SIGNAL(loadFinished(bool))); - newPage->setHtml(QString("<html><body>test</body></html>"), QUrl()); + newPage->setHtml(QString("<html><body>test</body></html>"), QUrl("qrc://secure/origin")); QTRY_COMPARE(spyLoadFinished.count(), 1); if (evaluateJavaScriptSync(newPage, QLatin1String("!navigator.geolocation")).toBool()) { delete view; @@ -2636,30 +2634,6 @@ void tst_QWebEnginePage::testEnablePersistentStorage() #endif } -void tst_QWebEnginePage::defaultTextEncoding() -{ - QString defaultCharset = evaluateJavaScriptSync(m_page, "document.defaultCharset").toString(); - QVERIFY(!defaultCharset.isEmpty()); - QCOMPARE(QWebEngineSettings::globalSettings()->defaultTextEncoding(), defaultCharset); - - m_page->settings()->setDefaultTextEncoding(QString("utf-8")); - QCoreApplication::processEvents(); - QString charset = evaluateJavaScriptSync(m_page, "document.defaultCharset").toString(); - QCOMPARE(charset, QString("utf-8")); - QCOMPARE(m_page->settings()->defaultTextEncoding(), charset); - - m_page->settings()->setDefaultTextEncoding(QString()); - QCoreApplication::processEvents(); - charset = evaluateJavaScriptSync(m_page, "document.defaultCharset").toString(); - QVERIFY(!charset.isEmpty()); - QCOMPARE(charset, defaultCharset); - - QWebEngineSettings::globalSettings()->setDefaultTextEncoding(QString("utf-8")); - QCoreApplication::processEvents(); - charset = evaluateJavaScriptSync(m_page, "document.defaultCharset").toString(); - QCOMPARE(charset, QString("utf-8")); - QCOMPARE(QWebEngineSettings::globalSettings()->defaultTextEncoding(), charset); -} #if defined(QWEBENGINEPAGE_ERRORPAGEEXTENSION) class ErrorPage : public QWebEnginePage @@ -3094,22 +3068,6 @@ void tst_QWebEnginePage::supportedContentType() #endif } - -void tst_QWebEnginePage::navigatorCookieEnabled() -{ -#if !defined(QWEBENGINEPAGE_NETWORKACCESSMANAGER) - QSKIP("QWEBENGINEPAGE_NETWORKACCESSMANAGER"); -#else - m_page->networkAccessManager()->setCookieJar(0); - QVERIFY(!m_page->networkAccessManager()->cookieJar()); - QVERIFY(!evaluateJavaScriptSync(m_page, "navigator.cookieEnabled").toBool()); - - m_page->networkAccessManager()->setCookieJar(new QNetworkCookieJar()); - QVERIFY(m_page->networkAccessManager()->cookieJar()); - QVERIFY(evaluateJavaScriptSync(m_page, "navigator.cookieEnabled").toBool()); -#endif -} - void tst_QWebEnginePage::thirdPartyCookiePolicy() { #if !defined(DUMPRENDERTREESUPPORTQT) diff --git a/tools/qmake/mkspecs/features/functions.prf b/tools/qmake/mkspecs/features/functions.prf index 9e8886e86..ed6fa289b 100644 --- a/tools/qmake/mkspecs/features/functions.prf +++ b/tools/qmake/mkspecs/features/functions.prf @@ -11,12 +11,12 @@ defineTest(isPlatformSupported) { return(false) } msvc { - !equals(MSVC_VER, "12.0"):!equals(MSVC_VER, "14.0") { - skipBuild("Qt WebEngine on Windows requires MSVC 2013 or MSVC 2015.") + !equals(MSVC_VER, "14.0") { + skipBuild("Qt WebEngine on Windows requires MSVC 2015 Update 2 or later.") return(false) } } else { - skipBuild("Qt WebEngine on Windows requires MSVC 2013 or MSVC 2015.") + skipBuild("Qt WebEngine on Windows requires MSVC 2015 Update 2 or later.") return(false) } isBuildingOnWin32() { diff --git a/tools/scripts/take_snapshot.py b/tools/scripts/take_snapshot.py index 25b3dc15e..e270a9b60 100755 --- a/tools/scripts/take_snapshot.py +++ b/tools/scripts/take_snapshot.py @@ -92,8 +92,10 @@ def isInChromiumBlacklist(file_path): not 'media/desktop_media_list.h' in file_path and not 'media/desktop_streams_registry.' in file_path and not 'common/chrome_switches.' in file_path and - not 'common/localized_error.' in file_path and + not 'common/content_restriction.h' in file_path and not 'common/spellcheck_' in file_path and + not '/renderer_host/pepper/' in file_path and + not '/renderer/pepper/' in file_path and not '/spellchecker/' in file_path and not '/tools/convert_dict/' in file_path and not file_path.endswith('cf_resources.rc') and @@ -105,47 +107,41 @@ def isInChromiumBlacklist(file_path): or file_path.startswith('chrome_frame') or file_path.startswith('chromeos') or file_path.startswith('cloud_print') - or (file_path.startswith('components') and - not file_path.startswith('components/cdm') and - not file_path.startswith('components/device_event_log') and - not file_path.startswith('components/devtools_') and - not file_path.startswith('components/error_page') and - not file_path.startswith('components/keyed_service') and - not file_path.startswith('components/mime_util') and - not file_path.startswith('components/precache') and - not file_path.startswith('components/pref_registry') and - not file_path.startswith('components/printing') and - not file_path.startswith('components/resources') and - not file_path.startswith('components/scheduler') and - not file_path.startswith('components/security_interstitials') and - not file_path.startswith('components/startup_metric_utils') and - not file_path.startswith('components/strings') and - not file_path.startswith('components/tracing') and - not file_path.startswith('components/url_formatter') and - not file_path.startswith('components/user_prefs') and - not file_path.startswith('components/version_') and - not file_path.startswith('components/visitedlink') and - not file_path.startswith('components/web_cache') and - not file_path.startswith('components/webcrypto') and - not file_path.startswith('components/webusb') and - not file_path.endswith('.grd') and - not file_path.endswith('.grdp') and - not 'components_strings' in file_path) + or file_path.startswith('components/chrome_apps/') + or file_path.startswith('components/cronet/') + or file_path.startswith('components/drive/') + or file_path.startswith('components/invalidation/') + or file_path.startswith('components/gcm_driver/') + or file_path.startswith('components/google/') + or file_path.startswith('components/metrics/') + or file_path.startswith('components/mus/') + or file_path.startswith('components/nacl/') + or file_path.startswith('components/omnibox/') + or file_path.startswith('components/policy/') + or file_path.startswith('components/proximity_auth/') + or (file_path.startswith('components/resources/terms/') and not file_path.endswith('terms_chromium.html')) + or file_path.startswith('components/rlz/') + or file_path.startswith('components/sync_driver/') + or file_path.startswith('components/test/') + or file_path.startswith('components/test_runner/') + or file_path.startswith('components/translate/') + or file_path.startswith('components/variations/') or file_path.startswith('content/public/android/java') or (file_path.startswith('content/shell') and - not file_path.startswith('content/shell/common')) + not file_path.startswith('content/shell/common') and + not file_path.endswith('.grd')) or file_path.startswith('courgette') or (file_path.startswith('extensions') and not 'browser/extension_function_registry.h' in file_path and not 'browser/extension_function_histogram_value.h' in file_path and - not 'browser/notification_types.cc' in file_path and - not 'browser/notification_types.h' in file_path) + not 'browser/notification_types.' in file_path and + not 'common/constants.' in file_path and + not 'common/url_pattern.' in file_path) or file_path.startswith('google_update') or file_path.startswith('ios') or file_path.startswith('media/base/android/java') or file_path.startswith('native_client') or file_path.startswith('net/android/java') - or file_path.startswith('pdf') or file_path.startswith('remoting') or file_path.startswith('rlz') or file_path.startswith('sync') @@ -195,32 +191,23 @@ def isInChromiumBlacklist(file_path): or (file_path.startswith('third_party/polymer') and not file_path.startswith('third_party/polymer/v1_0/components-chromium/')) or file_path.startswith('third_party/openh264/src/res') + or file_path.startswith('third_party/pdfium/tools') + or file_path.startswith('third_party/pdfium/third_party') or file_path.startswith('third_party/pdfsqueeze') or file_path.startswith('third_party/pefile') or file_path.startswith('third_party/perl') - or file_path.startswith('third_party/pdfium') or file_path.startswith('third_party/psyco_win32') or file_path.startswith('third_party/scons-2.0.1') or file_path.startswith('third_party/sfntly/src/cpp/data/fonts') or file_path.startswith('third_party/trace-viewer') or file_path.startswith('third_party/undoview') or file_path.startswith('third_party/webgl') + or file_path.startswith('tools/android') + or file_path.startswith('tools/luci_go') + or file_path.startswith('tools/metrics') or file_path.startswith('tools/memory_inspector') - or (file_path.startswith('tools') and - not file_path.startswith('tools/clang') and - not file_path.startswith('tools/compile_test') and - not file_path.startswith('tools/generate_library_loader') and - not file_path.startswith('tools/generate_shim_headers') and - not file_path.startswith('tools/generate_stubs') and - not file_path.startswith('tools/grit') and - not file_path.startswith('tools/gyp') and - not file_path.startswith('tools/json_comment_eater') and - not file_path.startswith('tools/json_schema_compiler') and - not file_path.startswith('tools/idl_parser') and - not file_path.startswith('tools/memory') and - not file_path.startswith('tools/msan') and - not file_path.startswith('tools/protoc_wrapper') and - not file_path.startswith('tools/ubsan')) + or file_path.startswith('tools/perf') + or file_path.startswith('tools/swarming_client') or file_path.startswith('ui/android/java') or file_path.startswith('ui/app_list') or file_path.startswith('ui/base/ime/chromeos') diff --git a/tools/scripts/version_resolver.py b/tools/scripts/version_resolver.py index 6029bbdc9..e58c647de 100644 --- a/tools/scripts/version_resolver.py +++ b/tools/scripts/version_resolver.py @@ -38,8 +38,8 @@ import json import urllib2 import git_submodule as GitSubmodule -chromium_version = '49.0.2623.111' -chromium_branch = '2623' +chromium_version = '51.0.2704.79' +chromium_branch = '2704' ninja_version = 'v1.6.0' json_url = 'http://omahaproxy.appspot.com/all.json' diff --git a/tools/scripts/windeploy-examples.py b/tools/scripts/windeploy-examples.py new file mode 100755 index 000000000..c41a5bc31 --- /dev/null +++ b/tools/scripts/windeploy-examples.py @@ -0,0 +1,393 @@ +#!/usr/bin/env python + +############################################################################# +# +# Copyright (C) 2015 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 2.1 as published by the Free Software +# Foundation and appearing in the file LICENSE.LGPL included in the +# packaging of this file. Please review the following information to +# ensure the GNU Lesser General Public License version 2.1 requirements +# will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +# +# As a special exception, The Qt Company gives you certain additional +# rights. These rights are described in The Qt Company LGPL Exception +# version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +# +# GNU General Public License Usage +# Alternatively, this file may be used under the terms of the GNU +# General Public License version 3.0 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 3.0 requirements will be +# met: http://www.gnu.org/copyleft/gpl.html. +# +# +# $QT_END_LICENSE$ +# +############################################################################# + +import argparse +import os +import re +import subprocess +import shutil +import sys + + +class Api: + QUICK = "webengine" + WIDGET = "webenginewidgets" + + +class Mode: + RELEASE = "release" + DEBUG = "debug" + + +def is_windows(): + return os.name == "nt" + + +class ArgManager(object): + def __init__(self): + try: + self.__args = self.__parse() + except: + raise + + self.build_dir = self.__args.build_dir + self.src_dir = self.__args.src_dir + self.example_filter = re.compile("%s-%s-%s" % (self.__api_filter(), self.__name_filter(), self.__mode_filter())) + self.list_examples = self.__args.list_examples + self.force = self.__args.force + self.verbose = self.__args.verbose + self.out_dir = self.__args.out_dir + + def __parse(self): + ap = argparse.ArgumentParser(description="Deploy QtWebEngine example binaries on Windows.") + ap.add_argument("--release", dest="release", action="store_true", default=False, + help="Deploy release binaries only") + ap.add_argument("--debug", dest="debug", action="store_true", default=False, + help="Deploy debug binaries only") + ap.add_argument("--quick", dest="quick", action="store_true", default=False, + help="Deploy quick examples only") + ap.add_argument("--widget", dest="widget", action="store_true", default=False, + help="Deploy widget examples only") + ap.add_argument("-e", "--examples", dest="examples", nargs="+", action="store", default=".*", + help="Select example to deploy") + ap.add_argument("-l", "--list-examples", dest="list_examples", action="store_true", default=False, + help="List available examples") + ap.add_argument("-f", "--force", dest="force", action="store_true", default=False, + help="Force to overwrite existing files") + ap.add_argument("-v", "--verbose", dest="verbose", action="store_true", default=False, + help="Print windeployqt output") + ap.add_argument("--src-dir", dest="src_dir", action="store", type=self.__validate_src_dir, default=None, + help="Specify path of Qt sources. It is used for finding QML files of the example" + "and scanning for QML imports") + ap.add_argument("--build-dir", dest="build_dir", action="store", type=self.__validate_build_dir, default=None, + help="Specify path of the Qt binaries. It is used for finding qmake.exe, windeployqt.exe and" + "binaries of the examples. It is not necessary to set if qmake.exe is set in the path") + ap.add_argument("-o", "--out-dir", dest="out_dir", action="store", default=os.getcwd(), + help="Specify path for the deployed examples. If it is not set" + "current working directory is used") + return ap.parse_args() + + def __validate_src_dir(self, src_dir): + if not os.path.exists(src_dir): + raise OSError("The specified Qt source directory does not exist: %s" % src_dir) + + qtwebengine_dir = src_dir + # Accept Qt top level source directory too + if os.path.exists(os.path.join(src_dir, "qtwebengine")): + qtwebengine_dir = os.path.join(src_dir, "qtwebengine") + + examples_dir = os.path.join(qtwebengine_dir, "examples") + must_have_paths = [ + os.path.join(examples_dir, "examples.pro"), + os.path.join(examples_dir, Api.QUICK), + os.path.join(examples_dir, Api.WIDGET), + ] + + # Check whether src_dir is the proper QtWebEngine source directory + for p in must_have_paths: + if not os.path.exists(p): + raise OSError("The specified Qt source directory is invalid: %s" % src_dir) + + return src_dir + + def __validate_build_dir(self, build_dir): + if not os.path.exists(build_dir): + raise OSError("The specified Qt build directory does not exist: %s" % build_dir) + + # Accept QtWebEngine build directory too + if os.path.basename(build_dir) == "qtwebengine": + build_dir = os.path.abspath(os.path.join(build_dir, "..")) + + # Attempt to support custom build directories + if os.path.exists(os.path.join(build_dir, "bin", "qmake.exe")): + return build_dir + + # Check existence of qtbase/bin/qmake.exe + qtbase_dir = os.path.join(build_dir, "qtbase") + if not os.path.exists(os.path.join(qtbase_dir, "bin", "qmake.exe")): + raise OSError("Program 'qmake.exe' cannot be found in the specified Qt build directory: %s" % build_dir) + + return qtbase_dir + + def __mode_filter(self): + if self.__args.release and not self.__args.debug: + return Mode.RELEASE + if not self.__args.release and self.__args.debug: + return Mode.DEBUG + return ".*" + + def __api_filter(self): + if self.__args.quick and not self.__args.widget: + return Api.QUICK + if not self.__args.quick and self.__args.widget: + return Api.WIDGET + return ".*" + + def __name_filter(self): + alt_list = [] + + examples = self.__args.examples + if not isinstance(examples, list): + examples = [examples] + + for e in examples: + if "," in e: + alt_list.extend(e.split(",")) + else: + alt_list.append(e) + + return "|".join(alt_list) + + +class QtHelper(object): + def __init__(self, build_path=None, src_path=None): + self.__build_path = build_path if build_path is not None else "" + self.__src_path = src_path if src_path is not None else "" + self.__query = {} + self.__angle = None + + self.__qmake = "qmake.exe" + self.__windeployqt = "windeployqt.exe" + if build_path: + self.__qmake = os.path.join(self.__build_path, "bin", self.__qmake) + self.__windeployqt = os.path.join(self.__build_path, "bin", self.__windeployqt) + + try: + program = self.__qmake + subprocess.check_output([program, "-v"]) + program = self.__windeployqt + subprocess.check_output([program, "-h"]) + except OSError as e: + raise OSError("Program '%s' cannot be executed\n%s" % (program, e)) + except: + raise + + self.__query = self.get_query() + self.__build_path = self.get_build_path() + self.__src_path = self.get_src_path() + self.__angle = self.has_angle() + + def get_query(self): + if self.__query: + return self.__query + + qmake_output = subprocess.check_output([self.__qmake, "-query"]).split("\r\n") + query = {} + for line in qmake_output: + entry = line.split(":", 1) + if len(entry) != 2: + continue + query[entry[0]] = entry[1] + return query + + def get_build_path(self): + return os.path.abspath(os.path.join(self.__query["QT_INSTALL_PREFIX"], "..")) + + def get_src_path(self): + if self.__src_path: + return self.__src_path + + if "QT_INSTALL_PREFIX/src" in self.__query: + return os.path.abspath(os.path.join(self.__query["QT_INSTALL_PREFIX/src"], "..")) + + return self.__build_path + + def get_windeployqt(self): + return self.__windeployqt + + def has_angle(self): + if self.__angle: + return self.__angle + + qconfig_pri_path = os.path.abspath(os.path.join(self.__query["QT_HOST_PREFIX"], "mkspecs", "qconfig.pri")) + print(qconfig_pri_path) + if not os.path.exists(qconfig_pri_path): + sys.stderr.write("Configuration file qconfig.pri cannot be found. Fallback to desktop GL mode.\n") + return False + + qt_config = [] + + qconfig_pri = open(qconfig_pri_path, "r") + for line in qconfig_pri: + if line.startswith("QT_CONFIG +="): + qt_config = re.match("^QT_CONFIG \+= (.+)$", line).group(1).split(" ") + qconfig_pri.close() + + return "angle" in qt_config + + def collect_examples(self): + examples = [] + + for api in [Api.QUICK, Api.WIDGET]: + examples_root_dir_path = os.path.join(self.__build_path, "qtwebengine", "examples", api) + if not os.path.exists(examples_root_dir_path): + continue + + for example in os.listdir(examples_root_dir_path): + example_dir_path = os.path.join(examples_root_dir_path, example) + if not os.path.exists(example_dir_path): + continue + + example_src_path = os.path.join(self.__src_path, "qtwebengine", "examples", api, example) + + for mode in [Mode.RELEASE, Mode.DEBUG]: + example_exe_path = os.path.join(example_dir_path, mode, example + ".exe") + if not os.path.exists(example_exe_path): + continue + examples.append(Example(example, api, mode, self.__angle, example_exe_path, example_src_path)) + + return examples + + +class Example(str): + def __new__(cls, example, api, mode, angle, exe_path, src_path): + obj = str.__new__(cls, "%s-%s-%s" % (api, example, mode)) + return obj + + def __init__(self, example, api, mode, angle, exe_path, src_path): + super(Example, self).__init__("%s-%s-%s" % (api, example, mode)) + self.__name = example + self.__api = api + self.__mode = mode + self.__angle = angle + self.__exe_path = exe_path + self.__src_path = src_path + + def get_deploy_params(self, mode, force): + deploy_params = [] + deploy_params.append("--%s" % mode) + deploy_params.append("--compiler-runtime") + + if self.__angle: + deploy_params.append("--angle") + + if force: + deploy_params.append("--force") + + if self.__api is Api.QUICK: + deploy_params.append("--qmldir") + deploy_params.append(self.__src_path) + + if self.__mode is Mode.DEBUG: + deploy_params.append("--pdb") + + return deploy_params + + def name(self): + return self.__name + + def deploy(self, qt, dest_path, force=False, verbose=False): + src_path = os.path.dirname(self.__exe_path) + for f in os.listdir(src_path): + shutil.copy(os.path.join(src_path, f), dest_path) + + deploy_command = [] + deploy_command.append(qt.get_windeployqt()) + # Debug executables also need the release libraries + deploy_command.extend(self.get_deploy_params(Mode.RELEASE, force)) + deploy_command.append(dest_path) + + if verbose: + print("%s" % " ".join(deploy_command)) + + out = None if verbose else open(os.devnull, "w") + exit_code = subprocess.call(deploy_command, stdout=out) + + if self.__mode is Mode.DEBUG and not exit_code: + param_release = "--%s" % Mode.RELEASE + param_debug = "--%s" % Mode.DEBUG + deploy_command = map(lambda item: param_debug if item == param_release else item, deploy_command) + + if verbose: + print("%s" % " ".join(deploy_command)) + + exit_code = subprocess.call(deploy_command, stdout=out) + + if out is not None: + out.close() + + return exit_code + + +def main(): + try: + args = ArgManager() + + if not is_windows(): + raise OSError("This script works on Windows only\n") + + qt = QtHelper(args.build_dir, args.src_dir) + except Exception as e: + sys.stderr.write(str(e)) + exit(1) + + example_list = filter((lambda e: args.example_filter.match(e)), qt.collect_examples()) + if not example_list: + print("There is no example that fulfills the requirements") + return + + for example in example_list: + if args.list_examples: + print(example.name()) + continue + + print("Deploying %s ..." % example.name()) + dest_path = os.path.abspath(os.path.join(args.out_dir, example.name())) + if not os.path.exists(dest_path): + os.makedirs(dest_path) + elif os.listdir(dest_path) and not args.force: + sys.stderr.write("Destination directory is not empty: %s\n" % dest_path) + sys.stderr.write("Skip deploying %s\n" % example.name()) + continue + + exit_code = example.deploy(qt, dest_path, args.force, args.verbose) + if exit_code: + sys.stderr.write("Deploy of example '%s' has failed: %s\n" % (example.name(), exit_code)) + exit(exit_code) + + print("Example '%s' has been successfully deployed at %s" % (example.name(), dest_path)) + + return + +if __name__ == "__main__": + main() |