31
26
#include <QtCore/QRegularExpression>
32
27
#include <QtCore/QTextStream>
33
28
#include <QtQuick/QQuickWindow>
34
#include <QtQml/QQmlEngine>
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());
68
m_window->setProperty("applicationName", QCoreApplication::applicationName());
76
void WebappContainer::qmlEngineCreated(QQmlEngine * engine)
78
registerCookieQmlTypes(engine);
81
bool WebappContainer::registerCookieQmlTypes(QQmlEngine * engine)
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");
93
65
void WebappContainer::printUsage() const
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;
127
QString WebappContainer::accountProvider() const
129
QString accountProvider;
130
Q_FOREACH(const QString& argument, m_arguments) {
131
if (argument.startsWith("--accountProvider=")) {
132
accountProvider = argument.split("--accountProvider=")[1];
136
return accountProvider;
139
95
QString WebappContainer::webappName() const
141
97
Q_FOREACH(const QString& argument, m_arguments) {