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..b22df900c03e5911bf06264b0dcf06e92acccff9 100644 |
--- a/chrome/browser/resources/pdf/pdf.js |
+++ b/chrome/browser/resources/pdf/pdf.js |
@@ -41,13 +41,14 @@ function getFilenameFromURL(url) { |
/** |
* Called when navigation happens in the current tab. |
+ * @param {int} tabId The id of the current tab; -1 if no current tab. |
Dan Beam
2015/09/25 20:57:31
there are no ints in javascript. this should be nu
wjmaclean
2015/09/28 13:29:35
Done.
|
* @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}); |
+function onNavigateInCurrentTab(tabId, 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 && tabId != -1) |
+ chrome.tabs.update(tabId, {url: url}); |
else |
window.location.href = url; |
} |
@@ -247,12 +248,18 @@ function PDFViewer(browserApi) { |
document.addEventListener('keydown', this.handleKeyEvent_.bind(this)); |
document.addEventListener('mousemove', this.handleMouseEvent_.bind(this)); |
+ var onNavigateBoundToCurrentTab = function(browserApi, url) { |
Dan Beam
2015/09/25 20:57:31
browserApi is already a local variable to this met
wjmaclean
2015/09/28 13:29:35
Acknowledged.
|
+ var tabId = browserApi ? browserApi.getStreamInfo().tabId : -1; |
Dan Beam
2015/09/25 20:57:31
you're binding this.browserApi_ from outside, and
wjmaclean
2015/09/28 13:29:35
Acknowledged.
|
+ onNavigateInCurrentTab(tabId, url); |
+ }.bind(undefined, this.browserApi_); |
+ |
// Parse open pdf parameters. |
this.paramsParser_ = |
new OpenPDFParamsParser(this.getNamedDestination_.bind(this)); |
this.navigator_ = new Navigator(this.browserApi_.getStreamInfo().originalUrl, |
this.viewport_, this.paramsParser_, |
- onNavigateInCurrentTab, onNavigateInNewTab); |
+ onNavigateBoundToCurrentTab, |
raymes
2015/09/27 23:02:02
I think you should be able to delete onNavigateBou
wjmaclean
2015/09/28 13:29:35
Ok.
I wasn't sure if it was safe to assume that t
|
+ onNavigateInNewTab); |
this.viewportScroller_ = |
new ViewportScroller(this.viewport_, this.plugin_, window); |
} |