Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 /** | |
| 6 * @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.
| |
| 7 * Keep a stack of stream details for requests. These are pushed onto the stack | |
| 8 * as requests come in and popped off the stack as they are handled by a | |
| 9 * renderer. | |
| 10 * TODO(raymes): This is probably racy for multiple requests. We could associate | |
| 11 * an ID with the request but this code will probably change completely when | |
| 12 * MIME type handling is improved. | |
| 13 */ | |
| 14 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.
| |
| 15 | |
| 16 function popStreamDetails() { | |
| 17 if (streamsCache_.length > 0) | |
| 18 return streamsCache_.pop(); | |
| 19 } | |
| 20 | |
| 5 chrome.streamsPrivate.onExecuteMimeTypeHandler.addListener( | 21 chrome.streamsPrivate.onExecuteMimeTypeHandler.addListener( |
| 6 function(mime_type, original_url, content_url, tab_id) { | 22 function(mime_type, original_url, content_url, tab_id) { |
| 7 // TODO(raymes): Currently this doesn't work with embedded PDFs (it | 23 // TODO(raymes): Currently this doesn't work with embedded PDFs (it |
| 8 // causes the entire frame to navigate). Also work out how we can | 24 // causes the entire frame to navigate). Also work out how we can |
| 9 // mask the URL with the URL of the PDF. | 25 // mask the URL with the URL of the PDF. |
| 10 chrome.tabs.update(tab_id, { url: 'index.html?' + content_url }); | 26 var streamDetails = { |
| 27 mimeType: mime_type, | |
| 28 originalURL: original_url, | |
| 29 streamURL: content_url | |
| 30 }; | |
| 31 streamsCache_.push(streamDetails); | |
| 32 chrome.tabs.update(tab_id, { url: 'index.html' }); | |
| 11 } | 33 } |
| 12 ); | 34 ); |
| OLD | NEW |