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

Side by Side Diff: chrome/common/extensions/docs/examples/api/tabs/screenshot/screenshot.js

Issue 7003059: Added license header (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 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.
4
1 // To make sure we can uniquely identify each screenshot tab, add an id as a 5 // To make sure we can uniquely identify each screenshot tab, add an id as a
2 // query param to the url that displays the screenshot. 6 // query param to the url that displays the screenshot.
3 var id = 100; 7 var id = 100;
4 8
5 function takeScreenshot() { 9 function takeScreenshot() {
6 chrome.tabs.captureVisibleTab(null, function(img) { 10 chrome.tabs.captureVisibleTab(null, function(img) {
7 var screenshotUrl = img; 11 var screenshotUrl = img;
8 var viewTabUrl = [chrome.extension.getURL('screenshot.html'), 12 var viewTabUrl = [chrome.extension.getURL('screenshot.html'),
9 '?id=', id++].join(''); 13 '?id=', id++].join('');
10 14
(...skipping 26 matching lines...) Expand all
37 } 41 }
38 }; 42 };
39 chrome.tabs.onUpdated.addListener(addSnapshotImageToTab); 43 chrome.tabs.onUpdated.addListener(addSnapshotImageToTab);
40 44
41 }); 45 });
42 }); 46 });
43 } 47 }
44 48
45 // Listen for a click on the camera icon. On that click, take a screenshot. 49 // Listen for a click on the camera icon. On that click, take a screenshot.
46 chrome.browserAction.onClicked.addListener(function(tab) { 50 chrome.browserAction.onClicked.addListener(function(tab) {
47 takeScreenshot(); 51 if (tab.url.match(/code.google.com/)) {
52 takeScreenshot();
53 } else {
54 alert('This sample can only take screenshots of code.google.com pages');
55 }
48 }); 56 });
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/examples/api/tabs/screenshot/manifest.json ('k') | chrome/common/extensions/docs/samples.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698