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

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

Issue 830433002: Navigation to relative fragments does not work correctly for OOP pdf. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes after taking all nameddest at load time. Created 5 years, 11 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
Index: chrome/browser/resources/pdf/pdf.js
diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js
index a8ec3081fc0f46a7015d7ede91659ce26a14140e..9133d2a19f2ff80c3813714481d7d7093af44752 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -138,6 +138,8 @@ function PDFViewer(streamDetails) {
// Parse open pdf parameters.
var paramsParser = new OpenPDFParamsParser(this.streamDetails_.originalUrl);
this.urlParams_ = paramsParser.urlParams;
raymes 2015/01/11 23:08:41 Let's move these two lines of code into handleURLP
Deepak 2015/01/12 09:21:43 I agree, we don't need these 2 variables here.
+ // This will have name of all the nameddest from the loaded PDF.
+ this.namedDestinations_ = {};
raymes 2015/01/11 23:08:41 Rather than storing these here, maybe we can just
Deepak 2015/01/12 09:21:43 Done.
}
PDFViewer.prototype = {
@@ -380,13 +382,23 @@ PDFViewer.prototype = {
this.viewport_.goToPage(message.data.page);
break;
case 'loadProgress':
+ this.namedDestinations_ = message.data.namedDestinations;
raymes 2015/01/11 23:08:41 Let's add a new message type for named destination
Deepak 2015/01/12 09:21:43 Done. I have added a message and sending that when
this.updateProgress_(message.data.progress);
break;
case 'navigate':
- if (message.data.newTab)
- window.open(message.data.url);
- else
- window.location.href = message.data.url;
+ if (message.data.newTab) {
+ chrome.tabs.create({ url: message.data.url });
+ } else {
+ var hashIndex = message.data.url.search('#');
+ if (hashIndex != -1) {
+ var urlString = message.data.url.substring(hashIndex + 1);
+ if (this.namedDestinations_[urlString] != undefined)
+ this.viewport_.goToPage(this.namedDestinations_[urlString]);
+ } else {
+ chrome.tabs.update(this.streamDetails_.tabId,
raymes 2015/01/11 23:08:41 We don't need to use the chrome.tabs API here - th
Deepak 2015/01/12 09:21:43 window.location.href = message.data.url; is OK, Bu
+ { url: message.data.url });
+ }
+ }
raymes 2015/01/11 23:08:41 Let's move all of this code into a new function. T
Deepak 2015/01/12 09:21:43 Done.
break;
case 'setScrollPosition':
var position = this.viewport_.position;

Powered by Google App Engine
This is Rietveld 408576698