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

Delta Between Two Patch Sets: lib/options.js

Issue 29536764: Issue 5587, 5748 - Use mobile options page on Firefox for Android (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: Remove ping and handle error Created Oct. 2, 2017, 8 a.m.
Right Patch Set: Remove workaround for FOUC issue and update adblockplusui dependency Created Oct. 5, 2017, 1:24 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/notificationHelper.js ('k') | metadata.chrome » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 callback(new ext.Page(optionsTab)); 52 callback(new ext.Page(optionsTab));
53 } 53 }
54 else 54 else
55 { 55 {
56 // If we don't already have an options page, it means we've just opened 56 // If we don't already have an options page, it means we've just opened
57 // one, in which case we must find the tab, wait for it to be ready, and 57 // one, in which case we must find the tab, wait for it to be ready, and
58 // then return the call. 58 // then return the call.
59 findOptionsTab(tab => 59 findOptionsTab(tab =>
60 { 60 {
61 if (!tab) 61 if (!tab)
62 {
63 // This likely means that there was an error. Let the callback deal
64 // with it.
65 callback();
Manish Jethani 2017/10/02 08:03:14 I think it's better to call the callback anyway wi
Sebastian Noack 2017/10/04 01:22:32 I can think of two scenarios here: 1. chrome.runt
Manish Jethani 2017/10/04 03:46:49 In general I think that a callback should be calle
Sebastian Noack 2017/10/04 05:33:14 This would rather be an argument to return a Promi
Manish Jethani 2017/10/04 13:02:45 Acknowledged.
66 return; 62 return;
67 }
68 63
69 function onMessage(message, sender) 64 function onMessage(message, sender)
70 { 65 {
71 if (message.type == "app.listen" && 66 if (message.type == "app.listen" &&
72 sender.page && sender.page.id == tab.id) 67 sender.page && sender.page.id == tab.id)
73 { 68 {
74 port.off("app.listen", onMessage); 69 port.off("app.listen", onMessage);
75 callback(new ext.Page(tab)); 70 callback(new ext.Page(tab));
76 } 71 }
77 } 72 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // On Firefox for Android, open the options page directly when the browser 127 // On Firefox for Android, open the options page directly when the browser
133 // action is clicked. 128 // action is clicked.
134 chrome.browserAction.onClicked.addListener(() => 129 chrome.browserAction.onClicked.addListener(() =>
135 { 130 {
136 ext.pages.query({active: true, lastFocusedWindow: true}, pages => 131 ext.pages.query({active: true, lastFocusedWindow: true}, pages =>
137 { 132 {
138 let currentPage = pages[0]; 133 let currentPage = pages[0];
139 134
140 showOptions(optionsPage => 135 showOptions(optionsPage =>
141 { 136 {
142 if (!["http:", "https:"].includes(currentPage.url.protocol)) 137 if (!/^https?:$/.test(currentPage.url.protocol))
Sebastian Noack 2017/10/04 01:22:33 You could just use a regular expression here (if y
Manish Jethani 2017/10/04 03:46:49 Done.
143 return; 138 return;
144 139
145 optionsPage.sendMessage({ 140 optionsPage.sendMessage({
146 type: "app.respond", 141 type: "app.respond",
147 action: "showPageOptions", 142 action: "showPageOptions",
148 args: [ 143 args: [
149 { 144 {
150 host: getDecodedHostname(currentPage.url).replace(/^www\./, ""), 145 host: getDecodedHostname(currentPage.url).replace(/^www\./, ""),
151 whitelisted: !!checkWhitelisted(currentPage) 146 whitelisted: !!checkWhitelisted(currentPage)
152 } 147 }
153 ] 148 ]
154 }); 149 });
155 }); 150 });
156 }); 151 });
157 }); 152 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld