Merge lp:~justinmcp/unity-chromium-extension/1469601 into lp:unity-chromium-extension

Proposed by Justin McPherson
Status: Needs review
Proposed branch: lp:~justinmcp/unity-chromium-extension/1469601
Merge into: lp:unity-chromium-extension
Diff against target: 582 lines (+167/-143)
13 files modified
chromium-extension/background-page.js (+63/-60)
chromium-extension/chromium-extension.pro (+3/-3)
chromium-extension/infobar.css (+0/-20)
chromium-extension/infobar.html (+0/-20)
chromium-extension/infobar.js (+0/-33)
chromium-extension/manifest.json.in (+12/-4)
chromium-extension/options.js (+2/-2)
chromium-extension/popup.css (+21/-0)
chromium-extension/popup.html (+20/-0)
chromium-extension/popup.js (+33/-0)
debian/changelog (+7/-0)
debian/control (+1/-1)
messaging-host/main.cpp (+5/-0)
To merge this branch: bzr merge lp:~justinmcp/unity-chromium-extension/1469601
Reviewer Review Type Date Requested Status
Alexandre Abreu Pending
WebApps Pending
Review via email: mp+263316@code.launchpad.net
To post a comment you must log in.
Revision history for this message
David Barth (dbarth) wrote :

lgtm

257. By Justin McPherson

Add check for new enumeration value in Qt >= 5.5.

Unmerged revisions

257. By Justin McPherson

Add check for new enumeration value in Qt >= 5.5.

256. By Justin McPherson <justin@phablet-dev>

WIP

255. By Justin McPherson <justin@phablet-dev>

WIP

254. By Justin McPherson <justin@phablet-dev>

WIP

253. By Justin McPherson <justin@phablet-dev>

WIP

252. By Justin McPherson <justin@phablet-dev>

WIP

251. By Justin McPherson <justin@phablet-dev>

WIP

250. By Justin McPherson <justin@phablet-dev>

WIP

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'chromium-extension/background-page.js'
2--- chromium-extension/background-page.js 2014-06-20 06:16:48 +0000
3+++ chromium-extension/background-page.js 2016-05-11 04:47:43 +0000
4@@ -1,17 +1,17 @@
5 /* Chromium Unity integration extension
6- *
7+ *
8 * Copyright 2012 Canonical Ltd.
9 *
10- * This program is free software: you can redistribute it and/or modify it
11- * under the terms of the GNU General Public License version 3, as published
12+ * This program is free software: you can redistribute it and/or modify it
13+ * under the terms of the GNU General Public License version 3, as published
14 * by the Free Software Foundation.
15 *
16- * This program is distributed in the hope that it will be useful, but
17- * WITHOUT ANY WARRANTY; without even the implied warranties of
18- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
19+ * This program is distributed in the hope that it will be useful, but
20+ * WITHOUT ANY WARRANTY; without even the implied warranties of
21+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
22 * PURPOSE. See the GNU General Public License for more details.
23 *
24- * You should have received a copy of the GNU General Public License along
25+ * You should have received a copy of the GNU General Public License along
26 * with this program. If not, see <http://www.gnu.org/licenses/>.
27 **/
28
29@@ -22,7 +22,7 @@
30 var host_callbacks = [];
31
32 var portListener = function (msg) {
33- callback = host_callbacks.pop();
34+ callback = host_callbacks.pop();
35 if (callback === undefined) {
36 return;
37 }
38@@ -30,12 +30,10 @@
39 };
40
41 var portDisconnecter = function () {
42- console.log('UCX: port disconnected');
43- port = null
44+ port = null;
45 };
46
47 var sendNativeMessage = function (msg, callback) {
48- console.log("UCX: sendnativemessage: port=" + port);
49 if (port === null) {
50 port = chrome.runtime.connectNative(HOST_ADDRESS);
51 port.onMessage.addListener(portListener);
52@@ -50,46 +48,42 @@
53
54
55 /////////////////////////////////////////////////////////
56- //
57- // Scafolding to keep track of data associated w/ infobar requests
58+ //
59+ // Scafolding to keep track of data associated w/ pageaction requests
60 // (Chromium's structure imposes some kind of state being maintained
61- // in order to communicate data)
62- //
63+ // in order to communicate data)
64+ //
65 ////////////////////////////////////////////////////////
66- //
67+ //
68 // list of callback that are to be called asynchronously
69 // per tab. Used in the user integration/installation resquests context.
70- //
71- // One thing to keep in mind is that one constraint, that bring some amount of
72- // 'soundness' is that there is a hard limit (provided by the browser) of one infobar per tab.
73
74- var user_infobar_request_callbacks = {};
75- var addInfobarRequestCallbackFor = function (infobarRequestId, callback, message, details) {
76- user_infobar_request_callbacks[infobarRequestId] = {
77+ var user_popup_request_callbacks = {};
78+ var addPopupRequestCallbackFor = function (popupRequestId, callback, message, details) {
79+ user_popup_request_callbacks[popupRequestId] = {
80 callback: callback,
81 message: message,
82 details: details
83 };
84 };
85
86- var getDataIfAnyFor = function (infobarRequestId) {
87- if (user_infobar_request_callbacks[infobarRequestId] === undefined) {
88+ var getDataIfAnyFor = function (popupRequestId) {
89+ if (user_popup_request_callbacks[popupRequestId] === undefined) {
90 return "";
91 }
92 return {
93- message: user_infobar_request_callbacks[infobarRequestId].message,
94- details: user_infobar_request_callbacks[infobarRequestId].details
95+ message: user_popup_request_callbacks[popupRequestId].message,
96+ details: user_popup_request_callbacks[popupRequestId].details
97 };
98 };
99-
100- var invokeAndRemoveCallbackIfAnyFor = function (infobarRequestId, arguments) {
101- if (user_infobar_request_callbacks[infobarRequestId] === undefined) {
102+ var invokeAndRemoveCallbackIfAnyFor = function (popupRequestId, args) {
103+ if (user_popup_request_callbacks[popupRequestId] === undefined) {
104 return;
105 }
106- var callback = user_infobar_request_callbacks[infobarRequestId].callback;
107- user_infobar_request_callbacks[infobarRequestId] = undefined;
108+ var callback = user_popup_request_callbacks[popupRequestId].callback;
109+ user_popup_request_callbacks[popupRequestId] = undefined;
110 if (typeof(callback) === 'function') {
111- callback(arguments);
112+ callback(args);
113 }
114 };
115
116@@ -106,35 +100,37 @@
117 },
118 function (response) {
119 if (response.available) {
120- addInfobarRequestCallbackFor(
121+ addPopupRequestCallbackFor(
122 windowInfos.tabId,
123 function (result) {
124 if (result && result.integrate) {
125 sendNativeMessage({
126 "method" : "install",
127 "url" : url
128- })
129+ });
130 } else {
131 sendNativeMessage({
132 "method" : "dont_ask",
133 "url" : url
134- })
135+ });
136 }
137+
138+ chrome.pageAction.hide(windowInfos.tabId);
139 },
140 chrome.i18n.getMessage("integration_copy", [ response.appName, response.appDomain ]),
141 null);
142
143- chrome.infobars.show({ tabId: windowInfos.tabId, path: "infobar.html" });
144+ chrome.pageAction.show(windowInfos.tabId);
145 }
146 });
147- };
148-
149-
150+ };
151+
152+
153 // {{{ main request handler
154-
155+
156 /**
157 * Handles & responds to content script requests.
158- *
159+ *
160 */
161 var init_requested_stamps = {};
162 var contentScriptsRequestHandler = function (request, sender, callback) {
163@@ -144,10 +140,10 @@
164 logging: false,
165 incognito: sender.tab.incognito
166 };
167-
168+
169 try {
170 if (window.localStorage) {
171- settings.logging = localStorage['logging'];
172+ settings.logging = localStorage.logging;
173 }
174 }
175 catch (e) {
176@@ -156,8 +152,8 @@
177
178 callback (settings);
179 },
180- on_user_infobar_request_result: function (request, sender, callback) {
181- invokeAndRemoveCallbackIfAnyFor (request.tabId, request);
182+ on_user_popup_request_result: function (request, sender, callback) {
183+ invokeAndRemoveCallbackIfAnyFor(request.tabId, request);
184 },
185 init_requested: function (request, sender, callback) {
186 sendNativeMessage({
187@@ -166,30 +162,32 @@
188 },
189 function (response) {
190 if (response.available) {
191- addInfobarRequestCallbackFor(
192+ addPopupRequestCallbackFor(
193 sender.tab.id,
194 function (result) {
195 if (result && result.integrate) {
196 sendNativeMessage({
197 "method" : "install",
198 "url" : request.options.url
199- })
200+ });
201 } else {
202 sendNativeMessage({
203 "method" : "dont_ask",
204 "url" : request.options.url
205- })
206+ });
207 }
208+
209+ chrome.pageAction.hide(windowInfos.tabId);
210 },
211 chrome.i18n.getMessage("integration_copy", [ response.appName, response.appDomain ]),
212 null);
213
214- chrome.infobars.show({ tabId: windowInfos.tabId, path: "infobar.html" });
215+ chrome.pageAction.show(windowInfos.tabId);
216 }
217 });
218 }
219 };
220-
221+
222 // validate request
223 if (!request || !request.method) {
224 callback({ error: "Invalid request structure" });
225@@ -200,20 +198,18 @@
226 return true;
227 }
228
229- if (typeof(request.method) != 'string' || request.method.length == 0) {
230+ if (typeof(request.method) != 'string' || request.method.length === 0) {
231 callback({ error: "Invalid request method" });
232 return true;
233 }
234
235- console.log('Got request: ' + request.method);
236-
237 var handler = handlers [request.method];
238 if (handler !== undefined && typeof(handler) == 'function') {
239 handler(request, sender, callback);
240 return true;
241 }
242 return false;
243- }
244+ };
245
246 // Main event handler and communication link
247 // w/ content scripts
248@@ -221,18 +217,16 @@
249 // }}}
250
251 ///////////////////////////////////////////////////////////////////////
252- //
253+ //
254 // Window management related functions. In chromeless mode, we have specific
255 // rules for tab management to make webapps feel more "native" than plain
256 // web applications.
257- //
258+ //
259 ///////////////////////////////////////////////////////////////////////
260
261 var onTabChanged = function (tabId, windowId, url) {
262 var onInstalled = function (installed, packageName, appName, appDomain) { };
263
264- console.log("onTabChanged: " + url);
265-
266 matchesIntegrationScripts(
267 null, //plugin,
268 url,
269@@ -255,15 +249,24 @@
270
271 chrome.tabs.onUpdated.addListener(
272 function(tabId, changeInfo, tab) {
273- console.log("onUpdated " + changeInfo.url);
274 if (changeInfo && changeInfo.url) {
275 onTabChanged(tabId, tab.windowId, changeInfo.url);
276 }
277 }
278 );
279
280+ chrome.tabs.onReplaced.addListener(
281+ function(addedTabId, removedTabId) {
282+ chrome.tabs.get(addedTabId, function(tab) {
283+ if (tab && tab.url) {
284+ onTabChanged(addedTabId, tab.windowId, tab.url);
285+ }
286+ });
287+ }
288+ );
289+
290 /*
291- * Returns a potential message associated with a tab id (infobar)
292+ * Returns a potential message associated with a tab id (popup)
293 */
294 return {
295 getMessageForTabId: function (tabId) {
296
297=== modified file 'chromium-extension/chromium-extension.pro'
298--- chromium-extension/chromium-extension.pro 2014-05-21 12:53:43 +0000
299+++ chromium-extension/chromium-extension.pro 2016-05-11 04:47:43 +0000
300@@ -12,9 +12,9 @@
301 background-page.js \
302 base-content-script.js \
303 browser.js \
304- infobar.css \
305- infobar.html \
306- infobar.js \
307+ popup.css \
308+ popup.html \
309+ popup.js \
310 _locales \
311 options.html \
312 options.js \
313
314=== removed file 'chromium-extension/infobar.css'
315--- chromium-extension/infobar.css 2012-05-16 18:19:03 +0000
316+++ chromium-extension/infobar.css 1970-01-01 00:00:00 +0000
317@@ -1,20 +0,0 @@
318-body {
319- background: -webkit-linear-gradient(#E9E9E9, #DADADA);
320- font-family: Tahoma, Geneva, sans-serif;
321- font-size: 13px;
322- height: 36px; /* Infobars are limited to 36-72px */
323- margin: 0;
324- overflow: hidden;
325- padding-left: 6px;
326- padding-right: 6px;
327- padding-top: 5px;
328-}
329-
330-img {
331- padding-right: 6px;
332-}
333-
334-button {
335- padding-right: 10px;
336-}
337-
338
339=== removed file 'chromium-extension/infobar.html'
340--- chromium-extension/infobar.html 2012-10-12 01:18:07 +0000
341+++ chromium-extension/infobar.html 1970-01-01 00:00:00 +0000
342@@ -1,20 +0,0 @@
343-<html>
344-
345-<head>
346-</head>
347-
348-<link rel="stylesheet" type="text/css" href="infobar.css"></link>
349-<script src="infobar.js"></script>
350-
351-<body>
352-
353-<div id="content" style="display:none">
354- <span id="message"></span>
355- <input type="button" id="notintegrate" value="Never for this site" />
356- <input type="button" id="integrate" value="Yes" onclick="doIntegrate(true)"/>
357-</div>
358-
359-</body>
360-
361-
362-</html>
363
364=== removed file 'chromium-extension/infobar.js'
365--- chromium-extension/infobar.js 2014-11-18 07:07:15 +0000
366+++ chromium-extension/infobar.js 1970-01-01 00:00:00 +0000
367@@ -1,33 +0,0 @@
368-var doIntegrate = function (integrate) {
369- chrome.tabs.query({currentWindow: true, active: true}, function (tabs) {
370- chrome.runtime.sendMessage({tabId: tabs[0].id, method: "on_user_infobar_request_result", integrate: integrate}
371- , function (response) {});
372- window.close();
373- });
374-};
375-
376-window.onload = function () {
377- chrome.runtime.getBackgroundPage(function (bg) {
378- document.getElementById('notintegrate').onclick = function () { doIntegrate(false); };
379- document.getElementById('integrate').onclick = function () { doIntegrate(true); };
380-
381- chrome.tabs.query({currentWindow: true, active: true}, function (tabs) {
382- if (tabs.length === 0) {
383- window.close();
384- return;
385- }
386- if (!bg || !bg.background_page) {
387- window.close();
388- return;
389- }
390- var msg = bg.background_page.getMessageForTabId(tabs[0].id);
391- if (msg == null) {
392- window.close();
393- return;
394- }
395- document.getElementById ('content').style.display = "block";
396- document.getElementById ('message').innerHTML = msg || "";
397- });
398- });
399-};
400-
401
402=== modified file 'chromium-extension/manifest.json.in'
403--- chromium-extension/manifest.json.in 2014-05-21 12:22:21 +0000
404+++ chromium-extension/manifest.json.in 2016-05-11 04:47:43 +0000
405@@ -19,17 +19,25 @@
406 '"icons"': {
407 '"16": "skin/cof-16.png"',
408 '"48": "skin/cof-48.png"'
409- },
410+ },
411
412 '"default_locale": "en"',
413
414 '"background"': {
415 '"page"': '"background-page.html"'
416- },
417+ },
418
419- '"permissions": ["tabs", "http://*/*", "infobars", "nativeMessaging"]',
420+ '"permissions": ["tabs", "http://*/*", "nativeMessaging"]',
421+ '"page_action"': {
422+ '"default_icon"': {
423+ '"19"': '"skin/cof-16.png"',
424+ '"38"': '"skin/cof-48.png"'
425+ },
426+ '"default_title"': '"Unity Webapps"',
427+ '"default_popup"': '"popup.html"'
428+ },
429 '"options_page": "options.html"',
430-
431+
432 '"content_scripts"': [
433 {
434 '"all_frames"': true,
435
436=== modified file 'chromium-extension/options.js'
437--- chromium-extension/options.js 2012-11-08 18:15:19 +0000
438+++ chromium-extension/options.js 2016-05-11 04:47:43 +0000
439@@ -9,8 +9,8 @@
440 document.getElementById('logging').disabled = true;
441 return;
442 }
443-
444- var logging = localStorage["logging"];
445+
446+ var logging = localStorage.logging;
447 var loggingElt = document.getElementById("logging");
448 if (loggingElt) {
449 loggingElt.checked = (logging == "true");
450
451=== added file 'chromium-extension/popup.css'
452--- chromium-extension/popup.css 1970-01-01 00:00:00 +0000
453+++ chromium-extension/popup.css 2016-05-11 04:47:43 +0000
454@@ -0,0 +1,21 @@
455+body {
456+ background: -webkit-linear-gradient(#E9E9E9, #DADADA);
457+ font-family: Tahoma, Geneva, sans-serif;
458+ font-size: 13px;
459+ height: 36px;
460+ width: 300px;
461+ margin: 0;
462+ overflow: hidden;
463+ padding-left: 6px;
464+ padding-right: 6px;
465+ padding-top: 5px;
466+}
467+
468+img {
469+ padding-right: 6px;
470+}
471+
472+button {
473+ padding-right: 10px;
474+}
475+
476
477=== added file 'chromium-extension/popup.html'
478--- chromium-extension/popup.html 1970-01-01 00:00:00 +0000
479+++ chromium-extension/popup.html 2016-05-11 04:47:43 +0000
480@@ -0,0 +1,20 @@
481+<html>
482+
483+<head>
484+</head>
485+
486+<link rel="stylesheet" type="text/css" href="popup.css"></link>
487+<script src="popup.js"></script>
488+
489+<body>
490+
491+<div id="content" style="display:none">
492+ <span id="message"></span>
493+ <input type="button" id="notintegrate" value="Never for this site" />
494+ <input type="button" id="integrate" value="Yes" onclick="doIntegrate(true)"/>
495+</div>
496+
497+</body>
498+
499+
500+</html>
501
502=== added file 'chromium-extension/popup.js'
503--- chromium-extension/popup.js 1970-01-01 00:00:00 +0000
504+++ chromium-extension/popup.js 2016-05-11 04:47:43 +0000
505@@ -0,0 +1,33 @@
506+var doIntegrate = function (integrate) {
507+ chrome.tabs.query({currentWindow: true, active: true}, function (tabs) {
508+ chrome.runtime.sendMessage({tabId: tabs[0].id, method: "on_user_popup_request_result", integrate: integrate}
509+ , function (response) {});
510+ window.close();
511+ });
512+};
513+
514+window.onload = function () {
515+ chrome.runtime.getBackgroundPage(function (bg) {
516+ document.getElementById('notintegrate').onclick = function () { doIntegrate(false); };
517+ document.getElementById('integrate').onclick = function () { doIntegrate(true); };
518+
519+ chrome.tabs.query({currentWindow: true, active: true}, function (tabs) {
520+ if (tabs.length === 0) {
521+ window.close();
522+ return;
523+ }
524+ if (!bg || !bg.background_page) {
525+ window.close();
526+ return;
527+ }
528+ var msg = bg.background_page.getMessageForTabId(tabs[0].id);
529+ if (msg === null) {
530+ window.close();
531+ return;
532+ }
533+ document.getElementById ('content').style.display = "block";
534+ document.getElementById ('message').innerHTML = msg || "";
535+ });
536+ });
537+};
538+
539
540=== modified file 'debian/changelog'
541--- debian/changelog 2015-01-19 16:49:41 +0000
542+++ debian/changelog 2016-05-11 04:47:43 +0000
543@@ -1,3 +1,10 @@
544+unity-chromium-extension (3.2.1+15.04.20150119-0ubuntu1) vivid; urgency=medium
545+
546+ * Fixes: 1469601, by changing the notification method to use the pageAction
547+ facility for display.
548+
549+ -- Justin McPherson <justin.mcpherson@canonical.com> Tue, 30 Jun 2015 13:18:59 +1000
550+
551 unity-chromium-extension (3.2.0+15.04.20150119-0ubuntu1) vivid; urgency=medium
552
553 [ Justin McPherson ]
554
555=== modified file 'debian/control'
556--- debian/control 2014-12-17 14:18:53 +0000
557+++ debian/control 2016-05-11 04:47:43 +0000
558@@ -1,7 +1,7 @@
559 Source: unity-chromium-extension
560 Priority: optional
561 Maintainer: Ubuntu Desktop Team <ubuntu-desktop@lists.ubuntu.com>
562-Build-Depends: chromium-browser (>= 34.0.1847.116-0ubuntu2),
563+Build-Depends: chromium-browser (>= 42.0.2311.90-0ubuntu1),
564 debhelper (>= 9),
565 dh-autoreconf,
566 libglib2.0-dev,
567
568=== modified file 'messaging-host/main.cpp'
569--- messaging-host/main.cpp 2014-06-20 06:16:48 +0000
570+++ messaging-host/main.cpp 2016-05-11 04:47:43 +0000
571@@ -36,6 +36,11 @@
572 case QtDebugMsg:
573 syslog_type |= LOG_DEBUG;
574 break;
575+#if QT_VERSION >= 0x050500
576+ case QtInfoMsg:
577+ syslog_type |= LOG_INFO;
578+ break;
579+#endif
580 case QtWarningMsg:
581 syslog_type |= LOG_WARNING;
582 break;

Subscribers

People subscribed via source and target branches

to all changes: