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

Unified Diff: extensions/renderer/resources/mime_handler_private_custom_bindings.js

Issue 2409073002: Use mojo from the PDF extension instead of using an extension API.
Patch Set: Created 4 years, 2 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
« no previous file with comments | « extensions/renderer/resources/keep_alive.js ('k') | extensions/test/data/api_test_base_unittest.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/resources/mime_handler_private_custom_bindings.js
diff --git a/extensions/renderer/resources/mime_handler_private_custom_bindings.js b/extensions/renderer/resources/mime_handler_private_custom_bindings.js
deleted file mode 100644
index 4a515394d1413698e119a165be108867743576de..0000000000000000000000000000000000000000
--- a/extensions/renderer/resources/mime_handler_private_custom_bindings.js
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2015 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.
-
-/**
- * Custom bindings for the mime handler API.
- */
-
-var binding = require('binding').Binding.create('mimeHandlerPrivate');
-
-var NO_STREAM_ERROR =
- 'Streams are only available from a mime handler view guest.';
-var STREAM_ABORTED_ERROR = 'Stream has been aborted.';
-
-var servicePromise = Promise.all([
- requireAsync('content/public/renderer/frame_interfaces'),
- requireAsync('extensions/common/api/mime_handler.mojom'),
- requireAsync('mojo/public/js/router'),
-]).then(function(modules) {
- var frameInterfaces = modules[0];
- var mojom = modules[1];
- var routerModule = modules[2];
- return new mojom.MimeHandlerService.proxyClass(new routerModule.Router(
- frameInterfaces.getInterface(mojom.MimeHandlerService.name)));
-});
-
-// Stores a promise to the GetStreamInfo() result to avoid making additional
-// calls in response to getStreamInfo() calls.
-var streamInfoPromise;
-
-function throwNoStreamError() {
- throw new Error(NO_STREAM_ERROR);
-}
-
-function createStreamInfoPromise() {
- return servicePromise.then(function(service) {
- return service.getStreamInfo();
- }).then(function(result) {
- if (!result.stream_info)
- throw new Error(STREAM_ABORTED_ERROR);
- return result.stream_info;
- }, throwNoStreamError);
-}
-
-function constructStreamInfoDict(streamInfo) {
- var headers = {};
- for (var header of streamInfo.response_headers) {
- headers[header[0]] = header[1];
- }
- return {
- mimeType: streamInfo.mime_type,
- originalUrl: streamInfo.original_url,
- streamUrl: streamInfo.stream_url,
- tabId: streamInfo.tab_id,
- embedded: !!streamInfo.embedded,
- responseHeaders: headers,
- };
-}
-
-binding.registerCustomHook(function(bindingsAPI) {
- var apiFunctions = bindingsAPI.apiFunctions;
- apiFunctions.setHandleRequestWithPromise('getStreamInfo', function() {
- if (!streamInfoPromise)
- streamInfoPromise = createStreamInfoPromise();
- return streamInfoPromise.then(constructStreamInfoDict);
- });
-
- apiFunctions.setHandleRequestWithPromise('abortStream', function() {
- return servicePromise.then(function(service) {
- return service.abortStream().then(function() {});
- }).catch(throwNoStreamError);
- });
-});
-
-exports.$set('binding', binding.generate());
« no previous file with comments | « extensions/renderer/resources/keep_alive.js ('k') | extensions/test/data/api_test_base_unittest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698