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..724f34f9141122020193a36bcf6680a49aa28012 100644 |
--- a/chrome/browser/resources/pdf/background.js |
+++ b/chrome/browser/resources/pdf/background.js |
@@ -2,11 +2,37 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-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 }); |
+(function() { |
+ 'use strict'; |
+ |
+ /** |
+ * 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 = []; |
+ |
+ window.popStreamDetails = function() { |
+ if (streamsCache.length > 0) |
+ return streamsCache.pop(); |
} |
arv (Not doing code reviews)
2014/02/21 14:41:03
missing semicolon now that is a statement.
raymes
2014/02/23 23:55:10
Done.
|
-); |
+ |
+ chrome.streamsPrivate.onExecuteMimeTypeHandler.addListener( |
+ function(mime_type, original_url, content_url, tab_id) { |
arv (Not doing code reviews)
2014/02/21 14:41:03
no underscores in js
raymes
2014/02/23 23:55:10
Done.
|
+ // 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. |
+ var streamDetails = { |
+ mimeType: mime_type, |
+ originalURL: original_url, |
+ streamURL: content_url |
+ }; |
+ streamsCache.push(streamDetails); |
+ chrome.tabs.update(tab_id, { url: 'index.html' }); |
arv (Not doing code reviews)
2014/02/21 14:41:03
no ws after { nor before }
raymes
2014/02/23 23:55:10
Done.
|
+ } |
+ ); |
+ |
+}()); |