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

Unified Diff: chrome/test/data/extensions/samples/screenshot/functions.js

Issue 144019: Functionality has been requested in the Extension API for Javascript to... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 5 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: chrome/test/data/extensions/samples/screenshot/functions.js
===================================================================
--- chrome/test/data/extensions/samples/screenshot/functions.js (revision 0)
+++ chrome/test/data/extensions/samples/screenshot/functions.js (revision 0)
@@ -0,0 +1,45 @@
+// Copyright (c) 2009 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.
+
+var button = null;
+var my_window = null;
+var screenshot_url = null;
+var child_loaded = false;
+var have_screenshot = false;
+
+function registerHandlers() {
+ button = document.getElementById("button");
+ button.addEventListener("click",handleClick);
+}
+
+function waitForChildLoaded() {
+ if(child_loaded && have_screenshot) {
+ var foo = my_window.document.getElementById("replacer");
+ foo.src = screenshot_url;
+ have_screenshot = false;
+ } else {
+ window.setTimeout(waitForChildLoaded, 50);
+ }
+}
+
+function handleClick() {
+ child_loaded = false;
+ chrome.tabs.getVisibleTabCapture(null,
+ function(img) {
+ try {
+ have_screenshot = true;
+ screenshot_url = img;
+ } catch(e) {
+ for(var f in e) {
+ console.log(f + ":" + e[f]);
+ }
+ }
+ });
+ my_window = window.open('popup.html');
+ window.setTimeout(waitForChildLoaded, 50);
+}
+
+function childLoaded() {
+ child_loaded = true;
+}
Property changes on: chrome\test\data\extensions\samples\screenshot\functions.js
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698