Index: Source/WebKit2/ChangeLog
===================================================================
--- a/Source/WebKit2/ChangeLog	(revision 152824)
+++ b/Source/WebKit2/ChangeLog	(working copy)
@@ -1,3 +1,21 @@
+2013-07-17  Alexandre Abreu  <alexandre.abreu@canonical.com>
+
+        Add a 'isMainFrame' parameter to QWebNavigationRequest.
+        https://bugs.webkit.org/show_bug.cgi?id=118860
+
+        Reviewed by NOBODY (OOPS!).
+
+        * UIProcess/API/qt/qwebnavigationrequest.cpp:
+        (QWebNavigationRequestPrivate::QWebNavigationRequestPrivate):
+        (QWebNavigationRequest::QWebNavigationRequest):
+        (QWebNavigationRequest::navigationType):
+        (QWebNavigationRequest::isMainFrame):
+        * UIProcess/API/qt/qwebnavigationrequest_p.h:
+        * UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp:
+        * UIProcess/qt/QtWebPagePolicyClient.cpp:
+        (WebKit::QtWebPagePolicyClient::decidePolicyForNavigationAction):
+        * UIProcess/qt/QtWebPagePolicyClient.h:
+
 2013-01-24  Michael Brüning  <michael.bruning@digia.com>
 
         [Qt][WK2] Pages / resources cannot be loaded from qrc files.
Index: Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest.cpp
===================================================================
--- a/Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest.cpp	(revision 152631)
+++ b/Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest.cpp	(working copy)
@@ -25,12 +25,13 @@
 
 class QWebNavigationRequestPrivate {
 public:
-    QWebNavigationRequestPrivate(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType)
+    QWebNavigationRequestPrivate(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType, bool isMainFrame)
         : url(url)
         , mouseButton(mouseButton)
         , keyboardModifiers(keyboardModifiers)
         , action(QQuickWebView::AcceptRequest)
         , navigationType(navigationType)
+        , isMainFrame(isMainFrame)
     {
     }
 
@@ -43,11 +44,12 @@ public:
     Qt::KeyboardModifiers keyboardModifiers;
     QQuickWebView::NavigationRequestAction action;
     QQuickWebView::NavigationType navigationType;
+    bool isMainFrame;
 };
 
-QWebNavigationRequest::QWebNavigationRequest(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType, QObject* parent)
+QWebNavigationRequest::QWebNavigationRequest(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType, bool isMainFrame, QObject* parent)
     : QObject(parent)
-    , d(new QWebNavigationRequestPrivate(url, mouseButton, keyboardModifiers, navigationType))
+    , d(new QWebNavigationRequestPrivate(url, mouseButton, keyboardModifiers, navigationType, isMainFrame))
 {
 }
 
@@ -89,3 +91,8 @@ QQuickWebView::NavigationType QWebNaviga
 {
     return d->navigationType;
 }
+
+bool QWebNavigationRequest::isMainFrame() const
+{
+    return d->isMainFrame;
+}
Index: Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest_p.h
===================================================================
--- a/Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest_p.h	(revision 152631)
+++ b/Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest_p.h	(working copy)
@@ -35,9 +35,10 @@ class QWEBKIT_EXPORT QWebNavigationReque
     Q_PROPERTY(int keyboardModifiers READ keyboardModifiers CONSTANT FINAL)
     Q_PROPERTY(QQuickWebView::NavigationRequestAction action READ action WRITE setAction NOTIFY actionChanged FINAL)
     Q_PROPERTY(QQuickWebView::NavigationType navigationType READ navigationType CONSTANT FINAL)
+    Q_PROPERTY(bool isMainFrame READ isMainFrame CONSTANT FINAL REVISION 1)
 
 public:
-    QWebNavigationRequest(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType, QObject* parent = 0);
+    QWebNavigationRequest(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType, bool isMainFrame, QObject* parent = 0);
     ~QWebNavigationRequest();
 
     QUrl url() const;
@@ -48,6 +49,8 @@ public:
     void setAction(QQuickWebView::NavigationRequestAction action);
     QQuickWebView::NavigationType navigationType() const;
 
+    bool isMainFrame() const;
+
 Q_SIGNALS:
     void actionChanged();
 
Index: Source/WebKit2/UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp
===================================================================
--- a/Source/WebKit2/UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp	(revision 152631)
+++ b/Source/WebKit2/UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp	(working copy)
@@ -90,6 +90,7 @@ static QStringList expectedAPI = QString
     << "QWebNavigationRequest.keyboardModifiers --> int"
     << "QWebNavigationRequest.action --> QQuickWebView::NavigationRequestAction"
     << "QWebNavigationRequest.navigationType --> QQuickWebView::NavigationType"
+    << "QWebNavigationRequest.isMainFrame --> bool"
     << "QWebNavigationRequest.actionChanged() --> void"
     ;
 
Index: Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.cpp
===================================================================
--- a/Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.cpp	(revision 152631)
+++ b/Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.cpp	(working copy)
@@ -44,11 +44,11 @@ QtWebPagePolicyClient::QtWebPagePolicyCl
     WKPageSetPagePolicyClient(pageRef, &policyClient);
 }
 
-void QtWebPagePolicyClient::decidePolicyForNavigationAction(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType, WKFramePolicyListenerRef listener)
+void QtWebPagePolicyClient::decidePolicyForNavigationAction(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType, bool isMainFrame, WKFramePolicyListenerRef listener)
 {
     // NOTE: even though the C API (and the WebKit2 IPC) supports an asynchronous answer, this is not currently working.
     // We are expected to call the listener immediately. See the patch for https://bugs.webkit.org/show_bug.cgi?id=53785.
-    QWebNavigationRequest navigationRequest(url, mouseButton, keyboardModifiers, navigationType);
+    QWebNavigationRequest navigationRequest(url, mouseButton, keyboardModifiers, navigationType, isMainFrame);
     emit m_webView->navigationRequested(&navigationRequest);
 
     switch (navigationRequest.action()) {
@@ -121,12 +121,13 @@ static QQuickWebView::NavigationType toQ
     return QQuickWebView::OtherNavigation;
 }
 
-void QtWebPagePolicyClient::decidePolicyForNavigationAction(WKPageRef, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef, const void* clientInfo)
+void QtWebPagePolicyClient::decidePolicyForNavigationAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef, const void* clientInfo)
 {
     WKRetainPtr<WKURLRef> frameURL(AdoptWK, WKFrameCopyURL(frame));
     WKRetainPtr<WKURLRef> requestURL(AdoptWK, WKURLRequestCopyURL(request));
     QUrl qUrl = WKURLCopyQUrl(requestURL.get());
-    toQtWebPagePolicyClient(clientInfo)->decidePolicyForNavigationAction(qUrl, toQtMouseButton(mouseButton), toQtKeyboardModifiers(modifiers), toQuickWebViewNavigationType(navigationType), listener);
+    bool isMainFrame = (WKPageGetMainFrame(page) == frame);
+    toQtWebPagePolicyClient(clientInfo)->decidePolicyForNavigationAction(qUrl, toQtMouseButton(mouseButton), toQtKeyboardModifiers(modifiers), toQuickWebViewNavigationType(navigationType), isMainFrame, listener);
 }
 
 void QtWebPagePolicyClient::decidePolicyForResponse(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef, WKFramePolicyListenerRef listener, WKTypeRef, const void*)
Index: Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.h
===================================================================
--- a/Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.h	(revision 152631)
+++ b/Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.h	(working copy)
@@ -36,7 +36,7 @@ public:
     QtWebPagePolicyClient(WKPageRef, QQuickWebView*);
 
 private:
-    void decidePolicyForNavigationAction(const QUrl&, Qt::MouseButton, Qt::KeyboardModifiers, QQuickWebView::NavigationType, WKFramePolicyListenerRef);
+    void decidePolicyForNavigationAction(const QUrl&, Qt::MouseButton, Qt::KeyboardModifiers, QQuickWebView::NavigationType, bool isMainFrame, WKFramePolicyListenerRef);
 
     // WKPagePolicyClient callbacks.
     static void decidePolicyForNavigationAction(WKPageRef, WKFrameRef, WKFrameNavigationType, WKEventModifiers, WKEventMouseButton, WKURLRequestRef, WKFramePolicyListenerRef, WKTypeRef userData, const void* clientInfo);
Index: Source/WebKit/qt/declarative/plugin.cpp
===================================================================
--- a/Source/WebKit/qt/declarative/plugin.cpp	2013-08-28 07:12:14.218319130 +0300
+++ b/Source/WebKit/qt/declarative/plugin.cpp	2013-08-28 07:12:55.398318775 +0300
@@ -58,6 +58,7 @@
         qmlRegisterUncreatableType<QQuickWebPage>(uri, 3, 0, "WebPage", QObject::tr("Cannot create separate instance of WebPage, use WebView"));
         qmlRegisterUncreatableType<QNetworkReply>(uri, 3, 0, "NetworkReply", QObject::tr("Cannot create separate instance of NetworkReply"));
         qmlRegisterUncreatableType<QWebNavigationRequest>(uri, 3, 0, "NavigationRequest", QObject::tr("Cannot create separate instance of NavigationRequest"));
+        qmlRegisterUncreatableType<QWebNavigationRequest, 1>(uri, 3, 1, "NavigationRequest", QObject::tr("Cannot create separate instance of NavigationRequest"));
         qmlRegisterUncreatableType<QWebLoadRequest>(uri, 3, 0, "WebLoadRequest", QObject::tr("Cannot create separate instance of WebLoadRequest"));
 #endif
     }
