~rpadovani/webbrowser-app/addressBarFullWidth

« back to all changes in this revision

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

  • Committer: Riccardo Padovani
  • Date: 2015-06-12 09:40:27 UTC
  • mfrom: (761.75.148 webbrowser-app)
  • Revision ID: riccardo@rpadovani.com-20150612094027-m45snw575knv09py
Merge from upstream and fix conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
    }
76
76
}
77
77
 
78
 
static QString currentArchitecturePathName()
79
 
{
80
 
#if defined(Q_PROCESSOR_X86_32)
81
 
    return QLatin1String("i386-linux-gnu");
82
 
#elif defined(Q_PROCESSOR_X86_64)
83
 
    return QLatin1String("x86_64-linux-gnu");
84
 
#elif defined(Q_PROCESSOR_ARM)
85
 
    return QLatin1String("arm-linux-gnueabihf");
86
 
#else
87
 
#error Unable to determine target architecture
88
 
#endif
89
 
}
90
 
 
91
 
static bool canUseOxide()
92
 
{
93
 
    // Use a runtime hint to transparently know if oxide
94
 
    // can be used as a backend without the user/dev having
95
 
    // to update its app or change something in the Exec args.
96
 
    // Version 1.1 of ubuntu apparmor policy allows this file to
97
 
    // be accessed whereas v1.0 only knows about qtwebkit.
98
 
    QString oxideHintLocation =
99
 
        QString("/usr/lib/%1/oxide-qt/oxide-renderer")
100
 
            .arg(currentArchitecturePathName());
101
 
 
102
 
    return QFile(oxideHintLocation).open(QIODevice::ReadOnly);
103
 
}
104
 
 
105
78
}
106
79
 
107
80
const QString WebappContainer::URL_PATTERN_SEPARATOR = ",";
110
83
 
111
84
WebappContainer::WebappContainer(int& argc, char** argv):
112
85
    BrowserApplication(argc, argv),
113
 
    m_withOxide(canUseOxide()),
114
86
    m_storeSessionCookies(false),
115
87
    m_backForwardButtonsVisible(false),
116
88
    m_addressBarVisible(false),
122
94
 
123
95
bool WebappContainer::initialize()
124
96
{
 
97
    earlyEnvironment();
 
98
 
125
99
    if (BrowserApplication::initialize("webcontainer/webapp-container.qml")) {
126
100
        parseCommandLine();
127
101
        parseExtraConfiguration();
146
120
        m_window->setProperty("chromeVisible", m_addressBarVisible);
147
121
        m_window->setProperty("accountProvider", m_accountProvider);
148
122
 
149
 
        qDebug() << "Using" << (m_withOxide ? "Oxide" : "QtWebkit") << "as the web engine backend";
150
 
        m_window->setProperty("oxide", m_withOxide);
151
 
 
152
123
        m_window->setProperty("webappUrlPatterns", m_webappUrlPatterns);
153
124
        QQmlContext* context = m_engine->rootContext();
154
125
        if (m_storeSessionCookies) {
301
272
    out << "  --webappUrlPatterns=URL_PATTERNS    list of comma-separated url patterns (wildcard based) that the webapp is allowed to navigate to" << endl;
302
273
    out << "  --accountProvider=PROVIDER_NAME     Online account provider for the application if the application is to reuse a local account." << endl;
303
274
    out << "  --store-session-cookies             store session cookies on disk" << endl;
 
275
    out << "  --enable-media-hub-audio            enable media-hub for audio playback" << endl;
304
276
    out << "  --user-agent-string=USER_AGENT      overrides the default User Agent with the provided one." << endl;
305
277
    out << "Chrome options (if none specified, no chrome is shown by default):" << endl;
306
278
    out << "  --enable-back-forward               enable the display of the back and forward buttons (implies --enable-addressbar)" << endl;
307
279
    out << "  --enable-addressbar                 enable the display of a minimal chrome (favicon and title)" << endl;
308
280
}
309
281
 
 
282
void WebappContainer::earlyEnvironment()
 
283
{
 
284
    Q_FOREACH(const QString& argument, m_arguments) {
 
285
        if (argument.startsWith("--enable-media-hub-audio")) {
 
286
            qputenv("OXIDE_ENABLE_MEDIA_HUB_AUDIO", QString("1").toLocal8Bit().constData());
 
287
        }
 
288
    }
 
289
}
 
290
 
310
291
void WebappContainer::parseCommandLine()
311
292
{
312
293
    Q_FOREACH(const QString& argument, m_arguments) {
313
 
        if (argument == "--webkit") {
314
 
            // force webkit
315
 
            m_withOxide = false;
316
 
        } else if (argument == "--oxide") {
317
 
            // force oxide
318
 
            m_withOxide = true;
319
 
        } else if (argument.startsWith("--webappModelSearchPath=")) {
 
294
        if (argument.startsWith("--webappModelSearchPath=")) {
320
295
            m_webappModelSearchPath = argument.split("--webappModelSearchPath=")[1];
321
296
        } else if (argument.startsWith("--webapp=")) {
322
297
            // We use the name as a reference instead of the URL with a subsequent step to match it with a webapp.