Merge lp:~abreu-alexandre/webbrowser-app/theme-color-meta-detection into lp:webbrowser-app

Proposed by Alexandre Abreu
Status: Merged
Approved by: Alberto Mardegan
Approved revision: no longer in the source branch.
Merged at revision: 1320
Proposed branch: lp:~abreu-alexandre/webbrowser-app/theme-color-meta-detection
Merge into: lp:webbrowser-app
Diff against target: 322 lines (+211/-2)
8 files modified
src/app/ChromeBase.qml (+2/-0)
src/app/webcontainer/CMakeLists.txt (+1/-1)
src/app/webcontainer/WebApp.qml (+5/-0)
src/app/webcontainer/WebViewImplOxide.qml (+43/-1)
src/app/webcontainer/WebappContainerWebview.qml (+8/-0)
src/app/webcontainer/webapp-specific-page-metadata-collector.js (+56/-0)
tests/autopilot/webapp_container/tests/fake_servers.py (+47/-0)
tests/autopilot/webapp_container/tests/test_page_meta_collector.py (+49/-0)
To merge this branch: bzr merge lp:~abreu-alexandre/webbrowser-app/theme-color-meta-detection
Reviewer Review Type Date Requested Status
Alberto Mardegan (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+279120@code.launchpad.net

Commit message

Handle theme_color page metainformation.

Description of the change

Handle theme_color page meta information as described here:

https://developers.google.com/web/updates/2014/11/Support-for-theme-color-in-Chrome-39-for-Android?hl=en

Test Case
---------

1. Go to a website that supports the theme_color meta info, e.g.

http://browsernative.com/theme-color-meta-tag-chrome-android-lollipop-546/

2. MAke sure that the background color of the navigation ui is updated,

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alberto Mardegan (mardy) wrote :

Since the tests are there, the description needs an update.

The code is good, I just wonder if we should implement some tricks on the text colour, to ensure that it's always visible against the background.

review: Approve
1295. By CI Train Bot Account

Resync trunk.

1296. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1297. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1298. By Zsombor Egri

Fix local Toolbar collision with UITK 1.3 Toolbar.
Approved by: Olivier Tilloy, Zoltan Balogh

1299. By Olivier Tilloy

Work around what appears to be a regression in the UITK by specifying a non-null delay when swiping a list item to delete it in unit tests. Fixes: #1526940
Approved by: Michael Sheldon

1300. By CI Train Bot Account

Releasing 0.23+16.04.20151218-0ubuntu1

1301. By Michael Sheldon

Add support for handling downloads internally within the browser. Fixes: #1354391
Approved by: Olivier Tilloy

1302. By CI Train Bot Account

Releasing 0.23+16.04.20151221-0ubuntu1

1303. By Olivier Tilloy

Update translation template.

1304. By Olivier Tilloy

Recognize openoffice and MS-office file formats as documents, now that the document viewer app knows how to render them. Fixes: #1523452
Approved by: Michael Sheldon, PS Jenkins bot

1305. By Olivier Tilloy

Do not allow interacting with tabs and the chrome while the settings page is shown. Fixes: #1524353
Approved by: PS Jenkins bot, Ugo Riboni

1306. By Olivier Tilloy

Use the screen size (diagonal in millimeters) to determine which default UA string and which UA overrides to use.
An empirical threshold of 19cm is being used, it is subject to further adjustments. Fixes: #1504084
Approved by: PS Jenkins bot

1307. By Olivier Tilloy

Add keyboard shorcuts for 'next' (Ctrl+G) and 'previous' (Ctrl+Shift+G) while in find-in-page mode. Fixes: #1522152
Approved by: PS Jenkins bot, Ugo Riboni

1308. By Olivier Tilloy

Fix the tab preview sometimes covering the tab chrome, in the tabs view.
Offset tab previews by 1px to cover the semi-transparent horizontal line at the bottom of the tab chrome asset. Fixes: #1520624
Approved by: PS Jenkins bot, Ugo Riboni

1309. By Olivier Tilloy

Fix some obvious issues in PreviewManager. Fixes: #1519019
Approved by: PS Jenkins bot, Ugo Riboni

1310. By Olivier Tilloy

Fix a crash when clearing the navigation history while the new tab view is open. Fixes: #1525937
Approved by: Ugo Riboni

1311. By Olivier Tilloy

Fix deleting multiple domains from the history view.
Add unit tests for the HistoryView component. Fixes: #1527144

1312. By CI Train Bot Account

Releasing 0.23+16.04.20151222.1-0ubuntu1

1313. By CI Train Bot Account

Resync trunk.

1314. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1315. By Alexandre Abreu

Make the webapp-container click hook more flexible. Instead of being able to delete cache & resource folders as the click is being uninstalled, one can also act on them as the click is being upgraded & installed. Fixes: #1522562
Approved by: PS Jenkins bot, Alberto Mardegan

1316. By Alexandre Abreu

Handle empty url pattern in configuration file and invalid url pattern being specified. Fixes: #1522585
Approved by: PS Jenkins bot, Alberto Mardegan

1317. By Alexandre Abreu

Handle application crashes or OOM interventions & save opened overlays Fixes: #1508969
Approved by: PS Jenkins bot, Alberto Mardegan

1318. By Alexandre Abreu

Limited handling of custom context menu for the container
Approved by: Alberto Mardegan

1319. By CI Train Bot Account

Releasing 0.23+16.04.20160106.4-0ubuntu1

1320. By Alexandre Abreu

Handle theme-color metadata

1321. By Alexandre Abreu

Add forgottten js file install

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/app/ChromeBase.qml'
--- src/app/ChromeBase.qml 2015-08-10 15:22:00 +0000
+++ src/app/ChromeBase.qml 2016-01-08 19:32:31 +0000
@@ -23,6 +23,8 @@
23StyledItem {23StyledItem {
24 id: chrome24 id: chrome
2525
26 objectName: "chromeBase"
27
26 property var webview28 property var webview
27 property alias backgroundColor: backgroundRect.color29 property alias backgroundColor: backgroundRect.color
2830
2931
=== modified file 'src/app/webcontainer/CMakeLists.txt'
--- src/app/webcontainer/CMakeLists.txt 2015-09-29 19:31:47 +0000
+++ src/app/webcontainer/CMakeLists.txt 2016-01-08 19:32:31 +0000
@@ -40,7 +40,7 @@
40install(TARGETS ${WEBAPP_CONTAINER}40install(TARGETS ${WEBAPP_CONTAINER}
41 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})41 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
4242
43file(GLOB QML_FILES *.qml)43file(GLOB QML_FILES *.qml *.js)
44install(FILES ${QML_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/webbrowser-app/webcontainer)44install(FILES ${QML_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/webbrowser-app/webcontainer)
45install(DIRECTORY actions DESTINATION ${CMAKE_INSTALL_DATADIR}/webbrowser-app/webcontainer45install(DIRECTORY actions DESTINATION ${CMAKE_INSTALL_DATADIR}/webbrowser-app/webcontainer
46 FILES_MATCHING PATTERN *.qml)46 FILES_MATCHING PATTERN *.qml)
4747
=== modified file 'src/app/webcontainer/WebApp.qml'
--- src/app/webcontainer/WebApp.qml 2016-01-06 19:43:23 +0000
+++ src/app/webcontainer/WebApp.qml 2016-01-08 19:32:31 +0000
@@ -140,6 +140,11 @@
140 height: parent.height - osk.height140 height: parent.height - osk.height
141 developerExtrasEnabled: webapp.developerExtrasEnabled141 developerExtrasEnabled: webapp.developerExtrasEnabled
142142
143 onThemeColorMetaInformationDetected: {
144 if (!webapp.chromeless && chromeLoader.item) {
145 chromeLoader.item.backgroundColor = theme_color
146 }
147 }
143 onSamlRequestUrlPatternReceived: {148 onSamlRequestUrlPatternReceived: {
144 addGeneratedUrlPattern(urlPattern)149 addGeneratedUrlPattern(urlPattern)
145 }150 }
146151
=== modified file 'src/app/webcontainer/WebViewImplOxide.qml'
--- src/app/webcontainer/WebViewImplOxide.qml 2016-01-06 19:43:23 +0000
+++ src/app/webcontainer/WebViewImplOxide.qml 2016-01-08 19:32:31 +0000
@@ -46,6 +46,7 @@
46 property bool blockOpenExternalUrls: false46 property bool blockOpenExternalUrls: false
4747
48 signal samlRequestUrlPatternReceived(string urlPattern)48 signal samlRequestUrlPatternReceived(string urlPattern)
49 signal themeColorMetaInformationDetected(string theme_color)
4950
50 // Those signals are used for testing purposes to externally51 // Those signals are used for testing purposes to externally
51 // track down the various internal logic & steps of a popup lifecycle.52 // track down the various internal logic & steps of a popup lifecycle.
@@ -69,7 +70,25 @@
69 context: WebContext {70 context: WebContext {
70 dataPath: webview.dataPath71 dataPath: webview.dataPath
71 userAgent: localUserAgentOverride ? localUserAgentOverride : defaultUserAgent72 userAgent: localUserAgentOverride ? localUserAgentOverride : defaultUserAgent
73
74 userScripts: [
75 Oxide.UserScript {
76 context: "oxide://webapp-specific-page-metadata-collector/"
77 url: Qt.resolvedUrl("webapp-specific-page-metadata-collector.js")
78 incognitoEnabled: false
79 matchAllFrames: false
80 }
81 ]
72 }82 }
83 messageHandlers: [
84 Oxide.ScriptMessageHandler {
85 msgId: "webapp-specific-page-metadata-detected"
86 contexts: ["oxide://webapp-specific-page-metadata-collector/"]
87 callback: function(msg, frame) {
88 handlePageMetadata(msg.args)
89 }
90 }
91 ]
7392
74 preferences.allowFileAccessFromFileUrls: runningLocalApplication93 preferences.allowFileAccessFromFileUrls: runningLocalApplication
75 preferences.allowUniversalAccessFromFileUrls: runningLocalApplication94 preferences.allowUniversalAccessFromFileUrls: runningLocalApplication
@@ -319,6 +338,30 @@
319 }338 }
320 }339 }
321340
341 function handlePageMetadata(metadata) {
342 if (metadata.type === 'manifest') {
343 var request = new XMLHttpRequest();
344 request.onreadystatechange = function() {
345 if (request.readyState === XMLHttpRequest.DONE) {
346 try {
347 var manifest = JSON.parse(request.responseText);
348 if (manifest['theme_color']
349 && manifest['theme_color'].length !== 0) {
350 themeColorMetaInformationDetected(manifest['theme_color'])
351 }
352 } catch(e) {}
353 }
354 }
355 request.open("GET", metadata.manifest);
356 request.send();
357 } else if (metadata.type === 'theme-color') {
358 if (metadata['theme_color']
359 && metadata['theme_color'].length !== 0) {
360 themeColorMetaInformationDetected(metadata['theme_color'])
361 }
362 }
363 }
364
322 onShowDownloadDialog: {365 onShowDownloadDialog: {
323 if (downloadDialogLoader.status === Loader.Ready) {366 if (downloadDialogLoader.status === Loader.Ready) {
324 var downloadDialog = PopupUtils.open(downloadDialogLoader.item, webview, {"contentType" : contentType,367 var downloadDialog = PopupUtils.open(downloadDialogLoader.item, webview, {"contentType" : contentType,
@@ -341,5 +384,4 @@
341 source: "ContentPickerDialog.qml"384 source: "ContentPickerDialog.qml"
342 asynchronous: true385 asynchronous: true
343 }386 }
344
345}387}
346388
=== modified file 'src/app/webcontainer/WebappContainerWebview.qml'
--- src/app/webcontainer/WebappContainerWebview.qml 2016-01-06 19:43:23 +0000
+++ src/app/webcontainer/WebappContainerWebview.qml 2016-01-08 19:32:31 +0000
@@ -42,6 +42,7 @@
42 property bool wide: false42 property bool wide: false
4343
44 signal samlRequestUrlPatternReceived(string urlPattern)44 signal samlRequestUrlPatternReceived(string urlPattern)
45 signal themeColorMetaInformationDetected(string theme_color)
4546
46 onWideChanged: if (webappContainerWebViewLoader.item) webappContainerWebViewLoader.item.wide = wide47 onWideChanged: if (webappContainerWebViewLoader.item) webappContainerWebViewLoader.item.wide = wide
4748
@@ -70,6 +71,13 @@
70 }71 }
71 }72 }
7273
74 Connections {
75 target: webappContainerWebViewLoader.item
76 onThemeColorMetaInformationDetected: {
77 themeColorMetaInformationDetected(theme_color)
78 }
79 }
80
73 Loader {81 Loader {
74 id: webappContainerWebViewLoader82 id: webappContainerWebViewLoader
75 objectName: "containerWebviewLoader"83 objectName: "containerWebviewLoader"
7684
=== added file 'src/app/webcontainer/webapp-specific-page-metadata-collector.js'
--- src/app/webcontainer/webapp-specific-page-metadata-collector.js 1970-01-01 00:00:00 +0000
+++ src/app/webcontainer/webapp-specific-page-metadata-collector.js 2016-01-08 19:32:31 +0000
@@ -0,0 +1,56 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This file is part of webbrowser-app.
5 *
6 * webbrowser-app is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * webbrowser-app is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19(function() {
20 function detectThemeColorMetaInformation() {
21 var theme_color_meta =
22 document.head.querySelector('meta[name="theme-color"]');
23 if (theme_color_meta) {
24 oxide.sendMessage(
25 'webapp-specific-page-metadata-detected', {
26 type: 'theme-color',
27 baseurl: document.location.href,
28 theme_color: theme_color_meta.getAttribute('content')
29 });
30 return true;
31 }
32 return false;
33 }
34 function detectManifestMetaInformation() {
35 var manifest = document.head.querySelector('link[rel="manifest"]');
36
37 if (manifest && manifest.getAttribute('href')) {
38 oxide.sendMessage(
39 'webapp-specific-page-metadata-detected', {
40 type: 'manifest',
41 baseurl: document.location.href,
42 manifest: manifest.href
43 });
44 return true;
45 }
46
47 return false;
48 }
49
50 var detectors = [detectThemeColorMetaInformation, detectManifestMetaInformation]
51 for (var i in detectors) {
52 if (detectors[i]()) {
53 break;
54 }
55 }
56})();
057
=== modified file 'tests/autopilot/webapp_container/tests/fake_servers.py'
--- tests/autopilot/webapp_container/tests/fake_servers.py 2015-12-17 13:56:54 +0000
+++ tests/autopilot/webapp_container/tests/fake_servers.py 2016-01-08 19:32:31 +0000
@@ -117,6 +117,39 @@
117 </html>117 </html>
118 """.format(loopcount)118 """.format(loopcount)
119119
120 def manifest_json_content(self):
121 return """
122{
123 "name": "Theme Color",
124 "short_name": "Theme Color",
125 "icons": [],
126 "theme_color": "#FF0000"
127} """
128
129 def theme_color_content(self, color, with_manifest=False):
130 color_content = ''
131 if color:
132 color_content = """
133<meta name=\"theme-color\" content=\"{}\"></meta>
134""".format(color)
135 manifest_content = ''
136 if with_manifest:
137 manifest_content = "<link rel=\"manifest\" href=\"manifest.json\">"
138
139 return """
140<html>
141<head>
142{}
143{}
144<title>theme-color</title>
145<script>
146</script>
147</head>
148<body>
149</body>
150</html>
151 """.format(color_content, manifest_content)
152
120 def open_close_content(self):153 def open_close_content(self):
121 return """154 return """
122<html>155<html>
@@ -187,6 +220,20 @@
187 elif self.path == '/open-close-content':220 elif self.path == '/open-close-content':
188 self.send_response(200)221 self.send_response(200)
189 self.serve_content(self.open_close_content())222 self.serve_content(self.open_close_content())
223 elif self.path == '/theme-color/manifest.json':
224 self.send_response(200)
225 self.serve_content(self.manifest_json_content())
226 elif self.path.startswith('/theme-color/'):
227 args = self.path[len('/theme-color/'):]
228 self.send_response(200)
229 color = ''
230 if args.startswith('?color='):
231 color = args[len('?color='):]
232 with_manifest = False
233 if args.startswith('?manifest='):
234 with_manifest = True
235 self.send_response(200)
236 self.serve_content(self.theme_color_content(color, with_manifest))
190 elif self.path.startswith('/saml/'):237 elif self.path.startswith('/saml/'):
191 args = self.path[len('/saml/'):]238 args = self.path[len('/saml/'):]
192 loopCount = 0239 loopCount = 0
193240
=== added file 'tests/autopilot/webapp_container/tests/test_page_meta_collector.py'
--- tests/autopilot/webapp_container/tests/test_page_meta_collector.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/webapp_container/tests/test_page_meta_collector.py 2016-01-08 19:32:31 +0000
@@ -0,0 +1,49 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2015 Canonical
3#
4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16from webapp_container.tests import WebappContainerTestCaseWithLocalContentBase
17
18from testtools.matchers import Equals
19from autopilot.matchers import Eventually
20
21
22class TestPageMetaCollector(WebappContainerTestCaseWithLocalContentBase):
23 def test_update_theme_color(self):
24 args = ['--enable-addressbar']
25 self.launch_webcontainer_app_with_local_http_server(
26 args,
27 '/theme-color/?color=red')
28 self.get_webcontainer_window().visible.wait_for(True)
29
30 chrome_base = self.app.wait_select_single(
31 objectName="chromeBase")
32
33 self.assertThat(
34 lambda: str(chrome_base.backgroundColor),
35 Eventually(Equals("Color(255, 0, 0, 255)")))
36
37 def test_update_theme_color_with_manifest(self):
38 args = ['--enable-addressbar']
39 self.launch_webcontainer_app_with_local_http_server(
40 args,
41 '/theme-color/?manifest=true')
42 self.get_webcontainer_window().visible.wait_for(True)
43
44 chrome_base = self.app.wait_select_single(
45 objectName="chromeBase")
46
47 self.assertThat(
48 lambda: str(chrome_base.backgroundColor),
49 Eventually(Equals("Color(255, 0, 0, 255)")))

Subscribers

People subscribed via source and target branches

to status/vote changes: