diff -Nru webbrowser-app-0.23+14.04.20140324/CMakeLists.txt webbrowser-app-0.23+14.04.20140328.3/CMakeLists.txt --- webbrowser-app-0.23+14.04.20140324/CMakeLists.txt 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/CMakeLists.txt 2014-03-28 17:07:01.000000000 +0000 @@ -29,6 +29,7 @@ endif() find_package(Qt5Core REQUIRED) +find_package(Qt5Gui REQUIRED) find_package(Qt5Sql REQUIRED) find_package(Qt5Widgets REQUIRED) find_package(Qt5Quick REQUIRED) diff -Nru webbrowser-app-0.23+14.04.20140324/debian/changelog webbrowser-app-0.23+14.04.20140328.3/debian/changelog --- webbrowser-app-0.23+14.04.20140324/debian/changelog 2014-04-01 13:40:14.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/debian/changelog 2014-04-01 13:40:14.000000000 +0000 @@ -1,3 +1,11 @@ +webbrowser-app (0.23+14.04.20140328.3-0ubuntu1) trusty; urgency=low + + [ Olivier Tilloy ] + * Land the master Oxide support branch. See individual revisions for + details. (LP: #1271756) + + -- Ubuntu daily release Fri, 28 Mar 2014 17:07:09 +0000 + webbrowser-app (0.23+14.04.20140324-0ubuntu1) trusty; urgency=low [ Alexandre Abreu ] diff -Nru webbrowser-app-0.23+14.04.20140324/debian/control webbrowser-app-0.23+14.04.20140328.3/debian/control --- webbrowser-app-0.23+14.04.20140324/debian/control 2014-04-01 13:40:14.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/debian/control 2014-04-01 13:40:14.000000000 +0000 @@ -8,8 +8,8 @@ hardening-wrapper, python, libqt5sql5-sqlite, - libqt5webkit5-dev, libqt5webkit5-qmlwebkitplugin, + liboxideqt-qmlplugin, qt5-default, qt5-qmake, qtbase5-dev, @@ -19,6 +19,7 @@ qtdeclarative5-qtquick2-plugin, qtdeclarative5-test-plugin, qtdeclarative5-ubuntu-ui-toolkit-plugin, + xvfb, Standards-Version: 3.9.4 Homepage: https://launchpad.net/webbrowser-app # If you aren't a member of ~phablet-team but need to upload packaging changes, @@ -30,7 +31,7 @@ Multi-Arch: foreign Depends: ${misc:Depends}, ${shlibs:Depends}, - libqt5webkit5-qmlwebkitplugin, + liboxideqt-qmlplugin, qtdeclarative5-qtquick2-plugin, qtdeclarative5-ubuntu-ui-extras-browser-plugin (= ${binary:Version}), qtdeclarative5-ubuntu-ui-toolkit-plugin, @@ -50,6 +51,7 @@ Depends: ${misc:Depends}, ${shlibs:Depends}, unity-webapps-qml, + libqt5webkit5-qmlwebkitplugin, webbrowser-app (= ${binary:Version}), Description: Ubuntu web applications container A lightweight webapps container tailored for Ubuntu, based on the Webkit @@ -62,6 +64,7 @@ ${shlibs:Depends}, libqt5sql5-sqlite, libqt5webkit5-qmlwebkitplugin, + liboxideqt-qmlplugin, qtdeclarative5-qtquick2-plugin, qtdeclarative5-ubuntu-ui-extras-browser-plugin-assets (>= ${source:Version}), qtdeclarative5-ubuntu-ui-toolkit-plugin, diff -Nru webbrowser-app-0.23+14.04.20140324/po/webbrowser-app.pot webbrowser-app-0.23+14.04.20140328.3/po/webbrowser-app.pot --- webbrowser-app-0.23+14.04.20140324/po/webbrowser-app.pot 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/po/webbrowser-app.pot 2014-03-28 17:07:01.000000000 +0000 @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: webbrowser-app\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-11-13 09:10+0100\n" +"POT-Creation-Date: 2014-03-26 10:59+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,14 +17,6 @@ "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: src/app/ActivityView.qml:36 src/app/Chrome.qml:127 -msgid "Activity" -msgstr "" - -#: src/app/ActivityView.qml:54 -msgid "Bookmarks" -msgstr "" - #: src/app/AlertDialog.qml:24 msgid "JavaScript Alert" msgstr "" @@ -57,6 +49,18 @@ msgid "Cancel" msgstr "" +#: src/app/BeforeUnloadDialog.qml:24 +msgid "Confirm Navigation" +msgstr "" + +#: src/app/BeforeUnloadDialog.qml:28 +msgid "Leave" +msgstr "" + +#: src/app/BeforeUnloadDialog.qml:33 +msgid "Stay" +msgstr "" + #: src/app/CertificateVerificationDialog.qml:24 msgid "This connection is untrusted" msgstr "" @@ -85,6 +89,10 @@ msgid "Forward" msgstr "" +#: src/app/Chrome.qml:127 src/app/webbrowser/ActivityView.qml:36 +msgid "Activity" +msgstr "" + #: src/app/ConfirmDialog.qml:24 msgid "JavaScript Confirmation" msgstr "" @@ -134,52 +142,6 @@ msgid "The website %1:%2 requires authentication." msgstr "" -#. TRANSLATORS: %1 refers to the number of open tabs -#: src/app/TabsList.qml:37 -#, qt-format -msgid "Currently viewing (%1)" -msgstr "" - -#: src/app/TabsList.qml:68 -msgid "+" -msgstr "" - -#: src/app/TimelineView.qml:83 -msgid "Today" -msgstr "" - -#: src/app/TimelineView.qml:85 -msgid "Yesterday" -msgstr "" - -#: src/app/TimelineView.qml:87 -msgid "Last 7 Days" -msgstr "" - -#: src/app/TimelineView.qml:89 -msgid "This Month" -msgstr "" - -#: src/app/TimelineView.qml:91 -msgid "This Year" -msgstr "" - -#: src/app/TimelineView.qml:93 -msgid "Older" -msgstr "" - -#: src/app/TimelineView.qml:276 -msgid "(local files)" -msgstr "" - -#: src/app/TimelineView.qml:278 -msgid "(other)" -msgstr "" - -#: src/app/WebViewImpl.qml:52 -msgid "This page wants to know your device’s location." -msgstr "" - #. TRANSLATORS: This is a free-form list of keywords associated to the 'Back' action. #. Keywords may actually be sentences, and must be separated by semi-colons. #: src/app/actions/Back.qml:26 @@ -266,24 +228,88 @@ msgid "Leave Page" msgstr "" -#. TRANSLATORS: %1 refers to the current page’s title -#: src/app/webapp-container.qml:44 src/app/webbrowser-app.qml:35 +#: src/app/webbrowser/ActivityView.qml:54 +msgid "Bookmarks" +msgstr "" + +#. TRANSLATORS: %1 refers to the number of open tabs +#: src/app/webbrowser/TabsList.qml:37 #, qt-format -msgid "%1 - Ubuntu Web Browser" +msgid "Currently viewing (%1)" msgstr "" -#: src/app/webapp-container.qml:46 src/app/webbrowser-app.qml:37 -msgid "Ubuntu Web Browser" +#: src/app/webbrowser/TabsList.qml:68 +msgid "+" +msgstr "" + +#: src/app/webbrowser/TimelineView.qml:84 +msgid "Today" msgstr "" -#: src/app/webbrowser-app.desktop.in:3 +#: src/app/webbrowser/TimelineView.qml:86 +msgid "Yesterday" +msgstr "" + +#: src/app/webbrowser/TimelineView.qml:88 +msgid "Last 7 Days" +msgstr "" + +#: src/app/webbrowser/TimelineView.qml:90 +msgid "This Month" +msgstr "" + +#: src/app/webbrowser/TimelineView.qml:92 +msgid "This Year" +msgstr "" + +#: src/app/webbrowser/TimelineView.qml:94 +msgid "Older" +msgstr "" + +#: src/app/webbrowser/TimelineView.qml:277 +msgid "(local files)" +msgstr "" + +#: src/app/webbrowser/TimelineView.qml:279 +msgid "(other)" +msgstr "" + +#: src/app/webbrowser/webbrowser-app.desktop.in:3 msgid "Browser" msgstr "" -#: src/app/webbrowser-app.desktop.in:4 +#: src/app/webbrowser/webbrowser-app.desktop.in:4 msgid "Web Browser" msgstr "" -#: src/app/webbrowser-app.desktop.in:5 +#: src/app/webbrowser/webbrowser-app.desktop.in:5 msgid "Browse the World Wide Web" msgstr "" + +#. TRANSLATORS: %1 refers to the current page’s title +#: src/app/webbrowser/webbrowser-app.qml:35 +#: src/app/webcontainer/webapp-container.qml:44 +#, qt-format +msgid "%1 - Ubuntu Web Browser" +msgstr "" + +#: src/app/webbrowser/webbrowser-app.qml:37 +#: src/app/webcontainer/webapp-container.qml:46 +msgid "Ubuntu Web Browser" +msgstr "" + +#: src/app/webcontainer/AccountsLoginPage.qml:70 +msgid "No local account found for " +msgstr "" + +#: src/app/webcontainer/AccountsLoginPage.qml:75 +msgid "Skip account creation step" +msgstr "" + +#: src/app/webcontainer/AccountsLoginPage.qml:124 +msgid "Add account" +msgstr "" + +#: src/app/webcontainer/AccountsView.qml:38 +msgid "Select an account" +msgstr "" diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/AlertDialog.qml webbrowser-app-0.23+14.04.20140328.3/src/app/AlertDialog.qml --- webbrowser-app-0.23+14.04.20140324/src/app/AlertDialog.qml 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/AlertDialog.qml 2014-03-28 17:07:01.000000000 +0000 @@ -26,8 +26,8 @@ Button { text: i18n.tr("OK") - onClicked: model.dismiss() + onClicked: model.accept() } Component.onCompleted: show() -} \ No newline at end of file +} diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/BeforeUnloadDialog.qml webbrowser-app-0.23+14.04.20140328.3/src/app/BeforeUnloadDialog.qml --- webbrowser-app-0.23+14.04.20140324/src/app/BeforeUnloadDialog.qml 1970-01-01 00:00:00.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/BeforeUnloadDialog.qml 2014-03-28 17:07:01.000000000 +0000 @@ -0,0 +1,38 @@ +/* + * Copyright 2014 Canonical Ltd. + * + * This file is part of webbrowser-app. + * + * webbrowser-app is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * webbrowser-app is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import QtQuick 2.0 +import Ubuntu.Components 0.1 +import Ubuntu.Components.Popups 0.1 as Popups + +Popups.Dialog { + title: i18n.tr("Confirm Navigation") + text: model.message + + Button { + text: i18n.tr("Leave") + onClicked: model.accept() + } + + Button { + text: i18n.tr("Stay") + onClicked: model.reject() + } + + Component.onCompleted: show() +} diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/browserapplication.cpp webbrowser-app-0.23+14.04.20140328.3/src/app/browserapplication.cpp --- webbrowser-app-0.23+14.04.20140324/src/app/browserapplication.cpp 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/browserapplication.cpp 2014-03-28 17:07:01.000000000 +0000 @@ -17,10 +17,13 @@ */ // Qt +#include #include +#include #include #include #include +#include #include // local @@ -29,7 +32,7 @@ #include "webbrowser-window.h" BrowserApplication::BrowserApplication(int& argc, char** argv) - : QApplication(argc, argv) + : QGuiApplication(argc, argv) , m_engine(0) , m_window(0) , m_component(0) @@ -37,6 +40,25 @@ { m_arguments = arguments(); m_arguments.removeFirst(); + + // The testability driver is only loaded by QApplication but not by + // QGuiApplication (see https://codereview.qt-project.org/#change,66513). + // Let’s load the testability driver on our own. + if (m_arguments.contains(QLatin1String("-testability")) || + qgetenv("QT_LOAD_TESTABILITY") == "1") { + QLibrary testLib(QLatin1String("qttestability")); + if (testLib.load()) { + typedef void (*TasInitialize)(void); + TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init"); + if (initFunction) { + initFunction(); + } else { + qCritical("Library qttestability resolve failed!"); + } + } else { + qCritical("Library qttestability load failed!"); + } + } } BrowserApplication::~BrowserApplication() @@ -80,6 +102,11 @@ QString appPkgName = qgetenv("APP_ID").split('_').first(); QCoreApplication::setApplicationName(appPkgName); + // Enable compositing in oxide + QOpenGLContext* glcontext = new QOpenGLContext(this); + glcontext->create(); + QSGContext::setSharedOpenGLContext(glcontext); + bool inspector = m_arguments.contains("--inspector"); if (inspector) { QString host; @@ -113,7 +140,7 @@ m_webbrowserWindowProxy = new WebBrowserWindow(); context->setContextProperty("webbrowserWindowProxy", m_webbrowserWindowProxy); - QObject* browser = m_component->create(); + QObject* browser = m_component->beginCreate(context); m_window = qobject_cast(browser); m_webbrowserWindowProxy->setWindow(m_window); diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/browserapplication.h webbrowser-app-0.23+14.04.20140328.3/src/app/browserapplication.h --- webbrowser-app-0.23+14.04.20140324/src/app/browserapplication.h 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/browserapplication.h 2014-03-28 17:07:01.000000000 +0000 @@ -24,14 +24,14 @@ #include #include #include -#include +#include class QQmlComponent; class QQmlEngine; class QQuickWindow; class WebBrowserWindow; -class BrowserApplication : public QApplication +class BrowserApplication : public QGuiApplication { Q_OBJECT @@ -49,11 +49,11 @@ QStringList m_arguments; QQmlEngine* m_engine; QQuickWindow* m_window; + QQmlComponent* m_component; private: QString appId() const; - QQmlComponent* m_component; WebBrowserWindow *m_webbrowserWindowProxy; }; diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/CMakeLists.txt webbrowser-app-0.23+14.04.20140328.3/src/app/CMakeLists.txt --- webbrowser-app-0.23+14.04.20140324/src/app/CMakeLists.txt 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/CMakeLists.txt 2014-03-28 17:07:01.000000000 +0000 @@ -16,6 +16,8 @@ qt5_use_modules(${COMMONLIB} Core Network Qml Quick Widgets) +include_directories(${Qt5Quick_PRIVATE_INCLUDE_DIRS}) + file(GLOB QML_FILES *.qml) install(FILES ${QML_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/webbrowser-app) install(DIRECTORY actions DESTINATION ${CMAKE_INSTALL_DATADIR}/webbrowser-app diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/PanelLoader.qml webbrowser-app-0.23+14.04.20140328.3/src/app/PanelLoader.qml --- webbrowser-app-0.23+14.04.20140324/src/app/PanelLoader.qml 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/PanelLoader.qml 2014-03-28 17:07:01.000000000 +0000 @@ -75,7 +75,10 @@ url: currentWebview ? currentWebview.url : "" - loading: currentWebview ? currentWebview.loading || (currentWebview.loadProgress === 0) : false + loading: currentWebview ? currentWebview.loading + // workaround for https://bugs.launchpad.net/oxide/+bug/1290821 + && !currentWebview.lastLoadStopped + : false loadProgress: currentWebview ? currentWebview.loadProgress : 0 canGoBack: currentWebview ? currentWebview.canGoBack : false diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/PromptDialog.qml webbrowser-app-0.23+14.04.20140328.3/src/app/PromptDialog.qml --- webbrowser-app-0.23+14.04.20140324/src/app/PromptDialog.qml 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/PromptDialog.qml 2014-03-28 17:07:01.000000000 +0000 @@ -42,5 +42,11 @@ onClicked: model.reject() } + Binding { + target: model + property: "currentValue" + value: input.text + } + Component.onCompleted: show() -} \ No newline at end of file +} diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/BookmarksView.qml webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/BookmarksView.qml --- webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/BookmarksView.qml 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/BookmarksView.qml 2014-03-28 17:07:01.000000000 +0000 @@ -50,8 +50,8 @@ url: model.url label: model.title ? model.title : model.url - property url thumbnailSource: "image://webthumbnail/" + model.url - thumbnail: WebThumbnailer.thumbnailExists(model.url) ? thumbnailSource : "" + //property url thumbnailSource: "image://webthumbnail/" + model.url + //thumbnail: WebThumbnailer.thumbnailExists(model.url) ? thumbnailSource : "" canBookmark: true bookmarksModel: bookmarksView.bookmarksModel diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/Browser.qml webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/Browser.qml --- webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/Browser.qml 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/Browser.qml 2014-03-28 17:07:01.000000000 +0000 @@ -17,8 +17,6 @@ */ import QtQuick 2.0 -import QtWebKit 3.1 -import QtWebKit.experimental 1.0 import Ubuntu.Components 0.1 import webbrowserapp.private 0.1 import "../actions" as Actions @@ -48,7 +46,7 @@ }, Actions.Bookmark { enabled: currentWebview - onTriggered: bookmarksModel.add(currentWebview.url, currentWebview.title, currentWebview.icon) + onTriggered: bookmarksModel.add(currentWebview.url, currentWebview.title, "")//currentWebview.icon) }, Actions.NewTab { onTriggered: newTab("", true) @@ -73,7 +71,7 @@ ErrorSheet { anchors.fill: webviewContainer - visible: currentWebview ? (currentWebview.lastLoadRequestStatus === WebView.LoadFailedStatus) : false + visible: currentWebview ? currentWebview.lastLoadFailed : false url: currentWebview ? currentWebview.url : "" onRefreshClicked: currentWebview.reload() } @@ -217,7 +215,7 @@ enabled: stack.depth === 0 visible: currentWebview === webview - experimental.preferences.developerExtrasEnabled: developerExtrasEnabled + //experimental.preferences.developerExtrasEnabled: developerExtrasEnabled contextualActions: ActionList { Actions.OpenLinkInNewTab { @@ -244,25 +242,9 @@ onNewTabRequested: newTab(url, true) - WebviewThumbnailer { - id: thumbnailer - webview: webview - targetSize: Qt.size(units.gu(12), units.gu(12)) - property url thumbnailSource: "image://webthumbnail/" + webview.url - onThumbnailRendered: { - if (url == webview.url) { - webview.thumbnail = thumbnailer.thumbnailSource - } - } - } - property url thumbnail: (url && thumbnailer.thumbnailExists()) ? thumbnailer.thumbnailSource : "" - onLoadingChanged: { - if (loadRequest.status === WebView.LoadSucceededStatus) { + if (lastLoadSucceeded) { _historyModel.add(webview.url, webview.title, webview.icon) - if (!thumbnailer.thumbnailExists()) { - thumbnailer.renderThumbnail() - } } } } diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/CMakeLists.txt webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/CMakeLists.txt --- webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/CMakeLists.txt 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/CMakeLists.txt 2014-03-28 17:07:01.000000000 +0000 @@ -19,25 +19,13 @@ bookmarks-model.cpp settings.cpp webbrowser-app.cpp - webthumbnail-provider.cpp - webthumbnail-utils.cpp - webview-thumbnailer.cpp ) add_executable(${WEBBROWSER_APP} ${WEBBROWSER_APP_SRC}) target_link_libraries(${WEBBROWSER_APP} ${COMMONLIB}) -qt5_use_modules(${WEBBROWSER_APP} Core Gui Quick Sql WebKit) - -# work around the lack of a public cmake module for Qt5V8 -set(Qt5V8_PRIVATE_INCLUDE_DIRS - "/usr/include/qt5/QtV8/${Qt5Qml_VERSION_STRING}" - "/usr/include/qt5/QtV8/${Qt5Qml_VERSION_STRING}/QtV8") -include_directories(${Qt5Core_PRIVATE_INCLUDE_DIRS} - ${Qt5V8_PRIVATE_INCLUDE_DIRS} - ${Qt5Quick_PRIVATE_INCLUDE_DIRS} - ${Qt5WebKit_PRIVATE_INCLUDE_DIRS}) +qt5_use_modules(${WEBBROWSER_APP} Core Gui Quick Sql) install(TARGETS ${WEBBROWSER_APP} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/TabsList.qml webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/TabsList.qml --- webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/TabsList.qml 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/TabsList.qml 2014-03-28 17:07:01.000000000 +0000 @@ -82,7 +82,7 @@ url: model.url label: model.title ? model.title : model.url - thumbnail: model.webview.thumbnail + //thumbnail: model.webview.thumbnail canClose: true onStateChanged: listview.state = state diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/TimelineView.qml webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/TimelineView.qml --- webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/TimelineView.qml 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/TimelineView.qml 2014-03-28 17:07:01.000000000 +0000 @@ -18,7 +18,7 @@ import QtQuick 2.0 import Ubuntu.Components 0.1 -import Ubuntu.Components.Extras.Browser 0.1 +//import Ubuntu.Components.Extras.Browser 0.1 import Ubuntu.Components.ListItems 0.1 as ListItem import webbrowserapp.private 0.1 @@ -173,8 +173,8 @@ url: model.url label: model.title ? model.title : model.url - property url thumbnailSource: "image://webthumbnail/" + model.url - thumbnail: WebThumbnailer.thumbnailExists(model.url) ? thumbnailSource : "" + //property url thumbnailSource: "image://webthumbnail/" + model.url + //thumbnail: WebThumbnailer.thumbnailExists(model.url) ? thumbnailSource : "" canBookmark: true bookmarksModel: timelineView.bookmarksModel @@ -282,8 +282,8 @@ } } - property url thumbnailSource: "image://webthumbnail/" + model.domain - thumbnail: WebThumbnailer.thumbnailExists(model.domain) ? thumbnailSource : "" + //property url thumbnailSource: "image://webthumbnail/" + model.domain + //thumbnail: WebThumbnailer.thumbnailExists(model.domain) ? thumbnailSource : "" onClicked: { if ((timeline.currentIndex == timelineIndex) && diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/webbrowser-app.cpp webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/webbrowser-app.cpp --- webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/webbrowser-app.cpp 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/webbrowser-app.cpp 2014-03-28 17:07:01.000000000 +0000 @@ -26,9 +26,6 @@ #include "settings.h" #include "tabs-model.h" #include "webbrowser-app.h" -#include "webthumbnail-provider.h" -#include "webthumbnail-utils.h" -#include "webview-thumbnailer.h" // system #include @@ -41,25 +38,14 @@ #include #include #include -#include #include #include WebbrowserApp::WebbrowserApp(int& argc, char** argv) : BrowserApplication(argc, argv) - , m_thumbnailUtilsThread(0) { } -WebbrowserApp::~WebbrowserApp() -{ - if (m_thumbnailUtilsThread) { - m_thumbnailUtilsThread->quit(); - m_thumbnailUtilsThread->wait(); - delete m_thumbnailUtilsThread; - } -} - bool WebbrowserApp::initialize() { // Re-direct webapps to the dedicated container for backward compatibility @@ -91,22 +77,9 @@ qmlRegisterType(uri, 0, 1, "HistoryDomainListChronologicalModel"); qmlRegisterType(uri, 0, 1, "TabsModel"); qmlRegisterType(uri, 0, 1, "BookmarksModel"); - qmlRegisterType(uri, 0, 1, "WebviewThumbnailer"); if (BrowserApplication::initialize("webbrowser/webbrowser-app.qml")) { m_window->setProperty("chromeless", m_arguments.contains("--chromeless")); - - // This singleton lives in its own thread to ensure that - // disk I/O is not performed in the UI thread. - WebThumbnailUtils& utils = WebThumbnailUtils::instance(); - m_thumbnailUtilsThread = new QThread; - utils.moveToThread(m_thumbnailUtilsThread); - m_thumbnailUtilsThread->start(); - - WebThumbnailProvider* thumbnailer = new WebThumbnailProvider; - m_engine->addImageProvider(QLatin1String("webthumbnail"), thumbnailer); - m_engine->rootContext()->setContextProperty("WebThumbnailer", thumbnailer); - QList urls = this->urls(); if (urls.isEmpty()) { Settings settings; @@ -116,6 +89,9 @@ Q_FOREACH(const QUrl& url, urls) { QMetaObject::invokeMethod(browser, "newTab", Q_ARG(QVariant, url), Q_ARG(QVariant, true)); } + + m_component->completeCreate(); + return true; } else { return false; diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/webbrowser-app.h webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/webbrowser-app.h --- webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/webbrowser-app.h 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/webbrowser-app.h 2014-03-28 17:07:01.000000000 +0000 @@ -21,22 +21,17 @@ #include "browserapplication.h" -class QThread; - class WebbrowserApp : public BrowserApplication { Q_OBJECT public: WebbrowserApp(int& argc, char** argv); - ~WebbrowserApp(); bool initialize(); private: virtual void printUsage() const; - - QThread* m_thumbnailUtilsThread; }; #endif // __WEBBROWSER_APP_H__ diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/webthumbnail-provider.cpp webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/webthumbnail-provider.cpp --- webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/webthumbnail-provider.cpp 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/webthumbnail-provider.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* - * Copyright 2013 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * webbrowser-app is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "webthumbnail-provider.h" -#include "webthumbnail-utils.h" - -// Qt -#include -#include - -WebThumbnailProvider::WebThumbnailProvider(QObject* parent) - : QObject(parent) - , QQuickImageProvider(QQuickImageProvider::Image) -{ -} - -QImage WebThumbnailProvider::requestImage(const QString& id, QSize* size, const QSize& requestedSize) -{ - QImage image; - QFileInfo cached = WebThumbnailUtils::thumbnailFile(QUrl(id)); - if (cached.exists()) { - QImageReader reader(cached.absoluteFilePath(), "PNG"); - if (requestedSize.isValid()) { - reader.setScaledSize(requestedSize); - } - *size = reader.size(); - reader.read(&image); - if (image.isNull()) { - qWarning() << "Failed to load cached thumbnail:" << reader.errorString(); - } - } - return image; -} - -bool WebThumbnailProvider::thumbnailExists(const QUrl& url) const -{ - return WebThumbnailUtils::thumbnailFile(url).exists(); -} diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/webthumbnail-provider.h webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/webthumbnail-provider.h --- webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/webthumbnail-provider.h 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/webthumbnail-provider.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* - * Copyright 2013 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * webbrowser-app is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef __WEBTHUMBNAIL_PROVIDER_H__ -#define __WEBTHUMBNAIL_PROVIDER_H__ - -// Qt -#include -#include -#include - -class WebThumbnailProvider : public QObject, public QQuickImageProvider -{ - Q_OBJECT - -public: - WebThumbnailProvider(QObject* parent=0); - - virtual QImage requestImage(const QString& id, QSize* size, const QSize& requestedSize); - - Q_INVOKABLE bool thumbnailExists(const QUrl& url) const; -}; - -#endif // __WEBTHUMBNAIL_PROVIDER_H__ diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/webthumbnail-utils.cpp webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/webthumbnail-utils.cpp --- webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/webthumbnail-utils.cpp 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/webthumbnail-utils.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -/* - * Copyright 2013 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * webbrowser-app is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "domain-utils.h" -#include "webthumbnail-utils.h" - -// Qt -#include -#include -#include -#include -#include - -#define MAX_CACHE_SIZE_IN_BYTES 5 * 1024 * 1024 // 5MB - -WebThumbnailUtils::WebThumbnailUtils(QObject* parent) - : QObject(parent) -{ -} - -WebThumbnailUtils& WebThumbnailUtils::instance() -{ - static WebThumbnailUtils utils; - return utils; -} - -WebThumbnailUtils::~WebThumbnailUtils() -{ -} - -QDir WebThumbnailUtils::cacheLocation() -{ - return QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/thumbnails"; -} - -void WebThumbnailUtils::ensureCacheLocation() -{ - QDir cache = cacheLocation(); - if (!cache.exists()) { - QDir::root().mkpath(cache.absolutePath()); - } -} - -QFileInfo WebThumbnailUtils::thumbnailFile(const QUrl& url) -{ - QString hash(QCryptographicHash::hash(url.toEncoded(), QCryptographicHash::Md5).toHex()); - return cacheLocation().absoluteFilePath(hash + ".png"); -} - -void WebThumbnailUtils::cacheThumbnail(const QUrl& url, const QImage& thumbnail) const -{ - ensureCacheLocation(); - QFileInfo file = thumbnailFile(url); - bool saved = thumbnail.save(file.absoluteFilePath()); - - if (saved) { - // Make a link to the thumbnail file for the corresponding domain’s thumbnail. - QUrl domain(DomainUtils::extractTopLevelDomainName(url)); - QString domainThumbnail = WebThumbnailUtils::thumbnailFile(domain).absoluteFilePath(); - if (QFile::exists(domainThumbnail)) { - QFile::remove(domainThumbnail); - } - QFile::link(file.fileName(), domainThumbnail); - } - - expireCache(); -} - -void WebThumbnailUtils::expireCache() const -{ - QDir cache = cacheLocation(); - if (!cache.exists()) { - return; - } - QStringList nameFilters = QStringList() << "*.png"; - QDir::Filters filters = QDir::Files | QDir::NoDotAndDotDot; - QDir::SortFlags sort = QDir::Time; - QFileInfoList entries = cache.entryInfoList(nameFilters, filters, sort); - qint64 currentSize = 0; - Q_FOREACH(const QFileInfo& entry, entries) { - currentSize += entry.size(); - } - if (currentSize > MAX_CACHE_SIZE_IN_BYTES) { - qint64 goal = MAX_CACHE_SIZE_IN_BYTES * 9 / 10; - while (!entries.isEmpty() && (currentSize > goal)) { - QFileInfo entry = entries.takeLast(); - qint64 size = entry.size(); - if (QFile::remove(entry.absoluteFilePath())) { - currentSize -= size; - } - } - } -} diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/webthumbnail-utils.h webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/webthumbnail-utils.h --- webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/webthumbnail-utils.h 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/webthumbnail-utils.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -/* - * Copyright 2013 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * webbrowser-app is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef __WEBTHUMBNAIL_UTILS_H__ -#define __WEBTHUMBNAIL_UTILS_H__ - -// Qt -#include -#include -#include - -class QImage; -class QUrl; - -class WebThumbnailUtils : public QObject -{ - Q_OBJECT - -public: - static WebThumbnailUtils& instance(); - ~WebThumbnailUtils(); - - static QDir cacheLocation(); - static void ensureCacheLocation(); - static QFileInfo thumbnailFile(const QUrl& url); - -public Q_SLOTS: - void cacheThumbnail(const QUrl& url, const QImage& thumbnail) const; - -private: - WebThumbnailUtils(QObject* parent=0); - - void expireCache() const; -}; - -#endif // __WEBTHUMBNAIL_UTILS_H__ diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/webview-thumbnailer.cpp webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/webview-thumbnailer.cpp --- webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/webview-thumbnailer.cpp 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/webview-thumbnailer.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,162 +0,0 @@ -/* - * Copyright 2013 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * webbrowser-app is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "webthumbnail-utils.h" -#include "webview-thumbnailer.h" - -// Qt -#include -#include -#include -#include -#include -#include - -class BindableFbo : public QSGBindable -{ -public: - BindableFbo(QOpenGLFramebufferObject* fbo) : m_fbo(fbo) {} - virtual void bind() const { m_fbo->bind(); } - -private: - QOpenGLFramebufferObject *m_fbo; -}; - -WebviewThumbnailer::WebviewThumbnailer(QQuickItem* parent) - : QQuickItem(parent) - , m_webview(0) -{ -} - -QQuickWebView* WebviewThumbnailer::webview() const -{ - return m_webview; -} - -void WebviewThumbnailer::setWebview(QQuickWebView* webview) -{ - if (webview != m_webview) { - m_webview = webview; - setFlag(QQuickItem::ItemHasContents, false); - Q_EMIT webviewChanged(); - } -} - -const QSize& WebviewThumbnailer::targetSize() const -{ - return m_targetSize; -} - -void WebviewThumbnailer::setTargetSize(const QSize& targetSize) -{ - if (targetSize != m_targetSize) { - m_targetSize = targetSize; - Q_EMIT targetSizeChanged(); - } -} - -bool WebviewThumbnailer::thumbnailExists() const -{ - if (m_webview) { - QUrl url = m_webview->url(); - if (url.isValid()) { - return WebThumbnailUtils::thumbnailFile(url).exists(); - } - } - return false; -} - -void WebviewThumbnailer::renderThumbnail() -{ - // Delay the actual rendering to give all elements on the page - // a chance to be fully rendered. - QTimer::singleShot(1000, this, SLOT(doRenderThumbnail())); -} - -void WebviewThumbnailer::doRenderThumbnail() -{ - if (m_webview) { - setFlag(QQuickItem::ItemHasContents); - update(); - } -} - -QSGNode* WebviewThumbnailer::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData* updatePaintNodeData) -{ - Q_UNUSED(updatePaintNodeData); - - if (!(m_webview && (flags() & QQuickItem::ItemHasContents))) { - return oldNode; - } - setFlag(QQuickItem::ItemHasContents, false); - - QQuickWebPage* page = m_webview->page(); - qreal min = qMin(page->width(), page->height()); - QSize size(min, min); - - QSGNode* node = QQuickItemPrivate::get(page)->itemNode(); - QSGNode* parent = node->QSGNode::parent(); - QSGNode* previousSibling = node->previousSibling(); - if (parent) { - parent->removeChildNode(node); - } - QSGRootNode root; - root.appendChildNode(node); - - QSGRenderer* renderer; -#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0) - renderer = QQuickItemPrivate::get(this)->sceneGraphContext()->createRenderer(); -#else - renderer = QQuickItemPrivate::get(this)->sceneGraphRenderContext()->createRenderer(); -#endif - renderer->setRootNode(static_cast(&root)); - - QOpenGLFramebufferObject fbo(size); - - renderer->setDeviceRect(size); - renderer->setViewportRect(size); - renderer->setProjectionMatrixToRect(QRectF(QPointF(), size)); - renderer->setClearColor(Qt::transparent); - - renderer->renderScene(BindableFbo(&fbo)); - - fbo.release(); - - const QUrl& url = m_webview->url(); - QImage image = fbo.toImage().scaled(m_targetSize, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); - - // Invoke the method asynchronously. - QMetaObject::invokeMethod(&WebThumbnailUtils::instance(), "cacheThumbnail", - Qt::QueuedConnection, Q_ARG(QUrl, url), Q_ARG(QImage, image)); - - root.removeChildNode(node); - renderer->setRootNode(0); - delete renderer; - - if (parent) { - if (previousSibling) { - parent->insertChildNodeAfter(node, previousSibling); - } else { - parent->prependChildNode(node); - } - } - - Q_EMIT thumbnailRendered(url); - - return oldNode; -} diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/webview-thumbnailer.h webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/webview-thumbnailer.h --- webbrowser-app-0.23+14.04.20140324/src/app/webbrowser/webview-thumbnailer.h 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/webbrowser/webview-thumbnailer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -/* - * Copyright 2013 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * webbrowser-app is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef __WEBVIEW_THUMBNAILER_H__ -#define __WEBVIEW_THUMBNAILER_H__ - -// Qt -#include -#include -#include - -class QQuickWebView; - -class WebviewThumbnailer : public QQuickItem -{ - Q_OBJECT - - Q_PROPERTY(QQuickWebView* webview READ webview WRITE setWebview NOTIFY webviewChanged) - Q_PROPERTY(QSize targetSize READ targetSize WRITE setTargetSize NOTIFY targetSizeChanged) - -public: - WebviewThumbnailer(QQuickItem* parent=0); - - QQuickWebView* webview() const; - void setWebview(QQuickWebView* webview); - - const QSize& targetSize() const; - void setTargetSize(const QSize& targetSize); - - Q_INVOKABLE bool thumbnailExists() const; - Q_INVOKABLE void renderThumbnail(); - -Q_SIGNALS: - void webviewChanged() const; - void targetSizeChanged() const; - void thumbnailRendered(const QUrl& url) const; - -protected: - virtual QSGNode* updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData* updatePaintNodeData); - -private Q_SLOTS: - void doRenderThumbnail(); - -private: - QQuickWebView* m_webview; - QSize m_targetSize; -}; - -#endif // __WEBVIEW_THUMBNAILER_H__ diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/webcontainer/webapp-container.cpp webbrowser-app-0.23+14.04.20140328.3/src/app/webcontainer/webapp-container.cpp --- webbrowser-app-0.23+14.04.20140324/src/app/webcontainer/webapp-container.cpp 2014-03-24 19:14:46.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/webcontainer/webapp-container.cpp 2014-03-28 17:07:01.000000000 +0000 @@ -24,10 +24,32 @@ // Qt #include #include +#include #include +#include #include #include #include +#include + + +namespace +{ + +QString currentArchitecturePathName() +{ +#if defined(Q_PROCESSOR_X86_32) + return QLatin1String("i386-linux-gnu"); +#elif defined(Q_PROCESSOR_X86_64) + return QLatin1String("x86_64-linux-gnu"); +#elif defined(Q_PROCESSOR_ARM) + return QLatin1String("arm-linux-gnueabihf"); +#else +#error Unable to determine target architecture +#endif +} + +} WebappContainer::WebappContainer(int& argc, char** argv) : BrowserApplication(argc, argv) @@ -50,7 +72,13 @@ m_window->setProperty("webappName", name); m_window->setProperty("backForwardButtonsVisible", m_arguments.contains("--enable-back-forward")); m_window->setProperty("addressBarVisible", m_arguments.contains("--enable-addressbar")); + + bool oxide = withOxide(); + qDebug() << "Using" << (oxide ? "Oxide" : "QtWebkit") << "as the web engine backend"; + m_window->setProperty("oxide", oxide); + m_window->setProperty("webappUrlPatterns", webappUrlPatterns()); + // When a webapp is being launched by name, the URL is pulled from its 'homepage'. if (name.isEmpty()) { QList urls = this->urls(); @@ -58,6 +86,9 @@ m_window->setProperty("url", urls.first()); } } + + m_component->completeCreate(); + return true; } else { return false; @@ -84,6 +115,31 @@ out << " --enable-addressbar enable the display of the address bar" << endl; } +bool WebappContainer::withOxide() const +{ + Q_FOREACH(const QString& argument, m_arguments) { + if (argument == "--webkit") { + // force webkit + return false; + } + if (argument == "--oxide") { + // force oxide + return true; + } + } + + // Use a runtime hint to transparently know if oxide + // can be used as a backend without the user/dev having + // to update its app or change something in the Exec args. + // Version 1.1 of ubuntu apparmor policy allows this file to + // be accessed whereas v1.0 only knows about qtwebkit. + QString oxideHintLocation = + QString("/usr/lib/%1/oxide-qt/oxide-renderer") + .arg(currentArchitecturePathName()); + + return QFile(oxideHintLocation).open(QIODevice::ReadOnly); +} + QString WebappContainer::webappModelSearchPath() const { Q_FOREACH(const QString& argument, m_arguments) { diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/webcontainer/webapp-container.h webbrowser-app-0.23+14.04.20140328.3/src/app/webcontainer/webapp-container.h --- webbrowser-app-0.23+14.04.20140324/src/app/webcontainer/webapp-container.h 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/webcontainer/webapp-container.h 2014-03-28 17:07:01.000000000 +0000 @@ -39,6 +39,7 @@ QString webappModelSearchPath() const; QString webappName() const; QStringList webappUrlPatterns() const; + bool withOxide() const; }; #endif // __WEBAPP_CONTAINER_H__ diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/webcontainer/webapp-container.qml webbrowser-app-0.23+14.04.20140328.3/src/app/webcontainer/webapp-container.qml --- webbrowser-app-0.23+14.04.20140324/src/app/webcontainer/webapp-container.qml 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/webcontainer/webapp-container.qml 2014-03-28 17:07:01.000000000 +0000 @@ -30,6 +30,7 @@ property alias webappName: browser.webappName property alias webappModelSearchPath: browser.webappModelSearchPath property alias webappUrlPatterns: browser.webappUrlPatterns + property alias oxide: browser.oxide contentOrientation: browser.screenOrientation diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/webcontainer/WebappContainerWebview.qml webbrowser-app-0.23+14.04.20140328.3/src/app/webcontainer/WebappContainerWebview.qml --- webbrowser-app-0.23+14.04.20140324/src/app/webcontainer/WebappContainerWebview.qml 1970-01-01 00:00:00.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/webcontainer/WebappContainerWebview.qml 2014-03-28 17:07:01.000000000 +0000 @@ -0,0 +1,151 @@ +/* + * Copyright 2014 Canonical Ltd. + * + * This file is part of webbrowser-app. + * + * webbrowser-app is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * webbrowser-app is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import QtQuick 2.0 +import Ubuntu.Components 0.1 +import Ubuntu.Unity.Action 1.0 as UnityActions +import Ubuntu.UnityWebApps 0.1 as UnityWebApps +import "../actions" as Actions +import ".." + +Item { + id: containerWebview + + property string url: "" + property bool withOxide: false + property bool developerExtrasEnabled: false + property string webappName: "" + property var currentWebview: webappContainerWebViewLoader.item + property var toolbar: null + property var webappUrlPatterns: null + + Loader { + id: webappContainerWebViewLoader + anchors.fill: parent + sourceComponent: withOxide ? webappContainerWebViewOxide : webappContainerWebViewWebkit + } + + Component { + id: webappContainerWebViewWebkit + + WebViewImplWebkit { + toolbar: containerWebview.toolbar + url: containerWebview.url + webappName: containerWebview.webappName + webappUrlPatterns: containerWebview.webappUrlPatterns + developerExtrasEnabled: containerWebview.developerExtrasEnabled + } + } + + Component { + id: webappContainerWebViewOxide + + WebViewImpl { + id: webview + + url: containerWebview.url + currentWebview: webview + toolbar: containerWebview.toolbar + + contextualActions: ActionList { + Actions.CopyLink { + enabled: webview.contextualData.href.toString() + onTriggered: Clipboard.push([webview.contextualData.href]) + } + Actions.CopyImage { + enabled: webview.contextualData.img.toString() + onTriggered: Clipboard.push([webview.contextualData.img]) + } + } + + function haveValidUrlPatterns() { + return webappUrlPatterns && webappUrlPatterns.length !== 0 + } + + /*function navigationRequestedDelegate(request) { + if (!request.isMainFrame) { + request.action = WebView.AcceptRequest + return + } + + // Pass-through if we are not running as a named webapp (--webapp='Gmail') + // or if we dont have a list of url patterns specified to filter the + // browsing actions + if ( ! haveValidUrlPatterns() && ! isRunningAsANamedWebapp()) { + request.action = WebView.AcceptRequest + return + } + + var action = WebView.IgnoreRequest + var url = request.url.toString() + + // The list of url patterns defined by the webapp takes precedence over command line + if (isRunningAsANamedWebapp()) { + if (unityWebapps.model.exists(unityWebapps.name) && + unityWebapps.model.doesUrlMatchesWebapp(unityWebapps.name, url)) { + request.action = WebView.AcceptRequest + return; + } + } + + // We still take the possible additional patterns specified in the command line + // (the in the case of finer grained ones specifically for the container and not + // as an 'install source' for the webapp). + if (webappUrlPatterns && webappUrlPatterns.length !== 0) { + for (var i = 0; i < webappUrlPatterns.length; ++i) { + var pattern = webappUrlPatterns[i] + if (url.match(pattern)) { + action = WebView.AcceptRequest + break + } + } + } + + request.action = action + if (action === WebView.IgnoreRequest) { + console.debug('Opening: ' + url + ' in the browser window.') + Qt.openUrlExternally(url) + } + }*/ + + onNewTabRequested: Qt.openUrlExternally(url) + + preferences.localStorageEnabled: true + + // Small shim needed when running as a webapp to wire-up connections + // with the webview (message received, etc…). + // This is being called (and expected) internally by the webapps + // component as a way to bind to a webview lookalike without + // reaching out directly to its internals (see it as an interface). + function getUnityWebappsProxies() { + var eventHandlers = { + onAppRaised: function () { + if (webbrowserWindow) { + try { + webbrowserWindow.raise(); + } catch (e) { + console.debug('Error while raising: ' + e); + } + } + } + }; + return UnityWebAppsUtils.makeProxiesForWebViewBindee(webview, eventHandlers) + } + } + } +} diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/webcontainer/WebApp.qml webbrowser-app-0.23+14.04.20140328.3/src/app/webcontainer/WebApp.qml --- webbrowser-app-0.23+14.04.20140324/src/app/webcontainer/WebApp.qml 2014-03-24 19:14:46.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/webcontainer/WebApp.qml 2014-03-28 17:07:01.000000000 +0000 @@ -17,8 +17,6 @@ */ import QtQuick 2.0 -import QtWebKit 3.1 -import QtWebKit.experimental 1.0 import Ubuntu.Components 0.1 import Ubuntu.Components.Popups 0.1 import Ubuntu.Unity.Action 1.0 as UnityActions @@ -29,20 +27,23 @@ BrowserView { id: webapp - currentWebview: webview + currentWebview: webview.currentWebview property alias url: webview.url - property string webappName: "" + property string webappModelSearchPath: "" - property var webappUrlPatterns: null + + property alias oxide: webview.withOxide + property alias webappName: webview.webappName + property alias webappUrlPatterns: webview.webappUrlPatterns actions: [ Actions.Back { - enabled: backForwardButtonsVisible && currentWebview.canGoBack + enabled: backForwardButtonsVisible && webview.currentWebview && webview.currentWebview.canGoBack onTriggered: webview.goBack() }, Actions.Forward { - enabled: backForwardButtonsVisible && currentWebview.canGoForward + enabled: backForwardButtonsVisible && webview.currentWebview && webview.currentWebview.canGoForward onTriggered: webview.goForward() }, Actions.Reload { @@ -58,10 +59,8 @@ // The UITK is trying too hard to be clever about the header and toolbar. flickable: null - WebViewImpl { + WebappContainerWebview { id: webview - - currentWebview: webview toolbar: panel.panel anchors { @@ -70,97 +69,17 @@ top: parent.top } height: parent.height - osk.height - - experimental.preferences.developerExtrasEnabled: developerExtrasEnabled - - contextualActions: ActionList { - Actions.CopyLink { - enabled: webview.contextualData.href.toString() - onTriggered: Clipboard.push([webview.contextualData.href]) - } - Actions.CopyImage { - enabled: webview.contextualData.img.toString() - onTriggered: Clipboard.push([webview.contextualData.img]) - } - } - - function haveValidUrlPatterns() { - return webappUrlPatterns && webappUrlPatterns.length !== 0 - } - - function navigationRequestedDelegate(request) { - if (!request.isMainFrame) { - request.action = WebView.AcceptRequest - return - } - - // Pass-through if we are not running as a named webapp (--webapp='Gmail') - // or if we dont have a list of url patterns specified to filter the - // browsing actions - if ( ! haveValidUrlPatterns() && ! isRunningAsANamedWebapp()) { - request.action = WebView.AcceptRequest - return - } - - var action = WebView.IgnoreRequest - var url = request.url.toString() - - // The list of url patterns defined by the webapp takes precedence over command line - if (isRunningAsANamedWebapp()) { - if (unityWebapps.model.exists(unityWebapps.name) && - unityWebapps.model.doesUrlMatchesWebapp(unityWebapps.name, url)) { - request.action = WebView.AcceptRequest - return; - } - } - - // We still take the possible additional patterns specified in the command line - // (the in the case of finer grained ones specifically for the container and not - // as an 'install source' for the webapp). - if (webappUrlPatterns && webappUrlPatterns.length !== 0) { - for (var i = 0; i < webappUrlPatterns.length; ++i) { - var pattern = webappUrlPatterns[i] - if (url.match(pattern)) { - action = WebView.AcceptRequest - break - } - } - } - - request.action = action - if (action === WebView.IgnoreRequest) { - console.debug('Opening: ' + url + ' in the browser window.') - Qt.openUrlExternally(url) - } - } - - onNewTabRequested: Qt.openUrlExternally(url) - - // Small shim needed when running as a webapp to wire-up connections - // with the webview (message received, etc…). - // This is being called (and expected) internally by the webapps - // component as a way to bind to a webview lookalike without - // reaching out directly to its internals (see it as an interface). - function getUnityWebappsProxies() { - var eventHandlers = { - onAppRaised: function () { - if (webbrowserWindow) { - try { - webbrowserWindow.raise(); - } catch (e) { - console.debug('Error while raising: ' + e); - } - } - } - }; - return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview, eventHandlers) - } + developerExtrasEnabled: webapp.developerExtrasEnabled } ErrorSheet { anchors.fill: webview - visible: webview.lastLoadRequestStatus == WebView.LoadFailedStatus - url: webview.url + visible: { + if (webview.lastLoadFailed !== undefined) + return webview.lastLoadFailed + return webview.currentWebview && webview.currentWebview.lastLoadFailed + } + url: webview.currentWebview.url onRefreshClicked: webview.reload() } } @@ -168,7 +87,7 @@ PanelLoader { id: panel - currentWebview: webview + currentWebview: webview.currentWebview chromeless: webapp.chromeless backForwardButtonsVisible: webapp.backForwardButtonsVisible @@ -185,12 +104,8 @@ UnityWebApps.UnityWebApps { id: unityWebapps name: webappName - bindee: webview + bindee: webview.currentWebview actionsContext: actionManager.globalContext model: UnityWebApps.UnityWebappsAppModel { searchPath: webappModelSearchPath } } - - function isRunningAsANamedWebapp() { - return webappName && typeof(webappName) === 'string' && webappName.length != 0 - } } diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/webcontainer/WebViewImplWebkit.qml webbrowser-app-0.23+14.04.20140328.3/src/app/webcontainer/WebViewImplWebkit.qml --- webbrowser-app-0.23+14.04.20140324/src/app/webcontainer/WebViewImplWebkit.qml 1970-01-01 00:00:00.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/webcontainer/WebViewImplWebkit.qml 2014-03-28 17:07:01.000000000 +0000 @@ -0,0 +1,159 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * This file is part of webbrowser-app. + * + * webbrowser-app is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * webbrowser-app is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import QtQuick 2.0 +import QtWebKit 3.1 +import QtWebKit.experimental 1.0 +import Ubuntu.Components 0.1 +import Ubuntu.Components.Extras.Browser 0.1 +import Ubuntu.UnityWebApps 0.1 as UnityWebApps +import Ubuntu.Components.Popups 0.1 +import "../actions" as Actions +import ".." + +UbuntuWebView { + id: webview + + property bool developerExtrasEnabled: false + property var currentWebview: webview + property var toolbar: null + property string webappName: "" + property var webappUrlPatterns: null + + experimental.certificateVerificationDialog: CertificateVerificationDialog {} + experimental.authenticationDialog: AuthenticationDialog {} + experimental.proxyAuthenticationDialog: ProxyAuthenticationDialog {} + experimental.alertDialog: AlertDialog {} + experimental.confirmDialog: ConfirmDialog {} + experimental.promptDialog: PromptDialog {} + + selectionActions: ActionList { + Actions.Copy { + onTriggered: selection.copy() + } + } + + property bool lastLoadFailed: false + onLoadingChanged: { + lastLoadFailed = (loadRequest.status === WebView.LoadFailedStatus) + } + + experimental.preferences.developerExtrasEnabled: developerExtrasEnabled + + experimental.onPermissionRequested: { + if (permission.type === PermissionRequest.Geolocation) { + if (webview.toolbar) { + webview.toolbar.close() + } + var text = i18n.tr("This page wants to know your device’s location.") + PopupUtils.open(Qt.resolvedUrl("PermissionRequest.qml"), + webview.currentWebview, + {"permission": permission, "text": text}) + } + // TODO: handle other types of permission requests + // TODO: we might want to store the answer to avoid requesting + // the permission everytime the user visits this site. + } + + contextualActions: ActionList { + Actions.CopyLink { + enabled: webview.contextualData.href.toString() + onTriggered: Clipboard.push([webview.contextualData.href]) + } + Actions.CopyImage { + enabled: webview.contextualData.img.toString() + onTriggered: Clipboard.push([webview.contextualData.img]) + } + } + + function isRunningAsANamedWebapp() { + return webview.webappName && typeof(webview.webappName) === 'string' && webview.webappName.length != 0 + } + + function haveValidUrlPatterns() { + return webappUrlPatterns && webappUrlPatterns.length !== 0 + } + + function navigationRequestedDelegate(request) { + if (!request.isMainFrame) { + request.action = WebView.AcceptRequest + return + } + + // Pass-through if we are not running as a named webapp (--webapp='Gmail') + // or if we dont have a list of url patterns specified to filter the + // browsing actions + if ( ! haveValidUrlPatterns() && ! isRunningAsANamedWebapp()) { + request.action = WebView.AcceptRequest + return + } + + var action = WebView.IgnoreRequest + var url = request.url.toString() + + // The list of url patterns defined by the webapp takes precedence over command line + if (isRunningAsANamedWebapp()) { + if (unityWebapps.model.exists(unityWebapps.name) && + unityWebapps.model.doesUrlMatchesWebapp(unityWebapps.name, url)) { + request.action = WebView.AcceptRequest + return; + } + } + + // We still take the possible additional patterns specified in the command line + // (the in the case of finer grained ones specifically for the container and not + // as an 'install source' for the webapp). + if (webappUrlPatterns && webappUrlPatterns.length !== 0) { + for (var i = 0; i < webappUrlPatterns.length; ++i) { + var pattern = webappUrlPatterns[i] + if (url.match(pattern)) { + action = WebView.AcceptRequest + break + } + } + } + + request.action = action + if (action === WebView.IgnoreRequest) { + console.debug('Opening: ' + url + ' in the browser window.') + Qt.openUrlExternally(url) + } + } + + onNewTabRequested: Qt.openUrlExternally(url) + + // Small shim needed when running as a webapp to wire-up connections + // with the webview (message received, etc…). + // This is being called (and expected) internally by the webapps + // component as a way to bind to a webview lookalike without + // reaching out directly to its internals (see it as an interface). + function getUnityWebappsProxies() { + var eventHandlers = { + onAppRaised: function () { + if (webbrowserWindow) { + try { + webbrowserWindow.raise(); + } catch (e) { + console.debug('Error while raising: ' + e); + } + } + } + }; + return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview, eventHandlers) + } +} diff -Nru webbrowser-app-0.23+14.04.20140324/src/app/WebViewImpl.qml webbrowser-app-0.23+14.04.20140328.3/src/app/WebViewImpl.qml --- webbrowser-app-0.23+14.04.20140324/src/app/WebViewImpl.qml 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/app/WebViewImpl.qml 2014-03-28 17:07:01.000000000 +0000 @@ -17,12 +17,10 @@ */ import QtQuick 2.0 -import QtWebKit 3.1 -import QtWebKit.experimental 1.0 -import Ubuntu.Components 0.1 -import Ubuntu.Components.Extras.Browser 0.1 -import Ubuntu.Components.Popups 0.1 -import "actions" as Actions +//import Ubuntu.Components 0.1 +import Ubuntu.Components.Extras.Browser 0.2 +//import Ubuntu.Components.Popups 0.1 +//import "actions" as Actions UbuntuWebView { id: webview @@ -30,20 +28,21 @@ property var currentWebview: webview property var toolbar: null - experimental.certificateVerificationDialog: CertificateVerificationDialog {} + /*experimental.certificateVerificationDialog: CertificateVerificationDialog {} experimental.authenticationDialog: AuthenticationDialog {} - experimental.proxyAuthenticationDialog: ProxyAuthenticationDialog {} - experimental.alertDialog: AlertDialog {} - experimental.confirmDialog: ConfirmDialog {} - experimental.promptDialog: PromptDialog {} + experimental.proxyAuthenticationDialog: ProxyAuthenticationDialog {}*/ + /*alertDialog: AlertDialog {} + confirmDialog: ConfirmDialog {} + promptDialog: PromptDialog {} + beforeUnloadDialog: BeforeUnloadDialog {}*/ - selectionActions: ActionList { + /*selectionActions: ActionList { Actions.Copy { onTriggered: selection.copy() } - } + }*/ - experimental.onPermissionRequested: { + /*experimental.onPermissionRequested: { if (permission.type === PermissionRequest.Geolocation) { if (webview.toolbar) { webview.toolbar.close() @@ -56,8 +55,5 @@ // TODO: handle other types of permission requests // TODO: we might want to store the answer to avoid requesting // the permission everytime the user visits this site. - } - - property int lastLoadRequestStatus: -1 - onLoadingChanged: lastLoadRequestStatus = loadRequest.status + }*/ } diff -Nru webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/CMakeLists.txt webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/CMakeLists.txt --- webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/CMakeLists.txt 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/CMakeLists.txt 2014-03-28 17:07:01.000000000 +0000 @@ -13,7 +13,7 @@ add_library(${PLUGIN} MODULE ${PLUGIN_SRC}) -qt5_use_modules(${PLUGIN} Core Qml) +qt5_use_modules(${PLUGIN} Core Gui Qml) file(GLOB QML_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.qml qmldir *.js) install(TARGETS ${PLUGIN} DESTINATION ${WEBBROWSER_IMPORTS_DIR}) diff -Nru webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/dummysingleton.qml webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/dummysingleton.qml --- webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/dummysingleton.qml 1970-01-01 00:00:00.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/dummysingleton.qml 2014-03-28 17:07:01.000000000 +0000 @@ -0,0 +1,27 @@ +/* + * Copyright 2014 Canonical Ltd. + * + * This file is part of webbrowser-app. + * + * webbrowser-app is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * webbrowser-app is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +// This file is not really used, but without it importing version 0.1 of +// Ubuntu.Components.Extras.Browser fails because the QML engine requests type +// UbuntuWebContext, despite it being specific to version 0.2 of the module. + +pragma Singleton + +import QtQml 2.0 + +QtObject {} diff -Nru webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/ItemSelector01.qml webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/ItemSelector01.qml --- webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/ItemSelector01.qml 1970-01-01 00:00:00.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/ItemSelector01.qml 2014-03-28 17:07:01.000000000 +0000 @@ -0,0 +1,63 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * This file is part of webbrowser-app. + * + * webbrowser-app is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * webbrowser-app is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import QtQuick 2.0 +import Ubuntu.Components 0.1 +import Ubuntu.Components.ListItems 0.1 as ListItem +import Ubuntu.Components.Popups 0.1 + +Popover { + id: itemSelector + + property QtObject selectorModel: model + + caller: parent + contentWidth: Math.min(parent.width - units.gu(10), units.gu(40)) + property real listContentHeight: 0 // intermediate property to avoid binding loop + contentHeight: Math.min(parent.height - units.gu(10), listContentHeight) + + ListView { + clip: true + width: itemSelector.contentWidth + height: itemSelector.contentHeight + + model: selectorModel.items + + delegate: ListItem.Standard { + text: model.text + enabled: model.enabled + selected: model.selected + onClicked: selectorModel.accept(model.index) + } + + section.property: "group" + section.delegate: ListItem.Header { + text: section + } + + onContentHeightChanged: itemSelector.listContentHeight = contentHeight + } + + Component.onCompleted: show() + + onVisibleChanged: { + if (!visible) { + selectorModel.reject() + } + } +} diff -Nru webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/ItemSelector02.qml webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/ItemSelector02.qml --- webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/ItemSelector02.qml 1970-01-01 00:00:00.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/ItemSelector02.qml 2014-03-28 17:07:01.000000000 +0000 @@ -0,0 +1,66 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * This file is part of webbrowser-app. + * + * webbrowser-app is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * webbrowser-app is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import QtQuick 2.0 +import Ubuntu.Components 0.1 +import Ubuntu.Components.ListItems 0.1 as ListItem +import Ubuntu.Components.Popups 0.1 + +Popover { + id: itemSelector + + property QtObject selectorModel: model + + caller: parent + contentWidth: Math.min(parent.width - units.gu(10), units.gu(40)) + property real listContentHeight: 0 // intermediate property to avoid binding loop + contentHeight: Math.min(parent.height - units.gu(10), listContentHeight) + + ListView { + clip: true + width: itemSelector.contentWidth + height: itemSelector.contentHeight + + model: selectorModel.items + + delegate: ListItem.Standard { + text: model.text + enabled: model.enabled + selected: model.selected + onClicked: { + selectorModel.items.select(model.index) + selectorModel.accept() + } + } + + section.property: "group" + section.delegate: ListItem.Header { + text: section + } + + onContentHeightChanged: itemSelector.listContentHeight = contentHeight + } + + Component.onCompleted: show() + + onVisibleChanged: { + if (!visible) { + selectorModel.cancel() + } + } +} diff -Nru webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/ItemSelector.qml webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/ItemSelector.qml --- webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/ItemSelector.qml 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/ItemSelector.qml 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright 2013 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * webbrowser-app is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.0 -import Ubuntu.Components 0.1 -import Ubuntu.Components.ListItems 0.1 as ListItem -import Ubuntu.Components.Popups 0.1 - -Popover { - id: itemSelector - - property QtObject selectorModel: model - - caller: parent - contentWidth: Math.min(parent.width - units.gu(10), units.gu(40)) - property real listContentHeight: 0 // intermediate property to avoid binding loop - contentHeight: Math.min(parent.height - units.gu(10), listContentHeight) - - ListView { - clip: true - width: itemSelector.contentWidth - height: itemSelector.contentHeight - - model: selectorModel.items - - delegate: ListItem.Standard { - text: model.text - enabled: model.enabled - selected: model.selected - onClicked: selectorModel.accept(model.index) - } - - section.property: "group" - section.delegate: ListItem.Header { - text: section - } - - onContentHeightChanged: itemSelector.listContentHeight = contentHeight - } - - Component.onCompleted: show() - - onVisibleChanged: { - if (!visible) { - selectorModel.reject() - } - } -} diff -Nru webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/plugin.cpp webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/plugin.cpp --- webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/plugin.cpp 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/plugin.cpp 2014-03-28 17:07:01.000000000 +0000 @@ -21,6 +21,8 @@ // Qt #include #include +#include +#include #include static float getQtWebkitDpr() @@ -31,6 +33,36 @@ return ok ? value : 1.0; } +static QString getFormFactor() +{ + // This implementation only considers two possible form factors: desktop, + // and mobile (which includes phones and tablets). + // XXX: do we need to consider other form factors, such as tablet? + const char* DESKTOP = "desktop"; + const char* MOBILE = "mobile"; + + // The "DESKTOP_MODE" environment variable can be used to force the form + // factor to desktop, when set to any valid value other than 0. + const char* DESKTOP_MODE_ENV_VAR = "DESKTOP_MODE"; + if (qEnvironmentVariableIsSet(DESKTOP_MODE_ENV_VAR)) { + QByteArray stringValue = qgetenv(DESKTOP_MODE_ENV_VAR); + bool ok = false; + int value = stringValue.toInt(&ok); + if (ok) { + return (value == 0) ? MOBILE : DESKTOP; + } + } + + // XXX: Assume that QtUbuntu means mobile, which is currently the case, + // but may not remain true forever. + QString platform = QGuiApplication::platformName(); + if ((platform == "ubuntu") || (platform == "ubuntumirclient")) { + return MOBILE; + } + + return DESKTOP; +} + void UbuntuBrowserPlugin::initializeEngine(QQmlEngine* engine, const char* uri) { Q_UNUSED(uri); @@ -45,6 +77,8 @@ // Set the desired pixel ratio (not needed once we use Qt’s way of // calculating the proper pixel ratio by device/screen). context->setContextProperty("QtWebKitDPR", getQtWebkitDpr()); + + context->setContextProperty("formFactor", getFormFactor()); } void UbuntuBrowserPlugin::registerTypes(const char* uri) diff -Nru webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/qmldir webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/qmldir --- webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/qmldir 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/qmldir 2014-03-28 17:07:01.000000000 +0000 @@ -1,3 +1,7 @@ module Ubuntu.Components.Extras.Browser plugin ubuntu-ui-extras-browser-plugin -UbuntuWebView 0.1 UbuntuWebView.qml +UbuntuWebView 0.1 UbuntuWebView01.qml +UbuntuWebView 0.2 UbuntuWebView02.qml +# Without the following line, importing version 0.1 of the module fails +singleton UbuntuWebContext 0.1 dummysingleton.qml +singleton UbuntuWebContext 0.2 UbuntuWebContext.qml diff -Nru webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/selection01.js webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/selection01.js --- webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/selection01.js 1970-01-01 00:00:00.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/selection01.js 2014-03-28 17:07:01.000000000 +0000 @@ -0,0 +1,193 @@ +/* + * Copyright 2013-2014 Canonical Ltd. + * + * This file is part of webbrowser-app. + * + * webbrowser-app is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * webbrowser-app is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +// List of domains known to interfere with touch events listeners +var blacklist = [ + "m.8tracks.com", // http://pad.lv/1279903 +]; +if (blacklist.indexOf(document.domain) === -1) { + + function elementContainedInBox(element, box) { + var rect = element.getBoundingClientRect(); + return ((box.left <= rect.left) && (box.right >= rect.right) && + (box.top <= rect.top) && (box.bottom >= rect.bottom)); + } + + function getImgFullUri(uri) { + if ((uri.slice(0, 7) === 'http://') || + (uri.slice(0, 8) === 'https://') || + (uri.slice(0, 7) === 'file://')) { + return uri; + } else if (uri.slice(0, 1) === '/') { + var docuri = document.documentURI; + var firstcolon = docuri.indexOf('://'); + var protocol = 'http://'; + if (firstcolon !== -1) { + protocol = docuri.slice(0, firstcolon + 3); + } + return protocol + document.domain + uri; + } else { + var base = document.baseURI; + var lastslash = base.lastIndexOf('/'); + if (lastslash === -1) { + return base + '/' + uri; + } else { + return base.slice(0, lastslash + 1) + uri; + } + } + } + + function getSelectedData(element) { + var node = element; + var data = new Object; + + var nodeName = node.nodeName.toLowerCase(); + if (nodeName === 'img') { + data.img = getImgFullUri(node.getAttribute('src')); + } else if (nodeName === 'a') { + data.href = node.href; + data.title = node.title; + } + + // If the parent tag is a hyperlink, we want it too. + var parent = node.parentNode; + if ((nodeName !== 'a') && parent && (parent.nodeName.toLowerCase() === 'a')) { + data.href = parent.href; + data.title = parent.title; + node = parent; + } + + var boundingRect = node.getBoundingClientRect(); + data.left = boundingRect.left; + data.top = boundingRect.top; + data.width = boundingRect.width; + data.height = boundingRect.height; + + node = node.cloneNode(true); + // filter out script nodes + var scripts = node.getElementsByTagName('script'); + while (scripts.length > 0) { + var scriptNode = scripts[0]; + if (scriptNode.parentNode) { + scriptNode.parentNode.removeChild(scriptNode); + } + } + data.html = node.outerHTML; + data.nodeName = node.nodeName.toLowerCase(); + // FIXME: extract the text and images in the order they appear in the block, + // so that this order is respected when the data is pushed to the clipboard. + data.text = node.textContent; + var images = []; + var imgs = node.getElementsByTagName('img'); + for (var i = 0; i < imgs.length; i++) { + images.push(getImgFullUri(imgs[i].getAttribute('src'))); + } + if (images.length > 0) { + data.images = images; + } + + return data; + } + + function adjustSelection(selection) { + // FIXME: allow selecting two consecutive blocks, instead of + // interpolating to the containing block. + var centerX = (selection.left + selection.right) / 2; + var centerY = (selection.top + selection.bottom) / 2; + var element = document.elementFromPoint(centerX, centerY); + var parent = element; + while (elementContainedInBox(parent, selection)) { + parent = parent.parentNode; + } + element = parent; + return getSelectedData(element); + } + + function distance(touch1, touch2) { + return Math.sqrt(Math.pow(touch2.clientX - touch1.clientX, 2) + + Math.pow(touch2.clientY - touch1.clientY, 2)); + } + + navigator.qt.onmessage = function(message) { + var data = null; + try { + data = JSON.parse(message.data); + } catch (error) { + return; + } + if ('query' in data) { + if (data.query === 'adjustselection') { + var selection = adjustSelection(data); + selection.event = 'selectionadjusted'; + navigator.qt.postMessage(JSON.stringify(selection)); + } + } + } + + var longpressObserver = -1; + var currentTouch = null; + var longpressDetected = false; + + function longPressDetected(x, y) { + longpressDetected = true; + var element = document.elementFromPoint(x, y); + var data = getSelectedData(element); + data.event = 'longpress'; + navigator.qt.postMessage(JSON.stringify(data)); + } + + function clearLongpressTimeout() { + clearTimeout(longpressObserver); + longpressObserver = -1; + currentTouch = null; + } + + var doc = document.documentElement; + + doc.addEventListener('touchstart', function(event) { + if (event.touches.length == 1) { + currentTouch = event.touches[0]; + longpressObserver = setTimeout(longPressDetected, 800, currentTouch.clientX, currentTouch.clientY); + } + }); + + doc.addEventListener('touchend', function(event) { + if (longpressDetected) { + longpressDetected = false; + event.preventDefault(); + } + clearLongpressTimeout(); + }); + + doc.addEventListener('touchmove', function(event) { + if (!currentTouch) { + return; + } + if ((event.changedTouches.length > 1) || (distance(event.changedTouches[0], currentTouch) > 3)) { + clearLongpressTimeout(); + } + }); + + doc.addEventListener('touchcancel', function(event) { + if (longpressDetected) { + longpressDetected = false; + } + clearLongpressTimeout(); + }); + +} diff -Nru webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/selection02.js webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/selection02.js --- webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/selection02.js 1970-01-01 00:00:00.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/selection02.js 2014-03-28 17:07:01.000000000 +0000 @@ -0,0 +1,147 @@ +/* + * Copyright 2013-2014 Canonical Ltd. + * + * This file is part of webbrowser-app. + * + * webbrowser-app is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * webbrowser-app is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +function elementContainedInBox(element, box) { + var rect = element.getBoundingClientRect(); + return ((box.left <= rect.left) && (box.right >= rect.right) && + (box.top <= rect.top) && (box.bottom >= rect.bottom)); +} + +function getImgFullUri(uri) { + if ((uri.slice(0, 7) === 'http://') || + (uri.slice(0, 8) === 'https://') || + (uri.slice(0, 7) === 'file://')) { + return uri; + } else if (uri.slice(0, 1) === '/') { + var docuri = document.documentURI; + var firstcolon = docuri.indexOf('://'); + var protocol = 'http://'; + if (firstcolon !== -1) { + protocol = docuri.slice(0, firstcolon + 3); + } + return protocol + document.domain + uri; + } else { + var base = document.baseURI; + var lastslash = base.lastIndexOf('/'); + if (lastslash === -1) { + return base + '/' + uri; + } else { + return base.slice(0, lastslash + 1) + uri; + } + } +} + +function getSelectedData(element) { + var node = element; + var data = new Object; + + var nodeName = node.nodeName.toLowerCase(); + if (nodeName === 'img') { + data.img = getImgFullUri(node.getAttribute('src')); + } else if (nodeName === 'a') { + data.href = node.href; + data.title = node.title; + } + + // If the parent tag is a hyperlink, we want it too. + var parent = node.parentNode; + if ((nodeName !== 'a') && parent && (parent.nodeName.toLowerCase() === 'a')) { + data.href = parent.href; + data.title = parent.title; + node = parent; + } + + var boundingRect = node.getBoundingClientRect(); + data.left = boundingRect.left; + data.top = boundingRect.top; + data.width = boundingRect.width; + data.height = boundingRect.height; + + node = node.cloneNode(true); + // filter out script nodes + var scripts = node.getElementsByTagName('script'); + while (scripts.length > 0) { + var scriptNode = scripts[0]; + if (scriptNode.parentNode) { + scriptNode.parentNode.removeChild(scriptNode); + } + } + data.html = node.outerHTML; + data.nodeName = node.nodeName.toLowerCase(); + // FIXME: extract the text and images in the order they appear in the block, + // so that this order is respected when the data is pushed to the clipboard. + data.text = node.textContent; + var images = []; + var imgs = node.getElementsByTagName('img'); + for (var i = 0; i < imgs.length; i++) { + images.push(getImgFullUri(imgs[i].getAttribute('src'))); + } + if (images.length > 0) { + data.images = images; + } + + return data; +} + +function adjustSelection(selection) { + // FIXME: allow selecting two consecutive blocks, instead of + // interpolating to the containing block. + var centerX = (selection.left + selection.right) / 2; + var centerY = (selection.top + selection.bottom) / 2; + var element = document.elementFromPoint(centerX, centerY); + var parent = element; + while (elementContainedInBox(parent, selection)) { + parent = parent.parentNode; + } + element = parent; + return getSelectedData(element); +} + +function distance(touch1, touch2) { + return Math.sqrt(Math.pow(touch2.clientX - touch1.clientX, 2) + + Math.pow(touch2.clientY - touch1.clientY, 2)); +} + +/*navigator.qt.onmessage = function(message) { + var data = null; + try { + data = JSON.parse(message.data); + } catch (error) { + return; + } + if ('query' in data) { + if (data.query === 'adjustselection') { + var selection = adjustSelection(data); + selection.event = 'selectionadjusted'; + navigator.qt.postMessage(JSON.stringify(selection)); + } + } +}*/ + +document.documentElement.addEventListener('contextmenu', function(event) { + var element = document.elementFromPoint(event.clientX, event.clientY); + var data = getSelectedData(element); + var w = document.defaultView; + data['scaleX'] = w.outerWidth / w.innerWidth * w.devicePixelRatio; + data['scaleY'] = w.outerHeight / w.innerHeight * w.devicePixelRatio; + oxide.sendMessage('contextmenu', data); +}); + +document.defaultView.addEventListener('scroll', function(event) { + oxide.sendMessage('scroll', {}); +}); diff -Nru webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/selection.js webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/selection.js --- webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/selection.js 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/selection.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,193 +0,0 @@ -/* - * Copyright 2013-2014 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * webbrowser-app is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -// List of domains known to interfere with touch events listeners -var blacklist = [ - "m.8tracks.com", // http://pad.lv/1279903 -]; -if (blacklist.indexOf(document.domain) === -1) { - - function elementContainedInBox(element, box) { - var rect = element.getBoundingClientRect(); - return ((box.left <= rect.left) && (box.right >= rect.right) && - (box.top <= rect.top) && (box.bottom >= rect.bottom)); - } - - function getImgFullUri(uri) { - if ((uri.slice(0, 7) === 'http://') || - (uri.slice(0, 8) === 'https://') || - (uri.slice(0, 7) === 'file://')) { - return uri; - } else if (uri.slice(0, 1) === '/') { - var docuri = document.documentURI; - var firstcolon = docuri.indexOf('://'); - var protocol = 'http://'; - if (firstcolon !== -1) { - protocol = docuri.slice(0, firstcolon + 3); - } - return protocol + document.domain + uri; - } else { - var base = document.baseURI; - var lastslash = base.lastIndexOf('/'); - if (lastslash === -1) { - return base + '/' + uri; - } else { - return base.slice(0, lastslash + 1) + uri; - } - } - } - - function getSelectedData(element) { - var node = element; - var data = new Object; - - var nodeName = node.nodeName.toLowerCase(); - if (nodeName === 'img') { - data.img = getImgFullUri(node.getAttribute('src')); - } else if (nodeName === 'a') { - data.href = node.href; - data.title = node.title; - } - - // If the parent tag is a hyperlink, we want it too. - var parent = node.parentNode; - if ((nodeName !== 'a') && parent && (parent.nodeName.toLowerCase() === 'a')) { - data.href = parent.href; - data.title = parent.title; - node = parent; - } - - var boundingRect = node.getBoundingClientRect(); - data.left = boundingRect.left; - data.top = boundingRect.top; - data.width = boundingRect.width; - data.height = boundingRect.height; - - node = node.cloneNode(true); - // filter out script nodes - var scripts = node.getElementsByTagName('script'); - while (scripts.length > 0) { - var scriptNode = scripts[0]; - if (scriptNode.parentNode) { - scriptNode.parentNode.removeChild(scriptNode); - } - } - data.html = node.outerHTML; - data.nodeName = node.nodeName.toLowerCase(); - // FIXME: extract the text and images in the order they appear in the block, - // so that this order is respected when the data is pushed to the clipboard. - data.text = node.textContent; - var images = []; - var imgs = node.getElementsByTagName('img'); - for (var i = 0; i < imgs.length; i++) { - images.push(getImgFullUri(imgs[i].getAttribute('src'))); - } - if (images.length > 0) { - data.images = images; - } - - return data; - } - - function adjustSelection(selection) { - // FIXME: allow selecting two consecutive blocks, instead of - // interpolating to the containing block. - var centerX = (selection.left + selection.right) / 2; - var centerY = (selection.top + selection.bottom) / 2; - var element = document.elementFromPoint(centerX, centerY); - var parent = element; - while (elementContainedInBox(parent, selection)) { - parent = parent.parentNode; - } - element = parent; - return getSelectedData(element); - } - - function distance(touch1, touch2) { - return Math.sqrt(Math.pow(touch2.clientX - touch1.clientX, 2) + - Math.pow(touch2.clientY - touch1.clientY, 2)); - } - - navigator.qt.onmessage = function(message) { - var data = null; - try { - data = JSON.parse(message.data); - } catch (error) { - return; - } - if ('query' in data) { - if (data.query === 'adjustselection') { - var selection = adjustSelection(data); - selection.event = 'selectionadjusted'; - navigator.qt.postMessage(JSON.stringify(selection)); - } - } - } - - var longpressObserver = -1; - var currentTouch = null; - var longpressDetected = false; - - function longPressDetected(x, y) { - longpressDetected = true; - var element = document.elementFromPoint(x, y); - var data = getSelectedData(element); - data.event = 'longpress'; - navigator.qt.postMessage(JSON.stringify(data)); - } - - function clearLongpressTimeout() { - clearTimeout(longpressObserver); - longpressObserver = -1; - currentTouch = null; - } - - var doc = document.documentElement; - - doc.addEventListener('touchstart', function(event) { - if (event.touches.length == 1) { - currentTouch = event.touches[0]; - longpressObserver = setTimeout(longPressDetected, 800, currentTouch.clientX, currentTouch.clientY); - } - }); - - doc.addEventListener('touchend', function(event) { - if (longpressDetected) { - longpressDetected = false; - event.preventDefault(); - } - clearLongpressTimeout(); - }); - - doc.addEventListener('touchmove', function(event) { - if (!currentTouch) { - return; - } - if ((event.changedTouches.length > 1) || (distance(event.changedTouches[0], currentTouch) > 3)) { - clearLongpressTimeout(); - } - }); - - doc.addEventListener('touchcancel', function(event) { - if (longpressDetected) { - longpressDetected = false; - } - clearLongpressTimeout(); - }); - -} diff -Nru webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/ua-override-worker.js webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/ua-override-worker.js --- webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/ua-override-worker.js 1970-01-01 00:00:00.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/ua-override-worker.js 2014-03-28 17:07:01.000000000 +0000 @@ -0,0 +1,46 @@ +/* + * Copyright 2014 Canonical Ltd. + * + * This file is part of webbrowser-app. + * + * webbrowser-app is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * webbrowser-app is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +var overrides = [ + [/^https?:\/\/mail.google.com\//, "Mozilla/5.0 (Linux; Ubuntu 14.04 like Android 4.4) AppleWebKit/537.36 Chromium/35.0.1870.2 Mobile Safari"] +]; + +function getUAoverride(url) { + for (var i = 0; i < overrides.length; i++) { + var override = overrides[i]; + if (override[0].test(url)) { + return override[1]; + } + } + return null; +} + +exports.onBeforeSendHeaders = function(event) { + var override = getUAoverride(event.url); + if (override !== null) { + event.setHeader("User-Agent", override); + oxide.sendMessage({url: event.url, override: override}); + } +} + +exports.onGetUserAgentOverride = function(data) { + var override = getUAoverride(event.url); + if (override !== null) { + data.userAgentOverride = override; + } +} diff -Nru webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/UbuntuWebContext.qml webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/UbuntuWebContext.qml --- webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/UbuntuWebContext.qml 1970-01-01 00:00:00.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/UbuntuWebContext.qml 2014-03-28 17:07:01.000000000 +0000 @@ -0,0 +1,58 @@ +/* + * Copyright 2014 Canonical Ltd. + * + * This file is part of webbrowser-app. + * + * webbrowser-app is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * webbrowser-app is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +pragma Singleton + +import QtQuick 2.0 +import com.canonical.Oxide 0.1 + +Item { + property string customUA: userAgent.defaultUA + + property QtObject sharedContext: WebContext { + dataPath: dataLocation + userAgent: customUA + networkRequestDelegate: uaOverrideWorker.item + userAgentOverrideDelegate: networkRequestDelegate + userScripts: [ + UserScript { + context: "oxide://selection/" + url: Qt.resolvedUrl("selection02.js") + incognitoEnabled: true + matchAllFrames: true + } + ] + } + + Component { + id: uaOverrideWorkerComponent + + WebContextDelegateWorker { + source: Qt.resolvedUrl("ua-override-worker.js") + onMessage: console.log("Overriden UA for", message.url, ":", message.override) + } + } + Loader { + id: uaOverrideWorker + sourceComponent: (formFactor === "mobile") ? uaOverrideWorkerComponent : undefined + } + + UserAgent02 { + id: userAgent + } +} diff -Nru webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/UbuntuWebView01.qml webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/UbuntuWebView01.qml --- webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/UbuntuWebView01.qml 1970-01-01 00:00:00.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/UbuntuWebView01.qml 2014-03-28 17:07:01.000000000 +0000 @@ -0,0 +1,272 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * This file is part of webbrowser-app. + * + * webbrowser-app is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * webbrowser-app is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import QtQuick 2.0 +import QtWebKit 3.1 +import QtWebKit.experimental 1.0 +import Ubuntu.Components 0.1 +import Ubuntu.Components.Extras.Browser 0.1 +import Ubuntu.Components.Popups 0.1 + +/*! + \qmltype MainView + \inqmlmodule Ubuntu.Components.Extras.Browser 0.1 + \obsolete + \brief Custom Ubuntu WebView extending QtWebKit’s WebView + + This version of UbuntuWebView is deprecated and shouldn’t be used in new + code. Use version 0.2 or higher instead. +*/ +WebView { + id: _webview + + signal newTabRequested(url url) + + QtObject { + property real devicePixelRatio: QtWebKitDPR + onDevicePixelRatioChanged: { + // Do not make this patch to QtWebKit a hard requirement. + if (_webview.experimental.hasOwnProperty('devicePixelRatio')) { + _webview.experimental.devicePixelRatio = devicePixelRatio + } + } + } + + interactive: !selection.visible + maximumFlickVelocity: height * 5 + + /** + * Client overridable function called before the default treatment of a + * valid navigation request. This function can stop the navigation request + * if it sets the 'action' field of the request to IgnoreRequest. + * + */ + function navigationRequestedDelegate(request) { } + + UserAgent01 { + id: userAgent + } + + /** + * This function can be overridden by client applications that embed an + * UbuntuWebView to provide a static overridden UA string. + * If not overridden, the default UA string and the default override + * mechanism will be used. + */ + function getUAString() { + // Note that this function used to accept a 'url' parameter to allow + // embedders to implement a custom override mechanism. It was removed + // after observing that no application was using it, and to simplify + // the API. Embedders willing to provide a custom override mechanism + // can always override (at their own risk) the onNavigationRequested + // slot. + return undefined + } + experimental.userAgent: (_webview.getUAString() === undefined) ? userAgent.defaultUA : _webview.getUAString() + onNavigationRequested: { + request.action = WebView.AcceptRequest; + + navigationRequestedDelegate (request); + if (request.action === WebView.IgnoreRequest) + return; + + var staticUA = _webview.getUAString() + if (staticUA === undefined) { + _webview.experimental.userAgent = userAgent.getUAString(request.url) + } else { + _webview.experimental.userAgent = staticUA + } + } + + experimental.preferences.navigatorQtObjectEnabled: true + experimental.userScripts: [Qt.resolvedUrl("hyperlinks.js"), + Qt.resolvedUrl("selection01.js")] + experimental.onMessageReceived: { + var data = null + try { + data = JSON.parse(message.data) + } catch (error) { + console.debug('DEBUG:', message.data) + return + } + if ('event' in data) { + if (data.event === 'longpress') { + if (('img' in data) || ('href' in data)) { + contextualData.clear() + if ('img' in data) { + contextualData.img = data.img + } + if ('href' in data) { + contextualData.href = data.href + contextualData.title = data.title + } + contextualRectangle.position(data) + PopupUtils.open(contextualPopover, contextualRectangle) + return + } + } + if ((data.event === 'longpress') || (data.event === 'selectionadjusted')) { + selection.clearData() + selection.createData() + if ('html' in data) { + selection.mimedata.html = data.html + } + // FIXME: push the text and image data in the order + // they appear in the selected block. + if ('text' in data) { + selection.mimedata.text = data.text + } + if ('images' in data) { + // TODO: download and cache the images locally + // (grab them from the webview’s cache, if possible), + // and forward local URLs. + selection.mimedata.urls = data.images + } + selection.show(data.left, data.top, data.width, data.height) + } else if (data.event === 'newtab') { + newTabRequested(data.url) + } + } + } + + experimental.itemSelector: ItemSelector01 {} + + property alias selection: selection + property ActionList selectionActions + Selection { + id: selection + + anchors.fill: parent + visible: false + + property Item __popover: null + property var mimedata: null + + Component { + id: selectionPopover + ActionSelectionPopover { + grabDismissAreaEvents: false + actions: selectionActions + } + } + + function createData() { + if (mimedata === null) { + mimedata = Clipboard.newData() + } + } + + function clearData() { + if (mimedata !== null) { + delete mimedata + mimedata = null + } + } + + function actionTriggered() { + selection.visible = false + } + + function __showPopover() { + __popover = PopupUtils.open(selectionPopover, selection.rect) + var actions = __popover.actions.actions + for (var i in actions) { + actions[i].onTriggered.connect(actionTriggered) + } + } + + function show(x, y, width, height) { + var scale = _webview.experimental.test.contentsScale * _webview.experimental.test.devicePixelRatio + rect.x = x * scale + _webview.contentX + rect.y = y * scale + _webview.contentY + rect.width = width * scale + rect.height = height * scale + visible = true + __showPopover() + } + + onVisibleChanged: { + if (!visible && (__popover != null)) { + PopupUtils.close(__popover) + __popover = null + } + } + + onResized: { + var message = new Object + message.query = 'adjustselection' + var rect = selection.rect + var scale = _webview.experimental.test.contentsScale * _webview.experimental.test.devicePixelRatio + message.left = (rect.x - _webview.contentX) / scale + message.right = (rect.x + rect.width - _webview.contentX) / scale + message.top = (rect.y - _webview.contentY) / scale + message.bottom = (rect.y + rect.height - _webview.contentY) / scale + _webview.experimental.postMessage(JSON.stringify(message)) + } + + function copy() { + Clipboard.push(mimedata) + clearData() + } + } + + Item { + id: contextualRectangle + + visible: false + + function position(data) { + var scale = _webview.experimental.test.contentsScale * _webview.experimental.test.devicePixelRatio + x = data.left * scale + y = data.top * scale + width = data.width * scale + height = data.height * scale + } + } + property QtObject contextualData: QtObject { + property url href + property string title + property url img + + function clear() { + href = '' + title = '' + img = '' + } + } + + property ActionList contextualActions + Component { + id: contextualPopover + ActionSelectionPopover { + actions: contextualActions + } + } + + Scrollbar { + parent: _webview.parent + flickableItem: _webview + align: Qt.AlignTrailing + } + + Scrollbar { + parent: _webview.parent + flickableItem: _webview + align: Qt.AlignBottom + } +} diff -Nru webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/UbuntuWebView02.qml webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/UbuntuWebView02.qml --- webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/UbuntuWebView02.qml 1970-01-01 00:00:00.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/UbuntuWebView02.qml 2014-03-28 17:07:01.000000000 +0000 @@ -0,0 +1,299 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * This file is part of webbrowser-app. + * + * webbrowser-app is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * webbrowser-app is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import QtQuick 2.0 +import QtQuick.Window 2.0 +import com.canonical.Oxide 0.1 +import Ubuntu.Components 0.1 +import Ubuntu.Components.Popups 0.1 +import "." + +WebView { + id: _webview + + signal newTabRequested(url url) + + //interactive: !selection.visible + + /** + * Client overridable function called before the default treatment of a + * valid navigation request. This function can stop the navigation request + * if it sets the 'action' field of the request to IgnoreRequest. + * + */ + function navigationRequestedDelegate(request) { } + + /** + * This function can be overridden by client applications that embed an + * UbuntuWebView to provide a static overridden UA string. + * If not overridden, the default UA string and the default override + * mechanism will be used. + * + * Note: as the UA string is a property of the shared context, + * an application that embeds several UbuntuWebViews that define different + * custom UA strings will result in the last view instantiated setting the + * UA for all the views. + */ + function getUAString() { + return undefined + } + + context: UbuntuWebContext.sharedContext + Component.onCompleted: { + var customUA = getUAString() + if (customUA !== undefined) { + UbuntuWebContext.customUA = customUA + } + } + + messageHandlers: [ + ScriptMessageHandler { + msgId: "contextmenu" + contexts: ["oxide://selection/"] + callback: function(msg, frame) { + if (('img' in msg.args) || ('href' in msg.args)) { + if (internal.currentContextualMenu != null) { + PopupUtils.close(internal.currentContextualMenu) + } + contextualData.clear() + if ('img' in msg.args) { + contextualData.img = msg.args.img + } + if ('href' in msg.args) { + contextualData.href = msg.args.href + contextualData.title = msg.args.title + } + contextualRectangle.position(msg.args) + internal.currentContextualMenu = PopupUtils.open(contextualPopover, contextualRectangle) + } else if (internal.currentContextualMenu != null) { + PopupUtils.close(internal.currentContextualMenu) + } + } + }, + ScriptMessageHandler { + msgId: "scroll" + contexts: ["oxide://selection/"] + callback: function(msg, frame) { + if (internal.currentContextualMenu != null) { + PopupUtils.close(internal.currentContextualMenu) + } + } + } + ] + + /*onNavigationRequested: { + request.action = WebView.AcceptRequest; + + navigationRequestedDelegate (request); + if (request.action === WebView.IgnoreRequest) + return; + + var staticUA = _webview.getUAString() + if (staticUA === undefined) { + _webview.experimental.userAgent = userAgent.getUAString(request.url) + } else { + _webview.experimental.userAgent = staticUA + } + }*/ + + /*experimental.preferences.navigatorQtObjectEnabled: true + experimental.userScripts: [Qt.resolvedUrl("hyperlinks.js"), + Qt.resolvedUrl("selection.js")] + experimental.onMessageReceived: { + var data = null + try { + data = JSON.parse(message.data) + } catch (error) { + console.debug('DEBUG:', message.data) + return + } + if ('event' in data) { + if (data.event === 'longpress') { + if (('img' in data) || ('href' in data)) { + contextualData.clear() + if ('img' in data) { + contextualData.img = data.img + } + if ('href' in data) { + contextualData.href = data.href + contextualData.title = data.title + } + contextualRectangle.position(data) + PopupUtils.open(contextualPopover, contextualRectangle) + return + } + } + if ((data.event === 'longpress') || (data.event === 'selectionadjusted')) { + selection.clearData() + selection.createData() + if ('html' in data) { + selection.mimedata.html = data.html + } + // FIXME: push the text and image data in the order + // they appear in the selected block. + if ('text' in data) { + selection.mimedata.text = data.text + } + if ('images' in data) { + // TODO: download and cache the images locally + // (grab them from the webview’s cache, if possible), + // and forward local URLs. + selection.mimedata.urls = data.images + } + selection.show(data.left, data.top, data.width, data.height) + } else if (data.event === 'newtab') { + newTabRequested(data.url) + } + } + }*/ + + popupMenu: ItemSelector02 {} + + /*property alias selection: selection + property ActionList selectionActions + Selection { + id: selection + + anchors.fill: parent + visible: false + + property Item __popover: null + property var mimedata: null + + Component { + id: selectionPopover + ActionSelectionPopover { + grabDismissAreaEvents: false + actions: selectionActions + } + } + + function createData() { + if (mimedata === null) { + mimedata = Clipboard.newData() + } + } + + function clearData() { + if (mimedata !== null) { + delete mimedata + mimedata = null + } + } + + function actionTriggered() { + selection.visible = false + } + + function __showPopover() { + __popover = PopupUtils.open(selectionPopover, selection.rect) + var actions = __popover.actions.actions + for (var i in actions) { + actions[i].onTriggered.connect(actionTriggered) + } + } + + function show(x, y, width, height) { + var scale = _webview.experimental.test.contentsScale * _webview.experimental.test.devicePixelRatio + rect.x = x * scale + _webview.contentX + rect.y = y * scale + _webview.contentY + rect.width = width * scale + rect.height = height * scale + visible = true + __showPopover() + } + + onVisibleChanged: { + if (!visible && (__popover != null)) { + PopupUtils.close(__popover) + __popover = null + } + } + + onResized: { + var message = new Object + message.query = 'adjustselection' + var rect = selection.rect + var scale = _webview.experimental.test.contentsScale * _webview.experimental.test.devicePixelRatio + message.left = (rect.x - _webview.contentX) / scale + message.right = (rect.x + rect.width - _webview.contentX) / scale + message.top = (rect.y - _webview.contentY) / scale + message.bottom = (rect.y + rect.height - _webview.contentY) / scale + _webview.experimental.postMessage(JSON.stringify(message)) + } + + function copy() { + Clipboard.push(mimedata) + clearData() + } + }*/ + + Item { + id: contextualRectangle + + visible: false + + function position(data) { + x = data.left * data.scaleX + y = data.top * data.scaleY + width = data.width * data.scaleX + height = data.height * data.scaleY + } + } + property QtObject contextualData: QtObject { + property url href + property string title + property url img + + function clear() { + href = '' + title = '' + img = '' + } + } + + property ActionList contextualActions + Component { + id: contextualPopover + ActionSelectionPopover { + actions: contextualActions + } + } + + QtObject { + id: internal + property int lastLoadRequestStatus: -1 + property Item currentContextualMenu: null + } + + readonly property bool lastLoadSucceeded: internal.lastLoadRequestStatus === LoadEvent.TypeSucceeded + readonly property bool lastLoadStopped: internal.lastLoadRequestStatus === LoadEvent.TypeStopped + readonly property bool lastLoadFailed: internal.lastLoadRequestStatus === LoadEvent.TypeFailed + onLoadingChanged: { + if (loadEvent.url.toString() !== "data:text/html,chromewebdata") { + internal.lastLoadRequestStatus = loadEvent.type + } + } + + readonly property int screenOrientation: Screen.orientation + onScreenOrientationChanged: { + if (internal.currentContextualMenu != null) { + PopupUtils.close(internal.currentContextualMenu) + } + } +} diff -Nru webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/UbuntuWebView.qml webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/UbuntuWebView.qml --- webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/UbuntuWebView.qml 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/UbuntuWebView.qml 1970-01-01 00:00:00.000000000 +0000 @@ -1,263 +0,0 @@ -/* - * Copyright 2013 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * webbrowser-app is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.0 -import QtWebKit 3.1 -import QtWebKit.experimental 1.0 -import Ubuntu.Components 0.1 -import Ubuntu.Components.Extras.Browser 0.1 -import Ubuntu.Components.Popups 0.1 - -WebView { - id: _webview - - signal newTabRequested(url url) - - QtObject { - property real devicePixelRatio: QtWebKitDPR - onDevicePixelRatioChanged: { - // Do not make this patch to QtWebKit a hard requirement. - if (_webview.experimental.hasOwnProperty('devicePixelRatio')) { - _webview.experimental.devicePixelRatio = devicePixelRatio - } - } - } - - interactive: !selection.visible - maximumFlickVelocity: height * 5 - - /** - * Client overridable function called before the default treatment of a - * valid navigation request. This function can stop the navigation request - * if it sets the 'action' field of the request to IgnoreRequest. - * - */ - function navigationRequestedDelegate(request) { } - - UserAgent { - id: userAgent - } - - /** - * This function can be overridden by client applications that embed an - * UbuntuWebView to provide a static overridden UA string. - * If not overridden, the default UA string and the default override - * mechanism will be used. - */ - function getUAString() { - // Note that this function used to accept a 'url' parameter to allow - // embedders to implement a custom override mechanism. It was removed - // after observing that no application was using it, and to simplify - // the API. Embedders willing to provide a custom override mechanism - // can always override (at their own risk) the onNavigationRequested - // slot. - return undefined - } - experimental.userAgent: (_webview.getUAString() === undefined) ? userAgent.defaultUA : _webview.getUAString() - onNavigationRequested: { - request.action = WebView.AcceptRequest; - - navigationRequestedDelegate (request); - if (request.action === WebView.IgnoreRequest) - return; - - var staticUA = _webview.getUAString() - if (staticUA === undefined) { - _webview.experimental.userAgent = userAgent.getUAString(request.url) - } else { - _webview.experimental.userAgent = staticUA - } - } - - experimental.preferences.navigatorQtObjectEnabled: true - experimental.userScripts: [Qt.resolvedUrl("hyperlinks.js"), - Qt.resolvedUrl("selection.js")] - experimental.onMessageReceived: { - var data = null - try { - data = JSON.parse(message.data) - } catch (error) { - console.debug('DEBUG:', message.data) - return - } - if ('event' in data) { - if (data.event === 'longpress') { - if (('img' in data) || ('href' in data)) { - contextualData.clear() - if ('img' in data) { - contextualData.img = data.img - } - if ('href' in data) { - contextualData.href = data.href - contextualData.title = data.title - } - contextualRectangle.position(data) - PopupUtils.open(contextualPopover, contextualRectangle) - return - } - } - if ((data.event === 'longpress') || (data.event === 'selectionadjusted')) { - selection.clearData() - selection.createData() - if ('html' in data) { - selection.mimedata.html = data.html - } - // FIXME: push the text and image data in the order - // they appear in the selected block. - if ('text' in data) { - selection.mimedata.text = data.text - } - if ('images' in data) { - // TODO: download and cache the images locally - // (grab them from the webview’s cache, if possible), - // and forward local URLs. - selection.mimedata.urls = data.images - } - selection.show(data.left, data.top, data.width, data.height) - } else if (data.event === 'newtab') { - newTabRequested(data.url) - } - } - } - - experimental.itemSelector: ItemSelector {} - - property alias selection: selection - property ActionList selectionActions - Selection { - id: selection - - anchors.fill: parent - visible: false - - property Item __popover: null - property var mimedata: null - - Component { - id: selectionPopover - ActionSelectionPopover { - grabDismissAreaEvents: false - actions: selectionActions - } - } - - function createData() { - if (mimedata === null) { - mimedata = Clipboard.newData() - } - } - - function clearData() { - if (mimedata !== null) { - delete mimedata - mimedata = null - } - } - - function actionTriggered() { - selection.visible = false - } - - function __showPopover() { - __popover = PopupUtils.open(selectionPopover, selection.rect) - var actions = __popover.actions.actions - for (var i in actions) { - actions[i].onTriggered.connect(actionTriggered) - } - } - - function show(x, y, width, height) { - var scale = _webview.experimental.test.contentsScale * _webview.experimental.test.devicePixelRatio - rect.x = x * scale + _webview.contentX - rect.y = y * scale + _webview.contentY - rect.width = width * scale - rect.height = height * scale - visible = true - __showPopover() - } - - onVisibleChanged: { - if (!visible && (__popover != null)) { - PopupUtils.close(__popover) - __popover = null - } - } - - onResized: { - var message = new Object - message.query = 'adjustselection' - var rect = selection.rect - var scale = _webview.experimental.test.contentsScale * _webview.experimental.test.devicePixelRatio - message.left = (rect.x - _webview.contentX) / scale - message.right = (rect.x + rect.width - _webview.contentX) / scale - message.top = (rect.y - _webview.contentY) / scale - message.bottom = (rect.y + rect.height - _webview.contentY) / scale - _webview.experimental.postMessage(JSON.stringify(message)) - } - - function copy() { - Clipboard.push(mimedata) - clearData() - } - } - - Item { - id: contextualRectangle - - visible: false - - function position(data) { - var scale = _webview.experimental.test.contentsScale * _webview.experimental.test.devicePixelRatio - x = data.left * scale - y = data.top * scale - width = data.width * scale - height = data.height * scale - } - } - property QtObject contextualData: QtObject { - property url href - property string title - property url img - - function clear() { - href = '' - title = '' - img = '' - } - } - - property ActionList contextualActions - Component { - id: contextualPopover - ActionSelectionPopover { - actions: contextualActions - } - } - - Scrollbar { - parent: _webview.parent - flickableItem: _webview - align: Qt.AlignTrailing - } - - Scrollbar { - parent: _webview.parent - flickableItem: _webview - align: Qt.AlignBottom - } -} diff -Nru webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/UserAgent01.qml webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/UserAgent01.qml --- webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/UserAgent01.qml 1970-01-01 00:00:00.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/UserAgent01.qml 2014-03-28 17:07:01.000000000 +0000 @@ -0,0 +1,90 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * This file is part of webbrowser-app. + * + * webbrowser-app is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * webbrowser-app is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import QtQuick 2.0 +import QtQuick.Window 2.0 +import Ubuntu.Components 0.1 +import "ua-overrides.js" as Overrides + +/* + * Useful documentation: + * http://en.wikipedia.org/wiki/User_agent#Format + * https://developer.mozilla.org/en-US/docs/Gecko_user_agent_string_reference + * https://wiki.mozilla.org/B2G/User_Agent + * https://github.com/mozilla-b2g/gaia/blob/master/build/ua-override-prefs.js + * https://developers.google.com/chrome/mobile/docs/user-agent + */ + +// This is an Item, not a QtObject, because it needs information about the Screen. +Item { + // %1: form factor (Mobile, Tablet, Desktop) + // %2: WebKit version + readonly property string _template: "Mozilla/5.0 (Ubuntu; %1) WebKit/%2" + + // See Source/WebCore/Configurations/Version.xcconfig in QtWebKit’s source tree + // TODO: determine this value at runtime + readonly property string _webkitVersion: "537.21" + + // FIXME: this is a quick hack that will become increasingly unreliable + // as we support more devices, so we need a better solution for this + // FIXME: only handling phone and tablet for now, need to handle desktop too + readonly property string _formFactor: (Screen.width >= units.gu(60)) ? "Tablet" : "Mobile" + + property string defaultUA: _template.arg(_formFactor).arg(_webkitVersion) + + property var overrides: Overrides.overrides + + function getDomain(url) { + var domain = url.toString() + var indexOfScheme = domain.indexOf("://") + if (indexOfScheme !== -1) { + domain = domain.slice(indexOfScheme + 3) + } + var indexOfPath = domain.indexOf("/") + if (indexOfPath !== -1) { + domain = domain.slice(0, indexOfPath) + } + return domain + } + + function getDomains(domain) { + var components = domain.split(".") + var domains = [] + for (var i = 0; i < components.length; i++) { + domains.push(components.slice(i).join(".")) + } + return domains + } + + function getUAString(url) { + var ua = defaultUA + var domains = getDomains(getDomain(url)) + for (var i = 0; i < domains.length; i++) { + var domain = domains[i] + if (domain in overrides) { + var form = overrides[domain] + if (typeof form == "string") { + return form + } else if (typeof form == "object") { + return ua.replace(form[0], form[1]) + } + } + } + return ua + } +} diff -Nru webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/UserAgent02.qml webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/UserAgent02.qml --- webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/UserAgent02.qml 1970-01-01 00:00:00.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/UserAgent02.qml 2014-03-28 17:07:01.000000000 +0000 @@ -0,0 +1,62 @@ +/* + * Copyright 2013-2014 Canonical Ltd. + * + * This file is part of webbrowser-app. + * + * webbrowser-app is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * webbrowser-app is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import QtQml 2.0 + +/* + * Useful documentation: + * http://en.wikipedia.org/wiki/User_agent#Format + * https://developer.mozilla.org/en-US/docs/Gecko_user_agent_string_reference + * https://wiki.mozilla.org/B2G/User_Agent + * https://github.com/mozilla-b2g/gaia/blob/master/build/ua-override-prefs.js + * https://developers.google.com/chrome/mobile/docs/user-agent + */ + +QtObject { + // %1: Ubuntu version, e.g. "14.04" + // %2: optional token to specify further attributes of the platform (must start with a whitespace), e.g. "like Android" + // %3: optional hardware ID token (must start with a semi-colon if present) + // %4: WebKit version, e.g. "537.36" + // %5: Chromium version, e.g. "35.0.1870.2" + // %6: optional token to provide additional free-form information (must start with a whitespace), e.g. "Mobile" + // note #1: "Mozilla/5.0" is misinformation, but it is a legacy token that + // virtually every single UA out there has, it seems unwise to remove it + // note #2: "AppleWebKit", as opposed to plain "WebKit", does make a + // difference in the content served by certain sites (e.g. gmail.com) + readonly property string _template: "Mozilla/5.0 (Linux; Ubuntu %1%2%3) AppleWebKit/%4 Chromium/%5%6" + + // FIXME: compute at build time (using lsb_release) + readonly property string _ubuntuVersion: "14.04" + + readonly property string _attributes: (formFactor === "mobile") ? " like Android 4.4" : "" + + readonly property string _hardwareID: "" + + // See chromium/src/webkit/build/webkit_version.h.in in oxide’s source tree. + readonly property string _webkitVersion: "537.36" + + // See chromium/src/chrome/VERSION in oxide’s source tree. + // Note: the actual version number probably doesn’t matter that much, + // however its format does, so we probably don’t need to bump it + // every time we rebase on a newer chromium. + readonly property string _chromiumVersion: "35.0.1870.2" + + readonly property string _more: (formFactor === "mobile") ? " Mobile" : "" + + property string defaultUA: _template.arg(_ubuntuVersion).arg(_attributes).arg(_hardwareID).arg(_webkitVersion).arg(_chromiumVersion).arg(_more) +} diff -Nru webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/UserAgent.qml webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/UserAgent.qml --- webbrowser-app-0.23+14.04.20140324/src/Ubuntu/Components/Extras/Browser/UserAgent.qml 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/src/Ubuntu/Components/Extras/Browser/UserAgent.qml 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ -/* - * Copyright 2013 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * webbrowser-app is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.0 -import QtQuick.Window 2.0 -import Ubuntu.Components 0.1 -import "ua-overrides.js" as Overrides - -/* - * Useful documentation: - * http://en.wikipedia.org/wiki/User_agent#Format - * https://developer.mozilla.org/en-US/docs/Gecko_user_agent_string_reference - * https://wiki.mozilla.org/B2G/User_Agent - * https://github.com/mozilla-b2g/gaia/blob/master/build/ua-override-prefs.js - * https://developers.google.com/chrome/mobile/docs/user-agent - */ - -// This is an Item, not a QtObject, because it needs information about the Screen. -Item { - // %1: form factor (Mobile, Tablet, Desktop) - // %2: WebKit version - readonly property string _template: "Mozilla/5.0 (Ubuntu; %1) WebKit/%2" - - // See Source/WebCore/Configurations/Version.xcconfig in QtWebKit’s source tree - // TODO: determine this value at runtime - readonly property string _webkitVersion: "537.21" - - // FIXME: this is a quick hack that will become increasingly unreliable - // as we support more devices, so we need a better solution for this - // FIXME: only handling phone and tablet for now, need to handle desktop too - readonly property string _formFactor: (Screen.width >= units.gu(60)) ? "Tablet" : "Mobile" - - property string defaultUA: _template.arg(_formFactor).arg(_webkitVersion) - - property var overrides: Overrides.overrides - - function getDomain(url) { - var domain = url.toString() - var indexOfScheme = domain.indexOf("://") - if (indexOfScheme !== -1) { - domain = domain.slice(indexOfScheme + 3) - } - var indexOfPath = domain.indexOf("/") - if (indexOfPath !== -1) { - domain = domain.slice(0, indexOfPath) - } - return domain - } - - function getDomains(domain) { - var components = domain.split(".") - var domains = [] - for (var i = 0; i < components.length; i++) { - domains.push(components.slice(i).join(".")) - } - return domains - } - - function getUAString(url) { - var ua = defaultUA - var domains = getDomains(getDomain(url)) - for (var i = 0; i < domains.length; i++) { - var domain = domains[i] - if (domain in overrides) { - var form = overrides[domain] - if (typeof form == "string") { - return form - } else if (typeof form == "object") { - return ua.replace(form[0], form[1]) - } - } - } - return ua - } -} diff -Nru webbrowser-app-0.23+14.04.20140324/tests/autopilot/webbrowser_app/tests/test_tabs.py webbrowser-app-0.23+14.04.20140328.3/tests/autopilot/webbrowser_app/tests/test_tabs.py --- webbrowser-app-0.23+14.04.20140324/tests/autopilot/webbrowser_app/tests/test_tabs.py 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/tests/autopilot/webbrowser_app/tests/test_tabs.py 2014-03-28 17:07:01.000000000 +0000 @@ -17,6 +17,7 @@ from __future__ import absolute_import import time +import unittest from testtools.matchers import Equals from autopilot.matchers import Eventually @@ -140,6 +141,8 @@ address_bar = self.main_window.get_address_bar() self.assertThat(address_bar.activeFocus, Eventually(Equals(True))) + # FIXME: re-enable when implemented in oxide + @unittest.skip("not implemented in oxide yet") def test_open_target_blank_in_new_tab(self): url = self.base_url + "/blanktargetlink" self.go_to_url(url) @@ -149,6 +152,8 @@ self.assertThat(self.main_window.currentIndex, Eventually(Equals(1))) self.assert_current_url(self.base_url + "/aleaiactaest") + # FIXME: re-enable when implemented in oxide + @unittest.skip("not implemented in oxide yet") def test_open_iframe_target_blank_in_new_tab(self): url = self.base_url + "/fulliframewithblanktargetlink" self.go_to_url(url) diff -Nru webbrowser-app-0.23+14.04.20140324/tests/unittests/qml/CMakeLists.txt webbrowser-app-0.23+14.04.20140328.3/tests/unittests/qml/CMakeLists.txt --- webbrowser-app-0.23+14.04.20140324/tests/unittests/qml/CMakeLists.txt 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/tests/unittests/qml/CMakeLists.txt 2014-03-28 17:07:01.000000000 +0000 @@ -1,8 +1,15 @@ +set(XVFB_COMMAND) +find_program(XVFBRUN xvfb-run) +if(XVFBRUN) + set(XVFB_COMMAND ${XVFBRUN} -s "-screen 0 640x480x24" -a) +else() + message(WARNING "Cannot find xvfb-run.") +endif() + set(TEST tst_QmlTests) add_executable(${TEST} tst_QmlTests.cpp) qt5_use_modules(${TEST} Core Qml Quick Test QuickTest) -add_test(${TEST} ${CMAKE_CURRENT_BINARY_DIR}/${TEST} -import ${CMAKE_BINARY_DIR}/src) -set_tests_properties(${TEST} PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=minimal") +add_test(${TEST} ${XVFB_COMMAND} ${CMAKE_CURRENT_BINARY_DIR}/${TEST} -import ${CMAKE_BINARY_DIR}/src) # copy qml files under test to build dir set(out_qml_files) @@ -13,7 +20,7 @@ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${webbrowser-common_SOURCE_DIR}/${qmlFile} ${CMAKE_CURRENT_BINARY_DIR}/undertest/${qmlFile}) list(APPEND out_qml_files undertest/${qmlFile}) endforeach(qmlFile) -set(privateApiQmlFiles UserAgent.qml ua-overrides.js) +set(privateApiQmlFiles UserAgent01.qml UserAgent02.qml ua-overrides.js) foreach(qmlFile ${privateApiQmlFiles}) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/undertest/${qmlFile} DEPENDS ${webbrowser-plugin_SOURCE_DIR}/${qmlFile} diff -Nru webbrowser-app-0.23+14.04.20140324/tests/unittests/qml/tst_UbuntuWebView01.qml webbrowser-app-0.23+14.04.20140328.3/tests/unittests/qml/tst_UbuntuWebView01.qml --- webbrowser-app-0.23+14.04.20140324/tests/unittests/qml/tst_UbuntuWebView01.qml 1970-01-01 00:00:00.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/tests/unittests/qml/tst_UbuntuWebView01.qml 2014-03-28 17:07:01.000000000 +0000 @@ -0,0 +1,46 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * This file is part of webbrowser-app. + * + * webbrowser-app is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * webbrowser-app is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import QtQuick 2.0 +import QtTest 1.0 +import Ubuntu.Components.Extras.Browser 0.1 + +TestCase { + name: "UbuntuWebView" + + function test_custom_UA_override() { + compare(webview1.getUAString(), undefined) + // passing a 'url' parameter to getUAString() + // (as was the API before) shouldn’t hurt: + compare(webview1.getUAString("http://example.com"), undefined) + verify(webview1.experimental.userAgent !== undefined) + compare(webview2.experimental.userAgent, "custom UA") + } + + UbuntuWebView { + id: webview1 + } + + UbuntuWebView { + id: webview2 + + function getUAString(url) { + return "custom UA" + } + } +} diff -Nru webbrowser-app-0.23+14.04.20140324/tests/unittests/qml/tst_UbuntuWebView02.qml webbrowser-app-0.23+14.04.20140328.3/tests/unittests/qml/tst_UbuntuWebView02.qml --- webbrowser-app-0.23+14.04.20140324/tests/unittests/qml/tst_UbuntuWebView02.qml 1970-01-01 00:00:00.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/tests/unittests/qml/tst_UbuntuWebView02.qml 2014-03-28 17:07:01.000000000 +0000 @@ -0,0 +1,43 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * This file is part of webbrowser-app. + * + * webbrowser-app is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * webbrowser-app is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import QtQuick 2.0 +import QtTest 1.0 +import Ubuntu.Components.Extras.Browser 0.2 + +TestCase { + name: "UbuntuWebView" + + function test_custom_UA_override() { + compare(webview1.getUAString(), undefined) + verify(webview1.context.userAgent !== undefined) + compare(webview2.context.userAgent, "custom UA") + } + + UbuntuWebView { + id: webview1 + } + + UbuntuWebView { + id: webview2 + + function getUAString(url) { + return "custom UA" + } + } +} diff -Nru webbrowser-app-0.23+14.04.20140324/tests/unittests/qml/tst_UbuntuWebView.qml webbrowser-app-0.23+14.04.20140328.3/tests/unittests/qml/tst_UbuntuWebView.qml --- webbrowser-app-0.23+14.04.20140324/tests/unittests/qml/tst_UbuntuWebView.qml 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/tests/unittests/qml/tst_UbuntuWebView.qml 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* - * Copyright 2013 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * webbrowser-app is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.0 -import QtTest 1.0 -import Ubuntu.Components.Extras.Browser 0.1 - -TestCase { - name: "UbuntuWebView" - - function test_custom_UA_override() { - compare(webview1.getUAString(), undefined) - // passing a 'url' parameter to getUAString() - // (as was the API before) shouldn’t hurt: - compare(webview1.getUAString("http://example.com"), undefined) - verify(webview1.experimental.userAgent !== undefined) - compare(webview2.experimental.userAgent, "custom UA") - } - - UbuntuWebView { - id: webview1 - } - - UbuntuWebView { - id: webview2 - - function getUAString(url) { - return "custom UA" - } - } -} diff -Nru webbrowser-app-0.23+14.04.20140324/tests/unittests/qml/tst_UserAgent01.qml webbrowser-app-0.23+14.04.20140328.3/tests/unittests/qml/tst_UserAgent01.qml --- webbrowser-app-0.23+14.04.20140324/tests/unittests/qml/tst_UserAgent01.qml 1970-01-01 00:00:00.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/tests/unittests/qml/tst_UserAgent01.qml 2014-03-28 17:07:01.000000000 +0000 @@ -0,0 +1,82 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * This file is part of webbrowser-app. + * + * webbrowser-app is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * webbrowser-app is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import QtQuick 2.0 +import QtTest 1.0 +import "undertest" + +TestCase { + name: "UserAgent" + + function test_get_domain_data() { + return [ + {url: "http://ubuntu.com", domain: "ubuntu.com"}, + {url: "http://www.ubuntu.com", domain: "www.ubuntu.com"}, + {url: "http://ubuntu.com/", domain: "ubuntu.com"}, + {url: "http://www.ubuntu.com/", domain: "www.ubuntu.com"}, + {url: "ubuntu.com", domain: "ubuntu.com"}, + {url: "ubuntu.com/", domain: "ubuntu.com"}, + {url: "ubuntu.com/phone", domain: "ubuntu.com"}, + {url: "http://ubuntu.com/phone", domain: "ubuntu.com"}, + {url: "www.ubuntu.com/phone", domain: "www.ubuntu.com"}, + {url: "http://ubuntu.com/phone/index.html", domain: "ubuntu.com"}, + {url: "ubuntu.com/phone/index.html", domain: "ubuntu.com"}, + {url: "www.ubuntu.com/phone/index.html", domain: "www.ubuntu.com"}, + {url: "http://ubuntu.com/phone/index.html?foo=bar&baz=bleh", domain: "ubuntu.com"}, + ] + } + function test_get_domain(data) { + compare(userAgent.getDomain(data.url), data.domain) + } + + function test_get_domains_data() { + return [ + {domain: "ubuntu.com", domains: ["ubuntu.com", "com"]}, + {domain: "test.example.org", domains: ["test.example.org", "example.org", "org"]}, + ] + } + function test_get_domains(data) { + compare(userAgent.getDomains(data.domain), data.domains) + } + + function test_get_ua_string_data() { + return [ + {url: "http://ubuntu.com", ua: userAgent.defaultUA}, + {url: "http://example.org", ua: "full override"}, + {url: "http://example.com/test", ua: "Mozilla/5.0 (Ubuntu Edge; Mobile) WebKit/537.21"}, + {url: "http://www.google.com/", ua: "Mozilla/5.0 (Ubuntu; ble) WebKit/537.21"}, + {url: "https://mail.google.com/", ua: "Mozilla/5.0 (Ubuntu; Touch) WebKit/537.21"}, + ] + } + function test_get_ua_string(data) { + compare(userAgent.getUAString(data.url), data.ua) + } + + UserAgent01 { + id: userAgent + + defaultUA: "Mozilla/5.0 (Ubuntu; Mobile) WebKit/537.21" + + overrides: { + "example.org": "full override", + "example.com": ["Ubuntu", "Ubuntu Edge"], + "google.com": [/mobi/i, "b"], + "mail.google.com": [/mobile/i, "Touch"], + } + } +} diff -Nru webbrowser-app-0.23+14.04.20140324/tests/unittests/qml/tst_UserAgent.qml webbrowser-app-0.23+14.04.20140328.3/tests/unittests/qml/tst_UserAgent.qml --- webbrowser-app-0.23+14.04.20140324/tests/unittests/qml/tst_UserAgent.qml 2014-03-24 19:14:36.000000000 +0000 +++ webbrowser-app-0.23+14.04.20140328.3/tests/unittests/qml/tst_UserAgent.qml 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -/* - * Copyright 2013 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * webbrowser-app is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.0 -import QtTest 1.0 -import "undertest" - -TestCase { - name: "UserAgent" - - function test_get_domain_data() { - return [ - {url: "http://ubuntu.com", domain: "ubuntu.com"}, - {url: "http://www.ubuntu.com", domain: "www.ubuntu.com"}, - {url: "http://ubuntu.com/", domain: "ubuntu.com"}, - {url: "http://www.ubuntu.com/", domain: "www.ubuntu.com"}, - {url: "ubuntu.com", domain: "ubuntu.com"}, - {url: "ubuntu.com/", domain: "ubuntu.com"}, - {url: "ubuntu.com/phone", domain: "ubuntu.com"}, - {url: "http://ubuntu.com/phone", domain: "ubuntu.com"}, - {url: "www.ubuntu.com/phone", domain: "www.ubuntu.com"}, - {url: "http://ubuntu.com/phone/index.html", domain: "ubuntu.com"}, - {url: "ubuntu.com/phone/index.html", domain: "ubuntu.com"}, - {url: "www.ubuntu.com/phone/index.html", domain: "www.ubuntu.com"}, - {url: "http://ubuntu.com/phone/index.html?foo=bar&baz=bleh", domain: "ubuntu.com"}, - ] - } - function test_get_domain(data) { - compare(userAgent.getDomain(data.url), data.domain) - } - - function test_get_domains_data() { - return [ - {domain: "ubuntu.com", domains: ["ubuntu.com", "com"]}, - {domain: "test.example.org", domains: ["test.example.org", "example.org", "org"]}, - ] - } - function test_get_domains(data) { - compare(userAgent.getDomains(data.domain), data.domains) - } - - function test_get_ua_string_data() { - return [ - {url: "http://ubuntu.com", ua: userAgent.defaultUA}, - {url: "http://example.org", ua: "full override"}, - {url: "http://example.com/test", ua: "Mozilla/5.0 (Ubuntu Edge; Mobile) WebKit/537.21"}, - {url: "http://www.google.com/", ua: "Mozilla/5.0 (Ubuntu; ble) WebKit/537.21"}, - {url: "https://mail.google.com/", ua: "Mozilla/5.0 (Ubuntu; Touch) WebKit/537.21"}, - ] - } - function test_get_ua_string(data) { - compare(userAgent.getUAString(data.url), data.ua) - } - - UserAgent { - id: userAgent - - defaultUA: "Mozilla/5.0 (Ubuntu; Mobile) WebKit/537.21" - - overrides: { - "example.org": "full override", - "example.com": ["Ubuntu", "Ubuntu Edge"], - "google.com": [/mobi/i, "b"], - "mail.google.com": [/mobile/i, "Touch"], - } - } -}