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; |