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: Created Jan. 13, 2017, 12:11 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) 1 chrome.runtime.onMessage.addListener((message, sender, sendResponse) =>
2 { 2 {
3 return ext.onMessage._dispatch(message, {}, sendResponse).indexOf(true) != -1; 3 return ext.onMessage._dispatch(message, {}, sendResponse).indexOf(true) != -1;
4 }); 4 });
5 5
6 ext.onExtensionUnloaded = (function() 6 ext.onExtensionUnloaded = (() =>
7 { 7 {
8 var port = null; 8 let port = null;
9 9
10 return { 10 return {
11 addListener: function(listener) 11 addListener: listener =>
12 { 12 {
13 if (!port) 13 if (!port)
14 port = chrome.runtime.connect(); 14 port = chrome.runtime.connect();
15 15
16 // When the extension is reloaded, disabled or uninstalled the 16 // When the extension is reloaded, disabled or uninstalled the
17 // background page dies and automatically disconnects all ports 17 // background page dies and automatically disconnects all ports
18 port.onDisconnect.addListener(listener); 18 port.onDisconnect.addListener(listener);
19 }, 19 },
20 removeListener: function(listener) 20 removeListener: listener =>
21 { 21 {
22 if (port) 22 if (port)
23 { 23 {
24 port.onDisconnect.removeListener(listener); 24 port.onDisconnect.removeListener(listener);
25 25
26 if (!port.onDisconnect.hasListeners()) 26 if (!port.onDisconnect.hasListeners())
27 { 27 {
28 port.disconnect(); 28 port.disconnect();
29 port = null; 29 port = null;
30 } 30 }
31 } 31 }
32 } 32 }
33 }; 33 };
34 })(); 34 })();
OLDNEW
« chrome/ext/common.js ('K') | « chrome/ext/common.js ('k') | chrome/ext/devtools.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld