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

GH-2188 - Adjustments for Ghostery Browser #622

Merged
merged 5 commits into from Oct 26, 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

@@ -110,8 +110,8 @@ class SetupViewContainer extends Component {
actions.setAntiTracking({ enable_anti_tracking: true });
actions.setAdBlock({ enable_ad_block: true });
actions.setSmartBlocking({ enable_smart_block: true });
actions.setGhosteryRewards({ enable_ghostery_rewards: !IS_FIREFOX && !IS_ANDROID });
actions.setHumanWeb({ enable_human_web: !IS_FIREFOX || BROWSER_INFO.name === 'ghostery_android' });
actions.setGhosteryRewards({ enable_ghostery_rewards: !IS_FIREFOX && !IS_ANDROID && BROWSER_INFO.name !== 'ghostery_desktop' });
actions.setHumanWeb({ enable_human_web: !IS_FIREFOX || BROWSER_INFO.name === 'ghostery_desktop' || BROWSER_INFO.name === 'ghostery_android' });
}

/**
@@ -3,10 +3,11 @@
"author": "Ghostery",
"name": "__MSG_name__",
"short_name": "Ghostery",
"version": "8.5.3",
"version_name": "8.5.3",
"version": "8.5.4",
"version_name": "8.5.4",
"default_locale": "en",
"description": "__MSG_short_description__",
"debug": true,
This conversation was marked as resolved by christophertino

This comment has been minimized.

@sammacbeth

sammacbeth Oct 23, 2020
Contributor

Should this be here?

This comment has been minimized.

@christophertino

christophertino Oct 23, 2020
Author Member

yea it's fine for develop. It gets removed by the builder.

"icons": {
"16": "app/images/icon16.png",
"48": "app/images/icon48.png",
@@ -114,4 +115,4 @@
"cliqz/offers-templates/checkout.html",
"cliqz/offers-templates/control-center.html"
]
}
}
@@ -21,6 +21,8 @@ import ghosteryDebugger from './classes/Debugger';
// object classes
import Events from './classes/EventHandlers';
import Policy from './classes/Policy';
import Rewards from './classes/Rewards';
import GhosteryModule from './classes/Module';
// static classes
import panelData from './classes/PanelData';
import bugDb from './classes/BugDb';
@@ -37,11 +39,8 @@ import globals from './classes/Globals';
import surrogatedb from './classes/SurrogateDb';
import tabInfo from './classes/TabInfo';
import metrics from './classes/Metrics';
import Rewards from './classes/Rewards';
import account from './classes/Account';
import GhosteryModule from './classes/Module';
import promoModals from './classes/PromoModals';

// utilities
import { allowAllwaysC2P } from './utils/click2play';
import * as common from './utils/common';
@@ -1617,6 +1616,12 @@ function initializeGhosteryModules() {
conf.install_random_number = randomNumber;
conf.install_date = dateString;

// Set default search partners for Ghostery Desktop Browser. These can be removed
// by the user under Trusted Site settings.
if (BROWSER_INFO.name === 'ghostery_desktop') {
conf.site_whitelist.push('bing.com', 'search.yahoo.com', 'startpage.com');
}

metrics.setUninstallUrl();

metrics.ping('install');
@@ -1642,18 +1647,22 @@ function initializeGhosteryModules() {
conf.enable_ad_block = !adblocker.isDisabled;
conf.enable_anti_tracking = !antitracking.isDisabled;
conf.enable_human_web = !humanweb.isDisabled;
conf.enable_offers = !offers.isDisabled && !IS_ANDROID;

if (IS_FIREFOX && BROWSER_INFO.name !== 'ghostery_android') {
if (globals.JUST_INSTALLED) {
conf.enable_human_web = false;
conf.enable_offers = false;
} else if (globals.REQUIRE_LEGACY_OPT_IN && !conf.cliqz_legacy_opt_in) {
conf.enable_human_web = false;
conf.enable_offers = cliqz.prefs.get('myoffrz.opted_in') || false;
conf.cliqz_legacy_opt_in = true;
// Make sure that getBrowserInfo() has resolved before we set these properties
(async() => {
await globals.BROWSER_INFO_READY;
conf.enable_offers = !offers.isDisabled && !IS_ANDROID && BROWSER_INFO.name !== 'ghostery_desktop';
if (IS_FIREFOX && BROWSER_INFO.name !== 'ghostery_desktop' && BROWSER_INFO.name !== 'ghostery_android') {
if (globals.JUST_INSTALLED) {
conf.enable_human_web = false;
conf.enable_offers = false;
} else if (globals.REQUIRE_LEGACY_OPT_IN && !conf.cliqz_legacy_opt_in) {
conf.enable_human_web = false;
conf.enable_offers = cliqz.prefs.get('myoffrz.opted_in') || false;
conf.cliqz_legacy_opt_in = true;
}
}
}
})();

const myoffrzShouldMigrate = conf.rewards_opted_in !== undefined && cliqz.prefs.get('myoffrz.opted_in', undefined) === undefined;
if (myoffrzShouldMigrate) {
@@ -1747,7 +1756,7 @@ function initializeGhosteryModules() {
// Open the Ghostery Hub on install with justInstalled query parameter set to true.
// We need to do this after running scheduledTasks for the first time
// because of an A/B test that determines which promo variant is shown in the Hub on install
if (globals.JUST_INSTALLED) {
if (globals.JUST_INSTALLED && BROWSER_INFO.name !== 'ghostery_desktop') {
const showAlternateHub = conf.hub_layout === 'alternate';
const route = showAlternateHub ? '#home' : '';
chrome.tabs.create({
@@ -93,6 +93,13 @@ class ConfData {
_initProperty('trackers_banner_status', true);
}

// Make sure that getBrowserInfo() has resolved before we set these properties
(async() => {
await globals.BROWSER_INFO_READY;
_initProperty('enable_metrics', BROWSER_INFO.name === 'ghostery_desktop');
_initProperty('enable_offers', !IS_CLIQZ && !IS_FIREFOX && !IS_ANDROID && BROWSER_INFO.name !== 'ghostery_desktop');
})();

// simple props
_initProperty('alert_bubble_pos', 'br');
_initProperty('alert_bubble_timeout', 15);
@@ -111,8 +118,6 @@ class ConfData {
_initProperty('enable_click2play', true);
_initProperty('enable_click2play_social', true);
_initProperty('enable_human_web', !IS_CLIQZ && !IS_FIREFOX);
_initProperty('enable_metrics', false);
_initProperty('enable_offers', !IS_CLIQZ && !IS_FIREFOX && !IS_ANDROID);
_initProperty('enable_abtests', true);
_initProperty('enable_smart_block', true);
_initProperty('expand_all_trackers', true);
@@ -18,22 +18,9 @@ import parser from 'ua-parser-js';
const manifest = chrome.runtime.getManifest();
const isCliqzBrowser = !!(chrome.runtime.isCliqz);

/**
* Check for information about this browser
* Note: This is asynchronous and not available at runtime.
* @private
* @return boolean
*/
function _checkBrowserInfo() {
if (typeof chrome.runtime.getBrowserInfo === 'function') {
return chrome.runtime.getBrowserInfo();
}
return Promise.resolve(false);
}

/**
* Structure which holds parameters to be used throughout the code, a.k.a. global values.
* Most of them (but not all) are const.
* Most of them (but not all) are constants.
* @memberOf BackgroundClasses
*/
class Globals {
@@ -45,6 +32,7 @@ class Globals {
this.BROWSER_INFO = {
displayName: '', name: '', token: '', version: '', os: 'other'
};
this.BROWSER_INFO_READY = this.buildBrowserInfo();
this.IS_CLIQZ = !!((manifest.applications && manifest.applications.gecko && manifest.applications.gecko.update_url) || isCliqzBrowser);

// flags
@@ -146,13 +134,11 @@ class Globals {
abtests: {},
cmp_data: {}
};

this.buildBrowserInfo();
}

/**
* Gets UA and Platform strings for current browser
* @return {Object}
* @return {Promise}
*/
buildBrowserInfo() {
const ua = parser(navigator.userAgent);
@@ -202,23 +188,33 @@ class Globals {
this.BROWSER_INFO.version = version;

// Check for Ghostery browsers
if (browser.includes('firefox') || browser.includes('mozilla')) {
_checkBrowserInfo().then((info) => {
if (info.name === 'Ghostery') {
if (platform.includes('android')) {
this.BROWSER_INFO.displayName = 'Ghostery Android Browser';
this.BROWSER_INFO.name = 'ghostery_android';
this.BROWSER_INFO.token = 'ga';
this.BROWSER_INFO.os = 'android';
} else {
this.BROWSER_INFO.displayName = 'Ghostery Desktop Browser';
this.BROWSER_INFO.name = 'ghostery_desktop';
this.BROWSER_INFO.token = 'gd';
}
this.BROWSER_INFO.version = info.version;
return Globals._checkBrowserInfo().then((info) => {
if (info && info.name === 'Ghostery') {
if (platform.includes('android')) {
this.BROWSER_INFO.displayName = 'Ghostery Android Browser';
this.BROWSER_INFO.name = 'ghostery_android';
this.BROWSER_INFO.token = 'ga';
this.BROWSER_INFO.os = 'android';
} else {
this.BROWSER_INFO.displayName = 'Ghostery Desktop Browser';
this.BROWSER_INFO.name = 'ghostery_desktop';
this.BROWSER_INFO.token = 'gd';
}
});
this.BROWSER_INFO.version = info.version;
}
});
}

/**
* Check for information about this browser (FF only)
* @private
* @return {Promise}
*/
static _checkBrowserInfo() {
if (typeof chrome.runtime.getBrowserInfo === 'function') {
return chrome.runtime.getBrowserInfo();
}
return Promise.resolve(false);
}
}

ProTip! Use n and p to navigate between commits in a pull request.