B2G/gecko/services/healthreport/policy.jsm
/**
   * Ensure user has responded to data submission policy.
   *
   * This must be called before data submission. If the policy has not been
   * responded to, data submission must not occur.
   *
   * @return bool Whether user has responded to data policy.
   */
Ensure user has responded to data submission policy.
This must be called before data submission. If the policy has not been
responded to, data submission must not occur.

@return bool Whether user has responded to data policy.
Ensure user has responded to data submission policy . This must be called before data submission . If the policy has not been responded to data submission must not occur . @return bool Whether user has responded to data policy .
function ensureNotifyResponse(now) {
    if (this.dataSubmissionPolicyBypassAcceptance) {
      return true;
    }
    let notifyState = this.notifyState;
    if (notifyState == this.STATE_NOTIFY_UNNOTIFIED) {
      let notifyAt = new Date(this.firstRunDate.getTime() +
                              this.SUBMISSION_NOTIFY_INTERVAL_MSEC);
      if (now.getTime() < notifyAt.getTime()) {
        this._log.debug("Don't have to notify about data submission yet.");
        return false;
      }
      let onComplete = function onComplete() {
        this._log.info("Data submission notification presented.");
        let now = this.now();
        this._dataSubmissionPolicyNotifiedDate = now;
        this.dataSubmissionPolicyNotifiedDate = now;
      }.bind(this);
      let deferred = Promise.defer();
      deferred.promise.then(onComplete, function onError(error) {
        this._log.warn("Data policy notification presentation failed: " +
                       CommonUtils.exceptionStr(error));
      });
      this._log.info("Requesting display of data policy.");
      let request = new NotifyPolicyRequest(this, deferred);
      try {
        this._listener.onNotifyDataPolicy(request);
      } catch (ex) {
        this._log.warn("Exception when calling onNotifyDataPolicy: " +
                       CommonUtils.exceptionStr(ex));
      }
      return false;
    }
    if (notifyState == this.STATE_NOTIFY_WAIT) {
      let implicitAcceptanceDate =
        new Date(this._dataSubmissionPolicyNotifiedDate.getTime() +
                 this.IMPLICIT_ACCEPTANCE_INTERVAL_MSEC);
      if (now.getTime() < implicitAcceptanceDate.getTime()) {
        this._log.debug("Still waiting for reaction or implicit acceptance.");
        return false;
      }
      this.recordUserAcceptance("implicit-time-elapsed");
      return true;
    }
    if (notifyState != this.STATE_NOTIFY_COMPLETE) {
      throw new Error("Unknown notification state: " + notifyState);
    }
    return true;
  }
function ensureNotifyResponse ( now ) { if ( this . dataSubmissionPolicyBypassAcceptance ) { return true ; } let notifyState = this . notifyState ; if ( notifyState == this . STATE_NOTIFY_UNNOTIFIED ) { let notifyAt = new Date ( this . firstRunDate . getTime ( ) + this . SUBMISSION_NOTIFY_INTERVAL_MSEC ) ; if ( now . getTime ( ) < notifyAt . getTime ( ) ) { this . _log . debug ( "Don't have to notify about data submission yet." ) ; return false ; } let onComplete = function onComplete ( ) { this . _log . info ( "Data submission notification presented." ) ; let now = this . now ( ) ; this . _dataSubmissionPolicyNotifiedDate = now ; this . dataSubmissionPolicyNotifiedDate = now ; } . bind ( this ) ; let deferred = Promise . defer ( ) ; deferred . promise . then ( onComplete , function onError ( error ) { this . _log . warn ( "Data policy notification presentation failed: " + CommonUtils . exceptionStr ( error ) ) ; } ) ; this . _log . info ( "Requesting display of data policy." ) ; let request = new NotifyPolicyRequest ( this , deferred ) ; try { this . _listener . onNotifyDataPolicy ( request ) ; } catch ( ex ) { this . _log . warn ( "Exception when calling onNotifyDataPolicy: " + CommonUtils . exceptionStr ( ex ) ) ; } return false ; } if ( notifyState == this . STATE_NOTIFY_WAIT ) { let implicitAcceptanceDate = new Date ( this . _dataSubmissionPolicyNotifiedDate . getTime ( ) + this . IMPLICIT_ACCEPTANCE_INTERVAL_MSEC ) ; if ( now . getTime ( ) < implicitAcceptanceDate . getTime ( ) ) { this . _log . debug ( "Still waiting for reaction or implicit acceptance." ) ; return false ; } this . recordUserAcceptance ( "implicit-time-elapsed" ) ; return true ; } if ( notifyState != this . STATE_NOTIFY_COMPLETE ) { throw new Error ( "Unknown notification state: " + notifyState ) ; } return true ; }
Ensure user has responded to data submission policy.
Ensure user has responded to data submission policy .
// We're waiting for user action or implicit acceptance after display. // Check for implicit acceptance. // If this happens, we have a coding error in this file.