     chrome.tabs.captureVisibleTab chrome.windows.WINDOW_ID_CURRENT, {quality : 80, format : "jpeg"}, (dataUrl) =>
       @storageManager.store "screenshots", {screenshotId:@pageId, _pageId:@pageId, screenshot:dataUrl}
       console.log "screenshot taken for #{@tab.url}"
+      console.log dataUrl
       @screenshotTaken = true
       return
     return


  constructor : (@message, @referer, sender, sendResponse, @storageManager, @activeTab) ->
    @dontStore = false
    @idleInterval = 5*60 #in second...
    @pageId = @message.content.pageId
    @tab = sender.tab

    console.log "update content of #{@pageId}"
    return
    
  setTabActivated : (isActive) =>
    @isActive = isActive
    @document.focusTime.push {timestamp: new Date().getTime(), focused: isActive}
    @storetemporaryDocument()
    if not @screenshotTaken and isActive and not @counting
      @keepcounting()
    return
  
  keepcounting : () =>
    if @isActive and not @screenshotTaken
      if @screenshotTimer > @screenshotDelay
        @takeScreenshot()
      else
        @counting = true
        setTimeout () =>
          @screenshotTimer += 10
          @counting = false
          @keepcounting()
        ,10
 
      
    
  setNotIdle : (isIdle) ->
    @document.activityTime.push {timestamp: new Date().getTime(), active: not isIdle}
