~mardy/signon-ui/lp1271052

« back to all changes in this revision

Viewing changes to src/browser-process/browser-process.cpp

  • Committer: Tarmac
  • Author(s): alberto.mardegan at canonical
  • Date: 2013-10-08 16:41:30 UTC
  • mfrom: (112.2.4 lp1231691)
  • Revision ID: tarmac-20131008164130-ksfasoeqkoius5v6
Let the client override the Page component.
. Fixes: https://bugs.launchpad.net/bugs/1231691.

Approved by PS Jenkins bot, Ken VanDine.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
{
41
41
    Q_OBJECT
42
42
    Q_DECLARE_PUBLIC(BrowserProcess)
 
43
    Q_PROPERTY(QUrl pageComponentUrl READ pageComponentUrl CONSTANT)
43
44
    Q_PROPERTY(QUrl currentUrl READ currentUrl WRITE setCurrentUrl)
44
45
    Q_PROPERTY(QUrl startUrl READ startUrl CONSTANT)
45
46
    Q_PROPERTY(QUrl finalUrl READ finalUrl CONSTANT)
51
52
    void processClientRequest();
52
53
 
53
54
    void setCurrentUrl(const QUrl &url);
 
55
    QUrl pageComponentUrl() const;
54
56
    QUrl currentUrl() const { return m_currentUrl; }
55
57
    QUrl startUrl() const { return m_startUrl; }
56
58
    QUrl finalUrl() const { return m_finalUrl; }
109
111
    delete m_dialog;
110
112
}
111
113
 
 
114
QUrl BrowserProcessPrivate::pageComponentUrl() const
 
115
{
 
116
    /* We define the X-PageComponent key to let the clients override the QML
 
117
     * component to be used to build the authentication page.
 
118
     * To prevent a malicious client to show it's own UI, we require that the
 
119
     * file path begins with "/usr/share/signon-ui/" (where Ubuntu click
 
120
     * packages cannot install files).
 
121
     */
 
122
    QUrl providedUrl = m_clientData.value("X-PageComponent").toString();
 
123
    if (providedUrl.isValid() && providedUrl.isLocalFile() &&
 
124
        providedUrl.path().startsWith("/usr/share/signon-ui/")) {
 
125
        return providedUrl;
 
126
    } else {
 
127
        return QStringLiteral("DefaultPage.qml");
 
128
    }
 
129
}
 
130
 
112
131
void BrowserProcessPrivate::processClientRequest()
113
132
{
114
133
    TRACE();
181
200
    QObject::connect(m_dialog, SIGNAL(finished(int)),
182
201
                     this, SLOT(onFinished()));
183
202
 
184
 
    QUrl webview("qrc:/webview.qml");
 
203
    QUrl webview("qrc:/MainWindow.qml");
185
204
    QDir qmlDir("/usr/share/signon-ui/qml");
186
205
    if (qmlDir.exists())
187
206
    {
188
 
        QFileInfo qmlFile(qmlDir.absolutePath() + "/webview.qml");
 
207
        QFileInfo qmlFile(qmlDir.absolutePath() + "/MainWindow.qml");
189
208
        if (qmlFile.exists())
190
209
            webview.setUrl(qmlFile.absoluteFilePath());
191
210
    }