Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use old method to find current URL in Qt < 4.8.0

  • Loading branch information...
commit f95e4ebe0b2711da1b776caebd89c72f9f09ef03 1 parent ecfa783
@mhoran mhoran authored
Showing with 23 additions and 0 deletions.
  1. +16 −0 src/CurrentUrl.cpp
  2. +6 −0 src/CurrentUrl.h
  3. +1 −0  src/WebPageManager.cpp
View
16 src/CurrentUrl.cpp
@@ -6,8 +6,24 @@ CurrentUrl::CurrentUrl(WebPageManager *manager, QStringList &arguments, QObject
}
void CurrentUrl::start() {
+#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
QStringList arguments;
QVariant result = page()->invokeCapybaraFunction("currentUrl", arguments);
QString url = result.toString();
emit finished(new Response(true, url));
+#else
+ QUrl humanUrl = wasRedirectedAndNotModifiedByJavascript() ?
+ page()->currentFrame()->url() : page()->currentFrame()->requestedUrl();
+ QByteArray encodedBytes = humanUrl.toEncoded();
+ emit finished(new Response(true, encodedBytes));
}
+
+bool CurrentUrl::wasRegularLoad() {
+ return page()->currentFrame()->url() == page()->currentFrame()->requestedUrl();
+}
+
+bool CurrentUrl::wasRedirectedAndNotModifiedByJavascript() {
+ return !wasRegularLoad() && page()->currentFrame()->url() == page()->history()->currentItem().url();
+#endif
+}
+
View
6 src/CurrentUrl.h
@@ -6,5 +6,11 @@ class CurrentUrl : public SocketCommand {
public:
CurrentUrl(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
+#if QT_VERSION < QT_VERSION_CHECK(4, 8, 0)
+
+ private:
+ bool wasRegularLoad();
+ bool wasRedirectedAndNotModifiedByJavascript();
+#endif
};
View
1  src/WebPageManager.cpp
@@ -100,6 +100,7 @@ void WebPageManager::reset() {
m_pages.first()->deleteLater();
m_pages.clear();
createPage(this)->setFocus();
+ currentPage()->currentFrame()->setUrl(QUrl("about:blank"));
}
NetworkCookieJar *WebPageManager::cookieJar() {
Please sign in to comment.
Something went wrong with that request. Please try again.