function WallpaperManager(dialogDom) {
  this.dialogDom_ = dialogDom;
  this.document_ = dialogDom.ownerDocument;
  this.useNewWallpaperPicker_ =
      loadTimeData.getBoolean('useNewWallpaperPicker');
  this.enableOnlineWallpaper_ = loadTimeData.valueExists('manifestBaseURL') ||
      this.useNewWallpaperPicker_;
  this.selectedItem_ = null;
  this.progressManager_ = new ProgressManager();
  this.customWallpaperData_ = null;
  this.currentWallpaper_ = null;
  this.wallpaperRequest_ = null;
  this.wallpaperDirs_ = WallpaperDirectories.getInstance();
  this.preDownloadDomInit_();

  // Uses the redesigned wallpaper picker if |useNewWallpaperPicker| is true.
  //
  // The old wallpaper picker fetches the manifest file once, and parse the info
  // (such as image url) from the file every time when the images need to be
  // displayed.
  // The new wallpaper picker has two steps: it first fetches a list of
  // collection names (ie. categories such as Art, Landscape etc.) via extension
  // API, and then fetches the info specific to each collection and caches the
  // info in a map.
  // After the url and relevant info of the images are fetched, the two share
  // the same path, ie. pass the info to |WallpaperThumbnailsGridItem| for
  // actual image rendering.
  this.document_.body.classList.toggle('v2', this.useNewWallpaperPicker_);
  this.placeWallpaperPicker_();

  if (this.useNewWallpaperPicker_) {
    // |collectionsInfo_| represents the list of wallpaper collections. Each
    // collection contains the display name and a unique id.
    this.collectionsInfo_ = null;
    // |imagesInfoMap_| caches the mapping between each collection id and the
    // images that belong to this collection. Each image is represented by a set
    // of info including the image url, author name, layout etc. Such info will
    // be used by |WallpaperThumbnailsGridItem| to display the images.
    this.imagesInfoMap_ = {};
    // The total count of images whose info has been fetched.
    this.imagesInfoCount_ = 0;
    this.getCollectionsInfo_();
  } else {
    this.fetchManifest_();
  }
}
/**
 * WallpaperManager constructor.
 *
 * WallpaperManager objects encapsulate the functionality of the wallpaper
 * manager extension.
 *
 * @constructor
 * @param {HTMLElement} dialogDom The DOM node containing the prototypical
 *     extension UI.
 */


@constructor
@param {HTMLElement} dialogDom The DOM node containing the prototypical
extension UI.
@constructor @param { HTMLElement } dialogDom The DOM node containing the prototypical extension UI .
function WallpaperManager(dialogDom) {
  this.dialogDom_ = dialogDom;
  this.document_ = dialogDom.ownerDocument;
  this.useNewWallpaperPicker_ =
      loadTimeData.getBoolean('useNewWallpaperPicker');
  this.enableOnlineWallpaper_ = loadTimeData.valueExists('manifestBaseURL') ||
      this.useNewWallpaperPicker_;
  this.selectedItem_ = null;
  this.progressManager_ = new ProgressManager();
  this.customWallpaperData_ = null;
  this.currentWallpaper_ = null;
  this.wallpaperRequest_ = null;
  this.wallpaperDirs_ = WallpaperDirectories.getInstance();
  this.preDownloadDomInit_();
   The old wallpaper picker fetches the manifest file once, and parse the info
   (such as image url) from the file every time when the images need to be
   displayed.
   The new wallpaper picker has two steps: it first fetches a list of
   collection names (ie. categories such as Art, Landscape etc.) via extension
   API, and then fetches the info specific to each collection and caches the
   info in a map.
   After the url and relevant info of the images are fetched, the two share
   the same path, ie. pass the info to |WallpaperThumbnailsGridItem| for
   actual image rendering.
  this.document_.body.classList.toggle('v2', this.useNewWallpaperPicker_);
  this.placeWallpaperPicker_();
  if (this.useNewWallpaperPicker_) {
     |collectionsInfo_| represents the list of wallpaper collections. Each
     collection contains the display name and a unique id.
    this.collectionsInfo_ = null;
     |imagesInfoMap_| caches the mapping between each collection id and the
     images that belong to this collection. Each image is represented by a set
     of info including the image url, author name, layout etc. Such info will
     be used by |WallpaperThumbnailsGridItem| to display the images.
    this.imagesInfoMap_ = {};
     The total count of images whose info has been fetched.
    this.imagesInfoCount_ = 0;
    this.getCollectionsInfo_();
  } else {
    this.fetchManifest_();
  }
}
function WallpaperManager ( dialogDom ) { this . dialogDom_ = dialogDom ; this . document_ = dialogDom . ownerDocument ; this . useNewWallpaperPicker_ = loadTimeData . getBoolean ( 'useNewWallpaperPicker' ) ; this . enableOnlineWallpaper_ = loadTimeData . valueExists ( 'manifestBaseURL' ) || this . useNewWallpaperPicker_ ; this . selectedItem_ = null ; this . progressManager_ = new ProgressManager ( ) ; this . customWallpaperData_ = null ; this . currentWallpaper_ = null ; this . wallpaperRequest_ = null ; this . wallpaperDirs_ = WallpaperDirectories . getInstance ( ) ; this . preDownloadDomInit_ ( ) ; this . document_ . body . classList . toggle ( 'v2' , this . useNewWallpaperPicker_ ) ; this . placeWallpaperPicker_ ( ) ; if ( this . useNewWallpaperPicker_ ) { this . collectionsInfo_ = null ; this . imagesInfoMap_ = { } ; this . imagesInfoCount_ = 0 ; this . getCollectionsInfo_ ( ) ; } else { this . fetchManifest_ ( ) ; } }
WallpaperManager constructor.
WallpaperManager constructor .
// Uses the redesigned wallpaper picker if |useNewWallpaperPicker| is true. // // The old wallpaper picker fetches the manifest file once, and parse the info // (such as image url) from the file every time when the images need to be // displayed. // The new wallpaper picker has two steps: it first fetches a list of // collection names (ie. categories such as Art, Landscape etc.) via extension // API, and then fetches the info specific to each collection and caches the // info in a map. // After the url and relevant info of the images are fetched, the two share // the same path, ie. pass the info to |WallpaperThumbnailsGridItem| for // actual image rendering. // |collectionsInfo_| represents the list of wallpaper collections. Each // collection contains the display name and a unique id. // |imagesInfoMap_| caches the mapping between each collection id and the // images that belong to this collection. Each image is represented by a set // of info including the image url, author name, layout etc. Such info will // be used by |WallpaperThumbnailsGridItem| to display the images. // The total count of images whose info has been fetched.