diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-03 09:55:33 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-03 09:55:33 +0100 |
commit | cd44dc59cdfc39534aef4d417e9f3c412e3be139 (patch) | |
tree | 8d89889ba95ed6ec9322e733846cc9cce9d7dff1 /Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp | |
parent | d11f84f5b5cdc0d92a08af01b13472fdd5f9acb9 (diff) | |
download | qtwebkit-cd44dc59cdfc39534aef4d417e9f3c412e3be139.tar.gz |
Imported WebKit commit fce473cb4d55aa9fe9d0b0322a2fffecb731b961 (http://svn.webkit.org/repository/webkit/trunk@106560)
Diffstat (limited to 'Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp')
-rw-r--r-- | Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp b/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp index 32de21af7..f7e2b8514 100644 --- a/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp +++ b/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp @@ -69,6 +69,64 @@ private: QString m_defaultValue; }; +class AuthenticationDialogContextObject : public QObject { + Q_OBJECT + Q_PROPERTY(QString hostname READ hostname CONSTANT) + Q_PROPERTY(QString realm READ realm CONSTANT) + Q_PROPERTY(QString prefilledUsername READ prefilledUsername CONSTANT) + +public: + AuthenticationDialogContextObject(const QString& hostname, const QString& realm, const QString& prefilledUsername) + : QObject() + , m_hostname(hostname) + , m_realm(realm) + , m_prefilledUsername(prefilledUsername) + { + } + + QString hostname() const { return m_hostname; } + QString realm() const { return m_realm; } + QString prefilledUsername() const { return m_prefilledUsername; } + +public slots: + void accept(const QString& username, const QString& password) { emit accepted(username, password); } + void reject() { emit rejected(); } + +signals: + void accepted(const QString& username, const QString& password); + void rejected(); + +private: + QString m_hostname; + QString m_realm; + QString m_prefilledUsername; +}; + +class CertificateVerificationDialogContextObject : public QObject { + Q_OBJECT + Q_PROPERTY(QString hostname READ hostname CONSTANT) + +public: + CertificateVerificationDialogContextObject(const QString& hostname) + : QObject() + , m_hostname(hostname) + { + } + + QString hostname() const { return m_hostname; } + +public slots: + void accept() { emit accepted(); } + void reject() { emit rejected(); } + +signals: + void accepted(); + void rejected(); + +private: + QString m_hostname; +}; + bool QtDialogRunner::initForAlert(QDeclarativeComponent* component, QQuickItem* dialogParent, const QString& message) { DialogContextObject* contextObject = new DialogContextObject(message); @@ -103,6 +161,32 @@ bool QtDialogRunner::initForPrompt(QDeclarativeComponent* component, QQuickItem* return true; } +bool QtDialogRunner::initForAuthentication(QDeclarativeComponent* component, QQuickItem* dialogParent, const QString& hostname, const QString& realm, const QString& prefilledUsername) +{ + AuthenticationDialogContextObject* contextObject = new AuthenticationDialogContextObject(hostname, realm, prefilledUsername); + if (!createDialog(component, dialogParent, contextObject)) + return false; + + connect(contextObject, SIGNAL(accepted(QString, QString)), SLOT(onAuthenticationAccepted(QString, QString))); + connect(contextObject, SIGNAL(accepted(QString, QString)), SLOT(quit())); + connect(contextObject, SIGNAL(rejected()), SLOT(quit())); + + return true; +} + +bool QtDialogRunner::initForCertificateVerification(QDeclarativeComponent* component, QQuickItem* dialogParent, const QString& hostname) +{ + CertificateVerificationDialogContextObject* contextObject = new CertificateVerificationDialogContextObject(hostname); + if (!createDialog(component, dialogParent, contextObject)) + return false; + + connect(contextObject, SIGNAL(accepted()), SLOT(onAccepted())); + connect(contextObject, SIGNAL(accepted()), SLOT(quit())); + connect(contextObject, SIGNAL(rejected()), SLOT(quit())); + + return true; +} + bool QtDialogRunner::createDialog(QDeclarativeComponent* component, QQuickItem* dialogParent, QObject* contextObject) { QDeclarativeContext* baseContext = component->creationContext(); |