diff --git a/app/hub/Views/SetupView/SetupViewContainer.jsx b/app/hub/Views/SetupView/SetupViewContainer.jsx index 38e410a23..6d4eb087c 100644 --- a/app/hub/Views/SetupView/SetupViewContainer.jsx +++ b/app/hub/Views/SetupView/SetupViewContainer.jsx @@ -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' }); } /** diff --git a/manifest.json b/manifest.json index c2a7b9e5d..99eb5870b 100644 --- a/manifest.json +++ b/manifest.json @@ -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, "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" ] -} \ No newline at end of file +} diff --git a/src/background.js b/src/background.js index 1644488a0..f0d211cab 100644 --- a/src/background.js +++ b/src/background.js @@ -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({ diff --git a/src/classes/ConfData.js b/src/classes/ConfData.js index 990db8cd4..3a2e7df1b 100644 --- a/src/classes/ConfData.js +++ b/src/classes/ConfData.js @@ -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); diff --git a/src/classes/Globals.js b/src/classes/Globals.js index a48fc1a85..d6d28fae8 100644 --- a/src/classes/Globals.js +++ b/src/classes/Globals.js @@ -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); } }