Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: native_client_sdk/src/build_tools/screenshot_extension/background.js

Issue 23458018: [NaCl SDK] Screen capture extension for use with SDK visual testing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nits Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/build_tools/screenshot_extension/background.js
diff --git a/native_client_sdk/src/build_tools/screenshot_extension/background.js b/native_client_sdk/src/build_tools/screenshot_extension/background.js
new file mode 100644
index 0000000000000000000000000000000000000000..f1e1808edc9611a1298b09abacae266b4f5a48d2
--- /dev/null
+++ b/native_client_sdk/src/build_tools/screenshot_extension/background.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function takeScreenshot(onScreenshot) {
+ console.log('Taking screenshot.');
+ chrome.tabs.captureVisibleTab(null, {format: 'png'}, function(img) {
+ console.log('Got screenshot, returning...');
+ onScreenshot(img);
+ });
+}
+
+chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
+ if (changeInfo.status != 'complete')
+ return;
+
+ chrome.tabs.executeScript(tabId,
+ {file: 'injected.js', runAt: 'document_start'});
+});
+
+chrome.runtime.onMessage.addListener(
+ function(request, sender, sendResponse) {
+ takeScreenshot(sendResponse);
+
+ // Keep the sendResponse channel open, so a response can be sent
+ // asynchronously.
+ return true;
+ });

Powered by Google App Engine
This is Rietveld 408576698