~abreu-alexandre/webbrowser-app/with-oxide

« back to all changes in this revision

Viewing changes to src/app/webcontainer/webapp-container.cpp

  • Committer: Olivier Tilloy
  • Date: 2014-03-17 11:08:33 UTC
  • mfrom: (419.1.41 webbrowser-app)
  • Revision ID: olivier.tilloy@canonical.com-20140317110833-q3ayse1fmr9k3hnf
Merge the latest changes from trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include "config.h"
20
20
#include "webapp-container.h"
21
21
 
22
 
#include "cookiestore.h"
23
 
#include "sqlitecookiestore.h"
24
 
#include "onlineaccountscookiestore.h"
25
 
 
26
 
 
27
22
// Qt
28
23
#include <QtCore/QCoreApplication>
29
24
#include <QtCore/QDebug>
31
26
#include <QtCore/QRegularExpression>
32
27
#include <QtCore/QTextStream>
33
28
#include <QtQuick/QQuickWindow>
34
 
#include <QtQml/QQmlEngine>
35
 
#include <QtQml>
36
 
 
37
29
 
38
30
WebappContainer::WebappContainer(int& argc, char** argv)
39
31
    : BrowserApplication(argc, argv)
57
49
        m_window->setProperty("backForwardButtonsVisible", m_arguments.contains("--enable-back-forward"));
58
50
        m_window->setProperty("addressBarVisible", m_arguments.contains("--enable-addressbar"));
59
51
        m_window->setProperty("webappUrlPatterns", webappUrlPatterns());
60
 
        m_window->setProperty("accountProvider", accountProvider());
61
52
        // When a webapp is being launched by name, the URL is pulled from its 'homepage'.
62
53
        if (name.isEmpty()) {
63
54
            QList<QUrl> urls = this->urls();
65
56
                m_window->setProperty("url", urls.first());
66
57
            }
67
58
        }
68
 
        m_window->setProperty("applicationName", QCoreApplication::applicationName());
69
 
 
70
59
        return true;
71
60
    } else {
72
61
        return false;
73
62
    }
74
63
}
75
64
 
76
 
void WebappContainer::qmlEngineCreated(QQmlEngine * engine)
77
 
{
78
 
    registerCookieQmlTypes(engine);
79
 
}
80
 
 
81
 
bool WebappContainer::registerCookieQmlTypes(QQmlEngine * engine)
82
 
{
83
 
    if (engine)
84
 
    {
85
 
        qmlRegisterType<CookieStore>("Ubuntu.WebContainer.Components", 0, 1, "CookieStore");
86
 
        qmlRegisterType<SqliteCookieStore>("Ubuntu.WebContainer.Components", 0, 1, "SqliteCookieStore");
87
 
        qmlRegisterType<OnlineAccountsCookieStore>("Ubuntu.WebContainer.Components", 0, 1, "OnlineAccountsCookieStore");
88
 
        return true;
89
 
    }
90
 
    return false;
91
 
}
92
 
 
93
65
void WebappContainer::printUsage() const
94
66
{
95
67
    QTextStream out(stdout);
96
68
    QString command = QFileInfo(QCoreApplication::applicationFilePath()).fileName();
97
 
    out << "Usage: " << command << " [-h|--help] [--fullscreen] [--maximized] [--inspector] "
98
 
                                   "[--app-id=APP_ID] [--homepage=URL] [--webapp[=name]] "
99
 
                                   "[--webappModelSearchPath=PATH] [--webappUrlPatterns=URL_PATTERNS] "
100
 
                                   "[--enable-back-forward] [--enable-addressbar] [URL]" << endl;
 
69
    out << "Usage: " << command << " [-h|--help] [--fullscreen] [--maximized] [--inspector] [--app-id=APP_ID] [--homepage=URL] [--webapp[=name]] [--webappModelSearchPath=PATH] [--webappUrlPatterns=URL_PATTERNS] [--enable-back-forward] [--enable-addressbar] [URL]" << endl;
101
70
    out << "Options:" << endl;
102
71
    out << "  -h, --help                          display this help message and exit" << endl;
103
72
    out << "  --fullscreen                        display full screen" << endl;
108
77
    out << "  --webapp[=name]                     try to match the webapp by name with an installed integration script (if any)" << endl;
109
78
    out << "  --webappModelSearchPath=PATH        alter the search path for installed webapps and set it to PATH. PATH can be an absolute or path relative to CWD" << endl;
110
79
    out << "  --webappUrlPatterns=URL_PATTERNS    list of comma-separated url patterns (wildcard based) that the webapp is allowed to navigate to" << endl;
111
 
    out << "  --accountProvider=PROVIDER_NAME     Online account provider for the application if the application is to reuse a local account." << endl;
112
80
    out << "Chrome options (if none specified, no chrome is shown by default):" << endl;
113
81
    out << "  --enable-back-forward               enable the display of the back and forward buttons" << endl;
114
82
    out << "  --enable-addressbar                 enable the display of the address bar" << endl;
124
92
    return QString();
125
93
}
126
94
 
127
 
QString WebappContainer::accountProvider() const
128
 
{
129
 
    QString accountProvider;
130
 
    Q_FOREACH(const QString& argument, m_arguments) {
131
 
        if (argument.startsWith("--accountProvider=")) {
132
 
            accountProvider = argument.split("--accountProvider=")[1];
133
 
            break;
134
 
        }
135
 
    }
136
 
    return accountProvider;
137
 
}
138
 
 
139
95
QString WebappContainer::webappName() const
140
96
{
141
97
    Q_FOREACH(const QString& argument, m_arguments) {