Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: chrome/ext/content.js

Issue 29371763: Issue 4795 - Use modern JavaScript syntax (Closed)
Patch Set: Addressed feedback, used destructuring Created Jan. 17, 2017, 7:39 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/ext/common.js ('k') | chrome/ext/devtools.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) 1 "use strict";
2
3 chrome.runtime.onMessage.addListener((message, sender, sendResponse) =>
2 { 4 {
3 return ext.onMessage._dispatch(message, {}, sendResponse).indexOf(true) != -1; 5 return ext.onMessage._dispatch(message, {}, sendResponse).indexOf(true) != -1;
4 }); 6 });
5 7
6 ext.onExtensionUnloaded = (function()
7 { 8 {
8 var port = null; 9 let port = null;
9 10
10 return { 11 ext.onExtensionUnloaded = {
11 addListener: function(listener) 12 addListener(listener)
12 { 13 {
13 if (!port) 14 if (!port)
14 port = chrome.runtime.connect(); 15 port = chrome.runtime.connect();
15 16
16 // When the extension is reloaded, disabled or uninstalled the 17 // When the extension is reloaded, disabled or uninstalled the
17 // background page dies and automatically disconnects all ports 18 // background page dies and automatically disconnects all ports
18 port.onDisconnect.addListener(listener); 19 port.onDisconnect.addListener(listener);
19 }, 20 },
20 removeListener: function(listener) 21 removeListener(listener)
21 { 22 {
22 if (port) 23 if (port)
23 { 24 {
24 port.onDisconnect.removeListener(listener); 25 port.onDisconnect.removeListener(listener);
25 26
26 if (!port.onDisconnect.hasListeners()) 27 if (!port.onDisconnect.hasListeners())
27 { 28 {
28 port.disconnect(); 29 port.disconnect();
29 port = null; 30 port = null;
30 } 31 }
31 } 32 }
32 } 33 }
33 }; 34 };
34 })(); 35 }
OLDNEW
« no previous file with comments | « chrome/ext/common.js ('k') | chrome/ext/devtools.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld