function Banners(
    directoryModel, volumeManager, document, showWelcome) {
  this.directoryModel_ = directoryModel;
  this.volumeManager_ = volumeManager;
  this.document_ = assert(document);
  this.showOffers_ = false;
  this.showWelcome_ = showWelcome;
  this.driveEnabled_ = false;

  this.usePromoWelcomeBanner_ = true;
  this.privateOnDirectoryChangedBound_ =
      this.privateOnDirectoryChanged_.bind(this);

  var handler = this.checkSpaceAndMaybeShowWelcomeBanner_.bind(this);
  this.directoryModel_.addEventListener('scan-completed', handler);
  this.directoryModel_.addEventListener('rescan-completed', handler);
  this.directoryModel_.addEventListener('directory-changed',
      this.onDirectoryChanged_.bind(this));

  this.unmountedPanel_ = this.document_.querySelector('#unmounted-panel');
  this.volumeManager_.volumeInfoList.addEventListener(
      'splice', this.onVolumeInfoListSplice_.bind(this));
  this.volumeManager_.addEventListener('drive-connection-changed',
      this.onDriveConnectionChanged_.bind(this));

  chrome.storage.onChanged.addListener(this.onStorageChange_.bind(this));
  this.welcomeHeaderCounter_ = WELCOME_HEADER_COUNTER_LIMIT;
  this.warningDismissedCounter_ = 0;
  this.downloadsWarningDismissedTime_ = 0;

  this.ready_ = Promise.all([
    new Promise(function(resolve, reject) {
      chrome.storage.local.get(
          [
            WELCOME_HEADER_COUNTER_KEY,
            DRIVE_WARNING_DISMISSED_KEY,
            DOWNLOADS_WARNING_DISMISSED_KEY
          ],
          function(values) {
            if (chrome.runtime.lastError) {
              reject('Failed to load banner data from chrome.storage: ' +
                  chrome.runtime.lastError.message);
              return;
            }
            this.welcomeHeaderCounter_ =
                parseInt(values[WELCOME_HEADER_COUNTER_KEY], 10) || 0;
            this.warningDismissedCounter_ =
                parseInt(values[DRIVE_WARNING_DISMISSED_KEY], 10) || 0;
            this.downloadsWarningDismissedTime_ =
                parseInt(values[DOWNLOADS_WARNING_DISMISSED_KEY], 10) || 0;

            // If it's in test, override the counter to show the header by
            // force.
            if (chrome.test) {
              this.welcomeHeaderCounter_ = 0;
              this.warningDismissedCounter_ = 0;
            }
            resolve();
          }.bind(this));
    }.bind(this)),
    new Promise(function(resolve) {
      // Get the 'allowRedeemOffers' preference for banners.
      chrome.fileManagerPrivate.getPreferences(function(pref) {
        this.showOffers_ = pref.allowRedeemOffers;
        resolve();
      }.bind(this));
    }.bind(this))
  ]).catch(function(error) {
    console.error(error);
  });

  // Authentication failed banner.
  this.authFailedBanner_ =
      this.document_.querySelector('#drive-auth-failed-warning');
  var authFailedText = this.authFailedBanner_.querySelector('.drive-text');
  authFailedText.innerHTML = util.htmlUnescape(str('DRIVE_NOT_REACHED'));
  authFailedText.querySelector('a').addEventListener('click', function(e) {
    chrome.fileManagerPrivate.logoutUserForReauthentication();
    e.preventDefault();
  });
  this.maybeShowAuthFailBanner_();
}
/**
 * Responsible for showing following banners in the file list.
 *  - WelcomeBanner
 *  - AuthFailBanner
 * @param {DirectoryModel} directoryModel The model.
 * @param {VolumeManagerWrapper} volumeManager The manager.
 * @param {Document} document HTML document.
 * @param {boolean} showWelcome True if the welcome banner can be shown.
 * @constructor
 * @extends {cr.EventTarget}
 */
Responsible for showing following banners in the file list.
Responsible for showing following banners in the file list .
function Banners(
    directoryModel, volumeManager, document, showWelcome) {
  this.directoryModel_ = directoryModel;
  this.volumeManager_ = volumeManager;
  this.document_ = assert(document);
  this.showOffers_ = false;
  this.showWelcome_ = showWelcome;
  this.driveEnabled_ = false;
  this.usePromoWelcomeBanner_ = true;
  this.privateOnDirectoryChangedBound_ =
      this.privateOnDirectoryChanged_.bind(this);
  var handler = this.checkSpaceAndMaybeShowWelcomeBanner_.bind(this);
  this.directoryModel_.addEventListener('scan-completed', handler);
  this.directoryModel_.addEventListener('rescan-completed', handler);
  this.directoryModel_.addEventListener('directory-changed',
      this.onDirectoryChanged_.bind(this));
  this.unmountedPanel_ = this.document_.querySelector('#unmounted-panel');
  this.volumeManager_.volumeInfoList.addEventListener(
      'splice', this.onVolumeInfoListSplice_.bind(this));
  this.volumeManager_.addEventListener('drive-connection-changed',
      this.onDriveConnectionChanged_.bind(this));
  chrome.storage.onChanged.addListener(this.onStorageChange_.bind(this));
  this.welcomeHeaderCounter_ = WELCOME_HEADER_COUNTER_LIMIT;
  this.warningDismissedCounter_ = 0;
  this.downloadsWarningDismissedTime_ = 0;
  this.ready_ = Promise.all([
    new Promise(function(resolve, reject) {
      chrome.storage.local.get(
          [
            WELCOME_HEADER_COUNTER_KEY,
            DRIVE_WARNING_DISMISSED_KEY,
            DOWNLOADS_WARNING_DISMISSED_KEY
          ],
          function(values) {
            if (chrome.runtime.lastError) {
              reject('Failed to load banner data from chrome.storage: ' +
                  chrome.runtime.lastError.message);
              return;
            }
            this.welcomeHeaderCounter_ =
                parseInt(values[WELCOME_HEADER_COUNTER_KEY], 10) || 0;
            this.warningDismissedCounter_ =
                parseInt(values[DRIVE_WARNING_DISMISSED_KEY], 10) || 0;
            this.downloadsWarningDismissedTime_ =
                parseInt(values[DOWNLOADS_WARNING_DISMISSED_KEY], 10) || 0;
            if (chrome.test) {
              this.welcomeHeaderCounter_ = 0;
              this.warningDismissedCounter_ = 0;
            }
            resolve();
          }.bind(this));
    }.bind(this)),
    new Promise(function(resolve) {
      chrome.fileManagerPrivate.getPreferences(function(pref) {
        this.showOffers_ = pref.allowRedeemOffers;
        resolve();
      }.bind(this));
    }.bind(this))
  ]).catch(function(error) {
    console.error(error);
  });
  this.authFailedBanner_ =
      this.document_.querySelector('#drive-auth-failed-warning');
  var authFailedText = this.authFailedBanner_.querySelector('.drive-text');
  authFailedText.innerHTML = util.htmlUnescape(str('DRIVE_NOT_REACHED'));
  authFailedText.querySelector('a').addEventListener('click', function(e) {
    chrome.fileManagerPrivate.logoutUserForReauthentication();
    e.preventDefault();
  });
  this.maybeShowAuthFailBanner_();
}
function Banners ( directoryModel , volumeManager , document , showWelcome ) { this . directoryModel_ = directoryModel ; this . volumeManager_ = volumeManager ; this . document_ = assert ( document ) ; this . showOffers_ = false ; this . showWelcome_ = showWelcome ; this . driveEnabled_ = false ; this . usePromoWelcomeBanner_ = true ; this . privateOnDirectoryChangedBound_ = this . privateOnDirectoryChanged_ . bind ( this ) ; var handler = this . checkSpaceAndMaybeShowWelcomeBanner_ . bind ( this ) ; this . directoryModel_ . addEventListener ( 'scan-completed' , handler ) ; this . directoryModel_ . addEventListener ( 'rescan-completed' , handler ) ; this . directoryModel_ . addEventListener ( 'directory-changed' , this . onDirectoryChanged_ . bind ( this ) ) ; this . unmountedPanel_ = this . document_ . querySelector ( '#unmounted-panel' ) ; this . volumeManager_ . volumeInfoList . addEventListener ( 'splice' , this . onVolumeInfoListSplice_ . bind ( this ) ) ; this . volumeManager_ . addEventListener ( 'drive-connection-changed' , this . onDriveConnectionChanged_ . bind ( this ) ) ; chrome . storage . onChanged . addListener ( this . onStorageChange_ . bind ( this ) ) ; this . welcomeHeaderCounter_ = WELCOME_HEADER_COUNTER_LIMIT ; this . warningDismissedCounter_ = 0 ; this . downloadsWarningDismissedTime_ = 0 ; this . ready_ = Promise . all ( [ new Promise ( function ( resolve , reject ) { chrome . storage . local . get ( [ WELCOME_HEADER_COUNTER_KEY , DRIVE_WARNING_DISMISSED_KEY , DOWNLOADS_WARNING_DISMISSED_KEY ] , function ( values ) { if ( chrome . runtime . lastError ) { reject ( 'Failed to load banner data from chrome.storage: ' + chrome . runtime . lastError . message ) ; return ; } this . welcomeHeaderCounter_ = parseInt ( values [ WELCOME_HEADER_COUNTER_KEY ] , 10 ) || 0 ; this . warningDismissedCounter_ = parseInt ( values [ DRIVE_WARNING_DISMISSED_KEY ] , 10 ) || 0 ; this . downloadsWarningDismissedTime_ = parseInt ( values [ DOWNLOADS_WARNING_DISMISSED_KEY ] , 10 ) || 0 ; if ( chrome . test ) { this . welcomeHeaderCounter_ = 0 ; this . warningDismissedCounter_ = 0 ; } resolve ( ) ; } . bind ( this ) ) ; } . bind ( this ) ) , new Promise ( function ( resolve ) { chrome . fileManagerPrivate . getPreferences ( function ( pref ) { this . showOffers_ = pref . allowRedeemOffers ; resolve ( ) ; } . bind ( this ) ) ; } . bind ( this ) ) ] ) . catch ( function ( error ) { console . error ( error ) ; } ) ; this . authFailedBanner_ = this . document_ . querySelector ( '#drive-auth-failed-warning' ) ; var authFailedText = this . authFailedBanner_ . querySelector ( '.drive-text' ) ; authFailedText . innerHTML = util . htmlUnescape ( str ( 'DRIVE_NOT_REACHED' ) ) ; authFailedText . querySelector ( 'a' ) . addEventListener ( 'click' , function ( e ) { chrome . fileManagerPrivate . logoutUserForReauthentication ( ) ; e . preventDefault ( ) ; } ) ; this . maybeShowAuthFailBanner_ ( ) ; }
Responsible for showing following banners in the file list.
Responsible for showing following banners in the file list .
// If it's in test, override the counter to show the header by // force. // Get the 'allowRedeemOffers' preference for banners. // Authentication failed banner.