Chromium Code Reviews| 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 53f14b5460e770d538a8ff1eacd57811510b8bcd..ba91a8a8d51adc617e3fef7ce9c2ba6aaa14887f 100644 |
| --- a/chrome/browser/resources/pdf/browser_api.js |
| +++ b/chrome/browser/resources/pdf/browser_api.js |
| @@ -152,15 +152,25 @@ function createBrowserApiForMimeHandlerView() { |
| return new Promise(function(resolve, reject) { |
| chrome.mimeHandlerPrivate.getStreamInfo(resolve); |
| }).then(function(streamInfo) { |
| - let manageZoom = !streamInfo.embedded && streamInfo.tabId != -1; |
| return new Promise(function(resolve, reject) { |
|
Sam McNally
2016/09/07 07:53:02
I'd prefer doing both API calls in parallel. Somet
Lei Zhang
2016/09/08 01:10:31
Done. Hope I got it right. A JS presubmit check do
|
| - if (!manageZoom) { |
| - resolve(); |
| + if (streamInfo.tabId == -1) { |
| + resolve(false); |
|
raymes
2016/09/07 06:10:14
nit: Maybe just resolve() or resolve(null) since t
Lei Zhang
2016/09/08 01:10:31
Done.
|
| return; |
| } |
| - chrome.tabs.setZoomSettings( |
| - streamInfo.tabId, {mode: 'manual', scope: 'per-tab'}, resolve); |
| - }).then(function() { return BrowserApi.create(streamInfo, manageZoom); }); |
| + chrome.tabs.get(streamInfo.tabId, resolve); |
| + }).then(function(tab) { |
| + let manageZoom = !streamInfo.embedded && streamInfo.tabId != -1; |
| + return new Promise(function(resolve, reject) { |
| + if (tab) |
| + streamInfo.tabUrl = tab.url; |
| + if (!manageZoom) { |
| + resolve(); |
| + return; |
| + } |
| + chrome.tabs.setZoomSettings( |
| + streamInfo.tabId, {mode: 'manual', scope: 'per-tab'}, resolve); |
| + }).then(function() { return BrowserApi.create(streamInfo, manageZoom); }); |
|
raymes
2016/09/07 06:10:14
This looks good to me, but I'm also not great with
Lei Zhang
2016/09/08 01:10:31
Acknowledged.
|
| + }); |
| }); |
| } |
| @@ -185,6 +195,7 @@ function createBrowserApiForStandaloneExtension() { |
| } |
| chrome.tabs.getCurrent(function(tab) { |
| streamInfo.tabId = tab.id; |
| + streamInfo.tabUrl = tab.url; |
| resolve(); |
| }); |
| }).then(function() { return BrowserApi.create(streamInfo, false); }); |