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

Side by Side Diff: popup.js

Issue 29565717: Issue 5832 - Use runtime.onMessage directly in popup (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created Oct. 5, 2017, 1:39 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
« no previous file with comments | « popup.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 25 matching lines...) Expand all
36 36
37 function whenPageReady() 37 function whenPageReady()
38 { 38 {
39 return new Promise(resolve => 39 return new Promise(resolve =>
40 { 40 {
41 function onMessage(message, sender) 41 function onMessage(message, sender)
42 { 42 {
43 if (message.type == "composer.ready" && sender.page && 43 if (message.type == "composer.ready" && sender.page &&
44 sender.page.id == tab.id) 44 sender.page.id == tab.id)
45 { 45 {
46 ext.onMessage.removeListener(onMessage); 46 chrome.runtime.onMessage.removeListener(onMessage);
47 resolve(); 47 resolve();
48 } 48 }
49 } 49 }
50 50
51 ext.onMessage.addListener(onMessage); 51 chrome.runtime.onMessage.addListener(onMessage);
52 52
53 chrome.runtime.sendMessage({ 53 chrome.runtime.sendMessage({
54 type: "composer.isPageReady", 54 type: "composer.isPageReady",
55 pageId: tab.id 55 pageId: tab.id
56 }, 56 },
57 ready => 57 ready =>
58 { 58 {
59 if (ready) 59 if (ready)
60 { 60 {
61 ext.onMessage.removeListener(onMessage); 61 chrome.runtime.onMessage.removeListener(onMessage);
62 resolve(); 62 resolve();
63 } 63 }
64 }); 64 });
65 }); 65 });
66 } 66 }
67 67
68 function onLoad() 68 function onLoad()
69 { 69 {
70 chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => 70 chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs =>
71 { 71 {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 function toggleCollapse(event) 175 function toggleCollapse(event)
176 { 176 {
177 let collapser = event.currentTarget; 177 let collapser = event.currentTarget;
178 let collapsible = document.getElementById(collapser.dataset.collapsible); 178 let collapsible = document.getElementById(collapser.dataset.collapsible);
179 collapsible.classList.toggle("collapsed"); 179 collapsible.classList.toggle("collapsed");
180 togglePref(collapser.dataset.option); 180 togglePref(collapser.dataset.option);
181 } 181 }
182 182
183 document.addEventListener("DOMContentLoaded", onLoad, false); 183 document.addEventListener("DOMContentLoaded", onLoad, false);
OLDNEW
« no previous file with comments | « popup.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld