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

Side by Side Diff: lib/browserAction.js

Issue 29536764: Issue 5587, 5748 - Use mobile options page on Firefox for Android (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Rebase on next Created Sept. 26, 2017, 10:04 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
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 /** @module browserAction */
Sebastian Noack 2017/09/27 01:38:35 Perhaps, this code can go into lib/options.js as w
Manish Jethani 2017/09/27 11:20:55 For now it could, but technically "browser action"
Sebastian Noack 2017/09/30 02:38:43 We would not preserve the BrowserAction class as i
Manish Jethani 2017/09/30 13:49:51 Done.
19
20 "use strict";
21
22 const {getDecodedHostname} = require("url");
23 const {checkWhitelisted} = require("whitelisting");
24 const {showOptions} = require("options");
25
26 // On Firefox for Android, open the options page directly when the browser
27 // action is clicked.
28 chrome.browserAction.onClicked.addListener(() =>
29 {
30 ext.pages.query({active: true, lastFocusedWindow: true}, pages =>
31 {
32 let currentPage = pages[0];
33
34 showOptions(optionsPage =>
35 {
36 if (!["http:", "https:"].includes(currentPage.url.protocol))
37 return;
38
39 optionsPage.sendMessage({
40 type: "app.respond",
41 action: "showPageOptions",
42 args: [
43 {
44 host: getDecodedHostname(currentPage.url).replace(/^www\./, ""),
45 whitelisted: !!checkWhitelisted(currentPage)
46 }
47 ]
48 });
49 });
50 });
51 });
OLDNEW
« no previous file with comments | « ext/background.js ('k') | lib/notificationHelper.js » ('j') | lib/notificationHelper.js » ('J')

Powered by Google App Engine
This is Rietveld