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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function() { 5 (function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 var streams = {};
9 * Keep a stack of stream details for requests. These are pushed onto the 9 var pluginInitFunctions = {};
10 * stack as requests come in and popped off the stack as they are handled by a
11 * renderer.
12 * TODO(raymes): This is probably racy for multiple requests. We could
13 * associate an ID with the request but this code will probably change
14 * completely when MIME type handling is improved.
15 */
16 var streamsCache = [];
17 10
11 function flush(viewId) {
12 if (viewId in streams && viewId in pluginInitFunctions) {
13 pluginInitFunctions[viewId](streams[viewId]);
14 delete streams[viewId];
15 delete pluginInitFunctions[viewId];
16 }
17 }
18
19 // Legacy.
18 window.popStreamDetails = function() { 20 window.popStreamDetails = function() {
19 if (streamsCache.length > 0) 21 for (var viewId in streams) {
20 return streamsCache.pop(); 22 var result = streams[viewId];
23 delete streams[viewId];
24 delete pluginInitFunctions[viewId];
25 return result;
26 }
21 }; 27 };
22 28
23 chrome.streamsPrivate.onExecuteMimeTypeHandler.addListener( 29 chrome.streamsPrivate.onExecuteMimeTypeHandler.addListener(
24 function(streamDetails) { 30 function(streamDetails) {
25 // TODO(raymes): Currently this doesn't work with embedded PDFs (it 31 if (!streamDetails.viewId) {
26 // causes the entire frame to navigate). Also work out how we can 32 streams.push(streamDetails);
27 // mask the URL with the URL of the PDF. 33 chrome.tabs.update(streamDetails.tabId, {url: 'index.html'});
28 streamsCache.push(streamDetails); 34 } else {
29 chrome.tabs.update(streamDetails.tabId, {url: 'index.html'}); 35 streams[streamDetails.viewId] = streamDetails;
36 flush(streamDetails.viewId);
37 }
30 } 38 }
31 ); 39 );
32 40
41 chrome.runtime.onMessage.addListener(
42 function(request, sender, responseFunction) {
43 pluginInitFunctions[request.viewId] = responseFunction;
44 flush(request.viewId);
45 }
46 );
33 }()); 47 }());
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698