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 8b5ef4472132ba1eee949769597b2958ab2ce8cb..85822de29c1e9e3b345d5593fda0f8947058e7b3 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); |
+ }); |
} |
/** |
@@ -171,30 +170,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); |
+ }); |
+ }); |
} |
/** |
@@ -212,18 +213,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); |
+ }); |
} |
/** |