1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
|
/*
* Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this program; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef qquickwebview_p_p_h
#define qquickwebview_p_p_h
#include "DefaultUndoController.h"
#include "PageViewportController.h"
#include "PageViewportControllerClient.h"
#include "QtPageClient.h"
#include "QtWebPageUIClient.h"
#include "qquickwebview_p.h"
#include "qquickwebpage_p.h"
#include <QtCore/QElapsedTimer>
#include <QtCore/QObject>
#include <QtCore/QScopedPointer>
#include <WebCore/ViewportArguments.h>
#include <WebKit2/WKRetainPtr.h>
#include <wtf/OwnPtr.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class CoordinatedGraphicsScene;
}
namespace WebKit {
class DownloadProxy;
class DrawingAreaProxy;
class QtDialogRunner;
class PageViewportControllerClientQt;
class QtWebContext;
class QtWebError;
class QtWebPageEventHandler;
class QtWebPagePolicyClient;
class WebPageProxy;
}
class QWebNavigationHistory;
class QWebKitTest;
class QWebChannelWebKitTransport;
QT_BEGIN_NAMESPACE
class QQmlComponent;
QT_END_NAMESPACE
class QQuickWebViewPrivate {
Q_DECLARE_PUBLIC(QQuickWebView)
friend class WebKit::QtDialogRunner;
friend class QQuickWebViewExperimental;
friend class QQuickWebPage;
friend class QWebPreferencesPrivate;
friend class QWebKitTest;
public:
static QQuickWebViewPrivate* get(QQuickWebView* q) { return q->d_ptr.data(); }
static QQuickWebViewPrivate* get(WKPageRef);
virtual ~QQuickWebViewPrivate();
virtual void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0);
virtual void onComponentComplete() { }
virtual void loadProgressDidChange(int loadProgress);
virtual void handleMouseEvent(QMouseEvent*);
static void didFindString(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo);
static void didFailToFindString(WKPageRef page, WKStringRef string, const void* clientInfo);
virtual void didChangeViewportProperties(const WebCore::ViewportAttributes& attr) { }
int loadProgress() const { return m_loadProgress; }
void setNeedsDisplay();
void didRenderFrame();
virtual WebKit::PageViewportController* viewportController() const { return 0; }
virtual void updateViewportSize() { }
void updateTouchViewportSize();
virtual qreal zoomFactor() const { return 1; }
virtual void setZoomFactor(qreal) { }
void _q_onVisibleChanged();
void _q_onUrlChanged();
void _q_onReceivedResponseFromDownload(QWebDownloadItem*);
void _q_onIconChangedForPageURL(const QString&);
void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, WebKit::QtWebPageUIClient::FileChooserType);
quint64 exceededDatabaseQuota(const QString& databaseName, const QString& displayName, WKSecurityOriginRef securityOrigin, quint64 currentQuota, quint64 currentOriginUsage, quint64 currentDatabaseUsage, quint64 expectedUsage);
void runJavaScriptAlert(const QString&);
bool runJavaScriptConfirm(const QString&);
QString runJavaScriptPrompt(const QString&, const QString& defaultValue, bool& ok);
void handleAuthenticationRequiredRequest(const QString& hostname, const QString& realm, const QString& prefilledUsername, QString& username, QString& password);
bool handleCertificateVerificationRequest(const QString& hostname);
void handleProxyAuthenticationRequiredRequest(const QString& hostname, uint16_t port, const QString& prefilledUsername, QString& username, QString& password);
void setRenderToOffscreenBuffer(bool enable) { m_renderToOffscreenBuffer = enable; }
void setTransparentBackground(bool);
void addAttachedPropertyTo(QObject*);
bool navigatorQtObjectEnabled() const;
bool renderToOffscreenBuffer() const { return m_renderToOffscreenBuffer; }
bool transparentBackground() const;
void setNavigatorQtObjectEnabled(bool);
void updateUserScripts();
void updateUserStyleSheets();
void updateSchemeDelegates();
QPointF contentPos() const;
void setContentPos(const QPointF&);
void updateIcon();
// PageClient.
WebCore::IntSize viewSize() const;
virtual void pageDidRequestScroll(const QPoint& pos) { }
void processDidCrash();
void didRelaunchProcess();
PassOwnPtr<WebKit::DrawingAreaProxy> createDrawingAreaProxy();
void handleDownloadRequest(WebKit::DownloadProxy*);
void didReceiveMessageFromNavigatorQtObject(WKStringRef message);
#ifdef HAVE_WEBCHANNEL
void didReceiveMessageFromNavigatorQtWebChannelTransportObject(WKStringRef message);
#endif
WebCore::CoordinatedGraphicsScene* coordinatedGraphicsScene();
float deviceScaleFactor();
void setIntrinsicDeviceScaleFactor(float);
protected:
class FlickableAxisLocker {
QQuickFlickable::FlickableDirection m_allowedDirection;
ulong m_time;
QPointF m_initialPosition;
QPointF m_lockReferencePosition;
int m_sampleCount;
QVector2D touchVelocity(const QTouchEvent* event);
public:
FlickableAxisLocker();
void update(const QTouchEvent* event);
void setReferencePosition(const QPointF&);
void reset();
QPointF adjust(const QPointF&);
};
// WKPageLoadClient callbacks.
static void didStartProvisionalLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void* clientInfo);
static void didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void* clientInfo);
static void didFailLoad(WKPageRef, WKFrameRef, WKErrorRef, WKTypeRef userData, const void* clientInfo);
static void didCommitLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void* clientInfo);
static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void* clientInfo);
static void didSameDocumentNavigationForFrame(WKPageRef, WKFrameRef, WKSameDocumentNavigationType, WKTypeRef userData, const void* clientInfo);
static void didReceiveTitleForFrame(WKPageRef, WKStringRef, WKFrameRef, WKTypeRef userData, const void* clientInfo);
static void didStartProgress(WKPageRef, const void* clientInfo);
static void didChangeProgress(WKPageRef, const void* clientInfo);
static void didFinishProgress(WKPageRef, const void* clientInfo);
static void didChangeBackForwardList(WKPageRef, WKBackForwardListItemRef, WKArrayRef, const void *clientInfo);
static void processDidBecomeUnresponsive(WKPageRef, const void* clientInfo);
static void processDidBecomeResponsive(WKPageRef, const void* clientInfo);
QQuickWebViewPrivate(QQuickWebView* viewport);
RefPtr<WebKit::WebPageProxy> webPageProxy;
WKRetainPtr<WKPageRef> webPage;
WKRetainPtr<WKPageGroupRef> pageGroup;
WebKit::QtPageClient pageClient;
WebKit::DefaultUndoController undoController;
OwnPtr<QWebNavigationHistory> navigationHistory;
OwnPtr<QWebPreferences> preferences;
QScopedPointer<WebKit::QtWebPagePolicyClient> pagePolicyClient;
QScopedPointer<WebKit::QtWebPageUIClient> pageUIClient;
QScopedPointer<QQuickWebPage> pageView;
QScopedPointer<WebKit::QtWebPageEventHandler> pageEventHandler;
QQuickWebView* q_ptr;
QQuickWebViewExperimental* experimental;
WebKit::QtWebContext* context;
FlickableAxisLocker axisLocker;
QQmlComponent* alertDialog;
QQmlComponent* confirmDialog;
QQmlComponent* promptDialog;
QQmlComponent* authenticationDialog;
QQmlComponent* certificateVerificationDialog;
QQmlComponent* itemSelector;
QQmlComponent* proxyAuthenticationDialog;
QQmlComponent* filePicker;
QQmlComponent* databaseQuotaDialog;
QQmlComponent* colorChooser;
QList<QUrl> userScripts;
QList<QUrl> userStyleSheets;
bool m_betweenLoadCommitAndFirstFrame;
bool m_useDefaultContentItemSize;
bool m_navigatorQtObjectEnabled;
bool m_renderToOffscreenBuffer;
bool m_allowAnyHTTPSCertificateForLocalHost;
QUrl m_iconUrl;
int m_loadProgress;
QString m_currentUrl;
};
class QQuickWebViewLegacyPrivate : public QQuickWebViewPrivate {
Q_DECLARE_PUBLIC(QQuickWebView)
public:
QQuickWebViewLegacyPrivate(QQuickWebView* viewport);
virtual void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0);
virtual void updateViewportSize();
qreal zoomFactor() const;
void setZoomFactor(qreal);
};
class QQuickWebViewFlickablePrivate : public QQuickWebViewPrivate {
Q_DECLARE_PUBLIC(QQuickWebView)
public:
QQuickWebViewFlickablePrivate(QQuickWebView* viewport);
virtual void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0);
virtual void onComponentComplete();
virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&);
virtual WebKit::PageViewportController* viewportController() const { return m_pageViewportController.data(); }
virtual void updateViewportSize();
virtual void pageDidRequestScroll(const QPoint& pos);
virtual void handleMouseEvent(QMouseEvent*);
private:
QScopedPointer<WebKit::PageViewportController> m_pageViewportController;
QScopedPointer<WebKit::PageViewportControllerClientQt> m_pageViewportControllerClient;
};
#endif // qquickwebview_p_p_h
|