1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 function takeScreenshot(onScreenshot) {
6 console.log('Taking screenshot.');
7 chrome.tabs.captureVisibleTab(null, {format: 'png'}, function(img) {
8 console.log('Got screenshot, returning...');
13 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
14 if (changeInfo.status != 'complete')
17 chrome.tabs.executeScript(tabId,
18 {file: 'injected.js', runAt: 'document_start'});
21 chrome.runtime.onMessage.addListener(
22 function(request, sender, sendResponse) {
23 takeScreenshot(sendResponse);
25 // Keep the sendResponse channel open, so a response can be sent