Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross platform extension #569

Merged
merged 5 commits into from Jun 19, 2020
Merged
Changes from all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -14,7 +14,7 @@
* @namespace PanelAndroidUtils
*/

import { apps } from '../../../cliqz/antitracking/tracker_db_v2.json';
import { apps } from '../../../cliqz/core/tracker_db_v2.json';

// Link to whotracks.me website
export default function getUrlFromTrackerId(id) {
@@ -45,7 +45,7 @@
"dependencies": {
"@cliqz/adblocker-circumvention": "^1.12.2",
"@cliqz/url-parser": "^1.1.3",
"browser-core": "https://github.com/cliqz-oss/browser-core/releases/download/v7.45.2/browser-core-7.45.2.tgz",
"browser-core": "https://github.com/cliqz-oss/browser-core/releases/download/v7.47.0/browser-core-7.47.0.tgz",
"classnames": "^2.2.5",
"d3": "^5.16.0",
"foundation-sites": "^6.6.2",
@@ -16,7 +16,7 @@
*/
import { debounce, every, size } from 'underscore';
import moment from 'moment/min/moment-with-locales.min';
import cliqz from './classes/Cliqz';
import cliqz, { HUMANWEB_MODULE, HPN_MODULE } from './classes/Cliqz';
// object class
import Events from './classes/EventHandlers';
import Policy from './classes/Policy';
@@ -75,8 +75,9 @@ const moduleMock = {
isEnabled: false,
on: () => {},
};
const humanweb = cliqz.modules['human-web'];
const { adblocker, antitracking, hpnv2 } = cliqz.modules;
const humanweb = cliqz.modules[HUMANWEB_MODULE];
const hpnv2 = cliqz.modules[HPN_MODULE];
const { adblocker, antitracking } = cliqz.modules;
const offers = cliqz.modules['offers-v2'] || moduleMock;
const insights = cliqz.modules.insights || moduleMock;
// add ghostery module to expose ghostery state to cliqz
@@ -1340,11 +1341,8 @@ function getDataForGhosteryTab(callback) {
*/
function initializePopup() {
if (BROWSER_INFO.os === 'android') {
chrome.browserAction.onClicked.addListener((tab) => {
chrome.tabs.create({
url: chrome.extension.getURL(`app/templates/panel_android.html?tabId=${tab.id}`),
This conversation was marked as resolved by christophertino

This comment has been minimized.

@christophertino

christophertino Jun 18, 2020
Member

@sammacbeth Check out

const tabId = new URLSearchParams(window.location.search).get('tabId');
. The React app uses that tabId value to fetch data for the panel view.

Using setPopup will require bumping our min FF Android version to 57+, which is fine.

This comment has been minimized.

@sammacbeth

sammacbeth Jun 19, 2020
Author Contributor

I was wondering why the panel seems to be working despite this, and it seems that there is code to handle the tabId parameter not being provided:

// The 'getPanelData' message is never sent by the panel, which uses ports only since 8.3.2
// The message is still sent by panel-android and by the setup hub as of 8.4.0
if (name === 'getPanelData') {
if (!message.tabId) {
utils.getActiveTab((tab) => {
const data = panelData.get(message.view, tab);
callback(data);
});

This code to get the active tab could be moved into the panel code to ensure it knows which tab it refers to in case an undefined tabId introduces other issues.

This comment has been minimized.

@christophertino

christophertino Jun 19, 2020
Member

Good catch. @IAmThePan we can most likely remove that tabId lookup in Panel.jsx (see above)

This comment has been minimized.

@IAmThePan

IAmThePan Jun 19, 2020
Contributor

Noted. However, including the tabId in the URL enables Anri to open the panel (android or regular) in a webpage rather than the popup so he can do regression tests.
I will incorporate these changes in my feature/update-android branch. I will keep the code to open the tabId without the query parameter, but I will make sure the query parameter can be included if the use (tester, or developer) wants easy access to the panel.

This comment has been minimized.

active: true,
});
chrome.browserAction.setPopup({
popup: 'app/templates/panel_android.html',
});
} else {
chrome.browserAction.setPopup({
@@ -15,4 +15,23 @@
import CLIQZ from 'browser-core';
import globals from './Globals';

const IS_ANDROID = globals.BROWSER_INFO.os === 'android';
export const HUMANWEB_MODULE = IS_ANDROID ? 'human-web-lite' : 'human-web';
export const HPN_MODULE = IS_ANDROID ? 'hpn-lite' : 'hpnv2';
// override the default prefs based on the platform
CLIQZ.config.default_prefs = {

This comment has been minimized.

@chrmod

chrmod Jun 17, 2020
Member

config.settings.HW_CHANNEL should be set to android for human-web-lite.

...CLIQZ.config.default_prefs,
// the following are enabled by default on non-android platforms
'modules.human-web.enabled': !IS_ANDROID,
'modules.hpnv2.enabled': !IS_ANDROID,
'modules.offers-v2.enabled': !IS_ANDROID,
'modules.offers-banner.enabled': !IS_ANDROID,
// the following are enabled for android only
'modules.human-web-lite.enabled': IS_ANDROID,
'modules.hpn-lite.enabled': IS_ANDROID,
};
if (IS_ANDROID) {
CLIQZ.config.settings.HW_CHANNEL = 'android';
}

export default new (CLIQZ.App)({ debug: globals.DEBUG });
ProTip! Use n and p to navigate between commits in a pull request.