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
3 // found in the LICENSE file.
9 * Keep a stack of stream details for requests. These are pushed onto the
10 * stack as requests come in and popped off the stack as they are handled by a
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.
16 var streamsCache
= [];
18 window
.popStreamDetails = function() {
19 if (streamsCache
.length
> 0)
20 return streamsCache
.pop();
23 chrome
.streamsPrivate
.onExecuteMimeTypeHandler
.addListener(
24 function(streamDetails
) {
25 // TODO(raymes): Currently this doesn't work with embedded PDFs (it
26 // causes the entire frame to navigate). Also work out how we can
27 // mask the URL with the URL of the PDF.
28 streamsCache
.push(streamDetails
);
29 chrome
.tabs
.update(streamDetails
.tabId
, {url
: 'index.html'});