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

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

Issue 8318001: Adding `content_security_policy` to a few sample extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Docs. Zips. Created 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/examples/api/tabs/screenshot/screenshot.js
diff --git a/chrome/common/extensions/docs/examples/api/tabs/screenshot/screenshot.js b/chrome/common/extensions/docs/examples/api/tabs/screenshot/screenshot.js
index 88ae90cb3222fa1d88da863027aa5721517b7e8f..cf83d33435f6f27bfc5b7918e10cacc7fa90fdef 100644
--- a/chrome/common/extensions/docs/examples/api/tabs/screenshot/screenshot.js
+++ b/chrome/common/extensions/docs/examples/api/tabs/screenshot/screenshot.js
@@ -2,55 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// To make sure we can uniquely identify each screenshot tab, add an id as a
-// query param to the url that displays the screenshot.
-var id = 100;
-
-function takeScreenshot() {
- chrome.tabs.captureVisibleTab(null, function(img) {
- var screenshotUrl = img;
- var viewTabUrl = [chrome.extension.getURL('screenshot.html'),
- '?id=', id++].join('');
-
- chrome.tabs.create({url: viewTabUrl}, function(tab) {
- var targetId = tab.id;
-
- var addSnapshotImageToTab = function(tabId, changedProps) {
- // We are waiting for the tab we opened to finish loading.
- // Check that the the tab's id matches the tab we opened,
- // and that the tab is done loading.
- if (tabId != targetId || changedProps.status != "complete")
- return;
-
- // Passing the above test means this is the event we were waiting for.
- // There is nothing we need to do for future onUpdated events, so we
- // use removeListner to stop geting called when onUpdated events fire.
- chrome.tabs.onUpdated.removeListener(addSnapshotImageToTab);
-
- // Look through all views to find the window which will display
- // the screenshot. The url of the tab which will display the
- // screenshot includes a query parameter with a unique id, which
- // ensures that exactly one view will have the matching URL.
- var views = chrome.extension.getViews();
- for (var i = 0; i < views.length; i++) {
- var view = views[i];
- if (view.location.href == viewTabUrl) {
- view.setScreenshotUrl(screenshotUrl);
- break;
- }
- }
- };
- chrome.tabs.onUpdated.addListener(addSnapshotImageToTab);
-
- });
- });
+function setScreenshotUrl(url) {
+ document.getElementById('target').src = url;
}
-
-// Listen for a click on the camera icon. On that click, take a screenshot.
-chrome.browserAction.onClicked.addListener(function(tab) {
- if (tab.url.match(/code.google.com/)) {
- takeScreenshot();
- } else {
- alert('This sample can only take screenshots of code.google.com pages');
- }
-});

Powered by Google App Engine
This is Rietveld 408576698