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

Commit

Permalink
Set frameName for WebPage's request callbacks.
Browse files Browse the repository at this point in the history
Add frameName to the hash passed to the following callbacks:

    * onResourceRequested
    * onResourceReceived (both "start" and "end")
    * onResourceError
  • Loading branch information
kanzure committed Jun 3, 2013
1 parent 4d91697 commit 09d36d8
Showing 1 changed file with 14 additions and 1 deletion.
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();

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);
}

0 comments on commit 09d36d8

Please sign in to comment.