B2G/gecko/browser/components/thumbnails/PageThumbs.jsm
/**
   * Captures a thumbnail for the given browser and stores it to the cache.
   * @param aBrowser The browser to capture a thumbnail for.
   * @param aCallback The function to be called when finished (optional).
   */
Captures a thumbnail for the given browser and stores it to the cache.
@param aBrowser The browser to capture a thumbnail for.
@param aCallback The function to be called when finished (optional).
Captures a thumbnail for the given browser and stores it to the cache . @param aBrowser The browser to capture a thumbnail for . @param aCallback The function to be called when finished ( optional ) .
function PageThumbs_captureAndStore(aBrowser, aCallback) {
    if (!this._prefEnabled()) {
      return;
    }
    let url = aBrowser.currentURI.spec;
    let channel = aBrowser.docShell.currentDocumentChannel;
    let originalURL = channel.originalURI.spec;
    this.capture(aBrowser.contentWindow, function (aInputStream) {
      let telemetryStoreTime = new Date();
      function finish(aSuccessful) {
        if (aSuccessful) {
          Services.telemetry.getHistogramById("FX_THUMBNAILS_STORE_TIME_MS")
            .add(new Date() - telemetryStoreTime);
           1) Users can drag any kind of links onto the newtab page. If those
              links redirect to a different URL then we want to be able to
              provide thumbnails for both of them.
           2) The newtab page should actually display redirect targets, only.
              Because of bug 559175 this information can get lost when using
              Sync and therefore also redirect sources appear on the newtab
              page. We also want thumbnails for those.
          if (url != originalURL)
            PageThumbsStorage.copy(url, originalURL);
        }
        if (aCallback)
          aCallback(aSuccessful);
      }
      PageThumbsStorage.write(url, aInputStream, finish);
    });
  }
function PageThumbs_captureAndStore ( aBrowser , aCallback ) { if ( ! this . _prefEnabled ( ) ) { return ; } let url = aBrowser . currentURI . spec ; let channel = aBrowser . docShell . currentDocumentChannel ; let originalURL = channel . originalURI . spec ; this . capture ( aBrowser . contentWindow , function ( aInputStream ) { let telemetryStoreTime = new Date ( ) ; function finish ( aSuccessful ) { if ( aSuccessful ) { Services . telemetry . getHistogramById ( "FX_THUMBNAILS_STORE_TIME_MS" ) . add ( new Date ( ) - telemetryStoreTime ) ; if ( url != originalURL ) PageThumbsStorage . copy ( url , originalURL ) ; } if ( aCallback ) aCallback ( aSuccessful ) ; } PageThumbsStorage . write ( url , aInputStream , finish ) ; } ) ; }
Captures a thumbnail for the given browser and stores it to the cache.
Captures a thumbnail for the given browser and stores it to the cache .
// We've been redirected. Create a copy of the current thumbnail for // the redirect source. We need to do this because: // // 1) Users can drag any kind of links onto the newtab page. If those //    links redirect to a different URL then we want to be able to //    provide thumbnails for both of them. // // 2) The newtab page should actually display redirect targets, only. //    Because of bug 559175 this information can get lost when using //    Sync and therefore also redirect sources appear on the newtab //    page. We also want thumbnails for those.