Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Set frameName for WebPage's resource callbacks. #11373

Merged
1 commit merged into from
Jan 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/networkaccessmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <QSslSocket>
#include <QSslCertificate>
#include <QRegExp>
#include <QWebFrame>

#include "phantom.h"
#include "config.h"
Expand Down Expand Up @@ -251,6 +252,9 @@ QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkR
if (op == QNetworkAccessManager::PostOperation) data["postData"] = postData.data();
data["time"] = QDateTime::currentDateTime();

QWebFrame *frame = qobject_cast<QWebFrame *>(request.originatingObject());
data["frameName"] = frame->frameName();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's important to check for NULL. Or it's going to get ugly here.

Same for the similar code below.


JsNetworkRequest jsNetworkRequest(&req, this);
emit resourceRequested(data, &jsNetworkRequest);

Expand Down Expand Up @@ -307,7 +311,7 @@ void NetworkAccessManager::handleStarted()
return;

m_started += reply;

QVariantList headers;
foreach (QByteArray headerName, reply->rawHeaderList()) {
QVariantMap header;
Expand All @@ -328,6 +332,9 @@ void NetworkAccessManager::handleStarted()
data["headers"] = headers;
data["time"] = QDateTime::currentDateTime();

QWebFrame *frame = qobject_cast<QWebFrame *>(reply->request().originatingObject());
data["frameName"] = frame->frameName();

emit resourceReceived(data);
}

Expand Down Expand Up @@ -378,6 +385,9 @@ void NetworkAccessManager::handleFinished(QNetworkReply *reply, const QVariant &
data["headers"] = headers;
data["time"] = QDateTime::currentDateTime();

QWebFrame *frame = qobject_cast<QWebFrame *>(reply->request().originatingObject());
data["frameName"] = frame->frameName();

m_ids.remove(reply);
m_started.remove(reply);

Expand Down Expand Up @@ -409,5 +419,8 @@ void NetworkAccessManager::handleNetworkError()
data["errorCode"] = reply->error();
data["errorString"] = reply->errorString();

QWebFrame *frame = qobject_cast<QWebFrame *>(reply->request().originatingObject());
data["frameName"] = frame->frameName();

emit resourceError(data);
}