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

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

Issue 797183005: Add a mimeHandler extension API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@streams-lifetime
Patch Set: Created 5 years, 11 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
deleted file mode 100644
index 1bf748a8ac1ea11f86369e233ab92a690094b07c..0000000000000000000000000000000000000000
--- a/chrome/browser/resources/pdf/background.js
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-(function() {
- 'use strict';
-
- /**
- * A map of view ID (which identifies a particular PDF viewer instance) to
- * stream object.
- * @type {Object.<string, Object>}
- */
- var streams = {};
-
- /**
- * A map of view ID (which identifies a particular PDF viewer instance) to
- * initialization function for that view.
- * @type {Object.<string, Function>}
- */
- var pluginInitFunctions = {};
-
- /**
- * If we have received a stream object and an initialization function for a
- * particular PDF viewer instance we know that the extension has loaded in
- * and we can pass it the stream. We can then delete the corresponding map
- * entries.
- * @param {string} viewId The ID of the view to initialize with a stream.
- */
- function flush(viewId) {
- if (viewId in streams && viewId in pluginInitFunctions) {
- pluginInitFunctions[viewId](streams[viewId]);
- delete streams[viewId];
- delete pluginInitFunctions[viewId];
- }
- }
-
- /**
- * This is called when loading a document with the PDF mime type and passes a
- * stream that points to the PDF file. This may be run before or after we
- * receive a message from the PDF viewer with its initialization function.
- */
- chrome.streamsPrivate.onExecuteMimeTypeHandler.addListener(
- function(streamDetails) {
- // Store the stream until we are contacted by the PDF viewer that owns the
- // stream.
- streams[streamDetails.viewId] = streamDetails;
- flush(streamDetails.viewId);
- }
- );
-
- /**
- * This is called when we receive a message from the PDF viewer indicating
- * it has loaded and is ready to receive a stream of the data.
- */
- chrome.runtime.onMessage.addListener(
- function(request, sender, responseFunction) {
- // Store the initialization function until we receive the stream which
- // corresponds to the PDF viewer.
- pluginInitFunctions[request.viewId] = responseFunction;
- flush(request.viewId);
- }
- );
-}());

Powered by Google App Engine
This is Rietveld 408576698