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

Side by Side Diff: chrome/browser/resources/feedback/js/take_screenshot.js

Issue 1382513002: Regression: 'Alt+Shift+i', shortcut key for "report an issue" works only once for every 2 tries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * Function to take the screenshot of the current screen. 6 * Function to take the screenshot of the current screen.
7 * @param {function(HTMLCanvasElement)} callback Callback for returning the 7 * @param {function(HTMLCanvasElement)} callback Callback for returning the
8 * canvas with the screenshot on it. 8 * canvas with the screenshot on it.
9 */ 9 */
10 function takeScreenshot(callback) { 10 function takeScreenshot(callback) {
11 var screenshotStream = null; 11 var screenshotStream = null;
12 var video = document.createElement('video'); 12 var video = document.createElement('video');
13 13
14 video.addEventListener('canplay', function(e) { 14 video.addEventListener('canplay', function(e) {
15 if (screenshotStream) { 15 if (screenshotStream) {
16 var canvas = document.createElement('canvas'); 16 var canvas = document.createElement('canvas');
17 canvas.setAttribute('width', video.videoWidth); 17 canvas.setAttribute('width', video.videoWidth);
18 canvas.setAttribute('height', video.videoHeight); 18 canvas.setAttribute('height', video.videoHeight);
19 canvas.getContext('2d').drawImage( 19 canvas.getContext('2d').drawImage(
20 video, 0, 0, video.videoWidth, video.videoHeight); 20 video, 0, 0, video.videoWidth, video.videoHeight);
21 21
22 video.pause(); 22 video.pause();
23 video.src = ''; 23 video.src = '';
24 24
25 screenshotStream.stop(); 25 screenshotStream.getVideoTracks()[0].stop();
26 screenshotStream = null; 26 screenshotStream = null;
27 27
28 callback(canvas); 28 callback(canvas);
29 } 29 }
30 }, false); 30 }, false);
31 31
32 navigator.webkitGetUserMedia( 32 navigator.webkitGetUserMedia(
33 { 33 {
34 video: { 34 video: {
35 mandatory: { 35 mandatory: {
36 chromeMediaSource: 'screen', 36 chromeMediaSource: 'screen',
37 maxWidth: 4096, 37 maxWidth: 4096,
38 maxHeight: 2560 38 maxHeight: 2560
39 } 39 }
40 } 40 }
41 }, 41 },
42 function(stream) { 42 function(stream) {
43 if (stream) { 43 if (stream) {
44 screenshotStream = stream; 44 screenshotStream = stream;
45 video.src = window.URL.createObjectURL(screenshotStream); 45 video.src = window.URL.createObjectURL(screenshotStream);
46 video.play(); 46 video.play();
47 } 47 }
48 }, 48 },
49 function(err) { 49 function(err) {
50 console.error('takeScreenshot failed: ' + 50 console.error('takeScreenshot failed: ' +
51 err.name + '; ' + err.message + '; ' + err.constraintName); 51 err.name + '; ' + err.message + '; ' + err.constraintName);
52 } 52 }
53 ); 53 );
54 } 54 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698