Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2459)

Unified Diff: chrome/browser/resources/pdf/pdf.js

Issue 1350073002: PDFs viewed inside a <webview> should navigate the same as PDFs in tabs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass tabId to Navigator() instead of browserApi_. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/pdf/navigator.js ('k') | chrome/test/data/pdf/navigator_test.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_ =
« no previous file with comments | « chrome/browser/resources/pdf/navigator.js ('k') | chrome/test/data/pdf/navigator_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698