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

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

Issue 554893002: [WORK_IN_PROGRESS] PDF::Save() fix for out-of-process-pdf. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: better fix for constrained windows Created 6 years, 3 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/browser/resources/pdf/background.js
diff --git a/chrome/browser/resources/pdf/background.js b/chrome/browser/resources/pdf/background.js
index 2114010193fb47095da2464de33d67fdede00557..3c514b679fde33b02899d49b871eb2dde3403111 100644
--- a/chrome/browser/resources/pdf/background.js
+++ b/chrome/browser/resources/pdf/background.js
@@ -5,29 +5,43 @@
(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 = [];
+ var streams = {};
+ var pluginInitFunctions = {};
+ function flush(viewId) {
+ if (viewId in streams && viewId in pluginInitFunctions) {
+ pluginInitFunctions[viewId](streams[viewId]);
+ delete streams[viewId];
+ delete pluginInitFunctions[viewId];
+ }
+ }
+
+ // Legacy.
window.popStreamDetails = function() {
- if (streamsCache.length > 0)
- return streamsCache.pop();
+ for (var viewId in streams) {
+ var result = streams[viewId];
+ delete streams[viewId];
+ delete pluginInitFunctions[viewId];
+ return result;
+ }
};
chrome.streamsPrivate.onExecuteMimeTypeHandler.addListener(
function(streamDetails) {
- // 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.
- streamsCache.push(streamDetails);
- chrome.tabs.update(streamDetails.tabId, {url: 'index.html'});
+ if (!streamDetails.viewId) {
+ streams.push(streamDetails);
+ chrome.tabs.update(streamDetails.tabId, {url: 'index.html'});
+ } else {
+ streams[streamDetails.viewId] = streamDetails;
+ flush(streamDetails.viewId);
+ }
}
);
+ chrome.runtime.onMessage.addListener(
+ function(request, sender, responseFunction) {
+ pluginInitFunctions[request.viewId] = responseFunction;
+ flush(request.viewId);
+ }
+ );
}());

Powered by Google App Engine
This is Rietveld 408576698