@@ -760,9 +760,16 @@ var TelemetryReportingPolicyImpl = {
760760 * Check if we are allowed to upload data.
761761 * Prerequisite: data submission is enabled (this.dataSubmissionEnabled).
762762 *
763- * For upload to be allowed from a data reporting standpoint, the user should
764- * not qualify to see the legacy policy notification flow and also not qualify
765- * to see the Terms of Use acceptance flow.
763+ * In order to submit data, at least ONE of these conditions should be true:
764+ * 1. The TOU flow is bypassed via a pref or Nimbus variable AND the legacy
765+ * notification flow bypass pref is set, so users bypass BOTH flows.
766+ * 2. The TOU flow is bypassed via a pref or Nimbus variable and the legacy
767+ * notification flow bypass pref is NOT set, so has been been shown the
768+ * legacy flow (the data submission pref should be true and the
769+ * datachoices infobar should have been displayed).
770+ * 3. The user has accepted the Terms of Use AND the user has opted-in to
771+ * sharing technical interaction data (the upload enabled pref should be
772+ * true).
766773 * @return {Boolean } True if we are allowed to upload data, false otherwise.
767774 */
768775 canUpload ( ) {
@@ -772,7 +779,33 @@ var TelemetryReportingPolicyImpl = {
772779 return false ;
773780 }
774781
775- return ! this . _shouldNotifyDataReportingPolicy ( ) && ! this . _shouldShowTOU ( ) ;
782+ const bypassLegacyFlow = Services . prefs . getBoolPref (
783+ TelemetryUtils . Preferences . BypassNotification ,
784+ false
785+ ) ;
786+ // TOU flow is bypassed if the Nimbus preonboarding feature is disabled
787+ // (disabled by default for Linux via the fallback
788+ // browser.preonboarding.enabled pref) or if the explicit bypass pref is
789+ // set.
790+ const bypassTOUFlow =
791+ Services . prefs . getBoolPref ( TOU_BYPASS_NOTIFICATION_PREF , false ) ||
792+ ( ! Services . prefs . getBoolPref ( "browser.preonboarding.enabled" , false ) &&
793+ this . _nimbusVariables ?. enabled !== true ) ||
794+ this . _nimbusVariables ?. enabled === false ;
795+ const allowInteractionData = Services . prefs . getBoolPref (
796+ "datareporting.healthreport.uploadEnabled" ,
797+ false
798+ ) ;
799+
800+ // Condition 1
801+ const canUploadBypassLegacyAndTOU = bypassLegacyFlow && bypassTOUFlow ;
802+ // Condition 2
803+ const canUploadLegacy =
804+ bypassTOUFlow && ! bypassLegacyFlow && this . isUserNotifiedOfCurrentPolicy ;
805+ // Condition 3
806+ const canUploadTOU = this . hasUserAcceptedCurrentTOU && allowInteractionData ;
807+
808+ return canUploadBypassLegacyAndTOU || canUploadLegacy || canUploadTOU ;
776809 } ,
777810
778811 isFirstRun ( ) {
@@ -839,20 +872,6 @@ var TelemetryReportingPolicyImpl = {
839872 * Determine whether the user should be shown the terms of use.
840873 */
841874 _shouldShowTOU ( ) {
842- // In some cases, _shouldShowTOU can be called before the Nimbus variables
843- // are set. When this happens, we call _configureFromNimbus to initialize
844- // these variables before evaluating them. This ensures we have accurate
845- // data regarding whether preonboarding is enabled for the user. When
846- // preonboarding is explicitly disabled, it should be treated the same the
847- // bypassing the TOU flow via the bypass pref.
848- if (
849- ! this . _nimbusVariables ||
850- ( typeof this . _nimbusVariables === "object" &&
851- Object . keys ( this . _nimbusVariables ) . length === 0 )
852- ) {
853- this . _configureFromNimbus ( ) ;
854- }
855-
856875 if ( ! this . _nimbusVariables . enabled || ! this . _nimbusVariables . screens ) {
857876 this . _log . trace (
858877 "_shouldShowTOU - TOU not enabled or no screens configured."
@@ -1077,7 +1096,7 @@ var TelemetryReportingPolicyImpl = {
10771096 // _during_ the Firefox process lifetime; right now, we only notify the user
10781097 // at Firefox startup.
10791098 this . updateTOUPrefsForLegacyUsers ( ) ;
1080- this . _configureFromNimbus ( ) ;
1099+ await this . _configureFromNimbus ( ) ;
10811100
10821101 if ( this . isFirstRun ( ) ) {
10831102 // We're performing the first run, flip firstRun preference for subsequent runs.
@@ -1214,7 +1233,7 @@ var TelemetryReportingPolicyImpl = {
12141233 * Capture Nimbus configuration: record feature variables for future use and
12151234 * set Gecko preferences based on values.
12161235 */
1217- _configureFromNimbus ( ) {
1236+ async _configureFromNimbus ( ) {
12181237 if ( AppConstants . MOZ_BUILD_APP != "browser" ) {
12191238 // OnboardingMessageProvider is browser/ only
12201239 return ;
0 commit comments