Roll android_tools to the latest.
[chromium-blink-merge.git] / native_client_sdk / src / build_tools / screenshot_extension / background.js
blobf1e1808edc9611a1298b09abacae266b4f5a48d2
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...');
9     onScreenshot(img);
10   });
13 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
14   if (changeInfo.status != 'complete')
15     return;
17   chrome.tabs.executeScript(tabId,
18                             {file: 'injected.js', runAt: 'document_start'});
19 });
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
26       // asynchronously.
27       return true;
28     });