1/*
2    Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
3
4    This library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Library General Public
6    License as published by the Free Software Foundation; either
7    version 2 of the License, or (at your option) any later version.
8
9    This library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Library General Public License for more details.
13
14    You should have received a copy of the GNU Library General Public License
15    along with this library; see the file COPYING.LIB.  If not, write to
16    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17    Boston, MA 02110-1301, USA.
18*/
19
20#include "config.h"
21
22#include "qwebnavigationrequest_p.h"
23
24#include "qquickwebview_p.h"
25
26class QWebNavigationRequestPrivate {
27public:
28    QWebNavigationRequestPrivate(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType)
29        : url(url)
30        , mouseButton(mouseButton)
31        , keyboardModifiers(keyboardModifiers)
32        , action(QQuickWebView::AcceptRequest)
33        , navigationType(navigationType)
34    {
35    }
36
37    ~QWebNavigationRequestPrivate()
38    {
39    }
40
41    QUrl url;
42    Qt::MouseButton mouseButton;
43    Qt::KeyboardModifiers keyboardModifiers;
44    QQuickWebView::NavigationRequestAction action;
45    QQuickWebView::NavigationType navigationType;
46};
47
48QWebNavigationRequest::QWebNavigationRequest(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType, QObject* parent)
49    : QObject(parent)
50    , d(new QWebNavigationRequestPrivate(url, mouseButton, keyboardModifiers, navigationType))
51{
52}
53
54QWebNavigationRequest::~QWebNavigationRequest()
55{
56    delete d;
57}
58
59void QWebNavigationRequest::setAction(QQuickWebView::NavigationRequestAction action)
60{
61    if (d->action == action)
62        return;
63
64    d->action = action;
65    emit actionChanged();
66}
67
68QUrl QWebNavigationRequest::url() const
69{
70    return d->url;
71}
72
73int QWebNavigationRequest::mouseButton() const
74{
75    return int(d->mouseButton);
76}
77
78int QWebNavigationRequest::keyboardModifiers() const
79{
80    return int(d->keyboardModifiers);
81}
82
83QQuickWebView::NavigationRequestAction QWebNavigationRequest::action() const
84{
85    return d->action;
86}
87
88QQuickWebView::NavigationType QWebNavigationRequest::navigationType() const
89{
90    return d->navigationType;
91}
92