| Index: chrome/browser/resources/pdf/browser_api.js
|
| diff --git a/chrome/browser/resources/pdf/browser_api.js b/chrome/browser/resources/pdf/browser_api.js
|
| index 28f17b9d1da1b9a80db49321bb06e1538e7e472a..512bfff6e9c584d97afd364a5e91fdafa1cb10fd 100644
|
| --- a/chrome/browser/resources/pdf/browser_api.js
|
| +++ b/chrome/browser/resources/pdf/browser_api.js
|
| @@ -71,13 +71,12 @@ class BrowserApi {
|
| * @param {BrowserApi.ZoomBehavior} zoomBehavior How to manage zoom.
|
| */
|
| static create(streamInfo, zoomBehavior) {
|
| - return Promise.all([
|
| - lookupDefaultZoom(streamInfo),
|
| - lookupInitialZoom(streamInfo)
|
| - ]).then(function(zoomFactors) {
|
| - return new BrowserApi(
|
| - streamInfo, zoomFactors[0], zoomFactors[1], zoomBehavior);
|
| - });
|
| + return Promise
|
| + .all([lookupDefaultZoom(streamInfo), lookupInitialZoom(streamInfo)])
|
| + .then(function(zoomFactors) {
|
| + return new BrowserApi(
|
| + streamInfo, zoomFactors[0], zoomFactors[1], zoomBehavior);
|
| + });
|
| }
|
|
|
| /**
|
| @@ -169,30 +168,32 @@ BrowserApi.ZoomBehavior = {
|
| */
|
| function createBrowserApiForMimeHandlerView() {
|
| return new Promise(function(resolve, reject) {
|
| - chrome.mimeHandlerPrivate.getStreamInfo(resolve);
|
| - }).then(function(streamInfo) {
|
| - let promises = [];
|
| - let zoomBehavior = BrowserApi.ZoomBehavior.NONE;
|
| - if (streamInfo.tabId != -1) {
|
| - zoomBehavior = streamInfo.embedded ?
|
| - BrowserApi.ZoomBehavior.PROPAGATE_PARENT :
|
| - BrowserApi.ZoomBehavior.MANAGE;
|
| - promises.push(new Promise(function(resolve) {
|
| - chrome.tabs.get(streamInfo.tabId, resolve);
|
| - }).then(function(tab) {
|
| - if (tab)
|
| - streamInfo.tabUrl = tab.url;
|
| - }));
|
| - }
|
| - if (zoomBehavior == BrowserApi.ZoomBehavior.MANAGE) {
|
| - promises.push(new Promise(function(resolve) {
|
| - chrome.tabs.setZoomSettings(
|
| - streamInfo.tabId, {mode: 'manual', scope: 'per-tab'}, resolve);
|
| - }));
|
| - }
|
| - return Promise.all(promises).then(
|
| - function() { return BrowserApi.create(streamInfo, zoomBehavior); });
|
| - });
|
| + chrome.mimeHandlerPrivate.getStreamInfo(resolve);
|
| + })
|
| + .then(function(streamInfo) {
|
| + let promises = [];
|
| + let zoomBehavior = BrowserApi.ZoomBehavior.NONE;
|
| + if (streamInfo.tabId != -1) {
|
| + zoomBehavior = streamInfo.embedded ?
|
| + BrowserApi.ZoomBehavior.PROPAGATE_PARENT :
|
| + BrowserApi.ZoomBehavior.MANAGE;
|
| + promises.push(new Promise(function(resolve) {
|
| + chrome.tabs.get(streamInfo.tabId, resolve);
|
| + }).then(function(tab) {
|
| + if (tab)
|
| + streamInfo.tabUrl = tab.url;
|
| + }));
|
| + }
|
| + if (zoomBehavior == BrowserApi.ZoomBehavior.MANAGE) {
|
| + promises.push(new Promise(function(resolve) {
|
| + chrome.tabs.setZoomSettings(
|
| + streamInfo.tabId, {mode: 'manual', scope: 'per-tab'}, resolve);
|
| + }));
|
| + }
|
| + return Promise.all(promises).then(function() {
|
| + return BrowserApi.create(streamInfo, zoomBehavior);
|
| + });
|
| + });
|
| }
|
|
|
| /**
|
| @@ -210,18 +211,19 @@ function createBrowserApiForPrintPreview() {
|
| tabId: -1,
|
| };
|
| return new Promise(function(resolve, reject) {
|
| - if (!chrome.tabs) {
|
| - resolve();
|
| - return;
|
| - }
|
| - chrome.tabs.getCurrent(function(tab) {
|
| - streamInfo.tabId = tab.id;
|
| - streamInfo.tabUrl = tab.url;
|
| - resolve();
|
| - });
|
| - }).then(function() {
|
| - return BrowserApi.create(streamInfo, BrowserApi.ZoomBehavior.NONE);
|
| - });
|
| + if (!chrome.tabs) {
|
| + resolve();
|
| + return;
|
| + }
|
| + chrome.tabs.getCurrent(function(tab) {
|
| + streamInfo.tabId = tab.id;
|
| + streamInfo.tabUrl = tab.url;
|
| + resolve();
|
| + });
|
| + })
|
| + .then(function() {
|
| + return BrowserApi.create(streamInfo, BrowserApi.ZoomBehavior.NONE);
|
| + });
|
| }
|
|
|
| /**
|
|
|