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

Unified Diff: chrome/browser/resources/pdf/background.js

Issue 169613005: Hookup print and save buttons in the out of process PDF plugin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/resources/pdf/index.html » ('j') | chrome/browser/resources/pdf/index.html » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/pdf/background.js
diff --git a/chrome/browser/resources/pdf/background.js b/chrome/browser/resources/pdf/background.js
index 06f5b2e0d768225039bf04a19d041ac281247e11..6659070180eb877c410adb5f8d548babd8f1fb81 100644
--- a/chrome/browser/resources/pdf/background.js
+++ b/chrome/browser/resources/pdf/background.js
@@ -2,11 +2,33 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+/**
+ * @private
arv (Not doing code reviews) 2014/02/20 20:10:45 Use an IIFE (function() { 'use strict'; var
raymes 2014/02/21 03:52:24 Done.
+ * Keep a stack of stream details for requests. These are pushed onto the stack
+ * as requests come in and popped off the stack as they are handled by a
+ * renderer.
+ * TODO(raymes): This is probably racy for multiple requests. We could associate
+ * an ID with the request but this code will probably change completely when
+ * MIME type handling is improved.
+ */
+var streamsCache_ = [];
arv (Not doing code reviews) 2014/02/20 20:10:45 No underscores on variables.
raymes 2014/02/21 03:52:24 Done.
+
+function popStreamDetails() {
+ if (streamsCache_.length > 0)
+ return streamsCache_.pop();
+}
+
chrome.streamsPrivate.onExecuteMimeTypeHandler.addListener(
function(mime_type, original_url, content_url, tab_id) {
// TODO(raymes): Currently this doesn't work with embedded PDFs (it
// causes the entire frame to navigate). Also work out how we can
// mask the URL with the URL of the PDF.
- chrome.tabs.update(tab_id, { url: 'index.html?' + content_url });
+ var streamDetails = {
+ mimeType: mime_type,
+ originalURL: original_url,
+ streamURL: content_url
+ };
+ streamsCache_.push(streamDetails);
+ chrome.tabs.update(tab_id, { url: 'index.html' });
}
);
« no previous file with comments | « no previous file | chrome/browser/resources/pdf/index.html » ('j') | chrome/browser/resources/pdf/index.html » ('J')

Powered by Google App Engine
This is Rietveld 408576698