Chromium Code Reviews| Index: chrome/browser/resources/pdf/pdf.js |
| diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js |
| index c8753e14a6207dca698cd16144c70cb57dba82f9..01db1b54ca187ec5455c55cc8680e0812b61afb9 100644 |
| --- a/chrome/browser/resources/pdf/pdf.js |
| +++ b/chrome/browser/resources/pdf/pdf.js |
| @@ -44,10 +44,10 @@ function getFilenameFromURL(url) { |
| * @param {string} url The url to be opened in the current tab. |
| */ |
| function onNavigateInCurrentTab(url) { |
| - // Prefer the tabs API because it can navigate from one file:// URL to |
| - // another. |
| - if (chrome.tabs) |
| - chrome.tabs.update({url: url}); |
| + // When the PDFviewer is not inside a <webview>, prefer the tabs API because |
| + // it can navigate from one file:// URL to another. |
| + if (chrome.tabs && this.tabId_ != -1) |
| + chrome.tabs.update(this.tabId_, {url: url}); |
| else |
| window.location.href = url; |
| } |
| @@ -118,6 +118,7 @@ function PDFViewer(browserApi) { |
| this.delayedScriptingMessages_ = []; |
| + this.tabId_ = this.browserApi_.getStreamInfo().tabId; |
| this.isPrintPreview_ = this.browserApi_.getStreamInfo().originalUrl.indexOf( |
| 'chrome://print') == 0; |
| this.isMaterial_ = location.pathname.substring(1) === 'index-material.html'; |
| @@ -250,7 +251,8 @@ function PDFViewer(browserApi) { |
| // Parse open pdf parameters. |
| this.paramsParser_ = |
| new OpenPDFParamsParser(this.getNamedDestination_.bind(this)); |
| - this.navigator_ = new Navigator(this.browserApi_.getStreamInfo().originalUrl, |
| + this.navigator_ = new Navigator(this.tabId_, |
| + this.browserApi_.getStreamInfo().originalUrl, |
| this.viewport_, this.paramsParser_, |
| onNavigateInCurrentTab, onNavigateInNewTab); |
|
raymes
2015/09/24 00:09:42
can we bind the tabId to onNavigateInCurrentTab ra
|
| this.viewportScroller_ = |