From b8c6c4a8588374cd0e1830871134d44d0460e0e8 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 28 Nov 2019 11:19:54 +0100 Subject: Cleanup renderer_host MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Selective application of clang-format in src/core/renderer_host Change-Id: I6fc78374be914dca15b15ab8b8f4b7bed83f21af Reviewed-by: Jüri Valdmann --- .../renderer_host/render_view_observer_host_qt.cpp | 7 ++-- .../renderer_host/render_view_observer_host_qt.h | 10 ++--- .../resource_dispatcher_host_delegate_qt.cpp | 47 +++++++++------------- .../resource_dispatcher_host_delegate_qt.h | 8 ++-- .../user_resource_controller_host.cpp | 43 +++++++++----------- .../renderer_host/user_resource_controller_host.h | 3 +- .../web_channel_ipc_transport_host.cpp | 5 +-- .../renderer_host/web_channel_ipc_transport_host.h | 6 ++- 8 files changed, 60 insertions(+), 69 deletions(-) (limited to 'src') diff --git a/src/core/renderer_host/render_view_observer_host_qt.cpp b/src/core/renderer_host/render_view_observer_host_qt.cpp index c097e102d..165a9d86a 100644 --- a/src/core/renderer_host/render_view_observer_host_qt.cpp +++ b/src/core/renderer_host/render_view_observer_host_qt.cpp @@ -69,7 +69,7 @@ void RenderViewObserverHostQt::fetchDocumentInnerText(quint64 requestId) web_contents()->GetRenderViewHost()->GetRoutingID(), requestId)); } -bool RenderViewObserverHostQt::OnMessageReceived(const IPC::Message& message) +bool RenderViewObserverHostQt::OnMessageReceived(const IPC::Message &message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(RenderViewObserverHostQt, message) @@ -80,15 +80,14 @@ bool RenderViewObserverHostQt::OnMessageReceived(const IPC::Message& message) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; - } -void RenderViewObserverHostQt::onDidFetchDocumentMarkup(quint64 requestId, const base::string16& markup) +void RenderViewObserverHostQt::onDidFetchDocumentMarkup(quint64 requestId, const base::string16 &markup) { m_adapterClient->didFetchDocumentMarkup(requestId, toQt(markup)); } -void RenderViewObserverHostQt::onDidFetchDocumentInnerText(quint64 requestId, const base::string16& innerText) +void RenderViewObserverHostQt::onDidFetchDocumentInnerText(quint64 requestId, const base::string16 &innerText) { m_adapterClient->didFetchDocumentInnerText(requestId, toQt(innerText)); } diff --git a/src/core/renderer_host/render_view_observer_host_qt.h b/src/core/renderer_host/render_view_observer_host_qt.h index a08263e07..8590ecbc5 100644 --- a/src/core/renderer_host/render_view_observer_host_qt.h +++ b/src/core/renderer_host/render_view_observer_host_qt.h @@ -45,7 +45,7 @@ #include namespace content { - class WebContents; +class WebContents; } namespace QtWebEngineCore { @@ -55,14 +55,14 @@ class WebContentsAdapterClient; class RenderViewObserverHostQt : public content::WebContentsObserver { public: - RenderViewObserverHostQt(content::WebContents*, WebContentsAdapterClient *adapterClient); + RenderViewObserverHostQt(content::WebContents *, WebContentsAdapterClient *adapterClient); void fetchDocumentMarkup(quint64 requestId); void fetchDocumentInnerText(quint64 requestId); private: - bool OnMessageReceived(const IPC::Message& message) override; - void onDidFetchDocumentMarkup(quint64 requestId, const base::string16& markup); - void onDidFetchDocumentInnerText(quint64 requestId, const base::string16& innerText); + bool OnMessageReceived(const IPC::Message &message) override; + void onDidFetchDocumentMarkup(quint64 requestId, const base::string16 &markup); + void onDidFetchDocumentInnerText(quint64 requestId, const base::string16 &innerText); WebContentsAdapterClient *m_adapterClient; }; diff --git a/src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp b/src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp index a08e2cf88..59b0ca516 100644 --- a/src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp +++ b/src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp @@ -77,17 +77,14 @@ namespace QtWebEngineCore { -void OnPdfStreamIntercepted( - const GURL& original_url, - std::string extension_id, - int frame_tree_node_id, - const content::ResourceRequestInfo::WebContentsGetter& - web_contents_getter) { - content::WebContents* web_contents = web_contents_getter.Run(); +void OnPdfStreamIntercepted(const GURL &original_url, std::string extension_id, int frame_tree_node_id, + const content::ResourceRequestInfo::WebContentsGetter &web_contents_getter) +{ + content::WebContents *web_contents = web_contents_getter.Run(); if (!web_contents) return; - WebContentsDelegateQt *contentsDelegate = static_cast(web_contents->GetDelegate()); + WebContentsDelegateQt *contentsDelegate = static_cast(web_contents->GetDelegate()); if (!contentsDelegate) return; @@ -97,19 +94,17 @@ void OnPdfStreamIntercepted( // If the applications has been set up to always download PDF files to open them in an // external viewer, trigger the download. std::unique_ptr params( - content::DownloadRequestUtils::CreateDownloadForWebContentsMainFrame( - web_contents, original_url, MISSING_TRAFFIC_ANNOTATION)); - content::BrowserContext::GetDownloadManager(web_contents->GetBrowserContext()) - ->DownloadUrl(std::move(params)); + content::DownloadRequestUtils::CreateDownloadForWebContentsMainFrame(web_contents, original_url, + MISSING_TRAFFIC_ANNOTATION)); + content::BrowserContext::GetDownloadManager(web_contents->GetBrowserContext())->DownloadUrl(std::move(params)); return; } // The URL passes the original pdf resource url, that will be requested // by the pdf viewer extension page. content::NavigationController::LoadURLParams params( - GURL(base::StringPrintf("%s://%s/index.html?%s", extensions::kExtensionScheme, - extension_id.c_str(), - original_url.spec().c_str()))); + GURL(base::StringPrintf("%s://%s/index.html?%s", extensions::kExtensionScheme, + extension_id.c_str(), original_url.spec().c_str()))); params.frame_tree_node_id = frame_tree_node_id; web_contents->GetController().LoadURLWithParams(params); @@ -120,8 +115,7 @@ bool ResourceDispatcherHostDelegateQt::ShouldInterceptResourceAsStream(net::URLR GURL *origin, std::string *payload) { - content::ResourceRequestInfo* info = - content::ResourceRequestInfo::ForRequest(request); + content::ResourceRequestInfo *info = content::ResourceRequestInfo::ForRequest(request); int render_process_host_id = -1; int render_frame_id = -1; @@ -130,7 +124,8 @@ bool ResourceDispatcherHostDelegateQt::ShouldInterceptResourceAsStream(net::URLR std::vector whitelist = MimeTypesHandler::GetMIMETypeWhitelist(); - extensions::ExtensionSystemQt *extensionSystem = ProfileIODataQt::FromResourceContext(info->GetContext())->GetExtensionSystem(); + extensions::ExtensionSystemQt *extensionSystem = + ProfileIODataQt::FromResourceContext(info->GetContext())->GetExtensionSystem(); if (!extensionSystem) return false; @@ -141,7 +136,7 @@ bool ResourceDispatcherHostDelegateQt::ShouldInterceptResourceAsStream(net::URLR if (!extension) continue; - MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); + MimeTypesHandler *handler = MimeTypesHandler::GetHandler(extension); if (!handler) continue; if (handler->CanHandleMIMEType(mime_type)) { @@ -159,8 +154,7 @@ bool ResourceDispatcherHostDelegateQt::ShouldInterceptResourceAsStream(net::URLR // Informs the delegate that a Stream was created. The Stream can be read from // the blob URL of the Stream, but can only be read once. -void ResourceDispatcherHostDelegateQt::OnStreamCreated(net::URLRequest *request, - std::unique_ptr stream) +void ResourceDispatcherHostDelegateQt::OnStreamCreated(net::URLRequest *request, std::unique_ptr stream) { content::ResourceRequestInfo *info = content::ResourceRequestInfo::ForRequest(request); std::map::iterator ix = stream_target_info_.find(request); @@ -173,13 +167,10 @@ void ResourceDispatcherHostDelegateQt::OnStreamCreated(net::URLRequest *request, return; } - base::PostTaskWithTraits( - FROM_HERE, {content::BrowserThread::UI}, - base::BindOnce(&OnPdfStreamIntercepted, - request->url(), ix->second.extension_id, - info->GetFrameTreeNodeId(), info->GetWebContentsGetterForRequest() - ) - ); + base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(&OnPdfStreamIntercepted, + request->url(), ix->second.extension_id, + info->GetFrameTreeNodeId(), info->GetWebContentsGetterForRequest())); stream_target_info_.erase(request); } diff --git a/src/core/renderer_host/resource_dispatcher_host_delegate_qt.h b/src/core/renderer_host/resource_dispatcher_host_delegate_qt.h index 3039fd03e..d9ee83581 100644 --- a/src/core/renderer_host/resource_dispatcher_host_delegate_qt.h +++ b/src/core/renderer_host/resource_dispatcher_host_delegate_qt.h @@ -47,7 +47,8 @@ namespace QtWebEngineCore { -class ResourceDispatcherHostDelegateQt : public content::ResourceDispatcherHostDelegate { +class ResourceDispatcherHostDelegateQt : public content::ResourceDispatcherHostDelegate +{ public: // If the stream will be rendered in a BrowserPlugin, |payload| will contain // the data that should be given to the old ResourceHandler to forward to the @@ -61,15 +62,16 @@ public: // the blob URL of the Stream, but can only be read once. void OnStreamCreated(net::URLRequest *request, std::unique_ptr stream) override; + private: #if BUILDFLAG(ENABLE_EXTENSIONS) - struct StreamTargetInfo { + struct StreamTargetInfo + { std::string extension_id; std::string view_id; }; std::map stream_target_info_; #endif - }; } // namespace QtWebEngineCore diff --git a/src/core/renderer_host/user_resource_controller_host.cpp b/src/core/renderer_host/user_resource_controller_host.cpp index ed4d736f2..96625c13f 100644 --- a/src/core/renderer_host/user_resource_controller_host.cpp +++ b/src/core/renderer_host/user_resource_controller_host.cpp @@ -51,39 +51,37 @@ namespace QtWebEngineCore { -class UserResourceControllerHost::WebContentsObserverHelper : public content::WebContentsObserver { +class UserResourceControllerHost::WebContentsObserverHelper : public content::WebContentsObserver +{ public: WebContentsObserverHelper(UserResourceControllerHost *, content::WebContents *); // WebContentsObserver overrides: void RenderFrameCreated(content::RenderFrameHost *renderFrameHost) override; - void RenderFrameHostChanged(content::RenderFrameHost *oldHost, - content::RenderFrameHost *newHost) override; + void RenderFrameHostChanged(content::RenderFrameHost *oldHost, content::RenderFrameHost *newHost) override; void WebContentsDestroyed() override; private: UserResourceControllerHost *m_controllerHost; }; -UserResourceControllerHost::WebContentsObserverHelper::WebContentsObserverHelper(UserResourceControllerHost *controller, content::WebContents *contents) - : content::WebContentsObserver(contents) - , m_controllerHost(controller) +UserResourceControllerHost::WebContentsObserverHelper::WebContentsObserverHelper(UserResourceControllerHost *controller, + content::WebContents *contents) + : content::WebContentsObserver(contents) + , m_controllerHost(controller) { } -void UserResourceControllerHost::WebContentsObserverHelper::RenderFrameCreated( - content::RenderFrameHost *renderFrameHost) +void UserResourceControllerHost::WebContentsObserverHelper::RenderFrameCreated(content::RenderFrameHost *renderFrameHost) { content::WebContents *contents = web_contents(); const QList scripts = m_controllerHost->m_perContentsScripts.value(contents); for (const UserScript &script : scripts) - renderFrameHost->Send(new RenderFrameObserverHelper_AddScript( - renderFrameHost->GetRoutingID(), script.data())); + renderFrameHost->Send(new RenderFrameObserverHelper_AddScript(renderFrameHost->GetRoutingID(), script.data())); } -void UserResourceControllerHost::WebContentsObserverHelper::RenderFrameHostChanged( - content::RenderFrameHost *oldHost, - content::RenderFrameHost *newHost) +void UserResourceControllerHost::WebContentsObserverHelper::RenderFrameHostChanged(content::RenderFrameHost *oldHost, + content::RenderFrameHost *newHost) { if (oldHost) oldHost->Send(new RenderFrameObserverHelper_ClearScripts(oldHost->GetRoutingID())); @@ -95,10 +93,12 @@ void UserResourceControllerHost::WebContentsObserverHelper::WebContentsDestroyed delete this; } -class UserResourceControllerHost::RenderProcessObserverHelper : public content::RenderProcessHostObserver { +class UserResourceControllerHost::RenderProcessObserverHelper : public content::RenderProcessHostObserver +{ public: RenderProcessObserverHelper(UserResourceControllerHost *); void RenderProcessHostDestroyed(content::RenderProcessHost *) override; + private: UserResourceControllerHost *m_controllerHost; }; @@ -142,9 +142,9 @@ void UserResourceControllerHost::addUserScript(const UserScript &script, WebCont } } contents->GetRenderViewHost()->Send( - new RenderFrameObserverHelper_AddScript( - contents->GetRenderViewHost()->GetMainFrame()->GetRoutingID(), - script.data())); + new RenderFrameObserverHelper_AddScript( + contents->GetRenderViewHost()->GetMainFrame()->GetRoutingID(), + script.data())); } } @@ -165,8 +165,7 @@ bool UserResourceControllerHost::removeUserScript(const UserScript &script, WebC return false; const bool isProfileWideScript = !adapter; if (isProfileWideScript) { - QList::iterator it - = std::find(m_profileWideScripts.begin(), m_profileWideScripts.end(), script); + QList::iterator it = std::find(m_profileWideScripts.begin(), m_profileWideScripts.end(), script); if (it == m_profileWideScripts.end()) return false; for (content::RenderProcessHost *renderer : qAsConst(m_observedProcesses)) @@ -181,9 +180,7 @@ bool UserResourceControllerHost::removeUserScript(const UserScript &script, WebC if (it == list.end()) return false; contents->GetRenderViewHost()->Send( - new RenderFrameObserverHelper_RemoveScript( - contents->GetMainFrame()->GetRoutingID(), - (*it).data())); + new RenderFrameObserverHelper_RemoveScript(contents->GetMainFrame()->GetRoutingID(), (*it).data())); list.erase(it); } return true; @@ -200,7 +197,7 @@ void UserResourceControllerHost::clearAllScripts(WebContentsAdapter *adapter) content::WebContents *contents = adapter->webContents(); m_perContentsScripts.remove(contents); contents->GetRenderViewHost()->Send( - new RenderFrameObserverHelper_ClearScripts(contents->GetMainFrame()->GetRoutingID())); + new RenderFrameObserverHelper_ClearScripts(contents->GetMainFrame()->GetRoutingID())); } } diff --git a/src/core/renderer_host/user_resource_controller_host.h b/src/core/renderer_host/user_resource_controller_host.h index 16a73f5fb..9d828feb6 100644 --- a/src/core/renderer_host/user_resource_controller_host.h +++ b/src/core/renderer_host/user_resource_controller_host.h @@ -66,7 +66,8 @@ namespace QtWebEngineCore { class WebContentsAdapter; -class Q_WEBENGINECORE_PRIVATE_EXPORT UserResourceControllerHost { +class Q_WEBENGINECORE_PRIVATE_EXPORT UserResourceControllerHost +{ public: UserResourceControllerHost(); diff --git a/src/core/renderer_host/web_channel_ipc_transport_host.cpp b/src/core/renderer_host/web_channel_ipc_transport_host.cpp index 4547b7fcf..6dbf2a370 100644 --- a/src/core/renderer_host/web_channel_ipc_transport_host.cpp +++ b/src/core/renderer_host/web_channel_ipc_transport_host.cpp @@ -61,7 +61,7 @@ inline QDebug operator<<(QDebug stream, content::RenderFrameHost *frame) return stream << "frame " << frame->GetRoutingID() << " in process " << frame->GetProcess()->GetID(); } -template +template inline QDebug operator<<(QDebug stream, const base::Optional &opt) { if (opt) @@ -140,8 +140,7 @@ void WebChannelIPCTransportHost::DispatchWebChannelMessage(const std::vector(binaryJson.data()), binaryJson.size()); + QJsonDocument doc = QJsonDocument::fromRawData(reinterpret_cast(binaryJson.data()), binaryJson.size()); if (!doc.isObject()) { qCCritical(log).nospace() << "received invalid webchannel message from " << frame; diff --git a/src/core/renderer_host/web_channel_ipc_transport_host.h b/src/core/renderer_host/web_channel_ipc_transport_host.h index 94891f25f..d53b24b6b 100644 --- a/src/core/renderer_host/web_channel_ipc_transport_host.h +++ b/src/core/renderer_host/web_channel_ipc_transport_host.h @@ -53,9 +53,11 @@ QT_FORWARD_DECLARE_CLASS(QString) namespace QtWebEngineCore { -class WebChannelIPCTransportHost : public QWebChannelAbstractTransport +class WebChannelIPCTransportHost + : public QWebChannelAbstractTransport , private content::WebContentsObserver - , qtwebchannel::mojom::WebChannelTransportHost { + , qtwebchannel::mojom::WebChannelTransportHost +{ public: WebChannelIPCTransportHost(content::WebContents *webContents, uint32_t worldId = 0, QObject *parent = nullptr); ~WebChannelIPCTransportHost() override; -- cgit v1.2.3