summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/api/qwebenginepage.cpp22
-rw-r--r--src/core/api/qwebenginepage_p.h3
-rw-r--r--src/core/content_browser_client_qt.cpp23
-rw-r--r--src/core/content_browser_client_qt.h2
-rw-r--r--src/core/content_main_delegate_qt.cpp4
-rw-r--r--src/core/net/cookie_monster_delegate_qt.cpp2
-rw-r--r--src/core/net/proxying_restricted_cookie_manager_qt.cpp2
-rw-r--r--src/core/net/proxying_url_loader_factory_qt.cpp2
-rw-r--r--src/core/permission_manager_qt.cpp7
-rw-r--r--src/core/permission_manager_qt.h8
-rw-r--r--src/core/profile_adapter.cpp31
-rw-r--r--src/core/profile_adapter.h1
-rw-r--r--src/core/profile_io_data_qt.cpp3
-rw-r--r--src/core/renderer/content_renderer_client_qt.cpp3
-rw-r--r--src/core/resource_bundle_qt.cpp2
-rw-r--r--src/core/web_contents_adapter.cpp6
-rw-r--r--src/core/web_contents_adapter_client.h3
-rw-r--r--src/core/web_contents_delegate_qt.cpp121
-rw-r--r--src/core/web_contents_delegate_qt.h22
-rw-r--r--src/core/web_engine_library_info.cpp10
-rw-r--r--src/core/web_engine_library_info.h1
21 files changed, 143 insertions, 135 deletions
diff --git a/src/core/api/qwebenginepage.cpp b/src/core/api/qwebenginepage.cpp
index c168ca93e..367688c88 100644
--- a/src/core/api/qwebenginepage.cpp
+++ b/src/core/api/qwebenginepage.cpp
@@ -305,28 +305,20 @@ void QWebEnginePagePrivate::loadStarted(const QUrl &provisionalUrl, bool isError
QTimer::singleShot(0, q, &QWebEnginePage::loadStarted);
}
-void QWebEnginePagePrivate::loadFinished(bool success, const QUrl &url, bool isErrorPage, int errorCode,
- const QString &errorDescription, bool triggersErrorPage)
+void QWebEnginePagePrivate::loadFinished(bool success, const QUrl &url, bool isErrorPage, int errorCode, const QString &errorDescription)
{
Q_Q(QWebEnginePage);
Q_UNUSED(url);
Q_UNUSED(errorCode);
Q_UNUSED(errorDescription);
- if (isErrorPage) {
- QTimer::singleShot(0, q, [q](){
- emit q->loadFinished(false);
- });
+ if (isErrorPage)
return;
- }
isLoading = false;
- Q_ASSERT((success && !triggersErrorPage) || !success);
- if (!triggersErrorPage) {
- QTimer::singleShot(0, q, [q, success](){
- emit q->loadFinished(success);
- });
- }
+ QTimer::singleShot(0, q, [q, success](){
+ emit q->loadFinished(success);
+ });
}
void QWebEnginePagePrivate::didPrintPageToPdf(const QString &filePath, bool success)
@@ -2293,6 +2285,10 @@ void QWebEnginePage::printToPdf(const QWebEngineCallback<const QByteArray&> &res
during page destruction. When QWebEnginePage is deleted, the callback is triggered with an invalid
value and it is not safe to use the corresponding QWebEnginePage or QWebEngineView instance inside it.
+ \note This function rasterizes the result when rendering onto \a printer. Please consider raising
+ the default resolution of \a printer to at least 300 DPI or using printToPdf() to produce
+ PDF file output more effectively.
+
\since 5.8
*/
void QWebEnginePage::print(QPrinter *printer, const QWebEngineCallback<bool> &resultCallback)
diff --git a/src/core/api/qwebenginepage_p.h b/src/core/api/qwebenginepage_p.h
index 1f8087c59..081287889 100644
--- a/src/core/api/qwebenginepage_p.h
+++ b/src/core/api/qwebenginepage_p.h
@@ -134,8 +134,7 @@ public:
void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) override;
void loadCommitted() override { }
void didFirstVisuallyNonEmptyPaint() override { }
- void loadFinished(bool success, const QUrl &url, bool isErrorPage, int errorCode,
- const QString &errorDescription, bool triggersErrorPage) override;
+ void loadFinished(bool success, const QUrl &url, bool isErrorPage, int errorCode, const QString &errorDescription) override;
void focusContainer() override;
void unhandledKeyEvent(QKeyEvent *event) override;
QSharedPointer<QtWebEngineCore::WebContentsAdapter>
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index 1b8ba26e8..d68cad2b0 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -39,6 +39,7 @@
#include "content_browser_client_qt.h"
+#include "base/files/file_util.h"
#include "base/optional.h"
#include "base/task/post_task.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
@@ -348,12 +349,7 @@ std::unique_ptr<net::ClientCertStore> ContentBrowserClientQt::CreateClientCertSt
std::string ContentBrowserClientQt::GetApplicationLocale()
{
- std::string bcp47Name = QLocale().bcp47Name().toStdString();
- if (m_cachedQtLocale != bcp47Name) {
- m_cachedQtLocale = bcp47Name;
- m_appLocale = WebEngineLibraryInfo::getApplicationLocale();
- }
- return m_appLocale;
+ return WebEngineLibraryInfo::getApplicationLocale();
}
std::string ContentBrowserClientQt::GetAcceptLangs(content::BrowserContext *context)
@@ -369,7 +365,7 @@ void ContentBrowserClientQt::AppendExtraCommandLineSwitches(base::CommandLine* c
std::string processType = command_line->GetSwitchValueASCII(switches::kProcessType);
if (processType == switches::kZygoteProcess)
- command_line->AppendSwitchASCII(switches::kLang, GetApplicationLocale());
+ command_line->AppendSwitchASCII(switches::kLang, WebEngineLibraryInfo::getApplicationLocale());
}
void ContentBrowserClientQt::GetAdditionalWebUISchemes(std::vector<std::string>* additional_schemes)
@@ -397,9 +393,8 @@ void ContentBrowserClientQt::GetAdditionalAllowedSchemesForFileSystem(std::vecto
#if defined(Q_OS_LINUX)
void ContentBrowserClientQt::GetAdditionalMappedFilesForChildProcess(const base::CommandLine& command_line, int child_process_id, content::PosixFileDescriptorInfo* mappings)
{
- const std::string &locale = GetApplicationLocale();
- const base::FilePath &locale_file_path = ui::ResourceBundle::GetSharedInstance().GetLocaleFilePath(locale);
- if (locale_file_path.empty())
+ const base::FilePath &locale_file_path = ui::ResourceBundle::GetSharedInstance().GetLocaleFilePath(WebEngineLibraryInfo::getResolvedLocale());
+ if (locale_file_path.empty() || !base::PathExists(locale_file_path))
return;
// Open pak file of the current locale in the Browser process and pass its file descriptor to the sandboxed
@@ -852,7 +847,13 @@ static bool navigationThrottleCallback(content::WebContents *source,
WebContentsViewQt::from(static_cast<content::WebContentsImpl *>(source)->GetView())->client();
if (!client)
return false;
- client->navigationRequested(pageTransitionToNavigationType(params.transition_type()),
+
+ // Redirects might not be reflected in transition_type at this point (see also chrome/.../web_navigation_api_helpers.cc)
+ auto transition_type = params.transition_type();
+ if (params.is_redirect())
+ transition_type = ui::PageTransitionFromInt(transition_type | ui::PAGE_TRANSITION_SERVER_REDIRECT);
+
+ client->navigationRequested(pageTransitionToNavigationType(transition_type),
toQt(params.url()),
navigationRequestAction,
params.is_main_frame());
diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h
index a5fcc64ef..bac155c8c 100644
--- a/src/core/content_browser_client_qt.h
+++ b/src/core/content_browser_client_qt.h
@@ -263,8 +263,6 @@ public:
private:
scoped_refptr<ShareGroupQt> m_shareGroupQt;
- std::string m_appLocale;
- std::string m_cachedQtLocale;
};
} // namespace QtWebEngineCore
diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp
index a8e8b7c8a..62d033f00 100644
--- a/src/core/content_main_delegate_qt.cpp
+++ b/src/core/content_main_delegate_qt.cpp
@@ -179,7 +179,9 @@ void ContentMainDelegateQt::PreSandboxStartup()
#endif
net::NetModule::SetResourceProvider(PlatformResourceProvider);
- ui::ResourceBundle::InitSharedInstanceWithLocale(WebEngineLibraryInfo::getApplicationLocale(), nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES);
+
+ base::i18n::SetICUDefaultLocale(WebEngineLibraryInfo::getApplicationLocale());
+ ui::ResourceBundle::InitSharedInstanceWithLocale(WebEngineLibraryInfo::getResolvedLocale(), nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES);
base::CommandLine* parsedCommandLine = base::CommandLine::ForCurrentProcess();
logging::LoggingSettings settings;
diff --git a/src/core/net/cookie_monster_delegate_qt.cpp b/src/core/net/cookie_monster_delegate_qt.cpp
index 792d34373..6d72a622b 100644
--- a/src/core/net/cookie_monster_delegate_qt.cpp
+++ b/src/core/net/cookie_monster_delegate_qt.cpp
@@ -80,7 +80,7 @@ public:
void AllowedAccess(const GURL &url, const net::SiteForCookies &site_for_cookies, AllowedAccessCallback callback) override
{
- bool allow = m_delegate->canGetCookies(toQt(site_for_cookies.RepresentativeUrl()), toQt(url));
+ bool allow = m_delegate->canGetCookies(toQt(site_for_cookies.first_party_url()), toQt(url));
std::move(callback).Run(allow);
}
diff --git a/src/core/net/proxying_restricted_cookie_manager_qt.cpp b/src/core/net/proxying_restricted_cookie_manager_qt.cpp
index b0d3787de..f86c0e997 100644
--- a/src/core/net/proxying_restricted_cookie_manager_qt.cpp
+++ b/src/core/net/proxying_restricted_cookie_manager_qt.cpp
@@ -197,7 +197,7 @@ bool ProxyingRestrictedCookieManagerQt::allowCookies(const GURL &url, const net:
{
if (!m_profileIoData)
return false;
- return m_profileIoData->canGetCookies(toQt(site_for_cookies.RepresentativeUrl()), toQt(url));
+ return m_profileIoData->canGetCookies(toQt(site_for_cookies.first_party_url()), toQt(url));
}
} // namespace QtWebEngineCore
diff --git a/src/core/net/proxying_url_loader_factory_qt.cpp b/src/core/net/proxying_url_loader_factory_qt.cpp
index bc70928ab..c945ee4d5 100644
--- a/src/core/net/proxying_url_loader_factory_qt.cpp
+++ b/src/core/net/proxying_url_loader_factory_qt.cpp
@@ -267,7 +267,7 @@ void InterceptedRequest::Restart()
if (!top_document_url.is_empty())
firstPartyUrl = toQt(top_document_url);
else
- firstPartyUrl = toQt(request_.site_for_cookies.RepresentativeUrl()); // m_topDocumentUrl can be empty for the main-frame.
+ firstPartyUrl = toQt(request_.site_for_cookies.first_party_url()); // m_topDocumentUrl can be empty for the main-frame.
auto info = new QWebEngineUrlRequestInfoPrivate(resourceType, navigationType, originalUrl, firstPartyUrl,
initiator, QByteArray::fromStdString(request_.method));
diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp
index f476a5aa1..e0a26e012 100644
--- a/src/core/permission_manager_qt.cpp
+++ b/src/core/permission_manager_qt.cpp
@@ -122,7 +122,6 @@ static blink::mojom::PermissionStatus toBlink(ProfileAdapter::PermissionState re
PermissionManagerQt::PermissionManagerQt()
: m_requestIdCount(0)
- , m_subscriberIdCount(0)
{
}
@@ -341,19 +340,19 @@ void PermissionManagerQt::ResetPermission(
m_permissions.remove(key);
}
-int PermissionManagerQt::SubscribePermissionStatusChange(
+content::PermissionControllerDelegate::SubscriptionId PermissionManagerQt::SubscribePermissionStatusChange(
content::PermissionType permission,
content::RenderFrameHost * /* render_frame_host */,
const GURL& requesting_origin,
base::RepeatingCallback<void(blink::mojom::PermissionStatus)> callback)
{
- int subscriber_id = ++m_subscriberIdCount;
+ auto subscriber_id = subscription_id_generator_.GenerateNextId();
m_subscribers.insert( { subscriber_id,
Subscription { toQt(permission), toQt(requesting_origin), std::move(callback) } });
return subscriber_id;
}
-void PermissionManagerQt::UnsubscribePermissionStatusChange(int subscription_id)
+void PermissionManagerQt::UnsubscribePermissionStatusChange(content::PermissionControllerDelegate::SubscriptionId subscription_id)
{
if (!m_subscribers.erase(subscription_id))
LOG(WARNING) << "PermissionManagerQt::UnsubscribePermissionStatusChange called on unknown subscription id" << subscription_id;
diff --git a/src/core/permission_manager_qt.h b/src/core/permission_manager_qt.h
index e046174df..f8d7e0ee3 100644
--- a/src/core/permission_manager_qt.h
+++ b/src/core/permission_manager_qt.h
@@ -89,13 +89,13 @@ public:
base::OnceCallback<void(
const std::vector<blink::mojom::PermissionStatus>&)> callback) override;
- int SubscribePermissionStatusChange(
+ content::PermissionControllerDelegate::SubscriptionId SubscribePermissionStatusChange(
content::PermissionType permission,
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
const base::RepeatingCallback<void(blink::mojom::PermissionStatus)> callback) override;
- void UnsubscribePermissionStatusChange(int subscription_id) override;
+ void UnsubscribePermissionStatusChange(content::PermissionControllerDelegate::SubscriptionId subscription_id) override;
private:
QHash<QPair<QUrl, ProfileAdapter::PermissionType>, bool> m_permissions;
@@ -118,9 +118,9 @@ private:
};
std::vector<Request> m_requests;
std::vector<MultiRequest> m_multiRequests;
- std::map<int, Subscription> m_subscribers;
+ std::map<content::PermissionControllerDelegate::SubscriptionId, Subscription> m_subscribers;
+ content::PermissionControllerDelegate::SubscriptionId::Generator subscription_id_generator_;
int m_requestIdCount;
- int m_subscriberIdCount;
};
diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp
index bc138b7d0..9a6275a84 100644
--- a/src/core/profile_adapter.cpp
+++ b/src/core/profile_adapter.cpp
@@ -87,6 +87,9 @@ inline QString buildLocationFromStandardPath(const QString &standardPath, const
namespace QtWebEngineCore {
+// static
+QPointer<ProfileAdapter> ProfileAdapter::s_profileForGlobalCertificateVerification;
+
ProfileAdapter::ProfileAdapter(const QString &storageName):
m_name(storageName)
, m_offTheRecord(storageName.isEmpty())
@@ -654,26 +657,26 @@ void ProfileAdapter::setUseForGlobalCertificateVerification(bool enable)
if (m_usedForGlobalCertificateVerification == enable)
return;
- static QPointer<ProfileAdapter> profileForglobalCertificateVerification;
-
m_usedForGlobalCertificateVerification = enable;
if (enable) {
- if (profileForglobalCertificateVerification) {
- profileForglobalCertificateVerification->m_usedForGlobalCertificateVerification = false;
- if (!m_profile->m_profileIOData->isClearHttpCacheInProgress())
- profileForglobalCertificateVerification->m_profile->m_profileIOData->resetNetworkContext();
- for (auto *client : qAsConst(profileForglobalCertificateVerification->m_clients))
+ if (s_profileForGlobalCertificateVerification) {
+ s_profileForGlobalCertificateVerification->m_usedForGlobalCertificateVerification = false;
+ for (auto *client : qAsConst(s_profileForGlobalCertificateVerification->m_clients))
client->useForGlobalCertificateVerificationChanged();
+ } else {
+ // OCSP enabled
+ for (auto adapter : qAsConst(WebEngineContext::current()->m_profileAdapters))
+ adapter->m_profile->m_profileIOData->resetNetworkContext();
}
- profileForglobalCertificateVerification = this;
+ s_profileForGlobalCertificateVerification = this;
} else {
- Q_ASSERT(profileForglobalCertificateVerification);
- Q_ASSERT(profileForglobalCertificateVerification == this);
- profileForglobalCertificateVerification = nullptr;
+ Q_ASSERT(s_profileForGlobalCertificateVerification);
+ Q_ASSERT(s_profileForGlobalCertificateVerification == this);
+ s_profileForGlobalCertificateVerification = nullptr;
+ // OCSP disabled
+ for (auto adapter : qAsConst(WebEngineContext::current()->m_profileAdapters))
+ adapter->m_profile->m_profileIOData->resetNetworkContext();
}
-
- if (!m_profile->m_profileIOData->isClearHttpCacheInProgress())
- m_profile->m_profileIOData->resetNetworkContext();
}
bool ProfileAdapter::isUsedForGlobalCertificateVerification() const
diff --git a/src/core/profile_adapter.h b/src/core/profile_adapter.h
index f59768004..e6e9ab7cb 100644
--- a/src/core/profile_adapter.h
+++ b/src/core/profile_adapter.h
@@ -215,6 +215,7 @@ public:
QString determineDownloadPath(const QString &downloadDirectory, const QString &suggestedFilename, const time_t &startTime);
+ static QPointer<ProfileAdapter> s_profileForGlobalCertificateVerification;
private:
void updateCustomUrlSchemeHandlers();
void resetVisitedLinksManager();
diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp
index 68e674f01..8e6c8fed3 100644
--- a/src/core/profile_io_data_qt.cpp
+++ b/src/core/profile_io_data_qt.cpp
@@ -224,6 +224,9 @@ void ProfileIODataQt::ConfigureNetworkContextParams(bool in_memory,
SystemNetworkContextManager::GetInstance()->ConfigureDefaultNetworkContextParams(network_context_params);
+ // FIXME: Faking old behavior to allow not enabling OCSP
+ network_context_params->initial_ssl_config->rev_checking_enabled = !ProfileAdapter::s_profileForGlobalCertificateVerification.isNull();
+
network_context_params->context_name = m_storageName.toStdString();
network_context_params->user_agent = m_httpUserAgent.toStdString();
network_context_params->accept_language = m_httpAcceptLanguage.toStdString();
diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp
index de3a76d78..99e98985b 100644
--- a/src/core/renderer/content_renderer_client_qt.cpp
+++ b/src/core/renderer/content_renderer_client_qt.cpp
@@ -117,6 +117,8 @@
#include "chrome/renderer/media/webrtc_logging_agent_impl.h"
#endif
+#include "web_engine_library_info.h"
+
namespace QtWebEngineCore {
static const char kHttpErrorDomain[] = "http";
@@ -133,6 +135,7 @@ ContentRendererClientQt::~ContentRendererClientQt() {}
void ContentRendererClientQt::RenderThreadStarted()
{
+ base::i18n::SetICUDefaultLocale(WebEngineLibraryInfo::getApplicationLocale());
content::RenderThread *renderThread = content::RenderThread::Get();
m_renderConfiguration.reset(new RenderConfiguration());
m_userResourceController.reset(new UserResourceController());
diff --git a/src/core/resource_bundle_qt.cpp b/src/core/resource_bundle_qt.cpp
index 22622f216..4e814a806 100644
--- a/src/core/resource_bundle_qt.cpp
+++ b/src/core/resource_bundle_qt.cpp
@@ -98,7 +98,7 @@ std::string ResourceBundle::LoadLocaleResources(const std::string &pref_locale,
{
DCHECK(!locale_resources_data_.get()) << "locale.pak already loaded";
- std::string app_locale = l10n_util::GetApplicationLocale(pref_locale);
+ std::string app_locale = l10n_util::GetApplicationLocale(pref_locale, false /* set_icu_locale */);
#if defined(OS_LINUX)
int locale_fd = base::GlobalDescriptors::GetInstance()->MaybeGet(kWebEngineLocale);
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 695ef24c1..f5656f571 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -717,8 +717,7 @@ void WebContentsAdapter::load(const QWebEngineHttpRequest &request)
m_adapterClient->loadFinished(false, request.url(), false,
net::ERR_DISALLOWED_URL_SCHEME,
QCoreApplication::translate("WebContentsAdapter",
- "HTTP-POST data can only be sent over HTTP(S) protocol"),
- false);
+ "HTTP-POST data can only be sent over HTTP(S) protocol"));
return;
}
params.post_data = network::ResourceRequestBody::CreateFromBytes(
@@ -773,7 +772,7 @@ void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeT
GURL dataUrlToLoad(urlString);
if (dataUrlToLoad.spec().size() > url::kMaxURLChars) {
- m_adapterClient->loadFinished(false, baseUrl, false, net::ERR_ABORTED, QString(), false);
+ m_adapterClient->loadFinished(false, baseUrl, false, net::ERR_ABORTED, QString());
return;
}
content::NavigationController::LoadURLParams params((dataUrlToLoad));
@@ -1994,6 +1993,7 @@ void WebContentsAdapter::discard()
if (m_webContents->IsLoading()) {
m_webContentsDelegate->didFailLoad(m_webContentsDelegate->url(webContents()), net::Error::ERR_ABORTED,
QStringLiteral("Discarded"));
+ m_webContentsDelegate->DidStopLoading();
}
content::WebContents::CreateParams createParams(m_profileAdapter->profile());
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index 497b94720..1e2c7bbec 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -195,8 +195,7 @@ public:
virtual void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) = 0;
virtual void loadCommitted() = 0;
virtual void didFirstVisuallyNonEmptyPaint() = 0;
- virtual void loadFinished(bool success, const QUrl &url, bool isErrorPage, int errorCode,
- const QString &errorDescription, bool triggersErrorPage) = 0;
+ virtual void loadFinished(bool success, const QUrl &url, bool isErrorPage, int errorCode, const QString &errorDescription) = 0;
virtual void focusContainer() = 0;
virtual void unhandledKeyEvent(QKeyEvent *event) = 0;
virtual QSharedPointer<WebContentsAdapter>
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index e71e78d3c..5d11f43c3 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -258,14 +258,12 @@ void WebContentsDelegateQt::CloseContents(content::WebContents *source)
void WebContentsDelegateQt::LoadProgressChanged(double progress)
{
- QUrl current_url(m_viewClient->webContentsAdapter()->getNavigationEntryOriginalUrl(m_viewClient->webContentsAdapter()->currentNavigationEntryIndex()));
- int p = qMin(qRound(progress * 100), 100);
-
- if (!m_loadingErrorFrameList.isEmpty() || !m_loadProgressMap.contains(current_url) || m_loadProgressMap[current_url] == 100 || p == 100)
+ if (!m_loadingInfo.isLoading()) // suppress signals that aren't between loadStarted and loadFinished
return;
- if (p > m_loadProgressMap[current_url]) { // ensure strict monotonic increase
- m_loadProgressMap[current_url] = p;
+ int p = qMin(qRound(progress * 100), 100);
+ if (p > m_loadingInfo.progress) { // ensure strict monotonic increase
+ m_loadingInfo.progress = p;
m_viewClient->loadProgressChanged(p);
}
}
@@ -285,11 +283,6 @@ void WebContentsDelegateQt::RenderFrameCreated(content::RenderFrameHost *render_
m_frameFocusedObserver.addNode(node);
}
-void WebContentsDelegateQt::RenderFrameDeleted(content::RenderFrameHost *render_frame_host)
-{
- m_loadingErrorFrameList.removeOne(render_frame_host->GetRoutingID());
-}
-
void WebContentsDelegateQt::RenderProcessGone(base::TerminationStatus status)
{
// RenderProcessHost::FastShutdownIfPossible results in TERMINATION_STATUS_STILL_RUNNING
@@ -339,40 +332,26 @@ void WebContentsDelegateQt::RenderViewHostChanged(content::RenderViewHost *, con
}
}
-void WebContentsDelegateQt::EmitLoadStarted(const QUrl &url, bool isErrorPage)
+void WebContentsDelegateQt::emitLoadStarted(bool isErrorPage)
{
for (auto &&wc : m_certificateErrorControllers)
if (auto controller = wc.lock())
controller->deactivate();
m_certificateErrorControllers.clear();
- m_isDocumentEmpty = true;
- m_viewClient->loadStarted(url, isErrorPage);
- m_viewClient->updateNavigationActions();
-
- if ((url.hasFragment() || m_lastLoadedUrl.hasFragment())
- && url.adjusted(QUrl::RemoveFragment) == m_lastLoadedUrl.adjusted(QUrl::RemoveFragment)
- && !m_isNavigationCommitted) {
- m_loadProgressMap.insert(url, 100);
- m_lastLoadedUrl = url;
- m_viewClient->loadProgressChanged(100);
+ // only report first ever load start or separate one for error page only
+ if (!isErrorPage && m_loadingInfo.isLoading()) // already running
return;
- }
- if (!m_loadProgressMap.isEmpty()) {
- QMap<QUrl, int>::iterator it = m_loadProgressMap.begin();
- while (it != m_loadProgressMap.end()) {
- if (it.value() == 100) {
- it = m_loadProgressMap.erase(it);
- continue;
- }
- ++it;
- }
+ m_isDocumentEmpty = true; // reset to default which may only be overridden on actual resource load complete
+ if (!isErrorPage) {
+ m_loadingInfo.progress = 0;
+ m_viewClient->loadStarted(m_loadingInfo.url, false);
+ m_viewClient->updateNavigationActions();
+ m_viewClient->loadProgressChanged(0);
+ } else {
+ m_viewClient->loadStarted(toQt(GURL(content::kUnreachableWebDataURL)), true);
}
-
- m_lastLoadedUrl = url;
- m_loadProgressMap.insert(url, 0);
- m_viewClient->loadProgressChanged(0);
}
void WebContentsDelegateQt::DidStartNavigation(content::NavigationHandle *navigation_handle)
@@ -380,34 +359,39 @@ void WebContentsDelegateQt::DidStartNavigation(content::NavigationHandle *naviga
if (!webEngineSettings()->testAttribute(QWebEngineSettings::ErrorPageEnabled))
navigation_handle->SetSilentlyIgnoreErrors();
- if (!navigation_handle->IsInMainFrame())
+ if (!navigation_handle->IsInMainFrame() || !web_contents()->IsLoadingToDifferentDocument())
return;
-
- m_loadingErrorFrameList.clear();
m_faviconManager->resetCandidates();
- EmitLoadStarted(toQt(navigation_handle->GetURL()));
+
+ m_loadingInfo.url = toQt(navigation_handle->GetURL());
+ // IsErrorPage is only set after navigation commit, so check it otherwise: error page shouldn't have navigation entry
+ bool isErrorPage = m_loadingInfo.triggersErrorPage && !navigation_handle->GetNavigationEntry();
+ emitLoadStarted(isErrorPage);
}
-void WebContentsDelegateQt::EmitLoadFinished(bool success, const QUrl &url, bool isErrorPage, int errorCode, const QString &errorDescription, bool triggersErrorPage)
+void WebContentsDelegateQt::emitLoadFinished(bool isErrorPage)
{
- Q_ASSERT(!isErrorPage || webEngineSettings()->testAttribute(QWebEngineSettings::ErrorPageEnabled));
- Q_ASSERT((triggersErrorPage && webEngineSettings()->testAttribute(QWebEngineSettings::ErrorPageEnabled)) || !triggersErrorPage);
-
- // When error page enabled we don't need to send the error page load finished signal
- if (m_loadProgressMap[url] == 100)
+ if (!m_loadingInfo.isLoading()) // not currently running
return;
- m_lastLoadedUrl = url;
- m_loadProgressMap[url] = 100;
- m_isNavigationCommitted = false;
- m_viewClient->loadProgressChanged(100);
+ Q_ASSERT(!isErrorPage || webEngineSettings()->testAttribute(QWebEngineSettings::ErrorPageEnabled));
+ Q_ASSERT((m_loadingInfo.triggersErrorPage && webEngineSettings()->testAttribute(QWebEngineSettings::ErrorPageEnabled)) || !m_loadingInfo.triggersErrorPage);
- m_viewClient->loadFinished(success, url, isErrorPage, errorCode, errorDescription, triggersErrorPage);
- m_viewClient->updateNavigationActions();
+ if (!isErrorPage) {
+ if (m_loadingInfo.progress < 100) {
+ m_loadingInfo.progress = 100;
+ m_viewClient->loadProgressChanged(100);
+ }
+
+ m_viewClient->loadFinished(m_loadingInfo.success, m_loadingInfo.url, false, m_loadingInfo.errorCode, m_loadingInfo.errorDescription);
+ m_viewClient->updateNavigationActions();
+ } else {
+ m_viewClient->loadFinished(false, toQt(GURL(content::kUnreachableWebDataURL)), true, 0, QString());
+ }
}
-void WebContentsDelegateQt::EmitLoadCommitted()
+void WebContentsDelegateQt::emitLoadCommitted()
{
m_findTextHelper->handleLoadCommitted();
m_viewClient->loadCommitted();
@@ -427,8 +411,7 @@ void WebContentsDelegateQt::DidFinishNavigation(content::NavigationHandle *navig
profileAdapter->visitedLinksManager()->addUrl(url);
}
- m_isNavigationCommitted = true;
- EmitLoadCommitted();
+ emitLoadCommitted();
}
// Success is reported by DidFinishLoad, but DidFailLoad is now dead code and needs to be handled below
@@ -443,13 +426,12 @@ void WebContentsDelegateQt::DidFinishNavigation(content::NavigationHandle *navig
// The load will succede as an error-page load later, and we reported the original error above
if (navigation_handle->IsErrorPage()) {
// Now report we are starting to load an error-page.
- m_loadingErrorFrameList.append(navigation_handle->GetRenderFrameHost()->GetRoutingID());
m_faviconManager->resetCandidates();
- EmitLoadStarted(toQt(GURL(content::kUnreachableWebDataURL)), true);
+ emitLoadStarted(true);
// If it is already committed we will not see another DidFinishNavigation call or a DidFinishLoad call.
if (navigation_handle->HasCommitted())
- EmitLoadCommitted();
+ emitLoadCommitted();
}
}
@@ -491,6 +473,9 @@ void WebContentsDelegateQt::DidStopLoading()
if (m_loadingState == LoadingState::Loading)
setLoadingState(LoadingState::Loaded);
+
+ emitLoadFinished();
+ m_loadingInfo.clear();
}
void WebContentsDelegateQt::didFailLoad(const QUrl &url, int errorCode, const QString &errorDescription)
@@ -500,7 +485,11 @@ void WebContentsDelegateQt::didFailLoad(const QUrl &url, int errorCode, const QS
// Delay notifying failure until the error-page is done loading.
// Error-pages are not loaded on failures due to abort.
bool aborted = (errorCode == -3 /* ERR_ABORTED*/ );
- EmitLoadFinished(false /* success */ , url, false /* isErrorPage */, errorCode, errorDescription, errorPageEnabled && !aborted);
+ m_loadingInfo.success = false;
+ m_loadingInfo.url = url;
+ m_loadingInfo.errorCode = errorCode;
+ m_loadingInfo.errorDescription = errorDescription;
+ m_loadingInfo.triggersErrorPage = errorPageEnabled && !aborted;
}
void WebContentsDelegateQt::DidFailLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url, int error_code)
@@ -514,10 +503,8 @@ void WebContentsDelegateQt::DidFailLoad(content::RenderFrameHost* render_frame_h
if (validated_url.spec() == content::kUnreachableWebDataURL) {
// error-pages should only ever fail due to abort:
Q_ASSERT(error_code == -3 /* ERR_ABORTED */);
- m_loadingErrorFrameList.removeOne(render_frame_host->GetRoutingID());
m_viewClient->iconChanged(QUrl());
-
- EmitLoadFinished(false /* success */, toQt(validated_url), true /* isErrorPage */);
+ emitLoadFinished(/* isErrorPage = */true);
return;
}
// Qt6: Consider getting rid of the error_description (Chromium already has)
@@ -532,12 +519,10 @@ void WebContentsDelegateQt::DidFinishLoad(content::RenderFrameHost* render_frame
{
Q_ASSERT(validated_url.is_valid());
if (validated_url.spec() == content::kUnreachableWebDataURL) {
- m_loadingErrorFrameList.removeOne(render_frame_host->GetRoutingID());
-
// Trigger LoadFinished signal for main frame's error page only.
if (!render_frame_host->GetParent()) {
m_viewClient->iconChanged(QUrl());
- EmitLoadFinished(true /* success */, toQt(validated_url), true /* isErrorPage */);
+ emitLoadFinished(/* isErrorPage = */true);
}
return;
@@ -555,7 +540,11 @@ void WebContentsDelegateQt::DidFinishLoad(content::RenderFrameHost* render_frame
int http_statuscode = entry ? entry->GetHttpStatusCode() : 0;
bool errorPageEnabled = webEngineSettings()->testAttribute(QWebEngineSettings::ErrorPageEnabled);
bool triggersErrorPage = errorPageEnabled && (http_statuscode >= 400) && m_isDocumentEmpty;
- EmitLoadFinished(http_statuscode < 400, toQt(validated_url), false /* isErrorPage */, http_statuscode, QString(), triggersErrorPage);
+
+ m_loadingInfo.success = http_statuscode < 400;
+ m_loadingInfo.url = toQt(validated_url);
+ m_loadingInfo.errorCode = http_statuscode;
+ m_loadingInfo.triggersErrorPage = triggersErrorPage;
}
void WebContentsDelegateQt::DidUpdateFaviconURL(content::RenderFrameHost *render_frame_host, const std::vector<blink::mojom::FaviconURLPtr> &candidates)
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index ca2cf2e0e..c3676d996 100644
--- a/src/core/web_contents_delegate_qt.h
+++ b/src/core/web_contents_delegate_qt.h
@@ -155,7 +155,6 @@ public:
// WebContentsObserver overrides
void RenderFrameCreated(content::RenderFrameHost *render_frame_host) override;
- void RenderFrameDeleted(content::RenderFrameHost *render_frame_host) override;
void RenderProcessGone(base::TerminationStatus status) override;
void RenderFrameHostChanged(content::RenderFrameHost *old_host, content::RenderFrameHost *new_host) override;
void RenderViewHostChanged(content::RenderViewHost *old_host, content::RenderViewHost *new_host) override;
@@ -212,9 +211,9 @@ private:
WindowOpenDisposition disposition, const gfx::Rect &initial_pos,
const QUrl &url,
bool user_gesture);
- void EmitLoadStarted(const QUrl &url, bool isErrorPage = false);
- void EmitLoadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString(), bool triggersErrorPage = false);
- void EmitLoadCommitted();
+ void emitLoadStarted(bool isErrorPage = false);
+ void emitLoadFinished(bool isErrorPage = false);
+ void emitLoadCommitted();
LoadingState determineLoadingState(content::WebContents *contents);
void setLoadingState(LoadingState state);
@@ -222,7 +221,6 @@ private:
int &streamCount(blink::mojom::MediaStreamType type);
WebContentsAdapterClient *m_viewClient;
- QList<int64_t> m_loadingErrorFrameList;
QScopedPointer<FaviconManager> m_faviconManager;
QScopedPointer<FindTextHelper> m_findTextHelper;
SavePageInfo m_savePageInfo;
@@ -238,9 +236,17 @@ private:
int m_desktopStreamCount = 0;
mutable bool m_pendingUrlUpdate = false;
- QMap<QUrl, int> m_loadProgressMap;
- QUrl m_lastLoadedUrl;
- bool m_isNavigationCommitted = false;
+ struct LoadingInfo {
+ bool success = false;
+ int progress = -1;
+ bool isLoading() const { return progress >= 0; }
+ QUrl url;
+ int errorCode = 0;
+ QString errorDescription;
+ bool triggersErrorPage = false;
+ void clear() { *this = LoadingInfo(); }
+ } m_loadingInfo;
+
bool m_isDocumentEmpty = true;
base::WeakPtrFactory<WebContentsDelegateQt> m_weakPtrFactory { this };
QList<QWeakPointer<CertificateErrorController>> m_certificateErrorControllers;
diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp
index 47c4634b3..407bd50bc 100644
--- a/src/core/web_engine_library_info.cpp
+++ b/src/core/web_engine_library_info.cpp
@@ -351,7 +351,7 @@ base::string16 WebEngineLibraryInfo::getApplicationName()
return toString16(qApp->applicationName());
}
-std::string WebEngineLibraryInfo::getApplicationLocale()
+std::string WebEngineLibraryInfo::getResolvedLocale()
{
base::CommandLine *parsedCommandLine = base::CommandLine::ForCurrentProcess();
if (parsedCommandLine->HasSwitch(switches::kLang)) {
@@ -365,6 +365,14 @@ std::string WebEngineLibraryInfo::getApplicationLocale()
return "en-US";
}
+std::string WebEngineLibraryInfo::getApplicationLocale()
+{
+ base::CommandLine *parsedCommandLine = base::CommandLine::ForCurrentProcess();
+ return parsedCommandLine->HasSwitch(switches::kLang)
+ ? parsedCommandLine->GetSwitchValueASCII(switches::kLang)
+ : QLocale().bcp47Name().toStdString();
+}
+
#if defined(OS_WIN)
bool WebEngineLibraryInfo::isRemoteDrivePath(const QString &path)
{
diff --git a/src/core/web_engine_library_info.h b/src/core/web_engine_library_info.h
index 4d23d8921..e7dc195f6 100644
--- a/src/core/web_engine_library_info.h
+++ b/src/core/web_engine_library_info.h
@@ -57,6 +57,7 @@ public:
static base::FilePath getPath(int key);
// Called by localized_error in our custom chrome layer
static base::string16 getApplicationName();
+ static std::string getResolvedLocale();
static std::string getApplicationLocale();
#if defined(OS_WIN)
static bool isRemoteDrivePath(const QString &path);