1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the QtWebView module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL3$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or later as published by the Free
28** Software Foundation and appearing in the file LICENSE.GPL included in
29** the packaging of this file. Please review the following information to
30** ensure the GNU General Public License version 2.0 requirements will be
31** met: http://www.gnu.org/licenses/gpl-2.0.html.
32**
33** $QT_END_LICENSE$
34**
35****************************************************************************/
36
37#ifndef QWEBVIEW_P_H
38#define QWEBVIEW_P_H
39
40//
41// W A R N I N G
42// -------------
43//
44// This file is not part of the Qt API. It exists purely as an
45// implementation detail. This header file may change from version to
46// version without notice, or even be removed.
47//
48// We mean it.
49//
50
51#include "qabstractwebview_p.h"
52#include "qwebviewinterface_p.h"
53#include "qnativeviewcontroller_p.h"
54#include <QtCore/qobject.h>
55#include <QtCore/qurl.h>
56#include <QtGui/qimage.h>
57#include <QtQml/qjsvalue.h>
58
59QT_BEGIN_NAMESPACE
60
61class QWebViewLoadRequestPrivate;
62
63class Q_WEBVIEW_EXPORT QWebView
64 : public QObject
65 , public QWebViewInterface
66 , public QNativeViewController
67{
68 Q_OBJECT
69public:
70 enum LoadStatus { // Changes here needs to be done in QQuickWebView as well
71 LoadStartedStatus,
72 LoadStoppedStatus,
73 LoadSucceededStatus,
74 LoadFailedStatus
75 };
76
77 explicit QWebView(QObject *p = 0);
78 ~QWebView() Q_DECL_OVERRIDE;
79
80 QString httpUserAgent() const Q_DECL_OVERRIDE;
81 void setHttpUserAgent(const QString &httpUserAgent) Q_DECL_OVERRIDE;
82 QUrl url() const Q_DECL_OVERRIDE;
83 void setUrl(const QUrl &url) Q_DECL_OVERRIDE;
84 bool canGoBack() const Q_DECL_OVERRIDE;
85 bool canGoForward() const Q_DECL_OVERRIDE;
86 QString title() const Q_DECL_OVERRIDE;
87 int loadProgress() const Q_DECL_OVERRIDE;
88 bool isLoading() const Q_DECL_OVERRIDE;
89
90 void setParentView(QObject *view) Q_DECL_OVERRIDE;
91 QObject *parentView() const Q_DECL_OVERRIDE;
92 void setGeometry(const QRect &geometry) Q_DECL_OVERRIDE;
93 void setVisibility(QWindow::Visibility visibility) Q_DECL_OVERRIDE;
94 void setVisible(bool visible) Q_DECL_OVERRIDE;
95 void setFocus(bool focus) Q_DECL_OVERRIDE;
96
97public Q_SLOTS:
98 void goBack() Q_DECL_OVERRIDE;
99 void goForward() Q_DECL_OVERRIDE;
100 void reload() Q_DECL_OVERRIDE;
101 void stop() Q_DECL_OVERRIDE;
102 void loadHtml(const QString &html, const QUrl &baseUrl = QUrl()) Q_DECL_OVERRIDE;
103
104Q_SIGNALS:
105 void titleChanged();
106 void urlChanged();
107 void loadingChanged(const QWebViewLoadRequestPrivate &loadRequest);
108 void loadProgressChanged();
109 void javaScriptResult(int id, const QVariant &result);
110 void requestFocus(bool focus);
111 void httpUserAgentChanged();
112
113protected:
114 void init() Q_DECL_OVERRIDE;
115 void runJavaScriptPrivate(const QString &script,
116 int callbackId) Q_DECL_OVERRIDE;
117
118private Q_SLOTS:
119 void onTitleChanged(const QString &title);
120 void onUrlChanged(const QUrl &url);
121 void onLoadProgressChanged(int progress);
122 void onLoadingChanged(const QWebViewLoadRequestPrivate &loadRequest);
123 void onHttpUserAgentChanged(const QString &httpUserAgent);
124
125private:
126 friend class QQuickViewController;
127 friend class QQuickWebView;
128
129 QAbstractWebView *d;
130
131 // provisional data
132 int m_progress;
133 QString m_title;
134 QUrl m_url;
135 mutable QString m_httpUserAgent;
136};
137
138QT_END_NAMESPACE
139
140#endif // QWEBVIEW_P_H
141

source code of qtwebview/src/webview/qwebview_p.h